diff --git a/.gitignore b/.gitignore index d7fcb019ae14a70ead3f84bbe97e01c3053acd5b..80fd850cd4483791afc19fc19732f5d0eadd8e2e 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,8 @@ pysim/ *.out *DS_Store tests/script/api/batchprepare +taosadapter +taosadapter-debug # Doxygen Generated files html/ diff --git a/.gitmodules b/.gitmodules index 31c211bf89c4ad9fe370774b4a60f1f5a6423323..7d5515f8c59b2cd9cd5099a9b55b6ca88d6ce37b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,21 +4,9 @@ [submodule "src/connector/hivemq-tdengine-extension"] path = src/connector/hivemq-tdengine-extension url = git@github.com:taosdata/hivemq-tdengine-extension.git -[submodule "deps/jemalloc"] - path = deps/jemalloc - url = https://github.com/jemalloc/jemalloc [submodule "deps/TSZ"] path = deps/TSZ url = https://github.com/taosdata/TSZ.git [submodule "examples/rust"] path = examples/rust url = https://github.com/songtianyi/tdengine-rust-bindings.git -[submodule "tools/taos-tools"] - path = tools/taos-tools - url = https://github.com/taosdata/taos-tools -[submodule "tools/taosadapter"] - path = tools/taosadapter - url = https://github.com/taosdata/taosadapter.git -[submodule "tools/taosws-rs"] - path = tools/taosws-rs - url = https://github.com/taosdata/taosws-rs diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 1b04e40f2a312f663dae2b0e9c2177618607de1f..83fa1479dc8057cc98b2132ba17be560ca341c26 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -113,6 +113,12 @@ def pre_test(){ echo "unmatched reposiotry ${CHANGE_URL}" ''' } + sh ''' + cd ${WKC} + git rm --cached tools/taos-tools 2>/dev/null || : + git rm --cached tools/taosadapter 2>/dev/null || : + git rm --cached tools/taosws-rs 2>/dev/null || : + ''' sh ''' cd ${WKC} git submodule update --init --recursive @@ -258,6 +264,13 @@ def pre_test_win(){ git branch git log -5 ''' + bat ''' + cd %WIN_COMMUNITY_ROOT% + git rm --cached tools/taos-tools 2>nul + git rm --cached tools/taosadapter 2>nul + git rm --cached tools/taosws-rs 2>nul + exit 0 + ''' bat ''' cd %WIN_COMMUNITY_ROOT% git submodule update --init --recursive diff --git a/cmake/cmake.options b/cmake/cmake.options index 51d6f530483a9571f24c0ca1ac7e31508c8ab2bf..8b33353632f16039dba2fe968caf4b912fd15143 100644 --- a/cmake/cmake.options +++ b/cmake/cmake.options @@ -84,6 +84,12 @@ ELSE () ENDIF () ENDIF () +option( + JEMALLOC_ENABLED + "If build with jemalloc" + OFF + ) + option( BUILD_SANITIZER "If build sanitizer" diff --git a/cmake/jemalloc_CMakeLists.txt.in b/cmake/jemalloc_CMakeLists.txt.in new file mode 100644 index 0000000000000000000000000000000000000000..5c5ac5c6265b9b31dc430a6d0b313fcd72bbdc5b --- /dev/null +++ b/cmake/jemalloc_CMakeLists.txt.in @@ -0,0 +1,14 @@ + +# jemalloc +ExternalProject_Add(jemalloc + GIT_REPOSITORY https://github.com/jemalloc/jemalloc.git + GIT_TAG 5.3.0 + SOURCE_DIR "${TD_CONTRIB_DIR}/jemalloc" + BINARY_DIR "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + GIT_SHALLOW true + GIT_PROGRESS true + ) diff --git a/cmake/taosadapter_CMakeLists.txt.in b/cmake/taosadapter_CMakeLists.txt.in new file mode 100644 index 0000000000000000000000000000000000000000..af3b5af4a6dea615f73ab29863b37cb14b9f4caf --- /dev/null +++ b/cmake/taosadapter_CMakeLists.txt.in @@ -0,0 +1,13 @@ + +# zlib +ExternalProject_Add(taosadapter + GIT_REPOSITORY https://github.com/taosdata/taosadapter.git + GIT_TAG df8678f + SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter" + BINARY_DIR "" + #BUILD_IN_SOURCE TRUE + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in new file mode 100644 index 0000000000000000000000000000000000000000..d430add979079486d0656544c554ec12249c69dc --- /dev/null +++ b/cmake/taostools_CMakeLists.txt.in @@ -0,0 +1,13 @@ + +# zlib +ExternalProject_Add(taos-tools + GIT_REPOSITORY https://github.com/taosdata/taos-tools.git + GIT_TAG 2.1.1 + SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" + BINARY_DIR "" + #BUILD_IN_SOURCE TRUE + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) diff --git a/cmake/taosws_CMakeLists.txt.in b/cmake/taosws_CMakeLists.txt.in new file mode 100644 index 0000000000000000000000000000000000000000..4b7c2644728fa8de0f989eafca2f914584b9b7aa --- /dev/null +++ b/cmake/taosws_CMakeLists.txt.in @@ -0,0 +1,13 @@ + +# zlib +ExternalProject_Add(taosws-rs + GIT_REPOSITORY https://github.com/taosdata/taosws-rs.git + GIT_TAG 9de599d + SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs" + BINARY_DIR "" + #BUILD_IN_SOURCE TRUE + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index e80e7e411016484632035726bb46fc663ef059ca..384cffc08c7ba85658826be20cc9276ad3177b5f 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -9,6 +9,28 @@ endfunction(cat IN_FILE OUT_FILE) set(CONTRIB_TMP_FILE "${CMAKE_BINARY_DIR}/deps_tmp_CMakeLists.txt.in") configure_file("${TD_SUPPORT_DIR}/deps_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +# taos-tools +if(${BUILD_TOOLS}) + cat("${TD_SUPPORT_DIR}/taostools_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +endif() + +# taosws-rs +if(${WEBSOCKET}) + cat("${TD_SUPPORT_DIR}/taosws_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +endif() + +# taosadapter +if(${BUILD_HTTP}) + MESSAGE("BUILD_HTTP is on") +else () + MESSAGE("BUILD_HTTP is off, use taosAdapter") + cat("${TD_SUPPORT_DIR}/taosadapter_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +endif() + +if(TD_LINUX_64 AND JEMALLOC_ENABLED) + cat("${TD_SUPPORT_DIR}/jemalloc_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +endif() + # pthread if(${BUILD_PTHREAD}) cat("${TD_SUPPORT_DIR}/pthread_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) @@ -381,6 +403,18 @@ if(${BUILD_ADDR2LINE}) endif(NOT ${TD_WINDOWS}) endif(${BUILD_ADDR2LINE}) +# jemalloc +IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + include(ExternalProject) + ExternalProject_Add(jemalloc + PREFIX "jemalloc" + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jemalloc + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/build/ + BUILD_COMMAND ${MAKE} + ) + INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/build/include) +ENDIF () # ================================================================================================ # Build test diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md index 129b7eb0c35b4409e8003855fb4facacb8e0c830..c5cbf5a70b7e49324ebb1e08cb31eac9098a74d6 100644 --- a/docs/en/12-taos-sql/10-function.md +++ b/docs/en/12-taos-sql/10-function.md @@ -15,9 +15,9 @@ Single-Row functions return a result row for each row in the query result. SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The absolute of a specific column. +**Description**: The absolute value of a specific field. -**Return value type**: UBIGINT if the input value is integer; DOUBLE if the input value is FLOAT/DOUBLE. +**Return value type**: Same as input type. **Applicable data types**: Numeric types. @@ -26,7 +26,7 @@ SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] **Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions. +- Cannot be used with aggregate functions. #### ACOS @@ -34,18 +34,18 @@ SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The anti-cosine of a specific column +**Description**: The anti-cosine of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Cannot be used with aggregate functions. #### ASIN @@ -53,18 +53,18 @@ SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The anti-sine of a specific column +**Description**: The anti-sine of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. **Applicable table types**: table, STable -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Cannot be used with aggregate functions. #### ATAN @@ -72,20 +72,18 @@ SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: anti-tangent of a specific column - -**Description**: The anti-cosine of a specific column +**Description**: anti-tangent of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. **Applicable table types**: table, STable -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Cannot be used with aggregate functions. #### CEIL @@ -93,19 +91,18 @@ SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The rounded up value of a specific column +**Description**: The rounded up value of a specific field. -**Return value type**: Same as the column being used +**Return value type**: Same as input type. **Applicable data types**: Numeric types. **Applicable table types**: table, STable -**Applicable nested query**: Inner query and outer query +**Applicable nested query**: Inner query and outer query. **More explanations**: -- Arithmetic operation can be performed on the result of `ceil` function -- Can't be used with aggregate functions +- Can't be used with aggregate functions. #### COS @@ -113,20 +110,18 @@ SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The cosine of a specific column +**Description**: The cosine of a specific field. -**Description**: The anti-cosine of a specific column - -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Can't be used with aggregate functions. #### FLOOR @@ -134,9 +129,9 @@ SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The rounded down value of a specific column +**Description**: The rounded down value of a specific field. -**More explanations**: The restrictions are same as those of the `CEIL` function. +**More explanations**: Refer to `CEIL` function for usage restrictions. #### LOG @@ -144,15 +139,15 @@ SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The log of a specific with `base` as the radix +**Description**: The logarithm of a specific field with `base` as the radix. If `base` parameter is ignored, natural logarithm of the field is returned. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: - Can't be used with aggregate functions @@ -163,18 +158,18 @@ SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause] SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The power of a specific column with `power` as the index +**Description**: The power of a specific field with `power` as the index. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Can't be used with aggregate functions. #### ROUND @@ -182,9 +177,9 @@ SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The rounded value of a specific column. +**Description**: The rounded value of a specific field. -**More explanations**: The restrictions are same as `CEIL` function. +**More explanations**: Refer to `CEIL` function for usage restrictions. #### SIN @@ -192,20 +187,20 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The sine of a specific column +**Description**: The sine of a specific field. -**Description**: The anti-cosine of a specific column +**Description**: The anti-cosine of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Can't be used with aggregate functions. #### SQRT @@ -213,18 +208,18 @@ SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The square root of a specific column +**Description**: The square root of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Can't be used with aggregate functions. #### TAN @@ -232,20 +227,20 @@ SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The tangent of a specific column +**Description**: The tangent of a specific field. -**Description**: The anti-cosine of a specific column +**Description**: The anti-cosine of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Can't be used with aggregate functions. ### String Functions @@ -257,19 +252,16 @@ String functiosn take strings as input and output numbers or strings. SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The length in number of characters of a string +**Description**: The mumber of characters of a string. -**Return value type**: Integer +**Return value type**: INTEGER. -**Applicable data types**: VARCHAR or NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable - -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations** +**Applicable nested query**: Inner query and Outer query. -- If the input value is NULL, the output is NULL too #### CONCAT @@ -277,15 +269,16 @@ SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The concatenation result of two or more strings, the number of strings to be concatenated is at least 2 and at most 8 +**Description**: The concatenation result of two or more strings. -**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. +**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. If input strings contain NULL value, the result is NULL. **Applicable data types**: VARCHAR, NCHAR. At least 2 input strings are requird, and at most 8 input strings are allowed. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. + +**Applicable nested query**: Inner query and Outer query. -**Applicable nested query**: Inner query and Outer query #### CONCAT_WS @@ -293,19 +286,16 @@ SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHER SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The concatenation result of two or more strings with separator, the number of strings to be concatenated is at least 3 and at most 9 +**Description**: The concatenation result of two or more strings with separator. -**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. +**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. If input strings contain NULL value, the result is NULL. **Applicable data types**: VARCHAR, NCHAR. At least 3 input strings are requird, and at most 9 input strings are allowed. -**Applicable table types**: table, STable - -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations**: +**Applicable nested query**: Inner query and Outer query. -- If the value of `separator` is NULL, the output is NULL. If the value of `separator` is not NULL but other input are all NULL, the output is empty string. #### LENGTH @@ -313,18 +303,16 @@ SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | st SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The length in bytes of a string +**Description**: The length in bytes of a string. -**Return value type**: Integer +**Return value type**: INTEGER. -**Applicable data types**: VARCHAR or NCHAR -**Applicable table types**: table, STable +**Applicable data types**: VARCHAR, NCHAR. -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations** +**Applicable nested query**: Inner query and Outer query. -- If the input value is NULL, the output is NULL too #### LOWER @@ -332,19 +320,16 @@ SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: Convert the input string to lower case - -**Return value type**: Same as input +**Description**: Convert the input string to lower case. -**Applicable data types**: VARCHAR or NCHAR +**Return value type**: Same as input type. -**Applicable table types**: table, STable +**Applicable data types**: VARCHAR, NCHAR. -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations** +**Applicable nested query**: Inner query and Outer query. -- If the input value is NULL, the output is NULL too #### LTRIM @@ -352,19 +337,16 @@ SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: Remove the left leading blanks of a string +**Description**: Remove the left leading blanks of a string. -**Return value type**: Same as input +**Return value type**: Same as input type. -**Applicable data types**: VARCHAR or NCHAR - -**Applicable table types**: table, STable +**Applicable data types**: VARCHAR, NCHAR. -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations** +**Applicable nested query**: Inner query and Outer query. -- If the input value is NULL, the output is NULL too #### RTRIM @@ -372,19 +354,16 @@ SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: Remove the right tailing blanks of a string +**Description**: Remove the right tailing blanks of a string. -**Return value type**: Same as input +**Return value type**: Same as input type. -**Applicable data types**: VARCHAR or NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable - -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations** +**Applicable nested query**: Inner query and Outer query. -- If the input value is NULL, the output is NULL too #### SUBSTR @@ -392,21 +371,21 @@ SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The sub-string starting from `pos` with length of `len` from the original string `str` +**Description**: The sub-string starting from `pos` with length of `len` from the original string `str`. -**Return value type**: Same as input +**Return value type**: Same as input type. -**Applicable data types**: VARCHAR or NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: - If the input is NULL, the output is NULL - Parameter `pos` can be an positive or negative integer; If it's positive, the starting position will be counted from the beginning of the string; if it's negative, the starting position will be counted from the end of the string. -- If `len` is not specified, it means from `pos` to the end. +- If `len` is not specified, it means from `pos` to the end of string. #### UPPER @@ -414,23 +393,20 @@ SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: Convert the input string to upper case +**Description**: Convert the input string to upper case. -**Return value type**: Same as input +**Return value type**: Same as input type. -**Applicable data types**: VARCHAR or NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable - -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations** +**Applicable nested query**: Inner query and Outer query. -- If the input value is NULL, the output is NULL too ### Conversion Functions -This kind of functions convert from one data type to another one. +Conversion functions convert from one data type to another. #### CAST @@ -438,43 +414,38 @@ This kind of functions convert from one data type to another one. SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: It's used for type casting. The input parameter `expression` can be data columns, constants, scalar functions or arithmetic between them. +**Description**: Used for type casting. Convert `expression` to the type specified by `type_name`. -**Return value type**: The type specified by parameter `type_name` +**Return value type**: The type specified by parameter `type_name`. -**Applicable data types**: - -- Parameter `expression` can be any data type except for JSON -- The output data type specified by `type_name` can only be one of BIGINT/VARCHAR(N)/TIMESTAMP/NCHAR(N)/BIGINT UNSIGNED +**Applicable data types**: `expression` can be any data type except for JSON. **More explanations**: -- Error will be reported for unsupported type casting -- NULL will be returned if the input value is NULL +- Error will be reported for unsupported type casting. - Some values of some supported data types may not be casted, below are known issues: 1)When casting VARCHAR/NCHAR to BIGINT/BIGINT UNSIGNED, some characters may be treated as illegal, for example "a" may be converted to 0. - 2)There may be overflow when casting singed integer or TIMESTAMP to unsigned BIGINT - 3)There may be overflow when casting unsigned BIGINT to BIGINT - 4)There may be overflow when casting FLOAT/DOUBLE to BIGINT or UNSIGNED BIGINT + 2)When casting to numeric type, if converted result is out of range the destination data type can hold, overflow may occur and casting behavior is undefined. + 3) When casting to VARCHAR/NCHAR type, if converted string length exceeds the length specified in `type_name`, the result will be truncated. (e.g. CAST("abcd" as BINARY(2)) will return string "ab"). #### TO_ISO8601 ```sql -SELECT TO_ISO8601(ts_val | ts_col) FROM { tb_name | stb_name } [WHERE clause]; +SELECT TO_ISO8601(ts[, timezone]) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The ISO8601 date/time format converted from a UNIX timestamp, plus the timezone of the client side system +**Description**: The ISO8601 date/time format converted from a UNIX timestamp, with timezone attached. `timezone` parameter allows attaching any customized timezone string to the output format. If `timezone` parameter is not specified, the timezone information of client side system will be attached. -**Return value type**: VARCHAR +**Return value type**: VARCHAR. -**Applicable column types**: TIMESTAMP, constant or a column +**Applicable data types**: INTEGER, TIMESTAMP. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- If the input is UNIX timestamp constant, the precision of the returned value is determined by the digits of the input timestamp -- If the input is a column of TIMESTAMP type, The precision of the returned value is same as the precision set for the current data base in use +- If the input is INTEGER represents UNIX timestamp, the precision of the returned value is determined by the digits of the input integer. +- If the input is of TIMESTAMP type, The precision of the returned value is same as the precision set for the current database in use. #### TO_JSON @@ -482,13 +453,13 @@ SELECT TO_ISO8601(ts_val | ts_col) FROM { tb_name | stb_name } [WHERE clause]; SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: Convert a JSON string to a JSON body。 +**Description**: Convert a JSON string to a JSON body. -**Return value type**: JSON +**Return value type**: JSON. -**Applicable column types**: JSON string, in the format like '{ "literal" : literal }'. '{}' is NULL value. keys in the string must be string constants, values can be constants of numeric types, bool, string or NULL. Escaping characters are not allowed in the JSON string. +**Applicable data types**: JSON string, in the format like '{ "literal" : literal }'. '{}' is NULL value. keys in the string must be string constants, values can be constants of numeric types, bool, string or NULL. Escaping characters are not allowed in the JSON string. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **Applicable nested query**: Inner query and Outer query. @@ -498,22 +469,22 @@ SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause]; SELECT TO_UNIXTIMESTAMP(datetime_string | ts_col) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: UNIX timestamp converted from a string of date/time format +**Description**: UNIX timestamp converted from a string of date/time format. -**Return value type**: Long integer +**Return value type**: BIGINT. -**Applicable column types**: Constant or column of VARCHAR/NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- The input string must be compatible with ISO8601/RFC3339 standard, 0 will be returned if the string can't be converted -- The precision of the returned timestamp is same as the precision set for the current data base in use +- The input string must be compatible with ISO8601/RFC3339 standard, NULL will be returned if the string cannot be converted. +- The precision of the returned timestamp is same as the precision set for the current database in use. ### DateTime Functions -This kind of functiosn oeprate on timestamp data. NOW(), TODAY() and TIMEZONE() are executed only once even though they may occurr multiple times in a single SQL statement. +DateTime functions applied to timestamp data. NOW(), TODAY() and TIMEZONE() are executed only once even though they may occur multiple times in a single SQL statement. #### NOW @@ -523,39 +494,39 @@ SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior NOW() INSERT INTO tb_name VALUES (NOW(), ...); ``` -**Description**: The current time of the client side system +**Description**: The current time of the client side system. -**Return value type**: TIMESTAMP +**Return value type**: TIMESTAMP. -**Applicable column types**: TIMESTAMP only +**Applicable data types**: TIMESTAMP only if used in WHERE/INSERT clause. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- Add and Subtract operation can be performed, for example NOW() + 1s, the time unit can be: - b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week) -- The precision of the returned timestamp is same as the precision set for the current data base in use +- Addition and Subtraction operation with time duration can be performed, for example NOW() + 1s, the time unit can be one of the followings: + b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week). +- The precision of the returned timestamp is same as the precision set for the current database in use. #### TIMEDIFF ```sql -SELECT TIMEDIFF(ts_val1 | datetime_string1 | ts_col1, ts_val2 | datetime_string2 | ts_col2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause]; +SELECT TIMEDIFF(ts1 | datetime_string1, ts2 | datetime_string2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The difference between two timestamps, and rounded to the time unit specified by `time_unit` +**Description**: The difference(duration) between two timestamps, and rounded to the time unit specified by `time_unit`. -**Return value type**: Long Integer +**Return value type**: BIGINT. -**Applicable column types**: UNIX timestamp constant, string constant of date/time format, or a column of TIMESTAMP type +**Applicable data types**: INTEGER/TIMESTAMP represents UNIX timestamp, or VARCHAR/NCHAR string in date/time format. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: - Time unit specified by `time_unit` can be: - 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day). -- The precision of the returned timestamp is same as the precision set for the current data base in use + 1b(nanosecond), 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day),1w(week). +- If `time_unit` parameter is not specified, the precision of the returned time duration is same as the precision set for the current database in use. #### TIMETRUNCATE @@ -563,19 +534,19 @@ SELECT TIMEDIFF(ts_val1 | datetime_string1 | ts_col1, ts_val2 | datetime_string2 SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: Truncate the input timestamp with unit specified by `time_unit` +**Description**: Truncate the input timestamp with unit specified by `time_unit`. -**Return value type**: TIMESTAMP +**Return value type**: TIMESTAMP. -**Applicable column types**: UNIX timestamp constant, string constant of date/time format, or a column of timestamp +**Applicable data types**: INTEGER/TIMESTAMP represents UNIX timestamp, or VARCHAR/NCHAR string in date/time format. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: - Time unit specified by `time_unit` can be: - 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day). -- The precision of the returned timestamp is same as the precision set for the current data base in use + 1b(nanosecond),1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day),1w(week). +- The precision of the returned timestamp is same as the precision set for the current database in use. #### TIMEZONE @@ -583,13 +554,13 @@ SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name SELECT TIMEZONE() FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The timezone of the client side system +**Description**: The timezone of the client side system. -**Return value type**: VARCHAR +**Return value type**: VARCHAR. -**Applicable column types**: None +**Applicable data types**: None. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. #### TODAY @@ -599,37 +570,60 @@ SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior TODAY INSERT INTO tb_name VALUES (TODAY(), ...); ``` -**Description**: The timestamp of 00:00:00 of the client side system +**Description**: The timestamp of 00:00:00 of the client side system. -**Return value type**: TIMESTAMP +**Return value type**: TIMESTAMP. -**Applicable column types**: TIMESTAMP only +**Applicable data types**: TIMESTAMP only if used in WHERE/INSERT clause. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- Add and Subtract operation can be performed, for example NOW() + 1s, the time unit can be: - b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week) -- The precision of the returned timestamp is same as the precision set for the current data base in use +- Addition and Subtraction operation can be performed with time durations, for example NOW() + 1s, the time unit can be: + b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week). +- The precision of the returned timestamp is same as the precision set for the current database in use. ## Aggregate Functions Aggregate functions return single result row for each group in the query result set. Groups are determined by `GROUP BY` clause or time window clause if they are used; or the whole result is considered a group if neither of them is used. +### APERCENTILE + +``` +SELECT APERCENTILE(field_name, P[, algo_type]) +FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: Similar to `PERCENTILE`, but a approximated result is returned. + +**Return value type**: DOUBLE. + +**Applicable column types**: Numeric types. + +**Applicable table types**: table, STable. + +**More explanations** + +- _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. +- **algo_type** can only be input as `default` or `t-digest`, if it's not specified `default` will be used, i.e. `apercentile(column_name, 50)` is same as `apercentile(column_name, 50, "default")`. +- If `default` is used, histogram based algorithm is used for calculation. If `t-digest` is used, `t-digest` sampling algorithm is used to calculate the result. + +**Nested query**: It can be used in both the outer query and inner query in a nested query. + ### AVG ``` SELECT AVG(field_name) FROM tb_name [WHERE clause]; ``` -**Description**: Get the average value of a column in a table or STable +**Description**: Get the average value of a column in a table or STable. -**Return value type**: Double precision floating number +**Return value type**: DOUBLE. -**Applicable column types**: Numeric type +**Applicable data types**: Numeric type. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. ### COUNT @@ -637,17 +631,17 @@ SELECT AVG(field_name) FROM tb_name [WHERE clause]; SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; ``` -**Description**: Get the number of rows or the number of non-null values in a table or a super table. +**Description**: Get the number of rows in a table or a super table. -**Return value type**: Long integer INT64 +**Return value type**: BIGINT. -**Applicable column types**: All +**Applicable data types**: All data types. -**Applicable table types**: table, super table, sub table +**Applicable table types**: table, STable. **More explanation**: -- Wildcard (\*) is used to represent all columns. The `COUNT` function is used to get the total number of all rows. +- Wildcard (\*) is used to represent all columns. If \* used `COUNT` function will get the total number of all rows. - The number of non-NULL values will be returned if this function is used on a specific column. ### ELAPSED @@ -656,13 +650,13 @@ SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; SELECT ELAPSED(field_name[, time_unit]) FROM { tb_name | stb_name } [WHERE clause] [INTERVAL(interval [, offset]) [SLIDING sliding]]; ``` -**Description**:`elapsed` function can be used to calculate the continuous time length in which there is valid data. If it's used with `INTERVAL` clause, the returned result is the calcualted time length within each time window. If it's used without `INTERVAL` caluse, the returned result is the calculated time length within the specified time range. Please be noted that the return value of `elapsed` is the number of `time_unit` in the calculated time length. +**Description**:`elapsed` function can be used to calculate the continuous time length in which there is valid data. If it's used with `INTERVAL` clause, the returned result is the calcualted time length within each time window. If it's used without `INTERVAL` caluse, the returned result is the calculated time duration within the specified time range. Please be noted that the calculated time duration is in the specified `time_unit`. -**Return value type**:Double +**Return value type**:DOUBLE. -**Applicable Column type**:Timestamp +**Applicable Column type**:TIMESTAMP. -**Applicable tables**: table, STable, outter in nested query +**Applicable tables**: table, STable, outter in nested query. **Explanations**: @@ -673,7 +667,7 @@ SELECT ELAPSED(field_name[, time_unit]) FROM { tb_name | stb_name } [WHERE claus - `group by tbname` must be used together when `elapsed` is used against a STable. - `group by` must NOT be used together when `elapsed` is used against a table or sub table. - When used in nested query, it's only applicable when the inner query outputs an implicit timestamp column as the primary key. For example, `select elapsed(ts) from (select diff(value) from sub1)` is legal usage while `select elapsed(ts) from (select * from sub1)` is not. -- It can't be used with `leastsquares`, `diff`, `derivative`, `top`, `bottom`, `last_row`, `interp`. +- It cannot be used with `leastsquares`, `diff`, `derivative`, `top`, `bottom`, `last_row`, `interp`. ### LEASTSQUARES @@ -683,25 +677,11 @@ SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause] **Description**: The linear regression function of the specified column and the timestamp column (primary key), `start_val` is the initial value and `step_val` is the step value. -**Return value type**: A string in the format of "(slope, intercept)" - -**Applicable column types**: Numeric types - -**Applicable table types**: table only - -### MODE - -``` -SELECT MODE(field_name) FROM tb_name [WHERE clause]; -``` - -**Description**:The value which has the highest frequency of occurrence. NULL is returned if there are multiple values which have highest frequency of occurrence. It can't be used on timestamp column. - -**Return value type**:Same as the data type of the column being operated upon +**Return value type**: VARCHAR string in the format of "(slope, intercept)". -**Applicable column types**:Data types except for timestamp +**Applicable data types**: Numeric types. -**More explanations**:Considering the number of returned result set is unpredictable, it's suggested to limit the number of unique values to 100,000, otherwise error will be returned. +**Applicable table types**: table only. ### SPREAD @@ -709,15 +689,15 @@ SELECT MODE(field_name) FROM tb_name [WHERE clause]; SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The difference between the max and the min of a specific column +**Description**: The difference between the max and the min value of a specific column. -**Return value type**: Double precision floating point +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**More explanations**: Can be used on a column of TIMESTAMP type, the result is the time range size. +**More explanations**: Can be used on a column of TIMESTAMP type, the result time unit precision is same as the current database in use. ### STDDEV @@ -725,13 +705,13 @@ SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; ``` -**Description**: Standard deviation of a specific column in a table or STable +**Description**: Standard deviation of a specific column in a table or STable. -**Return value type**: Double precision floating number +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. ### SUM @@ -739,13 +719,13 @@ SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; SELECT SUM(field_name) FROM tb_name [WHERE clause]; ``` -**Description**: The sum of a specific column in a table or STable +**Description**: The summation of values of a specific column in a table or STable. -**Return value type**: Double precision floating number or long integer +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. ### HYPERLOGLOG @@ -755,9 +735,9 @@ SELECT HYPERLOGLOG(field_name) FROM { tb_name | stb_name } [WHERE clause]; **Description**:The cardinal number of a specific column is returned by using hyperloglog algorithm. -**Return value type**:Integer +**Return value type**: INTEGER. -**Applicable column types**:Any data type +**Applicable column types**: All data types. **More explanations**: The benefit of using hyperloglog algorithm is that the memory usage is under control when the data volume is huge. However, when the data volume is very small, the result may be not accurate, it's recommented to use `select count(data) from (select unique(col) as data from table)` in this case. @@ -769,16 +749,16 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam **Description**:Returns count of data points in user-specified ranges. -**Return value type**:Double or INT64, depends on normalized parameter settings. +**Return value type**:DOUBLE or BIGINT, depends on normalized parameter settings. **Applicable column type**:Numerical types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **Explanations**: 1. bin_type: parameter to indicate the bucket type, valid inputs are: "user_input", "linear_bin", "log_bin"。 -2. bin_description: parameter to describe how to generate buckets,can be in the following JSON formats for each bin_type respectively: +2. bin_description: parameter to describe the rule to generate buckets,can be in the following JSON formats for each bin_type respectively: - "user_input": "[1, 3, 5, 7]": User specified bin values. @@ -798,32 +778,25 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam 3. normalized: setting to 1/0 to turn on/off result normalization. -## Selector Functions - -Selector functiosn choose one or more rows in the query result set to retrun according toe the semantics. You can specify to output ts column and other columns including tbname and tags so that you can easily know which rows the selected values belong to. - -### APERCENTILE +### PERCENTILE ``` -SELECT APERCENTILE(field_name, P[, algo_type]) -FROM { tb_name | stb_name } [WHERE clause] +SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; ``` -**Description**: Similar to `PERCENTILE`, but a simulated result is returned +**Description**: The value whose rank in a specific column matches the specified percentage. If such a value matching the specified percentage doesn't exist in the column, an interpolation value will be returned. -**Return value type**: Double precision floating point +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table. -**More explanations** +**More explanations**: _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. -- _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. -- **algo_type** can only be input as `default` or `t-digest`, if it's not specified `default` will be used, i.e. `apercentile(column_name, 50)` is same as `apercentile(column_name, 50, "default")`. -- When `t-digest` is used, `t-digest` sampling is used to calculate. +## Selector Functions -**Nested query**: It can be used in both the outer query and inner query in a nested query. +Selector functiosn choose one or more rows in the query result according to the semantics. You can specify to output primary timestamp column and other columns including tbname and tags so that you can easily know which rows the selected values belong to. ### BOTTOM @@ -833,17 +806,17 @@ SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; **Description**: The least _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- _k_ must be in range [1,100] -- The timestamp associated with the selected values are returned too -- Can't be used with `FILL` +- _k_ must be in range [1,100]. +- The timestamp associated with the selected values are returned too. +- Can't be used with `FILL`. ### FIRST @@ -851,13 +824,13 @@ SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The first non-null value of a specific column in a table or STable +**Description**: The first non-null value of a specific column in a table or STable. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Any data type +**Applicable column types**: All data types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: @@ -873,11 +846,11 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ **Description**: The value that matches the specified timestamp range is returned, if existing; or an interpolation value is returned. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Numeric data types +**Applicable column types**: Numeric data types. -**Applicable table types**: table, STable, nested query +**Applicable table types**: table, STable, nested query. **More explanations** @@ -895,13 +868,13 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The last non-NULL value of a specific column in a table or STable +**Description**: The last non-NULL value of a specific column in a table or STable. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Any data type +**Applicable column types**: All data types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: @@ -915,18 +888,18 @@ SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; ``` -**Description**: The last row of a table or STable +**Description**: The last row of a table or STable. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Any data type +**Applicable column types**: All data type. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: - When it's used against a STable, multiple rows with the same and largest timestamp may exist, in this case one of them is returned randomly and it's not guaranteed that the result is same if the query is run multiple times. -- Can't be used with `INTERVAL`. +- Cannot be used with `INTERVAL`. ### MAX @@ -934,13 +907,13 @@ SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The maximum value of a specific column of a table or STable +**Description**: The maximum value of a specific column of a table or STable. -**Return value type**: Same as the data type of the column being operated upon +**Return value type**: Same as the data type of the column being operated upon. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. ### MIN @@ -948,29 +921,48 @@ SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; ``` -**Description**: The minimum value of a specific column in a table or STable +**Description**: The minimum value of a specific column in a table or STable. -**Return value type**: Same as the data type of the column being operated upon +**Return value type**: Same as the data type of the column being operated upon. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -### PERCENTILE +### MODE ``` -SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; +SELECT MODE(field_name) FROM tb_name [WHERE clause]; ``` -**Description**: The value whose rank in a specific column matches the specified percentage. If such a value matching the specified percentage doesn't exist in the column, an interpolation value will be returned. +**Description**:The value which has the highest frequency of occurrence. NULL is returned if there are multiple values which have highest frequency of occurrence. -**Return value type**: Double precision floating point +**Return value type**:Same as the data type of the column being operated upon. -**Applicable column types**: Numeric types +**Applicable column types**: All data types. -**Applicable table types**: table +**More explanations**:Considering the number of returned result set is unpredictable, it's suggested to limit the number of unique values to 100,000, otherwise error will be returned. -**More explanations**: _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. +### SAMPLE + +```sql + SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: _k_ sampling values of a specific column. The applicable range of _k_ is [1,1000]. + +**Return value type**: Same as the column being operated. + +**Applicable data types**: All data types. + +**Applicable table types**: table, STable. + +**Applicable nested query**: Inner query and Outer query. + +**More explanations**: + +- Arithmetic operation cannot be operated on the result of `SAMPLE` function +- Must be used with `Partition by tbname` when it's used on a STable to force the result on each single timeline. ### TAIL @@ -980,11 +972,11 @@ SELECT TAIL(field_name, k, offset_val) FROM {tb_name | stb_name} [WHERE clause]; **Description**: The next _k_ rows are returned after skipping the last `offset_val` rows, NULL values are not ignored. `offset_val` is optional parameter. When it's not specified, the last _k_ rows are returned. When `offset_val` is used, the effect is same as `order by ts desc LIMIT k OFFSET offset_val`. -**Parameter value range**: k: [1,100] offset_val: [0,100] +**Parameter value range**: k: [1,100] offset_val: [0,100]. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Any data type except form timestamp, i.e. the primary key +**Applicable column types**: All data types. ### TOP @@ -994,17 +986,17 @@ SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; **Description**: The greatest _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- _k_ must be in range [1,100] -- The timestamp associated with the selected values are returned too -- Can't be used with `FILL` +- _k_ must be in range [1,100]. +- The timestamp associated with the selected values are returned too. +- Cannot be used with `FILL`. ### UNIQUE @@ -1014,9 +1006,9 @@ SELECT UNIQUE(field_name) FROM {tb_name | stb_name} [WHERE clause]; **Description**: The values that occur the first time in the specified column. The effect is similar to `distinct` keyword, but it can also be used to match tags or timestamp. -**Return value type**: Same as the column or tag being operated upon +**Return value type**: Same as the column or tag being operated upon. -**Applicable column types**: Any data types except for timestamp +**Applicable column types**: All data types. **More explanations**: @@ -1035,18 +1027,18 @@ TDengine provides a set of time-series specific functions to better meet the req **Description**: The cumulative sum of each row for a specific column. The number of output rows is same as that of the input rows. -**Return value type**: Long integer for integers; Double for floating points. Timestamp is returned for each row. +**Return value type**: BIGINT for signed integer input types; UNSIGNED BIGINT for unsigned integer input types; DOUBLE for floating point input types. -**Applicable data types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Arithmetic operation can't be performed on the result of `csum` function -- Can only be used with aggregate functions -- `Group by tbname` must be used together on a STable to force the result on a single timeline +- Arithmetic operation cannot be performed on the result of `csum` function. +- Can only be used with aggregate functions. +- `Partition by tbname` must be used together on a STable to force the result on a single timeline. ### DERIVATIVE @@ -1056,16 +1048,17 @@ SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHER **Description**: The derivative of a specific column. The time rage can be specified by parameter `time_interval`, the minimum allowed time range is 1 second (1s); the value of `ignore_negative` can be 0 or 1, 1 means negative values are ignored. -**Return value type**: Double precision floating point +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: - The number of result rows is the number of total rows in the time range subtracted by one, no output for the first row. -- It can be used together with `GROUP BY tbname` against a STable. +- It can be used together with `PARTITION BY tbname` against a STable. +- Can be used together with selection of relative columns. E.g. select \_rowts, DERIVATIVE() from. ### DIFF @@ -1075,16 +1068,17 @@ SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHER **Description**: The different of each row with its previous row for a specific column. `ignore_negative` can be specified as 0 or 1, the default value is 1 if it's not specified. `1` means negative values are ignored. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- The number of result rows is the number of rows subtracted by one, no output for the first row -- It can be used on STable with `GROUP by tbname` +- The number of result rows is the number of rows subtracted by one, no output for the first row. +- It can be used on STable with `PARTITION by tbname`. +- Can be used together with selection of relative columns. E.g. select \_rowts, DIFF() from. ### IRATE @@ -1094,15 +1088,15 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; **Description**: instantaneous rate on a specific column. The last two samples in the specified time range are used to calculate instantaneous rate. If the last sample value is smaller, then only the last sample value is used instead of the difference between the last two sample values. -**Return value type**: Double precision floating number +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- It can be used on stble with `GROUP BY`, i.e. timelines generated by `GROUP BY tbname` on a STable. +- It can be used on stble with `PARTITION BY`, i.e. timelines generated by `PARTITION BY tbname` on a STable. ### MAVG @@ -1112,40 +1106,19 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; **Description**: The moving average of continuous _k_ values of a specific column. If the number of input rows is less than _k_, nothing is returned. The applicable range of _k_ is [1,1000]. -**Return value type**: Double precision floating point +**Return value type**: DOUBLE. -**Applicable data types**: Numeric types - -**Applicable nested query**: Inner query and Outer query - -**Applicable table types**: table, STable - -**More explanations**: - -- Arithmetic operation can't be performed on the result of `MAVG`. -- Can't be used with aggregate functions. -- Must be used with `GROUP BY tbname` when it's used on a STable to force the result on each single timeline. - -### SAMPLE - -```sql - SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] -``` - -**Description**: _k_ sampling values of a specific column. The applicable range of _k_ is [1,10000] - -**Return value type**: Same as the column being operated plus the associated timestamp - -**Applicable data types**: Any data type except for tags of STable +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable nested query**: Inner query and Outer query. -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. **More explanations**: -- Arithmetic operation can't be operated on the result of `SAMPLE` function -- Must be used with `Group by tbname` when it's used on a STable to force the result on each single timeline +- Arithmetic operation cannot be performed on the result of `MAVG`. +- Cannot be used with aggregate functions. +- Must be used with `PARTITION BY tbname` when it's used on a STable to force the result on each single timeline. ### STATECOUNT @@ -1153,25 +1126,25 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The number of continuous rows satisfying the specified conditions for a specific column. The result is shown as an extra column for each row. If the specified condition is evaluated as true, the number is increased by 1; otherwise the number is reset to -1. If the input value is NULL, then the corresponding row is skipped. +**Description**: The number of continuous rows satisfying the specified conditions for a specific column. If the specified condition is evaluated as true, the number is increased by 1; otherwise the number is reset to -1. If the input value is NULL, then the corresponding row is skipped. **Applicable parameter values**: -- oper : Can be one of LT (lower than), GT (greater than), LE (lower than or euqal to), GE (greater than or equal to), NE (not equal to), EQ (equal to), the value is case insensitive -- val : Numeric types +- oper : Can be one of "LT" (lower than), "GT" (greater than), "LE" (lower than or euqal to), "GE" (greater than or equal to), "NE" (not equal to), "EQ" (equal to). +- val : Numeric types. -**Return value type**: Integer +**Return value type**: INTEGER. -**Applicable data types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Outer query only +**Applicable nested query**: Outer query only. **More explanations**: -- Must be used together with `GROUP BY tbname` when it's used on a STable to force the result into each single timeline] -- Can't be used with window operation, like interval/state_window/session_window +- Must be used together with `PARTITION BY tbname` when it's used on a STable to force the result into each single timeline. +- Cannot be used with window operation, like interval/state_window/session_window. ### STATEDURATION @@ -1179,26 +1152,26 @@ SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clau SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The length of time range in which all rows satisfy the specified condition for a specific column. The result is shown as an extra column for each row. The length for the first row that satisfies the condition is 0. Next, if the condition is evaluated as true for a row, the time interval between current row and its previous row is added up to the time range; otherwise the time range length is reset to -1. If the value of the column is NULL, the corresponding row is skipped. +**Description**: The length of time range in which all rows satisfy the specified condition for a specific column. The length for the first row that satisfies the condition is 0. Next, if the condition is evaluated as true for a row, the time interval between current row and its previous row is added up to the time range; otherwise the time range length is reset to -1. If the value of the column is NULL, the corresponding row is skipped. **Applicable parameter values**: -- oper : Can be one of LT (lower than), GT (greater than), LE (lower than or euqal to), GE (greater than or equal to), NE (not equal to), EQ (equal to), the value is case insensitive -- val : Numeric types -- unit: The unit of time interval, can be [1s, 1m, 1h], default is 1s +- oper : Can be one of "LT" (lower than), "GT" (greater than), "LE" (lower than or euqal to), "GE" (greater than or equal to), "NE" (not equal to), "EQ" (equal to). +- val : Numeric types. +- unit : The unit of time interval, can be: 1b(nanosecond), 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day),1w(week). If not specified, default is same as the current database time precision in use. -**Return value type**: Integer +**Return value type**: INTEGER. -**Applicable data types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Outer query only +**Applicable nested query**: Outer query only. **More explanations**: -- Must be used together with `GROUP BY tbname` when it's used on a STable to force the result into each single timeline] -- Can't be used with window operation, like interval/state_window/session_window +- Must be used together with `PARTITION BY tbname` when it's used on a STable to force the result into each single timeline. +- Cannot be used with window operation, like interval/state_window/session_window. ### TWA @@ -1206,17 +1179,17 @@ SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [W SELECT TWA(field_name) FROM tb_name WHERE clause; ``` -**Description**: Time weighted average on a specific column within a time range +**Description**: Time weighted average on a specific column within a time range. -**Return value type**: Double precision floating number +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- It can be used on stable with `GROUP BY`, i.e. timelines generated by `GROUP BY tbname` on a STable. +- It can be used on stable with `PARTITION BY`, i.e. timelines generated by `PARTITION BY tbname` on a STable. ## System Information Functions diff --git a/docs/zh/05-get-started/01-docker.md b/docs/zh/05-get-started/01-docker.md index 9ff67fa604688d97adb9c685596771c0494f6ee0..2edabad3c950eb7ef1361221eef56bed1046909a 100644 --- a/docs/zh/05-get-started/01-docker.md +++ b/docs/zh/05-get-started/01-docker.md @@ -3,329 +3,146 @@ sidebar_label: Docker title: 通过 Docker 快速体验 TDengine --- -虽然并不推荐在生产环境中通过 Docker 来部署 TDengine 服务,但 Docker 工具能够很好地屏蔽底层操作系统的环境差异,很适合在开发测试或初次体验时用于安装运行 TDengine 的工具集。特别是,借助 Docker,能够比较方便地在 macOS 和 Windows 系统上尝试 TDengine,而无需安装虚拟机或额外租用 Linux 服务器。另外,从 2.0.14.0 版本开始,TDengine 提供的镜像已经可以同时支持 X86-64、X86、arm64、arm32 平台,像 NAS、树莓派、嵌入式开发板之类可以运行 docker 的非主流计算机也可以基于本文档轻松体验 TDengine。 +本节首先介绍如何通过 Docker 快速体验 TDengine,然后介绍如何在 Docker 环境下体验 TDengine 的写入和查询功能。 -下文通过 Step by Step 风格的介绍,讲解如何通过 Docker 快速建立 TDengine 的单节点运行环境,以支持开发和测试。 +## 启动 TDengine -## 下载 Docker +如果已经安装了 docker, 只需执行下面的命令。 -Docker 工具自身的下载请参考 [Docker 官网文档](https://docs.docker.com/get-docker/)。 - -安装完毕后可以在命令行终端查看 Docker 版本。如果版本号正常输出,则说明 Docker 环境已经安装成功。 - -```bash -$ docker -v -Docker version 20.10.3, build 48d30b5 -``` - -## 使用 Docker 在容器中运行 TDengine - -### 在 Docker 容器中运行 TDengine server - -```bash -$ docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine -526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd -``` - -这条命令,启动一个运行了 TDengine server 的 docker 容器,并且将容器的 6030 到 6049 端口映射到宿主机的 6030 到 6049 端口上。如果宿主机已经运行了 TDengine server 并占用了相同端口,需要映射容器的端口到不同的未使用端口段。(详情参见 [TDengine 2.0 端口说明](/train-faq/faq#port)。为了支持 TDengine 客户端操作 TDengine server 服务, TCP 和 UDP 端口都需要打开。 - -- **docker run**:通过 Docker 运行一个容器 -- **-d**:让容器在后台运行 -- **-p**:指定映射端口。注意:如果不是用端口映射,依然可以进入 Docker 容器内部使用 TDengine 服务或进行应用开发,只是不能对容器外部提供服务 -- **tdengine/tdengine**:拉取的 TDengine 官方发布的应用镜像 -- **526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd**:这个返回的长字符是容器 ID,我们也可以通过容器 ID 来查看对应的容器 - -进一步,还可以使用 docker run 命令启动运行 TDengine server 的 docker 容器,并使用 `--name` 命令行参数将容器命名为 `tdengine`,使用 `--hostname` 指定 hostname 为 `tdengine-server`,通过 `-v` 挂载本地目录到容器,实现宿主机与容器内部的数据同步,防止容器删除后,数据丢失。 - -```bash -docker run -d --name tdengine --hostname="tdengine-server" -v ~/work/taos/log:/var/log/taos -v ~/work/taos/data:/var/lib/taos -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine +```shell +docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine ``` -- **--name tdengine**:设置容器名称,我们可以通过容器名称来访问对应的容器 -- **--hostname=tdengine-server**:设置容器内 Linux 系统的 hostname,我们可以通过映射 hostname 和 IP 来解决容器 IP 可能变化的问题。 -- **-v**:设置宿主机文件目录映射到容器内目录,避免容器删除后数据丢失。 +确定该容器已经启动并且在正常运行 -### 使用 docker ps 命令确认容器是否已经正确运行 - -```bash +```shell docker ps ``` -输出示例如下: +进入该容器并执行 bash +```shell +docker exec -it bash ``` -CONTAINER ID IMAGE COMMAND CREATED STATUS ··· -c452519b0f9b tdengine/tdengine "taosd" 14 minutes ago Up 14 minutes ··· -``` - -- **docker ps**:列出所有正在运行状态的容器信息。 -- **CONTAINER ID**:容器 ID。 -- **IMAGE**:使用的镜像。 -- **COMMAND**:启动容器时运行的命令。 -- **CREATED**:容器创建时间。 -- **STATUS**:容器状态。UP 表示运行中。 -### 通过 docker exec 命令,进入到 docker 容器中去做开发 +然后就可以执行相关的 Linux 命令操作和访问 TDengine -```bash -$ docker exec -it tdengine /bin/bash -root@tdengine-server:~/TDengine-server-2.4.0.4# -``` +:::info -- **docker exec**:通过 docker exec 命令进入容器,如果退出,容器不会停止。 -- **-i**:进入交互模式。 -- **-t**:指定一个终端。 -- **tdengine**:容器名称,需要根据 docker ps 指令返回的值进行修改。 -- **/bin/bash**:载入容器后运行 bash 来进行交互。 +Docker 工具自身的下载请参考 [Docker 官网文档](https://docs.docker.com/get-docker/)。 -进入容器后,执行 taos shell 客户端程序。 +安装完毕后可以在命令行终端查看 Docker 版本。如果版本号正常输出,则说明 Docker 环境已经安装成功。 ```bash -root@tdengine-server:~/TDengine-server-2.4.0.4# taos - -Welcome to the TDengine shell from Linux, Client Version:2.4.0.4 -Copyright (c) 2020 by TAOS Data, Inc. All rights reserved. - -taos> +$ docker -v +Docker version 20.10.3, build 48d30b5 ``` -TDengine 终端成功连接服务端,打印出了欢迎消息和版本信息。如果失败,会有错误信息打印出来。 - -在 TDengine 终端中,可以通过 SQL 命令来创建/删除数据库、表、超级表等,并可以进行插入和查询操作。具体可以参考 [TAOS SQL 说明文档](/taos-sql/)。 +::: -### 在宿主机访问 Docker 容器中的 TDengine server +## 运行 TDengine CLI -在使用了 -p 命令行参数映射了正确的端口启动了 TDengine Docker 容器后,就在宿主机使用 taos shell 命令即可访问运行在 Docker 容器中的 TDengine。 +有两种方式在 Docker 环境下使用 TDengine CLI (taos) 访问 TDengine. +- 进入容器后,执行 taos +- 在宿主机使用容器映射到主机的端口进行访问 `taos -h -P ` ``` $ taos +Welcome to the TDengine shell from Linux, Client Version:3.0.0.0 +Copyright (c) 2022 by TAOS Data, Inc. All rights reserved. -Welcome to the TDengine shell from Linux, Client Version:2.4.0.4 -Copyright (c) 2020 by TAOS Data, Inc. All rights reserved. +Server is Enterprise trial Edition, ver:3.0.0.0 and will expire at 2022-09-24 15:29:46. -taos> -``` +taos> -也可以在宿主机使用 curl 通过 RESTful 端口访问 Docker 容器内的 TDengine server。 - -``` -curl -L -u root:taosdata -d "show databases" 127.0.0.1:6041/rest/sql ``` -输出示例如下: -``` -{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep0,keep1,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep0,keep1,keep(D)",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[["test","2021-08-18 06:01:11.021",10000,4,1,1,10,"3650,3650,3650",16,6,100,4096,1,3000,2,0,"ms",0,"ready"],["log","2021-08-18 05:51:51.065",4,1,1,1,10,"30,30,30",1,3,100,4096,1,3000,2,0,"us",0,"ready"]],"rows":2} -``` +## 启动 REST 服务 -这条命令,通过 REST API 访问 TDengine server,这时连接的是本机的 6041 端口,可见连接成功。 - -TDengine REST API 详情请参考[官方文档](/reference/rest-api/)。 - -### 使用 Docker 容器运行 TDengine server 和 taosAdapter - -在 TDengine 2.4.0.0 之后版本的 Docker 容器,开始提供一个独立运行的组件 taosAdapter,代替之前版本 TDengine 中 taosd 进程中内置的 http server。taosAdapter 支持通过 RESTful 接口对 TDengine server 的数据写入和查询能力,并提供和 InfluxDB/OpenTSDB 兼容的数据摄取接口,允许 InfluxDB/OpenTSDB 应用程序无缝移植到 TDengine。在新版本 Docker 镜像中,默认启用了 taosAdapter,也可以使用 docker run 命令中设置 TAOS_DISABLE_ADAPTER=true 来禁用 taosAdapter;也可以在 docker run 命令中单独使用 taosAdapter,而不运行 taosd 。 - -注意:如果容器中运行 taosAdapter,需要根据需要映射其他端口,具体端口默认配置和修改方法请参考[taosAdapter 文档](/reference/taosadapter/)。 - -使用 docker 运行 TDengine 2.4.0.4 版本镜像(taosd + taosAdapter): +taosAdapter 是 TDengine 中提供 REST 服务的组件。下面这条命令会在容器中同时启动 `taosd` 和 `taosadapter` 两个服务组件。 ```bash -docker run -d --name tdengine-all -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine:2.4.0.4 +docker run -d --name tdengine-all -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine ``` -使用 docker 运行 TDengine 2.4.0.4 版本镜像(仅 taosAdapter,需要设置 firstEp 配置项 或 TAOS_FIRST_EP 环境变量): +如果想只启动 `taosadapter`: ```bash -docker run -d --name tdengine-taosa -p 6041-6049:6041-6049 -p 6041-6049:6041-6049/udp -e TAOS_FIRST_EP=tdengine-all tdengine/tdengine:2.4.0.4 taosadapter +docker run -d --name tdengine-taosa -p 6041-6049:6041-6049 -p 6041-6049:6041-6049/udp -e TAOS_FIRST_EP=tdengine-all tdengine/tdengine:3.0.0.0 taosadapter ``` -使用 docker 运行 TDengine 2.4.0.4 版本镜像(仅 taosd): +如果想只启动 `taosd`: ```bash -docker run -d --name tdengine-taosd -p 6030-6042:6030-6042 -p 6030-6042:6030-6042/udp -e TAOS_DISABLE_ADAPTER=true tdengine/tdengine:2.4.0.4 +docker run -d --name tdengine-taosd -p 6030-6042:6030-6042 -p 6030-6042:6030-6042/udp -e TAOS_DISABLE_ADAPTER=true tdengine/tdengine:3.0.0.0 ``` -使用 curl 命令验证 RESTful 接口可以正常工作: +## 访问 REST 接口 + +可以在宿主机使用 curl 通过 RESTful 端口访问 Docker 容器内的 TDengine server。 -```bash -curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "show databases;" 127.0.0.1:6041/rest/sql +``` +curl -L -u root:taosdata -d "show databases" 127.0.0.1:6041/rest/sql ``` 输出示例如下: ``` -{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[["log","2021-12-28 09:18:55.765",10,1,1,1,10,"30",1,3,100,4096,1,3000,2,0,"us",0,"ready"]],"rows":1} +{"code":0,"column_meta":[["name","VARCHAR",64],["create_time","TIMESTAMP",8],["vgroups","SMALLINT",2],["ntables","BIGINT",8],["replica","TINYINT",1],["strict","VARCHAR",4],["duration","VARCHAR",10],["keep","VARCHAR",32],["buffer","INT",4],["pagesize","INT",4],["pages","INT",4],["minrows","INT",4],["maxrows","INT",4],["wal","TINYINT",1],["fsync","INT",4],["comp","TINYINT",1],["cacheModel","VARCHAR",11],["precision","VARCHAR",2],["single_stable","BOOL",1],["status","VARCHAR",10],["retention","VARCHAR",60]],"data":[["information_schema",null,null,14,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"ready"],["performance_schema",null,null,3,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"ready"]],"rows":2} ``` -### 应用示例:在宿主机使用 taosBenchmark 写入数据到 Docker 容器中的 TDengine server - -1. 在宿主机命令行界面执行 taosBenchmark (曾命名为 taosdemo)写入数据到 Docker 容器中的 TDengine server +这条命令,通过 REST API 访问 TDengine server,这时连接的是从容器映射到主机的 6041 端口。 - ```bash - $ taosBenchmark - - taosBenchmark is simulating data generated by power equipments monitoring... - - host: 127.0.0.1:6030 - user: root - password: taosdata - configDir: - resultFile: ./output.txt - thread num of insert data: 10 - thread num of create table: 10 - top insert interval: 0 - number of records per req: 30000 - max sql length: 1048576 - database count: 1 - database[0]: - database[0] name: test - drop: yes - replica: 1 - precision: ms - super table count: 1 - super table[0]: - stbName: meters - autoCreateTable: no - childTblExists: no - childTblCount: 10000 - childTblPrefix: d - dataSource: rand - iface: taosc - insertRows: 10000 - interlaceRows: 0 - disorderRange: 1000 - disorderRatio: 0 - maxSqlLen: 1048576 - timeStampStep: 1 - startTimestamp: 2017-07-14 10:40:00.000 - sampleFormat: - sampleFile: - tagsFile: - columnCount: 3 - column[0]:FLOAT column[1]:INT column[2]:FLOAT - tagCount: 2 - tag[0]:INT tag[1]:BINARY(16) - - Press enter key to continue or Ctrl-C to stop - ``` - - 回车后,该命令将在数据库 test 下面自动创建一张超级表 meters,该超级表下有 1 万张表,表名为 "d0" 到 "d9999",每张表有 1 万条记录,每条记录有 (ts, current, voltage, phase) 四个字段,时间戳从 "2017-07-14 10:40:00 000" 到 "2017-07-14 10:40:09 999",每张表带有标签 location 和 groupId,groupId 被设置为 1 到 10, location 被设置为 "California.SanFrancisco" 或者 "California.SanDieo"。 - - 最后共插入 1 亿条记录。 - -2. 进入 TDengine 终端,查看 taosBenchmark 生成的数据。 - - - **进入命令行。** - - ```bash - $ root@c452519b0f9b:~/TDengine-server-2.4.0.4# taos +TDengine REST API 详情请参考[官方文档](/reference/rest-api/)。 - Welcome to the TDengine shell from Linux, Client Version:2.4.0.4 - Copyright (c) 2020 by TAOS Data, Inc. All rights reserved. +## 写入数据 - taos> - ``` +可以使用 TDengine 的自带工具 taosBenchmark 快速体验 TDengine 的写入。 - - **查看数据库。** +假定启动容器时已经将容器的6030端口映射到了宿主机的6030端口,则可以直接在宿主机命令行启动 taosBenchmark,也可以进入容器后执行: ```bash - $ taos> show databases; - name | created_time | ntables | vgroups | ··· - test | 2021-08-18 06:01:11.021 | 10000 | 6 | ··· - log | 2021-08-18 05:51:51.065 | 4 | 1 | ··· - + $ taosBenchmark + ``` - - **查看超级表。** - - ```bash - $ taos> use test; - Database changed. + 该命令将在数据库 test 下面自动创建一张超级表 meters,该超级表下有 1 万张表,表名为 "d0" 到 "d9999",每张表有 1 万条记录,每条记录有 (ts, current, voltage, phase) 四个字段,时间戳从 "2017-07-14 10:40:00 000" 到 "2017-07-14 10:40:09 999",每张表带有标签 location 和 groupId,groupId 被设置为 1 到 10, location 被设置为 "California.SanFrancisco" 或者 "California.LosAngeles"。 - $ taos> show stables; - name | created_time | columns | tags | tables | - ============================================================================================ - meters | 2021-08-18 06:01:11.116 | 4 | 2 | 10000 | - Query OK, 1 row(s) in set (0.003259s) + 这条命令很快完成 1 亿条记录的插入。具体时间取决于硬件性能。 - ``` + taosBenchmark 命令本身带有很多选项,配置表的数目、记录条数等等,您可以设置不同参数进行体验,请执行 `taosBenchmark --help` 详细列出。taosBenchmark 详细使用方法请参照 [taosBenchmark 参考手册](../../reference/taosbenchmark)。 - - **查看表,限制输出十条。** +## 体验查询 - ```bash - $ taos> select * from test.t0 limit 10; - - DB error: Table does not exist (0.002857s) - taos> select * from test.d0 limit 10; - ts | current | voltage | phase | - ====================================================================================== - 2017-07-14 10:40:00.000 | 10.12072 | 223 | 0.34167 | - 2017-07-14 10:40:00.001 | 10.16103 | 224 | 0.34445 | - 2017-07-14 10:40:00.002 | 10.00204 | 220 | 0.33334 | - 2017-07-14 10:40:00.003 | 10.00030 | 220 | 0.33333 | - 2017-07-14 10:40:00.004 | 9.84029 | 216 | 0.32222 | - 2017-07-14 10:40:00.005 | 9.88028 | 217 | 0.32500 | - 2017-07-14 10:40:00.006 | 9.88110 | 217 | 0.32500 | - 2017-07-14 10:40:00.007 | 10.08137 | 222 | 0.33889 | - 2017-07-14 10:40:00.008 | 10.12063 | 223 | 0.34167 | - 2017-07-14 10:40:00.009 | 10.16086 | 224 | 0.34445 | - Query OK, 10 row(s) in set (0.016791s) - - ``` +使用上述 taosBenchmark 插入数据后,可以在 TDengine CLI 输入查询命令,体验查询速度。可以直接在宿主机上也可以进入容器后运行。 - - **查看 d0 表的标签值。** +查询超级表下记录总条数: - ```bash - $ taos> select groupid, location from test.d0; - groupid | location | - ================================= - 0 | California.SanDieo | - Query OK, 1 row(s) in set (0.003490s) - ``` - -### 应用示例:使用数据收集代理软件写入 TDengine +```sql +taos> select count(*) from test.meters; +``` -taosAdapter 支持多个数据收集代理软件(如 Telegraf、StatsD、collectd 等),这里仅模拟 StasD 写入数据,在宿主机执行命令如下: +查询 1 亿条记录的平均值、最大值、最小值等: -``` -echo "foo:1|c" | nc -u -w0 127.0.0.1 6044 +```sql +taos> select avg(current), max(voltage), min(phase) from test.meters; ``` -然后可以使用 taos shell 查询 taosAdapter 自动创建的数据库 statsd 和 超级表 foo 中的内容: +查询 location="California.SanFrancisco" 的记录总条数: +```sql +taos> select count(*) from test.meters where location="California.SanFrancisco"; ``` -taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - log | 2021-12-28 09:18:55.765 | 12 | 1 | 1 | 1 | 10 | 30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | 0 | us | 0 | ready | - statsd | 2021-12-28 09:21:48.841 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | -Query OK, 2 row(s) in set (0.002112s) - -taos> use statsd; -Database changed. - -taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - foo | 2021-12-28 09:21:48.894 | 2 | 1 | 1 | -Query OK, 1 row(s) in set (0.001160s) - -taos> select * from foo; - ts | value | metric_type | -======================================================================================= - 2021-12-28 09:21:48.840820836 | 1 | counter | -Query OK, 1 row(s) in set (0.001639s) - -taos> -``` - -可以看到模拟数据已经被写入到 TDengine 中。 -## 停止正在 Docker 中运行的 TDengine 服务 +查询 groupId=10 的所有记录的平均值、最大值、最小值等: -```bash -docker stop tdengine +```sql +taos> select avg(current), max(voltage), min(phase) from test.meters where groupId=10; ``` -- **docker stop**:通过 docker stop 停止指定的正在运行中的 docker 镜像。 +对表 d10 按 10s 进行平均值、最大值和最小值聚合统计: + +```sql +taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s); +``` \ No newline at end of file diff --git a/docs/zh/05-get-started/03-package.md b/docs/zh/05-get-started/03-package.md index 6ac7567a057c2bc7c38b9776205a2aa2f50a11c3..6dbf74f8bcc3442018d259c9781999182fdc579d 100644 --- a/docs/zh/05-get-started/03-package.md +++ b/docs/zh/05-get-started/03-package.md @@ -245,7 +245,7 @@ select * from t; Query OK, 2 row(s) in set (0.003128s) ``` -除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TDengine CLI 连同应用驱动也可以独立安装在 Linux 或 Windows 机器上运行,更多细节请参考 [这里](../reference/taos-shell/) +除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TDengine CLI 连同应用驱动也可以独立安装在 Linux 或 Windows 机器上运行,更多细节请参考 [这里](../../reference/taos-shell/) ## 使用 taosBenchmark 体验写入速度 diff --git a/docs/zh/05-get-started/index.md b/docs/zh/05-get-started/index.md index d841c6e75d813386901df6874912559c0b024118..794081b4e4c438dee2d8cbe125de4094056f190f 100644 --- a/docs/zh/05-get-started/index.md +++ b/docs/zh/05-get-started/index.md @@ -3,6 +3,7 @@ title: 立即开始 description: '快速设置 TDengine 环境并体验其高效写入和查询' --- +TDengine 完整的软件包包括服务端(taosd)、用于与第三方系统对接并提供 RESTful 接口的 taosAdapter、应用驱动(taosc)、命令行程序 (CLI,taos) 和一些工具软件。TDengine 除了提供多种语言的连接器之外,还通过 [taosAdapter](/reference/taosadapter) 提供 [RESTful 接口](/reference/rest-api)。 本章主要介绍如何利用 Docker 或者安装包快速设置 TDengine 环境并体验其高效写入和查询。 diff --git a/docs/zh/07-develop/06-continuous-query.mdx b/docs/zh/07-develop/06-stream.md similarity index 100% rename from docs/zh/07-develop/06-continuous-query.mdx rename to docs/zh/07-develop/06-stream.md diff --git a/docs/zh/07-develop/07-subscribe.md b/docs/zh/07-develop/07-tmq.md similarity index 100% rename from docs/zh/07-develop/07-subscribe.md rename to docs/zh/07-develop/07-tmq.md diff --git a/docs/zh/12-taos-sql/02-database.md b/docs/zh/12-taos-sql/02-database.md index e3a0aa7c87461fd1621a38093871a1542e3dbf98..839b1e2015dec45dd2df7d3b88202022aae50e98 100644 --- a/docs/zh/12-taos-sql/02-database.md +++ b/docs/zh/12-taos-sql/02-database.md @@ -6,53 +6,86 @@ description: "创建、删除数据库,查看、修改数据库参数" ## 创建数据库 -``` -CREATE DATABASE [IF NOT EXISTS] db_name [KEEP keep] [DAYS days] [UPDATE 1]; -``` - -:::info -1. KEEP 是该数据库的数据保留多长天数,缺省是 3650 天(10 年),数据库会自动删除超过时限的数据; -2. UPDATE 标志数据库支持更新相同时间戳数据;(从 2.1.7.0 版本开始此参数支持设为 2,表示允许部分列更新,也即更新数据行时未被设置的列会保留原值。)(从 2.0.8.0 版本开始支持此参数。注意此参数不能通过 `ALTER DATABASE` 指令进行修改。) - 1. UPDATE 设为 0 时,表示不允许更新数据,后发送的相同时间戳的数据会被直接丢弃; - 2. UPDATE 设为 1 时,表示更新全部列数据,即如果更新一个数据行,其中某些列没有提供取值,那么这些列会被设为 NULL; - 3. UPDATE 设为 2 时,表示支持更新部分列数据,即如果更新一个数据行,其中某些列没有提供取值,那么这些列会保持原有数据行中的对应值; - 4. 更多关于 UPDATE 参数的用法,请参考[FAQ](/train-faq/faq)。 -3. 数据库名最大长度为 33; -4. 一条 SQL 语句的最大长度为 65480 个字符; -5. 创建数据库时可用的参数有: - - cache: [详细说明](/reference/config/#cache) - - blocks: [详细说明](/reference/config/#blocks) - - days: [详细说明](/reference/config/#days) - - keep: [详细说明](/reference/config/#keep) - - minRows: [详细说明](/reference/config/#minrows) - - maxRows: [详细说明](/reference/config/#maxrows) - - wal: [详细说明](/reference/config/#wallevel) - - fsync: [详细说明](/reference/config/#fsync) - - update: [详细说明](/reference/config/#update) - - cacheLast: [详细说明](/reference/config/#cachelast) - - replica: [详细说明](/reference/config/#replica) - - quorum: [详细说明](/reference/config/#quorum) - - comp: [详细说明](/reference/config/#comp) - - precision: [详细说明](/reference/config/#precision) -6. 请注意上面列出的所有参数都可以配置在配置文件 `taosd.cfg` 中作为创建数据库时使用的默认配置, `create database` 的参数中明确指定的会覆盖配置文件中的设置。 - -::: +```sql +CREATE DATABASE [IF NOT EXISTS] db_name [database_options] + +database_options: + database_option ... + +database_option: { + BUFFER value + | CACHEMODEL {'none' | 'last_row' | 'last_value' | 'both'} + | CACHESIZE value + | COMP {0 | 1 | 2} + | DURATION value + | WAL_FSYNC_PERIOD value + | MAXROWS value + | MINROWS value + | KEEP value + | PAGES value + | PAGESIZE value + | PRECISION {'ms' | 'us' | 'ns'} + | REPLICA value + | RETENTIONS ingestion_duration:keep_duration ... + | STRICT {'off' | 'on'} + | WAL_LEVEL {1 | 2} + | VGROUPS value + | SINGLE_STABLE {0 | 1} + | WAL_RETENTION_PERIOD value + | WAL_ROLL_PERIOD value + | WAL_RETENTION_SIZE value + | WAL_SEGMENT_SIZE value +} +``` + +### 参数说明 + +- BUFFER: 一个 VNODE 写入内存池大小,单位为 MB,默认为 96,最小为 3,最大为 16384。 +- CACHEMODEL:表示是否在内存中缓存子表的最近数据。默认为 none。 + - none:表示不缓存。 + - last_row:表示缓存子表最近一行数据。这将显著改善 LAST_ROW 函数的性能表现。 + - last_value:表示缓存子表每一列的最近的非 NULL 值。这将显著改善无特殊影响(WHERE、ORDER BY、GROUP BY、INTERVAL)下的 LAST 函数的性能表现。 + - both:表示同时打开缓存最近行和列功能。 +- CACHESIZE:表示每个 vnode 中用于缓存子表最近数据的内存大小。默认为 1 ,范围是[1, 65536],单位是 MB。 +- COMP:表示数据库文件压缩标志位,缺省值为 2,取值范围为 [0, 2]。 + - 0:表示不压缩。 + - 1:表示一阶段压缩。 + - 2:表示两阶段压缩。 +- DURATION:数据文件存储数据的时间跨度。可以使用加单位的表示形式,如 DURATION 100h、DURATION 10d 等,支持 m(分钟)、h(小时)和 d(天)三个单位。不加时间单位时默认单位为天,如 DURATION 50 表示 50 天。 +- WAL_FSYNC_PERIOD:当 WAL 参数设置为 2 时,落盘的周期。默认为 3000,单位毫秒。最小为 0,表示每次写入立即落盘;最大为 180000,即三分钟。 +- MAXROWS:文件块中记录的最大条数,默认为 4096 条。 +- MINROWS:文件块中记录的最小条数,默认为 100 条。 +- KEEP:表示数据文件保存的天数,缺省值为 3650,取值范围 [1, 365000],且必须大于或等于 DURATION 参数值。数据库会自动删除保存时间超过 KEEP 值的数据。KEEP 可以使用加单位的表示形式,如 KEEP 100h、KEEP 10d 等,支持 m(分钟)、h(小时)和 d(天)三个单位。也可以不写单位,如 KEEP 50,此时默认单位为天。 +- PAGES:一个 VNODE 中元数据存储引擎的缓存页个数,默认为 256,最小 64。一个 VNODE 元数据存储占用 PAGESIZE \* PAGES,默认情况下为 1MB 内存。 +- PAGESIZE:一个 VNODE 中元数据存储引擎的页大小,单位为 KB,默认为 4 KB。范围为 1 到 16384,即 1 KB 到 16 MB。 +- PRECISION:数据库的时间戳精度。ms 表示毫秒,us 表示微秒,ns 表示纳秒,默认 ms 毫秒。 +- REPLICA:表示数据库副本数,取值为 1 或 3,默认为 1。在集群中使用,副本数必须小于或等于 DNODE 的数目。 +- RETENTIONS:表示数据的聚合周期和保存时长,如 RETENTIONS 15s:7d,1m:21d,15m:50d 表示数据原始采集周期为 15 秒,原始数据保存 7 天;按 1 分钟聚合的数据保存 21 天;按 15 分钟聚合的数据保存 50 天。目前支持且只支持三级存储周期。 +- STRICT:表示数据同步的一致性要求,默认为 off。 + - on 表示强一致,即运行标准的 raft 协议,半数提交返回成功。 + - off 表示弱一致,本地提交即返回成功。 +- WAL_LEVEL:WAL 级别,默认为 1。 + - 1:写 WAL,但不执行 fsync。 + - 2:写 WAL,而且执行 fsync。 +- VGROUPS:数据库中初始 vgroup 的数目。 +- SINGLE_STABLE:表示此数据库中是否只可以创建一个超级表,用于超级表列非常多的情况。 + - 0:表示可以创建多张超级表。 + - 1:表示只可以创建一张超级表。 +- WAL_RETENTION_PERIOD:wal 文件的额外保留策略,用于数据订阅。wal 的保存时长,单位为 s。默认为 0,即落盘后立即删除。-1 表示不删除。 +- WAL_RETENTION_SIZE:wal 文件的额外保留策略,用于数据订阅。wal 的保存的最大上限,单位为 KB。默认为 0,即落盘后立即删除。-1 表示不删除。 +- WAL_ROLL_PERIOD:wal 文件切换时长,单位为 s。当 wal 文件创建并写入后,经过该时间,会自动创建一个新的 wal 文件。默认为 0,即仅在落盘时创建新文件。 +- WAL_SEGMENT_SIZE:wal 单个文件大小,单位为 KB。当前写入文件大小超过上限后会自动创建一个新的 wal 文件。默认为 0,即仅在落盘时创建新文件。 ### 创建数据库示例 -创建时间精度为纳秒的数据库, 保留 1 年数据: - ```sql -CREATE DATABASE test PRECISION 'ns' KEEP 365; -``` - -## 显示系统当前参数 +create database if not exists db vgroups 10 buffer 10 ``` -SHOW VARIABLES; -``` -## 使用数据库 +以上示例创建了一个有 10 个 vgroup 名为 db 的数据库, 其中每个 vnode 分配也 10MB 的写入缓存 + +### 使用数据库 ``` USE db_name; @@ -63,65 +96,61 @@ USE db_name; ## 删除数据库 ``` -DROP DATABASE [IF EXISTS] db_name; +DROP DATABASE [IF EXISTS] db_name ``` -删除数据库。指定 Database 所包含的全部数据表将被删除,谨慎使用! +删除数据库。指定 Database 所包含的全部数据表将被删除,该数据库的所有 vgroups 也会被全部销毁,请谨慎使用! ## 修改数据库参数 -``` -ALTER DATABASE db_name COMP 2; -``` +```sql +ALTER DATABASE db_name [alter_database_options] -COMP 参数是指修改数据库文件压缩标志位,缺省值为 2,取值范围为 [0, 2]。0 表示不压缩,1 表示一阶段压缩,2 表示两阶段压缩。 +alter_database_options: + alter_database_option ... +alter_database_option: { + CACHEMODEL {'none' | 'last_row' | 'last_value' | 'both'} + | CACHESIZE value + | FSYNC value + | KEEP value + | WAL value +} ``` -ALTER DATABASE db_name REPLICA 2; -``` - -REPLICA 参数是指修改数据库副本数,取值范围 [1, 3]。在集群中使用,副本数必须小于或等于 DNODE 的数目。 -``` -ALTER DATABASE db_name KEEP 365; -``` +:::note +其它参数在 3.0.0.0 中暂不支持修改 -KEEP 参数是指修改数据文件保存的天数,缺省值为 3650,取值范围 [days, 365000],必须大于或等于 days 参数值。 +::: -``` -ALTER DATABASE db_name QUORUM 2; -``` +## 查看数据库 -QUORUM 参数是指数据写入成功所需要的确认数,取值范围 [1, 2]。对于异步复制,quorum 设为 1,具有 master 角色的虚拟节点自己确认即可。对于同步复制,quorum 设为 2。原则上,Quorum >= 1 并且 Quorum <= replica(副本数),这个参数在启动一个同步模块实例时需要提供。 +### 查看系统中的所有数据库 ``` -ALTER DATABASE db_name BLOCKS 100; +SHOW DATABASES; ``` -BLOCKS 参数是每个 VNODE (TSDB) 中有多少 cache 大小的内存块,因此一个 VNODE 的用的内存大小粗略为(cache \* blocks)。取值范围 [3, 1000]。 +### 显示一个数据库的创建语句 ``` -ALTER DATABASE db_name CACHELAST 0; +SHOW CREATE DATABASE db_name; ``` -CACHELAST 参数控制是否在内存中缓存子表的最近数据。缺省值为 0,取值范围 [0, 1, 2, 3]。其中 0 表示不缓存,1 表示缓存子表最近一行数据,2 表示缓存子表每一列的最近的非 NULL 值,3 表示同时打开缓存最近行和列功能。(从 2.0.11.0 版本开始支持参数值 [0, 1],从 2.1.2.0 版本开始支持参数值 [0, 1, 2, 3]。) -说明:缓存最近行,将显著改善 LAST_ROW 函数的性能表现;缓存每列的最近非 NULL 值,将显著改善无特殊影响(WHERE、ORDER BY、GROUP BY、INTERVAL)下的 LAST 函数的性能表现。 - -:::tip -以上所有参数修改后都可以用 show databases 来确认是否修改成功。另外,从 2.1.3.0 版本开始,修改这些参数后无需重启服务器即可生效。 -::: +常用于数据库迁移。对一个已经存在的数据库,返回其创建语句;在另一个集群中执行该语句,就能得到一个设置完全相同的 Database。 -## 显示系统所有数据库 +### 查看数据库参数 -``` -SHOW DATABASES; +```sql +SHOW DATABASES \G; ``` -## 显示一个数据库的创建语句 +会列出系统中所有数据库的配置参数,并且每行只显示一个参数。 -``` -SHOW CREATE DATABASE db_name; -``` +## 删除过期数据 -常用于数据库迁移。对一个已经存在的数据库,返回其创建语句;在另一个集群中执行该语句,就能得到一个设置完全相同的 Database。 +```sql +TRIM DATABASE db_name; +``` +删除过期数据,并根据多级存储的配置归整数据。 diff --git a/docs/zh/12-taos-sql/03-table.md b/docs/zh/12-taos-sql/03-table.md index d7235f312933ec46ed427d5da7e2c5a229fa2926..1e20f73541b7465db76603dc16da8cd1daea0191 100644 --- a/docs/zh/12-taos-sql/03-table.md +++ b/docs/zh/12-taos-sql/03-table.md @@ -2,13 +2,45 @@ title: 表管理 --- -## 创建数据表 - -``` -CREATE TABLE [IF NOT EXISTS] tb_name (timestamp_field_name TIMESTAMP, field1_name data_type1 [, field2_name data_type2 ...]); -``` - -:::info 说明 +## 创建表 + +`CREATE TABLE` 语句用于创建普通表和以超级表为模板创建子表。 + +```sql +CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definitionn] ...) [table_options] + +CREATE TABLE create_subtable_clause + +CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definitionn] ...) + [TAGS (create_definition [, create_definitionn] ...)] + [table_options] + +create_subtable_clause: { + create_subtable_clause [create_subtable_clause] ... + | [IF NOT EXISTS] [db_name.]tb_name USING [db_name.]stb_name [(tag_name [, tag_name] ...)] TAGS (tag_value [, tag_value] ...) +} + +create_definition: + col_name column_definition + +column_definition: + type_name [comment 'string_value'] + +table_options: + table_option ... + +table_option: { + COMMENT 'string_value' + | WATERMARK duration[,duration] + | MAX_DELAY duration[,duration] + | ROLLUP(func_name [, func_name] ...) + | SMA(col_name [, col_name] ...) + | TTL value +} + +``` + +**使用说明** 1. 表的第一个字段必须是 TIMESTAMP,并且系统自动将其设为主键; 2. 表名最大长度为 192; @@ -18,106 +50,149 @@ CREATE TABLE [IF NOT EXISTS] tb_name (timestamp_field_name TIMESTAMP, field1_nam 6. 为了兼容支持更多形式的表名,TDengine 引入新的转义符 "\`",可以让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查。但是同样具有长度限制要求。使用转义字符以后,不再对转义字符中的内容进行大小写统一。 例如:\`aBc\` 和 \`abc\` 是不同的表名,但是 abc 和 aBc 是相同的表名。 需要注意的是转义字符中的内容必须是可打印字符。 - 上述的操作逻辑和约束要求与 MySQL 数据的操作一致。 - 从 2.3.0.0 版本开始支持这种方式。 -::: +**参数说明** +1. COMMENT:表注释。可用于超级表、子表和普通表。 +2. WATERMARK:指定窗口的关闭时间,默认值为 5 秒,最小单位毫秒,范围为0到15分钟,多个以逗号分隔。只可用于超级表,且只有当数据库使用了RETENTIONS参数时,才可以使用此表参数。 +3. MAX_DELAY:用于控制推送计算结果的最大延迟,默认值为 interval 的值(但不能超过最大值),最小单位毫秒,范围为1毫秒到15分钟,多个以逗号分隔。注:不建议 MAX_DELAY 设置太小,否则会过于频繁的推送结果,影响存储和查询性能,如无特殊需求,取默认值即可。只可用于超级表,且只有当数据库使用了RETENTIONS参数时,才可以使用此表参数。 +4. ROLLUP:Rollup 指定的聚合函数,提供基于多层级的降采样聚合结果。只可用于超级表。只有当数据库使用了RETENTIONS参数时,才可以使用此表参数。作用于超级表除TS列外的其它所有列,但是只能定义一个聚合函数。 聚合函数支持 avg, sum, min, max, last, first。 +5. SMA:Small Materialized Aggregates,提供基于数据块的自定义预计算功能。预计算类型包括MAX、MIN和SUM。可用于超级表/普通表。 +6. TTL:Time to Live,是用户用来指定表的生命周期的参数。如果在持续的TTL时间内,都没有数据写入该表,则TDengine系统会自动删除该表。这个TTL的时间只是一个大概时间,我们系统不保证到了时间一定会将其删除,而只保证存在这样一个机制。TTL单位是天,默认为0,表示不限制。用户需要注意,TTL优先级高于KEEP,即TTL时间满足删除机制时,即使当前数据的存在时间小于KEEP,此表也会被删除。只可用于子表和普通表。 -### 以超级表为模板创建数据表 +## 创建子表 -``` +### 创建子表 + +```sql CREATE TABLE [IF NOT EXISTS] tb_name USING stb_name TAGS (tag_value1, ...); ``` -以指定的超级表为模板,指定 TAGS 的值来创建数据表。 - -### 以超级表为模板创建数据表,并指定具体的 TAGS 列 +### 创建子表并指定标签的值 -``` +```sql CREATE TABLE [IF NOT EXISTS] tb_name USING stb_name (tag_name1, ...) TAGS (tag_value1, ...); ``` -以指定的超级表为模板,指定一部分 TAGS 列的值来创建数据表(没被指定的 TAGS 列会设为空值)。 -说明:从 2.0.17.0 版本开始支持这种方式。在之前的版本中,不允许指定 TAGS 列,而必须显式给出所有 TAGS 列的取值。 +以指定的超级表为模板,也可以指定一部分 TAGS 列的值来创建数据表(没被指定的 TAGS 列会设为空值)。 -### 批量创建数据表 +### 批量创建子表 -``` +```sql CREATE TABLE [IF NOT EXISTS] tb_name1 USING stb_name TAGS (tag_value1, ...) [IF NOT EXISTS] tb_name2 USING stb_name TAGS (tag_value2, ...) ...; ``` -以更快的速度批量创建大量数据表(服务器端 2.0.14 及以上版本)。 +批量建表方式要求数据表必须以超级表为模板。 在不超出 SQL 语句长度限制的前提下,单条语句中的建表数量建议控制在 1000 ~ 3000 之间,将会获得比较理想的建表速度。 + +## 修改普通表 -:::info +```sql +ALTER TABLE [db_name.]tb_name alter_table_clause + +alter_table_clause: { + alter_table_options + | ADD COLUMN col_name column_type + | DROP COLUMN col_name + | MODIFY COLUMN col_name column_type + | RENAME COLUMN old_col_name new_col_name +} + +alter_table_options: + alter_table_option ... + +alter_table_option: { + TTL value + | COMMENT 'string_value' +} -1.批量建表方式要求数据表必须以超级表为模板。 2.在不超出 SQL 语句长度限制的前提下,单条语句中的建表数量建议控制在 1000 ~ 3000 之间,将会获得比较理想的建表速度。 +``` -::: +**使用说明** +对普通表可以进行如下修改操作 +1. ADD COLUMN:添加列。 +2. DROP COLUMN:删除列。 +3. ODIFY COLUMN:修改列定义,如果数据列的类型是可变长类型,那么可以使用此指令修改其宽度,只能改大,不能改小。 +4. RENAME COLUMN:修改列名称。 -## 删除数据表 +### 增加列 -``` -DROP TABLE [IF EXISTS] tb_name; +```sql +ALTER TABLE tb_name ADD COLUMN field_name data_type; ``` -## 显示当前数据库下的所有数据表信息 +### 删除列 -``` -SHOW TABLES [LIKE tb_name_wildchar]; +```sql +ALTER TABLE tb_name DROP COLUMN field_name; ``` -显示当前数据库下的所有数据表信息。 +### 修改列宽 -## 显示一个数据表的创建语句 +```sql +ALTER TABLE tb_name MODIFY COLUMN field_name data_type(length); +``` +### 修改列名 + +```sql +ALTER TABLE tb_name RENAME COLUMN old_col_name new_col_name ``` -SHOW CREATE TABLE tb_name; + +## 修改子表 + +```sql +ALTER TABLE [db_name.]tb_name alter_table_clause + +alter_table_clause: { + alter_table_options + | SET TAG tag_name = new_tag_value +} + +alter_table_options: + alter_table_option ... + +alter_table_option: { + TTL value + | COMMENT 'string_value' +} ``` -常用于数据库迁移。对一个已经存在的数据表,返回其创建语句;在另一个集群中执行该语句,就能得到一个结构完全相同的数据表。 +**使用说明** +1. 对子表的列和标签的修改,除了更改标签值以外,都要通过超级表才能进行。 -## 获取表的结构信息 +### 修改子表标签值 ``` -DESCRIBE tb_name; +ALTER TABLE tb_name SET TAG tag_name=new_tag_value; ``` -## 修改表定义 +## 删除表 -### 表增加列 +可以在一条SQL语句中删除一个或多个普通表或子表。 +```sql +DROP TABLE [IF EXISTS] [db_name.]tb_name [, [IF EXISTS] [db_name.]tb_name] ... ``` -ALTER TABLE tb_name ADD COLUMN field_name data_type; -``` - -:::info -1. 列的最大个数为 1024,最小个数为 2;(从 2.1.7.0 版本开始,改为最多允许 4096 列) -2. 列名最大长度为 64。 +## 查看表的信息 -::: +### 显示所有表 -### 表删除列 +如下SQL语句可以列出当前数据库中的所有表名。 +```sql +SHOW TABLES [LIKE tb_name_wildchar]; ``` -ALTER TABLE tb_name DROP COLUMN field_name; -``` - -如果表是通过超级表创建,更改表结构的操作只能对超级表进行。同时针对超级表的结构更改对所有通过该结构创建的表生效。对于不是通过超级表创建的表,可以直接修改表结构。 -### 表修改列宽 +### 显示表创建语句 ``` -ALTER TABLE tb_name MODIFY COLUMN field_name data_type(length); +SHOW CREATE TABLE tb_name; ``` -如果数据列的类型是可变长格式(BINARY 或 NCHAR),那么可以使用此指令修改其宽度(只能改大,不能改小)。(2.1.3.0 版本新增) -如果表是通过超级表创建,更改表结构的操作只能对超级表进行。同时针对超级表的结构更改对所有通过该结构创建的表生效。对于不是通过超级表创建的表,可以直接修改表结构。 +常用于数据库迁移。对一个已经存在的数据表,返回其创建语句;在另一个集群中执行该语句,就能得到一个结构完全相同的数据表。 -### 修改子表标签值 +### 获取表结构信息 ``` -ALTER TABLE tb_name SET TAG tag_name=new_tag_value; -``` - -如果表是通过超级表创建,可以使用此指令修改其标签值 +DESCRIBE [db_name.]tb_name; +``` \ No newline at end of file diff --git a/docs/zh/12-taos-sql/04-stable.md b/docs/zh/12-taos-sql/04-stable.md index 3901427736e80bc8dd0dd87b454947af6e586561..59d9657694340ae263fb23b8c2b17ede8984426d 100644 --- a/docs/zh/12-taos-sql/04-stable.md +++ b/docs/zh/12-taos-sql/04-stable.md @@ -3,87 +3,121 @@ sidebar_label: 超级表管理 title: 超级表 STable 管理 --- -:::note - -在 2.0.15.0 及以后的版本中开始支持 STABLE 保留字。也即,在本节后文的指令说明中,CREATE、DROP、ALTER 三个指令在 2.0.15.0 之前的版本中 STABLE 保留字需写作 TABLE。 - -::: - ## 创建超级表 -``` -CREATE STABLE [IF NOT EXISTS] stb_name (timestamp_field_name TIMESTAMP, field1_name data_type1 [, field2_name data_type2 ...]) TAGS (tag1_name tag_type1, tag2_name tag_type2 [, tag3_name tag_type3]); +```sql +CREATE STABLE [IF NOT EXISTS] stb_name (create_definition [, create_definitionn] ...) TAGS (create_definition [, create_definition] ...) [table_options] + +create_definition: + col_name column_definition + +column_definition: + type_name [COMMENT 'string_value'] ``` -创建 STable,与创建表的 SQL 语法相似,但需要指定 TAGS 字段的名称和类型。 +**使用说明** +- 超级表中列的最大个数为 4096,需要注意,这里的 4096 是包含 TAG 列在内的,最小个数为 3,包含一个时间戳主键、一个 TAG 列和一个数据列。 +- 建表时可以给列或标签附加注释。 +- TAGS语法指定超级表的标签列,标签列需要遵循以下约定: + - TAGS 中的 TIMESTAMP 列写入数据时需要提供给定值,而暂不支持四则运算,例如 NOW + 10s 这类表达式。 + - TAGS 列名不能与其他列名相同。 + - TAGS 列名不能为预留关键字。 + - TAGS 最多允许 128 个,至少 1 个,总长度不超过 16 KB。 +- 关于表参数的详细说明,参见 CREATE TABLE 中的介绍。 -:::info +## 查看超级表 -1. TAGS 列的数据类型不能是 timestamp 类型;(从 2.1.3.0 版本开始,TAGS 列中支持使用 timestamp 类型,但需注意在 TAGS 中的 timestamp 列写入数据时需要提供给定值,而暂不支持四则运算,例如 `NOW + 10s` 这类表达式) -2. TAGS 列名不能与其他列名相同; -3. TAGS 列名不能为预留关键字(参见:[参数限制与保留关键字](/taos-sql/keywords/) 章节); -4. TAGS 最多允许 128 个,至少 1 个,总长度不超过 16 KB。 +### 显示当前数据库下的所有超级表信息 -::: +``` +SHOW STABLES [LIKE tb_name_wildcard]; +``` -## 删除超级表 +查看数据库内全部 STable,及其相关信息,包括 STable 的名称、创建时间、列数量、标签(TAG)数量、通过该 STable 建表的数量。 + +### 显示一个超级表的创建语句 ``` -DROP STABLE [IF EXISTS] stb_name; +SHOW CREATE STABLE stb_name; ``` -删除 STable 会自动删除通过 STable 创建的子表。 +常用于数据库迁移。对一个已经存在的超级表,返回其创建语句;在另一个集群中执行该语句,就能得到一个结构完全相同的超级表。 -## 显示当前数据库下的所有超级表信息 +### 获取超级表的结构信息 ``` -SHOW STABLES [LIKE tb_name_wildcard]; +DESCRIBE [db_name.]stb_name; ``` -查看数据库内全部 STable,及其相关信息,包括 STable 的名称、创建时间、列数量、标签(TAG)数量、通过该 STable 建表的数量。 - -## 显示一个超级表的创建语句 +## 删除超级表 ``` -SHOW CREATE STABLE stb_name; +DROP STABLE [IF EXISTS] [db_name.]stb_name ``` -常用于数据库迁移。对一个已经存在的超级表,返回其创建语句;在另一个集群中执行该语句,就能得到一个结构完全相同的超级表。 +删除 STable 会自动删除通过 STable 创建的子表以及子表中的所有数据。 -## 获取超级表的结构信息 +## 修改超级表 + +```sql +ALTER STABLE [db_name.]tb_name alter_table_clause + +alter_table_clause: { + alter_table_options + | ADD COLUMN col_name column_type + | DROP COLUMN col_name + | MODIFY COLUMN col_name column_type + | ADD TAG tag_name tag_type + | DROP TAG tag_name + | MODIFY TAG tag_name tag_type + | RENAME TAG old_tag_name new_tag_name +} + +alter_table_options: + alter_table_option ... + +alter_table_option: { + COMMENT 'string_value' +} -``` -DESCRIBE stb_name; ``` -## 修改超级表普通列 +**使用说明** -### 超级表增加列 +修改超级表的结构会对其下的所有子表生效。无法针对某个特定子表修改表结构。标签结构的修改需要对超级表下发,TDengine 会自动作用于此超级表的所有子表。 + +- ADD COLUMN:添加列。 +- DROP COLUMN:删除列。 +- MODIFY COLUMN:修改列定义,如果数据列的类型是可变长类型,那么可以使用此指令修改其宽度,只能改大,不能改小。 +- ADD TAG:给超级表添加一个标签。 +- DROP TAG:删除超级表的一个标签。从超级表删除某个标签后,该超级表下的所有子表也会自动删除该标签。 +- MODIFY TAG:修改超级表的一个标签的定义。如果标签的类型是可变长类型,那么可以使用此指令修改其宽度,只能改大,不能改小。 +- RENAME TAG:修改超级表的一个标签的名称。从超级表修改某个标签名后,该超级表下的所有子表也会自动更新该标签名。 + +### 增加列 ``` -ALTER STABLE stb_name ADD COLUMN field_name data_type; +ALTER STABLE stb_name ADD COLUMN col_name column_type; ``` -### 超级表删除列 +### 删除列 ``` -ALTER STABLE stb_name DROP COLUMN field_name; +ALTER STABLE stb_name DROP COLUMN col_name; ``` -### 超级表修改列宽 +### 修改列宽 ``` -ALTER STABLE stb_name MODIFY COLUMN field_name data_type(length); +ALTER STABLE stb_name MODIFY COLUMN col_name data_type(length); ``` -如果数据列的类型是可变长格式(BINARY 或 NCHAR),那么可以使用此指令修改其宽度(只能改大,不能改小)。(2.1.3.0 版本新增) - -## 修改超级表标签列 +如果数据列的类型是可变长格式(BINARY 或 NCHAR),那么可以使用此指令修改其宽度(只能改大,不能改小)。 ### 添加标签 ``` -ALTER STABLE stb_name ADD TAG new_tag_name tag_type; +ALTER STABLE stb_name ADD TAG tag_name tag_type; ``` 为 STable 增加一个新的标签,并指定新标签的类型。标签总数不能超过 128 个,总长度不超过 16KB 。 @@ -99,7 +133,7 @@ ALTER STABLE stb_name DROP TAG tag_name; ### 修改标签名 ``` -ALTER STABLE stb_name CHANGE TAG old_tag_name new_tag_name; +ALTER STABLE stb_name RENAME TAG old_tag_name new_tag_name; ``` 修改超级表的标签名,从超级表修改某个标签名后,该超级表下的所有子表也会自动更新该标签名。 diff --git a/docs/zh/12-taos-sql/05-insert.md b/docs/zh/12-taos-sql/05-insert.md index 04118303f3f6517d65d8ecbbe9fdeb774a3177b7..c91e70c481055b804d88c8911fb454a3dd15b799 100644 --- a/docs/zh/12-taos-sql/05-insert.md +++ b/docs/zh/12-taos-sql/05-insert.md @@ -5,7 +5,7 @@ title: 数据写入 ## 写入语法 -``` +```sql INSERT INTO tb_name [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)] @@ -18,46 +18,64 @@ INSERT INTO ...]; ``` -## 插入一条或多条记录 +**关于时间戳** + +1. TDengine 要求插入的数据必须要有时间戳,插入数据的时间戳要注意以下几点: + +2. 时间戳不同的格式语法会有不同的精度影响。字符串格式的时间戳写法不受所在 DATABASE 的时间精度设置影响;而长整形格式的时间戳写法会受到所在 DATABASE 的时间精度设置影响。例如,时间戳"2021-07-13 16:16:48"的 UNIX 秒数为 1626164208。则其在毫秒精度下需要写作 1626164208000,在微秒精度设置下就需要写为 1626164208000000,纳秒精度设置下需要写为 1626164208000000000。 + +3. 一次插入多行数据时,不要把首列的时间戳的值都写 NOW。否则会导致语句中的多条记录使用相同的时间戳,于是就可能出现相互覆盖以致这些数据行无法全部被正确保存。其原因在于,NOW 函数在执行中会被解析为所在 SQL 语句的客户端执行时间,出现在同一语句中的多个 NOW 标记也就会被替换为完全相同的时间戳取值。 + 允许插入的最老记录的时间戳,是相对于当前服务器时间,减去配置的 KEEP 值(数据保留的天数)。允许插入的最新记录的时间戳,是相对于当前服务器时间,加上配置的 DURATION 值(数据文件存储数据的时间跨度,单位为天)。KEEP 和 DURATION 都是可以在创建数据库时指定的,缺省值分别是 3650 天和 10 天。 + +**语法说明** + +1. USING 子句是自动建表语法。如果用户在写数据时并不确定某个表是否存在,此时可以在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表。自动建表时,要求必须以超级表为模板,并写明数据表的 TAGS 取值。可以只是指定部分 TAGS 列的取值,未被指定的 TAGS 列将置为 NULL。 + +2. 可以指定要插入值的列,对于为指定的列数据库将自动填充为 NULL。 + +3. VALUES 语法表示了要插入的一行或多行数据。 + +4. FILE 语法表示数据来自于 CSV 文件(英文逗号分隔、英文单引号括住每个值),CSV 文件无需表头。 + +5. 无论使用哪种语法,均可以在一条 INSERT 语句中同时向多个表插入数据。 + +6. INSERT 语句是完整解析后再执行的,对如下语句,不会再出现数据错误但建表成功的情况: + + ```sql + INSERT INTO d1001 USING meters TAGS('Beijing.Chaoyang', 2) VALUES('a'); + ``` + +7. 对于向多个子表插入数据的情况,依然会有部分数据写入失败,部分数据写入成功的情况。这是因为多个子表可能分布在不同的 VNODE 上,客户端将 INSERT 语句完整解析后,将数据发往各个涉及的 VNODE 上,每个 VNODE 独立进行写入操作。如果某个 VNODE 因为某些原因(比如网络问题或磁盘故障)导致写入失败,并不会影响其他 VNODE 节点的写入。 + +## 插入一条记录 指定已经创建好的数据子表的表名,并通过 VALUES 关键字提供一行或多行数据,即可向数据库写入这些数据。例如,执行如下语句可以写入一行记录: -``` +```sql INSERT INTO d1001 VALUES (NOW, 10.2, 219, 0.32); ``` +## 插入多条记录 + 或者,可以通过如下语句写入两行记录: -``` +```sql INSERT INTO d1001 VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32) (1626164208000, 10.15, 217, 0.33); ``` -:::note - -1. 在第二个例子中,两行记录的首列时间戳使用了不同格式的写法。其中字符串格式的时间戳写法不受所在 DATABASE 的时间精度设置影响;而长整形格式的时间戳写法会受到所在 DATABASE 的时间精度设置影响——例子中的时间戳在毫秒精度下可以写作 1626164208000,而如果是在微秒精度设置下就需要写为 1626164208000000,纳秒精度设置下需要写为 1626164208000000000。 -2. 在使用“插入多条记录”方式写入数据时,不能把第一列的时间戳取值都设为 NOW,否则会导致语句中的多条记录使用相同的时间戳,于是就可能出现相互覆盖以致这些数据行无法全部被正确保存。其原因在于,NOW 函数在执行中会被解析为所在 SQL 语句的实际执行时间,出现在同一语句中的多个 NOW 标记也就会被替换为完全相同的时间戳取值。 -3. 允许插入的最老记录的时间戳,是相对于当前服务器时间,减去配置的 keep 值(数据保留的天数);允许插入的最新记录的时间戳,是相对于当前服务器时间,加上配置的 days 值(数据文件存储数据的时间跨度,单位为天)。keep 和 days 都是可以在创建数据库时指定的,缺省值分别是 3650 天和 10 天。 - -::: - -## 插入记录,数据对应到指定的列 +## 指定列插入 向数据子表中插入记录时,无论插入一行还是多行,都可以让数据对应到指定的列。对于 SQL 语句中没有出现的列,数据库将自动填充为 NULL。主键(时间戳)不能为 NULL。例如: -``` +```sql INSERT INTO d1001 (ts, current, phase) VALUES ('2021-07-13 14:06:33.196', 10.27, 0.31); ``` -:::info -如果不指定列,也即使用全列模式——那么在 VALUES 部分提供的数据,必须为数据表的每个列都显式地提供数据。全列模式写入速度会远快于指定列,因此建议尽可能采用全列写入方式,此时空列可以填入 NULL。 - -::: - ## 向多个表插入记录 可以在一条语句中,分别向多个表插入一条或多条记录,并且也可以在插入过程中指定列。例如: -``` +```sql INSERT INTO d1001 VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-13 14:06:35.779', 10.15, 217, 0.33) d1002 (ts, current, phase) VALUES ('2021-07-13 14:06:34.255', 10.27, 0.31); ``` @@ -66,28 +84,24 @@ INSERT INTO d1001 VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07- 如果用户在写数据时并不确定某个表是否存在,此时可以在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表。自动建表时,要求必须以超级表为模板,并写明数据表的 TAGS 取值。例如: -``` +```sql INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32); ``` 也可以在自动建表时,只是指定部分 TAGS 列的取值,未被指定的 TAGS 列将置为 NULL。例如: -``` +```sql INSERT INTO d21001 USING meters (groupId) TAGS (2) VALUES ('2021-07-13 14:06:33.196', 10.15, 217, 0.33); ``` 自动建表语法也支持在一条语句中向多个表插入记录。例如: -``` +```sql INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-13 14:06:35.779', 10.15, 217, 0.33) d21002 USING meters (groupId) TAGS (2) VALUES ('2021-07-13 14:06:34.255', 10.15, 217, 0.33) d21003 USING meters (groupId) TAGS (2) (ts, current, phase) VALUES ('2021-07-13 14:06:34.255', 10.27, 0.31); ``` -:::info -在 2.0.20.5 版本之前,在使用自动建表语法并指定列时,子表的列名必须紧跟在子表名称后面,而不能如例子里那样放在 TAGS 和 VALUES 之间。从 2.0.20.5 版本开始,两种写法都可以,但不能在一条 SQL 语句中混用,否则会报语法错误。 -::: - ## 插入来自文件的数据记录 除了使用 VALUES 关键字插入一行或多行数据外,也可以把要写入的数据放在 CSV 文件中(英文逗号分隔、英文单引号括住每个值)供 SQL 指令读取。其中 CSV 文件无需表头。例如,如果 /tmp/csvfile.csv 文件的内容为: @@ -99,51 +113,19 @@ INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) VALUES ('202 那么通过如下指令可以把这个文件中的数据写入子表中: -``` +```sql INSERT INTO d1001 FILE '/tmp/csvfile.csv'; ``` ## 插入来自文件的数据记录,并自动建表 -从 2.1.5.0 版本开始,支持在插入来自 CSV 文件的数据时,以超级表为模板来自动创建不存在的数据表。例如: - -``` +```sql INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile.csv'; ``` 也可以在一条语句中向多个表以自动建表的方式插入记录。例如: -``` +```sql INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile_21001.csv' d21002 USING meters (groupId) TAGS (2) FILE '/tmp/csvfile_21002.csv'; ``` - -## 历史记录写入 - -可使用 IMPORT 或者 INSERT 命令,IMPORT 的语法,功能与 INSERT 完全一样。 - -针对 insert 类型的 SQL 语句,我们采用的流式解析策略,在发现后面的错误之前,前面正确的部分 SQL 仍会执行。下面的 SQL 中,INSERT 语句是无效的,但是 d1001 仍会被创建。 - -``` -taos> CREATE TABLE meters(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS(location BINARY(30), groupId INT); -Query OK, 0 row(s) affected (0.008245s) - -taos> SHOW STABLES; - name | created_time | columns | tags | tables | -============================================================================================ - meters | 2020-08-06 17:50:27.831 | 4 | 2 | 0 | -Query OK, 1 row(s) in set (0.001029s) - -taos> SHOW TABLES; -Query OK, 0 row(s) in set (0.000946s) - -taos> INSERT INTO d1001 USING meters TAGS('California.SanFrancisco', 2) VALUES('a'); - -DB error: invalid SQL: 'a' (invalid timestamp) (0.039494s) - -taos> SHOW TABLES; - table_name | created_time | columns | stable_name | -====================================================================================================== - d1001 | 2020-08-06 17:52:02.097 | 4 | meters | -Query OK, 1 row(s) in set (0.001091s) -``` diff --git a/docs/zh/12-taos-sql/06-select.md b/docs/zh/12-taos-sql/06-select.md index 92abc4344b7562842fae71a84fe0cb9a168596ed..75f149d0aeba924635bbccd6607ed9d820155a8d 100644 --- a/docs/zh/12-taos-sql/06-select.md +++ b/docs/zh/12-taos-sql/06-select.md @@ -5,121 +5,118 @@ title: 数据查询 ## 查询语法 -``` -SELECT select_expr [, select_expr ...] - FROM {tb_name_list} - [WHERE where_condition] - [SESSION(ts_col, tol_val)] - [STATE_WINDOW(col)] - [INTERVAL(interval_val [, interval_offset]) [SLIDING sliding_val]] - [FILL(fill_mod_and_val)] - [GROUP BY col_list] - [ORDER BY col_list { DESC | ASC }] +```sql +SELECT {DATABASE() | CLIENT_VERSION() | SERVER_VERSION() | SERVER_STATUS() | NOW() | TODAY() | TIMEZONE()} + +SELECT [DISTINCT] select_list + from_clause + [WHERE condition] + [PARTITION BY tag_list] + [window_clause] + [group_by_clause] + [order_by_clasue] [SLIMIT limit_val [SOFFSET offset_val]] [LIMIT limit_val [OFFSET offset_val]] - [>> export_file]; -``` + [>> export_file] -## 通配符 +select_list: + select_expr [, select_expr] ... -通配符 \* 可以用于代指全部列。对于普通表,结果中只有普通列。 +select_expr: { + * + | query_name.* + | [schema_name.] {table_name | view_name} .* + | t_alias.* + | expr [[AS] c_alias] +} -``` -taos> SELECT * FROM d1001; - ts | current | voltage | phase | -====================================================================================== - 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 | -Query OK, 3 row(s) in set (0.001165s) -``` +from_clause: { + table_reference [, table_reference] ... + | join_clause [, join_clause] ... +} + +table_reference: + table_expr t_alias -在针对超级表,通配符包含 _标签列_ 。 +table_expr: { + table_name + | view_name + | ( subquery ) +} +join_clause: + table_reference [INNER] JOIN table_reference ON condition + +window_clause: { + SESSION(ts_col, tol_val) + | STATE_WINDOW(col) + | INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [WATERMARK(watermark_val)] [FILL(fill_mod_and_val)] + +changes_option: { + DURATION duration_val + | ROWS rows_val +} + +group_by_clause: + GROUP BY expr [, expr] ... HAVING condition + +order_by_clasue: + ORDER BY order_expr [, order_expr] ... + +order_expr: + {expr | position | c_alias} [DESC | ASC] [NULLS FIRST | NULLS LAST] ``` -taos> SELECT * FROM meters; - ts | current | voltage | phase | location | groupid | -===================================================================================================================================== - 2018-10-03 14:38:05.500 | 11.80000 | 221 | 0.28000 | California.LosAngeles | 2 | - 2018-10-03 14:38:16.600 | 13.40000 | 223 | 0.29000 | California.LosAngeles | 2 | - 2018-10-03 14:38:05.000 | 10.80000 | 223 | 0.29000 | California.LosAngeles | 3 | - 2018-10-03 14:38:06.500 | 11.50000 | 221 | 0.35000 | California.LosAngeles | 3 | - 2018-10-03 14:38:04.000 | 10.20000 | 220 | 0.23000 | California.SanFrancisco | 3 | - 2018-10-03 14:38:16.650 | 10.30000 | 218 | 0.25000 | California.SanFrancisco | 3 | - 2018-10-03 14:38:05.000 | 10.30000 | 219 | 0.31000 | California.SanFrancisco | 2 | - 2018-10-03 14:38:15.000 | 12.60000 | 218 | 0.33000 | California.SanFrancisco | 2 | - 2018-10-03 14:38:16.800 | 12.30000 | 221 | 0.31000 | California.SanFrancisco | 2 | -Query OK, 9 row(s) in set (0.002022s) + +## 列表 + +查询语句可以指定部分或全部列作为返回结果。数据列和标签列都可以出现在列表中。 + +### 通配符 + +通配符 \* 可以用于代指全部列。对于普通表,结果中只有普通列。对于超级表和子表,还包含了 TAG 列。 + +```sql +SELECT * FROM d1001; ``` 通配符支持表名前缀,以下两个 SQL 语句均为返回全部的列: -``` +```sql SELECT * FROM d1001; SELECT d1001.* FROM d1001; ``` -在 JOIN 查询中,带前缀的\*和不带前缀\*返回的结果有差别, \*返回全部表的所有列数据(不包含标签),带前缀的通配符,则只返回该表的列数据。 +在 JOIN 查询中,带表名前缀的\*和不带前缀\*返回的结果有差别, \*返回全部表的所有列数据(不包含标签),而带表名前缀的通配符,则只返回该表的列数据。 -``` -taos> SELECT * FROM d1001, d1003 WHERE d1001.ts=d1003.ts; - ts | current | voltage | phase | ts | current | voltage | phase | -================================================================================================================================== - 2018-10-03 14:38:05.000 | 10.30000| 219 | 0.31000 | 2018-10-03 14:38:05.000 | 10.80000| 223 | 0.29000 | -Query OK, 1 row(s) in set (0.017385s) +```sql +SELECT * FROM d1001, d1003 WHERE d1001.ts=d1003.ts; +SELECT d1001.* FROM d1001,d1003 WHERE d1001.ts = d1003.ts; ``` -``` -taos> SELECT d1001.* FROM d1001,d1003 WHERE d1001.ts = d1003.ts; - ts | current | voltage | phase | -====================================================================================== - 2018-10-03 14:38:05.000 | 10.30000 | 219 | 0.31000 | -Query OK, 1 row(s) in set (0.020443s) -``` +上面的查询语句中,前者返回 d1001 和 d1003 的全部列,而后者仅返回 d1001 的全部列。 在使用 SQL 函数来进行查询的过程中,部分 SQL 函数支持通配符操作。其中的区别在于: `count(*)`函数只返回一列。`first`、`last`、`last_row`函数则是返回全部列。 -``` -taos> SELECT COUNT(*) FROM d1001; - count(*) | -======================== - 3 | -Query OK, 1 row(s) in set (0.001035s) -``` - -``` -taos> SELECT FIRST(*) FROM d1001; - first(ts) | first(current) | first(voltage) | first(phase) | -========================================================================================= - 2018-10-03 14:38:05.000 | 10.30000 | 219 | 0.31000 | -Query OK, 1 row(s) in set (0.000849s) -``` +### 标签列 -## 标签列 +在超级表和子表的查询中可以指定 _标签列_,且标签列的值会与普通列的数据一起返回。 -从 2.0.14 版本开始,支持在普通表的查询中指定 _标签列_,且标签列的值会与普通列的数据一起返回。 - -``` -taos> SELECT location, groupid, current FROM d1001 LIMIT 2; - location | groupid | current | -====================================================================== - California.SanFrancisco | 2 | 10.30000 | - California.SanFrancisco | 2 | 12.60000 | -Query OK, 2 row(s) in set (0.003112s) +```sql +ELECT location, groupid, current FROM d1001 LIMIT 2; ``` -注意:普通表的通配符 \* 中并不包含 _标签列_。 +### 结果去重 -## 获取标签列或普通列的去重取值 +`DISINTCT` 关键字可以对结果集中的一列或多列进行去重,去除的列既可以是标签列也可以是数据列。 -从 2.0.15.0 版本开始,支持在超级表查询标签列时,指定 DISTINCT 关键字,这样将返回指定标签列的所有不重复取值。注意,在 2.1.6.0 版本之前,DISTINCT 只支持处理单个标签列,而从 2.1.6.0 版本开始,DISTINCT 可以对多个标签列进行处理,输出这些标签列取值不重复的组合。 +对标签列去重: ```sql SELECT DISTINCT tag_name [, tag_name ...] FROM stb_name; ``` -从 2.1.7.0 版本开始,DISTINCT 也支持对数据子表或普通表进行处理,也即支持获取单个普通列的不重复取值,或多个普通列取值的不重复组合。 +对数据列去重: ```sql SELECT DISTINCT col_name [, col_name ...] FROM tb_name; @@ -133,210 +130,162 @@ SELECT DISTINCT col_name [, col_name ...] FROM tb_name; ::: -## 结果集列名 +### 结果集列名 `SELECT`子句中,如果不指定返回结果集合的列名,结果集列名称默认使用`SELECT`子句中的表达式名称作为列名称。此外,用户可使用`AS`来重命名返回结果集合中列的名称。例如: -``` +```sql taos> SELECT ts, ts AS primary_key_ts FROM d1001; - ts | primary_key_ts | -==================================================== - 2018-10-03 14:38:05.000 | 2018-10-03 14:38:05.000 | - 2018-10-03 14:38:15.000 | 2018-10-03 14:38:15.000 | - 2018-10-03 14:38:16.800 | 2018-10-03 14:38:16.800 | -Query OK, 3 row(s) in set (0.001191s) ``` 但是针对`first(*)`、`last(*)`、`last_row(*)`不支持针对单列的重命名。 -## 隐式结果列 +### 隐式结果列 `Select_exprs`可以是表所属列的列名,也可以是基于列的函数表达式或计算式,数量的上限 256 个。当用户使用了`interval`或`group by tags`的子句以后,在最后返回结果中会强制返回时间戳列(第一列)和 group by 子句中的标签列。后续的版本中可以支持关闭 group by 子句中隐式列的输出,列输出完全由 select 子句控制。 -## 表(超级表)列表 +### 伪列 -FROM 关键字后面可以是若干个表(超级表)列表,也可以是子查询的结果。 -如果没有指定用户的当前数据库,可以在表名称之前使用数据库的名称来指定表所属的数据库。例如:`power.d1001` 方式来跨库使用表。 +**TBNAME** +`TBNAME` 可以视为超级表中一个特殊的标签,代表子表的表名。 + +获取一个超级表所有的子表名及相关的标签信息: +```mysql +SELECT TBNAME, location FROM meters; ``` -SELECT * FROM power.d1001; ------------------------------- -USE power; -SELECT * FROM d1001; + +统计超级表下辖子表数量: + +```mysql +SELECT COUNT(*) FROM (SELECT DISTINCT TBNAME FROM meters); ``` -## 特殊功能 +以上两个查询均只支持在 WHERE 条件子句中添加针对标签(TAGS)的过滤条件。例如: -部分特殊的查询功能可以不使用 FROM 子句执行。获取当前所在的数据库 database(): +**\_QSTART/\_QEND** -``` -taos> SELECT DATABASE(); - database() | -================================= - power | -Query OK, 1 row(s) in set (0.000079s) -``` +\_qstart 和\_qend 表示用户输入的查询时间范围,即 WHERE 子句中主键时间戳条件所限定的时间范围。如果 WHERE 子句中没有有效的主键时间戳条件,则时间范围为[-2^63, 2^63-1]。 -如果登录的时候没有指定默认数据库,且没有使用`USE`命令切换数据,则返回 NULL。 +\_qstart 和\_qend 不能用于 WHERE 子句中。 -``` -taos> SELECT DATABASE(); - database() | -================================= - NULL | -Query OK, 1 row(s) in set (0.000184s) -``` +**\_WSTART/\_WEND/\_WDURATION** +\_wstart 伪列、\_wend 伪列和\_wduration 伪列 +\_wstart 表示窗口起始时间戳,\_wend 表示窗口结束时间戳,\_wduration 表示窗口持续时长。 -获取服务器和客户端版本号: +这三个伪列只能用于时间窗口的窗口切分查询之中,且要在窗口切分子句之后出现。 -``` -taos> SELECT CLIENT_VERSION(); - client_version() | -=================== - 2.0.0.0 | -Query OK, 1 row(s) in set (0.000070s) +**\_c0/\_ROWTS** + +TDengine 中,所有表的第一列都必须是时间戳类型,且为其主键,\_rowts 伪列和\_c0 伪列均代表了此列的值。相比实际的主键时间戳列,使用伪列更加灵活,语义也更加标准。例如,可以和 max\min 等函数一起使用。 -taos> SELECT SERVER_VERSION(); - server_version() | -=================== - 2.0.0.0 | -Query OK, 1 row(s) in set (0.000077s) +```sql +select _rowts, max(current) from meters; ``` -服务器状态检测语句。如果服务器正常,返回一个数字(例如 1)。如果服务器异常,返回 error code。该 SQL 语法能兼容连接池对于 TDengine 状态的检查及第三方工具对于数据库服务器状态的检查。并可以避免出现使用了错误的心跳检测 SQL 语句导致的连接池连接丢失的问题。 +## 查询对象 -``` -taos> SELECT SERVER_STATUS(); - server_status() | -================== - 1 | -Query OK, 1 row(s) in set (0.000074s) +FROM 关键字后面可以是若干个表(超级表)列表,也可以是子查询的结果。 +如果没有指定用户的当前数据库,可以在表名称之前使用数据库的名称来指定表所属的数据库。例如:`power.d1001` 方式来跨库使用表。 -taos> SELECT SERVER_STATUS() AS status; - status | -============== - 1 | -Query OK, 1 row(s) in set (0.000081s) -``` +TDengine 支持基于时间戳主键的 INNER JOIN,规则如下: -## \_block_dist 函数 +1. 支持 FROM 表列表和显式的 JOIN 子句两种语法。 +2. 对于普通表和子表,ON 条件必须有且只有时间戳主键的等值条件。 +3. 对于超级表,ON 条件在时间戳主键的等值条件之外,还要求有可以一一对应的标签列等值条件,不支持 OR 条件。 +4. 参与 JOIN 计算的表只能是同一种类型,即只能都是超级表,或都是子表,或都是普通表。 +5. JOIN 两侧均支持子查询。 +6. 参与 JOIN 的表个数上限为 10 个。 +7. 不支持与 FILL 子句混合使用。 -**功能说明**: 用于获得指定的(超级)表的数据块分布信息 +## GROUP BY -```txt title="语法" -SELECT _block_dist() FROM { tb_name | stb_name } -``` +如果在语句中同时指定了 GROUP BY 子句,那么 SELECT 列表只能包含如下表达式: -**返回结果类型**:字符串。 +1. 常量 +2. 聚集函数 +3. 与 GROUP BY 后表达式相同的表达式。 +4. 包含前面表达式的表达式 -**适用数据类型**:不能输入任何参数。 +GROUP BY 子句对每行数据按 GROUP BY 后的表达式的值进行分组,并为每个组返回一行汇总信息。 -**嵌套子查询支持**:不支持子查询或嵌套查询。 +GROUP BY 子句中的表达式可以包含表或视图中的任何列,这些列不需要出现在 SELECT 列表中。 -**返回结果**: +该子句对行进行分组,但不保证结果集的顺序。若要对分组进行排序,请使用 ORDER BY 子句 -- 返回 FROM 子句中输入的表或超级表的数据块分布情况。不支持查询条件。 -- 返回的结果是该表或超级表的数据块所包含的行数的数据分布直方图。 -```txt title="返回结果" -summary: -5th=[392], 10th=[392], 20th=[392], 30th=[392], 40th=[792], 50th=[792] 60th=[792], 70th=[792], 80th=[792], 90th=[792], 95th=[792], 99th=[792] Min=[392(Rows)] Max=[800(Rows)] Avg=[666(Rows)] Stddev=[2.17] Rows=[2000], Blocks=[3], Size=[5.440(Kb)] Comp=[0.23] RowsInMem=[0] SeekHeaderTime=[1(us)] -``` +## PARTITON BY -**上述信息的说明如下**: +PARTITION BY 子句是 TDengine 特色语法,按 part_list 对数据进行切分,在每个切分的分片中进行计算。 -- 查询的(超级)表所包含的存储在文件中的数据块(data block)中所包含的数据行的数量分布直方图信息:5%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 95%, 99% 的数值; -- 所有数据块中,包含行数最少的数据块所包含的行数量, 其中的 Min 指标 392 行。 -- 所有数据块中,包含行数最多的数据块所包含的行数量, 其中的 Max 指标 800 行。 -- 所有数据块行数的算数平均值 666 行(其中的 Avg 项)。 -- 所有数据块中行数分布的均方差为 2.17 ( stddev )。 -- 数据块包含的行的总数为 2000 行(Rows)。 -- 数据块总数是 3 个数据块 (Blocks)。 -- 数据块占用磁盘空间大小 5.44 Kb (size)。 -- 压缩后的数据块的大小除以原始数据的所获得的压缩比例: 23%(Comp),及压缩后的数据规模是原始数据规模的 23%。 -- 内存中存在的数据行数是 0,表示内存中没有数据缓存。 -- 获取数据块信息的过程中读取头文件的时间开销 1 微秒(SeekHeaderTime)。 +详见 [TDengine 特色查询](../distinguished) -**支持版本**:指定计算算法的功能从 2.1.0.x 版本开始,2.1.0.0 之前的版本不支持指定使用算法的功能。 +## ORDER BY -## TAOS SQL 中特殊关键词 +ORDER BY 子句对结果集排序。如果没有指定 ORDER BY,无法保证同一语句多次查询的结果集返回顺序一致。 -- `TBNAME`: 在超级表查询中可视为一个特殊的标签,代表查询涉及的子表名 -- `_c0`: 表示表(超级表)的第一列 +ORDER BY 后可以使用位置语法,位置标识为正整数,从 1 开始,表示使用 SELECT 列表的第几个表达式进行排序。 -## 小技巧 +ASC 表示升序,DESC 表示降序。 -获取一个超级表所有的子表名及相关的标签信息: +NULLS 语法用来指定 NULL 值在排序中输出的位置。NULLS LAST 是升序的默认值,NULLS FIRST 是降序的默认值。 + +## LIMIT + +LIMIT 控制输出条数,OFFSET 指定从第几条之后开始输出。LIMIT/OFFSET 对结果集的执行顺序在 ORDER BY 之后。LIMIT 5 OFFSET 2 可以简写为 LIMIT 2, 5,都输出第 3 行到第 7 行数据。 + +在有 PARTITION BY 子句时,LIMIT 控制的是每个切分的分片中的输出,而不是总的结果集输出。 + +## SLIMIT + +SLIMIT 和 PARTITION BY 子句一起使用,用来控制输出的分片的数量。SLIMIT 5 SOFFSET 2 可以简写为 SLIMIT 2, 5,都表示输出第 3 个到第 7 个分片。 + +需要注意,如果有 ORDER BY 子句,则输出只有一个分片。 + +## 特殊功能 + +部分特殊的查询功能可以不使用 FROM 子句执行。 + +### 获取当前数据库 +下面的命令可以获取当前所在的数据库 database(),如果登录的时候没有指定默认数据库,且没有使用`USE`命令切换数据,则返回 NULL。 + +```sql +SELECT DATABASE(); ``` -SELECT TBNAME, location FROM meters; + +### 获取服务器和客户端版本号 + +```sql +SELECT CLIENT_VERSION(); +SELECT SERVER_VERSION(); ``` -统计超级表下辖子表数量: +### 获取服务器状态 + +服务器状态检测语句。如果服务器正常,返回一个数字(例如 1)。如果服务器异常,返回 error code。该 SQL 语法能兼容连接池对于 TDengine 状态的检查及第三方工具对于数据库服务器状态的检查。并可以避免出现使用了错误的心跳检测 SQL 语句导致的连接池连接丢失的问题。 +```sql +SELECT SERVER_STATUS(); ``` -SELECT COUNT(TBNAME) FROM meters; + +### 获取当前时间 + +```sql +SELECT NOW(); ``` -以上两个查询均只支持在 WHERE 条件子句中添加针对标签(TAGS)的过滤条件。例如: +### 获取当前日期 +```sql +SELECT TODAY(); +``` + +### 获取当前时区 + +```sql +SELECT TIMEZONE(); ``` -taos> SELECT TBNAME, location FROM meters; - tbname | location | -================================================================== - d1004 | California.LosAngeles | - d1003 | California.LosAngeles | - d1002 | California.SanFrancisco | - d1001 | California.SanFrancisco | -Query OK, 4 row(s) in set (0.000881s) - -taos> SELECT COUNT(tbname) FROM meters WHERE groupId > 2; - count(tbname) | -======================== - 2 | -Query OK, 1 row(s) in set (0.001091s) -``` - -- 可以使用 \* 返回所有列,或指定列名。可以对数字列进行四则运算,可以给输出的列取列名。 - - 暂不支持含列名的四则运算表达式用于条件过滤算子(例如,不支持 `where a*2>6;`,但可以写 `where a>6/2;`)。 - - 暂不支持含列名的四则运算表达式作为 SQL 函数的应用对象(例如,不支持 `select min(2*a) from t;`,但可以写 `select 2*min(a) from t;`)。 -- WHERE 语句可以使用各种逻辑判断来过滤数字值,或使用通配符来过滤字符串。 -- 输出结果缺省按首列时间戳升序排序,但可以指定按降序排序( \_c0 指首列时间戳)。使用 ORDER BY 对其他字段进行排序,排序结果顺序不确定。 -- 参数 LIMIT 控制输出条数,OFFSET 指定从第几条开始输出。LIMIT/OFFSET 对结果集的执行顺序在 ORDER BY 之后。且 `LIMIT 5 OFFSET 2` 可以简写为 `LIMIT 2, 5`。 - - 在有 GROUP BY 子句的情况下,LIMIT 参数控制的是每个分组中至多允许输出的条数。 -- 参数 SLIMIT 控制由 GROUP BY 指令划分的分组中,至多允许输出几个分组的数据。且 `SLIMIT 5 SOFFSET 2` 可以简写为 `SLIMIT 2, 5`。 -- 通过 “>>” 输出结果可以导出到指定文件。 - -## 条件过滤操作 - -| **Operation** | **Note** | **Applicable Data Types** | -| ------------- | ------------------------ | ----------------------------------------- | -| > | larger than | all types except bool | -| < | smaller than | all types except bool | -| >= | larger than or equal to | all types except bool | -| <= | smaller than or equal to | all types except bool | -| = | equal to | all types | -| <\> | not equal to | all types | -| is [not] null | is null or is not null | all types | -| between and | within a certain range | all types except bool | -| in | match any value in a set | all types except first column `timestamp` | -| like | match a wildcard string | **`binary`** **`nchar`** | -| match/nmatch | filter regex | **`binary`** **`nchar`** | - -**使用说明**: - -- <\> 算子也可以写为 != ,请注意,这个算子不能用于数据表第一列的 timestamp 字段。 -- like 算子使用通配符字符串进行匹配检查。 - - 在通配符字符串中:'%'(百分号)匹配 0 到任意个字符;'\_'(下划线)匹配单个任意 ASCII 字符。 - - 如果希望匹配字符串中原本就带有的 \_(下划线)字符,那么可以在通配符字符串中写作 `\_`,也即加一个反斜线来进行转义。(从 2.2.0.0 版本开始支持) - - 通配符字符串最长不能超过 20 字节。(从 2.1.6.1 版本开始,通配符字符串的长度放宽到了 100 字节,并可以通过 taos.cfg 中的 maxWildCardsLength 参数来配置这一长度限制。但不建议使用太长的通配符字符串,将有可能严重影响 LIKE 操作的执行性能。) -- 同时进行多个字段的范围过滤,需要使用关键词 AND 来连接不同的查询条件,暂不支持 OR 连接的不同列之间的查询过滤条件。 - - 从 2.3.0.0 版本开始,已支持完整的同一列和/或不同列间的 AND/OR 运算。 -- 针对单一字段的过滤,如果是时间过滤条件,则一条语句中只支持设定一个;但针对其他的(普通)列或标签列,则可以使用 `OR` 关键字进行组合条件的查询过滤。例如: `((value > 20 AND value < 30) OR (value < 12))`。 - - 从 2.3.0.0 版本开始,允许使用多个时间过滤条件,但首列时间戳的过滤运算结果只能包含一个区间。 -- 从 2.0.17.0 版本开始,条件过滤开始支持 BETWEEN AND 语法,例如 `WHERE col2 BETWEEN 1.5 AND 3.25` 表示查询条件为“1.5 ≤ col2 ≤ 3.25”。 -- 从 2.1.4.0 版本开始,条件过滤开始支持 IN 算子,例如 `WHERE city IN ('California.SanFrancisco', 'California.SanDieo')`。说明:BOOL 类型写作 `{true, false}` 或 `{0, 1}` 均可,但不能写作 0、1 之外的整数;FLOAT 和 DOUBLE 类型会受到浮点数精度影响,集合内的值在精度范围内认为和数据行的值完全相等才能匹配成功;TIMESTAMP 类型支持非主键的列。 -- 从 2.3.0.0 版本开始,条件过滤开始支持正则表达式,关键字 match/nmatch,不区分大小写。 ## 正则表达式过滤 @@ -358,7 +307,7 @@ WHERE (column|tbname) **match/MATCH/nmatch/NMATCH** _regex_ ## JOIN 子句 -从 2.2.0.0 版本开始,TDengine 对内连接(INNER JOIN)中的自然连接(Natural join)操作实现了完整的支持。也即支持“普通表与普通表之间”、“超级表与超级表之间”、“子查询与子查询之间”进行自然连接。自然连接与内连接的主要区别是,自然连接要求参与连接的字段在不同的表/超级表中必须是同名字段。也即,TDengine 在连接关系的表达中,要求必须使用同名数据列/标签列的相等关系。 +TDengine 支持“普通表与普通表之间”、“超级表与超级表之间”、“子查询与子查询之间” 进行自然连接。自然连接与内连接的主要区别是,自然连接要求参与连接的字段在不同的表/超级表中必须是同名字段。也即,TDengine 在连接关系的表达中,要求必须使用同名数据列/标签列的相等关系。 在普通表与普通表之间的 JOIN 操作中,只能使用主键时间戳之间的相等关系。例如: @@ -429,7 +378,7 @@ UNION ALL SELECT ... TDengine 支持 UNION ALL 操作符。也就是说,如果多个 SELECT 子句返回结果集的结构完全相同(列名、列类型、列数、顺序),那么可以通过 UNION ALL 把这些结果集合并到一起。目前只支持 UNION ALL 模式,也即在结果集的合并过程中是不去重的。在同一个 sql 语句中,UNION ALL 最多支持 100 个。 -### SQL 示例 +## SQL 示例 对于下面的例子,表 tb1 用以下语句创建: diff --git a/docs/zh/12-taos-sql/08-delete-data.mdx b/docs/zh/12-taos-sql/08-delete-data.mdx index eafe8cff264b271384096adc2a0be9a7d01e579a..15becd259390c3c07f142a77ac2a602c5b7791ee 100644 --- a/docs/zh/12-taos-sql/08-delete-data.mdx +++ b/docs/zh/12-taos-sql/08-delete-data.mdx @@ -5,8 +5,6 @@ title: "删除数据" --- 删除数据是 TDengine 提供的根据指定时间段删除指定表或超级表中数据记录的功能,方便用户清理由于设备故障等原因产生的异常数据。 -注意:本功能只在企业版 2.6.0.0 及以后的版本中提供,如需此功能请点击下面的链接访问[企业版产品](https://www.taosdata.com/products#enterprise-edition-link) - **语法:** @@ -17,21 +15,21 @@ DELETE FROM [ db_name. ] tb_name [WHERE condition]; **功能:** 删除指定表或超级表中的数据记录 **参数:** - -- `db_name` : 可选参数,指定要删除表所在的数据库名,不填写则在当前数据库中 -- `tb_name` : 必填参数,指定要删除数据的表名,可以是普通表、子表,也可以是超级表。 -- `condition`: 可选参数,指定删除数据的过滤条件,不指定过滤条件则为表中所有数据,请慎重使用。特别说明,这里的where 条件中只支持对第一列时间列的过滤,如果是超级表,支持对 tag 列过滤。 + +- `db_name` : 可选参数,指定要删除表所在的数据库名,不填写则在当前数据库中 +- `tb_name` : 必填参数,指定要删除数据的表名,可以是普通表、子表,也可以是超级表。 +- `condition`: 可选参数,指定删除数据的过滤条件,不指定过滤条件则为表中所有数据,请慎重使用。特别说明,这里的 where 条件中只支持对第一列时间列的过滤。 **特别说明:** - -数据删除后不可恢复,请慎重使用。为了确保删除的数据确实是自己要删除的,建议可以先使用 `select` 语句加 `where` 后的删除条件查看要删除的数据内容,确认无误后再执行 `delete` 命令。 + +数据删除后不可恢复,请慎重使用。为了确保删除的数据确实是自己要删除的,建议可以先使用 `select` 语句加 `where` 后的删除条件查看要删除的数据内容,确认无误后再执行 `delete` 命令。 **示例:** - -`meters` 是一个超级表,`groupid` 是 int 类型的 tag 列,现在要删除 `meters` 表中时间小于 2021-10-01 10:40:00.100 且 tag 列 `groupid` 值为 1 的所有数据,sql 如下: + +`meters` 是一个超级表,`groupid` 是 int 类型的 tag 列,现在要删除 `meters` 表中时间小于 2021-10-01 10:40:00.100 的所有数据,sql 如下: ```sql -delete from meters where ts < '2021-10-01 10:40:00.100' and groupid=1 ; +delete from meters where ts < '2021-10-01 10:40:00.100' ; ``` 执行后显示结果为: diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index 7674967f09fb0c9e3069097dbc2bf35e93256992..7e4f3420b8afd98aea3a0906544df191797a527f 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -13,54 +13,54 @@ toc_max_heading_level: 4 #### ABS ```sql - SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] +SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**功能说明**:获得指定列的绝对值 +**功能说明**:获得指定字段的绝对值。 -**返回结果类型**:如果输入值为整数,输出值是 UBIGINT 类型。如果输入值是 FLOAT/DOUBLE 数据类型,输出值是 DOUBLE 数据类型。 +**返回结果类型**:与指定字段的原始数据类型一致。 **适用数据类型**:数值类型。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 **使用说明**:只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 #### ACOS ```sql - SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] +SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**功能说明**:获得指定列的反余弦结果 +**功能说明**:获得指定字段的反余弦结果。 -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**返回结果类型**:DOUBLE。 **适用数据类型**:数值类型。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 **使用说明**:只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 #### ASIN ```sql - SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] +SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**功能说明**:获得指定列的反正弦结果 +**功能说明**:获得指定字段的反正弦结果。 -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**返回结果类型**:DOUBLE。 **适用数据类型**:数值类型。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 **使用说明**:只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 @@ -68,85 +68,82 @@ toc_max_heading_level: 4 #### ATAN ```sql - SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] +SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**功能说明**:获得指定列的反正切结果 +**功能说明**:获得指定字段的反正切结果。 -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**返回结果类型**:DOUBLE。 **适用数据类型**:数值类型。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 **使用说明**:只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 #### CEIL -``` +```sql SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:获得指定列的向上取整数的结果。 +**功能说明**:获得指定字段的向上取整数的结果。 -**返回结果类型**:与指定列的原始数据类型一致。例如,如果指定列的原始数据类型为 Float,那么返回的数据类型也为 Float;如果指定列的原始数据类型为 Double,那么返回的数据类型也为 Double。 +**返回结果类型**:与指定字段的原始数据类型一致。 **适用数据类型**:数值类型。 -**适用于**: 普通表、超级表。 +**适用于**: 表和超级表。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**使用说明**: - -- 支持 +、-、\*、/ 运算,如 ceil(col1) + ceil(col2)。 -- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +**使用说明**: 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 #### COS ```sql - SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] +SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**功能说明**:获得指定列的余弦结果 +**功能说明**:获得指定字段的余弦结果。 -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**返回结果类型**:DOUBLE。 **适用数据类型**:数值类型。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 **使用说明**:只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 #### FLOOR -``` +```sql SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:获得指定列的向下取整数的结果。 +**功能说明**:获得指定字段的向下取整数的结果。 其他使用说明参见 CEIL 函数描述。 #### LOG ```sql - SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause] +SELECT LOG(field_name[, base]) FROM { tb_name | stb_name } [WHERE clause] ``` -**功能说明**:获得指定列对于底数 base 的对数 +**功能说明**:获得指定字段对于底数 base 的对数。如果 base 参数省略,则返回指定字段的自然对数值。 -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**返回结果类型**:DOUBLE。 **适用数据类型**:数值类型。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 **使用说明**:只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 @@ -154,83 +151,83 @@ SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; #### POW ```sql - SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] +SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] ``` -**功能说明**:获得指定列的指数为 power 的幂 +**功能说明**:获得指定字段的指数为 power 的幂。 -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**返回结果类型**:DOUBLE。 **适用数据类型**:数值类型。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 **使用说明**:只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 #### ROUND -``` +```sql SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:获得指定列的四舍五入的结果。 +**功能说明**:获得指定字段的四舍五入的结果。 其他使用说明参见 CEIL 函数描述。 #### SIN ```sql - SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] +SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**功能说明**:获得指定列的正弦结果 +**功能说明**:获得指定字段的正弦结果。 -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**返回结果类型**:DOUBLE。 **适用数据类型**:数值类型。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 **使用说明**:只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 #### SQRT ```sql - SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] +SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**功能说明**:获得指定列的平方根 +**功能说明**:获得指定字段的平方根。 -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**返回结果类型**:DOUBLE。 **适用数据类型**:数值类型。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 **使用说明**:只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 #### TAN ```sql - SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause] +SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**功能说明**:获得指定列的正切结果 +**功能说明**:获得指定字段的正切结果。 -**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL +**返回结果类型**:DOUBLE。 **适用数据类型**:数值类型。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 **使用说明**:只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 @@ -240,154 +237,154 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; #### CHAR_LENGTH -``` - SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] +```sql +SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` **功能说明**:以字符计数的字符串长度。 -**返回结果类型**:INT。如果输入值为NULL,输出值为NULL。 +**返回结果类型**:BIGINT。 -**适用数据类型**:VARCHAR, NCHAR +**适用数据类型**:VARCHAR, NCHAR。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 #### CONCAT ```sql - SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] +SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] ``` **功能说明**:字符串连接函数。 -**返回结果类型**:如果所有参数均为 VARCHAR 类型,则结果类型为 VARCHAR。如果参数包含NCHAR类型,则结果类型为NCHAR。如果输入值为NULL,输出值为NULL。 +**返回结果类型**:如果所有参数均为 VARCHAR 类型,则结果类型为 VARCHAR。如果参数包含NCHAR类型,则结果类型为NCHAR。如果参数包含NULL值,则输出值为NULL。 **适用数据类型**:VARCHAR, NCHAR。 该函数最小参数个数为2个,最大参数个数为8个。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 #### CONCAT_WS -``` - SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] +```sql +SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] ``` **功能说明**:带分隔符的字符串连接函数。 -**返回结果类型**:如果所有参数均为VARCHAR类型,则结果类型为VARCHAR。如果参数包含NCHAR类型,则结果类型为NCHAR。如果输入值为NULL,输出值为NULL。如果separator值不为NULL,其他输入为NULL,输出为空串。 +**返回结果类型**:如果所有参数均为VARCHAR类型,则结果类型为VARCHAR。如果参数包含NCHAR类型,则结果类型为NCHAR。如果参数包含NULL值,则输出值为NULL。 **适用数据类型**:VARCHAR, NCHAR。 该函数最小参数个数为3个,最大参数个数为9个。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 #### LENGTH -``` - SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] +```sql +SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` **功能说明**:以字节计数的字符串长度。 -**返回结果类型**:INT。 +**返回结果类型**:BIGINT。 **适用数据类型**:输入参数是 VARCHAR 类型或者 NCHAR 类型的字符串或者列。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 #### LOWER -``` - SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] +```sql +SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` **功能说明**:将字符串参数值转换为全小写字母。 -**返回结果类型**:同输入类型。如果输入值为NULL,输出值为NULL。 +**返回结果类型**:与输入字段的原始类型相同。 -**适用数据类型**:输入参数是 VARCHAR 类型或者 NCHAR 类型的字符串或者列。 +**适用数据类型**:VARCHAR, NCHAR。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 #### LTRIM -``` - SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] +```sql +SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` **功能说明**:返回清除左边空格后的字符串。 -**返回结果类型**:同输入类型。如果输入值为NULL,输出值为NULL。 +**返回结果类型**:与输入字段的原始类型相同。 -**适用数据类型**:输入参数是 VARCHAR 类型或者 NCHAR 类型的字符串或者列。 +**适用数据类型**:VARCHAR, NCHAR。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 #### RTRIM -``` - SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] +```sql +SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` **功能说明**:返回清除右边空格后的字符串。 -**返回结果类型**:同输入类型。如果输入值为NULL,输出值为NULL。 +**返回结果类型**:与输入字段的原始类型相同。 -**适用数据类型**:输入参数是 VARCHAR 类型或者 NCHAR 类型的字符串或者列。 +**适用数据类型**:VARCHAR, NCHAR。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 #### SUBSTR -``` - SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] +```sql +SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] ``` -**功能说明**:从源字符串 str 中的指定位置 pos 开始取一个长度为 len 的子串并返回。 +**功能说明**:从源字符串 str 中的指定位置 pos 开始取一个长度为 len 的子串并返回。如果输入参数 len 被忽略,返回的子串包含从 pos 开始的整个字串。 -**返回结果类型**:同输入类型。如果输入值为NULL,输出值为NULL。 +**返回结果类型**:与输入字段的原始类型相同。 -**适用数据类型**:输入参数是 VARCHAR 类型或者 NCHAR 类型的字符串或者列。输入参数pos可以为正数,也可以为负数。如果pos是正数,表示开始位置从字符串开头正数计算。如果pos为负数,表示开始位置从字符串结尾倒数计算。如果输入参数len被忽略,返回的子串包含从pos开始的整个字串。 +**适用数据类型**:VARCHAR, NCHAR。输入参数 pos 可以为正数,也可以为负数。如果 pos 是正数,表示开始位置从字符串开头正数计算。如果 pos 为负数,表示开始位置从字符串结尾倒数计算。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 #### UPPER -``` - SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause] +```sql +SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` **功能说明**:将字符串参数值转换为全大写字母。 -**返回结果类型**:同输入类型。如果输入值为NULL,输出值为NULL。 +**返回结果类型**:与输入字段的原始类型相同。 -**适用数据类型**:输入参数是 VARCHAR 类型或者 NCHAR 类型的字符串或者列。 +**适用数据类型**:VARCHAR, NCHAR。 **嵌套子查询支持**:适用于内层查询和外层查询。 -**适用于**: 表和超级表 +**适用于**: 表和超级表。 ### 转换函数 @@ -397,19 +394,22 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; #### CAST ```sql - SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] +SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**功能说明**:数据类型转换函数,输入参数 expression 支持普通列、常量、标量函数及它们之间的四则运算,只适用于 select 子句中。 +**功能说明**:数据类型转换函数,返回 expression 转换为 type_name 指定的类型后的结果。只适用于 select 子句中。 + +**返回结果类型**:CAST 中指定的类型(type_name)。 + +**适用数据类型**:输入参数 expression 的类型可以是BLOB、MEDIUMBLOB和JSON外的所有类型。 -**返回结果类型**:CAST 中指定的类型(type_name),可以是 BIGINT、BIGINT UNSIGNED、BINARY、VARCHAR、NCHAR和TIMESTAMP。 +**嵌套子查询支持**:适用于内层查询和外层查询。 -**适用数据类型**:输入参数 expression 的类型可以是BLOB、MEDIUMBLOB和JSON外的所有类型 +**适用于**: 表和超级表。 **使用说明**: - 对于不能支持的类型转换会直接报错。 -- 如果输入值为NULL则输出值也为NULL。 - 对于类型支持但某些值无法正确转换的情况对应的转换后的值以转换函数输出为准。目前可能遇到的几种情况: 1)字符串类型转换数值类型时可能出现的无效字符情况,例如"a"可能转为0,但不会报错。 2)转换到数值类型时,数值大于type_name可表示的范围时,则会溢出,但不会报错。 @@ -418,20 +418,23 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; #### TO_ISO8601 ```sql -SELECT TO_ISO8601(ts_val | ts_col) FROM { tb_name | stb_name } [WHERE clause]; +SELECT TO_ISO8601(ts[, timezone]) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:将 UNIX 时间戳转换成为 ISO8601 标准的日期时间格式,并附加客户端时区信息。 +**功能说明**:将 UNIX 时间戳转换成为 ISO8601 标准的日期时间格式,并附加时区信息。timezone 参数允许用户为输出结果指定附带任意时区信息。如果 timezone 参数省略,输出结果附带当前客户端的系统时区信息。 **返回结果数据类型**:VARCHAR 类型。 -**适用数据类型**:UNIX 时间戳常量或是 TIMESTAMP 类型的列 +**适用数据类型**:INTEGER, TIMESTAMP。 -**适用于**:表、超级表。 +**嵌套子查询支持**:适用于内层查询和外层查询。 + +**适用于**: 表和超级表。 **使用说明**: -- 如果输入是 UNIX 时间戳常量,返回格式精度由时间戳的位数决定; +- timezone 参数允许输入的时区格式为: [z/Z, +/-hhmm, +/-hh, +/-hh:mm]。例如,TO_ISO8601(1, "+00:00")。 +- 如果输入是表示 UNIX 时间戳的整形,返回格式精度由时间戳的位数决定; - 如果输入是 TIMSTAMP 类型的列,返回格式的时间戳精度与当前 DATABASE 设置的时间精度一致。 @@ -443,32 +446,34 @@ SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause]; **功能说明**: 将字符串常量转换为 JSON 类型。 -**返回结果数据类型**: JSON +**返回结果数据类型**: JSON。 **适用数据类型**: JSON 字符串,形如 '{ "literal" : literal }'。'{}'表示空值。键必须为字符串字面量,值可以为数值字面量、字符串字面量、布尔字面量或空值字面量。str_literal中不支持转义符。 -**适用于**: 表和超级表 - **嵌套子查询支持**:适用于内层查询和外层查询。 +**适用于**: 表和超级表。 + #### TO_UNIXTIMESTAMP ```sql -SELECT TO_UNIXTIMESTAMP(datetime_string | ts_col) FROM { tb_name | stb_name } [WHERE clause]; +SELECT TO_UNIXTIMESTAMP(datetime_string) FROM { tb_name | stb_name } [WHERE clause]; ``` **功能说明**:将日期时间格式的字符串转换成为 UNIX 时间戳。 -**返回结果数据类型**:长整型 INT64。 +**返回结果数据类型**:BIGINT。 -**应用字段**:字符串常量或是 VARCHAR/NCHAR 类型的列。 +**应用字段**:VARCHAR, NCHAR。 -**适用于**:表、超级表。 +**嵌套子查询支持**:适用于内层查询和外层查询。 + +**适用于**:表和超级表。 **使用说明**: -- 输入的日期时间字符串须符合 ISO8601/RFC3339 标准,无法转换的字符串格式将返回 0。 +- 输入的日期时间字符串须符合 ISO8601/RFC3339 标准,无法转换的字符串格式将返回 NULL。 - 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 @@ -488,11 +493,13 @@ INSERT INTO tb_name VALUES (NOW(), ...); **功能说明**:返回客户端当前系统时间。 -**返回结果数据类型**:TIMESTAMP 时间戳类型。 +**返回结果数据类型**:TIMESTAMP。 **应用字段**:在 WHERE 或 INSERT 语句中使用时只能作用于 TIMESTAMP 类型的字段。 -**适用于**:表、超级表。 +**适用于**:表和超级表。 + +**嵌套子查询支持**:适用于内层查询和外层查询。 **使用说明**: @@ -504,40 +511,42 @@ INSERT INTO tb_name VALUES (NOW(), ...); #### TIMEDIFF ```sql -SELECT TIMEDIFF(ts_val1 | datetime_string1 | ts_col1, ts_val2 | datetime_string2 | ts_col2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause]; +SELECT TIMEDIFF(ts | datetime_string1, ts | datetime_string2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause]; ``` **功能说明**:计算两个时间戳之间的差值,并近似到时间单位 time_unit 指定的精度。 -**返回结果数据类型**:长整型 INT64。 +**返回结果数据类型**:BIGINT。输入包含不符合时间日期格式字符串则返回 NULL。 -**应用字段**:UNIX 时间戳,日期时间格式的字符串,或者 TIMESTAMP 类型的列。 +**应用字段**:表示 UNIX 时间戳的 BIGINT, TIMESTAMP 类型,或符合日期时间格式的 VARCHAR, NCHAR 类型。 -**适用于**:表、超级表。 +**适用于**:表和超级表。 + +**嵌套子查询支持**:适用于内层查询和外层查询。 **使用说明**: - 支持的时间单位 time_unit 如下: - 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天)。 + 1b(纳秒), 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天), 1w(周)。 - 如果时间单位 time_unit 未指定, 返回的时间差值精度与当前 DATABASE 设置的时间精度一致。 #### TIMETRUNCATE ```sql -SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name | stb_name } [WHERE clause]; +SELECT TIMETRUNCATE(ts | datetime_string , time_unit) FROM { tb_name | stb_name } [WHERE clause]; ``` **功能说明**:将时间戳按照指定时间单位 time_unit 进行截断。 -**返回结果数据类型**:TIMESTAMP 时间戳类型。 +**返回结果数据类型**:TIMESTAMP。 -**应用字段**:UNIX 时间戳,日期时间格式的字符串,或者 TIMESTAMP 类型的列。 +**应用字段**:表示 UNIX 时间戳的 BIGINT, TIMESTAMP 类型,或符合日期时间格式的 VARCHAR, NCHAR 类型。 -**适用于**:表、超级表。 +**适用于**:表和超级表。 **使用说明**: - 支持的时间单位 time_unit 如下: - 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天)。 + 1b(纳秒), 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天), 1w(周)。 - 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 @@ -549,11 +558,11 @@ SELECT TIMEZONE() FROM { tb_name | stb_name } [WHERE clause]; **功能说明**:返回客户端当前时区信息。 -**返回结果数据类型**:VARCHAR 类型。 +**返回结果数据类型**:VARCHAR。 **应用字段**:无 -**适用于**:表、超级表。 +**适用于**:表和超级表。 #### TODAY @@ -566,11 +575,11 @@ INSERT INTO tb_name VALUES (TODAY(), ...); **功能说明**:返回客户端当日零时的系统时间。 -**返回结果数据类型**:TIMESTAMP 时间戳类型。 +**返回结果数据类型**:TIMESTAMP。 **应用字段**:在 WHERE 或 INSERT 语句中使用时只能作用于 TIMESTAMP 类型的字段。 -**适用于**:表、超级表。 +**适用于**:表和超级表。 **使用说明**: @@ -585,61 +594,79 @@ INSERT INTO tb_name VALUES (TODAY(), ...); TDengine 支持针对数据的聚合查询。提供如下聚合函数。 -### AVG +### APERCENTILE +```sql +SELECT APERCENTILE(field_name, P[, algo_type]) FROM { tb_name | stb_name } [WHERE clause] ``` + +**功能说明**:统计表/超级表中指定列的值的近似百分比分位数,与 PERCENTILE 函数相似,但是返回近似结果。 + +**返回数据类型**: DOUBLE。 + +**适用数据类型**:数值类型。 + +**适用于**:表和超级表。 + +**说明**: +- P值范围是[0,100],当为0时等同于MIN,为100时等同于MAX。 +- algo_type 取值为 "default" 或 "t-digest"。 输入为 "default" 时函数使用基于直方图算法进行计算。输入为 "t-digest" 时使用t-digest算法计算分位数的近似结果。如果不指定 algo_type 则使用 "default" 算法。 + +### AVG + +```sql SELECT AVG(field_name) FROM tb_name [WHERE clause]; ``` -**功能说明**:统计表/超级表中某列的平均值。 +**功能说明**:统计指定字段的平均值。 -**返回数据类型**:双精度浮点数 Double。 +**返回数据类型**:DOUBLE。 **适用数据类型**:数值类型。 -**适用于**:表、超级表。 +**适用于**:表和超级表。 ### COUNT -``` +```sql SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; ``` -**功能说明**:统计表/超级表中记录行数或某列的非空值个数。 +**功能说明**:统计指定字段的记录行数。 -**返回数据类型**:长整型 INT64。 +**返回数据类型**:BIGINT。 -**适用数据类型**:应用全部字段。 +**适用数据类型**:全部类型字段。 -**适用于**:表、超级表。 +**适用于**:表和超级表。 **使用说明**: - 可以使用星号(\*)来替代具体的字段,使用星号(\*)返回全部记录数量。 -- 针对同一表的(不包含 NULL 值)字段查询结果均相同。 -- 如果统计对象是具体的列,则返回该列中非 NULL 值的记录数量。 +- 如果统计字段是具体的列,则返回该列中非 NULL 值的记录数量。 ### ELAPSED -```mysql +```sql SELECT ELAPSED(ts_primary_key [, time_unit]) FROM { tb_name | stb_name } [WHERE clause] [INTERVAL(interval [, offset]) [SLIDING sliding]]; ``` **功能说明**:elapsed函数表达了统计周期内连续的时间长度,和twa函数配合使用可以计算统计曲线下的面积。在通过INTERVAL子句指定窗口的情况下,统计在给定时间范围内的每个窗口内有数据覆盖的时间范围;如果没有INTERVAL子句,则返回整个给定时间范围内的有数据覆盖的时间范围。注意,ELAPSED返回的并不是时间范围的绝对值,而是绝对值除以time_unit所得到的单位个数。 -**返回结果类型**:Double +**返回结果类型**:DOUBLE。 -**适用数据类型**:Timestamp类型 +**适用数据类型**:TIMESTAMP。 **支持的版本**:2.6.0.0 及以后的版本。 **适用于**: 表,超级表,嵌套查询的外层查询 **说明**: -- field_name参数只能是表的第一列,即timestamp主键列。 -- 按time_unit参数指定的时间单位返回,最小是数据库的时间分辨率。time_unit参数未指定时,以数据库的时间分辨率为时间单位。 +- field_name参数只能是表的第一列,即 TIMESTAMP 类型的主键列。 +- 按time_unit参数指定的时间单位返回,最小是数据库的时间分辨率。time_unit 参数未指定时,以数据库的时间分辨率为时间单位。支持的时间单位 time_unit 如下: + 1b(纳秒), 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天), 1w(周)。 - 可以和interval组合使用,返回每个时间窗口的时间戳差值。需要特别注意的是,除第一个时间窗口和最后一个时间窗口外,中间窗口的时间戳差值均为窗口长度。 - order by asc/desc不影响差值的计算结果。 - 对于超级表,需要和group by tbname子句组合使用,不可以直接使用。 @@ -647,9 +674,10 @@ SELECT ELAPSED(ts_primary_key [, time_unit]) FROM { tb_name | stb_name } [WHERE - 对于嵌套查询,仅当内层查询会输出隐式时间戳列时有效。例如select elapsed(ts) from (select diff(value) from sub1)语句,diff函数会让内层查询输出隐式时间戳列,此为主键列,可以用于elapsed函数的第一个参数。相反,例如select elapsed(ts) from (select * from sub1) 语句,ts列输出到外层时已经没有了主键列的含义,无法使用elapsed函数。此外,elapsed函数作为一个与时间线强依赖的函数,形如select elapsed(ts) from (select diff(value) from st group by tbname)尽管会返回一条计算结果,但并无实际意义,这种用法后续也将被限制。 - 不支持与leastsquares、diff、derivative、top、bottom、last_row、interp等函数混合使用。 + ### LEASTSQUARES -``` +```sql SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause]; ``` @@ -662,45 +690,30 @@ SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause] **适用于**:表。 -### MODE - -``` -SELECT MODE(field_name) FROM tb_name [WHERE clause]; -``` - -**功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,输出空。 - -**返回数据类型**:同应用的字段。 - -**适用数据类型**: 数值类型。 - -**适用于**:表和超级表。 - - ### SPREAD -``` +```sql SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:统计表/超级表中某列的最大值和最小值之差。 +**功能说明**:统计表中某列的最大值和最小值之差。 -**返回数据类型**:双精度浮点数。 +**返回数据类型**:DOUBLE。 -**适用数据类型**:数值类型或TIMESTAMP类型。 +**适用数据类型**:INTEGER, TIMESTAMP。 **适用于**:表和超级表。 ### STDDEV -``` +```sql SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; ``` **功能说明**:统计表中某列的均方差。 -**返回数据类型**:双精度浮点数 Double。 +**返回数据类型**:DOUBLE。 **适用数据类型**:数值类型。 @@ -709,13 +722,13 @@ SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; ### SUM -``` +```sql SELECT SUM(field_name) FROM tb_name [WHERE clause]; ``` **功能说明**:统计表/超级表中某列的和。 -**返回数据类型**:双精度浮点数 Double 和长整型 INT64。 +**返回数据类型**:DOUBLE, BIGINT。 **适用数据类型**:数值类型。 @@ -724,15 +737,15 @@ SELECT SUM(field_name) FROM tb_name [WHERE clause]; ### HYPERLOGLOG -``` +```sql SELECT HYPERLOGLOG(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` **功能说明**: - - 采用 hyperloglog 算法,返回某列的基数。该算法在数据量很大的情况下,可以明显降低内存的占用,但是求出来的基数是个估算值,标准误差(标准误差是多次实验,每次的平均数的标准差,不是与真实结果的误差)为 0.81%。 + - 采用 hyperloglog 算法,返回某列的基数。该算法在数据量很大的情况下,可以明显降低内存的占用,求出来的基数是个估算值,标准误差(标准误差是多次实验,每次的平均数的标准差,不是与真实结果的误差)为 0.81%。 - 在数据量较少的时候该算法不是很准确,可以使用 select count(data) from (select unique(col) as data from table) 的方法。 -**返回结果类型**:整形。 +**返回结果类型**:INTEGER。 **适用数据类型**:任何类型。 @@ -741,13 +754,13 @@ SELECT HYPERLOGLOG(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### HISTOGRAM -``` +```sql SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_name [WHERE clause]; ``` **功能说明**:统计数据按照用户指定区间的分布。 -**返回结果类型**:如归一化参数 normalized 设置为 1,返回结果为双精度浮点类型 DOUBLE,否则为长整形 INT64。 +**返回结果类型**:如归一化参数 normalized 设置为 1,返回结果为 DOUBLE 类型,否则为 BIGINT 类型。 **适用数据类型**:数值型字段。 @@ -769,28 +782,30 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam 3. normalized 是否将返回结果归一化到 0~1 之间 。有效输入为 0 和 1。 -## 选择函数 +### PERCENTILE -选择函数根据语义在查询结果集中选择一行或多行结果返回。用户可以同时指定输出 ts 列或其他列(包括 tbname 和标签列),这样就可以方便地知道被选出的值是源于哪个数据行的。 +```sql +SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; +``` -### APERCENTILE +**功能说明**:统计表中某列的值百分比分位数。 -``` -SELECT APERCENTILE(field_name, P[, algo_type]) -FROM { tb_name | stb_name } [WHERE clause] -``` +**返回数据类型**: DOUBLE。 -**功能说明**:统计表/超级表中指定列的值的近似百分比分位数,与 PERCENTILE 函数相似,但是返回近似结果。 +**应用字段**:数值类型。 + +**适用于**:表。 -**返回数据类型**: 双精度浮点数 Double。 +**使用说明**:*P*值取值范围 0≤*P*≤100,为 0 的时候等同于 MIN,为 100 的时候等同于 MAX。 -**适用数据类型**:数值类型。P值范围是[0,100],当为0时等同于MIN,为100时等同于MAX。如果不指定 algo_type 则使用默认算法 。 -**适用于**:表、超级表。 +## 选择函数 + +选择函数根据语义在查询结果集中选择一行或多行结果返回。用户可以同时指定输出 ts 列或其他列(包括 tbname 和标签列),这样就可以方便地知道被选出的值是源于哪个数据行的。 ### BOTTOM -``` +```sql SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ``` @@ -810,7 +825,7 @@ SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ### FIRST -``` +```sql SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` @@ -830,7 +845,7 @@ SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### INTERP -``` +```sql SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ RANGE(timestamp1,timestamp2) ] [EVERY(interval)] [FILL ({ VALUE | PREV | NULL | LINEAR | NEXT})]; ``` @@ -854,7 +869,7 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ ### LAST -``` +```sql SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` @@ -875,7 +890,7 @@ SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### LAST_ROW -``` +```sql SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; ``` @@ -894,7 +909,7 @@ SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; ### MAX -``` +```sql SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` @@ -909,7 +924,7 @@ SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### MIN -``` +```sql SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; ``` @@ -922,26 +937,46 @@ SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; **适用于**:表和超级表。 -### PERCENTILE +### MODE +```sql +SELECT MODE(field_name) FROM tb_name [WHERE clause]; ``` -SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; + +**功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,输出NULL。 + +**返回数据类型**:与输入数据类型一致。 + +**适用数据类型**:全部类型字段。 + +**适用于**:表和超级表。 + + +### SAMPLE + +```sql +SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] ``` -**功能说明**:统计表中某列的值百分比分位数。 + **功能说明**: 获取数据的 k 个采样值。参数 k 的合法输入范围是 1≤ k ≤ 1000。 -**返回数据类型**: 双精度浮点数 Double。 + **返回结果类型**: 同原始数据类型, 返回结果中带有该行记录的时间戳。 -**应用字段**:数值类型。 + **适用数据类型**: 在超级表查询中使用时,不能应用在标签之上。 -**适用于**:表。 + **嵌套子查询支持**: 适用于内层查询和外层查询。 -**使用说明**:*P*值取值范围 0≤*P*≤100,为 0 的时候等同于 MIN,为 100 的时候等同于 MAX。 + **适用于**:表和超级表。 + + **使用说明**: + + - 不能参与表达式计算;该函数可以应用在普通表和超级表上; + - 使用在超级表上的时候,需要搭配 PARTITION by tbname 使用,将结果强制规约到单个时间线。 ### TAIL -``` +```sql SELECT TAIL(field_name, k, offset_val) FROM {tb_name | stb_name} [WHERE clause]; ``` @@ -951,14 +986,14 @@ SELECT TAIL(field_name, k, offset_val) FROM {tb_name | stb_name} [WHERE clause]; **返回数据类型**:同应用的字段。 -**适用数据类型**:适合于除时间主列外的任何类型。 +**适用数据类型**:适合于除时间主键列外的任何类型。 **适用于**:表、超级表。 ### TOP -``` +```sql SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ``` @@ -968,7 +1003,7 @@ SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; **适用数据类型**:数值类型。 -**适用于**:表、超级表。 +**适用于**:表和超级表。 **使用说明**: @@ -978,7 +1013,7 @@ SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ### UNIQUE -``` +```sql SELECT UNIQUE(field_name) FROM {tb_name | stb_name} [WHERE clause]; ``` @@ -998,48 +1033,50 @@ SELECT UNIQUE(field_name) FROM {tb_name | stb_name} [WHERE clause]; ### CSUM ```sql - SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] +SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` **功能说明**:累加和(Cumulative sum),输出行与输入行数相同。 -**返回结果类型**: 输入列如果是整数类型返回值为长整型 (int64_t),浮点数返回值为双精度浮点数(Double)。无符号整数类型返回值为无符号长整型(uint64_t)。 返回结果中同时带有每行记录对应的时间戳。 +**返回结果类型**: 输入列如果是整数类型返回值为长整型 (int64_t),浮点数返回值为双精度浮点数(Double)。无符号整数类型返回值为无符号长整型(uint64_t)。 **适用数据类型**:数值类型。 **嵌套子查询支持**: 适用于内层查询和外层查询。 -**适用于**:表和超级表 +**适用于**:表和超级表。 **使用说明**: - 不支持 +、-、*、/ 运算,如 csum(col1) + csum(col2)。 - 只能与聚合(Aggregation)函数一起使用。 该函数可以应用在普通表和超级表上。 - - 使用在超级表上的时候,需要搭配 Group by tbname使用,将结果强制规约到单个时间线。 + - 使用在超级表上的时候,需要搭配 PARTITION BY tbname使用,将结果强制规约到单个时间线。 ### DERIVATIVE -``` +```sql SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHERE clause]; ``` **功能说明**:统计表中某列数值的单位变化率。其中单位时间区间的长度可以通过 time_interval 参数指定,最小可以是 1 秒(1s);ignore_negative 参数的值可以是 0 或 1,为 1 时表示忽略负值。 -**返回数据类型**:双精度浮点数。 +**返回数据类型**:DOUBLE。 **适用数据类型**:数值类型。 -**适用于**:表、超级表 - -**使用说明**: DERIVATIVE 函数可以在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname)。 +**适用于**:表和超级表。 +**使用说明**: + + - DERIVATIVE 函数可以在由 PARTITION BY 划分出单独时间线的情况下用于超级表(也即 PARTITION BY tbname)。 + - 可以与选择相关联的列一起使用。 例如: select \_rowts, DERIVATIVE() from。 ### DIFF - ```sql - SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHERE clause]; - ``` +```sql +SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHERE clause]; +``` **功能说明**:统计表中某列的值与前一行对应值的差。 ignore_negative 取值为 0|1 , 可以不填,默认值为 0. 不忽略负值。ignore_negative 为 1 时表示忽略负数。 @@ -1047,71 +1084,55 @@ SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHER **适用数据类型**:数值类型。 -**适用于**:表、超级表。 +**适用于**:表和超级表。 -**使用说明**: 输出结果行数是范围内总行数减一,第一行没有结果输出。 +**使用说明**: + + - 输出结果行数是范围内总行数减一,第一行没有结果输出。 + - 可以与选择相关联的列一起使用。 例如: select \_rowts, DIFF() from。 ### IRATE -``` +```sql SELECT IRATE(field_name) FROM tb_name WHERE clause; ``` **功能说明**:计算瞬时增长率。使用时间区间中最后两个样本数据来计算瞬时增长速率;如果这两个值呈递减关系,那么只取最后一个数用于计算,而不是使用二者差值。 -**返回数据类型**:双精度浮点数 Double。 +**返回数据类型**:DOUBLE。 **适用数据类型**:数值类型。 -**适用于**:表、超级表。 +**适用于**:表和超级表。 + ### MAVG ```sql - SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] +SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] ``` **功能说明**: 计算连续 k 个值的移动平均数(moving average)。如果输入行数小于 k,则无结果输出。参数 k 的合法输入范围是 1≤ k ≤ 1000。 - **返回结果类型**: 返回双精度浮点数类型。 + **返回结果类型**: DOUBLE。 **适用数据类型**: 数值类型。 **嵌套子查询支持**: 适用于内层查询和外层查询。 - **适用于**:表和超级表 + **适用于**:表和超级表。 **使用说明**: - 不支持 +、-、*、/ 运算,如 mavg(col1, k1) + mavg(col2, k1); - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用; - - 使用在超级表上的时候,需要搭配 Group by tbname使用,将结果强制规约到单个时间线。 - -### SAMPLE - -```sql - SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] -``` - - **功能说明**: 获取数据的 k 个采样值。参数 k 的合法输入范围是 1≤ k ≤ 1000。 - - **返回结果类型**: 同原始数据类型, 返回结果中带有该行记录的时间戳。 + - 使用在超级表上的时候,需要搭配 PARTITION BY tbname使用,将结果强制规约到单个时间线。 - **适用数据类型**: 在超级表查询中使用时,不能应用在标签之上。 - - **嵌套子查询支持**: 适用于内层查询和外层查询。 - - **适用于**:表和超级表 - - **使用说明**: - - - 不能参与表达式计算;该函数可以应用在普通表和超级表上; - - 使用在超级表上的时候,需要搭配 Group by tbname 使用,将结果强制规约到单个时间线。 ### STATECOUNT -``` +```sql SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clause]; ``` @@ -1119,10 +1140,10 @@ SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clau **参数范围**: -- oper : LT (小于)、GT(大于)、LE(小于等于)、GE(大于等于)、NE(不等于)、EQ(等于),不区分大小写。 +- oper : "LT" (小于)、"GT"(大于)、"LE"(小于等于)、"GE"(大于等于)、"NE"(不等于)、"EQ"(等于),不区分大小写。 - val : 数值型 -**返回结果类型**:整形。 +**返回结果类型**:INTEGER。 **适用数据类型**:数值类型。 @@ -1132,7 +1153,7 @@ SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clau **使用说明**: -- 该函数可以应用在普通表上,在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname) +- 该函数可以应用在普通表上,在由 PARTITION BY 划分出单独时间线的情况下用于超级表(也即 PARTITION BY tbname) - 不能和窗口操作一起使用,例如 interval/state_window/session_window。 @@ -1146,11 +1167,11 @@ SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [W **参数范围**: -- oper : LT (小于)、GT(大于)、LE(小于等于)、GE(大于等于)、NE(不等于)、EQ(等于),不区分大小写。 +- oper : "LT" (小于)、"GT"(大于)、"LE"(小于等于)、"GE"(大于等于)、"NE"(不等于)、"EQ"(等于),不区分大小写。 - val : 数值型 -- unit : 时间长度的单位,范围[1s、1m、1h ],不足一个单位舍去。默认为 1s。 +- unit : 时间长度的单位,可取值时间单位: 1b(纳秒), 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天), 1w(周)。如果省略,默认为当前数据库精度。 -**返回结果类型**:整形。 +**返回结果类型**:INTEGER。 **适用数据类型**:数值类型。 @@ -1160,32 +1181,32 @@ SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [W **使用说明**: -- 该函数可以应用在普通表上,在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname) +- 该函数可以应用在普通表上,在由 PARTITION BY 划分出单独时间线的情况下用于超级表(也即 PARTITION BY tbname) - 不能和窗口操作一起使用,例如 interval/state_window/session_window。 ### TWA -``` +```sql SELECT TWA(field_name) FROM tb_name WHERE clause; ``` **功能说明**:时间加权平均函数。统计表中某列在一段时间内的时间加权平均。 -**返回数据类型**:双精度浮点数 Double。 +**返回数据类型**:DOUBLE。 **适用数据类型**:数值类型。 -**适用于**:表、超级表。 +**适用于**:表和超级表。 -**使用说明**: TWA 函数可以在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname)。 +**使用说明**: TWA 函数可以在由 PARTITION BY 划分出单独时间线的情况下用于超级表(也即 PARTITION BY tbname)。 ## 系统信息函数 ### DATABASE -``` +```sql SELECT DATABASE(); ``` @@ -1194,7 +1215,7 @@ SELECT DATABASE(); ### CLIENT_VERSION -``` +```sql SELECT CLIENT_VERSION(); ``` @@ -1202,7 +1223,7 @@ SELECT CLIENT_VERSION(); ### SERVER_VERSION -``` +```sql SELECT SERVER_VERSION(); ``` @@ -1210,7 +1231,7 @@ SELECT SERVER_VERSION(); ### SERVER_STATUS -``` +```sql SELECT SERVER_VERSION(); ``` diff --git a/docs/zh/12-taos-sql/12-interval.md b/docs/zh/12-taos-sql/12-distinguished.md similarity index 91% rename from docs/zh/12-taos-sql/12-interval.md rename to docs/zh/12-taos-sql/12-distinguished.md index 8bf0c578e79009ba9ca6999ffb27a05b223d25b5..2dad49ece942d0530c12afa145c2e11682c23fe3 100644 --- a/docs/zh/12-taos-sql/12-interval.md +++ b/docs/zh/12-taos-sql/12-distinguished.md @@ -12,16 +12,16 @@ TDengine 提供的特色查询包括标签切分查询和窗口切分查询。 超级表查询中,当需要针对标签进行数据切分然后在切分出的数据空间内再进行一系列的计算时使用标签切分子句,标签切分的语句如下: ```sql -PARTITION BY tag_list +PARTITION BY part_list ``` -其中 `tag_list` 是标签列的列表,还可以包括 tbname 伪列。 +part_list 可以是任意的标量表达式,包括列、常量、标量函数和它们的组合。 -TDengine 按如下方式处理标签切分子句: +当 PARTITION BY 和标签一起使用时,TDengine 按如下方式处理标签切分子句: -标签切分子句位于 `WHERE` 子句之后,且不能和 `JOIN` 子句一起使用。 -标签切分子句将超级表数据按指定的标签组合进行切分,然后对每个切分的分片进行指定的计算。计算由之后的子句定义(窗口子句、`GROUP BY` 子句或`SELECT` 子句)。 -标签切分子句可以和窗口切分子句(或 `GROUP BY` 子句)一起使用,此时后面的子句作用在每个切分的分片上。例如,下面的示例将数据按标签 `location` 进行分组,并对每个组按 10 分钟进行降采样,取其最大值。 +- 标签切分子句位于 WHERE 子句之后,且不能和 JOIN 子句一起使用。 +- 标签切分子句将超级表数据按指定的标签组合进行切分,每个切分的分片进行指定的计算。计算由之后的子句定义(窗口子句、GROUP BY 子句或 SELECT 子句)。 +- 标签切分子句可以和窗口切分子句(或 GROUP BY 子句)一起使用,此时后面的子句作用在每个切分的分片上。例如,将数据按标签 location 进行分组,并对每个组按 10 分钟进行降采样,取其最大值。 ```sql select max(current) from meters partition by location interval(10m) diff --git a/docs/zh/12-taos-sql/13-tmq.md b/docs/zh/12-taos-sql/13-tmq.md new file mode 100644 index 0000000000000000000000000000000000000000..4d9c475a3829456916175d8a0518c47d67bc18ee --- /dev/null +++ b/docs/zh/12-taos-sql/13-tmq.md @@ -0,0 +1,66 @@ +--- +sidebar_label: 消息队列 +title: 消息队列 +--- + +TDengine 3.0.0.0 开始对消息队列做了大幅的优化和增强以简化用户的解决方案。 + +## 创建订阅主题 + +```sql +CREATE TOPIC [IF NOT EXISTS] topic_name AS {subquery | DATABASE db_name | STABLE stb_name }; +``` + +订阅主题包括三种:列订阅、超级表订阅和数据库订阅。 + +**列订阅是**用 subquery 描述,支持过滤和标量函数和 UDF 标量函数,不支持 JOIN、GROUP BY、窗口切分子句、聚合函数和 UDF 聚合函数。列订阅规则如下: + +1. TOPIC 一旦创建则返回结果的字段确定 +2. 被订阅或用于计算的列不可被删除、修改 +3. 列可以新增,但新增的列不出现在订阅结果字段中 +4. 对于 select \*,则订阅展开为创建时所有的列(子表、普通表为数据列,超级表为数据列加标签列) + +**超级表订阅和数据库订阅**规则如下: + +1. 被订阅主体的 schema 变更不受限 +2. 返回消息中 schema 是块级别的,每块的 schema 可能不一样 +3. 列变更后写入的数据若未落盘,将以写入时的 schema 返回 +4. 列变更后写入的数据若未已落盘,将以落盘时的 schema 返回 + +## 删除订阅主题 + +```sql +DROP TOPIC [IF EXISTS] topic_name; +``` + +此时如果该订阅主题上存在 consumer,则此 consumer 会收到一个错误。 + +## 查看订阅主题 + +## SHOW TOPICS + +```sql +SHOW TOPICS; +``` + +显示当前数据库下的所有主题的信息。 + +## 创建消费组 + +消费组的创建只能通过 TDengine 客户端驱动或者连接器所提供的 API 创建。 + +## 删除消费组 + +```sql +DROP CONSUMER GROUP [IF EXISTS] cgroup_name ON topic_name; +``` + +删除主题 topic_name 上的消费组 cgroup_name。 + +## 查看消费组 + +```sql +SHOW CONSUMERS; +``` + +显示当前数据库下所有活跃的消费者的信息。 diff --git a/docs/zh/12-taos-sql/14-stream.md b/docs/zh/12-taos-sql/14-stream.md index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7ff7da2bfb82e282cefb1a554283860d0e683de2 100644 --- a/docs/zh/12-taos-sql/14-stream.md +++ b/docs/zh/12-taos-sql/14-stream.md @@ -0,0 +1,122 @@ +--- +sidebar_label: 流式计算 +title: 流式计算 +--- + +在时序数据的处理中,经常要对原始数据进行清洗、预处理,再使用时序数据库进行长久的储存。用户通常需要在时序数据库之外再搭建 Kafka、Flink、Spark 等流计算处理引擎,增加了用户的开发成本和维护成本。 + +使用 TDengine 3.0 的流式计算引擎能够最大限度的减少对这些额外中间件的依赖,真正将数据的写入、预处理、长期存储、复杂分析、实时计算、实时报警触发等功能融为一体,并且,所有这些任务只需要使用 SQL 完成,极大降低了用户的学习成本、使用成本。 + +## 创建流式计算 + +```sql +CREATE STREAM [IF NOT EXISTS] stream_name [stream_options] INTO stb_name AS subquery +stream_options: { + TRIGGER [AT_ONCE | WINDOW_CLOSE | MAX_DELAY time] + WATERMARK time +} + +``` + +其中 subquery 是 select 普通查询语法的子集: + +```sql +subquery: SELECT [DISTINCT] select_list + from_clause + [WHERE condition] + [PARTITION BY tag_list] + [window_clause] + [group_by_clause] +``` + +不支持 order_by,limit,slimit,fill 语句 + +例如,如下语句创建流式计算,同时自动创建名为 avg_vol 的超级表,此流计算以一分钟为时间窗口、30 秒为前向增量统计这些电表的平均电压,并将来自 meters 表的数据的计算结果写入 avg_vol 表,不同 partition 的数据会分别创建子表并写入不同子表。 + +```sql +CREATE STREAM avg_vol_s INTO avg_vol AS +SELECT _wstartts, count(*), avg(voltage) FROM meters PARTITION BY tbname INTERVAL(1m) SLIDING(30s); +``` + +## 删除流式计算 + +```sql +DROP STREAM [IF NOT EXISTS] stream_name +``` + +仅删除流式计算任务,由流式计算写入的数据不会被删除。 + +## 展示流式计算 + +```sql +SHOW STREAMS; +``` + +## 流式计算的触发模式 + +在创建流时,可以通过 TRIGGER 指令指定流式计算的触发模式。 + +对于非窗口计算,流式计算的触发是实时的;对于窗口计算,目前提供 3 种触发模式: + +1. AT_ONCE:写入立即触发 + +2. WINDOW_CLOSE:窗口关闭时触发(窗口关闭由事件时间决定,可配合 watermark 使用,详见《流式计算的乱序数据容忍策略》) + +3. MAX_DELAY time:若窗口关闭,则触发计算。若窗口未关闭,且未关闭时长超过 max delay 指定的时间,则触发计算。 + +由于窗口关闭是由事件时间决定的,如事件流中断、或持续延迟,则事件时间无法更新,可能导致无法得到最新的计算结果。 + +因此,流式计算提供了以事件时间结合处理时间计算的 MAX_DELAY 触发模式。 + +MAX_DELAY 模式在窗口关闭时会立即触发计算。此外,当数据写入后,计算触发的时间超过 max delay 指定的时间,则立即触发计算 + +## 流式计算的乱序数据容忍策略 + +在创建流时,可以在 stream_option 中指定 watermark。 + +流式计算通过 watermark 来度量对乱序数据的容忍程度,watermark 默认为 0。 + +T = 最新事件时间 - watermark + +每批到来的数据都会以上述公式更新窗口关闭时间,并将窗口结束时间 < T 的所有打开的窗口关闭,若触发模式为 WINDOW_CLOSE 或 MAX_DELAY,则推送窗口聚合结果。 + +流式计算的过期数据处理策略 +对于已关闭的窗口,再次落入该窗口中的数据被标记为过期数据,对于过期数据,流式计算提供两种处理方式: + +1. 直接丢弃:这是常见流式计算引擎提供的默认(甚至是唯一)计算模式 + +2. 重新计算:从 TSDB 中重新查找对应窗口的所有数据并重新计算得到最新结果 + +无论在哪种模式下,watermark 都应该被妥善设置,来得到正确结果(直接丢弃模式)或避免频繁触发重算带来的性能开销(重新计算模式)。 + +## 流式计算的数据填充策略 + +TODO + +## 流式计算与会话窗口(session window) + +```sql +window_clause: { + SESSION(ts_col, tol_val) + | STATE_WINDOW(col) + | INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [FILL(fill_mod_and_val)] +} +``` + +其中,SESSION 是会话窗口,tol_val 是时间间隔的最大范围。在 tol_val 时间间隔范围内的数据都属于同一个窗口,如果连续的两条数据的时间超过 tol_val,则自动开启下一个窗口。 + +## 流式计算的监控与流任务分布查询 + +TODO + +## 流式计算的内存控制与存算分离 + +TODO + +## 流式计算的暂停与恢复 + +```sql +STOP STREAM stream_name; + +RESUME STREAM stream_name; +``` diff --git a/docs/zh/12-taos-sql/19-limit.md b/docs/zh/12-taos-sql/19-limit.md index 95d1837ac66d0e4a718a21e206431ceb94ebe6b7..ff552fc9771f5b428554acc62e9aeac03a305ecc 100644 --- a/docs/zh/12-taos-sql/19-limit.md +++ b/docs/zh/12-taos-sql/19-limit.md @@ -9,8 +9,8 @@ title: 命名与边界限制 2. 允许英文字符或下划线开头,不允许以数字开头 3. 不区分大小写 4. 转义后表(列)名规则: - 为了兼容支持更多形式的表(列)名,TDengine 引入新的转义符 "`"。可用让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查。 - 转义后的表(列)名同样受到长度限制要求,且长度计算的时候不计算转义符。使用转义字符以后,不再对转义字符中的内容进行大小写统一。 + 为了兼容支持更多形式的表(列)名,TDengine 引入新的转义符 "`"。可用让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查 + 转义后的表(列)名同样受到长度限制要求,且长度计算的时候不计算转义符。使用转义字符以后,不再对转义字符中的内容进行大小写统一 例如:\`aBc\` 和 \`abc\` 是不同的表(列)名,但是 abc 和 aBc 是相同的表(列)名。 需要注意的是转义字符中的内容必须是可打印字符。 @@ -23,28 +23,30 @@ title: 命名与边界限制 ## 一般限制 -- 数据库名最大长度为 32。 +- 数据库名最大长度为 32 - 表名最大长度为 192,不包括数据库名前缀和分隔符 -- 每行数据最大长度 48KB (注意:数据行内每个 BINARY/NCHAR 类型的列还会额外占用 2 个字节的存储位置)。 +- 每行数据最大长度 48KB (注意:数据行内每个 BINARY/NCHAR 类型的列还会额外占用 2 个字节的存储位置) - 列名最大长度为 64 - 最多允许 4096 列,最少需要 2 列,第一列必须是时间戳。 - 标签名最大长度为 64 -- 最多允许 128 个,至少要有 1 个标签,一个表中标签值的总长度不超过 16KB 。 -- SQL 语句最大长度 1048576 个字符,也可通过客户端配置参数 maxSQLLength 修改,取值范围 65480 ~ 1048576。 -- SELECT 语句的查询结果,最多允许返回 4096 列(语句中的函数调用可能也会占用一些列空间),超限时需要显式指定较少的返回数据列,以避免语句执行报错。 -- 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制。 +- 最多允许 128 个,至少要有 1 个标签,一个表中标签值的总长度不超过 16KB +- SQL 语句最大长度 1048576 个字符,也可通过客户端配置参数 maxSQLLength 修改,取值范围 65480 ~ 1048576 +- SELECT 语句的查询结果,最多允许返回 4096 列(语句中的函数调用可能也会占用一些列空间),超限时需要显式指定较少的返回数据列,以避免语句执行报错 +- 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制 - 数据库的副本数只能设置为 1 或 3 - 用户名的最大长度是 23 个字节 - 用户密码的最大长度是 15 个字节 -- 总数据行数取决于可用资源 +- 总数据行数取决于可用资源 - 单个数据库的虚拟结点数上限为 1024 ## 表(列)名合法性说明 ### TDengine 中的表(列)名命名规则如下: + 只能由字母、数字、下划线构成,数字不能在首位,长度不能超过 192 字节,不区分大小写。这里表名称不包括数据库名的前缀和分隔符。 ### 转义后表(列)名规则: + 为了兼容支持更多形式的表(列)名,TDengine 引入新的转义符 "`",可以避免表名与关键词的冲突,同时不受限于上述表名合法性约束检查,转义符不计入表名的长度。 转义后的表(列)名同样受到长度限制要求,且长度计算的时候不计算转义符。使用转义字符以后,不再对转义字符中的内容进行大小写统一。 diff --git a/docs/zh/12-taos-sql/20-keywords.md b/docs/zh/12-taos-sql/20-keywords.md index d91c9be2ac58ea68d1444afa214658dafddccbbd..cac29d7863ff77a6ec15bb9bddedd006317b719c 100644 --- a/docs/zh/12-taos-sql/20-keywords.md +++ b/docs/zh/12-taos-sql/20-keywords.md @@ -1,5 +1,5 @@ --- -sidebar_label: 保留关键字 +sidebar_label: 保留关键字 title: TDengine 保留关键字 --- @@ -58,70 +58,70 @@ title: TDengine 保留关键字 ### D -- DATABASE -- DATABASES -- DAYS -- DBS -- DEFERRED +- DATABASE +- DATABASES +- DAYS +- DBS +- DEFERRED - DELETE - DELIMITERS -- DESC -- DESCRIBE -- DETACH -- DISTINCT -- DIVIDE -- DNODE -- DNODES -- DOT -- DOUBLE -- DROP +- DESC +- DESCRIBE +- DETACH +- DISTINCT +- DIVIDE +- DNODE +- DNODES +- DOT +- DOUBLE +- DROP ### E -- END -- EQ -- EXISTS -- EXPLAIN +- END +- EQ +- EXISTS +- EXPLAIN ### F -- FAIL -- FILE -- FILL -- FLOAT -- FOR -- FROM -- FSYNC +- FAIL +- FILE +- FILL +- FLOAT +- FOR +- FROM +- FSYNC ### G -- GE -- GLOB +- GE +- GLOB - GRANTS -- GROUP -- GT +- GROUP +- GT ### H -- HAVING +- HAVING ### I - ID - IF -- IGNORE +- IGNORE - IMMEDIA -- IMPORT -- IN +- IMPORT +- IN - INITIAL -- INSERT +- INSERT - INSTEAD -- INT +- INT - INTEGER - INTERVA -- INTO -- IS -- ISNULL +- INTO +- IS +- ISNULL ### J @@ -130,190 +130,147 @@ title: TDengine 保留关键字 ### K - KEEP -- KEY +- KEY - KILL ### L -- LE -- LIKE -- LIMIT +- LE +- LIKE +- LIMIT - LINEAR -- LOCAL -- LP +- LOCAL +- LP - LSHIFT -- LT +- LT ### M -- MATCH -- MAXROWS -- MINROWS -- MINUS -- MNODES -- MODIFY -- MODULES +- MATCH +- MAXROWS +- MINROWS +- MINUS +- MNODES +- MODIFY +- MODULES ### N -- NE -- NONE -- NOT +- NE +- NONE +- NOT - NOTNULL -- NOW +- NOW - NULL ### O -- OF +- OF - OFFSET -- OR -- ORDER +- OR +- ORDER ### P - PARTITION -- PASS -- PLUS -- PPS +- PASS +- PLUS +- PPS - PRECISION -- PREV +- PREV - PRIVILEGE ### Q -- QTIME +- QTIME - QUERIE -- QUERY +- QUERY - QUORUM ### R -- RAISE -- REM +- RAISE +- REM - REPLACE - REPLICA -- RESET +- RESET - RESTRIC -- ROW -- RP +- ROW +- RP - RSHIFT ### S -- SCORES -- SELECT -- SEMI +- SCORES +- SELECT +- SEMI - SESSION -- SET -- SHOW -- SLASH +- SET +- SHOW +- SLASH - SLIDING -- SLIMIT +- SLIMIT - SMALLIN - SOFFSET -- STable +- STable - STableS -- STAR -- STATE +- STAR +- STATE - STATEMEN - STATE_WI -- STORAGE -- STREAM -- STREAMS -- STRING -- SYNCDB +- STORAGE +- STREAM +- STREAMS +- STRING +- SYNCDB ### T -- TABLE -- TABLES -- TAG -- TAGS -- TBNAME -- TIMES -- TIMESTAMP -- TINYINT -- TOPIC -- TOPICS -- TRIGGER -- TSERIES +- TABLE +- TABLES +- TAG +- TAGS +- TBNAME +- TIMES +- TIMESTAMP +- TINYINT +- TOPIC +- TOPICS +- TRIGGER +- TSERIES ### U -- UMINUS -- UNION -- UNSIGNED -- UPDATE -- UPLUS -- USE -- USER -- USERS -- USING +- UMINUS +- UNION +- UNSIGNED +- UPDATE +- UPLUS +- USE +- USER +- USERS +- USING ### V -- VALUES -- VARIABLE +- VALUES +- VARIABLE - VARIABLES -- VGROUPS -- VIEW -- VNODES +- VGROUPS +- VIEW +- VNODES ### W - WAL - WHERE -### _ - -- _C0 -- _QSTART -- _QSTOP -- _QDURATION -- _WSTART -- _WSTOP -- _WDURATION - - -## 特殊说明 -### TBNAME -`TBNAME` 可以视为超级表中一个特殊的标签,代表子表的表名。 - -获取一个超级表所有的子表名及相关的标签信息: - -```mysql -SELECT TBNAME, location FROM meters; -``` - -统计超级表下辖子表数量: - -```mysql -SELECT COUNT(TBNAME) FROM meters; -``` - -以上两个查询均只支持在WHERE条件子句中添加针对标签(TAGS)的过滤条件。例如: -```mysql -taos> SELECT TBNAME, location FROM meters; - tbname | location | -================================================================== - d1004 | California.SanFrancisco | - d1003 | California.SanFrancisco | - d1002 | California.LosAngeles | - d1001 | California.LosAngeles | -Query OK, 4 row(s) in set (0.000881s) - -taos> SELECT COUNT(tbname) FROM meters WHERE groupId > 2; - count(tbname) | -======================== - 2 | -Query OK, 1 row(s) in set (0.001091s) -``` -### _QSTART/_QSTOP/_QDURATION -表示查询过滤窗口的起始,结束以及持续时间。 - -### _WSTART/_WSTOP/_WDURATION -窗口切分聚合查询(例如 interval/session window/state window)中表示每个切分窗口的起始,结束以及持续时间。 - -### _c0/_ROWTS -_c0 _ROWTS 等价,表示表或超级表的第一列 +### \_ + +- \_C0 +- \_QSTART +- \_QSTOP +- \_QDURATION +- \_WSTART +- \_WSTOP +- \_WDURATION diff --git a/docs/zh/12-taos-sql/21-node.md b/docs/zh/12-taos-sql/21-node.md new file mode 100644 index 0000000000000000000000000000000000000000..4816daf42042c0607aebf37c8b57961e5b1927fe --- /dev/null +++ b/docs/zh/12-taos-sql/21-node.md @@ -0,0 +1,154 @@ +--- +sidebar_label: 集群管理 +title: 集群管理 +--- + +组成 TDengine 集群的物理实体是 dnode (data node 的缩写),它是一个运行在操作系统之上的进程。在 dnode 中可以建立负责时序数据存储的 vnode (virtual node),在多节点集群环境下当某个数据库的 replica 为 3 时,该数据库中的每个 vgroup 由 3 个 vnode 组成;当数据库的 replica 为 1 时,该数据库中的每个 vgroup 由 1 个 vnode 组成。如果要想配置某个数据库为多副本,则集群中的 dnode 数量至少为 3。在 dnode 还可以创建 mnode (management node),单个集群中最多可以创建三个 mnode。在 TDengine 3.0.0.0 中为了支持存算分离,引入了一种新的逻辑节点 qnode (query node),qnode 和 vnode 既可以共存在一个 dnode 中,也可以完全分离在不同的 dnode 上。 + +## 创建数据节点 + +```sql +CREATE DNODE {dnode_endpoint | dnode_host_name PORT port_val} +``` + +其中 `dnode_endpoint` 是形成 `hostname:port`的格式。也可以分开指定 hostname 和 port。 + +实际操作中推荐先创建 dnode,再启动相应的 dnode 进程,这样该 dnode 就可以立即根据其配置文件中的 firstEP 加入集群。每个 dnode 在加入成功后都会被分配一个 ID。 + +## 查看数据节点 + +```sql +SHOW DNODES; +``` + +可以列出集群中所有的数据节点,所列出的字段有 dnode 的 ID, endpoint, status。 + +## 删除数据节点 + +```sql +DROP DNODE {dnode_id | dnode_endpoint} +``` + +可以用 dnoe_id 或 endpoint 两种方式从集群中删除一个 dnode。注意删除 dnode 不等于停止相应的进程。实际中推荐先将一个 dnode 删除之后再停止其所对应的进程。 + +## 修改数据节点配置 + +```sql +ALTER DNODE dnode_id dnode_option + +ALTER ALL DNODES dnode_option + +dnode_option: { + 'resetLog' + | 'balance' value + | 'monitor' value + | 'debugFlag' value + | 'monDebugFlag' value + | 'vDebugFlag' value + | 'mDebugFlag' value + | 'cDebugFlag' value + | 'httpDebugFlag' value + | 'qDebugflag' value + | 'sdbDebugFlag' value + | 'uDebugFlag' value + | 'tsdbDebugFlag' value + | 'sDebugflag' value + | 'rpcDebugFlag' value + | 'dDebugFlag' value + | 'mqttDebugFlag' value + | 'wDebugFlag' value + | 'tmrDebugFlag' value + | 'cqDebugFlag' value +} +``` + +上面语法中的这些可修改配置项其配置方式与 dnode 配置文件中的配置方式相同,区别是修改是动态的立即生效,且不需要重启 dnode。 + +## 添加管理节点 + +```sql +CREATE MNODE ON DNODE dnode_id +``` + +系统启动默认在 firstEP 节点上创建一个 MNODE,用户可以使用此语句创建更多的 MNODE 来提高系统可用性。一个集群最多存在三个 MNODE,一个 DNODE 上只能创建一个 MNODE。 + +## 查看管理节点 + +```sql +SHOW MNODES; +``` + +列出集群中所有的管理节点,包括其 ID,所在 DNODE 以及状态。 + +## 删除管理节点 + +```sql +DROP MNODE ON DNODE dnode_id; +``` + +删除 dnode_id 所指定的 DNODE 上的 MNODE。 + +## 创建查询节点 + +```sql +CREATE QNODE ON DNODE dnode_id; +``` + +系统启动默认没有 QNODE,用户可以创建 QNODE 来实现计算和存储的分离。一个 DNODE 上只能创建一个 QNODE。一个 DNODE 的 `supportVnodes` 参数如果不为 0,同时又在其上创建上 QNODE,则在该 dnode 中既有负责存储管理的 vnode 又有负责查询计算的 qnode,如果还在该 dnode 上创建了 mnode,则一个 dnode 上最多三种逻辑节点都可以存在。但通过配置也可以使其彻底分离。将一个 dnode 的`supportVnodes`配置为 0,可以选择在其上创建 mnode 或者 qnode 中的一种,这样可以实现三种逻辑节点在物理上的彻底分离。 + +## 查看查询节点 + +```sql +SHOW QNODES; +``` + +列出集群中所有查询节点,包括 ID,及所在 DNODE。 + +## 删除查询节点 + +```sql +DROP QNODE ON DNODE dnode_id; +``` + +删除 ID 为 dnode_id 的 DNODE 上的 QNODE,但并不会影响该 dnode 的状态。 + +## 修改客户端配置 + +如果将客户端也看作广义的集群的一部分,可以通过如下命令动态修改客户端配置参数。 + +```sql +ALTER LOCAL local_option + +local_option: { + 'resetLog' + | 'rpcDebugFlag' value + | 'tmrDebugFlag' value + | 'cDebugFlag' value + | 'uDebugFlag' value + | 'debugFlag' value +} +``` + +上面语法中的参数与在配置文件中配置客户端的用法相同,但不需要重启客户端,修改后立即生效。 + +## 查看客户端配置 + +```sql +SHOW LOCAL VARIABLES; +``` + +## 合并 vgroup + +```sql +MERGE VGROUP vgroup_no1 vgroup_no2; +``` + +如果在系统实际运行一段时间后,因为不同时间线的数据特征不同导致在 vgroups 之间的数据和负载分布不均衡,可以通过合并或拆分 vgroups 的方式逐步实现负载均衡。 + +## 拆分 vgroup + +```sql +SPLIT VGROUP vgroup_no; +``` + +会创建一个新的 vgroup,并将指定 vgroup 中的数据按照一致性 HASH 迁移一部分到新的 vgroup 中。此过程中,原 vgroup 可以正常提供读写服务。 diff --git a/docs/zh/12-taos-sql/22-information.md b/docs/zh/12-taos-sql/22-information.md deleted file mode 100644 index 0695aa5172f0632cdfb0b388791f33a554f86d36..0000000000000000000000000000000000000000 --- a/docs/zh/12-taos-sql/22-information.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -sidebar_label: Information内置数据库 -title: Information内置数据库 ---- - diff --git a/docs/zh/12-taos-sql/22-meta.md b/docs/zh/12-taos-sql/22-meta.md new file mode 100644 index 0000000000000000000000000000000000000000..e5bc800de7d4408ef2c97547af1ad0a5dd64893b --- /dev/null +++ b/docs/zh/12-taos-sql/22-meta.md @@ -0,0 +1,179 @@ +--- +sidebar_label: 元数据库 +title: 元数据库 +--- + +TDengine 内置了一个名为 `INFORMATION_SCHEMA` 的数据库,提供对数据库元数据、数据库系统信息和状态的访问,例如数据库或表的名称,当前执行的 SQL 语句等。该数据库存储有关 TDengine 维护的所有其他数据库的信息。它包含多个只读表。实际上,这些表都是视图,而不是基表,因此没有与它们关联的文件。所以对这些表只能查询,不能进行 INSERT 等写入操作。`INFORMATION_SCHEMA` 数据库旨在以一种更一致的方式来提供对 TDengine 支持的各种 SHOW 语句(如 SHOW TABLES、SHOW DATABASES)所提供的信息的访问。与 SHOW 语句相比,使用 SELECT ... FROM INFORMATION_SCHEMA.tablename 具有以下优点: + +1. 可以使用 USE 语句将 INFORMATION_SCHEMA 设为默认数据库 +2. 可以使用 SELECT 语句熟悉的语法,只需要学习一些表名和列名 +3. 可以对查询结果进行筛选、排序等操作。事实上,可以使用任意 TDengine 支持的 SELECT 语句对 INFORMATION_SCHEMA 中的表进行查询 +4. TDengine 在后续演进中可以灵活的添加已有 INFORMATION_SCHEMA 中表的列,而不用担心对既有业务系统造成影响 +5. 与其他数据库系统更具互操作性。例如,Oracle 数据库用户熟悉查询 Oracle 数据字典中的表 + +Note: 由于 SHOW 语句已经被开发者熟悉和广泛使用,所以它们仍然被保留。 + +本章将详细介绍 `INFORMATION_SCHEMA` 这个内置元数据库中的表和表结构。 + +## DNODES + +提供 dnode 的相关信息。也可以使用 SHOW DNODES 来查询这些信息。 + +| # | **列名** | **数据类型** | **说明** | +| --- | :------------: | ------------ | --------------------- | +| 1 | vnodes | SMALLINT | dnode 中的 vnode 个数 | +| 2 | support_vnodes | SMALLINT | 支持的 vnode 个数 | +| 3 | status | BINARY(10) | 当前状态 | +| 4 | note | BINARY(256) | 离线原因等信息 | +| 5 | id | SMALLINT | dnode id | +| 6 | endpoint | BINARY(134) | dnode 的地址 | +| 7 | create | TIMESTAMP | 创建时间 | + +## MNODES + +提供 mnode 的相关信息。也可以使用 SHOW MNODES 来查询这些信息。 + +| # | **列名** | **数据类型** | **说明** | +| --- | :---------: | ------------ | ------------------ | +| 1 | id | SMALLINT | mnode id | +| 2 | endpoint | BINARY(134) | mnode 的地址 | +| 3 | role | BINARY(10) | 当前角色 | +| 4 | role_time | TIMESTAMP | 成为当前角色的时间 | +| 5 | create_time | TIMESTAMP | 创建时间 | + +## MODULES + +提供组件的相关信息。也可以使用 SHOW MODULES 来查询这些信息 + +| # | **列名** | **数据类型** | **说明** | +| --- | :------: | ------------ | ---------- | +| 1 | id | SMALLINT | module id | +| 2 | endpoint | BINARY(134) | 组件的地址 | +| 3 | module | BINARY(10) | 组件状态 | + +## QNODES + +当前系统中 QNODE 的信息。也可以使用 SHOW QNODES 来查询这些信息。 + +| # | **列名** | **数据类型** | **说明** | +| --- | :---------: | ------------ | ------------ | +| 1 | id | SMALLINT | module id | +| 2 | endpoint | BINARY(134) | qnode 的地址 | +| 3 | create_time | TIMESTAMP | 创建时间 | + +## USER_DATABASES + +提供用户创建的数据库对象的相关信息。也可以使用 SHOW DATABASES 来查询这些信息。 + +TODO + +| # | **列名** | **数据类型** | **说明** | +| --- | :---------: | ------------ | ------------------------------------------------ | +| 1 | name | BINARY(32) | 数据库名 | +| 2 | create_time | TIMESTAMP | 创建时间 | +| 3 | ntables | INT | 数据库中表的数量,包含子表和普通表但不包含超级表 | +| 4 | vgroups | INT | 数据库中有多少个 vgroup | +| 5 | replica | INT | 副本数 | +| 6 | quorum | INT | 写成功的确认数 | +| 7 | days | INT | 单文件存储数据的时间跨度 | +| 8 | keep | INT | 数据保留时长 | +| 9 | buffer | INT | 每个 vnode 写缓存的内存块大小,单位 MB | +| 10 | minrows | INT | 文件块中记录的最大条数 | +| 11 | maxrows | INT | 文件块中记录的最小条数 | +| 12 | wal_level | INT | WAL 级别 | +| 13 | walfsync_period | INT | 数据落盘周期 | +| 14 | comp | INT | 数据压缩方式 | +| 15 | precision | BINARY(2) | 时间分辨率 | +| 16 | status | BINARY(10) | 数据库状态 | + +## USER_FUNCTIONS + +TODO + +## USER_INDEXES + +提供用户创建的索引的相关信息。也可以使用 SHOW INDEX 来查询这些信息。 + +| # | **列名** | **数据类型** | **说明** | +| --- | :--------------: | ------------ | ---------------------------------------------------------------------------------- | +| 1 | db_name | BINARY(32) | 包含此索引的表所在的数据库名 | +| 2 | table_name | BINARY(192) | 包含此索引的表的名称 | +| 3 | index_name | BINARY(192) | 索引名 | +| 4 | column_name | BINARY(64) | 建索引的列的列名 | +| 5 | index_type | BINARY(10) | 目前有 SMA 和 FULLTEXT | +| 6 | index_extensions | BINARY(256) | 索引的额外信息。对 SMA 类型的索引,是函数名的列表。对 FULLTEXT 类型的索引为 NULL。 | + +## USER_STABLES + +提供用户创建的超级表的相关信息。 + +| # | **列名** | **数据类型** | **说明** | +| --- | :-----------: | ------------ | ------------------------ | +| 1 | stable_name | BINARY(192) | 超级表表名 | +| 2 | db_name | BINARY(64) | 超级表所在的数据库的名称 | +| 3 | create_time | TIMESTAMP | 创建时间 | +| 4 | columns | INT | 列数目 | +| 5 | tags | INT | 标签数目 | +| 6 | last_update | TIMESTAMP | 最后更新时间 | +| 7 | table_comment | BINARY(1024) | 表注释 | +| 8 | watermark | BINARY(64) | 窗口的关闭时间 | +| 9 | max_delay | BINARY(64) | 推送计算结果的最大延迟 | +| 10 | rollup | BINARY(128) | rollup 聚合函数 | + +## USER_STREAMS + +提供用户创建的流计算的相关信息。 + +| # | **列名** | **数据类型** | **说明** | +| --- | :---------: | ------------ | --------------------------- | +| 1 | stream_name | BINARY(192) | 流计算名称 | +| 2 | user_name | BINARY(23) | 创建流计算的用户 | +| 3 | dest_table | BINARY(192) | 流计算写入的目标表 | +| 4 | create_time | TIMESTAMP | 创建时间 | +| 5 | sql | BLOB | 创建流计算时提供的 SQL 语句 | + +## USER_TABLES + +提供用户创建的普通表和子表的相关信息 + +| # | **列名** | **数据类型** | **说明** | +| --- | :-----------: | ------------ | ---------------- | +| 1 | table_name | BINARY(192) | 表名 | +| 2 | db_name | BINARY(64) | 数据库名 | +| 3 | create_time | TIMESTAMP | 创建时间 | +| 4 | columns | INT | 列数目 | +| 5 | stable_name | BINARY(192) | 所属的超级表表名 | +| 6 | uid | BIGINT | 表 id | +| 7 | vgroup_id | INT | vgroup id | +| 8 | ttl | INT | 表的生命周期 | +| 9 | table_comment | BINARY(1024) | 表注释 | +| 10 | type | BINARY(20) | 表类型 | + +## USER_USERS + +提供系统中创建的用户的相关信息。 + +| # | **列名** | **数据类型** | **说明** | +| --- | :---------: | ------------ | -------- | +| 1 | user_name | BINARY(23) | 用户名 | +| 2 | privilege | BINARY(256) | 权限 | +| 3 | create_time | TIMESTAMP | 创建时间 | + +## VGROUPS + +系统中所有 vgroups 的信息。 + +| # | **列名** | **数据类型** | **说明** | +| --- | :--------: | ------------ | ---------------------------- | +| 1 | vg_id | INT | vgroup id | +| 2 | db_name | BINARY(32) | 数据库名 | +| 3 | tables | INT | 此 vgroup 内有多少表 | +| 4 | status | BINARY(10) | 此 vgroup 的状态 | +| 5 | onlines | INT | 在线的成员数目 | +| 6 | v1_dnode | INT | 第一个成员所在的 dnode 的 id | +| 7 | v1_status | BINARY(10) | 第一个成员的状态 | +| 8 | v2_dnode | INT | 第二个成员所在的 dnode 的 id | +| 9 | v2_status | BINARY(10) | 第二个成员的状态 | +| 10 | v3_dnode | INT | 第三个成员所在的 dnode 的 id | +| 11 | v3_status | BINARY(10) | 第三个成员的状态 | +| 12 | compacting | INT | compact 状态 | diff --git a/docs/zh/12-taos-sql/23-show.md b/docs/zh/12-taos-sql/23-show.md new file mode 100644 index 0000000000000000000000000000000000000000..781f94324c78e7975abde33803cffdb914da020c --- /dev/null +++ b/docs/zh/12-taos-sql/23-show.md @@ -0,0 +1,270 @@ +--- +sidebar_label: SHOW 命令 +title: 使用 SHOW 命令查看系统元数据 +--- + +除了使用 `select` 语句查询 `INFORMATION_SCHEMA` 数据库中的表获得系统中的各种元数据、系统信息和状态之外,也可以用 `SHOW` 命令来实现同样的目的。 + +## SHOW ACCOUNTS + +```sql +SHOW ACCOUNTS; +``` + +显示当前系统中所有租户的信息。 + +注:企业版独有 + +## SHOW APPS + +```sql +SHOW APPS; +``` + +显示接入集群的应用(客户端)信息。 + +## SHOW BNODES + +```sql +SHOW BNODES; +``` + +显示当前系统中存在的 BNODE (backup node, 即备份节点)的信息。 + +## SHOW CLUSTER + +```sql +SHOW CLUSTER; +``` + +显示当前集群的信息 + +## SHOW CONNECTIONS + +```sql +SHOW CONNECTIONS; +``` + +显示当前系统中存在的连接的信息。 + +## SHOW CONSUMERS + +```sql +SHOW CONSUMERS; +``` + +显示当前数据库下所有活跃的消费者的信息。 + +## SHOW CREATE DATABASE + +```sql +SHOW CREATE DATABASE db_name; +``` + +显示 db_name 指定的数据库的创建语句。 + +## SHOW CREATE STABLE + +```sql +SHOW CREATE STABLE [db_name.]stb_name; +``` + +显示 tb_name 指定的超级表的创建语句 + +## SHOW CREATE TABLE + +```sql +SHOW CREATE TABLE [db_name.]tb_name +``` + +显示 tb_name 指定的表的创建语句。支持普通表、超级表和子表。 + +## SHOW DATABASES + +```sql +SHOW DATABASES; +``` + +显示用户定义的所有数据库。 + +## SHOW DNODES + +```sql +SHOW DNODES; +``` + +显示当前系统中 DNODE 的信息。 + +## SHOW FUNCTIONS + +```sql +SHOW FUNCTIONS; +``` + +显示用户定义的自定义函数。 + +## SHOW LICENSE + +```sql +SHOW LICENSE; +SHOW GRANTS; +``` + +显示企业版许可授权的信息。 + +注:企业版独有 + +## SHOW INDEXES + +```sql +SHOW INDEXES FROM tbl_name [FROM db_name]; +``` + +显示已创建的索引。 + +## SHOW LOCAL VARIABLES + +```sql +SHOW LOCAL VARIABLES; +``` + +显示当前客户端配置参数的运行值。 + +## SHOW MNODES + +```sql +SHOW MNODES; +``` + +显示当前系统中 MNODE 的信息。 + +## SHOW MODULES + +```sql +SHOW MODULES; +``` + +显示当前系统中所安装的组件的信息。 + +## SHOW QNODES + +```sql +SHOW QNODES; +``` + +显示当前系统中 QNODE (查询节点)的信息。 + +## SHOW SCORES + +```sql +SHOW SCORES; +``` + +显示系统被许可授权的容量的信息。 + +注:企业版独有 + +## SHOW SNODES + +```sql +SHOW SNODES; +``` + +显示当前系统中 SNODE (流计算节点)的信息。 + +## SHOW STABLES + +```sql +SHOW [db_name.]STABLES [LIKE 'pattern']; +``` + +显示当前数据库下的所有超级表的信息。可以使用 LIKE 对表名进行模糊匹配。 + +## SHOW STREAMS + +```sql +SHOW STREAMS; +``` + +显示当前系统内所有流计算的信息。 + +## SHOW SUBSCRIPTIONS + +```sql +SHOW SUBSCRIPTIONS; +``` + +显示当前数据库下的所有的订阅关系 + +## SHOW TABLES + +```sql +SHOW [db_name.]TABLES [LIKE 'pattern']; +``` + +显示当前数据库下的所有普通表和子表的信息。可以使用 LIKE 对表名进行模糊匹配。 + +## SHOW TABLE DISTRIBUTED + +```sql +SHOW TABLE DISTRIBUTED table_name; +``` + +显示表的数据分布信息。 + +## SHOW TAGS + +```sql +SHOW TAGS FROM child_table_name [FROM db_name]; +``` + +显示子表的标签信息。 + +## SHOW TOPICS + +```sql +SHOW TOPICS; +``` + +显示当前数据库下的所有主题的信息。 + +## SHOW TRANSACTIONS + +```sql +SHOW TRANSACTIONS; +``` + +显示当前系统中正在执行的事务的信息 + +## SHOW USERS + +```sql +SHOW USERS; +``` + +显示当前系统中所有用户的信息。包括用户自定义的用户和系统默认用户。 + +## SHOW VARIABLES + +```sql +SHOW VARIABLES; +SHOW DNODE dnode_id VARIABLES; +``` + +显示当前系统中各节点需要相同的配置参数的运行值,也可以指定 DNODE 来查看其的配置参数。 + +## SHOW VGROUPS + +```sql +SHOW [db_name.]VGROUPS; +``` + +显示当前系统中所有 VGROUP 或某个 db 的 VGROUPS 的信息。 + +## SHOW VNODES + +```sql +SHOW VNODES [dnode_name]; +``` + +显示当前系统中所有 VNODE 或某个 DNODE 的 VNODE 的信息。 diff --git a/docs/zh/12-taos-sql/25-grant.md b/docs/zh/12-taos-sql/25-grant.md new file mode 100644 index 0000000000000000000000000000000000000000..0c290350cc155e975e5a817c991bebc74944cd04 --- /dev/null +++ b/docs/zh/12-taos-sql/25-grant.md @@ -0,0 +1,94 @@ +--- +sidebar_label: 权限管理 +title: 权限管理 +--- + +本节讲述如何在 TDengine 中进行权限管理的相关操作。 + +## 创建用户 + +```sql +CREATE USER use_name PASS password; +``` + +创建用户。 + +use_name最长为23字节。 + +password最长为128字节,合法字符包括"a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/",不可以出现单双引号、撇号、反斜杠和空格,且不可以为空。 + +## 删除用户 + +```sql +DROP USER user_name; +``` + +## 修改用户信息 + +```sql +ALTER USER user_name alter_user_clause + +alter_user_clause: { + PASS 'literal' + | ENABLE value + | SYSINFO value +} +``` + +- PASS:修改用户密码。 +- ENABLE:修改用户是否启用。1表示启用此用户,0表示禁用此用户。 +- SYSINFO:修改用户是否可查看系统信息。1表示可以查看系统信息,0表示不可以查看系统信息。 + + +## 授权 + +```sql +GRANT privileges ON priv_level TO user_name + +privileges : { + ALL + | priv_type [, priv_type] ... +} + +priv_type : { + READ + | WRITE +} + +priv_level : { + dbname.* + | *.* +} +``` + +对用户授权。 + +授权级别支持到DATABASE,权限有READ和WRITE两种。 + +TDengine 有超级用户和普通用户两类用户。超级用户缺省创建为root,拥有所有权限。使用超级用户创建出来的用户为普通用户。在未授权的情况下,普通用户可以创建DATABASE,并拥有自己创建的DATABASE的所有权限,包括删除数据库、修改数据库、查询时序数据和写入时序数据。超级用户可以给普通用户授予其他DATABASE的读写权限,使其可以在此DATABASE上读写数据,但不能对其进行删除和修改数据库的操作。 + +对于非DATABASE的对象,如USER、DNODE、UDF、QNODE等,普通用户只有读权限(一般为SHOW命令),不能创建和修改。 + +## 撤销授权 + +```sql +REVOKE privileges ON priv_level FROM user_name + +privileges : { + ALL + | priv_type [, priv_type] ... +} + +priv_type : { + READ + | WRITE +} + +priv_level : { + dbname.* + | *.* +} + +``` + +收回对用户的授权。 \ No newline at end of file diff --git a/docs/zh/12-taos-sql/26-udf.md b/docs/zh/12-taos-sql/26-udf.md new file mode 100644 index 0000000000000000000000000000000000000000..bd8d61a5844241efae9eee99a73c65afd3d0926f --- /dev/null +++ b/docs/zh/12-taos-sql/26-udf.md @@ -0,0 +1,28 @@ +--- +sidebar_label: 自定义函数 +title: 用户自定义函数 +--- + +除了 TDengine 的内置函数以外,用户还可以编写自己的函数逻辑并加入TDengine系统中。 + +## 创建函数 + +```sql +CREATE [AGGREGATE] FUNCTION func_name AS library_path OUTPUTTYPE type_name [BUFSIZE value] +``` + +语法说明: + +AGGREGATE:标识此函数是标量函数还是聚集函数。 +func_name:函数名,必须与函数实现中udfNormalFunc的实际名称一致。 +library_path:包含UDF函数实现的动态链接库的绝对路径,是在客户端侧主机上的绝对路径。 +OUTPUTTYPE:标识此函数的返回类型。 +BUFSIZE:中间结果的缓冲区大小,单位是字节。不设置则默认为0。最大不可超过512字节。 + +关于如何开发自定义函数,请参考 [UDF使用说明](../../develop/udf)。 + +## 删除自定义函数 + +```sql +DROP FUNCTION func_name +``` \ No newline at end of file diff --git a/docs/zh/12-taos-sql/27-index.md b/docs/zh/12-taos-sql/27-index.md new file mode 100644 index 0000000000000000000000000000000000000000..2c0907723e76f304566e6a19bdef2d63225f903f --- /dev/null +++ b/docs/zh/12-taos-sql/27-index.md @@ -0,0 +1,47 @@ +--- +sidebar_label: 索引 +title: 使用索引 +--- + +TDengine 从 3.0.0.0 版本开始引入了索引功能,支持 SMA 索引和 FULLTEXT 索引。 + +## 创建索引 + +```sql +CREATE FULLTEXT INDEX index_name ON tb_name (col_name [, col_name] ...) + +CREATE SMA INDEX index_name ON tb_name index_option + +index_option: + FUNCTION(functions) INTERVAL(interval_val [, interval_offset]) [SLIDING(sliding_val)] [WATERMARK(watermark_val)] [MAX_DELAY(max_delay_val)] + +functions: + function [, function] ... +``` + +### SMA 索引 + +对指定列按 INTERVAL 子句定义的时间窗口创建进行预聚合计算,预聚合计算类型由 functions_string 指定。SMA 索引能提升指定时间段的聚合查询的性能。目前,限制一个超级表只能创建一个 SMA INDEX。 + +- 支持的函数包括 MAX、MIN 和 SUM。 +- WATERMARK: 最小单位毫秒,取值范围 [0ms, 900000ms],默认值为 5 秒,只可用于超级表。 +- MAX_DELAY: 最小单位毫秒,取值范围 [1ms, 900000ms],默认值为 interval 的值(但不能超过最大值),只可用于超级表。注:不建议 MAX_DELAY 设置太小,否则会过于频繁的推送结果,影响存储和查询性能,如无特殊需求,取默认值即可。 + +### FULLTEXT 索引 + +对指定列建立文本索引,可以提升含有文本过滤的查询的性能。FULLTEXT 索引不支持 index_option 语法。现阶段只支持对 JSON 类型的标签列创建 FULLTEXT 索引。不支持多列联合索引,但可以为每个列分布创建 FULLTEXT 索引。 + +## 删除索引 + +```sql +DROP INDEX index_name; +``` + +## 查看索引 + +````sql +```sql +SHOW INDEXES FROM tbl_name [FROM db_name]; +```` + +显示在所指定的数据库或表上已创建的索引。 diff --git a/docs/zh/12-taos-sql/28-recovery.md b/docs/zh/12-taos-sql/28-recovery.md new file mode 100644 index 0000000000000000000000000000000000000000..72b220b8ff44917831ac16301237702c991b9b15 --- /dev/null +++ b/docs/zh/12-taos-sql/28-recovery.md @@ -0,0 +1,38 @@ +--- +sidebar_label: 异常恢复 +title: 异常恢复 +--- + +在一个复杂的应用场景中,连接和查询任务等有可能进入一种错误状态或者耗时过长迟迟无法结束,此时需要有能够终止这些连接或任务的方法。 + +## 终止连接 + +```sql +KILL CONNECTION conn_id; +``` + +conn_id 可以通过 `SHOW CONNECTIONS` 获取。 + +## 终止查询 + +```sql +SHOW QUERY query_id; +``` + +query_id 可以通过 `SHOW QUERIES` 获取。 + +## 终止事务 + +```sql +KILL TRANSACTION trans_id +``` + +trans_id 可以通过 `SHOW TRANSACTIONS` 获取。 + +## 重置客户端缓存 + +```sql +RESET QUERY CACHE; +``` + +如果在多客户端情况下出现元数据不同步的情况,可以用这条命令强制清空客户端缓存,随后客户端会从服务端拉取最新的元数据。 diff --git a/docs/zh/13-operation/03-tolerance.md b/docs/zh/13-operation/03-tolerance.md deleted file mode 100644 index 2c466819621adc10423c452328714c81e6f6f966..0000000000000000000000000000000000000000 --- a/docs/zh/13-operation/03-tolerance.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: 容错和灾备 ---- - -## 容错 - -TDengine 支持**WAL**(Write Ahead Log)机制,实现数据的容错能力,保证数据的高可用。 - -TDengine 接收到应用的请求数据包时,先将请求的原始数据包写入数据库日志文件,等数据成功写入数据库数据文件后,再删除相应的 WAL。这样保证了 TDengine 能够在断电等因素导致的服务重启时从数据库日志文件中恢复数据,避免数据的丢失。 - -涉及的系统配置参数有两个: - -- walLevel:WAL 级别,0:不写 WAL; 1:写 WAL, 但不执行 fsync; 2:写 WAL, 而且执行 fsync。 -- fsync:当 walLevel 设置为 2 时,执行 fsync 的周期。设置为 0,表示每次写入,立即执行 fsync。 - -如果要 100%的保证数据不丢失,需要将 walLevel 设置为 2,fsync 设置为 0。这时写入速度将会下降。但如果应用侧启动的写数据的线程数达到一定的数量(超过 50),那么写入数据的性能也会很不错,只会比 fsync 设置为 3000 毫秒下降 30%左右。 - -## 灾备 - -TDengine 的集群通过多个副本的机制,来提供系统的高可用性,实现灾备能力。 - -TDengine 集群是由 mnode 负责管理的,为保证 mnode 的高可靠,可以配置多个 mnode 副本,副本数由系统配置参数 numOfMnodes 决定,为了支持高可靠,需要设置大于 1。为保证元数据的强一致性,mnode 副本之间通过同步方式进行数据复制,保证了元数据的强一致性。 - -TDengine 集群中的时序数据的副本数是与数据库关联的,一个集群里可以有多个数据库,每个数据库可以配置不同的副本数。创建数据库时,通过参数 replica 指定副本数。为了支持高可靠,需要设置副本数大于 1。 - -TDengine 集群的节点数必须大于等于副本数,否则创建表时将报错。 - -当 TDengine 集群中的节点部署在不同的物理机上,并设置多个副本数时,就实现了系统的高可靠性,无需再使用其他软件或工具。TDengine 企业版还可以将副本部署在不同机房,从而实现异地容灾。 diff --git a/docs/zh/13-operation/06-admin.md b/docs/zh/13-operation/06-admin.md deleted file mode 100644 index 7934d31eafb774fb45e1902bee29e8b518d152d6..0000000000000000000000000000000000000000 --- a/docs/zh/13-operation/06-admin.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: 用户管理 ---- - -系统管理员可以在 CLI 界面里添加、删除用户,也可以修改密码。CLI 里 SQL 语法如下: - -```sql -CREATE USER PASS <'password'>; -``` - -创建用户,并指定用户名和密码,密码需要用单引号引起来,单引号为英文半角 - -```sql -DROP USER ; -``` - -删除用户,限 root 用户使用 - -```sql -ALTER USER PASS <'password'>; -``` - -修改用户密码,为避免被转换为小写,密码需要用单引号引用,单引号为英文半角 - -```sql -ALTER USER PRIVILEGE ; -``` - -修改用户权限为:write 或 read,不需要添加单引号 - -说明:系统内共有 super/write/read 三种权限级别,但目前不允许通过 alter 指令把 super 权限赋予用户。 - -```sql -SHOW USERS; -``` - -显示所有用户 - -:::note -SQL 语法中,< >表示需要用户输入的部分,但请不要输入< >本身。 - -::: diff --git a/docs/zh/13-operation/09-status.md b/docs/zh/13-operation/09-status.md deleted file mode 100644 index e7ae78bace91f6dab06591340965ba04efdd5edb..0000000000000000000000000000000000000000 --- a/docs/zh/13-operation/09-status.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: 系统连接、任务查询管理 ---- - -系统管理员可以从 CLI 查询系统的连接、正在进行的查询、流式计算,并且可以关闭连接、停止正在进行的查询和流式计算。 - -## 显示数据库的连接 - -```sql -SHOW CONNECTIONS; -``` - -其结果中的一列显示 ip:port, 为连接的 IP 地址和端口号。 - -## 强制关闭数据库连接 - -```sql -KILL CONNECTION ; -``` - -其中的 connection-id 是 SHOW CONNECTIONS 中显示的第一列的数字。 - -## 显示数据查询 - -```sql -SHOW QUERIES; -``` - -其中第一列显示的以冒号隔开的两个数字为 query-id,为发起该 query 应用连接的 connection-id 和查询次数。 - -## 强制关闭数据查询 - -```sql -KILL QUERY ; -``` - -其中 query-id 是 SHOW QUERIES 中显示的 connection-id:query-no 字串,如“105:2”,拷贝粘贴即可。 - -## 显示连续查询 - -```sql -SHOW STREAMS; -``` - -其中第一列显示的以冒号隔开的两个数字为 stream-id, 为启动该 stream 应用连接的 connection-id 和发起 stream 的次数。 - -## 强制关闭连续查询 - -```sql -KILL STREAM ; -``` - -其中的 stream-id 是 SHOW STREAMS 中显示的 connection-id:stream-no 字串,如 103:2,拷贝粘贴即可。 diff --git a/docs/zh/14-reference/12-config/index.md b/docs/zh/14-reference/12-config/index.md index 2d1866d5dd1874164d03ffdfb382010c8345ad63..fefb50c541d9b293ddabb7d5cbaa5f68bf1dee98 100644 --- a/docs/zh/14-reference/12-config/index.md +++ b/docs/zh/14-reference/12-config/index.md @@ -80,21 +80,16 @@ taos --dump-config | 补充说明 | RESTful 服务在 2.4.0.0 之前(不含)由 taosd 提供,默认端口为 6041; 在 2.4.0.0 及后续版本由 taosAdapter,默认端口为 6041 | :::note -确保集群中所有主机在端口 6030-6042 上的 TCP/UDP 协议能够互通。(详细的端口情况请参见下表) +确保集群中所有主机在端口 6030 上的 TCP 协议能够互通。(详细的端口情况请参见下表) ::: | 协议 | 默认端口 | 用途说明 | 修改方法 | | :--- | :-------- | :---------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------- | -| TCP | 6030 | 客户端与服务端之间通讯。 | 由配置文件设置 serverPort 决定。 | -| TCP | 6035 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 | -| TCP | 6040 | 多节点集群的节点间数据同步。 | 随 serverPort 端口变化。 | +| TCP | 6030 | 客户端与服务端之间通讯,多节点集群的节点间通讯。 | 由配置文件设置 serverPort 决定。 | | TCP | 6041 | 客户端与服务端之间的 RESTful 通讯。 | 随 serverPort 端口变化。注意 taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | -| TCP | 6042 | Arbitrator 的服务端口。 | 随 Arbitrator 启动参数设置变化。 | | TCP | 6043 | TaosKeeper 监控服务端口。 | 随 TaosKeeper 启动参数设置变化。 | | TCP | 6044 | 支持 StatsD 的数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | | UDP | 6045 | 支持 collectd 数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | | TCP | 6060 | 企业版内 Monitor 服务的网络端口。 | | -| UDP | 6030-6034 | 客户端与服务端之间通讯。 | 随 serverPort 端口变化。 | -| UDP | 6035-6039 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 ### maxShellConns @@ -105,26 +100,6 @@ taos --dump-config | 取值范围 | 10-50000000 | | 缺省值 | 5000 | -### maxConnections - -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 一个数据库连接所容许的 dnode 连接数 | -| 取值范围 | 1-100000 | -| 缺省值 | 5000 | -| 补充说明 | 实际测试下来,如果默认没有配,选 50 个 worker thread 会产生 Network unavailable | - -### rpcForceTcp - -| 属性 | 说明 | -| -------- | --------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 强制使用 TCP 传输 | -| 取值范围 | 0: 不开启 1: 开启 | -| 缺省值 | 0 | -| 补充说明 | 在网络比较差的环境中,建议开启。
2.0 版本新增。 | - ## 监控相关 ### monitor @@ -132,10 +107,26 @@ taos --dump-config | 属性 | 说明 | | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | | 适用范围 | 仅服务端适用 | -| 含义 | 服务器内部的系统监控开关。监控主要负责收集物理节点的负载状况,包括 CPU、内存、硬盘、网络带宽、HTTP 请求量的监控记录,记录信息存储在`LOG`库中。 | +| 含义 | 服务器内部的系统监控开关。监控主要负责收集物理节点的负载状况,包括 CPU、内存、硬盘、网络带宽的监控记录,监控信息将通过 HTTP 协议发送给由 `monitorFqdn` 和 `monitorProt` 指定的 TaosKeeper 监控服务 | | 取值范围 | 0:关闭监控服务, 1:激活监控服务。 | | 缺省值 | 1 | +### monitorFqdn + +| 属性 | 说明 | +| -------- | -------------------------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | TaosKeeper 监控服务的 FQDN | +| 缺省值 | 无 | + +### monitorPort + +| 属性 | 说明 | +| -------- | -------------------------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | TaosKeeper 监控服务的端口号 | +| 缺省值 | 6043 | + ### monitorInterval | 属性 | 说明 | @@ -143,9 +134,10 @@ taos --dump-config | 适用范围 | 仅服务端适用 | | 含义 | 监控数据库记录系统参数(CPU/内存)的时间间隔 | | 单位 | 秒 | -| 取值范围 | 1-600 | +| 取值范围 | 1-200000 | | 缺省值 | 30 | + ### telemetryReporting | 属性 | 说明 | @@ -167,19 +159,10 @@ taos --dump-config | 缺省值 | 无 | | 补充说明 | 计算规则可以根据实际应用可能的最大并发数和表的数字相乘,再乘 170 。
(2.0.15 以前的版本中,此参数的单位是字节) | -### ratioOfQueryCores - -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 设置查询线程的最大数量。 | -| 缺省值 | 1 | -| 补充说明 | 最小值 0 表示只有 1 个查询线程
最大值 2 表示最大建立 2 倍 CPU 核数的查询线程。
默认为 1,表示最大和 CPU 核数相等的查询线程。
该值可以为小数,即 0.5 表示最大建立 CPU 核数一半的查询线程。 | - ### maxNumOfDistinctRes | 属性 | 说明 | -| -------- | -------------------------------- | --- | +| -------- | -------------------------------- | | 适用范围 | 仅服务端适用 | | 含义 | 允许返回的 distinct 结果最大行数 | | 取值范围 | 默认值为 10 万,最大值 1 亿 | @@ -301,96 +284,6 @@ charset 的有效值是 UTF-8。 | 含义 | 数据文件目录,所有的数据文件都将写入该目录 | | 缺省值 | /var/lib/taos | -### cache - -| 属性 | 说明 | -| -------- | ------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 内存块的大小 | -| 单位 | MB | -| 缺省值 | 16 | - -### blocks - -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 每个 vnode(tsdb)中有多少 cache 大小的内存块。因此一个 vnode 的用的内存大小粗略为(cache \* blocks) | -| 缺省值 | 6 | - -### days - -| 属性 | 说明 | -| -------- | -------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 数据文件存储数据的时间跨度 | -| 单位 | 天 | -| 缺省值 | 10 | - -### keep - -| 属性 | 说明 | -| -------- | -------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 数据保留的天数 | -| 单位 | 天 | -| 缺省值 | 3650 | - -### minRows - -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 文件块中记录的最小条数 | -| 缺省值 | 100 | - -### maxRows - -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 文件块中记录的最大条数 | -| 缺省值 | 4096 | - -### walLevel - -| 属性 | 说明 | -| -------- | --------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | WAL 级别 | -| 取值范围 | 0: 不写WAL;
1:写 WAL, 但不执行 fsync
2:写 WAL, 而且执行 fsync | -| 缺省值 | 1 | - -### fsync - -| 属性 | 说明 | -| -------- | -------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 当 WAL 设置为 2 时,执行 fsync 的周期 | -| 单位 | 毫秒 | -| 取值范围 | 最小为 0,表示每次写入,立即执行 fsync
最大为 180000(三分钟) | -| 缺省值 | 3000 | - -### update - -| 属性 | 说明 | -| -------- | ---------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 允许更新已存在的数据行 | -| 取值范围 | 0:不允许更新
1:允许整行更新
2:允许部分列更新。(2.1.7.0 版本开始此参数支持设为 2,在此之前取值只能是 [0, 1]) | -| 缺省值 | 0 | -| 补充说明 | 2.0.8.0 版本之前,不支持此参数。 | - -### cacheLast - -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 是否在内存中缓存子表的最近数据 | -| 取值范围 | 0:关闭
1:缓存子表最近一行数据
2:缓存子表每一列的最近的非 NULL 值
3:同时打开缓存最近行和列功能。(2.1.2.0 版本开始此参数支持 0 ~ 3 的取值范围,在此之前取值只能是 [0, 1]) | -| 缺省值 | 0 | -| 补充说明 | 2.1.2.0 版本之前、2.0.20.7 版本之前在 taos.cfg 文件中不支持此参数。 | - ### minimalTmpDirGB | 属性 | 说明 | @@ -409,110 +302,19 @@ charset 的有效值是 UTF-8。 | 单位 | GB | | 缺省值 | 2.0 | -### vnodeBak - -| 属性 | 说明 | -| -------- | -------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 删除 vnode 时是否备份 vnode 目录 | -| 取值范围 | 0:否,1:是 | -| 缺省值 | 1 | - ## 集群相关 -### numOfMnodes - -| 属性 | 说明 | -| -------- | ------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 系统中管理节点个数 | -| 缺省值 | 3 | - -### replica - -| 属性 | 说明 | -| -------- | ------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 副本个数 | -| 取值范围 | 1-3 | -| 缺省值 | 1 | - -### quorum - -| 属性 | 说明 | -| -------- | -------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 多副本环境下指令执行的确认数要求 | -| 取值范围 | 1,2 | -| 缺省值 | 1 | - -### role +### supportVnodes | 属性 | 说明 | | -------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | 适用范围 | 仅服务端适用 | -| 含义 | dnode 的可选角色 | -| 取值范围 | 0:any(既可作为 mnode,也可分配 vnode)
1:mgmt(只能作为 mnode,不能分配 vnode)
2:dnode(不能作为 mnode,只能分配 vnode) | -| 缺省值 | 0 | - -### balance - -| 属性 | 说明 | -| -------- | ---------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 是否启动负载均衡 | -| 取值范围 | 0,1 | -| 缺省值 | 1 | - -### balanceInterval - -| 属性 | 说明 | -| -------- | ------------------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 管理节点在正常运行状态下,检查负载均衡的时间间隔 | -| 单位 | 秒 | -| 取值范围 | 1-30000 | -| 缺省值 | 300 | - -### arbitrator - -| 属性 | 说明 | -| -------- | ------------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 系统中裁决器的 endpoint,其格式如 firstEp | -| 缺省值 | 空 | +| 含义 | dnode 支持的最大 vnode 数目 | +| 取值范围 | 0-4096 | +| 缺省值 | 256 | ## 时间相关 -### precision - -| 属性 | 说明 | -| -------- | ------------------------------------------------- | -| 适用范围 | 仅服务端 | -| 含义 | 创建数据库时使用的时间精度 | -| 取值范围 | ms: millisecond; us: microsecond ; ns: nanosecond | -| 缺省值 | ms | - -### rpcTimer - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | rpc 重试时长 | -| 单位 | 毫秒 | -| 取值范围 | 100-3000 | -| 缺省值 | 300 | - -### rpcMaxTime - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | rpc 等待应答最大时长 | -| 单位 | 秒 | -| 取值范围 | 100-7200 | -| 缺省值 | 600 | - ### statusInterval | 属性 | 说明 | @@ -533,105 +335,8 @@ charset 的有效值是 UTF-8。 | 取值范围 | 1-120 | | 缺省值 | 3 | -### tableMetaKeepTimer - -| 属性 | 说明 | -| -------- | --------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 表的元数据 cache 时长 | -| 单位 | 秒 | -| 取值范围 | 1-8640000 | -| 缺省值 | 7200 | - -### maxTmrCtrl - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 定时器个数 | -| 单位 | 个 | -| 取值范围 | 8-2048 | -| 缺省值 | 512 | - -### offlineThreshold - -| 属性 | 说明 | -| -------- | ------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | dnode 离线阈值,超过该时间将导致 dnode 离线 | -| 单位 | 秒 | -| 取值范围 | 5-7200000 | -| 缺省值 | 86400\*10(10 天) | - ## 性能调优 -### numOfThreadsPerCore - -| 属性 | 说明 | -| -------- | ----------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 每个 CPU 核生成的队列消费者线程数量 | -| 缺省值 | 1.0 | - -### ratioOfQueryThreads - -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 设置查询线程的最大数量 | -| 取值范围 | 0:表示只有 1 个查询线程
1:表示最大和 CPU 核数相等的查询线程
2:表示最大建立 2 倍 CPU 核数的查询线程。 | -| 缺省值 | 1 | -| 补充说明 | 该值可以为小数,即 0.5 表示最大建立 CPU 核数一半的查询线程。 | - -### maxVgroupsPerDb - -| 属性 | 说明 | -| -------- | ------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 每个 DB 中 能够使用的最大 vnode 个数 | -| 取值范围 | 0-8192 | -| 缺省值 | 0 | - -### maxTablesPerVnode - -| 属性 | 说明 | -| -------- | --------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 每个 vnode 中能够创建的最大表个数 | -| 缺省值 | 1000000 | - -### minTablesPerVnode - -| 属性 | 说明 | -| -------- | --------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 每个 vnode 中必须创建表的最小数量 | -| 缺省值 | 1000 | - -### tableIncStepPerVnode - -| 属性 | 说明 | -| -------- | ------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 每个 vnode 中超过最小表数,i.e. minTablesPerVnode, 后递增步长 | -| 缺省值 | 1000 | - -### maxNumOfOrderedRes - -| 属性 | 说明 | -| -------- | -------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 支持超级表时间排序允许的最多记录数限制 | -| 缺省值 | 10 万 | - -### mnodeEqualVnodeNum - -| 属性 | 说明 | -| -------- | ------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 将一个 mnode 等同于 vnode 消耗的个数 | -| 缺省值 | 4 | - ### numOfCommitThreads | 属性 | 说明 | @@ -642,23 +347,6 @@ charset 的有效值是 UTF-8。 ## 压缩相关 -### comp - -| 属性 | 说明 | -| -------- | ----------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 文件压缩标志位 | -| 取值范围 | 0:关闭,1:一阶段压缩,2:两阶段压缩 | -| 缺省值 | 2 | - -### tsdbMetaCompactRatio - -| 属性 | 说明 | -| -------- | -------------------------------------------------------------- | -| 含义 | tsdb meta 文件中冗余数据超过多少阈值,开启 meta 文件的压缩功能 | -| 取值范围 | 0:不开启,[1-100]:冗余数据比例 | -| 缺省值 | 0 | - ### compressMsgSize | 属性 | 说明 | @@ -680,165 +368,6 @@ charset 的有效值是 UTF-8。 | 缺省值 | -1 | | 补充说明 | 2.3.0.0 版本新增。 | -### lossyColumns - -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| 适用范围 | 服务器端 | -| 含义 | 配置要进行有损压缩的浮点数据类型 | -| 取值范围 | 空字符串:关闭有损压缩
float:只对 float 类型进行有损压缩
double:只对 double 类型进行有损压缩
float \| double:float double 都进行有损压缩 | -| 缺省值 | 空字符串 | -| 补充说明 | 有损压缩默认为关闭状态,只有配置后才生效 | - -### fPrecision - -| 属性 | 说明 | -| -------- | -------------------------------- | -| 适用范围 | 服务器端 | -| 含义 | 设置 float 类型浮点数压缩精度 | -| 取值范围 | 0.1 ~ 0.00000001 | -| 缺省值 | 0.00000001 | -| 补充说明 | 小于此值的浮点数尾数部分将被截取 | - -### dPrecision - -| 属性 | 说明 | -| -------- | -------------------------------- | -| 适用范围 | 服务器端 | -| 含义 | 设置 double 类型浮点数压缩精度 | -| 取值范围 | 0.1 ~ 0.0000000000000001 | -| 缺省值 | 0.0000000000000001 | -| 补充说明 | 小于此值的浮点数尾数部分将被截取 | - -## 连续查询相关 - -### stream - -| 属性 | 说明 | -| -------- | ------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 是否启用连续查询(流计算功能) | -| 取值范围 | 0:不允许
1:允许 | -| 缺省值 | 1 | - -### minSlidingTime - -| 属性 | 说明 | -| -------- | ----------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 最小滑动窗口时长 | -| 单位 | 毫秒 | -| 取值范围 | 10-1000000 | -| 缺省值 | 10 | -| 补充说明 | 支持 us 补值后,这个值就是 1us 了。 | - -### minIntervalTime - -| 属性 | 说明 | -| -------- | -------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 时间窗口最小值 | -| 单位 | 毫秒 | -| 取值范围 | 1-1000000 | -| 缺省值 | 10 | - -### maxStreamCompDelay - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 连续查询启动最大延迟 | -| 单位 | 毫秒 | -| 取值范围 | 10-1000000000 | -| 缺省值 | 20000 | - -### maxFirstStreamCompDelay - -| 属性 | 说明 | -| -------- | -------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 第一次连续查询启动最大延迟 | -| 单位 | 毫秒 | -| 取值范围 | 10-1000000000 | -| 缺省值 | 10000 | - -### retryStreamCompDelay - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 连续查询重试等待间隔 | -| 单位 | 毫秒 | -| 取值范围 | 10-1000000000 | -| 缺省值 | 10 | - -### streamCompDelayRatio - -| 属性 | 说明 | -| -------- | ---------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 连续查询的延迟时间计算系数,实际延迟时间为本参数乘以计算时间窗口 | -| 取值范围 | 0.1-0.9 | -| 缺省值 | 0.1 | - -:::info -为避免多个 stream 同时执行占用太多系统资源,程序中对 stream 的执行时间人为增加了一些随机的延时。
maxFirstStreamCompDelay 是 stream 第一次执行前最少要等待的时间。
streamCompDelayRatio 是延迟时间的计算系数,它乘以查询的 interval 后为延迟时间基准。
maxStreamCompDelay 是延迟时间基准的上限。
实际延迟时间为一个不超过延迟时间基准的随机值。
stream 某次计算失败后需要重试,retryStreamCompDelay 是重试的等待时间基准。
实际重试等待时间为不超过等待时间基准的随机值。 - -::: - -## HTTP 相关 - -:::note -HTTP 服务在 2.4.0.0(不含)以前的版本中由 taosd 提供,在 2.4.0.0 以后(含)由 taosAdapter 提供。 -本节的配置参数仅在 2.4.0.0(不含)以前的版本中生效。如果您使用的是 2.4.0.0(含)及以后的版本请参考[文档](/reference/taosadapter/)。 - -::: - -### http - -| 属性 | 说明 | -| -------- | --------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 服务器内部的 http 服务开关。 | -| 取值范围 | 0:关闭 http 服务, 1:激活 http 服务。 | -| 缺省值 | 1 | - -### httpEnableRecordSql - -| 属性 | 说明 | -| -------- | --------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 记录通过 RESTFul 接口,产生的 SQL 调用。 | -| 缺省值 | 0 | -| 补充说明 | 生成的文件(httpnote.0/httpnote.1),与服务端日志所在目录相同。 | - -### httpMaxThreads - -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | RESTFul 接口的线程数。taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | -| 缺省值 | 2 | - -### restfulRowLimit - -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | RESTFul 接口单次返回的记录条数。taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | -| 缺省值 | 10240 | -| 补充说明 | 最大 10,000,000 | - -### httpDBNameMandatory - -| 属性 | 说明 | -| -------- | ---------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 是否在 URL 中输入 数据库名称 | -| 取值范围 | 0:不开启,1:开启 | -| 缺省值 | 0 | -| 补充说明 | 2.3 版本新增。 | - ## 日志相关 ### logDir @@ -894,50 +423,23 @@ HTTP 服务在 2.4.0.0(不含)以前的版本中由 taosd 提供,在 2.4.0 | 取值范围 | 131(输出错误和警告日志),135(输出错误、警告和调试日志),143(输出错误、警告、调试和跟踪日志) | | 缺省值 | 131 或 135(不同模块有不同的默认值) | -### mDebugFlag - -| 属性 | 说明 | -| -------- | ------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 管理模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | - -### dDebugFlag - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | dnode 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | - -### sDebugFlag - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | sync 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | - -### wDebugFlag +### tmrDebugFlag | 属性 | 说明 | | -------- | -------------------- | | 适用范围 | 服务端和客户端均适用 | -| 含义 | WAL 模块的日志开关 | +| 含义 | 定时器模块的日志开关 | | 取值范围 | 同上 | -| 缺省值 | 135 | +| 缺省值 | | -### sdbDebugFlag +### uDebugFlag -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | sdb 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | +| 属性 | 说明 | +| -------- | ---------------------- | +| 适用范围 | 服务端和客户端均适用 | +| 含义 | 共用功能模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | ### rpcDebugFlag @@ -948,12 +450,21 @@ HTTP 服务在 2.4.0.0(不含)以前的版本中由 taosd 提供,在 2.4.0 | 取值范围 | 同上 | | 缺省值 | | -### tmrDebugFlag +### jniDebugFlag + +| 属性 | 说明 | +| -------- | ------------------ | +| 适用范围 | 仅客户端适用 | +| 含义 | jni 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | + +### qDebugFlag | 属性 | 说明 | | -------- | -------------------- | | 适用范围 | 服务端和客户端均适用 | -| 含义 | 定时器模块的日志开关 | +| 含义 | query 模块的日志开关 | | 取值范围 | 同上 | | 缺省值 | | @@ -966,157 +477,113 @@ HTTP 服务在 2.4.0.0(不含)以前的版本中由 taosd 提供,在 2.4.0 | 取值范围 | 同上 | | 缺省值 | | -### jniDebugFlag - -| 属性 | 说明 | -| -------- | ------------------ | -| 适用范围 | 仅客户端适用 | -| 含义 | jni 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | - -### odbcDebugFlag - -| 属性 | 说明 | -| -------- | ------------------- | -| 适用范围 | 仅客户端适用 | -| 含义 | odbc 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | - -### uDebugFlag - -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 共用功能模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | - -### httpDebugFlag +### dDebugFlag -| 属性 | 说明 | -| -------- | ------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | http 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| 属性 | 说明 | +| -------- | -------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | dnode 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | 135 | -### mqttDebugFlag +### vDebugFlag -| 属性 | 说明 | -| -------- | ------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | mqtt 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| 属性 | 说明 | +| -------- | -------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | vnode 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | -### monitorDebugFlag +### mDebugFlag | 属性 | 说明 | | -------- | ------------------ | | 适用范围 | 仅服务端适用 | -| 含义 | 监控模块的日志开关 | +| 含义 | mnode 模块的日志开关 | | 取值范围 | 同上 | -| 缺省值 | | +| 缺省值 | 135 | -### qDebugFlag +### wDebugFlag | 属性 | 说明 | | -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 查询模块的日志开关 | +| 适用范围 | 仅服务端适用 | +| 含义 | wal 模块的日志开关 | | 取值范围 | 同上 | -| 缺省值 | | +| 缺省值 | 135 | -### vDebugFlag +### sDebugFlag | 属性 | 说明 | | -------- | -------------------- | | 适用范围 | 服务端和客户端均适用 | -| 含义 | vnode 模块的日志开关 | +| 含义 | sync 模块的日志开关 | | 取值范围 | 同上 | -| 缺省值 | | +| 缺省值 | 135 | ### tsdbDebugFlag | 属性 | 说明 | | -------- | ------------------- | | 适用范围 | 仅服务端适用 | -| 含义 | TSDB 模块的日志开关 | +| 含义 | tsdb 模块的日志开关 | | 取值范围 | 同上 | | 缺省值 | | -### cqDebugFlag - -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 连续查询模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | - -## 仅客户端适用 +### tqDebugFlag -### maxSQLLength - -| 属性 | 说明 | -| -------- | --------------------------- | -| 适用范围 | 仅客户端适用 | -| 含义 | 单条 SQL 语句允许的最长限制 | -| 单位 | bytes | -| 取值范围 | 65480-1048576 | -| 缺省值 | 1048576 | +| 属性 | 说明 | +| -------- | ------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | tq 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | -### tscEnableRecordSql +### fsDebugFlag -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------------------- | -| 含义 | 是否记录客户端 sql 语句到文件 | -| 取值范围 | 0:否,1:是 | -| 缺省值 | 0 | -| 补充说明 | 生成的文件(tscnote-xxxx.0/tscnote-xxx.1,xxxx 是 pid),与客户端日志所在目录相同。 | +| 属性 | 说明 | +| -------- | ------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | fs 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | -### maxBinaryDisplayWidth +### udfDebugFlag -| 属性 | 说明 | -| -------- | -------------------------------------------------------------------------- | -| 含义 | Taos shell 中 binary 和 nchar 字段的显示宽度上限,超过此限制的部分将被隐藏 | -| 取值范围 | 5 - | -| 缺省值 | 30 | +| 属性 | 说明 | +| -------- | ---------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | UDF 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | -:::info -实际上限按以下规则计算:如果字段值的长度大于 maxBinaryDisplayWidth,则显示上限为 **字段名长度** 和 **maxBinaryDisplayWidth** 的较大者。
否则,上限为 **字段名长度** 和 **字段值长度** 的较大者。
可在 shell 中通过命令 set max_binary_display_width nn 动态修改此选项 +### smaDebugFlag -::: +| 属性 | 说明 | +| -------- | ---------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | sma 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | -### maxWildCardsLength +### idxDebugFlag -| 属性 | 说明 | -| -------- | ------------------------------------------ | -| 含义 | 设定 LIKE 算子的通配符字符串允许的最大长度 | -| 单位 | bytes | -| 取值范围 | 0-16384 | -| 缺省值 | 100 | -| 补充说明 | 2.1.6.1 版本新增。 | +| 属性 | 说明 | +| -------- | ---------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | index 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | -### clientMerge +### tdbDebugFlag -| 属性 | 说明 | -| -------- | ---------------------------- | -| 含义 | 是否允许客户端对写入数据去重 | -| 取值范围 | 0:不开启,1:开启 | -| 缺省值 | 0 | -| 补充说明 | 2.3 版本新增。 | - -### maxRegexStringLen - -| 属性 | 说明 | -| -------- | -------------------------- | -| 含义 | 正则表达式最大允许长度 | -| 取值范围 | 默认值 128,最大长度 16384 | -| 缺省值 | 128 | -| 补充说明 | 2.3 版本新增。 | +| 属性 | 说明 | +| -------- | ---------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | tdb 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | | ## 其他 diff --git a/docs/zh/14-reference/14-taosx.md b/docs/zh/14-reference/14-taosx.md new file mode 100644 index 0000000000000000000000000000000000000000..ed3f8d488fe6f809e855510df913f69cc79ee6a0 --- /dev/null +++ b/docs/zh/14-reference/14-taosx.md @@ -0,0 +1,4 @@ +--- +sidebar_label: taosX +title: 使用 taosX 在集群间复制数据 +--- \ No newline at end of file diff --git a/docs/zh/14-reference/_category_.yml b/docs/zh/14-reference/_category_.yml index ae861a15ff626b1e0424a28838830702262aa377..faca32476cc5a636ad76b093272d1116ff06ed3a 100644 --- a/docs/zh/14-reference/_category_.yml +++ b/docs/zh/14-reference/_category_.yml @@ -1 +1 @@ -label: 参考指南 \ No newline at end of file +label: 参考手册 \ No newline at end of file diff --git a/docs/zh/14-reference/index.md b/docs/zh/14-reference/index.md index f48ce31fcefd2f0d875aee64e7d92490f4e92fcb..e9c0c4fe236b8eefec1275a447c1dd1188921ee0 100644 --- a/docs/zh/14-reference/index.md +++ b/docs/zh/14-reference/index.md @@ -1,8 +1,8 @@ --- -title: 参考指南 +title: 参考手册 --- -参考指南是对 TDengine 本身、 TDengine 各语言连接器及自带的工具最详细的介绍。 +参考手册是对 TDengine 本身、 TDengine 各语言连接器及自带的工具最详细的介绍。 ```mdx-code-block import DocCardList from '@theme/DocCardList'; diff --git a/docs/zh/13-operation/01-pkg-install.md b/docs/zh/17-operation/01-pkg-install.md similarity index 98% rename from docs/zh/13-operation/01-pkg-install.md rename to docs/zh/17-operation/01-pkg-install.md index f814ee70b77db1a775dda951bab413da03d57561..0680f7609543322d1b74f4ca89df56d14fb705f7 100644 --- a/docs/zh/13-operation/01-pkg-install.md +++ b/docs/zh/17-operation/01-pkg-install.md @@ -10,7 +10,7 @@ import TabItem from "@theme/TabItem"; ## 安装 -关于安装,请参考 [使用安装包立即开始](../get-started/package) +关于安装,请参考 [使用安装包立即开始](../../get-started/package) diff --git a/docs/zh/13-operation/02-planning.mdx b/docs/zh/17-operation/02-planning.mdx similarity index 57% rename from docs/zh/13-operation/02-planning.mdx rename to docs/zh/17-operation/02-planning.mdx index 954ba7ca00ebdcb10cfcad515292d96127106ff3..0d63c4eaf365036cbba1d838ba6ee860a894724d 100644 --- a/docs/zh/13-operation/02-planning.mdx +++ b/docs/zh/17-operation/02-planning.mdx @@ -5,33 +5,28 @@ title: 容量规划 使用 TDengine 来搭建一个物联网大数据平台,计算资源、存储资源需要根据业务场景进行规划。下面分别讨论系统运行所需要的内存、CPU 以及硬盘空间。 -## 内存需求 +## 服务端内存需求 -每个 Database 可以创建固定数目的 vgroup,默认与 CPU 核数相同,可通过 maxVgroupsPerDb 配置;vgroup 中的每个副本会是一个 vnode;每个 vnode 会占用固定大小的内存(大小与数据库的配置参数 blocks 和 cache 有关);每个 Table 会占用与标签总长度有关的内存;此外,系统会有一些固定的内存开销。因此,每个 DB 需要的系统内存可通过如下公式计算: +每个 Database 可以创建固定数目的 vgroup,默认 2 个 vgroup,在创建数据库时可以通过`vgroups `参数来指定,其副本数由参数`replica `指定。vgroup 中的每个副本会是一个 vnode;所以每个数据库占用的内存由以下几个参数决定: -``` -Database Memory Size = maxVgroupsPerDb * replica * (blocks * cache + 10MB) + numOfTables * (tagSizePerTable + 0.5KB) -``` +- vgroups +- replica +- buffer +- pages +- pagesize +- cachesize -示例:假设 maxVgroupPerDB 是缺省值 64,cache 是缺省大小 16M, blocks 是缺省值 6,并且一个 DB 中有 10 万张表,单副本,标签总长度是 256 字节,则这个 DB 总的内存需求为:64 \* 1 \* (16 \* 6 + 10) + 100000 \* (0.25 + 0.5) / 1000 = 6792M。 +关于这些参数的详细说明请参考 [数据库管理](../../taos-sql/database)。 -在实际的系统运维中,我们通常会更关心 TDengine 服务进程(taosd)会占用的内存量。 +一个数据库所需要的内存大小等于 ``` -taosd 内存总量 = vnode 内存 + mnode 内存 + 查询内存 +vgroups * replica * (buffer + pages * pagesize + cachesize) ``` -其中: - -1. “vnode 内存”指的是集群中所有的 Database 存储分摊到当前 taosd 节点上所占用的内存资源。可以按上文“Database Memory Size”计算公式估算每个 DB 的内存占用量进行加总,再按集群中总共的 TDengine 节点数做平均(如果设置为多副本,则还需要乘以对应的副本倍数)。 -2. “mnode 内存”指的是集群中管理节点所占用的资源。如果一个 taosd 节点上分布有 mnode 管理节点,则内存消耗还需要增加“0.2KB \* 集群中数据表总数”。 -3. “查询内存”指的是服务端处理查询请求时所需要占用的内存。单条查询语句至少会占用“0.2KB \* 查询涉及的数据表总数”的内存量。 +但要注意的是这些内存并不需要由单一服务器提供,而是由整个集群中所有数据节点共同负担,相当于由这些数据节点所在的服务器共同负担。如果集群中有不止一个数据库,则所需内存要累加。更复杂的场景是如果集群中的数据节点并非在最初就一次性全部建立,而是随着使用中系统负载的增加逐步增加服务器并增加数据节点,则新创建的数据库会导致新旧数据节点上的负载并不均衡,此时简单的理论计算并不能直接使用,要结合各数据节点的负载情况。 -注意:以上内存估算方法,主要讲解了系统的“必须内存需求”,而不是“内存总数上限”。在实际运行的生产环境中,由于操作系统缓存、资源管理调度等方面的原因,内存规划应当在估算结果的基础上保留一定冗余,以维持系统状态和系统性能的稳定性。并且,生产环境通常会配置系统资源的监控工具,以便及时发现硬件资源的紧缺情况。 - -最后,如果内存充裕,可以考虑加大 Blocks 的配置,这样更多数据将保存在内存里,提高写入和查询速度。 - -### 客户端内存需求 +## 客户端内存需求 客户端应用采用 taosc 客户端驱动连接服务端,会有内存需求的开销。 @@ -56,7 +51,7 @@ CPU 的需求取决于如下两方面: - **数据插入** TDengine 单核每秒能至少处理一万个插入请求。每个插入请求可以带多条记录,一次插入一条记录与插入 10 条记录,消耗的计算资源差别很小。因此每次插入,条数越大,插入效率越高。如果一个插入请求带 200 条以上记录,单核就能达到每秒插入 100 万条记录的速度。但对前端数据采集的要求越高,因为需要缓存记录,然后一批插入。 - **查询需求** TDengine 提供高效的查询,但是每个场景的查询差异很大,查询频次变化也很大,难以给出客观数字。需要用户针对自己的场景,写一些查询语句,才能确定。 -因此仅对数据插入而言,CPU 是可以估算出来的,但查询所耗的计算资源无法估算。在实际运营过程中,不建议 CPU 使用率超过 50%,超过后,需要增加新的节点,以获得更多计算资源。 +因此仅对数据插入而言,CPU 是可以估算出来的,但查询所耗的计算资源无法估算。在实际运行过程中,不建议 CPU 使用率超过 50%,超过后,需要增加新的节点,以获得更多计算资源。 ## 存储需求 @@ -77,5 +72,3 @@ Raw DataSize = numOfTables * rowSizePerTable * rowsPerTable 根据上面的内存、CPU、存储的预估,就可以知道整个系统需要多少核、多少内存、多少存储空间。如果数据副本数不为 1,总需求量需要再乘以副本数。 因为 TDengine 具有很好的水平扩展能力,根据总量,再根据单个物理机或虚拟机的资源,就可以轻松决定需要购置多少台物理机或虚拟机了。 - -**立即计算 CPU、内存、存储,请参见:[资源估算方法](https://www.taosdata.com/config/config.html)。** diff --git a/docs/zh/17-operation/03-tolerance.md b/docs/zh/17-operation/03-tolerance.md new file mode 100644 index 0000000000000000000000000000000000000000..2cfd4b6484acdcb617cd91ed694d2f4c0f010e93 --- /dev/null +++ b/docs/zh/17-operation/03-tolerance.md @@ -0,0 +1,30 @@ +--- +title: 容错和灾备 +--- + +## 容错 + +TDengine 支持 **WAL**(Write Ahead Log)机制,实现数据的容错能力,保证数据的高可用。 + +TDengine 接收到应用的请求数据包时,先将请求的原始数据包写入数据库日志文件,等数据成功写入数据库数据文件后,再删除相应的 WAL。这样保证了 TDengine 能够在断电等因素导致的服务重启时从数据库日志文件中恢复数据,避免数据的丢失。 + +涉及的系统配置参数有两个: + +- wal_level:WAL 级别,1:写 WAL,但不执行 fsync。2:写 WAL,而且执行 fsync。默认值为 1。 +- wal_fsync_period:当 wal_level 设置为 2 时,执行 fsync 的周期。设置为 0,表示每次写入,立即执行 fsync。 + +如果要 100%的保证数据不丢失,需要将 wal_level 设置为 2,wal_fsync_period 设置为 0。这时写入速度将会下降。但如果应用侧启动的写数据的线程数达到一定的数量(超过 50),那么写入数据的性能也会很不错,只会比 wal_fsync_period 设置为 3000 毫秒下降 30%左右。 + +## 灾备 + +TDengine 的集群通过多个副本的机制,来提供系统的高可用性,同时具备一定的灾备能力。 + +TDengine 集群是由 mnode 负责管理的,为保证 mnode 的高可靠,可以配置 三个 mnode 副本。为保证元数据的强一致性,mnode 副本之间通过同步方式进行数据复制,保证了元数据的强一致性。 + +TDengine 集群中的时序数据的副本数是与数据库关联的,一个集群里可以有多个数据库,每个数据库可以配置不同的副本数。创建数据库时,通过参数 replica 指定副本数。为了支持高可靠,需要设置副本数为 3。 + +TDengine 集群的节点数必须大于等于副本数,否则创建表时将报错。 + +当 TDengine 集群中的节点部署在不同的物理机上,并设置多个副本数时,就实现了系统的高可靠性,无需再使用其他软件或工具。TDengine 企业版还可以将副本部署在不同机房,从而实现异地容灾。 + +另外一种灾备方式是通过 `taosX` 将一个 TDengine 集群的数据同步复制到物理上位于不同数据中心的另一个 TDengine 集群。其详细使用方法请参考 [taosX 参考手册](../../reference/taosX) diff --git a/docs/zh/13-operation/07-import.md b/docs/zh/17-operation/07-import.md similarity index 100% rename from docs/zh/13-operation/07-import.md rename to docs/zh/17-operation/07-import.md diff --git a/docs/zh/13-operation/08-export.md b/docs/zh/17-operation/08-export.md similarity index 100% rename from docs/zh/13-operation/08-export.md rename to docs/zh/17-operation/08-export.md diff --git a/docs/zh/13-operation/10-monitor.md b/docs/zh/17-operation/10-monitor.md similarity index 100% rename from docs/zh/13-operation/10-monitor.md rename to docs/zh/17-operation/10-monitor.md diff --git a/docs/zh/13-operation/17-diagnose.md b/docs/zh/17-operation/17-diagnose.md similarity index 100% rename from docs/zh/13-operation/17-diagnose.md rename to docs/zh/17-operation/17-diagnose.md diff --git a/docs/zh/13-operation/_category_.yml b/docs/zh/17-operation/_category_.yml similarity index 100% rename from docs/zh/13-operation/_category_.yml rename to docs/zh/17-operation/_category_.yml diff --git a/docs/zh/13-operation/index.md b/docs/zh/17-operation/index.md similarity index 100% rename from docs/zh/13-operation/index.md rename to docs/zh/17-operation/index.md diff --git a/docs/zh/21-tdinternal/01-arch.md b/docs/zh/21-tdinternal/01-arch.md index 507ccea6291cd2cdd5d2477e151ee58d2865e0be..4edad0fd1dda699d39ccf43ae9d6cc1894713bea 100644 --- a/docs/zh/21-tdinternal/01-arch.md +++ b/docs/zh/21-tdinternal/01-arch.md @@ -5,7 +5,7 @@ title: 整体架构 ## 集群与基本逻辑单元 -TDengine 的设计是基于单个硬件、软件系统不可靠,基于任何单台计算机都无法提供足够计算能力和存储能力处理海量数据的假设进行设计的。因此 TDengine 从研发的第一天起,就按照分布式高可靠架构进行设计,是支持水平扩展的,这样任何单台或多台服务器发生硬件故障或软件错误都不影响系统的可用性和可靠性。同时,通过节点虚拟化并辅以自动化负载均衡技术,TDengine 能最高效率地利用异构集群中的计算和存储资源降低硬件投资。 +TDengine 的设计是基于单个硬件、软件系统不可靠,基于任何单台计算机都无法提供足够计算能力和存储能力处理海量数据的假设进行设计的。因此 TDengine 从研发的第一天起,就按照分布式高可靠架构进行设计,是支持水平扩展的,这样任何单台或多台服务器发生硬件故障或软件错误都不影响系统的可用性和可靠性。同时,通过节点虚拟化并辅以负载均衡技术,TDengine 能最高效率地利用异构集群中的计算和存储资源降低硬件投资。 ### 主要逻辑单元 @@ -19,45 +19,43 @@ TDengine 分布式架构的逻辑结构图如下: **物理节点(pnode):** pnode 是一独立运行、拥有自己的计算、存储和网络能力的计算机,可以是安装有 OS 的物理机、虚拟机或 Docker 容器。物理节点由其配置的 FQDN(Fully Qualified Domain Name)来标识。TDengine 完全依赖 FQDN 来进行网络通讯,如果不了解 FQDN,请看博文[《一篇文章说清楚 TDengine 的 FQDN》](https://www.taosdata.com/blog/2020/09/11/1824.html)。 -**数据节点(dnode):** dnode 是 TDengine 服务器侧执行代码 taosd 在物理节点上的一个运行实例,一个工作的系统必须有至少一个数据节点。dnode 包含零到多个逻辑的虚拟节点(vnode),零或者至多一个逻辑的管理节点(mnode)。dnode 在系统中的唯一标识由实例的 End Point(EP)决定。EP 是 dnode 所在物理节点的 FQDN(Fully Qualified Domain Name)和系统所配置的网络端口号(Port)的组合。通过配置不同的端口,一个物理节点(一台物理机、虚拟机或容器)可以运行多个实例,或有多个数据节点。 +**数据节点(dnode):** dnode 是 TDengine 服务器侧执行代码 taosd 在物理节点上的一个运行实例,一个工作的系统必须有至少一个数据节点。dnode 包含零到多个逻辑的虚拟节点(vnode),零或者至多一个逻辑的管理节点(mnode),零或者至多一个逻辑的弹性计算节点(qnode),零或者至多一个逻辑的流计算节点(snode)。dnode 在系统中的唯一标识由实例的 End Point(EP)决定。EP 是 dnode 所在物理节点的 FQDN(Fully Qualified Domain Name)和系统所配置的网络端口号(Port)的组合。通过配置不同的端口,一个物理节点(一台物理机、虚拟机或容器)可以运行多个实例,或有多个数据节点。 -**虚拟节点(vnode):** 为更好的支持数据分片、负载均衡,防止数据过热或倾斜,数据节点被虚拟化成多个虚拟节点(vnode,图中 V2,V3,V4 等)。每个 vnode 都是一个相对独立的工作单元,是时序数据存储的基本单元,具有独立的运行线程、内存空间与持久化存储的路径。一个 vnode 包含一定数量的表(数据采集点)。当创建一张新表时,系统会检查是否需要创建新的 vnode。一个数据节点上能创建的 vnode 的数量取决于该数据节点所在物理节点的硬件资源。一个 vnode 只属于一个 DB,但一个 DB 可以有多个 vnode。一个 vnode 除存储的时序数据外,也保存有所包含的表的 schema、标签值等。一个虚拟节点由所属的数据节点的 EP,以及所属的 VGroup ID 在系统内唯一标识,由管理节点创建并管理。 +**虚拟节点(vnode):** 为更好的支持数据分片、负载均衡,防止数据过热或倾斜,数据节点被虚拟化成多个虚拟节点(vnode,图中 V2,V3,V4 等)。每个 vnode 都是一个相对独立的工作单元,是时序数据存储的基本单元,具有独立的运行线程、内存空间与持久化存储的路径。一个 vnode 包含一定数量的表(数据采集点)。当创建一个新 DB 时,系统会创建新的 vnode。一个数据节点上能创建的 vnode 的数量取决于该数据节点所在物理节点的硬件资源。一个 vnode 只属于一个 DB,但一个 DB 可以有多个 vnode。一个 vnode 除存储的时序数据外,也保存有所包含的表的 schema、标签值等。一个虚拟节点由所属的数据节点的 EP,以及所属的 VGroup ID 在系统内唯一标识,由管理节点创建并管理。 -**管理节点(mnode):** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M)。同时,管理节点也负责元数据(包括用户、数据库、表、静态标签等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(最多不超过 3 个)mnode,它们自动构建成为一个虚拟管理节点组(图中 M0,M1,M2)。mnode 间采用 master/slave 的机制进行管理,而且采取强一致方式进行数据同步,任何数据更新操作只能在 Master 上进行。mnode 集群的创建由系统自动完成,无需人工干预。每个 dnode 上至多有一个 mnode,由所属的数据节点的 EP 来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的 EP。 +**管理节点(mnode):** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M)。同时,管理节点也负责元数据(包括用户、数据库、超级表等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(最多不超过 3 个)mnode,它们自动构建成为一个虚拟管理节点组(图中 M1,M2,M3)。mnode 支持多副本,采用 RAFT 一致性协议,保证系统的高可用与高可靠,任何数据更新操作只能在 Leader 上进行。mnode 集群的第一个节点在集群部署时自动完成,其他节点的创建与删除由用户通过 SQL 命令完成。每个 dnode 上至多有一个 mnode,由所属的数据节点的 EP 来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的 EP。 -**虚拟节点组(VGroup):** 不同数据节点上的 vnode 可以组成一个虚拟节点组(vgroup)来保证系统的高可靠。虚拟节点组内采取 master/slave 的方式进行管理。写操作只能在 master vnode 上进行,系统采用异步复制的方式将数据同步到 slave vnode,这样确保了一份数据在多个物理节点上有拷贝。一个 vgroup 里虚拟节点个数就是数据的副本数。如果一个 DB 的副本数为 N,系统必须有至少 N 数据节点。副本数在创建 DB 时通过参数 replica 可以指定,缺省为 1。使用 TDengine 的多副本特性,可以不再需要昂贵的磁盘阵列等存储设备,就可以获得同样的数据高可靠性。虚拟节点组由管理节点创建、管理,并且由管理节点分配一个系统唯一的 ID,VGroup ID。如果两个虚拟节点的 VGroup ID 相同,说明他们属于同一个组,数据互为备份。虚拟节点组里虚拟节点的个数是可以动态改变的,容许只有一个,也就是没有数据复制。VGroup ID 是永远不变的,即使一个虚拟节点组被删除,它的 ID 也不会被收回重复利用。 +**弹性计算点(qnode):** 一个虚拟的逻辑单元,运行查询计算任务,也包括基于系统表来实现的 show 命令(图中 Q)。集群中可配置多个 qnode,在整个集群内部共享使用(图中 Q1,Q2,Q3)。qnode 不与具体的 DB 绑定,即一个 qnode 可以同时执行多个 DB 的查询任务。每个 dnode 上至多有一个 qnode,由所属的数据节点的 EP 来唯一标识。客户端通过与 mnode 交互,获取可用的 qnode 列表,当没有可用的 qnode 时,计算任务在 vnode 中执行。 -**Taosc** taosc 是 TDengine 给应用提供的驱动程序(driver),负责处理应用与集群的接口交互,提供 C/C++ 语言原生接口,内嵌于 JDBC、C#、Python、Go、Node.js 语言连接库里。应用都是通过 taosc 而不是直接连接集群中的数据节点与整个集群进行交互的。这个模块负责获取并缓存元数据;将插入、查询等请求转发到正确的数据节点;在把结果返回给应用时,还需要负责最后一级的聚合、排序、过滤等操作。对于 JDBC、C/C++、C#、Python、Go、Node.js 接口而言,这个模块是在应用所处的物理节点上运行。同时,为支持全分布式的 RESTful 接口,taosc 在 TDengine 集群的每个 dnode 上都有一运行实例。 +**流计算点(snode):** 一个虚拟的逻辑单元,只运行流计算任务(图中 S)。集群中可配置多个 snode,在整个集群内部共享使用(图中 S1,S2,S3)。snode 不与具体的 stream 绑定,即一个 snode 可以同时执行多个 stream 的计算任务。每个 dnode 上至多有一个 snode,由所属的数据节点的 EP 来唯一标识。由 mnode 调度可用的 snode 完成流计算任务,当没有可用的 snode 时,流计算任务在 vnode 中执行。 -### 节点之间的通讯 +**虚拟节点组(VGroup):** 不同数据节点上的 vnode 可以组成一个虚拟节点组(vgroup),采用 RAFT 一致性协议,保证系统的高可用与高可靠。写操作只能在 leader vnode 上进行,系统采用异步复制的方式将数据同步到 follower vnode,这样确保了一份数据在多个物理节点上有拷贝。一个 vgroup 里虚拟节点个数就是数据的副本数。如果一个 DB 的副本数为 N,系统必须有至少 N 数据节点。副本数在创建 DB 时通过参数 replica 可以指定,缺省为 1。使用 TDengine 的多副本特性,可以不再需要昂贵的磁盘阵列等存储设备,就可以获得同样的数据高可靠性。虚拟节点组由管理节点创建、管理,并且由管理节点分配一个系统唯一的 ID,VGroup ID。如果两个虚拟节点的 VGroup ID 相同,说明他们属于同一个组,数据互为备份。虚拟节点组里虚拟节点的个数是可以动态改变的,容许只有一个,也就是没有数据复制。VGroup ID 是永远不变的,即使一个虚拟节点组被删除,它的 ID 也不会被收回重复利用。 -**通讯方式:**TDengine 系统的各个数据节点之间,以及应用驱动与各数据节点之间的通讯是通过 TCP/UDP 进行的。因为考虑到物联网场景,数据写入的包一般不大,因此 TDengine 除采用 TCP 做传输之外,还采用 UDP 方式,因为 UDP 更加高效,而且不受连接数的限制。TDengine 实现了自己的超时、重传、确认等机制,以确保 UDP 的可靠传输。对于数据量不到 15K 的数据包,采取 UDP 的方式进行传输,超过 15K 的,或者是查询类的操作,自动采取 TCP 的方式进行传输。同时,TDengine 根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。对于数据节点之间的数据复制,只采用 TCP 方式进行数据传输。 +**Taosc** taosc 是 TDengine 给应用提供的驱动程序(driver),负责处理应用与集群的接口交互,提供 C/C++ 语言原生接口,内嵌于 JDBC、C#、Python、Go、Node.js 语言连接库里。应用都是通过 taosc 而不是直接连接集群中的数据节点与整个集群进行交互的。这个模块负责获取并缓存元数据;将插入、查询等请求转发到正确的数据节点;在把结果返回给应用时,还需要负责最后一级的聚合、排序、过滤等操作。对于 JDBC、C/C++、C#、Python、Go、Node.js 接口而言,这个模块是在应用所处的物理节点上运行。同时,taosc 也可以与 taosAdapter 交互,支持全分布式的 RESTful 接口。 -**FQDN 配置:**一个数据节点有一个或多个 FQDN,可以在系统配置文件 taos.cfg 通过参数“fqdn”进行指定,如果没有指定,系统将自动获取计算机的 hostname 作为其 FQDN。如果节点没有配置 FQDN,可以直接将该节点的配置参数 fqdn 设置为它的 IP 地址。但不建议使用 IP,因为 IP 地址可变,一旦变化,将让集群无法正常工作。一个数据节点的 EP(End Point)由 FQDN + Port 组成。采用 FQDN,需要保证 DNS 服务正常工作,或者在节点以及应用所在的节点配置好 hosts 文件。另外,这个参数值的长度需要控制在 96 个字符以内。 +### 节点之间的通讯 -**端口配置:**一个数据节点对外的端口由 TDengine 的系统配置参数 serverPort 决定,对集群内部通讯的端口是 serverPort+5。为支持多线程高效的处理 UDP 数据,每个对内和对外的 UDP 连接,都需要占用 5 个连续的端口。 +**通讯方式:**TDengine 系统的各个数据节点之间,以及应用驱动与各数据节点之间的通讯是通过 TCP 进行的。TDengine 根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。 -- 集群内数据节点之间的数据复制操作占用一个 TCP 端口,是 serverPort+10。 -- 集群数据节点对外提供 RESTful 服务占用一个 TCP 端口,是 serverPort+11。 -- 集群内数据节点与 Arbitrator 节点之间通讯占用一个 TCP 端口,是 serverPort+12。 +**FQDN 配置:**一个数据节点有一个或多个 FQDN,可以在系统配置文件 taos.cfg 通过参数“fqdn”进行指定,如果没有指定,系统将自动获取计算机的 hostname 作为其 FQDN。如果节点没有配置 FQDN,可以直接将该节点的配置参数 fqdn 设置为它的 IP 地址。但不建议使用 IP,因为 IP 地址可变,一旦变化,将让集群无法正常工作。一个数据节点的 EP(End Point)由 FQDN + Port 组成。采用 FQDN,需要保证 DNS 服务正常工作,或者在节点以及应用所在的节点配置好 hosts 文件。另外,这个参数值的长度需要控制在 96 个字符以内。 -因此一个数据节点总的端口范围为 serverPort 到 serverPort+12,总共 13 个 TCP/UDP 端口。确保集群中所有主机在端口 6030-6042 上的 TCP/UDP 协议能够互通。详细的端口情况请参见 [TDengine 2.0 端口说明](/train-faq/faq#port) +**端口配置:**一个数据节点对外的端口由 TDengine 的系统配置参数 serverPort 决定,默认为 6030。 **集群对外连接:**TDengine 集群可以容纳单个、多个甚至几千个数据节点。应用只需要向集群中任何一个数据节点发起连接即可,连接需要提供的网络参数是一数据节点的 End Point(FQDN 加配置的端口号)。通过命令行 CLI 启动应用 taos 时,可以通过选项-h 来指定数据节点的 FQDN,-P 来指定其配置的端口号,如果端口不配置,将采用 TDengine 的系统配置参数 serverPort。 -**集群内部通讯:**各个数据节点之间通过 TCP/UDP 进行连接。一个数据节点启动时,将获取 mnode 所在的 dnode 的 EP 信息,然后与系统中的 mnode 建立起连接,交换信息。获取 mnode 的 EP 信息有三步: +**集群内部通讯:**各个数据节点之间通过 TCP 进行连接。一个数据节点启动时,将获取 mnode 所在的 dnode 的 EP 信息,然后与系统中的 mnode 建立起连接,交换信息。获取 mnode 的 EP 信息有三步: -1. 检查 mnodeEpSet.json 文件是否存在,如果不存在或不能正常打开获得 mnode EP 信息,进入第二步; +1. 检查 dnode.json 文件是否存在,如果不存在或不能正常打开获得 mnode EP 信息,进入第二步; 2. 检查系统配置文件 taos.cfg,获取节点配置参数 firstEp、secondEp(这两个参数指定的节点可以是不带 mnode 的普通节点,这样的话,节点被连接时会尝试重定向到 mnode 节点),如果不存在或者 taos.cfg 里没有这两个配置参数,或无效,进入第三步; 3. 将自己的 EP 设为 mnode EP,并独立运行起来。 获取 mnode EP 列表后,数据节点发起连接,如果连接成功,则成功加入进工作的集群,如果不成功,则尝试 mnode EP 列表中的下一个。如果都尝试了,但连接都仍然失败,则休眠几秒后,再进行尝试。 -**Mnode 的选择:**TDengine 逻辑上有管理节点,但没有单独的执行代码,服务器侧只有一套执行代码 taosd。那么哪个数据节点会是管理节点呢?这是系统自动决定的,无需任何人工干预。原则如下:一个数据节点启动时,会检查自己的 End Point,并与获取的 mnode EP List 进行比对,如果在其中,该数据节点认为自己应该启动 mnode 模块,成为 mnode。如果自己的 EP 不在 mnode EP List 里,则不启动 mnode 模块。在系统的运行过程中,由于负载均衡、宕机等原因,mnode 有可能迁移至新的 dnode,但一切都是透明的,无需人工干预,配置参数的修改,是 mnode 自己根据资源做出的决定。 +**Mnode 的选择:**TDengine 逻辑上有管理节点,但没有单独的执行代码,服务器侧只有一套执行代码 taosd。那么哪个数据节点会是管理节点呢?在集群部署时,第一个数据节点自动成为管理节点。集群中的其他管理节点的创建与删除,由用户通过 SQL 语句完成。 **新数据节点的加入:**系统有了一个数据节点后,就已经成为一个工作的系统。添加新的节点进集群时,有两个步骤,第一步:使用 TDengine CLI 连接到现有工作的数据节点,然后用命令“CREATE DNODE”将新的数据节点的 End Point 添加进去;第二步:在新的数据节点的系统配置参数文件 taos.cfg 里,将 firstEp,secondEp 参数设置为现有集群中任意两个数据节点的 EP 即可。具体添加的详细步骤请见详细的用户手册。这样就把集群一步一步的建立起来。 -**重定向:**无论是 dnode 还是 taosc,最先都是要发起与 mnode 的连接,但 mnode 是系统自动创建并维护的,因此对于用户来说,并不知道哪个 dnode 在运行 mnode。TDengine 只要求向系统中任何一个工作的 dnode 发起连接即可。因为任何一个正在运行的 dnode,都维护有目前运行的 mnode EP List。当收到一个来自新启动的 dnode 或 taosc 的连接请求,如果自己不是 mnode,则将 mnode EP List 回复给对方,taosc 或新启动的 dnode 收到这个 list,就重新尝试建立连接。当 mnode EP List 发生改变,通过节点之间的消息交互,各个数据节点就很快获取最新列表,并通知 taosc。 +**重定向:**无论是 dnode 还是 taosc,最先都是要发起与 mnode 的连接,由于 mnode 是可以动态调整的,所以对于用户来说,并不知道哪个 dnode 在运行 mnode。TDengine 只要求向系统中任何一个工作的 dnode 发起连接即可。因为任何一个正在运行的 dnode,都维护有目前运行的 mnode EP List。当收到一个来自新启动的 dnode 或 taosc 的连接请求,如果自己不是 mnode,则将 mnode EP List 回复给对方,taosc 或新启动的 dnode 收到这个 list,就重新尝试建立连接。当 mnode EP List 发生改变,通过节点之间的消息交互,各个数据节点就很快获取最新列表,并通知 taosc。 ### 一个典型的消息流程 @@ -68,15 +66,17 @@ TDengine 分布式架构的逻辑结构图如下:
图 2 TDengine 典型的操作流程
1. 应用通过 JDBC 或其他 API 接口发起插入数据的请求。 -2. taosc 会检查缓存,看是否保存有该表的 meta data。如果有,直接到第 4 步。如果没有,taosc 将向 mnode 发出 get meta-data 请求。 -3. mnode 将该表的 meta-data 返回给 taosc。Meta-data 包含有该表的 schema,而且还有该表所属的 vgroup 信息(vnode ID 以及所在的 dnode 的 End Point,如果副本数为 N,就有 N 组 End Point)。如果 taosc 迟迟得不到 mnode 回应,而且存在多个 mnode,taosc 将向下一个 mnode 发出请求。 -4. taosc 向 master vnode 发起插入请求。 -5. vnode 插入数据后,给 taosc 一个应答,表示插入成功。如果 taosc 迟迟得不到 vnode 的回应,taosc 会认为该节点已经离线。这种情况下,如果被插入的数据库有多个副本,taosc 将向 vgroup 里下一个 vnode 发出插入请求。 -6. taosc 通知 APP,写入成功。 +2. taosc 会检查缓存,看是否保存有该表所在数据库的 vgroup-info 信息。如果有,直接到第 4 步。如果没有,taosc 将向 mnode 发出 get vgroup-info 请求。 +3. mnode 将该表所在数据库的 vgroup-info 返回给 taosc。Vgroup-info 包含数据库的 vgroup 分布信息(vnode ID 以及所在的 dnode 的 End Point,如果副本数为 N,就有 N 组 End Point),还包含每个 vgroup 中存储数据表的 hash 范围。如果 taosc 迟迟得不到 mnode 回应,而且存在多个 mnode,taosc 将向下一个 mnode 发出请求。 +4. taosc 会继续检查缓存,看是否保存有该表的 meta-data。如果有,直接到第 6 步。如果没有,taosc 将向 vnode 发出 get meta-data 请求。 +5. vnode 将该表的 meta-data 返回给 taosc。Meta-data 包含有该表的 schema。 +6. taosc 向 leader vnode 发起插入请求。 +7. vnode 插入数据后,给 taosc 一个应答,表示插入成功。如果 taosc 迟迟得不到 vnode 的回应,taosc 会认为该节点已经离线。这种情况下,如果被插入的数据库有多个副本,taosc 将向 vgroup 里下一个 vnode 发出插入请求。 +8. taosc 通知 APP,写入成功。 -对于第二和第三步,taosc 启动时,并不知道 mnode 的 End Point,因此会直接向配置的集群对外服务的 End Point 发起请求。如果接收到该请求的 dnode 并没有配置 mnode,该 dnode 会在回复的消息中告知 mnode EP 列表,这样 taosc 会重新向新的 mnode 的 EP 发出获取 meta-data 的请求。 +对于第二步,taosc 启动时,并不知道 mnode 的 End Point,因此会直接向配置的集群对外服务的 End Point 发起请求。如果接收到该请求的 dnode 并没有配置 mnode,该 dnode 会在回复的消息中告知 mnode EP 列表,这样 taosc 会重新向新的 mnode 的 EP 发出获取 meta-data 的请求。 -对于第四和第五步,没有缓存的情况下,taosc 无法知道虚拟节点组里谁是 master,就假设第一个 vnodeID 就是 master,向它发出请求。如果接收到请求的 vnode 并不是 master,它会在回复中告知谁是 master,这样 taosc 就向建议的 master vnode 发出请求。一旦得到插入成功的回复,taosc 会缓存 master 节点的信息。 +对于第四和第六步,没有缓存的情况下,taosc 无法知道虚拟节点组里谁是 leader,就假设第一个 vnodeID 就是 leader,向它发出请求。如果接收到请求的 vnode 并不是 leader,它会在回复中告知谁是 leader,这样 taosc 就向建议的 leader vnode 发出请求。一旦得到插入成功的回复,taosc 会缓存 leader 节点的信息。 上述是插入数据的流程,查询、计算的流程也完全一致。taosc 把这些复杂的流程全部封装屏蔽了,对于应用来说无感知也无需任何特别处理。 @@ -89,13 +89,13 @@ TDengine 分布式架构的逻辑结构图如下: TDengine 存储的数据包括采集的时序数据以及库、表相关的元数据、标签数据等,这些数据具体分为三部分: - 时序数据:存放于 vnode 里,由 data、head 和 last 三个文件组成,数据量大,查询量取决于应用场景。容许乱序写入,但暂时不支持删除操作,并且仅在 update 参数设置为 1 时允许更新操作。通过采用一个采集点一张表的模型,一个时间段的数据是连续存储,对单张表的写入是简单的追加操作,一次读,可以读到多条记录,这样保证对单个采集点的插入和查询操作,性能达到最优。 -- 标签数据:存放于 vnode 里的 meta 文件,支持增删改查四个标准操作。数据量不大,有 N 张表,就有 N 条记录,因此可以全内存存储。如果标签过滤操作很多,查询将十分频繁,因此 TDengine 支持多核多线程并发查询。只要计算资源足够,即使有数千万张表,过滤结果能毫秒级返回。 -- 元数据:存放于 mnode 里,包含系统节点、用户、DB、Table Schema 等信息,支持增删改查四个标准操作。这部分数据的量不大,可以全内存保存,而且由于客户端有缓存,查询量也不大。因此目前的设计虽是集中式存储管理,但不会构成性能瓶颈。 +- 数据表元数据:包含标签信息和 Table Schema 信息,存放于 vnode 里的 meta 文件,支持增删改查四个标准操作。数据量很大,有 N 张表,就有 N 条记录,因此采用 LRU 存储,支持标签数据的索引。TDengine 支持多核多线程并发查询。只要计算内存足够,元数据全内存存储,千万级别规模的标签数据过滤结果能毫秒级返回。在内存资源不足的情况下,仍然可以支持数千万张表的快速查询。 +- 数据库元数据:存放于 mnode 里,包含系统节点、用户、DB、STable Schema 等信息,支持增删改查四个标准操作。这部分数据的量不大,可以全内存保存,而且由于客户端有缓存,查询量也不大。因此目前的设计虽是集中式存储管理,但不会构成性能瓶颈。 与典型的 NoSQL 存储模型相比,TDengine 将标签数据与时序数据完全分离存储,它具有两大优势: - 能够极大地降低标签数据存储的冗余度:一般的 NoSQL 数据库或时序数据库,采用的 K-V 存储,其中的 Key 包含时间戳、设备 ID、各种标签。每条记录都带有这些重复的内容,浪费存储空间。而且如果应用要在历史数据上增加、修改或删除标签,需要遍历数据,重写一遍,操作成本极其昂贵。 -- 能够实现极为高效的多表之间的聚合查询:做多表之间聚合查询时,先把符合标签过滤条件的表查找出来,然后再查找这些表相应的数据块,这样大幅减少要扫描的数据集,从而大幅提高查询效率。而且标签数据采用全内存的结构进行管理和维护,千万级别规模的标签数据查询可以在毫秒级别返回。 +- 能够实现极为高效的多表之间的聚合查询:做多表之间聚合查询时,先把符合标签过滤条件的表查找出来,然后再查找这些表相应的数据块,这样大幅减少要扫描的数据集,从而大幅提高查询效率。 ### 数据分片 @@ -105,7 +105,7 @@ vnode(虚拟数据节点)负责为采集的时序数据提供写入、查询 对于单独一个数据采集点,无论其数据量多大,一个 vnode(或 vgroup,如果副本数大于 1)有足够的计算资源和存储资源来处理(如果每秒生成一条 16 字节的记录,一年产生的原始数据不到 0.5G),因此 TDengine 将一张表(一个数据采集点)的所有数据都存放在一个 vnode 里,而不会让同一个采集点的数据分布到两个或多个 dnode 上。而且一个 vnode 可存储多个数据采集点(表)的数据,一个 vnode 可容纳的表的数目的上限为一百万。设计上,一个 vnode 里所有的表都属于同一个 DB。一个数据节点上,除非特殊配置,一个 DB 拥有的 vnode 数目不会超过系统核的数目。 -创建 DB 时,系统并不会马上分配资源。但当创建一张表时,系统将看是否有已经分配的 vnode,且该 vnode 是否有空余的表空间,如果有,立即在该有空位的 vnode 创建表。如果没有,系统将从集群中,根据当前的负载情况,在一个 dnode 上创建一新的 vnode,然后创建表。如果 DB 有多个副本,系统不是只创建一个 vnode,而是一个 vgroup(虚拟数据节点组)。系统对 vnode 的数目没有任何限制,仅仅受限于物理节点本身的计算和存储资源。 +TDengine 3.0 采用 hash 一致性算法,确定每张数据表所在的 vnode。创建 DB 时,系统会立刻分配指定数目的 vnode,并确定每个 vnode 所负责的数据表范围。当创建一张表时,系统根据数据表名计算出所在的 vnodeID,立即在该 vnode 创建表。如果 DB 有多个副本,系统不是只创建一个 vnode,而是一个 vgroup(虚拟数据节点组)。系统对 vnode 的数目没有任何限制,仅仅受限于物理节点本身的计算和存储资源。 每张表的 meta data(包含 schema,标签等)也存放于 vnode 里,而不是集中存放于 mnode,实际上这是对 Meta 数据的分片,这样便于高效并行的进行标签过滤操作。 @@ -117,77 +117,68 @@ TDengine 除 vnode 分片之外,还对时序数据按照时间段进行分区 ### 负载均衡 -每个 dnode 都定时向 mnode(虚拟管理节点)报告其状态(包括硬盘空间、内存大小、CPU、网络、虚拟节点个数等),因此 mnode 了解整个集群的状态。基于整体状态,当 mnode 发现某个 dnode 负载过重,它会将 dnode 上的一个或多个 vnode 挪到其他 dnode。在挪动过程中,对外服务继续进行,数据插入、查询和计算操作都不受影响。 +每个 dnode 都定时向 mnode(虚拟管理节点)报告其状态(包括硬盘空间、内存大小、CPU、网络、虚拟节点个数等),因此 mnode 了解整个集群的状态。基于整体状态,当 mnode 发现某个 dnode 负载过重,它会将 dnode 上的一个或多个 vnode 挪到其他 dnode。在挪动过程中,对外服务继续进行,数据插入、查询和计算操作都不受影响。负载均衡的触发时间,由用户指定。 -如果 mnode 一段时间没有收到 dnode 的状态报告,mnode 会认为这个 dnode 已经离线。如果离线时间超过一定时长(时长由配置参数 offlineThreshold 决定),该 dnode 将被 mnode 强制剔除出集群。该 dnode 上的 vnodes 如果副本数大于 1,系统将自动在其他 dnode 上创建新的副本,以保证数据的副本数。如果该 dnode 上还有 mnode,而且 mnode 的副本数大于 1,系统也将自动在其他 dnode 上创建新的 mnode,以保证 mnode 的副本数。 - -当新的数据节点被添加进集群,因为新的计算和存储被添加进来,系统也将自动启动负载均衡流程。 - -负载均衡过程无需任何人工干预,应用也无需重启,将自动连接新的节点,完全透明。 +当新的数据节点被添加进集群,因为新的计算和存储被添加进来,用户需要手动触发负载均衡流程,使得系统在最优的情况下运行。 **提示:负载均衡由参数 balance 控制,决定开启/关闭自动负载均衡。** ## 数据写入与复制流程 -如果一个数据库有 N 个副本,那一个虚拟节点组就有 N 个虚拟节点,但是只有一个是 master,其他都是 slave。当应用将新的记录写入系统时,只有 master vnode 能接受写的请求。如果 slave vnode 收到写的请求,系统将通知 taosc 需要重新定向。 +如果一个数据库有 N 个副本,那一个虚拟节点组就有 N 个虚拟节点,但是只有一个是 leader,其他都是 follower。当应用将新的记录写入系统时,只有 leader vnode 能接受写的请求。如果 follower vnode 收到写的请求,系统将通知 taosc 需要重新定向。 -### Master Vnode 写入流程 +### Leader Vnode 写入流程 -Master Vnode 遵循下面的写入流程: +Leader Vnode 遵循下面的写入流程: -![TDengine Database Master写入流程](./write_master.webp) +![TDengine Database Leader写入流程](./write_leader.webp) -
图 3 TDengine Master 写入流程
+
图 3 TDengine Leader 写入流程
-1. master vnode 收到应用的数据插入请求,验证 OK,进入下一步; -2. 如果系统配置参数 walLevel 大于 0,vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失; -3. 如果有多个副本,vnode 将把数据包转发给同一虚拟节点组内的 slave vnodes,该转发包带有数据的版本号(version); -4. 写入内存,并将记录加入到 skip list; -5. master vnode 返回确认信息给应用,表示写入成功; -6. 如果第 2、3、4 步中任何一步失败,将直接返回错误给应用。 +1. leader vnode 收到应用的数据插入请求,验证 OK,进入下一步; +2. vnode 将该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失; +3. 如果有多个副本,vnode 将把数据包转发给同一虚拟节点组内的 follower vnodes,该转发包带有数据的版本号(version); +4. 写入内存,并将记录加入到 skip list。但如果未达成一致,会触发回滚操作; +5. leader vnode 返回确认信息给应用,表示写入成功; +6. 如果第 2、3、4 步中任何一步失败,将直接返回错误给应用; -### Slave Vnode 写入流程 +### Follower Vnode 写入流程 -对于 slave vnode,写入流程是: +对于 follower vnode,写入流程是: -![TDengine Database Slave 写入流程](./write_slave.webp) +![TDengine Database Follower 写入流程](./write_follower.webp) -
图 4 TDengine Slave 写入流程
+
图 4 TDengine Follower 写入流程
-1. slave vnode 收到 Master vnode 转发了的数据插入请求。检查 last version 是否与 master 一致,如果一致,进入下一步。如果不一致,需要进入同步状态。 -2. 如果系统配置参数 walLevel 大于 0,vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失。 +1. follower vnode 收到 leader vnode 转发了的数据插入请求。 +2. vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失。 3. 写入内存,更新内存中的 skip list。 -与 master vnode 相比,slave vnode 不存在转发环节,也不存在回复确认环节,少了两步。但写内存与 WAL 是完全一样的。 +与 leader vnode 相比,follower vnode 不存在转发环节,也不存在回复确认环节,少了两步。但写内存与 WAL 是完全一样的。 ### 主从选择 Vnode 会保持一个数据版本号(version),对内存数据进行持久化存储时,对该版本号也进行持久化存储。每个数据更新操作,无论是采集的时序数据还是元数据,这个版本号将增加 1。 -一个 vnode 启动时,角色(master、slave)是不定的,数据是处于未同步状态,它需要与虚拟节点组内其他节点建立 TCP 连接,并互相交换 status,其中包括 version 和自己的角色。通过 status 的交换,系统进入选主流程,规则如下: - -1. 如果只有一个副本,该副本永远就是 master -2. 所有副本都在线时,版本最高的被选为 master -3. 在线的虚拟节点数过半,而且有虚拟节点是 slave 的话,该虚拟节点自动成为 master -4. 对于 2 和 3,如果多个虚拟节点满足成为 master 的要求,那么虚拟节点组的节点列表里,最前面的选为 master +一个 vnode 启动时,角色(leader、follower)是不定的,数据是处于未同步状态,它需要与虚拟节点组内其他节点建立 TCP 连接,并互相交换 status,按照标准的 raft 一致性算法完成选主。 -更多的关于数据复制的流程,请见[《TDengine 2.0 数据复制模块设计》](/tdinternal/replica/)。 +更多的关于数据复制的流程,请见[《TDengine 3.0 数据复制模块设计》](/tdinternal/replica/)。 ### 同步复制 -对于数据一致性要求更高的场景,异步数据复制无法满足要求,因为有极小的概率丢失数据,因此 TDengine 提供同步复制的机制供用户选择。在创建数据库时,除指定副本数 replica 之外,用户还需要指定新的参数 quorum。如果 quorum 大于 1,它表示每次 master 转发给副本时,需要等待 quorum-1 个回复确认,才能通知应用,数据在 slave 已经写入成功。如果在一定的时间内,得不到 quorum-1 个回复确认,master vnode 将返回错误给应用。 +对于数据一致性要求更高的场景,异步数据复制提供的最终一致性无法满足要求。因此 TDengine 提供同步复制的机制供用户选择。在创建数据库时,除指定副本数 replica 之外,用户还需要指定新的参数 strict。如果 strict 等于 1,它表示每次 leader 转发给副本时,需要等待半数以上副本达成一致后,才能通知应用,数据在 follower 已经写入成功。如果在一定的时间内,得不到半数以上副本的确认,leader vnode 将返回错误给应用。 采用同步复制,系统的性能会有所下降,而且 latency 会增加。因为元数据要强一致,mnode 之间的数据同步缺省就是采用的同步复制。 ## 缓存与持久化 -### 缓存 +### 时序数据缓存 TDengine 采用时间驱动缓存管理策略(First-In-First-Out,FIFO),又称为写驱动的缓存管理机制。这种策略有别于读驱动的数据缓存模式(Least-Recent-Used,LRU),直接将最近写入的数据保存在系统的缓存中。当缓存达到临界值的时候,将最早的数据批量写入磁盘。一般意义上来说,对于物联网数据的使用,用户最为关心的是刚产生的数据,即当前状态。TDengine 充分利用这一特性,将最近到达的(当前状态)数据保存在缓存中。 TDengine 通过查询函数向用户提供毫秒级的数据获取能力。直接将最近到达的数据保存在缓存中,可以更加快速地响应用户针对最近一条或一批数据的查询分析,整体上提供更快的数据库查询响应能力。从这个意义上来说,**可通过设置合适的配置参数将 TDengine 作为数据缓存来使用,而不需要再部署 Redis 或其他额外的缓存系统**,可有效地简化系统架构,降低运维的成本。需要注意的是,TDengine 重启以后系统的缓存将被清空,之前缓存的数据均会被批量写入磁盘,缓存的数据将不会像专门的 key-value 缓存系统再将之前缓存的数据重新加载到缓存中。 -每个 vnode 有自己独立的内存,而且由多个固定大小的内存块组成,不同 vnode 之间完全隔离。数据写入时,类似于日志的写法,数据被顺序追加写入内存,但每个 vnode 维护有自己的 skip list,便于迅速查找。当三分之一以上的内存块写满时,启动落盘操作,而且后续写的操作在新的内存块进行。这样,一个 vnode 里有三分之一内存块是保留有最近的数据的,以达到缓存、快速查找的目的。一个 vnode 的内存块的个数由配置参数 blocks 决定,内存块的大小由配置参数 cache 决定。 +每个 vnode 有自己独立的内存,而且由多个固定大小的内存块组成,不同 vnode 之间完全隔离。数据写入时,类似于日志的写法,数据被顺序追加写入内存,但每个 vnode 维护有自己的 skip list,便于迅速查找。当三分之一以上的内存块写满时,启动落盘操作,而且后续写的操作在新的内存块进行。这样,一个 vnode 里有三分之一内存块是保留有最近的数据的,以达到缓存、快速查找的目的。一个 vnode 的内存大小由配置参数 buffer 决定。 ### 持久化存储 diff --git a/docs/zh/21-tdinternal/message.webp b/docs/zh/21-tdinternal/message.webp index a2a42abff3d6e932b41a3abe9feae4a5cc13c9e5..4a5f5f86f38abfe134cef2801b7dca24c55b6657 100644 Binary files a/docs/zh/21-tdinternal/message.webp and b/docs/zh/21-tdinternal/message.webp differ diff --git a/docs/zh/21-tdinternal/structure.webp b/docs/zh/21-tdinternal/structure.webp index b77a42c074b15302b5c3ab889fb550a46dd549b3..ee7a799975b3d2a71f27c236743ddd6bd0be7f69 100644 Binary files a/docs/zh/21-tdinternal/structure.webp and b/docs/zh/21-tdinternal/structure.webp differ diff --git a/docs/zh/21-tdinternal/write_follower.webp b/docs/zh/21-tdinternal/write_follower.webp new file mode 100644 index 0000000000000000000000000000000000000000..1ca537cd60506a7e7ef0f9442bdcd9d8035fae4d Binary files /dev/null and b/docs/zh/21-tdinternal/write_follower.webp differ diff --git a/docs/zh/21-tdinternal/write_leader.webp b/docs/zh/21-tdinternal/write_leader.webp new file mode 100644 index 0000000000000000000000000000000000000000..1771961b97766aaa43bc47f1311c441c94511477 Binary files /dev/null and b/docs/zh/21-tdinternal/write_leader.webp differ diff --git a/docs/zh/21-tdinternal/write_master.webp b/docs/zh/21-tdinternal/write_master.webp deleted file mode 100644 index 9624036ed3d46ed60924ead9ce5c61acee0f4652..0000000000000000000000000000000000000000 Binary files a/docs/zh/21-tdinternal/write_master.webp and /dev/null differ diff --git a/docs/zh/21-tdinternal/write_slave.webp b/docs/zh/21-tdinternal/write_slave.webp deleted file mode 100644 index 7c45dec11b00e6a738de458f9e1bedacfad75a96..0000000000000000000000000000000000000000 Binary files a/docs/zh/21-tdinternal/write_slave.webp and /dev/null differ diff --git a/examples/c/tmq.c b/examples/c/tmq.c index 1d2b26624bb3be70051e183b7228b0ec90a48aa8..fd1f146618874132738a675714841e966353311a 100644 --- a/examples/c/tmq.c +++ b/examples/c/tmq.c @@ -29,7 +29,7 @@ static void msg_process(TAOS_RES* msg) { printf("vg: %d\n", tmq_get_vgroup_id(msg)); if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META) { tmq_raw_data raw = {0}; - int32_t code = tmq_get_raw_meta(msg, &raw); + int32_t code = tmq_get_raw(msg, &raw); if (code == 0) { TAOS* pConn = taos_connect("192.168.1.86", "root", "taosdata", NULL, 0); if (pConn == NULL) { @@ -50,7 +50,7 @@ static void msg_process(TAOS_RES* msg) { } taos_free_result(pRes); - int32_t ret = taos_write_raw_meta(pConn, raw); + int32_t ret = tmq_write_raw(pConn, raw); printf("write raw data: %s\n", tmq_err2str(ret)); taos_close(pConn); } diff --git a/examples/c/tmq_taosx.c b/examples/c/tmq_taosx.c index 13f3b18e64b69271adea3637f19f074138dd6d86..d0def4426905b773db948b0cf6f0d22c8733d5da 100644 --- a/examples/c/tmq_taosx.c +++ b/examples/c/tmq_taosx.c @@ -49,18 +49,25 @@ static void msg_process(TAOS_RES* msg) { printf("meta result: %s\n", result); } tmq_free_json_meta(result); - - - tmq_raw_data raw = {0}; - tmq_get_raw_meta(msg, &raw); - int32_t ret = taos_write_raw_meta(pConn, raw); - printf("write raw meta: %s\n", tmq_err2str(ret)); } - if(tmq_get_res_type(msg) == TMQ_RES_DATA){ - int32_t ret =taos_write_raw_data(pConn, msg); - printf("write raw data: %s\n", tmq_err2str(ret)); - } + tmq_raw_data raw = {0}; + tmq_get_raw(msg, &raw); + int32_t ret = tmq_write_raw(pConn, raw); + printf("write raw data: %s\n", tmq_err2str(ret)); + +// else{ +// while(1){ +// int numOfRows = 0; +// void *pData = NULL; +// taos_fetch_raw_block(msg, &numOfRows, &pData); +// if(numOfRows == 0) break; +// printf("write data: tbname:%s, numOfRows:%d\n", tmq_get_table_name(msg), numOfRows); +// int ret = taos_write_raw_block(pConn, numOfRows, pData, tmq_get_table_name(msg)); +// printf("write raw data: %s\n", tmq_err2str(ret)); +// } +// } + taos_close(pConn); } @@ -121,7 +128,7 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = taos_query(pConn, "insert into ct0 values(now, 1, 2, 'a')"); + pRes = taos_query(pConn, "insert into ct0 values(1626006833600, 1, 2, 'a')"); if (taos_errno(pRes) != 0) { printf("failed to insert into ct0, reason:%s\n", taos_errstr(pRes)); return -1; @@ -142,7 +149,7 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = taos_query(pConn, "insert into ct1 values(now, 3, 4, 'b')"); + pRes = taos_query(pConn, "insert into ct1 values(1626006833600, 3, 4, 'b')"); if (taos_errno(pRes) != 0) { printf("failed to insert into ct1, reason:%s\n", taos_errstr(pRes)); return -1; @@ -156,7 +163,7 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = taos_query(pConn, "insert into ct3 values(now, 5, 6, 'c') ct1 values(now+1s, 2, 3, 'sds') (now+2s, 4, 5, 'ddd') ct0 values(now+1s, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')"); + pRes = taos_query(pConn, "insert into ct3 values(1626006833600, 5, 6, 'c') ct1 values(1626006833601, 2, 3, 'sds') (1626006833602, 4, 5, 'ddd') ct0 values(1626006833602, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')"); if (taos_errno(pRes) != 0) { printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes)); return -1; @@ -177,7 +184,14 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = taos_query(pConn, "insert into ct3 values(now+7s, 53, 63, 'cffffffffffffffffffffffffffff', 8989898899999) (now+9s, 51, 62, 'c333', 940)"); + pRes = taos_query(pConn, "insert into ct3 values(1626006833605, 53, 63, 'cffffffffffffffffffffffffffff', 8989898899999) (1626006833609, 51, 62, 'c333', 940)"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into ct3 select * from ct1"); if (taos_errno(pRes) != 0) { printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes)); return -1; @@ -198,19 +212,26 @@ int32_t init_env() { } taos_free_result(pRes); -// pRes = taos_query(pConn, "drop table ct3 ct1"); -// if (taos_errno(pRes) != 0) { -// printf("failed to drop child table ct3, reason:%s\n", taos_errstr(pRes)); -// return -1; -// } -// taos_free_result(pRes); -// -// pRes = taos_query(pConn, "drop table st1"); -// if (taos_errno(pRes) != 0) { -// printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes)); -// return -1; -// } -// taos_free_result(pRes); + pRes = taos_query(pConn, "delete from abc1 .ct3 where ts < 1626006833606"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "drop table ct3 ct1"); + if (taos_errno(pRes) != 0) { + printf("failed to drop child table ct3, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "drop table st1"); + if (taos_errno(pRes) != 0) { + printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); pRes = taos_query(pConn, "create table if not exists n1(ts timestamp, c1 int, c2 nchar(4))"); if (taos_errno(pRes) != 0) { @@ -261,12 +282,12 @@ int32_t init_env() { } taos_free_result(pRes); -// pRes = taos_query(pConn, "drop table n1"); -// if (taos_errno(pRes) != 0) { -// printf("failed to drop normal table n1, reason:%s\n", taos_errstr(pRes)); -// return -1; -// } -// taos_free_result(pRes); + pRes = taos_query(pConn, "drop table n1"); + if (taos_errno(pRes) != 0) { + printf("failed to drop normal table n1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); pRes = taos_query(pConn, "create table jt(ts timestamp, i int) tags(t json)"); if (taos_errno(pRes) != 0) { @@ -289,21 +310,21 @@ int32_t init_env() { } taos_free_result(pRes); -// pRes = taos_query(pConn, -// "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 " -// "nchar(8), t4 bool)"); -// if (taos_errno(pRes) != 0) { -// printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes)); -// return -1; -// } -// taos_free_result(pRes); -// -// pRes = taos_query(pConn, "drop table st1"); -// if (taos_errno(pRes) != 0) { -// printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes)); -// return -1; -// } -// taos_free_result(pRes); + pRes = taos_query(pConn, + "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 " + "nchar(8), t4 bool)"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "drop table st1"); + if (taos_errno(pRes) != 0) { + printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); taos_close(pConn); return 0; diff --git a/include/client/taos.h b/include/client/taos.h index 5f147bb07cadbb7969a352fd5b0fb0191e732bb2..6f3244ea82fcbe5edfd52689d2c6a95fc3a2e521 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -260,17 +260,20 @@ enum tmq_res_t { }; typedef struct tmq_raw_data{ - void* raw_meta; - uint32_t raw_meta_len; - uint16_t raw_meta_type; + void* raw; + uint32_t raw_len; + uint16_t raw_type; } tmq_raw_data; typedef enum tmq_res_t tmq_res_t; DLL_EXPORT tmq_res_t tmq_get_res_type(TAOS_RES *res); -DLL_EXPORT int32_t tmq_get_raw_meta(TAOS_RES *res, tmq_raw_data *raw_meta); -DLL_EXPORT int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data raw_meta); -DLL_EXPORT int32_t taos_write_raw_data(TAOS *taos, TAOS_RES *res); +DLL_EXPORT int32_t tmq_get_raw(TAOS_RES *res, tmq_raw_data *raw); +DLL_EXPORT int32_t tmq_write_raw(TAOS *taos, tmq_raw_data raw); +DLL_EXPORT int taos_write_raw_block(TAOS *taos, int numOfRows, char *pData, const char* tbname); + + +DLL_EXPORT void tmq_free_raw(tmq_raw_data raw); DLL_EXPORT char *tmq_get_json_meta(TAOS_RES *res); // Returning null means error. Returned result need to be freed by tmq_free_json_meta DLL_EXPORT void tmq_free_json_meta(char* jsonMeta); DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res); diff --git a/include/common/tcommon.h b/include/common/tcommon.h index e1aadd448663616e8526b3201a1af13bb7775ed2..c5404085bbb56d01b39866e515bf743349ced983 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -40,6 +40,7 @@ enum { || x == TDMT_VND_CREATE_TABLE \ || x == TDMT_VND_ALTER_TABLE \ || x == TDMT_VND_DROP_TABLE \ + || x == TDMT_VND_DELETE \ ) // clang-format on diff --git a/include/common/tglobal.h b/include/common/tglobal.h index ac998b807e2c6124c12d36867b268a799e9f2d9d..c07f422557d2622e843fc1ab91b6f4e8b1d11a77 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -41,10 +41,8 @@ extern int32_t tsCompressMsgSize; extern int32_t tsCompressColData; extern int32_t tsMaxNumOfDistinctResults; extern int32_t tsCompatibleModel; -extern bool tsEnableSlaveQuery; extern bool tsPrintAuth; extern int64_t tsTickPerMin[3]; - extern int32_t tsCountAlwaysReturnValue; // multi-process @@ -92,8 +90,6 @@ extern uint16_t tsTelemPort; 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 bool tsRetrieveBlockingModel; // retrieve threads will be blocked -extern bool tsKeepOriginalColumnName; -extern bool tsDeadLockKillQuery; // query client extern int32_t tsQueryPolicy; @@ -102,11 +98,6 @@ extern int32_t tsQuerySmaOptimize; // client extern int32_t tsMinSlidingTime; extern int32_t tsMinIntervalTime; -extern int32_t tsMaxStreamComputDelay; -extern int32_t tsStreamCompStartDelay; -extern int32_t tsRetryStreamCompDelay; -extern float tsStreamComputDelayRatio; // the delayed computing ration of the whole time window -extern int64_t tsMaxRetentWindow; // build info extern char version[]; diff --git a/include/common/tmsg.h b/include/common/tmsg.h index ee19969e5004836f60d84b52aed7ba963e9675b7..5d6d9178ed0ef7abbddae592c4dbb08de4e906ba 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -737,7 +737,7 @@ typedef struct { int32_t daysToKeep2; int32_t minRows; int32_t maxRows; - int32_t fsyncPeriod; + int32_t walFsyncPeriod; int8_t walLevel; int8_t precision; // time resolution int8_t compression; @@ -748,6 +748,10 @@ typedef struct { int8_t ignoreExist; int32_t numOfRetensions; SArray* pRetensions; // SRetention + int32_t walRetentionPeriod; + int64_t walRetentionSize; + int32_t walRollPeriod; + int64_t walSegmentSize; } SCreateDbReq; int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq); @@ -764,7 +768,7 @@ typedef struct { int32_t daysToKeep0; int32_t daysToKeep1; int32_t daysToKeep2; - int32_t fsyncPeriod; + int32_t walFsyncPeriod; int8_t walLevel; int8_t strict; int8_t cacheLast; @@ -855,7 +859,7 @@ typedef struct { int32_t daysToKeep2; int32_t minRows; int32_t maxRows; - int32_t fsyncPeriod; + int32_t walFsyncPeriod; int8_t walLevel; int8_t precision; int8_t compression; @@ -1133,7 +1137,7 @@ typedef struct { int32_t daysToKeep2; int32_t minRows; int32_t maxRows; - int32_t fsyncPeriod; + int32_t walFsyncPeriod; uint32_t hashBegin; uint32_t hashEnd; int8_t hashMethod; @@ -1150,6 +1154,10 @@ typedef struct { int32_t numOfRetensions; SArray* pRetensions; // SRetention void* pTsma; + int32_t walRetentionPeriod; + int64_t walRetentionSize; + int32_t walRollPeriod; + int64_t walSegmentSize; } SCreateVnodeReq; int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq); @@ -1184,7 +1192,7 @@ typedef struct { int32_t daysToKeep0; int32_t daysToKeep1; int32_t daysToKeep2; - int32_t fsyncPeriod; + int32_t walFsyncPeriod; int8_t walLevel; int8_t strict; int8_t cacheLast; @@ -1977,7 +1985,7 @@ typedef struct SVCreateTbReq { union { struct { char* name; // super table name - uint8_t tagNum; + uint8_t tagNum; tb_uid_t suid; SArray* tagName; uint8_t* pTag; @@ -3036,11 +3044,41 @@ typedef struct SDeleteRes { int64_t skey; int64_t ekey; int64_t affectedRows; + char tableFName[TSDB_TABLE_NAME_LEN]; + char tsColName[TSDB_COL_NAME_LEN]; } SDeleteRes; int32_t tEncodeDeleteRes(SEncoder* pCoder, const SDeleteRes* pRes); int32_t tDecodeDeleteRes(SDecoder* pCoder, SDeleteRes* pRes); +typedef struct { + int32_t msgType; + int32_t msgLen; + void* msg; +} SBatchMsg; + +typedef struct { + SMsgHead header; + int32_t msgNum; + SBatchMsg msg[]; +} SBatchReq; + +typedef struct { + int32_t reqType; + int32_t msgLen; + int32_t rspCode; + void* msg; +} SBatchRsp; + +static FORCE_INLINE void tFreeSBatchRsp(void *p) { + if (NULL == p) { + return; + } + + SBatchRsp* pRsp = (SBatchRsp*)p; + taosMemoryFree(pRsp->msg); +} + #pragma pack(pop) #ifdef __cplusplus diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 56e0935ce1318225cb30d97fb614a6a6f672edbe..20dc04631e0aee7ae2d694f8dbe0eb4b048cb17c 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -136,6 +136,7 @@ enum { TD_DEF_MSG_TYPE(TDMT_MND_DROP_INDEX, "drop-index", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_GET_INDEX, "get-index", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_GET_TABLE_INDEX, "get-table-index", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_BATCH_META, "batch-meta", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_TABLE_CFG, "table-cfg", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_CREATE_TOPIC, "create-topic", SMCreateTopicReq, SMCreateTopicRsp) TD_DEF_MSG_TYPE(TDMT_MND_ALTER_TOPIC, "alter-topic", NULL, NULL) @@ -180,6 +181,7 @@ enum { TD_DEF_MSG_TYPE(TDMT_VND_TABLE_META, "vnode-table-meta", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_TABLES_META, "vnode-tables-meta", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_TABLE_CFG, "vnode-table-cfg", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_VND_BATCH_META, "vnode-batch-meta", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_CREATE_STB, "vnode-create-stb", SVCreateStbReq, NULL) TD_DEF_MSG_TYPE(TDMT_VND_ALTER_STB, "vnode-alter-stb", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_DROP_STB, "vnode-drop-stb", SVDropStbReq, NULL) diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 0fce573af985060049f895d2c1ef944d67b37d0f..401cb3214b7598af2ae8e343f0d22d9e8c635a2a 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -16,261 +16,262 @@ #ifndef _TD_COMMON_TOKEN_H_ #define _TD_COMMON_TOKEN_H_ -#define TK_OR 1 -#define TK_AND 2 -#define TK_UNION 3 -#define TK_ALL 4 -#define TK_MINUS 5 -#define TK_EXCEPT 6 -#define TK_INTERSECT 7 -#define TK_NK_BITAND 8 -#define TK_NK_BITOR 9 -#define TK_NK_LSHIFT 10 -#define TK_NK_RSHIFT 11 -#define TK_NK_PLUS 12 -#define TK_NK_MINUS 13 -#define TK_NK_STAR 14 -#define TK_NK_SLASH 15 -#define TK_NK_REM 16 -#define TK_NK_CONCAT 17 -#define TK_CREATE 18 -#define TK_ACCOUNT 19 -#define TK_NK_ID 20 -#define TK_PASS 21 -#define TK_NK_STRING 22 -#define TK_ALTER 23 -#define TK_PPS 24 -#define TK_TSERIES 25 -#define TK_STORAGE 26 -#define TK_STREAMS 27 -#define TK_QTIME 28 -#define TK_DBS 29 -#define TK_USERS 30 -#define TK_CONNS 31 -#define TK_STATE 32 -#define TK_USER 33 -#define TK_ENABLE 34 -#define TK_NK_INTEGER 35 -#define TK_SYSINFO 36 -#define TK_DROP 37 -#define TK_GRANT 38 -#define TK_ON 39 -#define TK_TO 40 -#define TK_REVOKE 41 -#define TK_FROM 42 -#define TK_NK_COMMA 43 -#define TK_READ 44 -#define TK_WRITE 45 -#define TK_NK_DOT 46 -#define TK_DNODE 47 -#define TK_PORT 48 -#define TK_DNODES 49 -#define TK_NK_IPTOKEN 50 -#define TK_LOCAL 51 -#define TK_QNODE 52 -#define TK_BNODE 53 -#define TK_SNODE 54 -#define TK_MNODE 55 -#define TK_DATABASE 56 -#define TK_USE 57 -#define TK_FLUSH 58 -#define TK_TRIM 59 -#define TK_IF 60 -#define TK_NOT 61 -#define TK_EXISTS 62 -#define TK_BUFFER 63 -#define TK_CACHEMODEL 64 -#define TK_CACHESIZE 65 -#define TK_COMP 66 -#define TK_DURATION 67 -#define TK_NK_VARIABLE 68 -#define TK_FSYNC 69 -#define TK_MAXROWS 70 -#define TK_MINROWS 71 -#define TK_KEEP 72 -#define TK_PAGES 73 -#define TK_PAGESIZE 74 -#define TK_PRECISION 75 -#define TK_REPLICA 76 -#define TK_STRICT 77 -#define TK_WAL 78 -#define TK_VGROUPS 79 -#define TK_SINGLE_STABLE 80 -#define TK_RETENTIONS 81 -#define TK_SCHEMALESS 82 -#define TK_NK_COLON 83 -#define TK_TABLE 84 -#define TK_NK_LP 85 -#define TK_NK_RP 86 -#define TK_STABLE 87 -#define TK_ADD 88 -#define TK_COLUMN 89 -#define TK_MODIFY 90 -#define TK_RENAME 91 -#define TK_TAG 92 -#define TK_SET 93 -#define TK_NK_EQ 94 -#define TK_USING 95 -#define TK_TAGS 96 -#define TK_COMMENT 97 -#define TK_BOOL 98 -#define TK_TINYINT 99 -#define TK_SMALLINT 100 -#define TK_INT 101 -#define TK_INTEGER 102 -#define TK_BIGINT 103 -#define TK_FLOAT 104 -#define TK_DOUBLE 105 -#define TK_BINARY 106 -#define TK_TIMESTAMP 107 -#define TK_NCHAR 108 -#define TK_UNSIGNED 109 -#define TK_JSON 110 -#define TK_VARCHAR 111 -#define TK_MEDIUMBLOB 112 -#define TK_BLOB 113 -#define TK_VARBINARY 114 -#define TK_DECIMAL 115 -#define TK_MAX_DELAY 116 -#define TK_WATERMARK 117 -#define TK_ROLLUP 118 -#define TK_TTL 119 -#define TK_SMA 120 -#define TK_FIRST 121 -#define TK_LAST 122 -#define TK_SHOW 123 -#define TK_DATABASES 124 -#define TK_TABLES 125 -#define TK_STABLES 126 -#define TK_MNODES 127 -#define TK_MODULES 128 -#define TK_QNODES 129 -#define TK_FUNCTIONS 130 -#define TK_INDEXES 131 -#define TK_ACCOUNTS 132 -#define TK_APPS 133 -#define TK_CONNECTIONS 134 -#define TK_LICENCE 135 -#define TK_GRANTS 136 -#define TK_QUERIES 137 -#define TK_SCORES 138 -#define TK_TOPICS 139 -#define TK_VARIABLES 140 -#define TK_BNODES 141 -#define TK_SNODES 142 -#define TK_CLUSTER 143 -#define TK_TRANSACTIONS 144 -#define TK_DISTRIBUTED 145 -#define TK_CONSUMERS 146 -#define TK_SUBSCRIPTIONS 147 -#define TK_LIKE 148 -#define TK_INDEX 149 -#define TK_FUNCTION 150 -#define TK_INTERVAL 151 -#define TK_TOPIC 152 -#define TK_AS 153 -#define TK_WITH 154 -#define TK_META 155 -#define TK_CONSUMER 156 -#define TK_GROUP 157 -#define TK_DESC 158 -#define TK_DESCRIBE 159 -#define TK_RESET 160 -#define TK_QUERY 161 -#define TK_CACHE 162 -#define TK_EXPLAIN 163 -#define TK_ANALYZE 164 -#define TK_VERBOSE 165 -#define TK_NK_BOOL 166 -#define TK_RATIO 167 -#define TK_NK_FLOAT 168 -#define TK_COMPACT 169 -#define TK_VNODES 170 -#define TK_IN 171 -#define TK_OUTPUTTYPE 172 -#define TK_AGGREGATE 173 -#define TK_BUFSIZE 174 -#define TK_STREAM 175 -#define TK_INTO 176 -#define TK_TRIGGER 177 -#define TK_AT_ONCE 178 -#define TK_WINDOW_CLOSE 179 -#define TK_IGNORE 180 -#define TK_EXPIRED 181 -#define TK_KILL 182 -#define TK_CONNECTION 183 -#define TK_TRANSACTION 184 -#define TK_BALANCE 185 -#define TK_VGROUP 186 -#define TK_MERGE 187 -#define TK_REDISTRIBUTE 188 -#define TK_SPLIT 189 -#define TK_SYNCDB 190 -#define TK_DELETE 191 -#define TK_INSERT 192 -#define TK_NULL 193 -#define TK_NK_QUESTION 194 -#define TK_NK_ARROW 195 -#define TK_ROWTS 196 -#define TK_TBNAME 197 -#define TK_QSTART 198 -#define TK_QEND 199 -#define TK_QDURATION 200 -#define TK_WSTART 201 -#define TK_WEND 202 -#define TK_WDURATION 203 -#define TK_CAST 204 -#define TK_NOW 205 -#define TK_TODAY 206 -#define TK_TIMEZONE 207 -#define TK_CLIENT_VERSION 208 -#define TK_SERVER_VERSION 209 -#define TK_SERVER_STATUS 210 -#define TK_CURRENT_USER 211 -#define TK_COUNT 212 -#define TK_LAST_ROW 213 -#define TK_BETWEEN 214 -#define TK_IS 215 -#define TK_NK_LT 216 -#define TK_NK_GT 217 -#define TK_NK_LE 218 -#define TK_NK_GE 219 -#define TK_NK_NE 220 -#define TK_MATCH 221 -#define TK_NMATCH 222 -#define TK_CONTAINS 223 -#define TK_JOIN 224 -#define TK_INNER 225 -#define TK_SELECT 226 -#define TK_DISTINCT 227 -#define TK_WHERE 228 -#define TK_PARTITION 229 -#define TK_BY 230 -#define TK_SESSION 231 -#define TK_STATE_WINDOW 232 -#define TK_SLIDING 233 -#define TK_FILL 234 -#define TK_VALUE 235 -#define TK_NONE 236 -#define TK_PREV 237 -#define TK_LINEAR 238 -#define TK_NEXT 239 -#define TK_HAVING 240 -#define TK_RANGE 241 -#define TK_EVERY 242 -#define TK_ORDER 243 -#define TK_SLIMIT 244 -#define TK_SOFFSET 245 -#define TK_LIMIT 246 -#define TK_OFFSET 247 -#define TK_ASC 248 -#define TK_NULLS 249 -#define TK_ID 250 -#define TK_NK_BITNOT 251 -#define TK_VALUES 252 -#define TK_IMPORT 253 -#define TK_NK_SEMI 254 -#define TK_FILE 255 +#define TK_OR 1 +#define TK_AND 2 +#define TK_UNION 3 +#define TK_ALL 4 +#define TK_MINUS 5 +#define TK_EXCEPT 6 +#define TK_INTERSECT 7 +#define TK_NK_BITAND 8 +#define TK_NK_BITOR 9 +#define TK_NK_LSHIFT 10 +#define TK_NK_RSHIFT 11 +#define TK_NK_PLUS 12 +#define TK_NK_MINUS 13 +#define TK_NK_STAR 14 +#define TK_NK_SLASH 15 +#define TK_NK_REM 16 +#define TK_NK_CONCAT 17 +#define TK_CREATE 18 +#define TK_ACCOUNT 19 +#define TK_NK_ID 20 +#define TK_PASS 21 +#define TK_NK_STRING 22 +#define TK_ALTER 23 +#define TK_PPS 24 +#define TK_TSERIES 25 +#define TK_STORAGE 26 +#define TK_STREAMS 27 +#define TK_QTIME 28 +#define TK_DBS 29 +#define TK_USERS 30 +#define TK_CONNS 31 +#define TK_STATE 32 +#define TK_USER 33 +#define TK_ENABLE 34 +#define TK_NK_INTEGER 35 +#define TK_SYSINFO 36 +#define TK_DROP 37 +#define TK_GRANT 38 +#define TK_ON 39 +#define TK_TO 40 +#define TK_REVOKE 41 +#define TK_FROM 42 +#define TK_NK_COMMA 43 +#define TK_READ 44 +#define TK_WRITE 45 +#define TK_NK_DOT 46 +#define TK_DNODE 47 +#define TK_PORT 48 +#define TK_DNODES 49 +#define TK_NK_IPTOKEN 50 +#define TK_LOCAL 51 +#define TK_QNODE 52 +#define TK_BNODE 53 +#define TK_SNODE 54 +#define TK_MNODE 55 +#define TK_DATABASE 56 +#define TK_USE 57 +#define TK_FLUSH 58 +#define TK_TRIM 59 +#define TK_IF 60 +#define TK_NOT 61 +#define TK_EXISTS 62 +#define TK_BUFFER 63 +#define TK_CACHEMODEL 64 +#define TK_CACHESIZE 65 +#define TK_COMP 66 +#define TK_DURATION 67 +#define TK_NK_VARIABLE 68 +#define TK_MAXROWS 69 +#define TK_MINROWS 70 +#define TK_KEEP 71 +#define TK_PAGES 72 +#define TK_PAGESIZE 73 +#define TK_PRECISION 74 +#define TK_REPLICA 75 +#define TK_STRICT 76 +#define TK_VGROUPS 77 +#define TK_SINGLE_STABLE 78 +#define TK_RETENTIONS 79 +#define TK_SCHEMALESS 80 +#define TK_WAL_LEVEL 81 +#define TK_WAL_FSYNC_PERIOD 82 +#define TK_WAL_RETENTION_PERIOD 83 +#define TK_WAL_RETENTION_SIZE 84 +#define TK_WAL_ROLL_PERIOD 85 +#define TK_WAL_SEGMENT_SIZE 86 +#define TK_NK_COLON 87 +#define TK_TABLE 88 +#define TK_NK_LP 89 +#define TK_NK_RP 90 +#define TK_STABLE 91 +#define TK_ADD 92 +#define TK_COLUMN 93 +#define TK_MODIFY 94 +#define TK_RENAME 95 +#define TK_TAG 96 +#define TK_SET 97 +#define TK_NK_EQ 98 +#define TK_USING 99 +#define TK_TAGS 100 +#define TK_COMMENT 101 +#define TK_BOOL 102 +#define TK_TINYINT 103 +#define TK_SMALLINT 104 +#define TK_INT 105 +#define TK_INTEGER 106 +#define TK_BIGINT 107 +#define TK_FLOAT 108 +#define TK_DOUBLE 109 +#define TK_BINARY 110 +#define TK_TIMESTAMP 111 +#define TK_NCHAR 112 +#define TK_UNSIGNED 113 +#define TK_JSON 114 +#define TK_VARCHAR 115 +#define TK_MEDIUMBLOB 116 +#define TK_BLOB 117 +#define TK_VARBINARY 118 +#define TK_DECIMAL 119 +#define TK_MAX_DELAY 120 +#define TK_WATERMARK 121 +#define TK_ROLLUP 122 +#define TK_TTL 123 +#define TK_SMA 124 +#define TK_FIRST 125 +#define TK_LAST 126 +#define TK_SHOW 127 +#define TK_DATABASES 128 +#define TK_TABLES 129 +#define TK_STABLES 130 +#define TK_MNODES 131 +#define TK_MODULES 132 +#define TK_QNODES 133 +#define TK_FUNCTIONS 134 +#define TK_INDEXES 135 +#define TK_ACCOUNTS 136 +#define TK_APPS 137 +#define TK_CONNECTIONS 138 +#define TK_LICENCE 139 +#define TK_GRANTS 140 +#define TK_QUERIES 141 +#define TK_SCORES 142 +#define TK_TOPICS 143 +#define TK_VARIABLES 144 +#define TK_BNODES 145 +#define TK_SNODES 146 +#define TK_CLUSTER 147 +#define TK_TRANSACTIONS 148 +#define TK_DISTRIBUTED 149 +#define TK_CONSUMERS 150 +#define TK_SUBSCRIPTIONS 151 +#define TK_LIKE 152 +#define TK_INDEX 153 +#define TK_FUNCTION 154 +#define TK_INTERVAL 155 +#define TK_TOPIC 156 +#define TK_AS 157 +#define TK_WITH 158 +#define TK_META 159 +#define TK_CONSUMER 160 +#define TK_GROUP 161 +#define TK_DESC 162 +#define TK_DESCRIBE 163 +#define TK_RESET 164 +#define TK_QUERY 165 +#define TK_CACHE 166 +#define TK_EXPLAIN 167 +#define TK_ANALYZE 168 +#define TK_VERBOSE 169 +#define TK_NK_BOOL 170 +#define TK_RATIO 171 +#define TK_NK_FLOAT 172 +#define TK_OUTPUTTYPE 173 +#define TK_AGGREGATE 174 +#define TK_BUFSIZE 175 +#define TK_STREAM 176 +#define TK_INTO 177 +#define TK_TRIGGER 178 +#define TK_AT_ONCE 179 +#define TK_WINDOW_CLOSE 180 +#define TK_IGNORE 181 +#define TK_EXPIRED 182 +#define TK_KILL 183 +#define TK_CONNECTION 184 +#define TK_TRANSACTION 185 +#define TK_BALANCE 186 +#define TK_VGROUP 187 +#define TK_MERGE 188 +#define TK_REDISTRIBUTE 189 +#define TK_SPLIT 190 +#define TK_DELETE 191 +#define TK_INSERT 192 +#define TK_NULL 193 +#define TK_NK_QUESTION 194 +#define TK_NK_ARROW 195 +#define TK_ROWTS 196 +#define TK_TBNAME 197 +#define TK_QSTART 198 +#define TK_QEND 199 +#define TK_QDURATION 200 +#define TK_WSTART 201 +#define TK_WEND 202 +#define TK_WDURATION 203 +#define TK_CAST 204 +#define TK_NOW 205 +#define TK_TODAY 206 +#define TK_TIMEZONE 207 +#define TK_CLIENT_VERSION 208 +#define TK_SERVER_VERSION 209 +#define TK_SERVER_STATUS 210 +#define TK_CURRENT_USER 211 +#define TK_COUNT 212 +#define TK_LAST_ROW 213 +#define TK_BETWEEN 214 +#define TK_IS 215 +#define TK_NK_LT 216 +#define TK_NK_GT 217 +#define TK_NK_LE 218 +#define TK_NK_GE 219 +#define TK_NK_NE 220 +#define TK_MATCH 221 +#define TK_NMATCH 222 +#define TK_CONTAINS 223 +#define TK_IN 224 +#define TK_JOIN 225 +#define TK_INNER 226 +#define TK_SELECT 227 +#define TK_DISTINCT 228 +#define TK_WHERE 229 +#define TK_PARTITION 230 +#define TK_BY 231 +#define TK_SESSION 232 +#define TK_STATE_WINDOW 233 +#define TK_SLIDING 234 +#define TK_FILL 235 +#define TK_VALUE 236 +#define TK_NONE 237 +#define TK_PREV 238 +#define TK_LINEAR 239 +#define TK_NEXT 240 +#define TK_HAVING 241 +#define TK_RANGE 242 +#define TK_EVERY 243 +#define TK_ORDER 244 +#define TK_SLIMIT 245 +#define TK_SOFFSET 246 +#define TK_LIMIT 247 +#define TK_OFFSET 248 +#define TK_ASC 249 +#define TK_NULLS 250 +#define TK_ID 251 +#define TK_NK_BITNOT 252 +#define TK_VALUES 253 +#define TK_IMPORT 254 +#define TK_NK_SEMI 255 +#define TK_FILE 256 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/executor/dataSinkMgt.h b/include/libs/executor/dataSinkMgt.h index 8d5a8abcb4aa595086d5b223e6b8dc028554384f..47177dc11b5669511d92202605c002e34c64d589 100644 --- a/include/libs/executor/dataSinkMgt.h +++ b/include/libs/executor/dataSinkMgt.h @@ -38,6 +38,8 @@ typedef struct SDeleterRes { int64_t skey; int64_t ekey; int64_t affectedRows; + char tableName[TSDB_TABLE_NAME_LEN]; + char tsColName[TSDB_COL_NAME_LEN]; } SDeleterRes; typedef struct SDeleterParam { diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index 65e20336ccf36d1cf3667828729c76efa1edb355..a7fae403edbb608945840da7237080258aa37e1c 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -64,17 +64,7 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers); * @param SReadHandle * @return */ -qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols, - SSchemaWrapper** pSchema); - -/** - * Set the input data block for the stream scan. - * @param tinfo - * @param input - * @param type - * @return - */ -int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input, int32_t type, bool assignUid); +qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols, SSchemaWrapper** pSchema); /** * Set multiple input data blocks for the stream scan. @@ -84,7 +74,7 @@ int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input, int32_t type, bool * @param type * @return */ -int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type, bool assignUid); +int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type); /** * Update the table id list, add or remove. diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 8cb48cc9f05df87c1636ed60c032ddadeac75d8e..8fa63bbd4502a121b0e26a29df948d8f34f77ef1 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -143,6 +143,7 @@ typedef struct SqlFunctionCtx { struct SExprInfo *pExpr; struct SDiskbasedBuf *pBuf; struct SSDataBlock *pSrcBlock; + struct SSDataBlock *pDstBlock; // used by indifinite rows function to set selectivity int32_t curBufPage; bool increase; diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index f1f60cb8e5e39d5c55eac192bca799a04a17b59f..60ad3ba451361fcb0f00c61f03e16ed7999cc0ac 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -209,6 +209,7 @@ typedef enum EFuncDataRequired { } EFuncDataRequired; EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow); +EFuncDataRequired fmFuncDynDataRequired(int32_t funcId, void* pRes, STimeWindow* pTimeWindow); int32_t fmGetFuncExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet); int32_t fmGetScalarFuncExecFuncs(int32_t funcId, SScalarFuncExecFuncs* pFpSet); diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index e13f85002cfe761b9760b9ef8e302984d41d303d..fc1d5245063f400249b99df50b3cc4a853679982 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -74,6 +74,10 @@ typedef struct SDatabaseOptions { int8_t singleStable; SNodeList* pRetentions; int8_t schemaless; + int32_t walRetentionPeriod; + int32_t walRetentionSize; + int32_t walRollPeriod; + int32_t walSegmentSize; } SDatabaseOptions; typedef struct SCreateDatabaseStmt { diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index ba16acf7b00e6e485262c7ae372f5c1977c9cea9..644185a244794f47ec1c8be0ee55822135ed14aa 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -151,7 +151,8 @@ typedef struct SVnodeModifyLogicNode { uint64_t tableId; uint64_t stableId; int8_t tableType; // table type - char tableFName[TSDB_TABLE_FNAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; + char tsColName[TSDB_COL_NAME_LEN]; STimeWindow deleteTimeRange; SVgroupsInfo* pVgroupList; SNodeList* pInsertCols; @@ -328,6 +329,7 @@ typedef struct STableScanPhysiNode { int8_t triggerType; int64_t watermark; int8_t igExpired; + bool assignBlockUid; } STableScanPhysiNode; typedef STableScanPhysiNode STableSeqScanPhysiNode; @@ -493,7 +495,7 @@ typedef struct SQueryInserterNode { uint64_t tableId; uint64_t stableId; int8_t tableType; // table type - char tableFName[TSDB_TABLE_FNAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; int32_t vgId; SEpSet epSet; } SQueryInserterNode; @@ -502,7 +504,8 @@ typedef struct SDataDeleterNode { SDataSinkNode sink; uint64_t tableId; int8_t tableType; // table type - char tableFName[TSDB_TABLE_FNAME_LEN]; + char tableFName[TSDB_TABLE_NAME_LEN]; + char tsColName[TSDB_COL_NAME_LEN]; STimeWindow deleteTimeRange; SNode* pAffectedRows; } SDataDeleterNode; diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 81ed5b5ecd2e1453bcde056b14980b6381c6861c..0600d16d72e14025eb6774f59b729c80c3348361 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -375,6 +375,7 @@ typedef struct SQuery { int8_t precision; SCmdMsgInfo* pCmdMsg; int32_t msgType; + SArray* pTargetTableList; SArray* pTableList; SArray* pDbList; bool showRewrite; diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index cc040594b1d2478fa469d95fbb09b0f0d358b629..b62f822313efee9968d1910cc7835e9181b72b50 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -251,8 +251,8 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t (_code) == TSDB_CODE_APP_NOT_READY || (_code) == TSDB_CODE_RPC_BROKEN_LINK) #define NEED_CLIENT_RM_TBLMETA_REQ(_type) \ - ((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_VND_CREATE_STB || (_type) == TDMT_VND_DROP_TABLE || \ - (_type) == TDMT_VND_DROP_STB) + ((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_MND_CREATE_STB || (_type) == TDMT_VND_DROP_TABLE || \ + (_type) == TDMT_MND_DROP_STB) #define NEED_SCHEDULER_REDIRECT_ERROR(_code) \ ((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_NODE_NOT_DEPLOYED || \ diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index eb83da180352ccfbb9994379b8aec7dd9678df65..240415b66b328d1679b39e7d1077e066d3e59c85 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -55,7 +55,6 @@ enum { TASK_INPUT_STATUS__NORMAL = 1, TASK_INPUT_STATUS__BLOCKED, TASK_INPUT_STATUS__RECOVER, - TASK_INPUT_STATUS__PROCESSING, TASK_INPUT_STATUS__STOP, TASK_INPUT_STATUS__FAILED, }; @@ -171,8 +170,8 @@ typedef struct { } STaskDispatcherFixedEp; typedef struct { - // int8_t hashMethod; char stbFullName[TSDB_TABLE_FNAME_LEN]; + int32_t waitingRspCnt; SUseDbRsp dbInfo; } STaskDispatcherShuffle; @@ -270,7 +269,7 @@ typedef struct SStreamTask { int64_t startVer; int64_t checkpointVer; int64_t processedVer; - int32_t numOfVgroups; + // int32_t numOfVgroups; // children info SArray* childEpInfo; // SArray @@ -320,17 +319,6 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask); void tFreeSStreamTask(SStreamTask* pTask); static FORCE_INLINE int32_t streamTaskInput(SStreamTask* pTask, SStreamQueueItem* pItem) { -#if 0 - while (1) { - int8_t inputStatus = - atomic_val_compare_exchange_8(&pTask->inputStatus, TASK_INPUT_STATUS__NORMAL, TASK_INPUT_STATUS__PROCESSING); - if (inputStatus == TASK_INPUT_STATUS__NORMAL) { - break; - } - ASSERT(0); - } -#endif - if (pItem->type == STREAM_INPUT__DATA_SUBMIT) { SStreamDataSubmit* pSubmitClone = streamSubmitRefClone((SStreamDataSubmit*)pItem); if (pSubmitClone == NULL) { @@ -443,13 +431,14 @@ typedef struct { typedef struct { int64_t streamId; int32_t taskId; - int32_t sourceTaskId; - int32_t sourceVg; + int32_t upstreamTaskId; + int32_t upstreamNodeId; } SStreamTaskRecoverReq; typedef struct { int64_t streamId; - int32_t taskId; + int32_t rspTaskId; + int32_t reqTaskId; int8_t inputStatus; } SStreamTaskRecoverRsp; diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index d767b3521eddb8a57d8bb0d27c4d73abd484afd8..aec8a1f73e3d5d8f6c78539c38adb6ace6ad6492 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -210,7 +210,7 @@ SyncGroupId syncGetVgId(int64_t rid); void syncGetEpSet(int64_t rid, SEpSet* pEpSet); void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet); int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak); -int32_t syncProposeBatch(int64_t rid, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize); +int32_t syncProposeBatch(int64_t rid, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize); bool syncEnvIsStart(); const char* syncStr(ESyncState state); bool syncIsRestoreFinish(int64_t rid); diff --git a/include/libs/sync/syncTools.h b/include/libs/sync/syncTools.h index 7e956237401bed6140201ff84427e9cda2aa9e8b..cd2c2d4a4f8b708246786fa1ea0cf030d5799593 100644 --- a/include/libs/sync/syncTools.h +++ b/include/libs/sync/syncTools.h @@ -238,7 +238,7 @@ typedef struct SyncClientRequestBatch { char data[]; // block2, block3 } SyncClientRequestBatch; -SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg* rpcMsgArr, SRaftMeta* raftArr, int32_t arrSize, +SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg** rpcMsgPArr, SRaftMeta* raftArr, int32_t arrSize, int32_t vgId); void syncClientRequestBatch2RpcMsg(const SyncClientRequestBatch* pSyncMsg, SRpcMsg* pRpcMsg); void syncClientRequestBatchDestroy(SyncClientRequestBatch* pMsg); diff --git a/include/libs/wal/wal.h b/include/libs/wal/wal.h index 220c4f73e0867b9ca71ef4adb2a3c9d5ac9ffa21..14173690967ffd26be92cf13a05af6f7508533fe 100644 --- a/include/libs/wal/wal.h +++ b/include/libs/wal/wal.h @@ -77,11 +77,11 @@ typedef struct { } SWalSyncInfo; typedef struct { - int8_t protoVer; int64_t version; - int16_t msgType; + int64_t ingestTs; int32_t bodyLen; - int64_t ingestTs; // not implemented + int16_t msgType; + int8_t protoVer; // sync meta SWalSyncInfo syncMeta; @@ -103,8 +103,8 @@ typedef struct SWal { int32_t fsyncSeq; // meta SWalVer vers; - TdFilePtr pWriteLogTFile; - TdFilePtr pWriteIdxTFile; + TdFilePtr pLogFile; + TdFilePtr pIdxFile; int32_t writeCur; SArray *fileInfoSet; // SArray // status diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 4f4d0001343cf1d5fdccec695c74abac28ef3d35..3493cbb3a39fe007e04cbe2e1592e9de020c1252 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -192,6 +192,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_NO_USER_FROM_CONN TAOS_DEF_ERROR_CODE(0, 0x0354) #define TSDB_CODE_MND_TOO_MANY_USERS TAOS_DEF_ERROR_CODE(0, 0x0355) #define TSDB_CODE_MND_INVALID_ALTER_OPER TAOS_DEF_ERROR_CODE(0, 0x0356) +#define TSDB_CODE_MND_AUTH_FAILURE TAOS_DEF_ERROR_CODE(0, 0x0357) // mnode-stable-part1 #define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360) @@ -512,7 +513,6 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_ONLY_ONE_JSON_TAG TAOS_DEF_ERROR_CODE(0, 0x2633) #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_INVALID_DAYS_VALUE TAOS_DEF_ERROR_CODE(0, 0x2636) #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_INVALID_TOPIC_QUERY TAOS_DEF_ERROR_CODE(0, 0x2639) diff --git a/include/util/tdef.h b/include/util/tdef.h index 688fe5fe85fb5ab8e29daea26531e5979eca8772..6d893765fcfb77b520ee2067a86e7ec28c1537ab 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -358,6 +358,15 @@ typedef enum ELogicConditionType { #define TSDB_DB_SCHEMALESS_OFF 0 #define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF +#define TSDB_DB_MIN_WAL_RETENTION_PERIOD -1 +#define TSDB_DEFAULT_DB_WAL_RETENTION_PERIOD 0 +#define TSDB_DB_MIN_WAL_RETENTION_SIZE -1 +#define TSDB_DEFAULT_DB_WAL_RETENTION_SIZE 0 +#define TSDB_DB_MIN_WAL_ROLL_PERIOD 0 +#define TSDB_DEFAULT_DB_WAL_ROLL_PERIOD 0 +#define TSDB_DB_MIN_WAL_SEGMENT_SIZE 0 +#define TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE 0 + #define TSDB_MIN_ROLLUP_MAX_DELAY 1 // unit millisecond #define TSDB_MAX_ROLLUP_MAX_DELAY (15 * 60 * 1000) #define TSDB_MIN_ROLLUP_WATERMARK 0 // unit millisecond diff --git a/include/util/tlog.h b/include/util/tlog.h index 76d04a5997f1247d830e435bd2a2b1058fc0f0ec..68b004cda74f158791d38decf73346425bf44de9 100644 --- a/include/util/tlog.h +++ b/include/util/tlog.h @@ -63,6 +63,7 @@ extern int32_t metaDebugFlag; extern int32_t udfDebugFlag; extern int32_t smaDebugFlag; extern int32_t idxDebugFlag; +extern int32_t tdbDebugFlag; int32_t taosInitLog(const char *logName, int32_t maxFiles); void taosCloseLog(); diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 779fa681404434612332387d80beaace4c17e6ef..b4c0fd380e485d47520ca71213cdd046f8e1ca4f 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -222,6 +222,7 @@ typedef struct SRequestObj { int32_t code; SArray* dbList; SArray* tableList; + SArray* targetTableList; SQueryExecMetric metric; SRequestSendRecvBody body; bool syncQuery; // todo refactor: async query object diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 03238e6747c71bae8c9286a9ad87010a21c4d843..68f47ba9152894293745be6eee05fecaf31f44a7 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -235,6 +235,7 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC if (TSDB_CODE_SUCCESS == code || NEED_CLIENT_HANDLE_ERROR(code)) { TSWAP(pRequest->dbList, (*pQuery)->pDbList); TSWAP(pRequest->tableList, (*pQuery)->pTableList); + TSWAP(pRequest->targetTableList, (*pQuery)->pTargetTableList); } return code; @@ -851,7 +852,7 @@ void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) { tscDebug("schedulerExecCb request type %s", TMSG_INFO(pRequest->type)); if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type)) { - removeMeta(pTscObj, pRequest->tableList); + removeMeta(pTscObj, pRequest->targetTableList); } // return to client @@ -1094,7 +1095,7 @@ SRequestObj* execQuery(uint64_t connId, const char* sql, int sqlLen, bool valida } while (retryNum++ < REQUEST_TOTAL_EXEC_TIMES); if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type)) { - removeMeta(pRequest->pTscObj, pRequest->tableList); + removeMeta(pRequest->pTscObj, pRequest->targetTableList); } return pRequest; @@ -2019,7 +2020,7 @@ int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, } if (('a' <= *(tbList + i) && 'z' >= *(tbList + i)) || ('A' <= *(tbList + i) && 'Z' >= *(tbList + i)) || - ('0' <= *(tbList + i) && '9' >= *(tbList + i))) { + ('0' <= *(tbList + i) && '9' >= *(tbList + i)) || ('_' == *(tbList + i))) { if (vLen[vIdx] > 0) { goto _return; } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 77b31011a3d0109045154d72cda8bc1a4af65f6a..b04b4ea2aa771c63883d6668f3f7d5a9f8778add 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -687,6 +687,7 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) { TSWAP(pRequest->dbList, (pQuery)->pDbList); TSWAP(pRequest->tableList, (pQuery)->pTableList); + TSWAP(pRequest->targetTableList, (pQuery)->pTargetTableList); destorySqlParseWrapper(pWrapper); @@ -973,7 +974,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { conn.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp); - code = catalogAsyncGetAllMeta(pCtg, &conn, &catalogReq, syncCatalogFn, NULL, NULL); + code = catalogAsyncGetAllMeta(pCtg, &conn, &catalogReq, syncCatalogFn, pRequest->body.param, NULL); if (code) { goto _return; } diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index 70edb32f2d54e7b95a534da971c637245b0b2512..fa21f82d190569e1c6eb3b2642aeb7b63d4b66f9 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -693,6 +693,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) { TSWAP(pStmt->exec.pRequest->dbList, pStmt->sql.pQuery->pDbList); TSWAP(pStmt->exec.pRequest->tableList, pStmt->sql.pQuery->pTableList); + TSWAP(pStmt->exec.pRequest->targetTableList, pStmt->sql.pQuery->pTargetTableList); // if (STMT_TYPE_QUERY == pStmt->sql.queryRes) { // STMT_ERR_RET(stmtRestoreQueryFields(pStmt)); diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 74d5d4270b9e8ba6fa9f5cc549a69ec62e628347..88ebb099e5469d64ca6caf31b9cc60e42694e67a 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -1206,6 +1206,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { SDecoder decoder; tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead)); tDecodeSMqDataRsp(&decoder, &pRspWrapper->dataRsp); + tDecoderClear(&decoder); memcpy(&pRspWrapper->dataRsp, pMsg->pData, sizeof(SMqRspHead)); } else { ASSERT(rspType == TMQ_MSG_TYPE__POLL_META_RSP); @@ -1859,6 +1860,10 @@ tmq_res_t tmq_get_res_type(TAOS_RES* res) { if (TD_RES_TMQ(res)) { return TMQ_RES_DATA; } else if (TD_RES_TMQ_META(res)) { + SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; + if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DELETE) { + return TMQ_RES_DATA; + } return TMQ_RES_TABLE_META; } else { return TMQ_RES_INVALID; @@ -1913,17 +1918,6 @@ const char* tmq_get_table_name(TAOS_RES* res) { return NULL; } -int32_t tmq_get_raw_meta(TAOS_RES* res, tmq_raw_data *raw) { - if (TD_RES_TMQ_META(res) && raw) { - SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; - raw->raw_meta = pMetaRspObj->metaRsp.metaRsp; - raw->raw_meta_len = pMetaRspObj->metaRsp.metaRspLen; - raw->raw_meta_type = pMetaRspObj->metaRsp.resMsgType; - return TSDB_CODE_SUCCESS; - } - return TSDB_CODE_INVALID_PARA; -} - static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* schemaTag, char* name, int64_t id, int8_t t) { char* string = NULL; @@ -2436,30 +2430,6 @@ _exit: return string; } -char* tmq_get_json_meta(TAOS_RES* res) { - if (!TD_RES_TMQ_META(res)) { - return NULL; - } - - SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; - if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_CREATE_STB) { - return processCreateStb(&pMetaRspObj->metaRsp); - } else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_ALTER_STB) { - return processAlterStb(&pMetaRspObj->metaRsp); - } else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DROP_STB) { - return processDropSTable(&pMetaRspObj->metaRsp); - } else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_CREATE_TABLE) { - return processCreateTable(&pMetaRspObj->metaRsp); - } else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_ALTER_TABLE) { - return processAlterTable(&pMetaRspObj->metaRsp); - } else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DROP_TABLE) { - return processDropTable(&pMetaRspObj->metaRsp); - } - return NULL; -} - -void tmq_free_json_meta(char* jsonMeta) { taosMemoryFreeClear(jsonMeta); } - static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) { SVCreateStbReq req = {0}; SDecoder coder; @@ -2531,6 +2501,13 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) { pQuery.stableQuery = true; launchQueryImpl(pRequest, &pQuery, true, NULL); + + if(pRequest->code == TSDB_CODE_SUCCESS){ + SCatalog* pCatalog = NULL; + catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog); + catalogRemoveTableMeta(pCatalog, &tableName); + } + code = pRequest->code; taosMemoryFree(pCmdMsg.pMsg); @@ -2572,7 +2549,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { pReq.suid = req.suid; STscObj* pTscObj = pRequest->pTscObj; - SName tableName; + SName tableName = {0}; tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name); SCmdMsgInfo pCmdMsg = {0}; @@ -2593,6 +2570,13 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { pQuery.stableQuery = true; launchQueryImpl(pRequest, &pQuery, true, NULL); + + if(pRequest->code == TSDB_CODE_SUCCESS){ + SCatalog* pCatalog = NULL; + catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog); + catalogRemoveTableMeta(pCatalog, &tableName); + } + code = pRequest->code; taosMemoryFree(pCmdMsg.pMsg); @@ -2659,17 +2643,20 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { .requestId = pRequest->requestId, .requestObjRefId = pRequest->self, .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; + + pRequest->tableList = taosArrayInit(req.nReqs, sizeof(SName)); // loop to create table for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pCreateReq = req.pReqs + iReq; SVgroupInfo pInfo = {0}; - SName pName; + SName pName = {0}; toName(pTscObj->acctId, pRequest->pDb, pCreateReq->name, &pName); code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &pInfo); if (code != TSDB_CODE_SUCCESS) { goto end; } + taosArrayPush(pRequest->tableList, &pName); SVgroupCreateTableBatch* pTableBatch = taosHashGet(pVgroupHashmap, &pInfo.vgId, sizeof(pInfo.vgId)); if (pTableBatch == NULL) { @@ -2703,8 +2690,11 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { goto end; } - launchQueryImpl(pRequest, pQuery, false, NULL); - pQuery = NULL; // no need to free in the end + launchQueryImpl(pRequest, pQuery, true, NULL); + if (pRequest->code == TSDB_CODE_SUCCESS){ + removeMeta(pTscObj, pRequest->tableList); + } + code = pRequest->code; end: @@ -2772,19 +2762,21 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { .requestId = pRequest->requestId, .requestObjRefId = pRequest->self, .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; + pRequest->tableList = taosArrayInit(req.nReqs, sizeof(SName)); // loop to create table for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pDropReq = req.pReqs + iReq; pDropReq->igNotExists = true; SVgroupInfo pInfo = {0}; - SName pName; + SName pName = {0}; toName(pTscObj->acctId, pRequest->pDb, pDropReq->name, &pName); code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &pInfo); if (code != TSDB_CODE_SUCCESS) { goto end; } + taosArrayPush(pRequest->tableList, &pName); SVgroupDropTableBatch* pTableBatch = taosHashGet(pVgroupHashmap, &pInfo.vgId, sizeof(pInfo.vgId)); if (pTableBatch == NULL) { SVgroupDropTableBatch tBatch = {0}; @@ -2815,8 +2807,10 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { goto end; } - launchQueryImpl(pRequest, pQuery, false, NULL); - pQuery = NULL; // no need to free in the end + launchQueryImpl(pRequest, pQuery, true, NULL); + if (pRequest->code == TSDB_CODE_SUCCESS){ + removeMeta(pTscObj, pRequest->tableList); + } code = pRequest->code; end: @@ -2827,6 +2821,70 @@ end: return code; } +// delete from db.tabl where .. -> delete from tabl where .. +// delete from db .tabl where .. -> delete from tabl where .. +//static void getTbName(char *sql){ +// char *ch = sql; +// +// bool inBackQuote = false; +// int8_t dotIndex = 0; +// while(*ch != '\0'){ +// if(!inBackQuote && *ch == '`'){ +// inBackQuote = true; +// ch++; +// continue; +// } +// +// if(inBackQuote && *ch == '`'){ +// inBackQuote = false; +// ch++; +// +// continue; +// } +// +// if(!inBackQuote && *ch == '.'){ +// dotIndex ++; +// if(dotIndex == 2){ +// memmove(sql, ch + 1, strlen(ch + 1) + 1); +// break; +// } +// } +// ch++; +// } +//} + +static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) { + SDeleteRes req = {0}; + SDecoder coder = {0}; + int32_t code = TSDB_CODE_SUCCESS; + + // decode and process req + void* data = POINTER_SHIFT(meta, sizeof(SMsgHead)); + int32_t len = metaLen - sizeof(SMsgHead); + tDecoderInit(&coder, data, len); + if (tDecodeDeleteRes(&coder, &req) < 0) { + code = TSDB_CODE_INVALID_PARA; + goto end; + } + +// getTbName(req.tableFName); + char sql[256] = {0}; + sprintf(sql, "delete from `%s` where `%s` >= %" PRId64" and `%s` <= %" PRId64, req.tableFName, req.tsColName, req.skey, req.tsColName, req.ekey); + printf("delete sql:%s\n", sql); + + TAOS_RES* res = taos_query(taos, sql); + SRequestObj *pRequest = (SRequestObj *)res; + code = pRequest->code; + if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { + code = TSDB_CODE_SUCCESS; + } + taos_free_result(res); + +end: + tDecoderClear(&coder); + return code; +} + static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) { SVAlterTbReq req = {0}; SDecoder coder = {0}; @@ -2914,15 +2972,21 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) { goto end; } - launchQueryImpl(pRequest, pQuery, false, NULL); - pQuery = NULL; // no need to free in the end + launchQueryImpl(pRequest, pQuery, true, NULL); + pVgData = NULL; pArray = NULL; code = pRequest->code; if (code == TSDB_CODE_VND_TABLE_NOT_EXIST) { - code = 0; + code = TSDB_CODE_SUCCESS; } + if(pRequest->code == TSDB_CODE_SUCCESS){ + SExecResult* pRes = &pRequest->body.resInfo.execRes; + if(pRes->res != NULL){ + code = handleAlterTbExecRes(pRes->res, pCatalog); + } + } end: taosArrayDestroy(pArray); if (pVgData) taosMemoryFreeClear(pVgData->pData); @@ -2933,27 +2997,6 @@ end: return code; } -int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data raw_meta){ - if (!taos) { - return TSDB_CODE_INVALID_PARA; - } - - if(raw_meta.raw_meta_type == TDMT_VND_CREATE_STB) { - return taosCreateStb(taos, raw_meta.raw_meta, raw_meta.raw_meta_len); - }else if(raw_meta.raw_meta_type == TDMT_VND_ALTER_STB){ - return taosCreateStb(taos, raw_meta.raw_meta, raw_meta.raw_meta_len); - }else if(raw_meta.raw_meta_type == TDMT_VND_DROP_STB){ - return taosDropStb(taos, raw_meta.raw_meta, raw_meta.raw_meta_len); - }else if(raw_meta.raw_meta_type == TDMT_VND_CREATE_TABLE){ - return taosCreateTable(taos, raw_meta.raw_meta, raw_meta.raw_meta_len); - }else if(raw_meta.raw_meta_type == TDMT_VND_ALTER_TABLE){ - return taosAlterTable(taos, raw_meta.raw_meta, raw_meta.raw_meta_len); - }else if(raw_meta.raw_meta_type == TDMT_VND_DROP_TABLE){ - return taosDropTable(taos, raw_meta.raw_meta, raw_meta.raw_meta_len); - } - return TSDB_CODE_INVALID_PARA; -} - typedef struct{ SVgroupInfo vg; void *data; @@ -2964,15 +3007,196 @@ static void destroyVgHash(void* data) { taosMemoryFreeClear(vgData->data); } -int32_t taos_write_raw_data(TAOS *taos, TAOS_RES *msg){ - if (!TD_RES_TMQ(msg)) { - uError("WriteRaw:msg is not tmq : %d", *(int8_t*)msg); - return TSDB_CODE_TMQ_INVALID_MSG; +int taos_write_raw_block(TAOS *taos, int rows, char *pData, const char* tbname){ + int32_t code = TSDB_CODE_SUCCESS; + STableMeta* pTableMeta = NULL; + SQuery *pQuery = NULL; + + SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT); + if(!pRequest){ + uError("WriteRaw:createRequest error request is null"); + code = terrno; + goto end; } + if (!pRequest->pDb) { + uError("WriteRaw:not use db"); + code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; + goto end; + } + + SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}}; + strcpy(pName.dbname, pRequest->pDb); + strcpy(pName.tname, tbname); + + struct SCatalog *pCatalog = NULL; + code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); + if(code != TSDB_CODE_SUCCESS){ + uError("WriteRaw: get gatlog error"); + goto end; + } + + SRequestConnInfo conn = {0}; + conn.pTrans = pRequest->pTscObj->pAppInfo->pTransporter; + conn.requestId = pRequest->requestId; + conn.requestObjRefId = pRequest->self; + conn.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp); + + SVgroupInfo vgData = {0}; + code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vgData); + if (code != TSDB_CODE_SUCCESS) { + uError("WriteRaw:catalogGetTableHashVgroup failed. table name: %s", tbname); + goto end; + } + + code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta); + if (code != TSDB_CODE_SUCCESS) { + uError("WriteRaw:catalogGetTableMeta failed. table name: %s", tbname); + goto end; + } + uint64_t suid = (TSDB_NORMAL_TABLE == pTableMeta->tableType ? 0 : pTableMeta->suid); + uint64_t uid = pTableMeta->uid; + int32_t numOfCols = pTableMeta->tableInfo.numOfColumns; + + uint16_t fLen = 0; + int32_t rowSize = 0; + int16_t nVar = 0; + for (int i = 0; i < numOfCols; i++) { + SSchema *schema = pTableMeta->schema + i; + fLen += TYPE_BYTES[schema->type]; + rowSize += schema->bytes; + if(IS_VAR_DATA_TYPE(schema->type)){ + nVar ++; + } + } + + int32_t extendedRowSize = rowSize + TD_ROW_HEAD_LEN - sizeof(TSKEY) + nVar * sizeof(VarDataOffsetT) + + (int32_t)TD_BITMAP_BYTES(numOfCols - 1); + int32_t schemaLen = 0; + int32_t submitLen = sizeof(SSubmitBlk) + schemaLen + rows * extendedRowSize; + + int32_t totalLen = sizeof(SSubmitReq) + submitLen; + SSubmitReq* subReq = taosMemoryCalloc(1, totalLen); + SSubmitBlk* blk = POINTER_SHIFT(subReq, sizeof(SSubmitReq)); + void* blkSchema = POINTER_SHIFT(blk, sizeof(SSubmitBlk)); + STSRow* rowData = POINTER_SHIFT(blkSchema, schemaLen); + + SRowBuilder rb = {0}; + tdSRowInit(&rb, pTableMeta->sversion); + tdSRowSetTpInfo(&rb, numOfCols, fLen); + int32_t dataLen = 0; + + char* pStart = pData + sizeof(int32_t) + sizeof(uint64_t) + numOfCols * (sizeof(int16_t) + sizeof(int32_t)); + int32_t* colLength = (int32_t*)pStart; + pStart += sizeof(int32_t) * numOfCols; + + SResultColumn *pCol = taosMemoryCalloc(numOfCols, sizeof(SResultColumn)); + + for (int32_t i = 0; i < numOfCols; ++i) { + if (IS_VAR_DATA_TYPE(pTableMeta->schema[i].type)) { + pCol[i].offset = (int32_t*)pStart; + pStart += rows * sizeof(int32_t); + } else { + pCol[i].nullbitmap = pStart; + pStart += BitmapLen(rows); + } + + pCol[i].pData = pStart; + pStart += colLength[i]; + } + + for (int32_t j = 0; j < rows; j++) { + tdSRowResetBuf(&rb, rowData); + int32_t offset = 0; + for (int32_t k = 0; k < numOfCols; k++) { + const SSchema* pColumn = &pTableMeta->schema[k]; + + if (IS_VAR_DATA_TYPE(pColumn->type)) { + if (pCol[k].offset[j] != -1) { + char* data = pCol[k].pData + pCol[k].offset[j]; + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, offset, k); + } else { + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, offset, k); + } + } else { + if (!colDataIsNull_f(pCol[k].nullbitmap, j)) { + char* data = pCol[k].pData + pColumn->bytes * j; + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, offset, k); + } else { + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, offset, k); + } + } + + offset += TYPE_BYTES[pColumn->type]; + } + int32_t rowLen = TD_ROW_LEN(rowData); + rowData = POINTER_SHIFT(rowData, rowLen); + dataLen += rowLen; + } + + taosMemoryFree(pCol); + + blk->uid = htobe64(uid); + blk->suid = htobe64(suid); + blk->padding = htonl(blk->padding); + blk->sversion = htonl(pTableMeta->sversion); + blk->schemaLen = htonl(schemaLen); + blk->numOfRows = htons(rows); + blk->dataLen = htonl(dataLen); + subReq->length = sizeof(SSubmitReq) + sizeof(SSubmitBlk) + schemaLen + dataLen; + subReq->numOfBlocks = 1; + + pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); + if (NULL == pQuery) { + uError("create SQuery error"); + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE; + pQuery->haveResultSet = false; + pQuery->msgType = TDMT_VND_SUBMIT; + pQuery->pRoot = (SNode *)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT); + if (NULL == pQuery->pRoot) { + uError("create pQuery->pRoot error"); + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + SVnodeModifOpStmt *nodeStmt = (SVnodeModifOpStmt *)(pQuery->pRoot); + nodeStmt->payloadType = PAYLOAD_TYPE_KV; + nodeStmt->pDataBlocks = taosArrayInit(1, POINTER_BYTES); + + SVgDataBlocks *dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); + if (NULL == dst) { + code = TSDB_CODE_TSC_OUT_OF_MEMORY; + goto end; + } + dst->vg = vgData; + dst->numOfTables = subReq->numOfBlocks; + dst->size = subReq->length; + dst->pData = (char*)subReq; + subReq->header.vgId = htonl(dst->vg.vgId); + subReq->version = htonl(1); + subReq->header.contLen = htonl(subReq->length); + subReq->length = htonl(subReq->length); + subReq->numOfBlocks = htonl(subReq->numOfBlocks); + subReq = NULL; // no need free + taosArrayPush(nodeStmt->pDataBlocks, &dst); + + launchQueryImpl(pRequest, pQuery, true, NULL); + code = pRequest->code; + +end: + taosMemoryFreeClear(pTableMeta); + qDestroyQuery(pQuery); + return code; +} + +static int32_t tmqWriteRaw(TAOS *taos, void* data, int32_t dataLen){ int32_t code = TSDB_CODE_SUCCESS; SHashObj *pVgHash = NULL; SQuery *pQuery = NULL; + SMqRspObj rspObj = {0}; + SDecoder decoder = {0}; terrno = TSDB_CODE_SUCCESS; SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT); @@ -2981,6 +3205,17 @@ int32_t taos_write_raw_data(TAOS *taos, TAOS_RES *msg){ return terrno; } + rspObj.resIter = -1; + rspObj.resType = RES_TYPE__TMQ; + + tDecoderInit(&decoder, data, dataLen); + code = tDecodeSMqDataRsp(&decoder, &rspObj.rsp); + if (code != 0){ + uError("WriteRaw:decode smqDataRsp error"); + code = TSDB_CODE_INVALID_MSG; + goto end; + } + if (!pRequest->pDb) { uError("WriteRaw:not use db"); code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; @@ -3001,18 +3236,18 @@ int32_t taos_write_raw_data(TAOS *taos, TAOS_RES *msg){ conn.requestId = pRequest->requestId; conn.requestObjRefId = pRequest->self; conn.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp); - SMqRspObj *rspObj = ((SMqRspObj*)msg); - printf("raw data block num:%d\n", rspObj->rsp.blockNum); - while (++rspObj->resIter < rspObj->rsp.blockNum) { - SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj->rsp.blockData, rspObj->resIter); - if (!rspObj->rsp.withSchema) { - uError("WriteRaw:no schema, iter:%d", rspObj->resIter); + + printf("raw data block num:%d\n", rspObj.rsp.blockNum); + while (++rspObj.resIter < rspObj.rsp.blockNum) { + SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter); + if (!rspObj.rsp.withSchema) { + uError("WriteRaw:no schema, iter:%d", rspObj.resIter); goto end; } - SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj->rsp.blockSchema, rspObj->resIter); - setResSchemaInfo(&rspObj->resInfo, pSW->pSchema, pSW->nCols); + SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.blockSchema, rspObj.resIter); + setResSchemaInfo(&rspObj.resInfo, pSW->pSchema, pSW->nCols); - code = setQueryResultFromRsp(&rspObj->resInfo, pRetrieve, false, false); + code = setQueryResultFromRsp(&rspObj.resInfo, pRetrieve, false, false); if(code != TSDB_CODE_SUCCESS){ uError("WriteRaw: setQueryResultFromRsp error"); goto end; @@ -3030,13 +3265,13 @@ int32_t taos_write_raw_data(TAOS *taos, TAOS_RES *msg){ } } - int32_t rows = rspObj->resInfo.numOfRows; + int32_t rows = rspObj.resInfo.numOfRows; int32_t extendedRowSize = rowSize + TD_ROW_HEAD_LEN - sizeof(TSKEY) + nVar * sizeof(VarDataOffsetT) + (int32_t)TD_BITMAP_BYTES(pSW->nCols - 1); int32_t schemaLen = 0; int32_t submitLen = sizeof(SSubmitBlk) + schemaLen + rows * extendedRowSize; - const char* tbName = tmq_get_table_name(msg); + const char* tbName = (const char*)taosArrayGetP(rspObj.rsp.blockTbName, rspObj.resIter); if(!tbName){ uError("WriteRaw: tbname is null"); code = TSDB_CODE_TMQ_INVALID_MSG; @@ -3108,13 +3343,13 @@ int32_t taos_write_raw_data(TAOS *taos, TAOS_RES *msg){ for (int32_t j = 0; j < rows; j++) { tdSRowResetBuf(&rb, rowData); - doSetOneRowPtr(&rspObj->resInfo); - rspObj->resInfo.current += 1; + doSetOneRowPtr(&rspObj.resInfo); + rspObj.resInfo.current += 1; int32_t offset = 0; for (int32_t k = 0; k < pSW->nCols; k++) { const SSchema* pColumn = &pSW->pSchema[k]; - char *data = rspObj->resInfo.row[k]; + char *data = rspObj.resInfo.row[k]; if (!data) { tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, offset, k); } else { @@ -3186,13 +3421,105 @@ int32_t taos_write_raw_data(TAOS *taos, TAOS_RES *msg){ launchQueryImpl(pRequest, pQuery, true, NULL); code = pRequest->code; + end: + tDecoderClear(&decoder); + taos_free_result(&rspObj); qDestroyQuery(pQuery); destroyRequest(pRequest); taosHashCleanup(pVgHash); return code; } +char* tmq_get_json_meta(TAOS_RES* res) { + if (!TD_RES_TMQ_META(res)) { + return NULL; + } + + SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; + if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_CREATE_STB) { + return processCreateStb(&pMetaRspObj->metaRsp); + } else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_ALTER_STB) { + return processAlterStb(&pMetaRspObj->metaRsp); + } else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DROP_STB) { + return processDropSTable(&pMetaRspObj->metaRsp); + } else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_CREATE_TABLE) { + return processCreateTable(&pMetaRspObj->metaRsp); + } else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_ALTER_TABLE) { + return processAlterTable(&pMetaRspObj->metaRsp); + } else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DROP_TABLE) { + return processDropTable(&pMetaRspObj->metaRsp); + } + return NULL; +} + +void tmq_free_json_meta(char* jsonMeta) { taosMemoryFreeClear(jsonMeta); } + +int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data *raw) { + if (!raw || !res){ + return TSDB_CODE_INVALID_PARA; + } + if (TD_RES_TMQ_META(res)) { + SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; + raw->raw = pMetaRspObj->metaRsp.metaRsp; + raw->raw_len = pMetaRspObj->metaRsp.metaRspLen; + raw->raw_type = pMetaRspObj->metaRsp.resMsgType; + } else if(TD_RES_TMQ(res)){ + SMqRspObj *rspObj = ((SMqRspObj*)res); + + int32_t len = 0; + int32_t code = 0; + tEncodeSize(tEncodeSMqDataRsp, &rspObj->rsp, len, code); + if (code < 0) { + return -1; + } + + void *buf = taosMemoryCalloc(1, len); + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, len); + tEncodeSMqDataRsp(&encoder, &rspObj->rsp); + tEncoderClear(&encoder); + + raw->raw = buf; + raw->raw_len = len; + raw->raw_type = RES_TYPE__TMQ; + } else { + return TSDB_CODE_TMQ_INVALID_MSG; + } + return TSDB_CODE_SUCCESS; +} + +void tmq_free_raw(tmq_raw_data raw) { + if (raw.raw_type == RES_TYPE__TMQ){ + taosMemoryFree(raw.raw); + } +} + +int32_t tmq_write_raw(TAOS *taos, tmq_raw_data raw){ + if (!taos) { + return TSDB_CODE_INVALID_PARA; + } + + if(raw.raw_type == TDMT_VND_CREATE_STB) { + return taosCreateStb(taos, raw.raw, raw.raw_len); + }else if(raw.raw_type == TDMT_VND_ALTER_STB){ + return taosCreateStb(taos, raw.raw, raw.raw_len); + }else if(raw.raw_type == TDMT_VND_DROP_STB){ + return taosDropStb(taos, raw.raw, raw.raw_len); + }else if(raw.raw_type == TDMT_VND_CREATE_TABLE){ + return taosCreateTable(taos, raw.raw, raw.raw_len); + }else if(raw.raw_type == TDMT_VND_ALTER_TABLE){ + return taosAlterTable(taos, raw.raw, raw.raw_len); + }else if(raw.raw_type == TDMT_VND_DROP_TABLE) { + return taosDropTable(taos, raw.raw, raw.raw_len); + }else if(raw.raw_type == TDMT_VND_DELETE){ + return taosDeleteData(taos, raw.raw, raw.raw_len); + }else if(raw.raw_type == RES_TYPE__TMQ){ + return tmqWriteRaw(taos, raw.raw, raw.raw_len); + } + return TSDB_CODE_INVALID_PARA; +} + void tmq_commit_async(tmq_t* tmq, const TAOS_RES* msg, tmq_commit_cb* cb, void* param) { // tmqCommitInner2(tmq, msg, 0, 1, cb, param); diff --git a/source/common/src/systable.c b/source/common/src/systable.c index bae00bbd57864548129b11408c04bff6b0134430..7d07946dc96632d32447228aa196fcd2829d0514 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -84,17 +84,19 @@ static const SSysDbTableSchema userDBSchema[] = { {.name = "pages", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "minrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "maxrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - {.name = "wal", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, - {.name = "fsync", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, - {.name = "cacheModel", .bytes = TSDB_CACHE_MODEL_STR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, - {.name = "single_stable", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL}, {.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, - // {.name = "schemaless", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL}, {.name = "retention", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, - - // {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update + {.name = "single_stable", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL}, + {.name = "cachemodel", .bytes = TSDB_CACHE_MODEL_STR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "cachesize", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "wal_level", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, + {.name = "wal_fsync_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "wal_retention_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "wal_retention_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, + {.name = "wal_roll_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "wal_seg_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, }; static const SSysDbTableSchema userFuncSchema[] = { @@ -255,14 +257,13 @@ static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema)}, {TSDB_INS_TABLE_MODULES, modulesSchema, tListLen(modulesSchema)}, {TSDB_INS_TABLE_QNODES, qnodesSchema, tListLen(qnodesSchema)}, - {TSDB_INS_TABLE_SNODES, snodesSchema, tListLen(snodesSchema)}, - {TSDB_INS_TABLE_BNODES, bnodesSchema, tListLen(bnodesSchema)}, +// {TSDB_INS_TABLE_SNODES, snodesSchema, tListLen(snodesSchema)}, +// {TSDB_INS_TABLE_BNODES, bnodesSchema, tListLen(bnodesSchema)}, {TSDB_INS_TABLE_CLUSTER, clusterSchema, tListLen(clusterSchema)}, {TSDB_INS_TABLE_USER_DATABASES, userDBSchema, tListLen(userDBSchema)}, {TSDB_INS_TABLE_USER_FUNCTIONS, userFuncSchema, tListLen(userFuncSchema)}, {TSDB_INS_TABLE_USER_INDEXES, userIdxSchema, tListLen(userIdxSchema)}, {TSDB_INS_TABLE_USER_STABLES, userStbsSchema, tListLen(userStbsSchema)}, - {TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema)}, {TSDB_INS_TABLE_USER_TABLES, userTblsSchema, tListLen(userTblsSchema)}, {TSDB_INS_TABLE_USER_TAGS, userTagsSchema, tListLen(userTagsSchema)}, // {TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, userTblDistSchema, tListLen(userTblDistSchema)}, diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index f64a0df36f6cc99e93ce7b1d71f0ffc78348dc30..faee6cc2facc9ddcc4cdcabf2c8b554ac9a673b7 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1713,7 +1713,7 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) { size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock); int32_t rows = pDataBlock->info.rows; - printf("%s |block type %d |child id %d|group id %zX\n", flag, (int32_t)pDataBlock->info.type, + printf("%s |block type %d |child id %d|group id %" PRIu64 "\n", flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.groupId); for (int32_t j = 0; j < rows; j++) { printf("%s |", flag); @@ -1763,9 +1763,9 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf) int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock); int32_t rows = pDataBlock->info.rows; int32_t len = 0; - len += snprintf(dumpBuf + len, size - len, "===stream===%s |block type %d |child id %d|group id:%" PRIu64 "| uid:%ld|\n", flag, + len += snprintf(dumpBuf + len, size - len, "===stream===%s |block type %d|child id %d|group id:%" PRIu64 "|uid:%ld|rows:%d\n", flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.groupId, - pDataBlock->info.uid); + pDataBlock->info.uid, pDataBlock->info.rows); if (len >= size - 1) return dumpBuf; for (int32_t j = 0; j < rows; j++) { @@ -1878,7 +1878,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks msgLen += sizeof(SSubmitBlk); int32_t dataLen = 0; for (int32_t j = 0; j < rows; ++j) { // iterate by row - tdSRowResetBuf(&rb, POINTER_SHIFT(pDataBuf, msgLen)); // set row buf + tdSRowResetBuf(&rb, POINTER_SHIFT(pDataBuf, msgLen + dataLen)); // set row buf bool isStartKey = false; int32_t offset = 0; for (int32_t k = 0; k < colNum; ++k) { // iterate by column diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 7a20969a633d5d349c7cb0944e6c1162edec14ef..ce09b83fae3ec8767a0bad361467371526c55693 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -35,7 +35,6 @@ int32_t tsNumOfSupportVnodes = 256; // common int32_t tsMaxShellConns = 50000; int32_t tsShellActivityTimer = 3; // second -bool tsEnableSlaveQuery = true; bool tsPrintAuth = false; // multi process @@ -118,20 +117,6 @@ int32_t tsMaxNumOfDistinctResults = 1000 * 10000; // 1 database precision unit for interval time range, changed accordingly int32_t tsMinIntervalTime = 1; -// 20sec, the maximum value of stream computing delay, changed accordingly -int32_t tsMaxStreamComputDelay = 20000; - -// 10sec, the first stream computing delay time after system launched successfully, changed accordingly -int32_t tsStreamCompStartDelay = 10000; - -// the stream computing delay time after executing failed, change accordingly -int32_t tsRetryStreamCompDelay = 10 * 1000; - -// The delayed computing ration. 10% of the whole computing time window by default. -float tsStreamComputDelayRatio = 0.1f; - -int64_t tsMaxRetentWindow = 24 * 3600L; // maximum time window tolerance - // the maximum allowed query buffer size during query processing for each data node. // -1 no limit (default) // 0 no query allowed, queries are disabled @@ -142,12 +127,6 @@ int64_t tsQueryBufferSizeBytes = -1; // in retrieve blocking model, the retrieve threads will wait for the completion of the query processing. bool tsRetrieveBlockingModel = false; -// last_row(*), first(*), last_row(ts, col1, col2) query, the result fields will be the original column name -bool tsKeepOriginalColumnName = false; - -// kill long query -bool tsDeadLockKillQuery = false; - // tsdb config // For backward compatibility bool tsdbForceKeepFile = false; @@ -316,6 +295,7 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "udfDebugFlag", udfDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "smaDebugFlag", smaDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "idxDebugFlag", idxDebugFlag, 0, 255, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "tdbDebugFlag", tdbDebugFlag, 0, 255, 0) != 0) return -1; return 0; } @@ -329,11 +309,10 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { if (cfgAddString(pCfg, "fqdn", defaultFqdn, 1) != 0) return -1; if (cfgAddInt32(pCfg, "serverPort", defaultServerPort, 1, 65056, 1) != 0) return -1; if (cfgAddDir(pCfg, "tempDir", tsTempDir, 1) != 0) return -1; - if (cfgAddFloat(pCfg, "minimalTempDirGB", 1.0f, 0.001f, 10000000, 1) != 0) return -1; + if (cfgAddFloat(pCfg, "minimalTmpDirGB", 1.0f, 0.001f, 10000000, 1) != 0) return -1; if (cfgAddInt32(pCfg, "shellActivityTimer", tsShellActivityTimer, 1, 120, 1) != 0) return -1; if (cfgAddInt32(pCfg, "compressMsgSize", tsCompressMsgSize, -1, 100000000, 1) != 0) return -1; if (cfgAddInt32(pCfg, "compressColData", tsCompressColData, -1, 100000000, 1) != 0) return -1; - if (cfgAddBool(pCfg, "keepColumnName", tsKeepOriginalColumnName, 1) != 0) return -1; if (cfgAddInt32(pCfg, "queryPolicy", tsQueryPolicy, 1, 3, 1) != 0) return -1; if (cfgAddInt32(pCfg, "querySmaOptimize", tsQuerySmaOptimize, 0, 1, 1) != 0) return -1; if (cfgAddString(pCfg, "smlChildTableName", "", 1) != 0) return -1; @@ -382,15 +361,9 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "minIntervalTime", tsMinIntervalTime, 1, 1000000, 0) != 0) return -1; if (cfgAddInt32(pCfg, "maxNumOfDistinctRes", tsMaxNumOfDistinctResults, 10 * 10000, 10000 * 10000, 0) != 0) return -1; if (cfgAddInt32(pCfg, "countAlwaysReturnValue", tsCountAlwaysReturnValue, 0, 1, 0) != 0) return -1; - if (cfgAddInt32(pCfg, "maxStreamCompDelay", tsMaxStreamComputDelay, 10, 1000000000, 0) != 0) return -1; - if (cfgAddInt32(pCfg, "maxFirstStreamCompDelay", tsStreamCompStartDelay, 1000, 1000000000, 0) != 0) return -1; - if (cfgAddInt32(pCfg, "retryStreamCompDelay", tsRetryStreamCompDelay, 10, 1000000000, 0) != 0) return -1; - if (cfgAddFloat(pCfg, "streamCompDelayRatio", tsStreamComputDelayRatio, 0.1, 0.9, 0) != 0) return -1; if (cfgAddInt32(pCfg, "queryBufferSize", tsQueryBufferSize, -1, 500000000000, 0) != 0) return -1; if (cfgAddBool(pCfg, "retrieveBlockingModel", tsRetrieveBlockingModel, 0) != 0) return -1; if (cfgAddBool(pCfg, "printAuth", tsPrintAuth, 0) != 0) return -1; - if (cfgAddBool(pCfg, "slaveQuery", tsEnableSlaveQuery, 0) != 0) return -1; - if (cfgAddBool(pCfg, "deadLockKillQuery", tsDeadLockKillQuery, 0) != 0) return -1; if (cfgAddInt32(pCfg, "multiProcess", tsMultiProcess, 0, 2, 0) != 0) return -1; if (cfgAddInt32(pCfg, "mnodeShmSize", tsMnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1; @@ -398,7 +371,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "qnodeShmSize", tsQnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1; if (cfgAddInt32(pCfg, "snodeShmSize", tsSnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1; if (cfgAddInt32(pCfg, "bnodeShmSize", tsBnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1; - if (cfgAddInt32(pCfg, "mumOfShmThreads", tsNumOfShmThreads, 1, 1024, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "numOfShmThreads", tsNumOfShmThreads, 1, 1024, 0) != 0) return -1; tsNumOfRpcThreads = tsNumOfCores / 2; tsNumOfRpcThreads = TRANGE(tsNumOfRpcThreads, 1, 4); @@ -408,25 +381,21 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { tsNumOfCommitThreads = TRANGE(tsNumOfCommitThreads, 2, 4); if (cfgAddInt32(pCfg, "numOfCommitThreads", tsNumOfCommitThreads, 1, 1024, 0) != 0) return -1; - tsNumOfMnodeQueryThreads = tsNumOfCores * 2; - tsNumOfMnodeQueryThreads = TRANGE(tsNumOfMnodeQueryThreads, 4, 8); - if (cfgAddInt32(pCfg, "numOfMnodeQueryThreads", tsNumOfMnodeQueryThreads, 1, 1024, 0) != 0) return -1; - tsNumOfMnodeReadThreads = tsNumOfCores / 8; tsNumOfMnodeReadThreads = TRANGE(tsNumOfMnodeReadThreads, 1, 4); if (cfgAddInt32(pCfg, "numOfMnodeReadThreads", tsNumOfMnodeReadThreads, 1, 1024, 0) != 0) return -1; tsNumOfVnodeQueryThreads = tsNumOfCores * 2; tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 4); - if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 1, 1024, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 4, 1024, 0) != 0) return -1; tsNumOfVnodeStreamThreads = tsNumOfCores / 4; tsNumOfVnodeStreamThreads = TMAX(tsNumOfVnodeStreamThreads, 4); - if (cfgAddInt32(pCfg, "numOfVnodeStreamThreads", tsNumOfVnodeStreamThreads, 1, 1024, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "numOfVnodeStreamThreads", tsNumOfVnodeStreamThreads, 4, 1024, 0) != 0) return -1; tsNumOfVnodeFetchThreads = tsNumOfCores / 4; tsNumOfVnodeFetchThreads = TMAX(tsNumOfVnodeFetchThreads, 4); - if (cfgAddInt32(pCfg, "numOfVnodeFetchThreads", tsNumOfVnodeFetchThreads, 1, 1024, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "numOfVnodeFetchThreads", tsNumOfVnodeFetchThreads, 4, 1024, 0) != 0) return -1; tsNumOfVnodeWriteThreads = tsNumOfCores; tsNumOfVnodeWriteThreads = TMAX(tsNumOfVnodeWriteThreads, 1); @@ -446,11 +415,11 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { tsNumOfSnodeSharedThreads = tsNumOfCores / 4; tsNumOfSnodeSharedThreads = TRANGE(tsNumOfSnodeSharedThreads, 2, 4); - if (cfgAddInt32(pCfg, "numOfSnodeSharedThreads", tsNumOfSnodeSharedThreads, 1, 1024, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "numOfSnodeSharedThreads", tsNumOfSnodeSharedThreads, 2, 1024, 0) != 0) return -1; tsNumOfSnodeUniqueThreads = tsNumOfCores / 4; tsNumOfSnodeUniqueThreads = TRANGE(tsNumOfSnodeUniqueThreads, 2, 4); - if (cfgAddInt32(pCfg, "numOfSnodeUniqueThreads", tsNumOfSnodeUniqueThreads, 1, 1024, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "numOfSnodeUniqueThreads", tsNumOfSnodeUniqueThreads, 2, 1024, 0) != 0) return -1; tsRpcQueueMemoryAllowed = tsTotalMemoryKB * 1024 * 0.1; tsRpcQueueMemoryAllowed = TRANGE(tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, TSDB_MAX_MSG_SIZE * 10000L); @@ -506,6 +475,7 @@ static void taosSetServerLogCfg(SConfig *pCfg) { udfDebugFlag = cfgGetItem(pCfg, "udfDebugFlag")->i32; smaDebugFlag = cfgGetItem(pCfg, "smaDebugFlag")->i32; idxDebugFlag = cfgGetItem(pCfg, "idxDebugFlag")->i32; + tdbDebugFlag = cfgGetItem(pCfg, "tdbDebugFlag")->i32; } static int32_t taosSetClientCfg(SConfig *pCfg) { @@ -530,7 +500,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { tstrncpy(tsTempDir, cfgGetItem(pCfg, "tempDir")->str, PATH_MAX); taosExpandDir(tsTempDir, tsTempDir, PATH_MAX); - tsTempSpace.reserved = cfgGetItem(pCfg, "minimalTempDirGB")->fval; + tsTempSpace.reserved = cfgGetItem(pCfg, "minimalTmpDirGB")->fval; if (taosMulMkDir(tsTempDir) != 0) { uError("failed to create tempDir:%s since %s", tsTempDir, terrstr()); return -1; @@ -543,7 +513,6 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32; tsCompressMsgSize = cfgGetItem(pCfg, "compressMsgSize")->i32; tsCompressColData = cfgGetItem(pCfg, "compressColData")->i32; - tsKeepOriginalColumnName = cfgGetItem(pCfg, "keepColumnName")->bval; tsNumOfTaskQueueThreads = cfgGetItem(pCfg, "numOfTaskQueueThreads")->i32; tsQueryPolicy = cfgGetItem(pCfg, "queryPolicy")->i32; tsQuerySmaOptimize = cfgGetItem(pCfg, "querySmaOptimize")->i32; @@ -577,15 +546,9 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsMinIntervalTime = cfgGetItem(pCfg, "minIntervalTime")->i32; tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32; tsCountAlwaysReturnValue = cfgGetItem(pCfg, "countAlwaysReturnValue")->i32; - tsMaxStreamComputDelay = cfgGetItem(pCfg, "maxStreamCompDelay")->i32; - tsStreamCompStartDelay = cfgGetItem(pCfg, "maxFirstStreamCompDelay")->i32; - tsRetryStreamCompDelay = cfgGetItem(pCfg, "retryStreamCompDelay")->i32; - tsStreamComputDelayRatio = cfgGetItem(pCfg, "streamCompDelayRatio")->fval; tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32; tsRetrieveBlockingModel = cfgGetItem(pCfg, "retrieveBlockingModel")->bval; tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval; - tsEnableSlaveQuery = cfgGetItem(pCfg, "slaveQuery")->bval; - tsDeadLockKillQuery = cfgGetItem(pCfg, "deadLockKillQuery")->i32; tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval; tsMnodeShmSize = cfgGetItem(pCfg, "mnodeShmSize")->i32; @@ -596,7 +559,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32; tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32; - tsNumOfMnodeQueryThreads = cfgGetItem(pCfg, "numOfMnodeQueryThreads")->i32; tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32; tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32; tsNumOfVnodeStreamThreads = cfgGetItem(pCfg, "numOfVnodeStreamThreads")->i32; @@ -671,9 +633,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { break; } case 'd': { - if (strcasecmp("deadLockKillQuery", name) == 0) { - tsDeadLockKillQuery = cfgGetItem(pCfg, "deadLockKillQuery")->i32; - } else if (strcasecmp("dDebugFlag", name) == 0) { + if (strcasecmp("dDebugFlag", name) == 0) { dDebugFlag = cfgGetItem(pCfg, "dDebugFlag")->i32; } break; @@ -730,9 +690,6 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { break; } case 'k': { - if (strcasecmp("keepColumnName", name) == 0) { - tsKeepOriginalColumnName = cfgGetItem(pCfg, "keepColumnName")->bval; - } break; } case 'l': { @@ -756,10 +713,6 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { tsMaxShellConns = cfgGetItem(pCfg, "maxShellConns")->i32; } else if (strcasecmp("maxNumOfDistinctRes", name) == 0) { tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32; - } else if (strcasecmp("maxStreamCompDelay", name) == 0) { - tsMaxStreamComputDelay = cfgGetItem(pCfg, "maxStreamCompDelay")->i32; - } else if (strcasecmp("maxFirstStreamCompDelay", name) == 0) { - tsStreamCompStartDelay = cfgGetItem(pCfg, "maxFirstStreamCompDelay")->i32; } break; } @@ -770,8 +723,8 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { break; } case 'i': { - if (strcasecmp("minimalTempDirGB", name) == 0) { - tsTempSpace.reserved = cfgGetItem(pCfg, "minimalTempDirGB")->fval; + if (strcasecmp("minimalTmpDirGB", name) == 0) { + tsTempSpace.reserved = cfgGetItem(pCfg, "minimalTmpDirGB")->fval; } else if (strcasecmp("minimalDataDirGB", name) == 0) { tsDataSpace.reserved = cfgGetItem(pCfg, "minimalDataDirGB")->fval; } else if (strcasecmp("minSlidingTime", name) == 0) { @@ -832,8 +785,6 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32; } else if (strcasecmp("numOfCommitThreads", name) == 0) { tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32; - } else if (strcasecmp("numOfMnodeQueryThreads", name) == 0) { - tsNumOfMnodeQueryThreads = cfgGetItem(pCfg, "numOfMnodeQueryThreads")->i32; } else if (strcasecmp("numOfMnodeReadThreads", name) == 0) { tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32; } else if (strcasecmp("numOfVnodeQueryThreads", name) == 0) { @@ -881,9 +832,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { break; } case 'r': { - if (strcasecmp("retryStreamCompDelay", name) == 0) { - tsRetryStreamCompDelay = cfgGetItem(pCfg, "retryStreamCompDelay")->i32; - } else if (strcasecmp("retrieveBlockingModel", name) == 0) { + if (strcasecmp("retrieveBlockingModel", name) == 0) { tsRetrieveBlockingModel = cfgGetItem(pCfg, "retrieveBlockingModel")->bval; } else if (strcasecmp("rpcQueueMemoryAllowed", name) == 0) { tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64; @@ -911,10 +860,6 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { tsNumOfSupportVnodes = cfgGetItem(pCfg, "supportVnodes")->i32; } else if (strcasecmp("statusInterval", name) == 0) { tsStatusInterval = cfgGetItem(pCfg, "statusInterval")->i32; - } else if (strcasecmp("streamCompDelayRatio", name) == 0) { - tsStreamComputDelayRatio = cfgGetItem(pCfg, "streamCompDelayRatio")->fval; - } else if (strcasecmp("slaveQuery", name) == 0) { - tsEnableSlaveQuery = cfgGetItem(pCfg, "slaveQuery")->bval; } else if (strcasecmp("snodeShmSize", name) == 0) { tsSnodeShmSize = cfgGetItem(pCfg, "snodeShmSize")->i32; } else if (strcasecmp("serverPort", name) == 0) { @@ -950,6 +895,8 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { uError("failed to create tempDir:%s since %s", tsTempDir, terrstr()); return -1; } + } else if (strcasecmp("tdbDebugFlag", name) == 0) { + tdbDebugFlag = cfgGetItem(pCfg, "tdbDebugFlag")->i32; } else if (strcasecmp("telemetryReporting", name) == 0) { tsEnableTelem = cfgGetItem(pCfg, "telemetryReporting")->bval; } else if (strcasecmp("telemetryInterval", name) == 0) { @@ -1151,14 +1098,14 @@ void taosCfgDynamicOptions(const char *option, const char *value) { } const char *options[] = { - "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag", - "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tmrDebugFlag", - "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", + "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag", + "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tdbDebugFlag", + "tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", }; int32_t *optionVars[] = { - &dDebugFlag, &vDebugFlag, &mDebugFlag, &wDebugFlag, &sDebugFlag, &tsdbDebugFlag, - &tqDebugFlag, &fsDebugFlag, &udfDebugFlag, &smaDebugFlag, &idxDebugFlag, &tmrDebugFlag, - &uDebugFlag, &smaDebugFlag, &rpcDebugFlag, &qDebugFlag, + &dDebugFlag, &vDebugFlag, &mDebugFlag, &wDebugFlag, &sDebugFlag, &tsdbDebugFlag, + &tqDebugFlag, &fsDebugFlag, &udfDebugFlag, &smaDebugFlag, &idxDebugFlag, &tdbDebugFlag, + &tmrDebugFlag, &uDebugFlag, &smaDebugFlag, &rpcDebugFlag, &qDebugFlag, }; int32_t optionSize = tListLen(options); @@ -1204,5 +1151,6 @@ void taosSetAllDebugFlag(int32_t flag) { taosSetDebugFlag(&udfDebugFlag, "udfDebugFlag", flag); taosSetDebugFlag(&smaDebugFlag, "smaDebugFlag", flag); taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag); + taosSetDebugFlag(&tdbDebugFlag, "tdbDebugFlag", flag); uInfo("all debug flag are set to %d", flag); } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index c94c624f8953e4317ca95e23dfa462dbe49a3dc1..3163982decb1fe4b62f2140cd1c1aa6f94bf3916 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -2010,7 +2010,7 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) { if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1; if (tEncodeI32(&encoder, pReq->minRows) < 0) return -1; if (tEncodeI32(&encoder, pReq->maxRows) < 0) return -1; - if (tEncodeI32(&encoder, pReq->fsyncPeriod) < 0) return -1; + if (tEncodeI32(&encoder, pReq->walFsyncPeriod) < 0) return -1; if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1; if (tEncodeI8(&encoder, pReq->precision) < 0) return -1; if (tEncodeI8(&encoder, pReq->compression) < 0) return -1; @@ -2018,6 +2018,10 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) { if (tEncodeI8(&encoder, pReq->strict) < 0) return -1; if (tEncodeI8(&encoder, pReq->cacheLast) < 0) return -1; if (tEncodeI8(&encoder, pReq->schemaless) < 0) return -1; + if (tEncodeI32(&encoder, pReq->walRetentionPeriod) < 0) return -1; + if (tEncodeI64(&encoder, pReq->walRetentionSize) < 0) return -1; + if (tEncodeI32(&encoder, pReq->walRollPeriod) < 0) return -1; + if (tEncodeI64(&encoder, pReq->walSegmentSize) < 0) return -1; if (tEncodeI8(&encoder, pReq->ignoreExist) < 0) return -1; if (tEncodeI32(&encoder, pReq->numOfRetensions) < 0) return -1; for (int32_t i = 0; i < pReq->numOfRetensions; ++i) { @@ -2052,7 +2056,7 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1; if (tDecodeI32(&decoder, &pReq->minRows) < 0) return -1; if (tDecodeI32(&decoder, &pReq->maxRows) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->fsyncPeriod) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->walFsyncPeriod) < 0) return -1; if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1; if (tDecodeI8(&decoder, &pReq->precision) < 0) return -1; if (tDecodeI8(&decoder, &pReq->compression) < 0) return -1; @@ -2060,6 +2064,10 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1; if (tDecodeI8(&decoder, &pReq->cacheLast) < 0) return -1; if (tDecodeI8(&decoder, &pReq->schemaless) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->walRetentionPeriod) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->walRetentionSize) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->walRollPeriod) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->walSegmentSize) < 0) return -1; if (tDecodeI8(&decoder, &pReq->ignoreExist) < 0) return -1; if (tDecodeI32(&decoder, &pReq->numOfRetensions) < 0) return -1; pReq->pRetensions = taosArrayInit(pReq->numOfRetensions, sizeof(SRetention)); @@ -2105,7 +2113,7 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) { if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1; - if (tEncodeI32(&encoder, pReq->fsyncPeriod) < 0) return -1; + if (tEncodeI32(&encoder, pReq->walFsyncPeriod) < 0) return -1; if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1; if (tEncodeI8(&encoder, pReq->strict) < 0) return -1; if (tEncodeI8(&encoder, pReq->cacheLast) < 0) return -1; @@ -2131,7 +2139,7 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) { if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->fsyncPeriod) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->walFsyncPeriod) < 0) return -1; if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1; if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1; if (tDecodeI8(&decoder, &pReq->cacheLast) < 0) return -1; @@ -2740,7 +2748,7 @@ int32_t tSerializeSDbCfgRsp(void *buf, int32_t bufLen, const SDbCfgRsp *pRsp) { if (tEncodeI32(&encoder, pRsp->daysToKeep2) < 0) return -1; if (tEncodeI32(&encoder, pRsp->minRows) < 0) return -1; if (tEncodeI32(&encoder, pRsp->maxRows) < 0) return -1; - if (tEncodeI32(&encoder, pRsp->fsyncPeriod) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->walFsyncPeriod) < 0) return -1; if (tEncodeI8(&encoder, pRsp->walLevel) < 0) return -1; if (tEncodeI8(&encoder, pRsp->precision) < 0) return -1; if (tEncodeI8(&encoder, pRsp->compression) < 0) return -1; @@ -2779,7 +2787,7 @@ int32_t tDeserializeSDbCfgRsp(void *buf, int32_t bufLen, SDbCfgRsp *pRsp) { if (tDecodeI32(&decoder, &pRsp->daysToKeep2) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->minRows) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->maxRows) < 0) return -1; - if (tDecodeI32(&decoder, &pRsp->fsyncPeriod) < 0) return -1; + if (tDecodeI32(&decoder, &pRsp->walFsyncPeriod) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->walLevel) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->precision) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->compression) < 0) return -1; @@ -3712,7 +3720,7 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1; if (tEncodeI32(&encoder, pReq->minRows) < 0) return -1; if (tEncodeI32(&encoder, pReq->maxRows) < 0) return -1; - if (tEncodeI32(&encoder, pReq->fsyncPeriod) < 0) return -1; + if (tEncodeI32(&encoder, pReq->walFsyncPeriod) < 0) return -1; if (tEncodeU32(&encoder, pReq->hashBegin) < 0) return -1; if (tEncodeU32(&encoder, pReq->hashEnd) < 0) return -1; if (tEncodeI8(&encoder, pReq->hashMethod) < 0) return -1; @@ -3742,6 +3750,10 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR uint32_t tsmaLen = (uint32_t)(htonl(((SMsgHead *)pReq->pTsma)->contLen)); if (tEncodeBinary(&encoder, (const uint8_t *)pReq->pTsma, tsmaLen) < 0) return -1; } + if (tEncodeI32(&encoder, pReq->walRetentionPeriod) < 0) return -1; + if (tEncodeI64(&encoder, pReq->walRetentionSize) < 0) return -1; + if (tEncodeI32(&encoder, pReq->walRollPeriod) < 0) return -1; + if (tEncodeI64(&encoder, pReq->walSegmentSize) < 0) return -1; tEndEncode(&encoder); @@ -3770,7 +3782,7 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq * if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1; if (tDecodeI32(&decoder, &pReq->minRows) < 0) return -1; if (tDecodeI32(&decoder, &pReq->maxRows) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->fsyncPeriod) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->walFsyncPeriod) < 0) return -1; if (tDecodeU32(&decoder, &pReq->hashBegin) < 0) return -1; if (tDecodeU32(&decoder, &pReq->hashEnd) < 0) return -1; if (tDecodeI8(&decoder, &pReq->hashMethod) < 0) return -1; @@ -3810,6 +3822,11 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq * if (tDecodeBinary(&decoder, (uint8_t **)&pReq->pTsma, NULL) < 0) return -1; } + if (tDecodeI32(&decoder, &pReq->walRetentionPeriod) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->walRetentionSize) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->walRollPeriod) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->walSegmentSize) < 0) return -1; + tEndDecode(&decoder); tDecoderClear(&decoder); return 0; @@ -3893,7 +3910,7 @@ int32_t tSerializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pReq if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1; - if (tEncodeI32(&encoder, pReq->fsyncPeriod) < 0) return -1; + if (tEncodeI32(&encoder, pReq->walFsyncPeriod) < 0) return -1; if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1; if (tEncodeI8(&encoder, pReq->strict) < 0) return -1; if (tEncodeI8(&encoder, pReq->cacheLast) < 0) return -1; @@ -3924,7 +3941,7 @@ int32_t tDeserializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pR if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->fsyncPeriod) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->walFsyncPeriod) < 0) return -1; if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1; if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1; if (tDecodeI8(&decoder, &pReq->cacheLast) < 0) return -1; @@ -5664,6 +5681,8 @@ int32_t tEncodeDeleteRes(SEncoder *pCoder, const SDeleteRes *pRes) { if (tEncodeI64(pCoder, pRes->ekey) < 0) return -1; if (tEncodeI64v(pCoder, pRes->affectedRows) < 0) return -1; + if (tEncodeCStr(pCoder, pRes->tableFName) < 0) return -1; + if (tEncodeCStr(pCoder, pRes->tsColName) < 0) return -1; return 0; } @@ -5675,12 +5694,14 @@ int32_t tDecodeDeleteRes(SDecoder *pCoder, SDeleteRes *pRes) { if (tDecodeI32v(pCoder, &nUid) < 0) return -1; for (int32_t iUid = 0; iUid < nUid; iUid++) { if (tDecodeU64(pCoder, &uid) < 0) return -1; - taosArrayPush(pRes->uidList, &uid); + if (pRes->uidList) taosArrayPush(pRes->uidList, &uid); } if (tDecodeI64(pCoder, &pRes->skey) < 0) return -1; if (tDecodeI64(pCoder, &pRes->ekey) < 0) return -1; if (tDecodeI64v(pCoder, &pRes->affectedRows) < 0) return -1; + if (tDecodeCStrTo(pCoder, pRes->tableFName) < 0) return -1; + if (tDecodeCStrTo(pCoder, pRes->tsColName) < 0) return -1; return 0; } int32_t tEncodeSMqDataRsp(SEncoder *pEncoder, const SMqDataRsp *pRsp) { diff --git a/source/dnode/mgmt/CMakeLists.txt b/source/dnode/mgmt/CMakeLists.txt index 581686ba904001b80638efd9ab225c3f68e91e09..45bef7f98ea3f590f53c646cc2abdebb6c5091dc 100644 --- a/source/dnode/mgmt/CMakeLists.txt +++ b/source/dnode/mgmt/CMakeLists.txt @@ -14,4 +14,7 @@ target_include_directories( taosd PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/node_mgmt/inc" ) +IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + add_dependencies(taosd jemalloc) +ENDIF () target_link_libraries(taosd dnode) diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index 22a53f07f6aeab486719da5fd3253154dc65a41e..647af20fcf24e47b27b02d69595f8d1555a4cc19 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -184,6 +184,7 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_BATCH_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_CFG, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 0471e2b85043e0286909d3174e8c937dd4e22f08..eca61dd960eaf6fd9b0dfbd0d9bdc4de698e8c77 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -160,6 +160,13 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { } pCfg->walCfg.vgId = pCreate->vgId; + pCfg->walCfg.fsyncPeriod = pCreate->walFsyncPeriod; + pCfg->walCfg.retentionPeriod = pCreate->walRetentionPeriod; + pCfg->walCfg.rollPeriod = pCreate->walRollPeriod; + pCfg->walCfg.retentionSize = pCreate->walRetentionSize; + pCfg->walCfg.segSize = pCreate->walSegmentSize; + pCfg->walCfg.level = pCreate->walLevel; + pCfg->hashBegin = pCreate->hashBegin; pCfg->hashEnd = pCreate->hashEnd; pCfg->hashMethod = pCreate->hashMethod; @@ -336,6 +343,7 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_VND_UPDATE_TAG_VAL, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_CFG, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_BATCH_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_TABLES_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SCH_CANCEL_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SCH_DROP_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index 5ad13e383a648b7703a7a247d182242950008750..9d1142801d945141c4c0831e03c40a3f33cef1e4 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -89,7 +89,7 @@ static void vmProcessStreamQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, pMsg, pInfo); if (code != 0) { if (terrno != 0) code = terrno; - dGError("vgId:%d, msg:%p failed to stream since %s", pVnode->vgId, pMsg, terrstr()); + dGError("vgId:%d, msg:%p failed to process stream since %s", pVnode->vgId, pMsg, terrstr()); vmSendRsp(pMsg, code); } diff --git a/source/dnode/mnode/impl/CMakeLists.txt b/source/dnode/mnode/impl/CMakeLists.txt index a4bd12a7f7627307cd1473d4ef973657c1c4fb49..c740ea1397e7b406f0b832d3d63aa88b9accd4e0 100644 --- a/source/dnode/mnode/impl/CMakeLists.txt +++ b/source/dnode/mnode/impl/CMakeLists.txt @@ -1,4 +1,11 @@ aux_source_directory(src MNODE_SRC) +IF (TD_PRIVILEGE) + ADD_DEFINITIONS(-D_PRIVILEGE) +ENDIF () +IF (TD_PRIVILEGE) + LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/privilege/src/privilege.c) +ENDIF () + add_library(mnode STATIC ${MNODE_SRC}) target_include_directories( mnode @@ -8,11 +15,8 @@ target_include_directories( target_link_libraries( mnode scheduler sdb wal transport cjson sync monitor executor qworker stream parser ) - IF (TD_GRANT) TARGET_LINK_LIBRARIES(mnode grant) -ENDIF () -IF (TD_GRANT) ADD_DEFINITIONS(-D_GRANT) ENDIF () diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index f6c92c3929e36da220aaf2c6d5f638e845df3ffc..06c64dcea6aed0cf0b563e858df110a6b4be8266 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -164,8 +164,8 @@ typedef struct { int32_t lastErrorNo; tmsg_t lastMsgType; SEpSet lastEpset; - char dbname1[TSDB_DB_FNAME_LEN]; - char dbname2[TSDB_DB_FNAME_LEN]; + char dbname1[TSDB_TABLE_FNAME_LEN]; + char dbname2[TSDB_TABLE_FNAME_LEN]; int32_t startFunc; int32_t stopFunc; int32_t paramLen; @@ -294,7 +294,7 @@ typedef struct { int32_t daysToKeep2; int32_t minRows; int32_t maxRows; - int32_t fsyncPeriod; + int32_t walFsyncPeriod; int8_t walLevel; int8_t precision; int8_t compression; @@ -302,9 +302,13 @@ typedef struct { int8_t strict; int8_t hashMethod; // default is 1 int8_t cacheLast; + int8_t schemaless; int32_t numOfRetensions; SArray* pRetensions; - int8_t schemaless; + int32_t walRetentionPeriod; + int64_t walRetentionSize; + int32_t walRollPeriod; + int64_t walSegmentSize; } SDbCfg; typedef struct { diff --git a/source/dnode/mnode/impl/inc/mndPrivilege.h b/source/dnode/mnode/impl/inc/mndPrivilege.h index f6002e3be8ba98e3867cef6034161545430f2a9d..dc88b25f51adbbbd1e813401645b51a4e3ba0089 100644 --- a/source/dnode/mnode/impl/inc/mndPrivilege.h +++ b/source/dnode/mnode/impl/inc/mndPrivilege.h @@ -30,6 +30,7 @@ int32_t mndCheckDbPrivilege(SMnode *pMnode, const char *user, EOperType operType int32_t mndCheckDbPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *dbname); int32_t mndCheckShowPrivilege(SMnode *pMnode, const char *user, EShowType showType, const char *dbname); int32_t mndCheckAlterUserPrivilege(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter); +int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUserAuthRsp *pRsp); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/inc/mndUser.h b/source/dnode/mnode/impl/inc/mndUser.h index 016ec3e6e9e6155c68c0553b738f237140bf1d42..970d1db7dbc2ff9a92f201aabb940fdeea1f22e4 100644 --- a/source/dnode/mnode/impl/inc/mndUser.h +++ b/source/dnode/mnode/impl/inc/mndUser.h @@ -17,6 +17,7 @@ #define _TD_MND_USER_H_ #include "mndInt.h" +#include "thash.h" #ifdef __cplusplus extern "C" { @@ -28,9 +29,10 @@ SUserObj *mndAcquireUser(SMnode *pMnode, const char *userName); void mndReleaseUser(SMnode *pMnode, SUserObj *pUser); // for trans test -SSdbRaw *mndUserActionEncode(SUserObj *pUser); -int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_t numOfUses, void **ppRsp, - int32_t *pRspLen); +SSdbRaw *mndUserActionEncode(SUserObj *pUser); +SHashObj *mndDupDbHash(SHashObj *pOld); +int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_t numOfUses, void **ppRsp, + int32_t *pRspLen); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 064ef9b40a772790ff01284cee9103dfe642f78b..9684753ace7d254d19f78b3d747cbe78e4ee2518 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -102,7 +102,7 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) { SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep2, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.minRows, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.maxRows, _OVER) - SDB_SET_INT32(pRaw, dataPos, pDb->cfg.fsyncPeriod, _OVER) + SDB_SET_INT32(pRaw, dataPos, pDb->cfg.walFsyncPeriod, _OVER) SDB_SET_INT8(pRaw, dataPos, pDb->cfg.walLevel, _OVER) SDB_SET_INT8(pRaw, dataPos, pDb->cfg.precision, _OVER) SDB_SET_INT8(pRaw, dataPos, pDb->cfg.compression, _OVER) @@ -120,6 +120,10 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) { SDB_SET_INT8(pRaw, dataPos, pRetension->keepUnit, _OVER) } SDB_SET_INT8(pRaw, dataPos, pDb->cfg.schemaless, _OVER) + SDB_SET_INT32(pRaw, dataPos, pDb->cfg.walRetentionPeriod, _OVER) + SDB_SET_INT64(pRaw, dataPos, pDb->cfg.walRetentionSize, _OVER) + SDB_SET_INT32(pRaw, dataPos, pDb->cfg.walRollPeriod, _OVER) + SDB_SET_INT64(pRaw, dataPos, pDb->cfg.walSegmentSize, _OVER) SDB_SET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER) SDB_SET_DATALEN(pRaw, dataPos, _OVER) @@ -175,7 +179,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep2, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.minRows, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.maxRows, _OVER) - SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.fsyncPeriod, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.walFsyncPeriod, _OVER) SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.walLevel, _OVER) SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.precision, _OVER) SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.compression, _OVER) @@ -199,6 +203,10 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) { } } SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.schemaless, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.walRetentionPeriod, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pDb->cfg.walRetentionSize, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.walRollPeriod, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pDb->cfg.walSegmentSize, _OVER) SDB_GET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER) taosInitRWLatch(&pDb->lock); @@ -241,7 +249,7 @@ static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew) { pOld->cfg.daysToKeep0 = pNew->cfg.daysToKeep0; pOld->cfg.daysToKeep1 = pNew->cfg.daysToKeep1; pOld->cfg.daysToKeep2 = pNew->cfg.daysToKeep2; - pOld->cfg.fsyncPeriod = pNew->cfg.fsyncPeriod; + pOld->cfg.walFsyncPeriod = pNew->cfg.walFsyncPeriod; pOld->cfg.walLevel = pNew->cfg.walLevel; pOld->cfg.strict = pNew->cfg.strict; pOld->cfg.cacheLast = pNew->cfg.cacheLast; @@ -304,7 +312,7 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) { if (pCfg->minRows < TSDB_MIN_MINROWS_FBLOCK || pCfg->minRows > TSDB_MAX_MINROWS_FBLOCK) return -1; if (pCfg->maxRows < TSDB_MIN_MAXROWS_FBLOCK || pCfg->maxRows > TSDB_MAX_MAXROWS_FBLOCK) return -1; if (pCfg->minRows > pCfg->maxRows) return -1; - if (pCfg->fsyncPeriod < TSDB_MIN_FSYNC_PERIOD || pCfg->fsyncPeriod > TSDB_MAX_FSYNC_PERIOD) return -1; + if (pCfg->walFsyncPeriod < TSDB_MIN_FSYNC_PERIOD || pCfg->walFsyncPeriod > TSDB_MAX_FSYNC_PERIOD) return -1; if (pCfg->walLevel < TSDB_MIN_WAL_LEVEL || pCfg->walLevel > TSDB_MAX_WAL_LEVEL) return -1; if (pCfg->precision < TSDB_MIN_PRECISION && pCfg->precision > TSDB_MAX_PRECISION) return -1; if (pCfg->compression < TSDB_MIN_COMP_LEVEL || pCfg->compression > TSDB_MAX_COMP_LEVEL) return -1; @@ -318,6 +326,10 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) { terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES; return -1; } + if (pCfg->walRetentionPeriod < TSDB_DB_MIN_WAL_RETENTION_PERIOD) return -1; + if (pCfg->walRetentionSize < TSDB_DB_MIN_WAL_RETENTION_SIZE) return -1; + if (pCfg->walRollPeriod < TSDB_DB_MIN_WAL_ROLL_PERIOD) return -1; + if (pCfg->walSegmentSize < TSDB_DB_MIN_WAL_SEGMENT_SIZE) return -1; terrno = 0; return terrno; @@ -335,7 +347,7 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) { if (pCfg->daysToKeep2 < 0) pCfg->daysToKeep2 = pCfg->daysToKeep1; if (pCfg->minRows < 0) pCfg->minRows = TSDB_DEFAULT_MINROWS_FBLOCK; if (pCfg->maxRows < 0) pCfg->maxRows = TSDB_DEFAULT_MAXROWS_FBLOCK; - if (pCfg->fsyncPeriod < 0) pCfg->fsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD; + if (pCfg->walFsyncPeriod < 0) pCfg->walFsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD; if (pCfg->walLevel < 0) pCfg->walLevel = TSDB_DEFAULT_WAL_LEVEL; if (pCfg->precision < 0) pCfg->precision = TSDB_DEFAULT_PRECISION; if (pCfg->compression < 0) pCfg->compression = TSDB_DEFAULT_COMP_LEVEL; @@ -345,6 +357,12 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) { if (pCfg->cacheLastSize <= 0) pCfg->cacheLastSize = TSDB_DEFAULT_CACHE_SIZE; if (pCfg->numOfRetensions < 0) pCfg->numOfRetensions = 0; if (pCfg->schemaless < 0) pCfg->schemaless = TSDB_DB_SCHEMALESS_OFF; + if (pCfg->walRetentionPeriod < 0 && pCfg->walRetentionPeriod != -1) + pCfg->walRetentionPeriod = TSDB_DEFAULT_DB_WAL_RETENTION_PERIOD; + if (pCfg->walRetentionSize < 0 && pCfg->walRetentionSize != -1) + pCfg->walRetentionSize = TSDB_DEFAULT_DB_WAL_RETENTION_SIZE; + if (pCfg->walRollPeriod < 0) pCfg->walRollPeriod = TSDB_DEFAULT_DB_WAL_ROLL_PERIOD; + if (pCfg->walSegmentSize < 0) pCfg->walSegmentSize = TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE; } static int32_t mndSetCreateDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroups) { @@ -448,7 +466,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate, .daysToKeep2 = pCreate->daysToKeep2, .minRows = pCreate->minRows, .maxRows = pCreate->maxRows, - .fsyncPeriod = pCreate->fsyncPeriod, + .walFsyncPeriod = pCreate->walFsyncPeriod, .walLevel = pCreate->walLevel, .precision = pCreate->precision, .compression = pCreate->compression, @@ -457,6 +475,10 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate, .cacheLast = pCreate->cacheLast, .hashMethod = 1, .schemaless = pCreate->schemaless, + .walRetentionPeriod = pCreate->walRetentionPeriod, + .walRetentionSize = pCreate->walRetentionSize, + .walRollPeriod = pCreate->walRollPeriod, + .walSegmentSize = pCreate->walSegmentSize, }; dbObj.cfg.numOfRetensions = pCreate->numOfRetensions; @@ -620,8 +642,8 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) { terrno = 0; } - if (pAlter->fsyncPeriod >= 0 && pAlter->fsyncPeriod != pDb->cfg.fsyncPeriod) { - pDb->cfg.fsyncPeriod = pAlter->fsyncPeriod; + if (pAlter->walFsyncPeriod >= 0 && pAlter->walFsyncPeriod != pDb->cfg.walFsyncPeriod) { + pDb->cfg.walFsyncPeriod = pAlter->walFsyncPeriod; terrno = 0; } @@ -811,7 +833,7 @@ static int32_t mndProcessGetDbCfgReq(SRpcMsg *pReq) { cfgRsp.daysToKeep2 = pDb->cfg.daysToKeep2; cfgRsp.minRows = pDb->cfg.minRows; cfgRsp.maxRows = pDb->cfg.maxRows; - cfgRsp.fsyncPeriod = pDb->cfg.fsyncPeriod; + cfgRsp.walFsyncPeriod = pDb->cfg.walFsyncPeriod; cfgRsp.walLevel = pDb->cfg.walLevel; cfgRsp.precision = pDb->cfg.precision; cfgRsp.compression = pDb->cfg.compression; @@ -1499,7 +1521,7 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in colDataAppend(pColInfo, rows, buf, false); } else if (i == 3) { colDataAppend(pColInfo, rows, (const char *)&numOfTables, false); - } else if (i == 20) { + } else if (i == 15) { colDataAppend(pColInfo, rows, statusVstr, false); } else { colDataAppendNULL(pColInfo, rows); @@ -1560,21 +1582,9 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.maxRows, false); - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walLevel, false); - - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.fsyncPeriod, false); - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.compression, false); - const char *cacheModelStr = getCacheModelStr(pDb->cfg.cacheLast); - char cacheModelVstr[24] = {0}; - STR_WITH_SIZE_TO_VARSTR(cacheModelVstr, cacheModelStr, strlen(cacheModelStr)); - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)cacheModelVstr, false); - const char *precStr = NULL; switch (pDb->cfg.precision) { case TSDB_TIME_PRECISION_MILLI: @@ -1595,20 +1605,47 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, rows, (const char *)precVstr, false); - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.numOfStables, false); - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, rows, (const char *)statusVstr, false); char *rentensionVstr = buildRetension(pDb->cfg.pRetensions); - pColInfo = taosArrayGet(pBlock->pDataBlock, cols); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); if (rentensionVstr == NULL) { colDataAppendNULL(pColInfo, rows); } else { colDataAppend(pColInfo, rows, (const char *)rentensionVstr, false); taosMemoryFree(rentensionVstr); } + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.numOfStables, false); + + const char *cacheModelStr = getCacheModelStr(pDb->cfg.cacheLast); + char cacheModelVstr[24] = {0}; + STR_WITH_SIZE_TO_VARSTR(cacheModelVstr, cacheModelStr, strlen(cacheModelStr)); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)cacheModelVstr, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.cacheLastSize, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walLevel, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walFsyncPeriod, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walRetentionPeriod, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walRollPeriod, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walRetentionSize, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walSegmentSize, false); } taosMemoryFree(buf); diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 7141a62be51d11f5a65e2a02cb2f52fe070f8612..3f90f087fd34985d99b5476610aec4dd5e9002d3 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -788,9 +788,9 @@ _OVER: static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; const char *options[] = { - "debugFlag", "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", - "tsdbDebugFlag", "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", - "tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", + "debugFlag", "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", + "tsdbDebugFlag", "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", + "tdbDebugFlag", "tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", }; int32_t optionSize = tListLen(options); @@ -805,15 +805,6 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { return -1; } - SDnodeObj *pDnode = mndAcquireDnode(pMnode, cfgReq.dnodeId); - if (pDnode == NULL) { - mError("dnode:%d, failed to config since %s ", cfgReq.dnodeId, terrstr()); - return -1; - } - SEpSet epSet = mndGetDnodeEpset(pDnode); - mndReleaseDnode(pMnode, pDnode); - - SDCfgDnodeReq dcfgReq = {0}; if (strcasecmp(cfgReq.config, "resetlog") == 0) { strcpy(dcfgReq.config, "resetlog"); @@ -839,7 +830,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { if (strncasecmp(cfgReq.config, optName, optLen) != 0) continue; const char *value = cfgReq.value; - int32_t flag = atoi(value); + int32_t flag = atoi(value); if (flag <= 0) { flag = atoi(cfgReq.config + optLen + 1); } @@ -861,16 +852,36 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { } } - int32_t bufLen = tSerializeSDCfgDnodeReq(NULL, 0, &dcfgReq); - void *pBuf = rpcMallocCont(bufLen); + int32_t code = -1; + SSdb *pSdb = pMnode->pSdb; + void *pIter = NULL; + while (1) { + SDnodeObj *pDnode = NULL; + pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode); + if (pIter == NULL) break; - if (pBuf == NULL) return -1; - tSerializeSDCfgDnodeReq(pBuf, bufLen, &dcfgReq); + if (pDnode->id == cfgReq.dnodeId || cfgReq.dnodeId == -1 || cfgReq.dnodeId == 0) { + SEpSet epSet = mndGetDnodeEpset(pDnode); + int32_t bufLen = tSerializeSDCfgDnodeReq(NULL, 0, &dcfgReq); + void *pBuf = rpcMallocCont(bufLen); + + if (pBuf != NULL) { + tSerializeSDCfgDnodeReq(pBuf, bufLen, &dcfgReq); + mInfo("dnode:%d, send config req to dnode, app:%p config:%s value:%s", cfgReq.dnodeId, pReq->info.ahandle, + dcfgReq.config, dcfgReq.value); + SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen}; + tmsgSendReq(&epSet, &rpcMsg); + code = 0; + } + } - mInfo("dnode:%d, send config req to dnode, app:%p config:%s value:%s", cfgReq.dnodeId, pReq->info.ahandle, - dcfgReq.config, dcfgReq.value); - SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen}; - return tmsgSendReq(&epSet, &rpcMsg); + sdbRelease(pSdb, pDnode); + } + + if (code == -1) { + terrno = TSDB_CODE_MND_DNODE_NOT_EXIST; + } + return code; } static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp) { diff --git a/source/dnode/mnode/impl/src/mndOffset.c b/source/dnode/mnode/impl/src/mndOffset.c index 00753de0ecf726b90613e46bd0afd5bb20f9d88e..9f6108004db0809b70907e13ca32988e6d278a48 100644 --- a/source/dnode/mnode/impl/src/mndOffset.c +++ b/source/dnode/mnode/impl/src/mndOffset.c @@ -281,7 +281,7 @@ static int32_t mndSetDropOffsetRedoLogs(SMnode *pMnode, STrans *pTrans, SMqOffse } int32_t mndDropOffsetByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { - int32_t code = -1; + int32_t code = 0; SSdb *pSdb = pMnode->pSdb; void *pIter = NULL; @@ -297,15 +297,15 @@ int32_t mndDropOffsetByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { if (mndSetDropOffsetCommitLogs(pMnode, pTrans, pOffset) < 0) { sdbRelease(pSdb, pOffset); - goto END; + sdbCancelFetch(pSdb, pIter); + code = -1; + break; } sdbRelease(pSdb, pOffset); } - code = 0; -END: - return code; + return code; } int32_t mndDropOffsetByTopic(SMnode *pMnode, STrans *pTrans, const char *topic) { diff --git a/source/dnode/mnode/impl/src/mndPrivilege.c b/source/dnode/mnode/impl/src/mndPrivilege.c index e4422c480f5b37874f20d36eb77ae99dbb027d51..151a2a64042bfab4cdbc5be38ef30b11680750a5 100644 --- a/source/dnode/mnode/impl/src/mndPrivilege.c +++ b/source/dnode/mnode/impl/src/mndPrivilege.c @@ -18,177 +18,20 @@ #include "mndDb.h" #include "mndUser.h" +#ifndef _PRIVILEGE int32_t mndInitPrivilege(SMnode *pMnode) { return 0; } - -void mndCleanupPrivilege(SMnode *pMnode) {} - -int32_t mndCheckOperPrivilege(SMnode *pMnode, const char *user, EOperType operType) { - int32_t code = 0; - SUserObj *pUser = mndAcquireUser(pMnode, user); - - if (pUser == NULL) { - terrno = TSDB_CODE_MND_NO_USER_FROM_CONN; - code = -1; - goto _OVER; - } - - if (pUser->superUser) { - goto _OVER; - } - - if (!pUser->enable) { - terrno = TSDB_CODE_MND_USER_DISABLED; - code = -1; - goto _OVER; - } - - switch (operType) { - case MND_OPER_CONNECT: - case MND_OPER_CREATE_FUNC: - case MND_OPER_DROP_FUNC: - case MND_OPER_SHOW_VARIBALES: - break; - default: - terrno = TSDB_CODE_MND_NO_RIGHTS; - code = -1; - } - -_OVER: - mndReleaseUser(pMnode, pUser); - return code; -} - -int32_t mndCheckAlterUserPrivilege(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter) { - if (pUser->superUser && pAlter->alterType != TSDB_ALTER_USER_PASSWD) { - terrno = TSDB_CODE_MND_NO_RIGHTS; - return -1; - } - - if (pOperUser->superUser) return 0; - - if (!pOperUser->enable) { - terrno = TSDB_CODE_MND_USER_DISABLED; - return -1; - } - - if (pAlter->alterType == TSDB_ALTER_USER_PASSWD) { - if (strcmp(pUser->user, pOperUser->user) == 0) { - if (pOperUser->sysInfo) return 0; - } - } - - terrno = TSDB_CODE_MND_NO_RIGHTS; - return -1; -} - -int32_t mndCheckShowPrivilege(SMnode *pMnode, const char *user, EShowType showType, const char *dbname) { - int32_t code = 0; - SUserObj *pUser = mndAcquireUser(pMnode, user); - - if (pUser == NULL) { - code = -1; - goto _OVER; - } - - if (pUser->superUser) { - goto _OVER; - } - - if (!pUser->enable) { - terrno = TSDB_CODE_MND_USER_DISABLED; - code = -1; - goto _OVER; - } - - if (pUser->sysInfo) { - goto _OVER; - } - - switch (showType) { - case TSDB_MGMT_TABLE_DB: - case TSDB_MGMT_TABLE_STB: - case TSDB_MGMT_TABLE_INDEX: - case TSDB_MGMT_TABLE_STREAMS: - case TSDB_MGMT_TABLE_CONSUMERS: - case TSDB_MGMT_TABLE_TOPICS: - case TSDB_MGMT_TABLE_SUBSCRIPTIONS: - case TSDB_MGMT_TABLE_FUNC: - case TSDB_MGMT_TABLE_QUERIES: - case TSDB_MGMT_TABLE_CONNS: - case TSDB_MGMT_TABLE_APPS: - case TSDB_MGMT_TABLE_TRANS: - code = 0; - break; - default: - terrno = TSDB_CODE_MND_NO_RIGHTS; - code = -1; - goto _OVER; - } - - if (showType == TSDB_MGMT_TABLE_STB || showType == TSDB_MGMT_TABLE_VGROUP || showType == TSDB_MGMT_TABLE_INDEX) { - code = mndCheckDbPrivilegeByName(pMnode, user, MND_OPER_READ_OR_WRITE_DB, dbname); - } - -_OVER: - mndReleaseUser(pMnode, pUser); - return code; +void mndCleanupPrivilege(SMnode *pMnode) {} +int32_t mndCheckOperPrivilege(SMnode *pMnode, const char *user, EOperType operType) { return 0; } +int32_t mndCheckAlterUserPrivilege(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter) { return 0; } +int32_t mndCheckShowPrivilege(SMnode *pMnode, const char *user, EShowType showType, const char *dbname) { return 0; } +int32_t mndCheckDbPrivilege(SMnode *pMnode, const char *user, EOperType operType, SDbObj *pDb) { return 0; } +int32_t mndCheckDbPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *dbname) { + return 0; } - -int32_t mndCheckDbPrivilege(SMnode *pMnode, const char *user, EOperType operType, SDbObj *pDb) { - int32_t code = 0; - SUserObj *pUser = mndAcquireUser(pMnode, user); - - if (pUser == NULL) { - code = -1; - goto _OVER; - } - - if (pUser->superUser) goto _OVER; - - if (!pUser->enable) { - terrno = TSDB_CODE_MND_USER_DISABLED; - code = -1; - goto _OVER; - } - - if (operType == MND_OPER_CREATE_DB) { - if (pUser->sysInfo) goto _OVER; - } - - if (operType == MND_OPER_ALTER_DB || operType == MND_OPER_DROP_DB || operType == MND_OPER_COMPACT_DB || - operType == MND_OPER_TRIM_DB) { - if (strcmp(pUser->user, pDb->createUser) == 0 && pUser->sysInfo) goto _OVER; - } - - if (operType == MND_OPER_USE_DB || operType == MND_OPER_READ_OR_WRITE_DB) { - if (strcmp(pUser->user, pDb->createUser) == 0) goto _OVER; - if (taosHashGet(pUser->readDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER; - if (taosHashGet(pUser->writeDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER; - } - - if (operType == MND_OPER_WRITE_DB) { - if (strcmp(pUser->user, pDb->createUser) == 0) goto _OVER; - if (taosHashGet(pUser->writeDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER; - } - - if (operType == MND_OPER_READ_DB) { - if (strcmp(pUser->user, pDb->createUser) == 0) goto _OVER; - if (taosHashGet(pUser->readDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER; - } - - terrno = TSDB_CODE_MND_NO_RIGHTS; - code = -1; - -_OVER: - mndReleaseUser(pMnode, pUser); - return code; +int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUserAuthRsp *pRsp) { + memcpy(pRsp->user, pUser->user, TSDB_USER_LEN); + pRsp->superAuth = 1; + pRsp->version = pUser->authVersion; + return 0; } - -int32_t mndCheckDbPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *dbname) { - SDbObj *pDb = mndAcquireDb(pMnode, dbname); - if (pDb == NULL) return -1; - - int32_t code = mndCheckDbPrivilege(pMnode, user, operType, pDb); - mndReleaseDb(pMnode, pDb); - return code; -} \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index f6ecd4493d7d7002398f2f3ef3d7f14f4bf75a23..4b57f45631f02133726d4306539ba66f91928cc3 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -240,7 +240,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { if (strncmp(connReq.passwd, pUser->pass, TSDB_PASSWORD_LEN - 1) != 0) { mGError("user:%s, failed to login from %s since invalid pass, input:%s", pReq->info.conn.user, ip, connReq.passwd); - code = TSDB_CODE_RPC_AUTH_FAILURE; + code = TSDB_CODE_MND_AUTH_FAILURE; goto _OVER; } diff --git a/source/dnode/mnode/impl/src/mndQuery.c b/source/dnode/mnode/impl/src/mndQuery.c index 5a527b994e2c8eb130fe5c16f294e7a9ef8342f2..2beeb10335b02c6d08a75c0f2c498c825e56de54 100644 --- a/source/dnode/mnode/impl/src/mndQuery.c +++ b/source/dnode/mnode/impl/src/mndQuery.c @@ -63,6 +63,106 @@ int32_t mndProcessQueryMsg(SRpcMsg *pMsg) { return code; } +int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) { + int32_t code = 0; + int32_t offset = 0; + int32_t rspSize = 0; + SBatchReq *batchReq = (SBatchReq*)pMsg->pCont; + int32_t msgNum = ntohl(batchReq->msgNum); + offset += sizeof(SBatchReq); + SBatchMsg req = {0}; + SBatchRsp rsp = {0}; + SRpcMsg reqMsg = *pMsg; + SRpcMsg rspMsg = {0}; + void* pRsp = NULL; + SMnode *pMnode = pMsg->info.node; + + SArray* batchRsp = taosArrayInit(msgNum, sizeof(SBatchRsp)); + if (NULL == batchRsp) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + + for (int32_t i = 0; i < msgNum; ++i) { + req.msgType = ntohl(*(int32_t*)((char*)pMsg->pCont + offset)); + offset += sizeof(req.msgType); + + req.msgLen = ntohl(*(int32_t*)((char*)pMsg->pCont + offset)); + offset += sizeof(req.msgLen); + + req.msg = (char*)pMsg->pCont + offset; + offset += req.msgLen; + + reqMsg.msgType = req.msgType; + reqMsg.pCont = req.msg; + reqMsg.contLen = req.msgLen; + reqMsg.info.rsp = NULL; + reqMsg.info.rspLen = 0; + + MndMsgFp fp = pMnode->msgFp[TMSG_INDEX(req.msgType)]; + if (fp == NULL) { + mError("msg:%p, failed to get msg handle, app:%p type:%s", pMsg, pMsg->info.ahandle, TMSG_INFO(pMsg->msgType)); + terrno = TSDB_CODE_MSG_NOT_PROCESSED; + return -1; + } + + if ((*fp)(&reqMsg)) { + rsp.rspCode = terrno; + } else { + rsp.rspCode = 0; + } + rsp.reqType = reqMsg.msgType; + rsp.msgLen = reqMsg.info.rspLen; + rsp.msg = reqMsg.info.rsp; + + taosArrayPush(batchRsp, &rsp); + + rspSize += sizeof(rsp) + rsp.msgLen - POINTER_BYTES; + } + + rspSize += sizeof(int32_t); + offset = 0; + + pRsp = rpcMallocCont(rspSize); + if (pRsp == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + + *(int32_t*)((char*)pRsp + offset) = htonl(msgNum); + offset += sizeof(msgNum); + for (int32_t i = 0; i < msgNum; ++i) { + SBatchRsp *p = taosArrayGet(batchRsp, i); + + *(int32_t*)((char*)pRsp + offset) = htonl(p->reqType); + offset += sizeof(p->reqType); + *(int32_t*)((char*)pRsp + offset) = htonl(p->msgLen); + offset += sizeof(p->msgLen); + *(int32_t*)((char*)pRsp + offset) = htonl(p->rspCode); + offset += sizeof(p->rspCode); + memcpy((char*)pRsp + offset, p->msg, p->msgLen); + offset += p->msgLen; + + rpcFreeCont(p->msg); + } + + taosArrayDestroy(batchRsp); + batchRsp = NULL; + +_exit: + + pMsg->info.rsp = pRsp; + pMsg->info.rspLen = rspSize; + + if (code) { + mError("mnd get batch meta failed cause of %s", tstrerror(code)); + } + + taosArrayDestroyEx(batchRsp, tFreeSBatchRsp); + + return code; +} + int32_t mndInitQuery(SMnode *pMnode) { if (qWorkerInit(NODE_TYPE_MNODE, MNODE_HANDLE, NULL, (void **)&pMnode->pQuery, &pMnode->msgCb) != 0) { mError("failed to init qworker in mnode since %s", terrstr()); @@ -76,6 +176,7 @@ int32_t mndInitQuery(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_SCH_MERGE_FETCH, mndProcessQueryMsg); mndSetMsgHandle(pMnode, TDMT_SCH_DROP_TASK, mndProcessQueryMsg); mndSetMsgHandle(pMnode, TDMT_SCH_QUERY_HEARTBEAT, mndProcessQueryMsg); + mndSetMsgHandle(pMnode, TDMT_MND_BATCH_META, mndProcessBatchMetaMsg); return 0; } diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index a46938590e19d2465d66eec9d012caa9172c6ca3..9d7fa537bb3ed9fffde4dc5b49e37e7e0e4afc84 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -114,18 +114,26 @@ int32_t mndAddSinkToTask(SMnode* pMnode, SStreamObj* pStream, SStreamTask* pTask int32_t mndAddDispatcherToInnerTask(SMnode* pMnode, SStreamObj* pStream, SStreamTask* pTask) { pTask->sinkType = TASK_SINK__NONE; + + bool isShuffle = false; + if (pStream->fixedSinkVgId == 0) { - pTask->dispatchType = TASK_DISPATCH__SHUFFLE; - pTask->dispatchMsgType = TDMT_STREAM_TASK_DISPATCH; SDbObj* pDb = mndAcquireDb(pMnode, pStream->targetDb); ASSERT(pDb); - - if (mndExtractDbInfo(pMnode, pDb, &pTask->shuffleDispatcher.dbInfo, NULL) < 0) { - ASSERT(0); - return -1; + if (pDb->cfg.numOfVgroups > 1) { + isShuffle = true; + pTask->dispatchType = TASK_DISPATCH__SHUFFLE; + pTask->dispatchMsgType = TDMT_STREAM_TASK_DISPATCH; + if (mndExtractDbInfo(pMnode, pDb, &pTask->shuffleDispatcher.dbInfo, NULL) < 0) { + ASSERT(0); + return -1; + } } + sdbRelease(pMnode->pSdb, pDb); + } + if (isShuffle) { memcpy(pTask->shuffleDispatcher.stbFullName, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN); SArray* pVgs = pTask->shuffleDispatcher.dbInfo.pVgroupInfos; int32_t sz = taosArrayGetSize(pVgs); @@ -383,10 +391,12 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { // exec pInnerTask->execType = TASK_EXEC__PIPE; +#if 0 SDbObj* pSourceDb = mndAcquireDb(pMnode, pStream->sourceDb); ASSERT(pDbObj != NULL); sdbRelease(pSdb, pSourceDb); pInnerTask->numOfVgroups = pSourceDb->cfg.numOfVgroups; +#endif if (tsSchedStreamToSnode) { SSnodeObj* pSnode = mndSchedFetchOneSnode(pMnode); diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 682e78acc0e7be19931520fd6db259af48837e87..aab0c7e81568d9498c80118a4fb59b5a64ae6f3d 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -641,6 +641,7 @@ static int32_t mndSetCreateStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj action.contLen = contLen; action.msgType = TDMT_VND_CREATE_STB; action.acceptableCode = TSDB_CODE_TDB_STB_ALREADY_EXIST; + action.retryCode = TSDB_CODE_TDB_STB_NOT_EXIST; if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); sdbCancelFetch(pSdb, pIter); @@ -805,7 +806,7 @@ _OVER: } int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) { - mndTransSetDbName(pTrans, pDb->name, NULL); + mndTransSetDbName(pTrans, pDb->name, pStb->name); if (mndSetCreateStbRedoLogs(pMnode, pTrans, pDb, pStb) != 0) return -1; if (mndSetCreateStbUndoLogs(pMnode, pTrans, pDb, pStb) != 0) return -1; if (mndSetCreateStbCommitLogs(pMnode, pTrans, pDb, pStb) != 0) return -1; @@ -1612,7 +1613,7 @@ static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbOb if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to alter stb:%s", pTrans->id, pStb->name); - mndTransSetDbName(pTrans, pDb->name, NULL); + mndTransSetDbName(pTrans, pDb->name, pStb->name); if (needRsp) { void *pCont = NULL; @@ -1811,7 +1812,7 @@ static int32_t mndDropStb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *p if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop stb:%s", pTrans->id, pStb->name); - mndTransSetDbName(pTrans, pDb->name, NULL); + mndTransSetDbName(pTrans, pDb->name, pStb->name); if (mndSetDropStbRedoLogs(pMnode, pTrans, pStb) != 0) goto _OVER; if (mndSetDropStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER; diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index 245dc413f1c2e701e9ced22f353cf6a78f9815f1..8feed476cd6ed217e6d5b91ec948bcad0abbcc8f 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -824,7 +824,7 @@ int32_t mndSetDropSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj } int32_t mndDropSubByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { - int32_t code = -1; + int32_t code = 0; SSdb *pSdb = pMnode->pSdb; void *pIter = NULL; @@ -840,12 +840,14 @@ int32_t mndDropSubByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { if (mndSetDropSubCommitLogs(pMnode, pTrans, pSub) < 0) { sdbRelease(pSdb, pSub); - goto END; + sdbCancelFetch(pSdb, pIter); + code = -1; + break; } + + sdbRelease(pSdb, pSub); } - code = 0; -END: return code; } diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 7acfc95bfc2f658e0667e93a8ab5876eeb30dfd5..7e3e5a9838839b596e5ae5bf07bd3d19a2820d3f 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -833,7 +833,7 @@ static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter) { } int32_t mndDropTopicByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { - int32_t code = -1; + int32_t code = 0; SSdb *pSdb = pMnode->pSdb; void *pIter = NULL; @@ -848,11 +848,14 @@ int32_t mndDropTopicByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { } if (mndSetDropTopicCommitLogs(pMnode, pTrans, pTopic) < 0) { - goto END; + sdbRelease(pSdb, pTopic); + sdbCancelFetch(pSdb, pIter); + code = -1; + break; } + + sdbRelease(pSdb, pTopic); } - code = 0; -END: return code; } diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 096a1534fdde3a12479ef295fbf459cca2973656..b2a0e6aac83f879bb1ba2d802894179d85d19d5a 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -127,8 +127,8 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { SDB_SET_INT8(pRaw, dataPos, 0, _OVER) SDB_SET_INT8(pRaw, dataPos, 0, _OVER) SDB_SET_INT64(pRaw, dataPos, pTrans->createdTime, _OVER) - SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname1, TSDB_DB_FNAME_LEN, _OVER) - SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname2, TSDB_DB_FNAME_LEN, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname1, TSDB_TABLE_FNAME_LEN, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname2, TSDB_TABLE_FNAME_LEN, _OVER) SDB_SET_INT32(pRaw, dataPos, pTrans->redoActionPos, _OVER) int32_t redoActionNum = taosArrayGetSize(pTrans->redoActions); @@ -290,8 +290,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { pTrans->exec = exec; pTrans->oper = oper; SDB_GET_INT64(pRaw, dataPos, &pTrans->createdTime, _OVER) - SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname1, TSDB_DB_FNAME_LEN, _OVER) - SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname2, TSDB_DB_FNAME_LEN, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname1, TSDB_TABLE_FNAME_LEN, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname2, TSDB_TABLE_FNAME_LEN, _OVER) SDB_GET_INT32(pRaw, dataPos, &pTrans->redoActionPos, _OVER) SDB_GET_INT32(pRaw, dataPos, &redoActionNum, _OVER) SDB_GET_INT32(pRaw, dataPos, &undoActionNum, _OVER) @@ -727,10 +727,10 @@ int32_t mndSetRpcInfoForDbTrans(SMnode *pMnode, SRpcMsg *pMsg, EOperType oper, c void mndTransSetDbName(STrans *pTrans, const char *dbname1, const char *dbname2) { if (dbname1 != NULL) { - memcpy(pTrans->dbname1, dbname1, TSDB_DB_FNAME_LEN); + tstrncpy(pTrans->dbname1, dbname1, TSDB_TABLE_FNAME_LEN); } if (dbname2 != NULL) { - memcpy(pTrans->dbname2, dbname2, TSDB_DB_FNAME_LEN); + tstrncpy(pTrans->dbname2, dbname2, TSDB_TABLE_FNAME_LEN); } } @@ -1287,13 +1287,26 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) { mDebug("trans:%d, stage keep on redoAction since %s", pTrans->id, tstrerror(code)); continueExec = false; } else { + pTrans->failedTimes++; pTrans->code = terrno; if (pTrans->policy == TRN_POLICY_ROLLBACK) { + if (pTrans->lastAction != 0) { + STransAction *pAction = taosArrayGet(pTrans->redoActions, pTrans->lastAction); + if (pAction->retryCode != 0 && pAction->retryCode != pAction->errCode) { + if (pTrans->failedTimes < 6) { + mError("trans:%d, stage keep on redoAction since action:%d code:0x%x not 0x%x, failedTimes:%d", pTrans->id, + pTrans->lastAction, pTrans->code, pAction->retryCode, pTrans->failedTimes); + taosMsleep(1000); + continueExec = true; + return true; + } + } + } + pTrans->stage = TRN_STAGE_ROLLBACK; mError("trans:%d, stage from redoAction to rollback since %s", pTrans->id, terrstr()); continueExec = true; } else { - pTrans->failedTimes++; mError("trans:%d, stage keep on redoAction since %s, failedTimes:%d", pTrans->id, terrstr(), pTrans->failedTimes); continueExec = false; } diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 0452659d47ab333be6de7da5350787b7c09102a9..5da119bb30af5bb27fb40d1dc42391893fb98c43 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -15,8 +15,8 @@ #define _DEFAULT_SOURCE #include "mndUser.h" -#include "mndPrivilege.h" #include "mndDb.h" +#include "mndPrivilege.h" #include "mndShow.h" #include "mndTrans.h" #include "tbase64.h" @@ -408,7 +408,7 @@ static int32_t mndAlterUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SRpc return 0; } -static SHashObj *mndDupDbHash(SHashObj *pOld) { +SHashObj *mndDupDbHash(SHashObj *pOld) { SHashObj *pNew = taosHashInit(taosHashGetSize(pOld), taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); if (pNew == NULL) { @@ -662,38 +662,6 @@ _OVER: return code; } -static int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUserAuthRsp *pRsp) { - memcpy(pRsp->user, pUser->user, TSDB_USER_LEN); - pRsp->superAuth = pUser->superUser; - pRsp->version = pUser->authVersion; - taosRLockLatch(&pUser->lock); - pRsp->readDbs = mndDupDbHash(pUser->readDbs); - pRsp->writeDbs = mndDupDbHash(pUser->writeDbs); - taosRUnLockLatch(&pUser->lock); - pRsp->createdDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); - if (NULL == pRsp->createdDbs) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - SSdb *pSdb = pMnode->pSdb; - void *pIter = NULL; - while (1) { - SDbObj *pDb = NULL; - pIter = sdbFetch(pSdb, SDB_DB, pIter, (void **)&pDb); - if (pIter == NULL) break; - - if (strcmp(pDb->createUser, pUser->user) == 0) { - int32_t len = strlen(pDb->name) + 1; - taosHashPut(pRsp->createdDbs, pDb->name, len, pDb->name, len); - } - - sdbRelease(pSdb, pDb); - } - - return 0; -} - static int32_t mndProcessGetUserAuthReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; int32_t code = -1; diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 3eb3a6cd1fd1f3423fe50829d307a1dfea815272..0567ec4e1425a1815af45448505a47cfada71259 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -214,7 +214,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg createReq.daysToKeep2 = pDb->cfg.daysToKeep2; createReq.minRows = pDb->cfg.minRows; createReq.maxRows = pDb->cfg.maxRows; - createReq.fsyncPeriod = pDb->cfg.fsyncPeriod; + createReq.walFsyncPeriod = pDb->cfg.walFsyncPeriod; createReq.walLevel = pDb->cfg.walLevel; createReq.precision = pDb->cfg.precision; createReq.compression = pDb->cfg.compression; @@ -230,6 +230,10 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg createReq.standby = standby; createReq.isTsma = pVgroup->isTsma; createReq.pTsma = pVgroup->pTsma; + createReq.walRetentionPeriod = pDb->cfg.walRetentionPeriod; + createReq.walRetentionSize = pDb->cfg.walRetentionSize; + createReq.walRollPeriod = pDb->cfg.walRollPeriod; + createReq.walSegmentSize = pDb->cfg.walSegmentSize; for (int32_t v = 0; v < pVgroup->replica; ++v) { SReplica *pReplica = &createReq.replicas[v]; @@ -282,7 +286,7 @@ void *mndBuildAlterVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_ alterReq.daysToKeep0 = pDb->cfg.daysToKeep0; alterReq.daysToKeep1 = pDb->cfg.daysToKeep1; alterReq.daysToKeep2 = pDb->cfg.daysToKeep2; - alterReq.fsyncPeriod = pDb->cfg.fsyncPeriod; + alterReq.walFsyncPeriod = pDb->cfg.walFsyncPeriod; alterReq.walLevel = pDb->cfg.walLevel; alterReq.strict = pDb->cfg.strict; alterReq.cacheLast = pDb->cfg.cacheLast; diff --git a/source/dnode/mnode/impl/test/db/db.cpp b/source/dnode/mnode/impl/test/db/db.cpp index 0fb8e9d5305f597d687fbf271a576bebe1a12e06..06916b375c41bb17c671d80f8d01b81f36a1ded8 100644 --- a/source/dnode/mnode/impl/test/db/db.cpp +++ b/source/dnode/mnode/impl/test/db/db.cpp @@ -44,7 +44,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { createReq.daysToKeep2 = 3650; createReq.minRows = 100; createReq.maxRows = 4096; - createReq.fsyncPeriod = 3000; + createReq.walFsyncPeriod = 3000; createReq.walLevel = 1; createReq.precision = 0; createReq.compression = 2; @@ -81,7 +81,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { alterdbReq.daysToKeep0 = -1; alterdbReq.daysToKeep1 = -1; alterdbReq.daysToKeep2 = -1; - alterdbReq.fsyncPeriod = 4000; + alterdbReq.walFsyncPeriod = 4000; alterdbReq.walLevel = 2; alterdbReq.strict = 1; alterdbReq.cacheLast = 1; @@ -140,7 +140,7 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) { createReq.daysToKeep2 = 3650; createReq.minRows = 100; createReq.maxRows = 4096; - createReq.fsyncPeriod = 3000; + createReq.walFsyncPeriod = 3000; createReq.walLevel = 1; createReq.precision = 0; createReq.compression = 2; diff --git a/source/dnode/mnode/impl/test/sma/sma.cpp b/source/dnode/mnode/impl/test/sma/sma.cpp index ce6954279f8da60e355229f19274f592657da309..06bb735f544babcad8bc7a90ff60feddeb97279f 100644 --- a/source/dnode/mnode/impl/test/sma/sma.cpp +++ b/source/dnode/mnode/impl/test/sma/sma.cpp @@ -49,7 +49,7 @@ void* MndTestSma::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { createReq.daysToKeep2 = 3650 * 1440; createReq.minRows = 100; createReq.maxRows = 4096; - createReq.fsyncPeriod = 3000; + createReq.walFsyncPeriod = 3000; createReq.walLevel = 1; createReq.precision = 0; createReq.compression = 2; diff --git a/source/dnode/mnode/impl/test/stb/stb.cpp b/source/dnode/mnode/impl/test/stb/stb.cpp index dfdd8f3a49703ac413418993ce3351d35782ca62..d275231c706e010acb3a694d6ff343a11f7dacdc 100644 --- a/source/dnode/mnode/impl/test/stb/stb.cpp +++ b/source/dnode/mnode/impl/test/stb/stb.cpp @@ -50,7 +50,7 @@ void* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { createReq.daysToKeep2 = 3650; createReq.minRows = 100; createReq.maxRows = 4096; - createReq.fsyncPeriod = 3000; + createReq.walFsyncPeriod = 3000; createReq.walLevel = 1; createReq.precision = 0; createReq.compression = 2; diff --git a/source/dnode/mnode/impl/test/topic/topic.cpp b/source/dnode/mnode/impl/test/topic/topic.cpp index 353cedf636bffa57e5ff6e3bc341ed18f2904659..84b3a21a8ff331d00d4795403fe362095c0f8c28 100644 --- a/source/dnode/mnode/impl/test/topic/topic.cpp +++ b/source/dnode/mnode/impl/test/topic/topic.cpp @@ -42,7 +42,7 @@ void* MndTestTopic::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { createReq.daysToKeep2 = 3650 * 1440; createReq.minRows = 100; createReq.maxRows = 4096; - createReq.fsyncPeriod = 3000; + createReq.walFsyncPeriod = 3000; createReq.walLevel = 1; createReq.precision = 0; createReq.compression = 2; diff --git a/source/dnode/mnode/impl/test/user/user.cpp b/source/dnode/mnode/impl/test/user/user.cpp index d8b6964114f485d5b99ce5484d4d0c0960f0feef..dd2bda6b190700688c38d527a07a9ee615e70913 100644 --- a/source/dnode/mnode/impl/test/user/user.cpp +++ b/source/dnode/mnode/impl/test/user/user.cpp @@ -309,7 +309,7 @@ TEST_F(MndTestUser, 03_Alter_User) { createReq.daysToKeep2 = 3650 * 1440; createReq.minRows = 100; createReq.maxRows = 4096; - createReq.fsyncPeriod = 3000; + createReq.walFsyncPeriod = 3000; createReq.walLevel = 1; createReq.precision = 0; createReq.compression = 2; diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 0a5fe1001cc4f177b071643f5b6070675220a361..352fb51a534d0b1b59a9358b462f435ca0a1bd07 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -179,7 +179,7 @@ static int32_t sndProcessTaskRecoverRsp(SSnode *pNode, SRpcMsg *pMsg) { SStreamMeta *pMeta = pNode->pMeta; SStreamTaskRecoverRsp *pRsp = pMsg->pCont; - int32_t taskId = pRsp->taskId; + int32_t taskId = pRsp->rspTaskId; SStreamTask *pTask = *(SStreamTask **)taosHashGet(pMeta->pHash, &taskId, sizeof(int32_t)); streamProcessRecoverRsp(pTask, pRsp); return 0; diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 04bf6bcc2b50ccf1a02ace316234acb78041d446..d8c84e952b43a5c0f0cfa64058d8f4a6fb77ca3e 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -371,8 +371,8 @@ struct SBlockIdx { struct SMapData { int32_t nItem; - int32_t *aOffset; int32_t nData; + int32_t *aOffset; uint8_t *pData; }; diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index 984b34814d9389374b36682e1b1e857e7f90ac23..dd1facb462ceb2b543f4a2ea443c9a886a6b13ca 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -78,8 +78,9 @@ void vnodeBufPoolReset(SVBufPool* pPool); // vnodeQuery.c int32_t vnodeQueryOpen(SVnode* pVnode); void vnodeQueryClose(SVnode* pVnode); -int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg); -int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg); +int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg, bool direct); +int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg, bool direct); +int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg); // vnodeCommit.c int32_t vnodeBegin(SVnode* pVnode); diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index b7c23c85273ac7a4fae956ed7a921c6a911d50cb..9ed2b25fdf203507e46cb8a79f8c3340bcba5c4f 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -268,6 +268,7 @@ struct SVnode { tsem_t canCommit; int64_t sync; int32_t blockCount; + bool restored; tsem_t syncSem; SQHandle* pQuery; }; diff --git a/source/dnode/vnode/src/meta/metaOpen.c b/source/dnode/vnode/src/meta/metaOpen.c index 59df35d5542585c6d9f24ae2f64d2b1dfc48e42e..7c7d14e33777a3e2b9905e6309c1ba12bbb6f40e 100644 --- a/source/dnode/vnode/src/meta/metaOpen.c +++ b/source/dnode/vnode/src/meta/metaOpen.c @@ -180,11 +180,41 @@ int metaClose(SMeta *pMeta) { return 0; } -int32_t metaRLock(SMeta *pMeta) { return taosThreadRwlockRdlock(&pMeta->lock); } +int32_t metaRLock(SMeta *pMeta) { + int32_t ret = 0; -int32_t metaWLock(SMeta *pMeta) { return taosThreadRwlockWrlock(&pMeta->lock); } + metaDebug("meta rlock %p B", &pMeta->lock); -int32_t metaULock(SMeta *pMeta) { return taosThreadRwlockUnlock(&pMeta->lock); } + ret = taosThreadRwlockRdlock(&pMeta->lock); + + metaDebug("meta rlock %p E", &pMeta->lock); + + return ret; +} + +int32_t metaWLock(SMeta *pMeta) { + int32_t ret = 0; + + metaDebug("meta wlock %p B", &pMeta->lock); + + ret = taosThreadRwlockWrlock(&pMeta->lock); + + metaDebug("meta wlock %p E", &pMeta->lock); + + return ret; +} + +int32_t metaULock(SMeta *pMeta) { + int32_t ret = 0; + + metaDebug("meta ulock %p B", &pMeta->lock); + + ret = taosThreadRwlockUnlock(&pMeta->lock); + + metaDebug("meta ulock %p E", &pMeta->lock); + + return ret; +} static int tbDbKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2) { STbDbKey *pTbDbKey1 = (STbDbKey *)pKey1; @@ -259,7 +289,7 @@ static int ctbIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL static int tagIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2) { STagIdxKey *pTagIdxKey1 = (STagIdxKey *)pKey1; STagIdxKey *pTagIdxKey2 = (STagIdxKey *)pKey2; - tb_uid_t uid1, uid2; + tb_uid_t uid1 = 0, uid2 = 0; int c; // compare suid @@ -287,14 +317,15 @@ static int tagIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL // all not NULL, compr tag vals c = doCompare(pTagIdxKey1->data, pTagIdxKey2->data, pTagIdxKey1->type, 0); if (c) return c; + } - if (IS_VAR_DATA_TYPE(pTagIdxKey1->type)) { - uid1 = *(tb_uid_t *)(pTagIdxKey1->data + varDataTLen(pTagIdxKey1->data)); - uid2 = *(tb_uid_t *)(pTagIdxKey2->data + varDataTLen(pTagIdxKey2->data)); - } else { - uid1 = *(tb_uid_t *)(pTagIdxKey1->data + tDataTypes[pTagIdxKey1->type].bytes); - uid2 = *(tb_uid_t *)(pTagIdxKey2->data + tDataTypes[pTagIdxKey2->type].bytes); - } + // both null or tag values are equal, then continue to compare uids + if (IS_VAR_DATA_TYPE(pTagIdxKey1->type)) { + uid1 = *(tb_uid_t *)(pTagIdxKey1->data + varDataTLen(pTagIdxKey1->data)); + uid2 = *(tb_uid_t *)(pTagIdxKey2->data + varDataTLen(pTagIdxKey2->data)); + } else { + uid1 = *(tb_uid_t *)(pTagIdxKey1->data + tDataTypes[pTagIdxKey1->type].bytes); + uid2 = *(tb_uid_t *)(pTagIdxKey2->data + tDataTypes[pTagIdxKey2->type].bytes); } // compare uid diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index b6cf08ddf89ca52cce705512705eca4e1dee07bf..26c81976dcfe58fe574789eb58dfd9c9e6c81316 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -178,7 +178,7 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { if (metaGetTableEntryByName(&mr, pReq->name) == 0) { // TODO: just for pass case #if 0 - terrno = TSDB_CODE_TDB_TABLE_ALREADY_EXIST; + terrno = TSDB_CODE_TDB_STB_ALREADY_EXIST; metaReaderClear(&mr); return -1; #else @@ -223,7 +223,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb // check if super table exists rc = tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pData, &nData); if (rc < 0 || *(tb_uid_t *)pData != pReq->suid) { - terrno = TSDB_CODE_VND_TABLE_NOT_EXIST; + terrno = TSDB_CODE_TDB_STB_NOT_EXIST; return -1; } @@ -293,7 +293,10 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn); ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c); if (ret < 0 || c) { - ASSERT(0); + tdbTbcClose(pUidIdxc); + + terrno = TSDB_CODE_TDB_STB_NOT_EXIST; + // ASSERT(0); return -1; } @@ -980,6 +983,9 @@ static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) { tbDbKey.version = pME->version; tbDbKey.uid = pME->uid; + metaDebug("vgId:%d, start to save table version:%" PRId64 "uid: %" PRId64, TD_VID(pMeta->pVnode), pME->version, + pME->uid); + pKey = &tbDbKey; kLen = sizeof(tbDbKey); @@ -1012,6 +1018,9 @@ static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) { return 0; _err: + metaError("vgId:%d, failed to save table version:%" PRId64 "uid: %" PRId64 " %s", TD_VID(pMeta->pVnode), pME->version, + pME->uid, tstrerror(terrno)); + taosMemoryFree(pVal); return -1; } diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index a6fde1e2d2e68c9ca44ec3dde40a4c112d3b27ff..3505711cd0f7a338f574951aea5f684f8fb4ce68 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -599,20 +599,20 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche SSubmitReq *pReq = NULL; // TODO: the schema update should be handled if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, SMA_VID(pSma), suid) < 0) { - smaError("vgId:%d, build submit req for rsma table %" PRIi64 "l evel %" PRIi8 " failed since %s", SMA_VID(pSma), + smaError("vgId:%d, build submit req for rsma stable %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), suid, pItem->level, terrstr()); goto _err; } if (pReq && tdProcessSubmitReq(sinkTsdb, output->info.version, pReq) < 0) { taosMemoryFreeClear(pReq); - smaError("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", + smaError("vgId:%d, process submit req for rsma stable %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), suid, pItem->level, terrstr()); goto _err; } - smaDebug("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " version:%"PRIi64, SMA_VID(pSma), - suid, pItem->level, output->info.version); + smaDebug("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " version:%" PRIi64, + SMA_VID(pSma), suid, pItem->level, output->info.version); taosMemoryFreeClear(pReq); taosArrayClear(pResult); @@ -644,7 +644,7 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType smaDebug("vgId:%d, execute rsma %" PRIi8 " task for qTaskInfo:%p suid:%" PRIu64, SMA_VID(pSma), level, pItem->taskInfo, suid); - if (qSetStreamInput(pItem->taskInfo, pMsg, inputType, true) < 0) { // INPUT__DATA_SUBMIT + if (qSetMultiStreamInput(pItem->taskInfo, pMsg, 1, inputType) < 0) { // INPUT__DATA_SUBMIT smaError("vgId:%d, rsma % " PRIi8 " qSetStreamInput failed since %s", SMA_VID(pSma), level, tstrerror(terrno)); return TSDB_CODE_FAILED; } @@ -1329,7 +1329,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { tdRefRSmaInfo(pSma, pRSmaInfo); SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL}; - qSetStreamInput(pItem->taskInfo, &dataBlock, STREAM_INPUT__DATA_BLOCK, false); + qSetMultiStreamInput(pItem->taskInfo, &dataBlock, 1, STREAM_INPUT__DATA_BLOCK); tdRSmaFetchAndSubmitResult(pItem, pRSmaInfo->pTSchema, pRSmaInfo->suid, pStat, STREAM_INPUT__DATA_BLOCK); tdUnRefRSmaInfo(pSma, pRSmaInfo); @@ -1356,4 +1356,4 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { _end: tdReleaseSmaRef(smaMgmt.rsetId, pItem->refId, __func__, __LINE__); -} \ No newline at end of file +} diff --git a/source/dnode/vnode/src/sma/smaSnapshot.c b/source/dnode/vnode/src/sma/smaSnapshot.c new file mode 100644 index 0000000000000000000000000000000000000000..21dfd8a32d617a2674940c483287506bdf7a8852 --- /dev/null +++ b/source/dnode/vnode/src/sma/smaSnapshot.c @@ -0,0 +1,288 @@ +/* + * 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 "sma.h" + +static int32_t rsmaSnapReadQTaskInfo(SRsmaSnapReader* pReader, uint8_t** ppData); +static int32_t rsmaSnapWriteQTaskInfo(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData); + +// SRsmaSnapReader ======================================== +struct SRsmaSnapReader { + SSma* pSma; + int64_t sver; + int64_t ever; + + // for data file + int8_t rsmaDataDone[TSDB_RETENTION_L2]; + STsdbSnapReader* pDataReader[TSDB_RETENTION_L2]; + + // for qtaskinfo file + int8_t qTaskDone; + SQTaskFReader* pQTaskFReader; +}; + +int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapReader** ppReader) { + int32_t code = 0; + SRsmaSnapReader* pReader = NULL; + + // alloc + pReader = (SRsmaSnapReader*)taosMemoryCalloc(1, sizeof(*pReader)); + if (pReader == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + pReader->pSma = pSma; + pReader->sver = sver; + pReader->ever = ever; + + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + if (pSma->pRSmaTsdb[i]) { + code = tsdbSnapReaderOpen(pSma->pRSmaTsdb[i], sver, ever, &pReader->pDataReader[i]); + if (code < 0) { + goto _err; + } + } + } + *ppReader = pReader; + smaInfo("vgId:%d vnode snapshot rsma reader opened succeed", SMA_VID(pSma)); + return TSDB_CODE_SUCCESS; +_err: + smaError("vgId:%d vnode snapshot rsma reader opened failed since %s", SMA_VID(pSma), tstrerror(code)); + return TSDB_CODE_FAILED; +} + +static int32_t rsmaSnapReadQTaskInfo(SRsmaSnapReader* pReader, uint8_t** ppData) { + int32_t code = 0; + SSma* pSma = pReader->pSma; + +_exit: + smaInfo("vgId:%d vnode snapshot rsma read qtaskinfo succeed", SMA_VID(pSma)); + return code; + +_err: + smaError("vgId:%d vnode snapshot rsma read qtaskinfo failed since %s", SMA_VID(pSma), tstrerror(code)); + return code; +} + +int32_t rsmaSnapRead(SRsmaSnapReader* pReader, uint8_t** ppData) { + int32_t code = 0; + + *ppData = NULL; + + smaInfo("vgId:%d vnode snapshot rsma read entry", SMA_VID(pReader->pSma)); + // read rsma1/rsma2 file + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + STsdbSnapReader* pTsdbSnapReader = pReader->pDataReader[i]; + if (!pTsdbSnapReader) { + continue; + } + if (!pReader->rsmaDataDone[i]) { + smaInfo("vgId:%d vnode snapshot rsma read level %d not done", SMA_VID(pReader->pSma), i); + code = tsdbSnapRead(pTsdbSnapReader, ppData); + if (code) { + goto _err; + } else { + if (*ppData) { + goto _exit; + } else { + pReader->rsmaDataDone[i] = 1; + } + } + } else { + smaInfo("vgId:%d vnode snapshot rsma read level %d is done", SMA_VID(pReader->pSma), i); + } + } + + // read qtaskinfo file + if (!pReader->qTaskDone) { + code = rsmaSnapReadQTaskInfo(pReader, ppData); + if (code) { + goto _err; + } else { + if (*ppData) { + goto _exit; + } else { + pReader->qTaskDone = 1; + } + } + } + +_exit: + smaInfo("vgId:%d vnode snapshot rsma read succeed", SMA_VID(pReader->pSma)); + return code; + +_err: + smaError("vgId:%d vnode snapshot rsma read failed since %s", SMA_VID(pReader->pSma), tstrerror(code)); + return code; +} + +int32_t rsmaSnapReaderClose(SRsmaSnapReader** ppReader) { + int32_t code = 0; + SRsmaSnapReader* pReader = *ppReader; + + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + if (pReader->pDataReader[i]) { + tsdbSnapReaderClose(&pReader->pDataReader[i]); + } + } + + if (pReader->pQTaskFReader) { + // TODO: close for qtaskinfo + smaInfo("vgId:%d vnode snapshot rsma reader closed for qTaskInfo", SMA_VID(pReader->pSma)); + } + + + smaInfo("vgId:%d vnode snapshot rsma reader closed", SMA_VID(pReader->pSma)); + + taosMemoryFreeClear(*ppReader); + return code; +} + +// SRsmaSnapWriter ======================================== +struct SRsmaSnapWriter { + SSma* pSma; + int64_t sver; + int64_t ever; + + // config + int64_t commitID; + + // for data file + STsdbSnapWriter* pDataWriter[TSDB_RETENTION_L2]; + + // for qtaskinfo file + SQTaskFReader* pQTaskFReader; + SQTaskFWriter* pQTaskFWriter; +}; + +int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapWriter** ppWriter) { + int32_t code = 0; + SRsmaSnapWriter* pWriter = NULL; + + // alloc + pWriter = (SRsmaSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter)); + if (pWriter == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + pWriter->pSma = pSma; + pWriter->sver = sver; + pWriter->ever = ever; + + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + if (pSma->pRSmaTsdb[i]) { + code = tsdbSnapWriterOpen(pSma->pRSmaTsdb[i], sver, ever, &pWriter->pDataWriter[i]); + if (code < 0) { + goto _err; + } + } + } + + // qtaskinfo + // TODO + + *ppWriter = pWriter; + + smaInfo("vgId:%d rsma snapshot writer open succeed", TD_VID(pSma->pVnode)); + return code; + +_err: + smaError("vgId:%d rsma snapshot writer open failed since %s", TD_VID(pSma->pVnode), tstrerror(code)); + *ppWriter = NULL; + return code; +} + +int32_t rsmaSnapWriterClose(SRsmaSnapWriter** ppWriter, int8_t rollback) { + int32_t code = 0; + SRsmaSnapWriter* pWriter = *ppWriter; + + if (rollback) { + ASSERT(0); + // code = tsdbFSRollback(pWriter->pTsdb->pFS); + // if (code) goto _err; + } else { + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + if (pWriter->pDataWriter[i]) { + code = tsdbSnapWriterClose(&pWriter->pDataWriter[i], rollback); + if (code) goto _err; + } + } + } + + taosMemoryFree(pWriter); + *ppWriter = NULL; + + smaInfo("vgId:%d vnode snapshot rsma writer close succeed", SMA_VID(pWriter->pSma)); + return code; + +_err: + smaError("vgId:%d vnode snapshot rsma writer close failed since %s", SMA_VID(pWriter->pSma), tstrerror(code)); + return code; +} + +int32_t rsmaSnapWrite(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { + int32_t code = 0; + SSnapDataHdr* pHdr = (SSnapDataHdr*)pData; + + // rsma1/rsma2 + if (pHdr->type == SNAP_DATA_RSMA1) { + pHdr->type = SNAP_DATA_TSDB; + code = tsdbSnapWrite(pWriter->pDataWriter[0], pData, nData); + } else if (pHdr->type == SNAP_DATA_RSMA2) { + pHdr->type = SNAP_DATA_TSDB; + code = tsdbSnapWrite(pWriter->pDataWriter[1], pData, nData); + } else if (pHdr->type == SNAP_DATA_QTASK) { + code = rsmaSnapWriteQTaskInfo(pWriter, pData, nData); + } + if (code < 0) goto _err; + +_exit: + smaInfo("vgId:%d rsma snapshot write for data %" PRIi8 " succeed", SMA_VID(pWriter->pSma), pHdr->type); + return code; + +_err: + smaError("vgId:%d rsma snapshot write for data %" PRIi8 " failed since %s", SMA_VID(pWriter->pSma), pHdr->type, + tstrerror(code)); + return code; +} + +static int32_t rsmaSnapWriteQTaskInfo(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { + int32_t code = 0; + + if (pWriter->pQTaskFWriter == NULL) { + // SDelFile* pDelFile = pWriter->fs.pDelFile; + + // // reader + // if (pDelFile) { + // code = tsdbDelFReaderOpen(&pWriter->pDelFReader, pDelFile, pTsdb, NULL); + // if (code) goto _err; + + // code = tsdbReadDelIdx(pWriter->pDelFReader, pWriter->aDelIdxR, NULL); + // if (code) goto _err; + // } + + // // writer + // SDelFile delFile = {.commitID = pWriter->commitID, .offset = 0, .size = 0}; + // code = tsdbDelFWriterOpen(&pWriter->pDelFWriter, &delFile, pTsdb); + // if (code) goto _err; + } + smaInfo("vgId:%d vnode snapshot rsma write qtaskinfo succeed", SMA_VID(pWriter->pSma)); +_exit: + return code; + +_err: + smaError("vgId:%d vnode snapshot rsma write qtaskinfo failed since %s", SMA_VID(pWriter->pSma), tstrerror(code)); + return code; +} diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 118e3a5d43d159abf7f3ed8a901c2707e7987cdf..364ecbab616e64cbac98aaa8062707017538ef69 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -146,8 +146,8 @@ int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con } } - int32_t len; - int32_t code; + int32_t len = 0; + int32_t code = 0; tEncodeSize(tEncodeSMqDataRsp, pRsp, len, code); if (code < 0) { return -1; @@ -164,9 +164,10 @@ int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); - SEncoder encoder; + SEncoder encoder = {0}; tEncoderInit(&encoder, abuf, len); tEncodeSMqDataRsp(&encoder, pRsp); + tEncoderClear(&encoder); SRpcMsg rsp = { .info = pMsg->info, @@ -176,8 +177,8 @@ int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con }; tmsgSendRsp(&rsp); - char buf1[80]; - char buf2[80]; + char buf1[80] = {0}; + char buf2[80] = {0}; tFormatOffset(buf1, 80, &pRsp->reqOffset); tFormatOffset(buf2, 80, &pRsp->rspOffset); tqDebug("vgId:%d from consumer:%" PRId64 ", (epoch %d) send rsp, block num: %d, reqOffset:%s, rspOffset:%s", @@ -583,7 +584,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) { pHandle->execHandle.execTb.suid = req.suid; SArray* tbUidList = taosArrayInit(0, sizeof(int64_t)); vnodeGetCtbIdList(pTq->pVnode, req.suid, tbUidList); - tqDebug("vgId:%d, tq try get suid:%" PRId64, pTq->pVnode->config.vgId, req.suid); + tqDebug("vgId:%d, tq try to get all ctb, suid:%" PRId64, pTq->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); @@ -652,7 +653,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) { } else { SReadHandle mgHandle = { .vnode = NULL, - .numOfVgroups = pTask->numOfVgroups, + .numOfVgroups = (int32_t)taosArrayGetSize(pTask->childEpInfo), }; pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &mgHandle); } @@ -795,7 +796,7 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) { int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) { SStreamTaskRecoverRsp* pRsp = pMsg->pCont; - int32_t taskId = pRsp->taskId; + int32_t taskId = pRsp->rspTaskId; SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); if (ppTask) { streamProcessRecoverRsp(*ppTask, pRsp); diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index e259dde29c86a7559d8d4dd5f256a81dc137727b..4e6a450d35d01d7c41a80bbb7ae1fc5d1c21b127 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -46,11 +46,6 @@ void tsdbCloseCache(SLRUCache *pCache) { } } -static void getTableCacheKeyS(tb_uid_t uid, const char *cacheType, char *key, int *len) { - snprintf(key, 30, "%" PRIi64 "%s", uid, cacheType); - *len = strlen(key); -} - static void getTableCacheKey(tb_uid_t uid, int cacheType, char *key, int *len) { if (cacheType == 0) { // last_row *(uint64_t *)key = (uint64_t)uid; @@ -245,8 +240,6 @@ int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, STSRow *row, STsdb char key[32] = {0}; int keyLen = 0; - // ((void)(row)); - // getTableCacheKey(uid, "l", key, &keyLen); getTableCacheKey(uid, 1, key, &keyLen); LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen); @@ -323,26 +316,10 @@ static tb_uid_t getTableSuidByUid(tb_uid_t uid, STsdb *pTsdb) { static int32_t getTableDelDataFromDelIdx(SDelFReader *pDelReader, SDelIdx *pDelIdx, SArray *aDelData) { int32_t code = 0; - // SMapData delDataMap; - // SDelData delData; - if (pDelIdx) { - // tMapDataReset(&delDataMap); - - // code = tsdbReadDelData(pDelReader, pDelIdx, &delDataMap, NULL); code = tsdbReadDelData(pDelReader, pDelIdx, aDelData, NULL); - if (code) goto _err; - /* - for (int32_t iDelData = 0; iDelData < delDataMap.nItem; ++iDelData) { - code = tMapDataGetItemByIdx(&delDataMap, iDelData, &delData, tGetDelData); - if (code) goto _err; - - taosArrayPush(aDelData, &delData); - } - */ } -_err: return code; } @@ -444,18 +421,16 @@ typedef struct SFSNextRowIter { SArray *aDFileSet; SDataFReader *pDataFReader; SArray *aBlockIdx; - // SMapData blockIdxMap; - // SBlockIdx blockIdx; - SBlockIdx *pBlockIdx; - SMapData blockMap; - int32_t nBlock; - int32_t iBlock; - SBlock block; - SBlockData blockData; - SBlockData *pBlockData; - int32_t nRow; - int32_t iRow; - TSDBROW row; + SBlockIdx *pBlockIdx; + SMapData blockMap; + int32_t nBlock; + int32_t iBlock; + SBlock block; + SBlockData blockData; + SBlockData *pBlockData; + int32_t nRow; + int32_t iRow; + TSDBROW row; } SFSNextRowIter; static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) { @@ -629,41 +604,8 @@ typedef struct SMemNextRowIter { } SMemNextRowIter; static int32_t getNextRowFromMem(void *iter, TSDBROW **ppRow) { - // static int32_t getNextRowFromMem(void *iter, SArray *pRowArray) { SMemNextRowIter *state = (SMemNextRowIter *)iter; int32_t code = 0; - /* - if (!state->iterOpened) { - if (state->pMem != NULL) { - tsdbTbDataIterOpen(state->pMem, NULL, 1, &state->iter); - - state->iterOpened = true; - - TSDBROW *pMemRow = tsdbTbDataIterGet(&state->iter); - if (pMemRow) { - state->curRow = pMemRow; - } else { - return code; - } - } else { - return code; - } - } - - taosArrayPush(pRowArray, state->curRow); - while (tsdbTbDataIterNext(&state->iter)) { - TSDBROW *row = tsdbTbDataIterGet(&state->iter); - - if (TSDBROW_TS(row) < TSDBROW_TS(state->curRow)) { - state->curRow = row; - break; - } else { - taosArrayPush(pRowArray, row); - } - } - - return code; - */ switch (state->state) { case SMEMNEXTROW_ENTER: { if (state->pMem != NULL) { @@ -702,44 +644,44 @@ _err: return code; } -static int32_t tsRowFromTsdbRow(STSchema *pTSchema, TSDBROW *pRow, STSRow **ppRow) { - int32_t code = 0; - - SColVal *pColVal = &(SColVal){0}; - - if (pRow->type == 0) { - *ppRow = tdRowDup(pRow->pTSRow); - } else { - SArray *pArray = taosArrayInit(pTSchema->numOfCols, sizeof(SColVal)); - if (pArray == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _exit; - } - - TSDBKEY key = TSDBROW_KEY(pRow); - STColumn *pTColumn = &pTSchema->columns[0]; - *pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.ts = key.ts}); - - if (taosArrayPush(pArray, pColVal) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _exit; - } - - for (int16_t iCol = 1; iCol < pTSchema->numOfCols; iCol++) { - tsdbRowGetColVal(pRow, pTSchema, iCol, pColVal); - if (taosArrayPush(pArray, pColVal) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _exit; - } - } - - code = tdSTSRowNew(pArray, pTSchema, ppRow); - if (code) goto _exit; - } - -_exit: - return code; -} +/* static int32_t tsRowFromTsdbRow(STSchema *pTSchema, TSDBROW *pRow, STSRow **ppRow) { */ +/* int32_t code = 0; */ + +/* SColVal *pColVal = &(SColVal){0}; */ + +/* if (pRow->type == 0) { */ +/* *ppRow = tdRowDup(pRow->pTSRow); */ +/* } else { */ +/* SArray *pArray = taosArrayInit(pTSchema->numOfCols, sizeof(SColVal)); */ +/* if (pArray == NULL) { */ +/* code = TSDB_CODE_OUT_OF_MEMORY; */ +/* goto _exit; */ +/* } */ + +/* TSDBKEY key = TSDBROW_KEY(pRow); */ +/* STColumn *pTColumn = &pTSchema->columns[0]; */ +/* *pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.ts = key.ts}); */ + +/* if (taosArrayPush(pArray, pColVal) == NULL) { */ +/* code = TSDB_CODE_OUT_OF_MEMORY; */ +/* goto _exit; */ +/* } */ + +/* for (int16_t iCol = 1; iCol < pTSchema->numOfCols; iCol++) { */ +/* tsdbRowGetColVal(pRow, pTSchema, iCol, pColVal); */ +/* if (taosArrayPush(pArray, pColVal) == NULL) { */ +/* code = TSDB_CODE_OUT_OF_MEMORY; */ +/* goto _exit; */ +/* } */ +/* } */ + +/* code = tdSTSRowNew(pArray, pTSchema, ppRow); */ +/* if (code) goto _exit; */ +/* } */ + +/* _exit: */ +/* return code; */ +/* } */ static bool tsdbKeyDeleted(TSDBKEY *key, SArray *pSkyline, int64_t *iSkyline) { bool deleted = false; @@ -768,10 +710,8 @@ static bool tsdbKeyDeleted(TSDBKEY *key, SArray *pSkyline, int64_t *iSkyline) { } typedef int32_t (*_next_row_fn_t)(void *iter, TSDBROW **ppRow); -// typedef int32_t (*_next_row_fn_t)(void *iter, SArray *pRowArray); typedef int32_t (*_next_row_clear_fn_t)(void *iter); -// typedef struct TsdbNextRowState { typedef struct { TSDBROW *pRow; bool stop; @@ -782,7 +722,6 @@ typedef struct { } TsdbNextRowState; typedef struct { - // STsdb *pTsdb; SArray *pSkyline; int64_t iSkyline; @@ -793,10 +732,8 @@ typedef struct { TSDBROW memRow, imemRow, fsRow; TsdbNextRowState input[3]; - // SMemTable *pMemTable; - // SMemTable *pIMemTable; - STsdbReadSnap *pReadSnap; - STsdb *pTsdb; + STsdbReadSnap *pReadSnap; + STsdb *pTsdb; } CacheNextRowIter; static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTsdb) { @@ -967,7 +904,7 @@ _err: return code; } -static int32_t mergeLastRow2(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRow) { +static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRow) { int32_t code = 0; STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1); @@ -978,8 +915,6 @@ static int32_t mergeLastRow2(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppR SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal)); SColVal *pColVal = &(SColVal){0}; - // tb_uid_t suid = getTableSuidByUid(uid, pTsdb); - TSKEY lastRowTs = TSKEY_MAX; CacheNextRowIter iter = {0}; @@ -1066,7 +1001,7 @@ _err: return code; } -static int32_t mergeLast2(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) { +static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) { int32_t code = 0; STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1); @@ -1077,8 +1012,6 @@ static int32_t mergeLast2(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) { SArray *pColArray = taosArrayInit(nCol, sizeof(SLastCol)); SColVal *pColVal = &(SColVal){0}; - // tb_uid_t suid = getTableSuidByUid(uid, pTsdb); - TSKEY lastRowTs = TSKEY_MAX; CacheNextRowIter iter = {0}; @@ -1124,12 +1057,7 @@ static int32_t mergeLast2(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) { continue; } } - /* - if ((TSDBROW_TS(pRow) < lastRowTs)) { - // goto build the result ts row - break; - } - */ + // merge into pColArray setNoneCol = false; for (iCol = noneCol; iCol < nCol; ++iCol) { @@ -1139,7 +1067,6 @@ static int32_t mergeLast2(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) { tsdbRowGetColVal(pRow, pTSchema, iCol, pColVal); if ((tColVal->isNone || tColVal->isNull) && (!pColVal->isNone && !pColVal->isNull)) { taosArraySet(pColArray, iCol, &(SLastCol){.ts = rowTs, .colVal = *pColVal}); - //} else if (tColVal->isNone && pColVal->isNone && !setNoneCol) { } else if ((tColVal->isNone || tColVal->isNull) && (pColVal->isNone || pColVal->isNull) && !setNoneCol) { noneCol = iCol; setNoneCol = true; @@ -1148,521 +1075,36 @@ static int32_t mergeLast2(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) { } while (setNoneCol); // build the result ts row here - //*dup = false; if (taosArrayGetSize(pColArray) <= 0) { *ppLastArray = NULL; taosArrayDestroy(pColArray); } else { *ppLastArray = pColArray; } - /* if (taosArrayGetSize(pColArray) == nCol) { - code = tdSTSRowNew(pColArray, pTSchema, ppRow); - if (code) goto _err; - } else { - *ppRow = NULL; - }*/ nextRowIterClose(&iter); - // taosArrayDestroy(pColArray); taosMemoryFreeClear(pTSchema); return code; _err: nextRowIterClose(&iter); - // taosArrayDestroy(pColArray); taosMemoryFreeClear(pTSchema); return code; } -// static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRow) { -// int32_t code = 0; -// SArray *pSkyline = NULL; - -// STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1); -// int16_t nCol = pTSchema->numOfCols; -// SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal)); - -// tb_uid_t suid = getTableSuidByUid(uid, pTsdb); - -// STbData *pMem = NULL; -// if (pTsdb->mem) { -// tsdbGetTbDataFromMemTable(pTsdb->mem, suid, uid, &pMem); -// } - -// STbData *pIMem = NULL; -// if (pTsdb->imem) { -// tsdbGetTbDataFromMemTable(pTsdb->imem, suid, uid, &pIMem); -// } - -// *ppRow = NULL; - -// pSkyline = taosArrayInit(32, sizeof(TSDBKEY)); - -// SDelIdx delIdx; - -// SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState); -// if (pDelFile) { -// SDelFReader *pDelFReader; - -// code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb, NULL); -// if (code) goto _err; - -// code = getTableDelIdx(pDelFReader, suid, uid, &delIdx); -// if (code) goto _err; - -// code = getTableDelSkyline(pMem, pIMem, pDelFReader, &delIdx, pSkyline); -// if (code) goto _err; - -// tsdbDelFReaderClose(&pDelFReader); -// } else { -// code = getTableDelSkyline(pMem, pIMem, NULL, NULL, pSkyline); -// if (code) goto _err; -// } - -// int64_t iSkyline = taosArrayGetSize(pSkyline) - 1; - -// SBlockIdx idx = {.suid = suid, .uid = uid}; - -// SFSNextRowIter fsState = {0}; -// fsState.state = SFSNEXTROW_FS; -// fsState.pTsdb = pTsdb; -// fsState.pBlockIdxExp = &idx; - -// SMemNextRowIter memState = {0}; -// SMemNextRowIter imemState = {0}; -// TSDBROW memRow, imemRow, fsRow; - -// TsdbNextRowState input[3] = {{&memRow, true, false, &memState, getNextRowFromMem, NULL}, -// {&imemRow, true, false, &imemState, getNextRowFromMem, NULL}, -// {&fsRow, false, true, &fsState, getNextRowFromFS, clearNextRowFromFS}}; - -// if (pMem) { -// memState.pMem = pMem; -// memState.state = SMEMNEXTROW_ENTER; -// input[0].stop = false; -// input[0].next = true; -// } -// if (pIMem) { -// imemState.pMem = pIMem; -// imemState.state = SMEMNEXTROW_ENTER; -// input[1].stop = false; -// input[1].next = true; -// } - -// int16_t nilColCount = nCol - 1; // count of null & none cols -// int iCol = 0; // index of first nil col index from left to right -// bool setICol = false; - -// do { -// for (int i = 0; i < 3; ++i) { -// if (input[i].next && !input[i].stop) { -// if (input[i].pRow == NULL) { -// code = input[i].nextRowFn(input[i].iter, &input[i].pRow); -// if (code) goto _err; - -// if (input[i].pRow == NULL) { -// input[i].stop = true; -// input[i].next = false; -// } -// } -// } -// } - -// if (input[0].stop && input[1].stop && input[2].stop) { -// break; -// } - -// // select maxpoint(s) from mem, imem, fs -// TSDBROW *max[3] = {0}; -// int iMax[3] = {-1, -1, -1}; -// int nMax = 0; -// TSKEY maxKey = TSKEY_MIN; - -// for (int i = 0; i < 3; ++i) { -// if (!input[i].stop && input[i].pRow != NULL) { -// TSDBKEY key = TSDBROW_KEY(input[i].pRow); - -// // merging & deduplicating on client side -// if (maxKey <= key.ts) { -// if (maxKey < key.ts) { -// nMax = 0; -// maxKey = key.ts; -// } - -// iMax[nMax] = i; -// max[nMax++] = input[i].pRow; -// } -// } -// } - -// // delete detection -// TSDBROW *merge[3] = {0}; -// int iMerge[3] = {-1, -1, -1}; -// int nMerge = 0; -// for (int i = 0; i < nMax; ++i) { -// TSDBKEY maxKey = TSDBROW_KEY(max[i]); - -// bool deleted = tsdbKeyDeleted(&maxKey, pSkyline, &iSkyline); -// if (!deleted) { -// iMerge[nMerge] = i; -// merge[nMerge++] = max[i]; -// } - -// input[iMax[i]].next = deleted; -// } - -// // merge if nMerge > 1 -// if (nMerge > 0) { -// *dup = false; - -// if (nMerge == 1) { -// code = tsRowFromTsdbRow(pTSchema, merge[nMerge - 1], ppRow); -// if (code) goto _err; -// } else { -// // merge 2 or 3 rows -// SRowMerger merger = {0}; - -// tRowMergerInit(&merger, merge[0], pTSchema); -// for (int i = 1; i < nMerge; ++i) { -// tRowMerge(&merger, merge[i]); -// } -// tRowMergerGetRow(&merger, ppRow); -// tRowMergerClear(&merger); -// } -// } - -// } while (1); - -// for (int i = 0; i < 3; ++i) { -// if (input[i].nextRowClearFn) { -// input[i].nextRowClearFn(input[i].iter); -// } -// } -// if (pSkyline) { -// taosArrayDestroy(pSkyline); -// } -// taosMemoryFreeClear(pTSchema); - -// return code; -// _err: -// for (int i = 0; i < 3; ++i) { -// if (input[i].nextRowClearFn) { -// input[i].nextRowClearFn(input[i].iter); -// } -// } -// if (pSkyline) { -// taosArrayDestroy(pSkyline); -// } -// taosMemoryFreeClear(pTSchema); -// tsdbError("vgId:%d merge last_row failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); -// return code; -// } - -// static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) { -// static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) { -// int32_t code = 0; -// SArray *pSkyline = NULL; -// STSRow *pRow = NULL; -// STSRow **ppRow = &pRow; - -// STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1); -// int16_t nCol = pTSchema->numOfCols; -// // SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal)); -// SArray *pColArray = taosArrayInit(nCol, sizeof(SLastCol)); - -// tb_uid_t suid = getTableSuidByUid(uid, pTsdb); - -// STbData *pMem = NULL; -// if (pTsdb->mem) { -// tsdbGetTbDataFromMemTable(pTsdb->mem, suid, uid, &pMem); -// } - -// STbData *pIMem = NULL; -// if (pTsdb->imem) { -// tsdbGetTbDataFromMemTable(pTsdb->imem, suid, uid, &pIMem); -// } - -// *ppLastArray = NULL; - -// pSkyline = taosArrayInit(32, sizeof(TSDBKEY)); - -// SDelIdx delIdx; - -// SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState); -// if (pDelFile) { -// SDelFReader *pDelFReader; - -// code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb, NULL); -// if (code) goto _err; - -// code = getTableDelIdx(pDelFReader, suid, uid, &delIdx); -// if (code) goto _err; - -// code = getTableDelSkyline(pMem, pIMem, pDelFReader, &delIdx, pSkyline); -// if (code) goto _err; - -// tsdbDelFReaderClose(&pDelFReader); -// } else { -// code = getTableDelSkyline(pMem, pIMem, NULL, NULL, pSkyline); -// if (code) goto _err; -// } - -// int64_t iSkyline = taosArrayGetSize(pSkyline) - 1; - -// SBlockIdx idx = {.suid = suid, .uid = uid}; - -// SFSNextRowIter fsState = {0}; -// fsState.state = SFSNEXTROW_FS; -// fsState.pTsdb = pTsdb; -// fsState.pBlockIdxExp = &idx; - -// SMemNextRowIter memState = {0}; -// SMemNextRowIter imemState = {0}; -// TSDBROW memRow, imemRow, fsRow; - -// TsdbNextRowState input[3] = {{&memRow, true, false, &memState, getNextRowFromMem, NULL}, -// {&imemRow, true, false, &imemState, getNextRowFromMem, NULL}, -// {&fsRow, false, true, &fsState, getNextRowFromFS, clearNextRowFromFS}}; - -// if (pMem) { -// memState.pMem = pMem; -// memState.state = SMEMNEXTROW_ENTER; -// input[0].stop = false; -// input[0].next = true; -// } -// if (pIMem) { -// imemState.pMem = pIMem; -// imemState.state = SMEMNEXTROW_ENTER; -// input[1].stop = false; -// input[1].next = true; -// } - -// int16_t nilColCount = nCol - 1; // count of null & none cols -// int iCol = 0; // index of first nil col index from left to right -// bool setICol = false; - -// do { -// for (int i = 0; i < 3; ++i) { -// if (input[i].next && !input[i].stop) { -// code = input[i].nextRowFn(input[i].iter, &input[i].pRow); -// if (code) goto _err; - -// if (input[i].pRow == NULL) { -// input[i].stop = true; -// input[i].next = false; -// } -// } -// } - -// if (input[0].stop && input[1].stop && input[2].stop) { -// break; -// } - -// // select maxpoint(s) from mem, imem, fs -// TSDBROW *max[3] = {0}; -// int iMax[3] = {-1, -1, -1}; -// int nMax = 0; -// TSKEY maxKey = TSKEY_MIN; - -// for (int i = 0; i < 3; ++i) { -// if (!input[i].stop && input[i].pRow != NULL) { -// TSDBKEY key = TSDBROW_KEY(input[i].pRow); - -// // merging & deduplicating on client side -// if (maxKey <= key.ts) { -// if (maxKey < key.ts) { -// nMax = 0; -// maxKey = key.ts; -// } - -// iMax[nMax] = i; -// max[nMax++] = input[i].pRow; -// } -// } -// } - -// // delete detection -// TSDBROW *merge[3] = {0}; -// int iMerge[3] = {-1, -1, -1}; -// int nMerge = 0; -// for (int i = 0; i < nMax; ++i) { -// TSDBKEY maxKey = TSDBROW_KEY(max[i]); - -// bool deleted = tsdbKeyDeleted(&maxKey, pSkyline, &iSkyline); -// if (!deleted) { -// iMerge[nMerge] = iMax[i]; -// merge[nMerge++] = max[i]; -// } - -// input[iMax[i]].next = deleted; -// } - -// // merge if nMerge > 1 -// if (nMerge > 0) { -// if (nMerge == 1) { -// code = tsRowFromTsdbRow(pTSchema, merge[nMerge - 1], ppRow); -// if (code) goto _err; -// } else { -// // merge 2 or 3 rows -// SRowMerger merger = {0}; - -// tRowMergerInit(&merger, merge[0], pTSchema); -// for (int i = 1; i < nMerge; ++i) { -// tRowMerge(&merger, merge[i]); -// } -// tRowMergerGetRow(&merger, ppRow); -// tRowMergerClear(&merger); -// } -// } else { -// /* *ppRow = NULL; */ -// /* return code; */ -// continue; -// } - -// if (iCol == 0) { -// STColumn *pTColumn = &pTSchema->columns[0]; -// SColVal *pColVal = &(SColVal){0}; - -// *pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.ts = maxKey}); - -// // if (taosArrayPush(pColArray, pColVal) == NULL) { -// if (taosArrayPush(pColArray, &(SLastCol){.ts = maxKey, .colVal = *pColVal}) == NULL) { -// code = TSDB_CODE_OUT_OF_MEMORY; -// goto _err; -// } - -// ++iCol; - -// setICol = false; -// for (int16_t i = iCol; i < nCol; ++i) { -// // tsdbRowGetColVal(*ppRow, pTSchema, i, pColVal); -// tTSRowGetVal(*ppRow, pTSchema, i, pColVal); -// // if (taosArrayPush(pColArray, pColVal) == NULL) { -// if (taosArrayPush(pColArray, &(SLastCol){.ts = maxKey, .colVal = *pColVal}) == NULL) { -// code = TSDB_CODE_OUT_OF_MEMORY; -// goto _err; -// } - -// if (pColVal->isNull || pColVal->isNone) { -// for (int j = 0; j < nMerge; ++j) { -// SColVal jColVal = {0}; -// tsdbRowGetColVal(merge[j], pTSchema, i, &jColVal); -// if (jColVal.isNull || jColVal.isNone) { -// input[iMerge[j]].next = true; -// } -// } -// if (!setICol) { -// iCol = i; -// setICol = true; -// } -// } else { -// --nilColCount; -// } -// } - -// if (*ppRow) { -// taosMemoryFreeClear(*ppRow); -// } - -// continue; -// } - -// setICol = false; -// for (int16_t i = iCol; i < nCol; ++i) { -// SColVal colVal = {0}; -// tTSRowGetVal(*ppRow, pTSchema, i, &colVal); -// TSKEY rowTs = (*ppRow)->ts; - -// // SColVal *tColVal = (SColVal *)taosArrayGet(pColArray, i); -// SLastCol *tTsVal = (SLastCol *)taosArrayGet(pColArray, i); -// SColVal *tColVal = &tTsVal->colVal; - -// if (!colVal.isNone && !colVal.isNull) { -// if (tColVal->isNull || tColVal->isNone) { -// // taosArraySet(pColArray, i, &colVal); -// taosArraySet(pColArray, i, &(SLastCol){.ts = rowTs, .colVal = colVal}); -// --nilColCount; -// } -// } else { -// if ((tColVal->isNull || tColVal->isNone) && !setICol) { -// iCol = i; -// setICol = true; - -// for (int j = 0; j < nMerge; ++j) { -// SColVal jColVal = {0}; -// tsdbRowGetColVal(merge[j], pTSchema, i, &jColVal); -// if (jColVal.isNull || jColVal.isNone) { -// input[iMerge[j]].next = true; -// } -// } -// } -// } -// } - -// if (*ppRow) { -// taosMemoryFreeClear(*ppRow); -// } -// } while (nilColCount > 0); - -// // if () new ts row from pColArray if non empty -// /* if (taosArrayGetSize(pColArray) == nCol) { */ -// /* code = tdSTSRowNew(pColArray, pTSchema, ppRow); */ -// /* if (code) goto _err; */ -// /* } */ -// /* taosArrayDestroy(pColArray); */ -// if (taosArrayGetSize(pColArray) <= 0) { -// *ppLastArray = NULL; -// taosArrayDestroy(pColArray); -// } else { -// *ppLastArray = pColArray; -// } -// if (*ppRow) { -// taosMemoryFreeClear(*ppRow); -// } - -// for (int i = 0; i < 3; ++i) { -// if (input[i].nextRowClearFn) { -// input[i].nextRowClearFn(input[i].iter); -// } -// } -// if (pSkyline) { -// taosArrayDestroy(pSkyline); -// } -// taosMemoryFreeClear(pTSchema); - -// return code; -// _err: -// taosArrayDestroy(pColArray); -// if (*ppRow) { -// taosMemoryFreeClear(*ppRow); -// } -// for (int i = 0; i < 3; ++i) { -// if (input[i].nextRowClearFn) { -// input[i].nextRowClearFn(input[i].iter); -// } -// } -// if (pSkyline) { -// taosArrayDestroy(pSkyline); -// } -// taosMemoryFreeClear(pTSchema); -// tsdbError("vgId:%d merge last_row failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); -// return code; -// } - int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHandle **handle) { int32_t code = 0; char key[32] = {0}; int keyLen = 0; - // getTableCacheKey(uid, "lr", key, &keyLen); + // getTableCacheKeyS(uid, "lr", key, &keyLen); getTableCacheKey(uid, 0, key, &keyLen); LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen); if (h) { - //*ppRow = (STSRow *)taosLRUCacheValue(pCache, h); } else { STSRow *pRow = NULL; bool dup = false; // which is always false for now - code = mergeLastRow2(uid, pTsdb, &dup, &pRow); + code = mergeLastRow(uid, pTsdb, &dup, &pRow); // if table's empty or error, return code of -1 if (code < 0 || pRow == NULL) { if (!dup && pRow) { @@ -1680,9 +1122,7 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUH code = -1; } - // tsdbCacheInsertLastrow(pCache, pTsdb, uid, pRow, dup); h = taosLRUCacheLookup(pCache, key, keyLen); - //*ppRow = (STSRow *)taosLRUCacheValue(pCache, h); } *handle = h; @@ -1719,18 +1159,13 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHand char key[32] = {0}; int keyLen = 0; - // getTableCacheKey(uid, "l", key, &keyLen); + // getTableCacheKeyS(uid, "l", key, &keyLen); getTableCacheKey(uid, 1, key, &keyLen); LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen); if (h) { - //*ppRow = (STSRow *)taosLRUCacheValue(pCache, h); - } else { - // STSRow *pRow = NULL; - // code = mergeLast(uid, pTsdb, &pRow); SArray *pLastArray = NULL; - // code = mergeLast(uid, pTsdb, &pLastArray); - code = mergeLast2(uid, pTsdb, &pLastArray); + code = mergeLast(uid, pTsdb, &pLastArray); // if table's empty or error, return code of -1 // if (code < 0 || pRow == NULL) { if (code < 0 || pLastArray == NULL) { @@ -1746,7 +1181,6 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHand } h = taosLRUCacheLookup(pCache, key, keyLen); - //*ppRow = (STSRow *)taosLRUCacheValue(pCache, h); } *handle = h; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index ea8ac09429af5018e4b01b3bc40e9a3242295fa9..03985654f88bfda5caac87980bea7c53e4f404d7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -31,7 +31,7 @@ typedef struct { typedef struct STableBlockScanInfo { uint64_t uid; TSKEY lastKey; - SBlockIdx blockIdx; + SMapData mapData; // block info (compressed) SArray* pBlockList; // block data index list SIterInfo iter; // mem buffer skip list iterator SIterInfo iiter; // imem buffer skip list iterator @@ -42,7 +42,7 @@ typedef struct STableBlockScanInfo { typedef struct SBlockOrderWrapper { int64_t uid; - SBlock* pBlock; + int64_t offset; } SBlockOrderWrapper; typedef struct SBlockOrderSupporter { @@ -53,11 +53,13 @@ typedef struct SBlockOrderSupporter { } SBlockOrderSupporter; typedef struct SIOCostSummary { - int64_t blockLoadTime; - int64_t smaLoadTime; - int64_t checkForNextTime; + int64_t numOfBlocks; + double blockLoadTime; + double buildmemBlock; int64_t headFileLoad; - int64_t headFileLoadTime; + double headFileLoadTime; + int64_t smaData; + double smaLoadTime; } SIOCostSummary; typedef struct SBlockLoadSuppInfo { @@ -86,6 +88,8 @@ typedef struct SDataBlockIter { int32_t index; SArray* blockList; // SArray int32_t order; + SBlock block; // current SBlock data + SHashObj* pTableMap; } SDataBlockIter; typedef struct SFileBlockDumpInfo { @@ -183,7 +187,7 @@ static int32_t setColumnIdSlotList(STsdbReader* pReader, SSDataBlock* pBlock) { static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableKeyInfo* idList, int32_t numOfTables) { // allocate buffer in order to load data blocks from file - // todo use simple hash instead + // todo use simple hash instead, optimize the memory consumption SHashObj* pTableMap = taosHashInit(numOfTables, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); if (pTableMap == NULL) { @@ -244,6 +248,7 @@ static void destroyBlockScanInfo(SHashObj* pTableMap) { p->delSkyline = taosArrayDestroy(p->delSkyline); p->pBlockList = taosArrayDestroy(p->pBlockList); + tMapDataClear(&p->mapData); } taosHashCleanup(pTableMap); @@ -320,6 +325,8 @@ static bool filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader) { goto _err; } + pReader->cost.headFileLoad += 1; + int32_t fid = pReader->status.pCurrentFileset->fid; tsdbFidKeyRange(fid, pReader->pTsdb->keepCfg.days, pReader->pTsdb->keepCfg.precision, &win.skey, &win.ekey); @@ -347,7 +354,7 @@ _err: return false; } -static void resetDataBlockIterator(SDataBlockIter* pIter, int32_t order) { +static void resetDataBlockIterator(SDataBlockIter* pIter, int32_t order, SHashObj* pTableMap) { pIter->order = order; pIter->index = -1; pIter->numOfBlocks = -1; @@ -356,6 +363,7 @@ static void resetDataBlockIterator(SDataBlockIter* pIter, int32_t order) { } else { taosArrayClear(pIter->blockList); } + pIter->pTableMap = pTableMap; } static void cleanupDataBlockIterator(SDataBlockIter* pIter) { taosArrayDestroy(pIter->blockList); } @@ -423,6 +431,12 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd pSup->tsColAgg.colId = PRIMARYKEY_TIMESTAMP_COL_ID; + code = tBlockDataInit(&pReader->status.fileBlockData); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + goto _end; + } + pReader->pResBlock = createResBlock(pCond, pReader->capacity); if (pReader->pResBlock == NULL) { code = terrno; @@ -521,7 +535,7 @@ _end: // } static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFReader* pFileReader, SArray* pIndexList) { - SArray* aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx)); + SArray* aBlockIdx = taosArrayInit(8, sizeof(SBlockIdx)); int64_t st = taosGetTimestampUs(); int32_t code = tsdbReadBlockIdx(pFileReader, aBlockIdx, NULL); @@ -554,16 +568,18 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFReader* pFileReader, STableBlockScanInfo* pScanInfo = p; if (pScanInfo->pBlockList == NULL) { - pScanInfo->pBlockList = taosArrayInit(16, sizeof(SBlock)); + pScanInfo->pBlockList = taosArrayInit(4, sizeof(int32_t)); } - pScanInfo->blockIdx = *pBlockIdx; taosArrayPush(pIndexList, pBlockIdx); } int64_t et2 = taosGetTimestampUs(); - tsdbDebug("load block index for %d tables completed, elapsed time:%.2f ms, set blockIdx:%.2f ms, size:%d bytes %s", - (int32_t)num, (et1 - st)/1000.0, (et2-et1)/1000.0, num * sizeof(SBlockIdx), pReader->idStr); + tsdbDebug("load block index for %d tables completed, elapsed time:%.2f ms, set blockIdx:%.2f ms, size:%.2f Kb %s", + (int32_t)num, (et1 - st)/1000.0, (et2-et1)/1000.0, num * sizeof(SBlockIdx)/1024.0, pReader->idStr); + + pReader->cost.headFileLoadTime += (et1 - st) / 1000.0; + _end: taosArrayDestroy(aBlockIdx); return code; @@ -584,23 +600,22 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, uint32_ break; } + tMapDataClear(&px->mapData); taosArrayClear(px->pBlockList); } for (int32_t i = 0; i < numOfTables; ++i) { SBlockIdx* pBlockIdx = taosArrayGet(pIndexList, i); - SMapData mapData = {0}; - tMapDataReset(&mapData); - tsdbReadBlock(pReader->pFileReader, pBlockIdx, &mapData, NULL); + STableBlockScanInfo* pScanInfo = taosHashGet(pReader->status.pTableMap, &pBlockIdx->uid, sizeof(int64_t)); - size += mapData.nData; + tMapDataReset(&pScanInfo->mapData); + tsdbReadBlock(pReader->pFileReader, pBlockIdx, &pScanInfo->mapData, NULL); - STableBlockScanInfo* pScanInfo = taosHashGet(pReader->status.pTableMap, &pBlockIdx->uid, sizeof(int64_t)); - for (int32_t j = 0; j < mapData.nItem; ++j) { + size += pScanInfo->mapData.nData; + for (int32_t j = 0; j < pScanInfo->mapData.nItem; ++j) { SBlock block = {0}; - - tMapDataGetItemByIdx(&mapData, j, &block, tGetBlock); + tMapDataGetItemByIdx(&pScanInfo->mapData, j, &block, tGetBlock); // 1. time range check if (block.minKey.ts > pReader->window.ekey || block.maxKey.ts < pReader->window.skey) { @@ -612,24 +627,26 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, uint32_ continue; } - void* p = taosArrayPush(pScanInfo->pBlockList, &block); + void* p = taosArrayPush(pScanInfo->pBlockList, &j); if (p == NULL) { - tMapDataClear(&mapData); + tMapDataClear(&pScanInfo->mapData); return TSDB_CODE_OUT_OF_MEMORY; } (*numOfBlocks) += 1; } - tMapDataClear(&mapData); if (pScanInfo->pBlockList != NULL && taosArrayGetSize(pScanInfo->pBlockList) > 0) { (*numOfValidTables) += 1; } } - int64_t et = taosGetTimestampUs(); + double el = (taosGetTimestampUs() - st)/1000.0; tsdbDebug("load block of %d tables completed, blocks:%d in %d tables, size:%.2f Kb, elapsed time:%.2f ms %s", - numOfTables, *numOfBlocks, *numOfValidTables, size/1000.0, (et-st)/1000.0, pReader->idStr); + numOfTables, *numOfBlocks, *numOfValidTables, size/1000.0, el, pReader->idStr); + + pReader->cost.numOfBlocks += (*numOfBlocks); + pReader->cost.headFileLoadTime += el; return TSDB_CODE_SUCCESS; } @@ -657,13 +674,22 @@ static void doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int32_ } } +static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) { + SFileDataBlockInfo* pFBlockInfo = taosArrayGet(pBlockIter->blockList, pBlockIter->index); + return pFBlockInfo; +} + +static SBlock* getCurrentBlock(SDataBlockIter* pBlockIter) { + return &pBlockIter->block; +} + static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo) { SReaderStatus* pStatus = &pReader->status; SDataBlockIter* pBlockIter = &pStatus->blockIter; SBlockData* pBlockData = &pStatus->fileBlockData; SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(pBlockIter); - SBlock* pBlock = taosArrayGet(pBlockScanInfo->pBlockList, pFBlock->tbBlockIdx); + SBlock* pBlock = getCurrentBlock(pBlockIter); SSDataBlock* pResBlock = pReader->pResBlock; int32_t numOfCols = blockDataGetNumOfCols(pResBlock); @@ -729,12 +755,12 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn setBlockAllDumped(pDumpInfo, pBlock, pReader->order); - int64_t elapsedTime = (taosGetTimestampUs() - st); + double elapsedTime = (taosGetTimestampUs() - st) / 1000.0; pReader->cost.blockLoadTime += elapsedTime; int32_t unDumpedRows = asc ? pBlock->nRow - pDumpInfo->rowIndex : pDumpInfo->rowIndex + 1; tsdbDebug("%p load file block into buffer, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64 - ", rows:%d, remain:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", elapsed time:%" PRId64 " us, %s", + ", rows:%d, remain:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", elapsed time:%.2f ms, %s", pReader, pBlockIter->index, pFBlock->tbBlockIdx, pBlock->minKey.ts, pBlock->maxKey.ts, remain, unDumpedRows, pBlock->minVersion, pBlock->maxVersion, elapsedTime, pReader->idStr); @@ -746,27 +772,30 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI int64_t st = taosGetTimestampUs(); SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(pBlockIter); - SBlock* pBlock = taosArrayGet(pBlockScanInfo->pBlockList, pFBlock->tbBlockIdx); + SBlock* pBlock = getCurrentBlock(pBlockIter); + SSDataBlock* pResBlock = pReader->pResBlock; int32_t numOfCols = blockDataGetNumOfCols(pResBlock); SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; - int32_t code = tsdbReadColData(pReader->pFileReader, &pBlockScanInfo->blockIdx, pBlock, pSupInfo->colIds, numOfCols, + SBlockIdx blockIdx = {.suid = pReader->suid, .uid = pBlockScanInfo->uid}; + int32_t code = tsdbReadColData(pReader->pFileReader, &blockIdx, pBlock, pSupInfo->colIds, numOfCols, pBlockData, NULL, NULL); if (code != TSDB_CODE_SUCCESS) { goto _error; } - int64_t elapsedTime = (taosGetTimestampUs() - st); + double elapsedTime = (taosGetTimestampUs() - st) / 1000.0; pReader->cost.blockLoadTime += elapsedTime; pDumpInfo->allDumped = false; tsdbDebug("%p load file block into buffer, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64 - ", rows:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", elapsed time:%" PRId64 " us, %s", + ", rows:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", elapsed time:%.2f ms, %s", pReader, pBlockIter->index, pFBlock->tbBlockIdx, pBlock->minKey.ts, pBlock->maxKey.ts, pBlock->nRow, pBlock->minVersion, pBlock->maxVersion, elapsedTime, pReader->idStr); + return TSDB_CODE_SUCCESS; _error: @@ -824,7 +853,21 @@ static int32_t fileDataBlockOrderCompar(const void* pLeft, const void* pRight, v SBlockOrderWrapper* pLeftBlock = &pSupporter->pDataBlockInfo[leftIndex][leftTableBlockIndex]; SBlockOrderWrapper* pRightBlock = &pSupporter->pDataBlockInfo[rightIndex][rightTableBlockIndex]; - return pLeftBlock->pBlock->aSubBlock[0].offset > pRightBlock->pBlock->aSubBlock[0].offset ? 1 : -1; + return pLeftBlock->offset > pRightBlock->offset ? 1 : -1; +} + +static int32_t doSetCurrentBlock(SDataBlockIter* pBlockIter) { + SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(pBlockIter); + STableBlockScanInfo* pScanInfo = taosHashGet(pBlockIter->pTableMap, &pFBlock->uid, sizeof(pFBlock->uid)); + + int32_t* mapDataIndex = taosArrayGet(pScanInfo->pBlockList, pFBlock->tbBlockIdx); + tMapDataGetItemByIdx(&pScanInfo->mapData, *mapDataIndex, &pBlockIter->block, tGetBlock); + +#if 0 + qDebug("check file block, table uid:%"PRIu64" index:%d offset:%"PRId64", ", pScanInfo->uid, *mapDataIndex, pBlockIter->block.aSubBlock[0].offset); +#endif + + return TSDB_CODE_SUCCESS; } static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIter, int32_t numOfBlocks) { @@ -867,10 +910,15 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte } sup.pDataBlockInfo[sup.numOfTables] = (SBlockOrderWrapper*)buf; + SBlock block = {0}; for (int32_t k = 0; k < num; ++k) { SBlockOrderWrapper wrapper = {0}; - wrapper.pBlock = (SBlock*)taosArrayGet(pTableScanInfo->pBlockList, k); + + int32_t* mapDataIndex = taosArrayGet(pTableScanInfo->pBlockList, k); + tMapDataGetItemByIdx(&pTableScanInfo->mapData, *mapDataIndex, &block, tGetBlock); + wrapper.uid = pTableScanInfo->uid; + wrapper.offset = block.aSubBlock[0].offset; sup.pDataBlockInfo[sup.numOfTables][k] = wrapper; cnt++; @@ -894,6 +942,7 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte pBlockIter->index = asc ? 0 : (numOfBlocks - 1); cleanupBlockOrderSupporter(&sup); + doSetCurrentBlock(pBlockIter); return TSDB_CODE_SUCCESS; } @@ -932,6 +981,8 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte taosMemoryFree(pTree); pBlockIter->index = asc ? 0 : (numOfBlocks - 1); + doSetCurrentBlock(pBlockIter); + return TSDB_CODE_SUCCESS; } @@ -944,6 +995,8 @@ static bool blockIteratorNext(SDataBlockIter* pBlockIter) { } pBlockIter->index += step; + doSetCurrentBlock(pBlockIter); + return true; } @@ -957,11 +1010,6 @@ static int32_t dataBlockPartiallyRequired(STimeWindow* pWindow, SVersionRange* p (pVerRange->maxVer < pBlock->maxVersion && pVerRange->maxVer >= pBlock->minVersion); } -static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) { - SFileDataBlockInfo* pFBlockInfo = taosArrayGet(pBlockIter->blockList, pBlockIter->index); - return pFBlockInfo; -} - static SBlock* getNeighborBlockOfSameTable(SFileDataBlockInfo* pFBlockInfo, STableBlockScanInfo* pTableBlockScanInfo, int32_t* nextIndex, int32_t order) { bool asc = ASCENDING_TRAVERSE(order); @@ -974,10 +1022,13 @@ static SBlock* getNeighborBlockOfSameTable(SFileDataBlockInfo* pFBlockInfo, STab } int32_t step = asc ? 1 : -1; - *nextIndex = pFBlockInfo->tbBlockIdx + step; - SBlock* pNext = taosArrayGet(pTableBlockScanInfo->pBlockList, *nextIndex); - return pNext; + + SBlock *pBlock = taosMemoryCalloc(1, sizeof(SBlock)); + int32_t* indexInMapdata = taosArrayGet(pTableBlockScanInfo->pBlockList, *nextIndex); + + tMapDataGetItemByIdx(&pTableBlockScanInfo->mapData, *indexInMapdata, pBlock, tGetBlock); + return pBlock; } static int32_t findFileBlockInfoIndex(SDataBlockIter* pBlockIter, SFileDataBlockInfo* pFBlockInfo) { @@ -1015,6 +1066,7 @@ static int32_t setFileBlockActiveInBlockIter(SDataBlockIter* pBlockIter, int32_t ASSERT(pBlockInfo->uid == fblock.uid && pBlockInfo->tbBlockIdx == fblock.tbBlockIdx); } + doSetCurrentBlock(pBlockIter); return TSDB_CODE_SUCCESS; } @@ -1117,6 +1169,7 @@ static bool fileBlockShouldLoad(STsdbReader* pReader, SFileDataBlockInfo* pFBloc bool overlapWithNeighbor = false; if (pNeighbor) { overlapWithNeighbor = overlapWithNeighborBlock(pBlock, pNeighbor, pReader->order); + taosMemoryFree(pNeighbor); } // has duplicated ts of different version in this block @@ -1142,17 +1195,20 @@ static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo* setComposedBlockFlag(pReader, true); - int64_t elapsedTime = taosGetTimestampUs() - st; - tsdbDebug("%p build data block from cache completed, elapsed time:%" PRId64 - " us, numOfRows:%d, numOfCols:%d, brange: %" PRId64 " - %" PRId64 " %s", - pReader, elapsedTime, pBlock->info.rows, (int32_t)blockDataGetNumOfCols(pBlock), pBlock->info.window.skey, - pBlock->info.window.ekey, pReader->idStr); + double elapsedTime = (taosGetTimestampUs() - st) / 1000.0; + tsdbDebug( + "%p build data block from cache completed, elapsed time:%.2f ms, numOfRows:%d, brange: %" PRId64 + " - %" PRId64 " %s", + pReader, elapsedTime, pBlock->info.rows, pBlock->info.window.skey, pBlock->info.window.ekey, pReader->idStr); + + pReader->cost.buildmemBlock += elapsedTime; return code; } static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo, TSDBROW* pRow, - STSRow* pTSRow, SIterInfo* pIter, int64_t key) { + SIterInfo* pIter, int64_t key) { SRowMerger merge = {0}; + STSRow* pTSRow = NULL; SBlockData* pBlockData = &pReader->status.fileBlockData; SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; @@ -1201,6 +1257,8 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* tRowMergerClear(&merge); doAppendOneRow(pReader->pResBlock, pReader, pTSRow); + + taosMemoryFree(pTSRow); return TSDB_CODE_SUCCESS; } @@ -1362,9 +1420,6 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; SBlockData* pBlockData = &pReader->status.fileBlockData; - SRowMerger merge = {0}; - STSRow* pTSRow = NULL; - int64_t key = pBlockData->aTSKEY[pDumpInfo->rowIndex]; TSDBROW* pRow = getValidRow(&pBlockScanInfo->iter, pBlockScanInfo->delSkyline, pReader); TSDBROW* piRow = getValidRow(&pBlockScanInfo->iiter, pBlockScanInfo->delSkyline, pReader); @@ -1374,21 +1429,27 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI } else { // imem + file if (pBlockScanInfo->iiter.hasVal) { - return doMergeBufAndFileRows(pReader, pBlockScanInfo, piRow, pTSRow, &pBlockScanInfo->iiter, key); + return doMergeBufAndFileRows(pReader, pBlockScanInfo, piRow, &pBlockScanInfo->iiter, key); } // mem + file if (pBlockScanInfo->iter.hasVal) { - return doMergeBufAndFileRows(pReader, pBlockScanInfo, pRow, pTSRow, &pBlockScanInfo->iter, key); + return doMergeBufAndFileRows(pReader, pBlockScanInfo, pRow, &pBlockScanInfo->iter, key); } // imem & mem are all empty, only file exist TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); + + STSRow* pTSRow = NULL; + SRowMerger merge = {0}; + tRowMergerInit(&merge, &fRow, pReader->pSchema); doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge); tRowMergerGetRow(&merge, &pTSRow); doAppendOneRow(pReader->pResBlock, pReader, pTSRow); + taosMemoryFree(pTSRow); + tRowMergerClear(&merge); return TSDB_CODE_SUCCESS; } } @@ -1408,9 +1469,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader, STableBlockScanInfo* if (!isValidFileBlockRow(pBlockData, pDumpInfo, pBlockScanInfo, pReader)) { pDumpInfo->rowIndex += step; - SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter); - SBlock* pBlock = taosArrayGet(pBlockScanInfo->pBlockList, pFBlock->tbBlockIdx); - + SBlock* pBlock = getCurrentBlock(&pReader->status.blockIter); if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) { setBlockAllDumped(pDumpInfo, pBlock, pReader->order); break; @@ -1421,9 +1480,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader, STableBlockScanInfo* } buildComposedDataBlockImpl(pReader, pBlockScanInfo); - - SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter); - SBlock* pBlock = taosArrayGet(pBlockScanInfo->pBlockList, pFBlock->tbBlockIdx); + SBlock* pBlock = getCurrentBlock(&pReader->status.blockIter); // currently loaded file data block is consumed if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) { @@ -1666,11 +1723,12 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(pBlockIter); STableBlockScanInfo* pScanInfo = taosHashGet(pStatus->pTableMap, &pFBlock->uid, sizeof(pFBlock->uid)); - SBlock* pBlock = taosArrayGet(pScanInfo->pBlockList, pFBlock->tbBlockIdx); + SBlock* pBlock = getCurrentBlock(pBlockIter); TSDBKEY key = getCurrentKeyInBuf(pBlockIter, pReader); if (fileBlockShouldLoad(pReader, pFBlock, pBlock, pScanInfo, key)) { - tBlockDataInit(&pStatus->fileBlockData); + tBlockDataReset(&pStatus->fileBlockData); + tBlockDataClearData(&pStatus->fileBlockData); code = doLoadFileBlockData(pReader, pBlockIter, pScanInfo, &pStatus->fileBlockData); if (code != TSDB_CODE_SUCCESS) { return code; @@ -1729,9 +1787,7 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) { // set the correct start position in case of the first/last file block, according to the query time window static void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter) { - SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(pBlockIter); - STableBlockScanInfo* pScanInfo = taosHashGet(pReader->status.pTableMap, &pFBlock->uid, sizeof(pFBlock->uid)); - SBlock* pBlock = taosArrayGet(pScanInfo->pBlockList, pFBlock->tbBlockIdx); + SBlock* pBlock = getCurrentBlock(pBlockIter); SReaderStatus* pStatus = &pReader->status; @@ -2102,6 +2158,8 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn } bool overlap = overlapWithNeighborBlock(pBlock, pNeighborBlock, pReader->order); + taosMemoryFree(pNeighborBlock); + if (overlap) { // load next block SReaderStatus* pStatus = &pReader->status; SDataBlockIter* pBlockIter = &pStatus->blockIter; @@ -2114,6 +2172,8 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn setFileBlockActiveInBlockIter(pBlockIter, neighborIndex, step); // 3. load the neighbor block, and set it to be the currently accessed file data block + tBlockDataReset(&pStatus->fileBlockData); + tBlockDataClearData(&pStatus->fileBlockData); int32_t code = doLoadFileBlockData(pReader, pBlockIter, pScanInfo, &pStatus->fileBlockData); if (code != TSDB_CODE_SUCCESS) { return code; @@ -2152,7 +2212,7 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc CHECK_FILEBLOCK_STATE st; SFileDataBlockInfo* pFileBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter); - SBlock* pCurrentBlock = taosArrayGet(pScanInfo->pBlockList, pFileBlockInfo->tbBlockIdx); + SBlock* pCurrentBlock = getCurrentBlock(&pReader->status.blockIter); checkForNeighborFileBlock(pReader, pScanInfo, pCurrentBlock, pFileBlockInfo, pMerger, key, &st); if (st == CHECK_FILEBLOCK_QUIT) { break; @@ -2461,7 +2521,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl SDataBlockIter* pBlockIter = &pReader->status.blockIter; initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader->order, pReader->idStr); - resetDataBlockIterator(&pReader->status.blockIter, pReader->order); + resetDataBlockIterator(&pReader->status.blockIter, pReader->order, pReader->status.pTableMap); // no data in files, let's try buffer in memory if (pReader->status.fileIter.numOfFiles == 0) { @@ -2477,7 +2537,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl SDataBlockIter* pBlockIter = &pPrevReader->status.blockIter; initFilesetIterator(&pPrevReader->status.fileIter, pPrevReader->pReadSnap->fs.aDFileSet, pPrevReader->order, pPrevReader->idStr); - resetDataBlockIterator(&pPrevReader->status.blockIter, pPrevReader->order); + resetDataBlockIterator(&pPrevReader->status.blockIter, pPrevReader->order, pReader->status.pTableMap); // no data in files, let's try buffer in memory if (pPrevReader->status.fileIter.numOfFiles == 0) { @@ -2517,8 +2577,11 @@ void tsdbReaderClose(STsdbReader* pReader) { } } taosMemoryFree(pSupInfo->buildBuf); + tBlockDataClear(&pReader->status.fileBlockData, true); cleanupDataBlockIterator(&pReader->status.blockIter); + + size_t numOfTables = taosHashGetSize(pReader->status.pTableMap); destroyBlockScanInfo(pReader->status.pTableMap); blockDataDestroy(pReader->pResBlock); @@ -2528,10 +2591,12 @@ void tsdbReaderClose(STsdbReader* pReader) { SIOCostSummary* pCost = &pReader->cost; - tsdbDebug("%p :io-cost summary: head-file read cnt:%" PRIu64 ", head-file time:%" PRIu64 " us, statis-info:%" PRId64 - " us, datablock:%" PRId64 " us, check data:%" PRId64 " us, %s", - pReader, pCost->headFileLoad, pCost->headFileLoadTime, pCost->smaLoadTime, pCost->blockLoadTime, - pCost->checkForNextTime, pReader->idStr); + tsdbDebug("%p :io-cost summary: head-file:%" PRIu64 ", head-file time:%.2f ms, SMA:%"PRId64" SMA-time:%.2f ms, " + "fileBlocks:%"PRId64", fileBlocks-time:%.2f ms, build in-memory-block-time:%.2f ms, STableBlockScanInfo " + "size:%.2f Kb %s", + pReader, pCost->headFileLoad, pCost->headFileLoadTime, pCost->smaData, pCost->smaLoadTime, + pCost->numOfBlocks, pCost->blockLoadTime, pCost->buildmemBlock, + numOfTables * sizeof(STableBlockScanInfo) /1000.0, pReader->idStr); taosMemoryFree(pReader->idStr); taosMemoryFree(pReader->pSchema); @@ -2543,7 +2608,6 @@ static bool doTsdbNextDataBlock(STsdbReader* pReader) { SSDataBlock* pBlock = pReader->pResBlock; blockDataCleanup(pBlock); - int64_t stime = taosGetTimestampUs(); SReaderStatus* pStatus = &pReader->status; if (pStatus->loadFromFile) { @@ -2639,9 +2703,8 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS } SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter); - STableBlockScanInfo* pBlockScanInfo = taosHashGet(pReader->status.pTableMap, &pFBlock->uid, sizeof(pFBlock->uid)); - SBlock* pBlock = taosArrayGet(pBlockScanInfo->pBlockList, pFBlock->tbBlockIdx); + SBlock* pBlock = getCurrentBlock(&pReader->status.blockIter); int64_t stime = taosGetTimestampUs(); SBlockLoadSuppInfo* pSup = &pReader->suppInfo; @@ -2690,12 +2753,13 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS } } - int64_t elapsed = taosGetTimestampUs() - stime; + double elapsed = (taosGetTimestampUs() - stime) / 1000.0; pReader->cost.smaLoadTime += elapsed; + pReader->cost.smaData += 1; *pBlockStatis = pSup->plist; - tsdbDebug("vgId:%d, succeed to load block SMA for uid %" PRIu64 ", elapsed time:%" PRId64 "us, %s", 0, pFBlock->uid, + tsdbDebug("vgId:%d, succeed to load block SMA for uid %" PRIu64 ", elapsed time:%.2f ms, %s", 0, pFBlock->uid, elapsed, pReader->idStr); return code; @@ -2711,13 +2775,9 @@ static SArray* doRetrieveDataBlock(STsdbReader* pReader) { SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pStatus->blockIter); STableBlockScanInfo* pBlockScanInfo = taosHashGet(pStatus->pTableMap, &pFBlock->uid, sizeof(pFBlock->uid)); - int32_t code = tBlockDataInit(&pStatus->fileBlockData); - if (code != TSDB_CODE_SUCCESS) { - terrno = code; - return NULL; - } - - code = doLoadFileBlockData(pReader, &pStatus->blockIter, pBlockScanInfo, &pStatus->fileBlockData); + tBlockDataReset(&pStatus->fileBlockData); + tBlockDataClearData(&pStatus->fileBlockData); + int32_t code = doLoadFileBlockData(pReader, &pStatus->blockIter, pBlockScanInfo, &pStatus->fileBlockData); if (code != TSDB_CODE_SUCCESS) { tBlockDataClear(&pStatus->fileBlockData, 1); @@ -2726,7 +2786,6 @@ static SArray* doRetrieveDataBlock(STsdbReader* pReader) { } copyBlockDataToSDataBlock(pReader, pBlockScanInfo); - tBlockDataClear(&pStatus->fileBlockData, 1); return pReader->pResBlock->pDataBlock; } @@ -2764,7 +2823,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) { tsdbDataFReaderClose(&pReader->pFileReader); initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader->order, pReader->idStr); - resetDataBlockIterator(&pReader->status.blockIter, pReader->order); + resetDataBlockIterator(&pReader->status.blockIter, pReader->order, pReader->status.pTableMap); resetDataBlockScanInfo(pReader->status.pTableMap); int32_t code = 0; @@ -2823,9 +2882,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa while (true) { if (hasNext) { - SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(pBlockIter); - STableBlockScanInfo* pScanInfo = taosHashGet(pStatus->pTableMap, &pFBlock->uid, sizeof(pFBlock->uid)); - SBlock* pBlock = taosArrayGet(pScanInfo->pBlockList, pFBlock->tbBlockIdx); + SBlock* pBlock = getCurrentBlock(pBlockIter); int32_t numOfRows = pBlock->nRow; pTableBlockInfo->totalRows += numOfRows; @@ -2846,7 +2903,6 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa pTableBlockInfo->blockRowsHisto[bucketIndex]++; hasNext = blockIteratorNext(&pStatus->blockIter); - } else { code = initForFirstBlockInFile(pReader, pBlockIter); if ((code != TSDB_CODE_SUCCESS) || (pReader->status.loadFromFile == false)) { diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index f318c69c6f70787a0a737a7b4134a7717acc8005..3e05b75dd010ec2336115efa8354e2892c07afa7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -24,6 +24,8 @@ void tMapDataReset(SMapData *pMapData) { void tMapDataClear(SMapData *pMapData) { tFree((uint8_t *)pMapData->aOffset); tFree(pMapData->pData); + pMapData->pData = NULL; + pMapData->aOffset = NULL; } int32_t tMapDataPutItem(SMapData *pMapData, void *pItem, int32_t (*tPutItemFn)(uint8_t *, void *)) { @@ -1020,6 +1022,10 @@ void tBlockDataClear(SBlockData *pBlockData, int8_t deepClear) { tFree((uint8_t *)pBlockData->aTSKEY); taosArrayDestroy(pBlockData->aIdx); taosArrayDestroyEx(pBlockData->aColData, deepClear ? tColDataClear : NULL); + pBlockData->aColData = NULL; + pBlockData->aIdx = NULL; + pBlockData->aTSKEY = NULL; + pBlockData->aVersion = NULL; } int32_t tBlockDataSetSchema(SBlockData *pBlockData, STSchema *pTSchema) { @@ -1395,10 +1401,26 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg) { break; case TSDB_DATA_TYPE_BOOL: break; - case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_TINYINT:{ + pColAgg->sum += colVal.value.i8; + if (pColAgg->min > colVal.value.i8) { + pColAgg->min = colVal.value.i8; + } + if (pColAgg->max < colVal.value.i8) { + pColAgg->max = colVal.value.i8; + } break; - case TSDB_DATA_TYPE_SMALLINT: + } + case TSDB_DATA_TYPE_SMALLINT:{ + pColAgg->sum += colVal.value.i16; + if (pColAgg->min > colVal.value.i16) { + pColAgg->min = colVal.value.i16; + } + if (pColAgg->max < colVal.value.i16) { + pColAgg->max = colVal.value.i16; + } break; + } case TSDB_DATA_TYPE_INT: { pColAgg->sum += colVal.value.i32; if (pColAgg->min > colVal.value.i32) { @@ -1419,24 +1441,79 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg) { } break; } - case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_FLOAT:{ + pColAgg->sum += colVal.value.f; + if (pColAgg->min > colVal.value.f) { + pColAgg->min = colVal.value.f; + } + if (pColAgg->max < colVal.value.f) { + pColAgg->max = colVal.value.f; + } break; - case TSDB_DATA_TYPE_DOUBLE: + } + case TSDB_DATA_TYPE_DOUBLE:{ + pColAgg->sum += colVal.value.d; + if (pColAgg->min > colVal.value.d) { + pColAgg->min = colVal.value.d; + } + if (pColAgg->max < colVal.value.d) { + pColAgg->max = colVal.value.d; + } break; + } case TSDB_DATA_TYPE_VARCHAR: break; - case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_TIMESTAMP:{ + if (pColAgg->min > colVal.value.i64) { + pColAgg->min = colVal.value.i64; + } + if (pColAgg->max < colVal.value.i64) { + pColAgg->max = colVal.value.i64; + } break; + } case TSDB_DATA_TYPE_NCHAR: break; - case TSDB_DATA_TYPE_UTINYINT: + case TSDB_DATA_TYPE_UTINYINT:{ + pColAgg->sum += colVal.value.u8; + if (pColAgg->min > colVal.value.u8) { + pColAgg->min = colVal.value.u8; + } + if (pColAgg->max < colVal.value.u8) { + pColAgg->max = colVal.value.u8; + } break; - case TSDB_DATA_TYPE_USMALLINT: + } + case TSDB_DATA_TYPE_USMALLINT:{ + pColAgg->sum += colVal.value.u16; + if (pColAgg->min > colVal.value.u16) { + pColAgg->min = colVal.value.u16; + } + if (pColAgg->max < colVal.value.u16) { + pColAgg->max = colVal.value.u16; + } break; - case TSDB_DATA_TYPE_UINT: + } + case TSDB_DATA_TYPE_UINT:{ + pColAgg->sum += colVal.value.u32; + if (pColAgg->min > colVal.value.u32) { + pColAgg->min = colVal.value.u32; + } + if (pColAgg->max < colVal.value.u32) { + pColAgg->max = colVal.value.u32; + } break; - case TSDB_DATA_TYPE_UBIGINT: + } + case TSDB_DATA_TYPE_UBIGINT:{ + pColAgg->sum += colVal.value.u64; + if (pColAgg->min > colVal.value.u64) { + pColAgg->min = colVal.value.u64; + } + if (pColAgg->max < colVal.value.u64) { + pColAgg->max = colVal.value.u64; + } break; + } case TSDB_DATA_TYPE_JSON: break; case TSDB_DATA_TYPE_VARBINARY: diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index eac1fd1a74dc9f83a15492c4e686b08d572734aa..e38fe9876b31be7d171a748c29a18ea5fc31c770 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -40,8 +40,8 @@ const SVnodeCfg vnodeCfgDefault = {.vgId = -1, .vgId = -1, .fsyncPeriod = 0, .retentionPeriod = -1, - .rollPeriod = -1, - .segSize = -1, + .rollPeriod = 0, + .segSize = 0, .retentionSize = -1, .level = TAOS_WAL_WRITE, }, diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 1c3e2f0514df46769786b05b7e529ab4913b5cea..71b9d70518947ba07253122f2f83c6841bb2b57f 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -21,7 +21,7 @@ int vnodeQueryOpen(SVnode *pVnode) { void vnodeQueryClose(SVnode *pVnode) { qWorkerDestroy((void **)&pVnode->pQuery); } -int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) { +int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) { STableInfoReq infoReq = {0}; STableMetaRsp metaRsp = {0}; SMetaReader mer1 = {0}; @@ -99,7 +99,12 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) { goto _exit; } - pRsp = rpcMallocCont(rspLen); + if (direct) { + pRsp = rpcMallocCont(rspLen); + } else { + pRsp = taosMemoryCalloc(1, rspLen); + } + if (pRsp == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; @@ -117,15 +122,19 @@ _exit: qError("get table %s meta failed cause of %s", infoReq.tbName, tstrerror(code)); } - tmsgSendRsp(&rpcMsg); - + if (direct) { + tmsgSendRsp(&rpcMsg); + } else { + *pMsg = rpcMsg; + } + taosMemoryFree(metaRsp.pSchemas); metaReaderClear(&mer2); metaReaderClear(&mer1); return TSDB_CODE_SUCCESS; } -int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg) { +int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) { STableCfgReq cfgReq = {0}; STableCfgRsp cfgRsp = {0}; SMetaReader mer1 = {0}; @@ -209,7 +218,12 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg) { goto _exit; } - pRsp = rpcMallocCont(rspLen); + if (direct) { + pRsp = rpcMallocCont(rspLen); + } else { + pRsp = taosMemoryCalloc(1, rspLen); + } + if (pRsp == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; @@ -227,14 +241,124 @@ _exit: qError("get table %s cfg failed cause of %s", cfgReq.tbName, tstrerror(code)); } - tmsgSendRsp(&rpcMsg); - + if (direct) { + tmsgSendRsp(&rpcMsg); + } else { + *pMsg = rpcMsg; + } + tFreeSTableCfgRsp(&cfgRsp); metaReaderClear(&mer2); metaReaderClear(&mer1); return TSDB_CODE_SUCCESS; } +int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) { + int32_t code = 0; + int32_t offset = 0; + int32_t rspSize = 0; + SBatchReq *batchReq = (SBatchReq*)pMsg->pCont; + int32_t msgNum = ntohl(batchReq->msgNum); + offset += sizeof(SBatchReq); + SBatchMsg req = {0}; + SBatchRsp rsp = {0}; + SRpcMsg reqMsg = *pMsg; + SRpcMsg rspMsg = {0}; + void* pRsp = NULL; + + SArray* batchRsp = taosArrayInit(msgNum, sizeof(SBatchRsp)); + if (NULL == batchRsp) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + + for (int32_t i = 0; i < msgNum; ++i) { + req.msgType = ntohl(*(int32_t*)((char*)pMsg->pCont + offset)); + offset += sizeof(req.msgType); + + req.msgLen = ntohl(*(int32_t*)((char*)pMsg->pCont + offset)); + offset += sizeof(req.msgLen); + + req.msg = (char*)pMsg->pCont + offset; + offset += req.msgLen; + + reqMsg.msgType = req.msgType; + reqMsg.pCont = req.msg; + reqMsg.contLen = req.msgLen; + + switch (req.msgType) { + case TDMT_VND_TABLE_META: + vnodeGetTableMeta(pVnode, &reqMsg, false); + break; + case TDMT_VND_TABLE_CFG: + vnodeGetTableCfg(pVnode, &reqMsg, false); + break; + default: + qError("invalid req msgType %d", req.msgType); + reqMsg.code = TSDB_CODE_INVALID_MSG; + reqMsg.pCont = NULL; + reqMsg.contLen = 0; + break; + } + + rsp.reqType = reqMsg.msgType; + rsp.msgLen = reqMsg.contLen; + rsp.rspCode = reqMsg.code; + rsp.msg = reqMsg.pCont; + + taosArrayPush(batchRsp, &rsp); + + rspSize += sizeof(rsp) + rsp.msgLen - POINTER_BYTES; + } + + rspSize += sizeof(int32_t); + offset = 0; + + pRsp = rpcMallocCont(rspSize); + if (pRsp == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + + *(int32_t*)((char*)pRsp + offset) = htonl(msgNum); + offset += sizeof(msgNum); + for (int32_t i = 0; i < msgNum; ++i) { + SBatchRsp *p = taosArrayGet(batchRsp, i); + + *(int32_t*)((char*)pRsp + offset) = htonl(p->reqType); + offset += sizeof(p->reqType); + *(int32_t*)((char*)pRsp + offset) = htonl(p->msgLen); + offset += sizeof(p->msgLen); + *(int32_t*)((char*)pRsp + offset) = htonl(p->rspCode); + offset += sizeof(p->rspCode); + memcpy((char*)pRsp + offset, p->msg, p->msgLen); + offset += p->msgLen; + + taosMemoryFreeClear(p->msg); + } + + taosArrayDestroy(batchRsp); + batchRsp = NULL; + +_exit: + + rspMsg.info = pMsg->info; + rspMsg.pCont = pRsp; + rspMsg.contLen = rspSize; + rspMsg.code = code; + rspMsg.msgType = pMsg->msgType; + + if (code) { + qError("vnd get batch meta failed cause of %s", tstrerror(code)); + } + + taosArrayDestroyEx(batchRsp, tFreeSBatchRsp); + + tmsgSendRsp(&rspMsg); + + return code; +} + int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { pLoad->vgId = TD_VID(pVnode); pLoad->syncState = syncGetMyRole(pVnode->sync); diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 9d06fbffdd961f51f7a8c153eae8879411b70919..a83e1ab85b0b0f7172eafadf0f94ebc3777102ca 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -106,7 +106,9 @@ int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) { .meta = pVnode->pMeta, .config = &pVnode->config, .vnode = pVnode, .pMsgCb = &pVnode->msgCb}; code = qWorkerProcessDeleteMsg(&handle, pVnode->pQuery, pMsg, &res); - if (code) goto _err; + if (code) { + goto _err; + } // malloc and encode tEncodeSize(tEncodeDeleteRes, &res, size, ret); @@ -296,7 +298,7 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) { int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { vTrace("message in fetch queue is processing"); if ((pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_VND_TABLE_META || - pMsg->msgType == TDMT_VND_TABLE_CFG) && + pMsg->msgType == TDMT_VND_TABLE_CFG || pMsg->msgType == TDMT_VND_BATCH_META) && !vnodeIsLeader(pVnode)) { vnodeRedirectRpcMsg(pVnode, pMsg); return 0; @@ -318,9 +320,11 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { case TDMT_SCH_QUERY_HEARTBEAT: return qWorkerProcessHbMsg(pVnode, pVnode->pQuery, pMsg, 0); case TDMT_VND_TABLE_META: - return vnodeGetTableMeta(pVnode, pMsg); + return vnodeGetTableMeta(pVnode, pMsg, true); case TDMT_VND_TABLE_CFG: - return vnodeGetTableCfg(pVnode, pMsg); + return vnodeGetTableCfg(pVnode, pMsg, true); + case TDMT_VND_BATCH_META: + return vnodeGetBatchMeta(pVnode, pMsg); case TDMT_VND_CONSUME: return tqProcessPollReq(pVnode->pTq, pMsg); case TDMT_STREAM_TASK_RUN: @@ -993,6 +997,11 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t version, void *pReq SDecoder *pCoder = &(SDecoder){0}; SDeleteRes *pRes = &(SDeleteRes){0}; + pRsp->msgType = TDMT_VND_DELETE_RSP; + pRsp->pCont = NULL; + pRsp->contLen = 0; + pRsp->code = TSDB_CODE_SUCCESS; + pRes->uidList = taosArrayInit(0, sizeof(tb_uid_t)); if (pRes->uidList == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -1010,6 +1019,15 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t version, void *pReq tDecoderClear(pCoder); taosArrayDestroy(pRes->uidList); + + SVDeleteRsp rsp = {.affectedRows = pRes->affectedRows}; + int32_t ret = 0; + tEncodeSize(tEncodeSVDeleteRsp, &rsp, pRsp->contLen, ret); + pRsp->pCont = rpcMallocCont(pRsp->contLen); + SEncoder ec = {0}; + tEncoderInit(&ec, pRsp->pCont, pRsp->contLen); + tEncodeSVDeleteRsp(&ec, &rsp); + tEncoderClear(&ec); return code; _err: diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index dbe44586813e27fba988f57efacfbd0cfce4134a..98e1716d9c423d9a11d20a91198b85ea687b476a 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -16,23 +16,28 @@ #define _DEFAULT_SOURCE #include "vnd.h" +#define BATCH_DISABLE 1 + static inline bool vnodeIsMsgBlock(tmsg_t type) { return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_CREATE_TABLE) || - (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) || (type == TDMT_VND_UPDATE_TAG_VAL); + (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) || (type == TDMT_VND_UPDATE_TAG_VAL) || + (type == TDMT_VND_ALTER_REPLICA); } static inline bool vnodeIsMsgWeak(tmsg_t type) { return false; } static inline void vnodeWaitBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) { if (vnodeIsMsgBlock(pMsg->msgType)) { - vTrace("vgId:%d, msg:%p wait block, type:%s", pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType)); + const STraceId *trace = &pMsg->info.traceId; + vGTrace("vgId:%d, msg:%p wait block, type:%s", pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType)); tsem_wait(&pVnode->syncSem); } } static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) { if (vnodeIsMsgBlock(pMsg->msgType)) { - vTrace("vgId:%d, msg:%p post block, type:%s", pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType)); + const STraceId *trace = &pMsg->info.traceId; + vGTrace("vgId:%d, msg:%p post block, type:%s", pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType)); tsem_post(&pVnode->syncSem); } } @@ -124,60 +129,147 @@ void vnodeRedirectRpcMsg(SVnode *pVnode, SRpcMsg *pMsg) { tmsgSendRedirectRsp(&rsp, &newEpSet); } -void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { - SVnode *pVnode = pInfo->ahandle; - int32_t vgId = pVnode->config.vgId; - int32_t code = 0; - SRpcMsg *pMsg = NULL; +static void inline vnodeHandleWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) { + SRpcMsg rsp = {.code = pMsg->code, .info = pMsg->info}; + if (vnodeProcessWriteMsg(pVnode, pMsg, pMsg->info.conn.applyIndex, &rsp) < 0) { + rsp.code = terrno; + const STraceId *trace = &pMsg->info.traceId; + vGError("vgId:%d, msg:%p failed to apply right now since %s", pVnode->config.vgId, pMsg, terrstr()); + } + if (rsp.info.handle != NULL) { + tmsgSendRsp(&rsp); + } +} + +static void vnodeHandleProposeError(SVnode *pVnode, SRpcMsg *pMsg, int32_t code) { + if (code == TSDB_CODE_SYN_NOT_LEADER) { + vnodeRedirectRpcMsg(pVnode, pMsg); + } else { + const STraceId *trace = &pMsg->info.traceId; + vGError("vgId:%d, msg:%p failed to propose since %s, code:0x%x", pVnode->config.vgId, pMsg, tstrerror(code), code); + SRpcMsg rsp = {.code = code, .info = pMsg->info}; + if (rsp.info.handle != NULL) { + tmsgSendRsp(&rsp); + } + } +} + +static void vnodeHandleAlterReplicaReq(SVnode *pVnode, SRpcMsg *pMsg) { + int32_t code = vnodeProcessAlterReplicaReq(pVnode, pMsg); + + if (code > 0) { + ASSERT(0); + } else if (code == 0) { + vnodeWaitBlockMsg(pVnode, pMsg); + } else { + if (terrno != 0) code = terrno; + vnodeHandleProposeError(pVnode, pMsg, code); + } + + const STraceId *trace = &pMsg->info.traceId; + vGTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->config.vgId, pMsg, code); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); +} + +static void inline vnodeProposeBatchMsg(SVnode *pVnode, SRpcMsg **pMsgArr, bool *pIsWeakArr, int32_t *arrSize) { + if (*arrSize <= 0) return; + +#if BATCH_DISABLE + int32_t code = syncPropose(pVnode->sync, pMsgArr[0], pIsWeakArr[0]); +#else + int32_t code = syncProposeBatch(pVnode->sync, pMsgArr, pIsWeakArr, *arrSize); +#endif + + if (code > 0) { + for (int32_t i = 0; i < *arrSize; ++i) { + vnodeHandleWriteMsg(pVnode, pMsgArr[i]); + } + } else if (code == 0) { + vnodeWaitBlockMsg(pVnode, pMsgArr[*arrSize - 1]); + } else { + if (terrno != 0) code = terrno; + for (int32_t i = 0; i < *arrSize; ++i) { + vnodeHandleProposeError(pVnode, pMsgArr[i], code); + } + } + + for (int32_t i = 0; i < *arrSize; ++i) { + SRpcMsg *pMsg = pMsgArr[i]; + const STraceId *trace = &pMsg->info.traceId; + vGTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->config.vgId, pMsg, code); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); + } + + *arrSize = 0; +} +void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { + SVnode *pVnode = pInfo->ahandle; + int32_t vgId = pVnode->config.vgId; + int32_t code = 0; + SRpcMsg *pMsg = NULL; + int32_t arrayPos = 0; + SRpcMsg **pMsgArr = taosMemoryCalloc(numOfMsgs, sizeof(SRpcMsg *)); + bool *pIsWeakArr = taosMemoryCalloc(numOfMsgs, sizeof(bool)); vTrace("vgId:%d, get %d msgs from vnode-write queue", vgId, numOfMsgs); - for (int32_t m = 0; m < numOfMsgs; m++) { + for (int32_t msg = 0; msg < numOfMsgs; msg++) { if (taosGetQitem(qall, (void **)&pMsg) == 0) continue; + bool isWeak = vnodeIsMsgWeak(pMsg->msgType); + bool isBlock = vnodeIsMsgBlock(pMsg->msgType); + const STraceId *trace = &pMsg->info.traceId; - vGTrace("vgId:%d, msg:%p get from vnode-write queue handle:%p", vgId, pMsg, pMsg->info.handle); + vGTrace("vgId:%d, msg:%p get from vnode-write queue, weak:%d block:%d msg:%d:%d pos:%d, handle:%p", vgId, pMsg, + isWeak, isBlock, msg, numOfMsgs, arrayPos, pMsg->info.handle); + + if (!pVnode->restored) { + vGError("vgId:%d, msg:%p failed to process since not leader", vgId, pMsg); + terrno = TSDB_CODE_APP_NOT_READY; + vnodeHandleProposeError(pVnode, pMsg, TSDB_CODE_APP_NOT_READY); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); + continue; + } + + if (pMsgArr == NULL || pIsWeakArr == NULL) { + vGError("vgId:%d, msg:%p failed to process since out of memory", vgId, pMsg); + terrno = TSDB_CODE_OUT_OF_MEMORY; + vnodeHandleProposeError(pVnode, pMsg, terrno); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); + continue; + } code = vnodePreProcessWriteMsg(pVnode, pMsg); if (code != 0) { - vError("vgId:%d, msg:%p failed to pre-process since %s", vgId, pMsg, terrstr()); - } else { - if (pMsg->msgType == TDMT_VND_ALTER_REPLICA) { - code = vnodeProcessAlterReplicaReq(pVnode, pMsg); - } else { - code = syncPropose(pVnode->sync, pMsg, vnodeIsMsgWeak(pMsg->msgType)); - if (code > 0) { - SRpcMsg rsp = {.code = pMsg->code, .info = pMsg->info}; - if (vnodeProcessWriteMsg(pVnode, pMsg, pMsg->info.conn.applyIndex, &rsp) < 0) { - rsp.code = terrno; - vError("vgId:%d, msg:%p failed to apply right now since %s", vgId, pMsg, terrstr()); - } - if (rsp.info.handle != NULL) { - tmsgSendRsp(&rsp); - } - } else if (code == 0) { - vnodeWaitBlockMsg(pVnode, pMsg); - } else { - } - } + vGError("vgId:%d, msg:%p failed to pre-process since %s", vgId, pMsg, terrstr()); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); + continue; } - if (code < 0) { - if (terrno == TSDB_CODE_SYN_NOT_LEADER) { - vnodeRedirectRpcMsg(pVnode, pMsg); - } else { - if (terrno != 0) code = terrno; - vError("vgId:%d, msg:%p failed to propose since %s, code:0x%x", vgId, pMsg, tstrerror(code), code); - SRpcMsg rsp = {.code = code, .info = pMsg->info}; - if (rsp.info.handle != NULL) { - tmsgSendRsp(&rsp); - } - } + if (pMsg->msgType == TDMT_VND_ALTER_REPLICA) { + vnodeHandleAlterReplicaReq(pVnode, pMsg); + continue; } - vGTrace("vgId:%d, msg:%p is freed, code:0x%x", vgId, pMsg, code); - rpcFreeCont(pMsg->pCont); - taosFreeQitem(pMsg); + if (isBlock || BATCH_DISABLE) { + vnodeProposeBatchMsg(pVnode, pMsgArr, pIsWeakArr, &arrayPos); + } + + pMsgArr[arrayPos] = pMsg; + pIsWeakArr[arrayPos] = isWeak; + arrayPos++; + + if (isBlock || msg == numOfMsgs - 1 || BATCH_DISABLE) { + vnodeProposeBatchMsg(pVnode, pMsgArr, pIsWeakArr, &arrayPos); + } } + + taosMemoryFree(pMsgArr); + taosMemoryFree(pIsWeakArr); } void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { @@ -189,8 +281,8 @@ void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { for (int32_t i = 0; i < numOfMsgs; ++i) { if (taosGetQitem(qall, (void **)&pMsg) == 0) continue; const STraceId *trace = &pMsg->info.traceId; - vGTrace("vgId:%d, msg:%p get from vnode-apply queue, type:%s handle:%p", vgId, pMsg, TMSG_INFO(pMsg->msgType), - pMsg->info.handle); + vGInfo("vgId:%d, msg:%p get from vnode-apply queue, type:%s handle:%p index:%ld", vgId, pMsg, + TMSG_INFO(pMsg->msgType), pMsg->info.handle, pMsg->info.conn.applyIndex); SRpcMsg rsp = {.code = pMsg->code, .info = pMsg->info}; if (rsp.code == 0) { @@ -321,7 +413,7 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { SyncClientRequestBatch *pSyncMsg = syncClientRequestBatchFromRpcMsg(pMsg); ASSERT(pSyncMsg != NULL); code = syncNodeOnClientRequestBatchCb(pSyncNode, pSyncMsg); - syncClientRequestBatchDestroyDeep(pSyncMsg); + syncClientRequestBatchDestroy(pSyncMsg); } else if (pMsg->msgType == TDMT_SYNC_REQUEST_VOTE) { SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pMsg); ASSERT(pSyncMsg != NULL); @@ -409,34 +501,59 @@ static void vnodeSyncReconfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReCon } static void vnodeSyncCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { - SVnode *pVnode = pFsm->data; - vTrace("vgId:%d, commit-cb is excuted, fsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s, msgtype:%d %s", - syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, - syncUtilState2String(cbMeta.state), pMsg->msgType, TMSG_INFO(pMsg->msgType)); - - if (cbMeta.code == 0) { - SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen}; - rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen); - memcpy(rpcMsg.pCont, pMsg->pCont, pMsg->contLen); - syncGetAndDelRespRpc(pVnode->sync, cbMeta.seqNum, &rpcMsg.info); - rpcMsg.info.conn.applyIndex = cbMeta.index; - rpcMsg.info.conn.applyTerm = cbMeta.term; - tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg); - } else { - SRpcMsg rsp = {.code = cbMeta.code, .info = pMsg->info}; - vError("vgId:%d, sync commit error, msgtype:%d,%s, error:0x%X, errmsg:%s", syncGetVgId(pVnode->sync), pMsg->msgType, - TMSG_INFO(pMsg->msgType), cbMeta.code, tstrerror(cbMeta.code)); - if (rsp.info.handle != NULL) { - tmsgSendRsp(&rsp); + if (cbMeta.isWeak == 0) { + SVnode *pVnode = pFsm->data; + + if (cbMeta.code == 0) { + SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen}; + rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen); + memcpy(rpcMsg.pCont, pMsg->pCont, pMsg->contLen); + syncGetAndDelRespRpc(pVnode->sync, cbMeta.seqNum, &rpcMsg.info); + rpcMsg.info.conn.applyIndex = cbMeta.index; + rpcMsg.info.conn.applyTerm = cbMeta.term; + + vInfo("vgId:%d, commit-cb is excuted, fsm:%p, index:%" PRId64 ", term:%" PRIu64 ", msg-index:%" PRId64 + ", isWeak:%d, code:%d, state:%d %s, msgtype:%d %s", + syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.term, rpcMsg.info.conn.applyIndex, cbMeta.isWeak, + cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), pMsg->msgType, TMSG_INFO(pMsg->msgType)); + + tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg); + } else { + SRpcMsg rsp = {.code = cbMeta.code, .info = pMsg->info}; + vError("vgId:%d, sync commit error, msgtype:%d,%s, index:%ld, error:0x%X, errmsg:%s", syncGetVgId(pVnode->sync), + pMsg->msgType, TMSG_INFO(pMsg->msgType), cbMeta.index, cbMeta.code, tstrerror(cbMeta.code)); + if (rsp.info.handle != NULL) { + tmsgSendRsp(&rsp); + } } } } static void vnodeSyncPreCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { - SVnode *pVnode = pFsm->data; - vTrace("vgId:%d, pre-commit-cb is excuted, fsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s, msgtype:%d %s", - syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, - syncUtilState2String(cbMeta.state), pMsg->msgType, TMSG_INFO(pMsg->msgType)); + if (cbMeta.isWeak == 1) { + SVnode *pVnode = pFsm->data; + vTrace("vgId:%d, pre-commit-cb is excuted, fsm:%p, index:%" PRId64 + ", isWeak:%d, code:%d, state:%d %s, msgtype:%d %s", + syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, + syncUtilState2String(cbMeta.state), pMsg->msgType, TMSG_INFO(pMsg->msgType)); + + if (cbMeta.code == 0) { + SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen}; + rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen); + memcpy(rpcMsg.pCont, pMsg->pCont, pMsg->contLen); + syncGetAndDelRespRpc(pVnode->sync, cbMeta.seqNum, &rpcMsg.info); + rpcMsg.info.conn.applyIndex = cbMeta.index; + rpcMsg.info.conn.applyTerm = cbMeta.term; + tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg); + } else { + SRpcMsg rsp = {.code = cbMeta.code, .info = pMsg->info}; + vError("vgId:%d, sync pre-commit error, msgtype:%d,%s, error:0x%X, errmsg:%s", syncGetVgId(pVnode->sync), + pMsg->msgType, TMSG_INFO(pMsg->msgType), cbMeta.code, tstrerror(cbMeta.code)); + if (rsp.info.handle != NULL) { + tmsgSendRsp(&rsp); + } + } + } } static void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { @@ -527,6 +644,12 @@ static void vnodeLeaderTransfer(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsm SVnode *pVnode = pFsm->data; } +static void vnodeRestoreFinish(struct SSyncFSM *pFsm) { + SVnode *pVnode = pFsm->data; + pVnode->restored = true; + vDebug("vgId:%d, sync restore finished", pVnode->config.vgId); +} + static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) { SSyncFSM *pFsm = taosMemoryCalloc(1, sizeof(SSyncFSM)); pFsm->data = pVnode; @@ -534,7 +657,7 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) { pFsm->FpPreCommitCb = vnodeSyncPreCommitMsg; pFsm->FpRollBackCb = vnodeSyncRollBackMsg; pFsm->FpGetSnapshotInfo = vnodeSyncGetSnapshot; - pFsm->FpRestoreFinishCb = NULL; + pFsm->FpRestoreFinishCb = vnodeRestoreFinish; pFsm->FpLeaderTransferCb = vnodeLeaderTransfer; pFsm->FpReConfigCb = vnodeSyncReconfig; pFsm->FpSnapshotStartRead = vnodeSnapshotStartRead; @@ -588,11 +711,10 @@ bool vnodeIsLeader(SVnode *pVnode) { return false; } - // todo - // if (!pVnode->restored) { - // terrno = TSDB_CODE_APP_NOT_READY; - // return false; - // } + if (!pVnode->restored) { + terrno = TSDB_CODE_APP_NOT_READY; + return false; + } return true; } \ No newline at end of file diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index bf3bc1f0f4937c3c3098ea8573c4ddbdfae42156..1aaa1ecfd723d573e885975fdd3dfd5afd4ba55f 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -31,6 +31,7 @@ extern "C" { #define CTG_DEFAULT_RENT_SECOND 10 #define CTG_DEFAULT_RENT_SLOT_SIZE 10 #define CTG_DEFAULT_MAX_RETRY_TIMES 3 +#define CTG_DEFAULT_BATCH_NUM 64 #define CTG_RENT_SLOT_SECOND 1.5 @@ -38,6 +39,8 @@ extern "C" { #define CTG_ERR_CODE_TABLE_NOT_EXIST TSDB_CODE_PAR_TABLE_NOT_EXIST +#define CTG_BATCH_FETCH 1 + enum { CTG_READ = 1, CTG_WRITE, @@ -200,8 +203,20 @@ typedef struct SCatalog { SCtgRentMgmt stbRent; } SCatalog; +typedef struct SCtgBatch { + int32_t batchId; + int32_t msgType; + int32_t msgSize; + SArray* pMsgs; + SRequestConnInfo conn; + char dbFName[TSDB_DB_FNAME_LEN]; + SArray* pTaskIds; +} SCtgBatch; + typedef struct SCtgJob { int64_t refId; + int32_t batchId; + SHashObj* pBatchs; SArray* pTasks; int32_t taskDone; SMetaData jobRes; @@ -236,6 +251,16 @@ typedef struct SCtgMsgCtx { char* target; } SCtgMsgCtx; + +typedef struct SCtgTaskCallbackParam { + uint64_t queryId; + int64_t refId; + SArray* taskId; + int32_t reqType; + int32_t batchId; +} SCtgTaskCallbackParam; + + typedef struct SCtgTask SCtgTask; typedef int32_t (*ctgSubTaskCbFp)(SCtgTask*); @@ -258,6 +283,7 @@ typedef struct SCtgTask { SRWLatch lock; SArray* pParents; SCtgSubRes subRes; + SHashObj* pBatchs; } SCtgTask; typedef int32_t (*ctgInitTaskFp)(SCtgJob*, int32_t, void*); @@ -618,6 +644,7 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SNa int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableCfg **out, SCtgTask* pTask); int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg **out, SCtgTask* pTask); int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **out, SCtgTask* pTask); +int32_t ctgLaunchBatchs(SCatalog* pCtg, SCtgJob *pJob, SHashObj* pBatchs); int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, void* param); int32_t ctgLaunchJob(SCtgJob *pJob); @@ -626,6 +653,9 @@ int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp, int32_t ctgGetTbCfgCb(SCtgTask *pTask); void ctgFreeHandle(SCatalog* pCatalog); +void ctgFreeMsgSendParam(void* param); +void ctgFreeBatch(SCtgBatch *pBatch); +void ctgFreeBatchs(SHashObj *pBatchs); int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst); int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput); int32_t ctgGenerateVgList(SCatalog *pCtg, SHashObj *vgHash, SArray** pList); @@ -642,7 +672,7 @@ int32_t ctgDbVgVersionSearchCompare(const void* key1, const void* key2); void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput); int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target); char * ctgTaskTypeStr(CTG_TASK_TYPE type); -int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, SCtgTask* pTask); +int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, char* dbFName, int32_t vgId); int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes); void ctgFreeSTableIndex(void *info); void ctgClearSubTaskRes(SCtgSubRes *pRes); diff --git a/source/libs/catalog/inc/ctgRemote.h b/source/libs/catalog/inc/ctgRemote.h index cd88863c1b9b306b264cd05986f0a7e3a6b814d8..fe0762a88af49d8ed8ee873f03b719b0bc169a79 100644 --- a/source/libs/catalog/inc/ctgRemote.h +++ b/source/libs/catalog/inc/ctgRemote.h @@ -20,12 +20,6 @@ extern "C" { #endif -typedef struct SCtgTaskCallbackParam { - uint64_t queryId; - int64_t refId; - uint64_t taskId; - int32_t reqType; -} SCtgTaskCallbackParam; #ifdef __cplusplus diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index 920acbac2e13b40d66085c0a4310490e6d4cd026..f4cee13ec0e6f8ad67cf01e557bd7bcce3aa1f91 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -473,8 +473,15 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const pJob->tbCfgNum = tbCfgNum; pJob->svrVerNum = svrVerNum; - pJob->pTasks = taosArrayInit(taskNum, sizeof(SCtgTask)); +#if CTG_BATCH_FETCH + pJob->pBatchs = taosHashInit(CTG_DEFAULT_BATCH_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + if (NULL == pJob->pBatchs) { + ctgError("taosHashInit %d batch failed", CTG_DEFAULT_BATCH_NUM); + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } +#endif + pJob->pTasks = taosArrayInit(taskNum, sizeof(SCtgTask)); if (NULL == pJob->pTasks) { ctgError("taosArrayInit %d tasks failed", taskNum); CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); @@ -560,7 +567,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const _return: - taosMemoryFreeClear(*job); + ctgFreeJob(*job); CTG_RET(code); } @@ -776,7 +783,8 @@ int32_t ctgCallSubCb(SCtgTask *pTask) { pParent->subRes.code = code; } } - + + pParent->pBatchs = pTask->pBatchs; CTG_ERR_JRET(pParent->subRes.fp(pParent)); } @@ -872,7 +880,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf * SVgroupInfo vgInfo = {0}; CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, ctx->pName, &vgInfo)); - ctgDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(ctx->pName), ctx->flag); + ctgDebug("will refresh tbmeta, supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(ctx->pName), ctx->flag); ctx->vgId = vgInfo.vgId; CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, ctx->pName, &vgInfo, NULL, pTask)); @@ -890,7 +898,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf * return TSDB_CODE_SUCCESS; } - ctgError("no tbmeta got, tbNmae:%s", tNameGetTableName(ctx->pName)); + ctgError("no tbmeta got, tbName:%s", tNameGetTableName(ctx->pName)); ctgRemoveTbMetaFromCache(pCtg, ctx->pName, false); CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST); @@ -1653,6 +1661,7 @@ int32_t ctgSetSubTaskCb(SCtgTask *pSub, SCtgTask *pTask) { if (CTG_TASK_DONE == pSub->status) { pTask->subRes.code = pSub->code; CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].cloneFp)(pSub, &pTask->subRes.res)); + pTask->pBatchs = pSub->pBatchs; CTG_ERR_JRET(pTask->subRes.fp(pTask)); } else { if (NULL == pSub->pParents) { @@ -1690,6 +1699,7 @@ int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp, CTG_ERR_RET(ctgSetSubTaskCb(pSub, pTask)); if (newTask) { + pSub->pBatchs = pTask->pBatchs; CTG_ERR_RET((*gCtgAsyncFps[pSub->type].launchFp)(pSub)); pSub->status = CTG_TASK_LAUNCHED; } @@ -1702,9 +1712,11 @@ int32_t ctgLaunchJob(SCtgJob *pJob) { for (int32_t i = 0; i < taskNum; ++i) { SCtgTask *pTask = taosArrayGet(pJob->pTasks, i); + pTask->pBatchs = pJob->pBatchs; qDebug("QID:0x%" PRIx64 " ctg launch [%dth] task", pJob->queryId, pTask->taskId); CTG_ERR_RET((*gCtgAsyncFps[pTask->type].launchFp)(pTask)); + pTask->status = CTG_TASK_LAUNCHED; } @@ -1712,6 +1724,10 @@ int32_t ctgLaunchJob(SCtgJob *pJob) { qDebug("QID:0x%" PRIx64 " ctg call user callback with rsp %s", pJob->queryId, tstrerror(pJob->jobResCode)); taosAsyncExec(ctgCallUserCb, pJob, NULL); +#if CTG_BATCH_FETCH + } else { + ctgLaunchBatchs(pJob->pCtg, pJob, pJob->pBatchs); +#endif } return TSDB_CODE_SUCCESS; diff --git a/source/libs/catalog/src/ctgRemote.c b/source/libs/catalog/src/ctgRemote.c index cc5dde929811a8900192d3f12414f2eed4887923..55bfc88a49f63cd2bf2a869f969e9e1e890746a0 100644 --- a/source/libs/catalog/src/ctgRemote.c +++ b/source/libs/catalog/src/ctgRemote.c @@ -18,9 +18,67 @@ #include "tname.h" #include "catalogInt.h" #include "systable.h" -#include "ctgRemote.h" #include "tref.h" +int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBuf *pMsg, int32_t rspCode) { + int32_t code = 0; + SArray* pTaskId = cbParam->taskId; + SCatalog* pCtg = pJob->pCtg; + int32_t taskNum = taosArrayGetSize(pTaskId); + SDataBuf taskMsg = *pMsg; + int32_t offset = 0; + int32_t msgNum = (TSDB_CODE_SUCCESS == rspCode && pMsg->pData && (pMsg->len > 0)) ? ntohl(*(int32_t*)pMsg->pData) : 0; + ASSERT(taskNum == msgNum || 0 == msgNum); + + ctgDebug("QID:0x%" PRIx64 " ctg got batch %d rsp %s", pJob->queryId, cbParam->batchId, TMSG_INFO(cbParam->reqType + 1)); + + offset += sizeof(msgNum); + SBatchRsp rsp = {0}; + SHashObj* pBatchs = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + if (NULL == pBatchs) { + ctgError("taosHashInit %d batch failed", taskNum); + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + + for (int32_t i = 0; i < taskNum; ++i) { + int32_t* taskId = taosArrayGet(pTaskId, i); + SCtgTask *pTask = taosArrayGet(pJob->pTasks, *taskId); + if (msgNum > 0) { + rsp.reqType = ntohl(*(int32_t*)((char*)pMsg->pData + offset)); + offset += sizeof(rsp.reqType); + rsp.msgLen = ntohl(*(int32_t*)((char*)pMsg->pData + offset)); + offset += sizeof(rsp.msgLen); + rsp.rspCode = ntohl(*(int32_t*)((char*)pMsg->pData + offset)); + offset += sizeof(rsp.rspCode); + rsp.msg = ((char*)pMsg->pData) + offset; + offset += rsp.msgLen; + + taskMsg.msgType = rsp.reqType; + taskMsg.pData = rsp.msg; + taskMsg.len = rsp.msgLen; + } else { + rsp.reqType = -1; + taskMsg.msgType = -1; + taskMsg.pData = NULL; + taskMsg.len = 0; + } + + pTask->pBatchs = pBatchs; + + ctgDebug("QID:0x%" PRIx64 " ctg task %d start to handle rsp %s", pJob->queryId, pTask->taskId, TMSG_INFO(taskMsg.msgType + 1)); + + (*gCtgAsyncFps[pTask->type].handleRspFp)(pTask, rsp.reqType, &taskMsg, (rsp.rspCode ? rsp.rspCode : rspCode)); + } + + CTG_ERR_JRET(ctgLaunchBatchs(pJob->pCtg, pJob, pBatchs)); + +_return: + + ctgFreeBatchs(pBatchs); + CTG_RET(code); +} + + int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, int32_t rspCode, char* target) { int32_t code = 0; @@ -233,6 +291,11 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, break; } default: + if (TSDB_CODE_SUCCESS != rspCode) { + qError("Got error rsp, error:%s", tstrerror(rspCode)); + CTG_ERR_RET(rspCode); + } + qError("invalid req type %s", TMSG_INFO(reqType)); return TSDB_CODE_APP_ERROR; } @@ -254,12 +317,32 @@ int32_t ctgHandleMsgCallback(void *param, SDataBuf *pMsg, int32_t rspCode) { goto _return; } - SCtgTask *pTask = taosArrayGet(pJob->pTasks, cbParam->taskId); + SCatalog* pCtg = pJob->pCtg; + + if (TDMT_VND_BATCH_META == cbParam->reqType || TDMT_MND_BATCH_META == cbParam->reqType) { + CTG_ERR_JRET(ctgHandleBatchRsp(pJob, cbParam, pMsg, rspCode)); + } else { + int32_t *taskId = taosArrayGet(cbParam->taskId, 0); + SCtgTask *pTask = taosArrayGet(pJob->pTasks, *taskId); + + qDebug("QID:0x%" PRIx64 " ctg task %d start to handle rsp %s", pJob->queryId, pTask->taskId, TMSG_INFO(cbParam->reqType + 1)); + +#if CTG_BATCH_FETCH + SHashObj* pBatchs = taosHashInit(CTG_DEFAULT_BATCH_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + if (NULL == pBatchs) { + ctgError("taosHashInit %d batch failed", CTG_DEFAULT_BATCH_NUM); + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + pTask->pBatchs = pBatchs; +#endif - qDebug("QID:0x%" PRIx64 " ctg task %d start to handle rsp %s", pJob->queryId, pTask->taskId, TMSG_INFO(cbParam->reqType + 1)); + CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].handleRspFp)(pTask, cbParam->reqType, pMsg, rspCode)); + +#if CTG_BATCH_FETCH + CTG_ERR_JRET(ctgLaunchBatchs(pJob->pCtg, pJob, pBatchs)); +#endif + } - CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].handleRspFp)(pTask, cbParam->reqType, pMsg, rspCode)); - _return: taosMemoryFree(pMsg->pData); @@ -272,12 +355,12 @@ _return: } -int32_t ctgMakeMsgSendInfo(SCtgTask* pTask, int32_t msgType, SMsgSendInfo **pMsgSendInfo) { +int32_t ctgMakeMsgSendInfo(SCtgJob* pJob, SArray* pTaskId, int32_t batchId, int32_t msgType, SMsgSendInfo **pMsgSendInfo) { int32_t code = 0; SMsgSendInfo *msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == msgSendInfo) { qError("calloc %d failed", (int32_t)sizeof(SMsgSendInfo)); - CTG_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + CTG_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } SCtgTaskCallbackParam *param = taosMemoryCalloc(1, sizeof(SCtgTaskCallbackParam)); @@ -287,12 +370,13 @@ int32_t ctgMakeMsgSendInfo(SCtgTask* pTask, int32_t msgType, SMsgSendInfo **pMsg } param->reqType = msgType; - param->queryId = pTask->pJob->queryId; - param->refId = pTask->pJob->refId; - param->taskId = pTask->taskId; + param->queryId = pJob->queryId; + param->refId = pJob->refId; + param->taskId = pTaskId; + param->batchId = batchId; msgSendInfo->param = param; - msgSendInfo->paramFreeFp = taosMemoryFree; + msgSendInfo->paramFreeFp = ctgFreeMsgSendParam; msgSendInfo->fp = ctgHandleMsgCallback; *pMsgSendInfo = msgSendInfo; @@ -301,18 +385,19 @@ int32_t ctgMakeMsgSendInfo(SCtgTask* pTask, int32_t msgType, SMsgSendInfo **pMsg _return: - taosMemoryFree(param); - taosMemoryFree(msgSendInfo); + taosArrayDestroy(pTaskId); + destroySendMsgInfo(msgSendInfo); CTG_RET(code); } -int32_t ctgAsyncSendMsg(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTask* pTask, int32_t msgType, void *msg, uint32_t msgSize) { +int32_t ctgAsyncSendMsg(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob* pJob, SArray* pTaskId, + int32_t batchId, char* dbFName, int32_t vgId, int32_t msgType, void *msg, uint32_t msgSize) { int32_t code = 0; SMsgSendInfo *pMsgSendInfo = NULL; - CTG_ERR_JRET(ctgMakeMsgSendInfo(pTask, msgType, &pMsgSendInfo)); + CTG_ERR_JRET(ctgMakeMsgSendInfo(pJob, pTaskId, batchId, msgType, &pMsgSendInfo)); - ctgUpdateSendTargetInfo(pMsgSendInfo, msgType, pTask); + ctgUpdateSendTargetInfo(pMsgSendInfo, msgType, dbFName, vgId); pMsgSendInfo->requestId = pConn->requestId; pMsgSendInfo->requestObjRefId = pConn->requestObjRefId; @@ -323,24 +408,178 @@ int32_t ctgAsyncSendMsg(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTask* pTask int64_t transporterId = 0; code = asyncSendMsgToServer(pConn->pTrans, &pConn->mgmtEps, &transporterId, pMsgSendInfo); + pMsgSendInfo = NULL; if (code) { ctgError("asyncSendMsgToSever failed, error: %s", tstrerror(code)); CTG_ERR_JRET(code); } - ctgDebug("ctg req msg sent, reqId:0x%" PRIx64 ", msg type:%d, %s", pTask->pJob->queryId, msgType, TMSG_INFO(msgType)); + ctgDebug("ctg req msg sent, reqId:0x%" PRIx64 ", msg type:%d, %s", pJob->queryId, msgType, TMSG_INFO(msgType)); return TSDB_CODE_SUCCESS; _return: if (pMsgSendInfo) { - taosMemoryFreeClear(pMsgSendInfo->param); - taosMemoryFreeClear(pMsgSendInfo); + destroySendMsgInfo(pMsgSendInfo); } CTG_RET(code); } +int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo *pConn, SCtgTask* pTask, int32_t msgType, void *msg, uint32_t msgSize) { + int32_t code = 0; + SHashObj* pBatchs = pTask->pBatchs; + SCtgJob* pJob = pTask->pJob; + SCtgBatch* pBatch = taosHashGet(pBatchs, &vgId, sizeof(vgId)); + int32_t taskNum = taosArrayGetSize(pTask->pJob->pTasks); + SCtgBatch newBatch = {0}; + SBatchMsg req = {0}; + + if (NULL == pBatch) { + newBatch.pMsgs = taosArrayInit(taskNum, sizeof(SBatchMsg)); + newBatch.pTaskIds = taosArrayInit(taskNum, sizeof(int32_t)); + if (NULL == newBatch.pMsgs || NULL == newBatch.pTaskIds) { + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + + newBatch.conn = *pConn; + + req.msgType = msgType; + req.msgLen = msgSize; + req.msg = msg; + if (NULL == taosArrayPush(newBatch.pMsgs, &req)) { + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + if (NULL == taosArrayPush(newBatch.pTaskIds, &pTask->taskId)) { + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + newBatch.msgSize = sizeof(SBatchReq) + sizeof(req) + msgSize - POINTER_BYTES; + + if (vgId > 0) { + if (TDMT_VND_TABLE_CFG == msgType) { + SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx; + tNameGetFullDbName(ctx->pName, newBatch.dbFName); + } else if (TDMT_VND_TABLE_META == msgType) { + SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx; + tNameGetFullDbName(ctx->pName, newBatch.dbFName); + } else { + ctgError("invalid vnode msgType %d", msgType); + CTG_ERR_JRET(TSDB_CODE_APP_ERROR); + } + } + + newBatch.msgType = (vgId > 0) ? TDMT_VND_BATCH_META : TDMT_MND_BATCH_META; + newBatch.batchId = atomic_add_fetch_32(&pJob->batchId, 1); + + if (0 != taosHashPut(pBatchs, &vgId, sizeof(vgId), &newBatch, sizeof(newBatch))) { + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + + ctgDebug("task %d %s req added to batch %d, target vgId %d", pTask->taskId, TMSG_INFO(msgType), newBatch.batchId, vgId); + + return TSDB_CODE_SUCCESS; + } + + req.msgType = msgType; + req.msgLen = msgSize; + req.msg = msg; + if (NULL == taosArrayPush(pBatch->pMsgs, &req)) { + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + if (NULL == taosArrayPush(pBatch->pTaskIds, &pTask->taskId)) { + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + pBatch->msgSize += sizeof(req) + msgSize - POINTER_BYTES; + + if (vgId > 0) { + if (TDMT_VND_TABLE_CFG == msgType) { + SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx; + tNameGetFullDbName(ctx->pName, newBatch.dbFName); + } else if (TDMT_VND_TABLE_META == msgType) { + SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx; + tNameGetFullDbName(ctx->pName, newBatch.dbFName); + } else { + ctgError("invalid vnode msgType %d", msgType); + CTG_ERR_JRET(TSDB_CODE_APP_ERROR); + } + } + + ctgDebug("task %d %s req added to batch %d, target vgId %d", pTask->taskId, TMSG_INFO(msgType), pBatch->batchId, vgId); + + return TSDB_CODE_SUCCESS; + +_return: + + ctgFreeBatch(&newBatch); + taosMemoryFree(msg); + + return code; +} + +int32_t ctgBuildBatchReqMsg(SCtgBatch* pBatch, int32_t vgId, void** msg) { + *msg = taosMemoryMalloc(pBatch->msgSize); + if (NULL == (*msg)) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + + int32_t offset = 0; + int32_t num = taosArrayGetSize(pBatch->pMsgs); + SBatchReq *pBatchReq = (SBatchReq*)(*msg); + + pBatchReq->header.vgId = htonl(vgId); + pBatchReq->msgNum = htonl(num); + offset += sizeof(SBatchReq); + + for (int32_t i = 0; i < num; ++i) { + SBatchMsg* pReq = taosArrayGet(pBatch->pMsgs, i); + *(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgType); + offset += sizeof(pReq->msgType); + *(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgLen); + offset += sizeof(pReq->msgLen); + memcpy((char*)(*msg) + offset, pReq->msg, pReq->msgLen); + offset += pReq->msgLen; + } + + ASSERT(pBatch->msgSize == offset); + + qDebug("batch req %d to vg %d msg built with %d meta reqs", pBatch->batchId, vgId, num); + + return TSDB_CODE_SUCCESS; +} + +int32_t ctgLaunchBatchs(SCatalog* pCtg, SCtgJob *pJob, SHashObj* pBatchs) { + int32_t code = 0; + void* msg = NULL; + void* p = taosHashIterate(pBatchs, NULL); + while (NULL != p) { + size_t len = 0; + int32_t* vgId = taosHashGetKey(p, &len); + SCtgBatch* pBatch = (SCtgBatch*)p; + + ctgDebug("QID:0x%" PRIx64 " ctg start to launch batch %d", pJob->queryId, pBatch->batchId); + + CTG_ERR_JRET(ctgBuildBatchReqMsg(pBatch, *vgId, &msg)); + code = ctgAsyncSendMsg(pCtg, &pBatch->conn, pJob, pBatch->pTaskIds, pBatch->batchId, + pBatch->dbFName, *vgId, pBatch->msgType, msg, pBatch->msgSize); + pBatch->pTaskIds = NULL; + CTG_ERR_JRET(code); + + p = taosHashIterate(pBatchs, p); + } + + return TSDB_CODE_SUCCESS; + +_return: + + if (p) { + taosHashCancelIterate(pBatchs, p); + } + taosMemoryFree(msg); + + CTG_RET(code); +} + + int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray *out, SCtgTask* pTask) { char *msg = NULL; int32_t msgLen = 0; @@ -361,7 +600,18 @@ int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, NULL)); - CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen)); + +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen)); +#else + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); + + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen)); +#endif } SRpcMsg rpcMsg = { @@ -396,7 +646,18 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray if (pTask) { CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, NULL)); - CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen)); + +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen)); +#else + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); + + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen)); +#endif } SRpcMsg rpcMsg = { @@ -436,8 +697,18 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SBuildU CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, input->db)); + +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen)); +#else + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); - CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen)); + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen)); +#endif } SRpcMsg rpcMsg = { @@ -476,8 +747,18 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)dbFName)); + +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen)); +#else + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); - CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen)); + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen)); +#endif } SRpcMsg rpcMsg = { @@ -516,8 +797,18 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)indexName)); + +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen)); +#else + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); - CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen)); + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen)); +#endif } SRpcMsg rpcMsg = { @@ -559,8 +850,18 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *n } CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)tbFName)); + +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen)); +#else + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); - CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen)); + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen)); +#endif } SRpcMsg rpcMsg = { @@ -599,8 +900,18 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const ch CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)funcName)); + +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen)); +#else + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); - CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen)); + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen)); +#endif } SRpcMsg rpcMsg = { @@ -639,8 +950,18 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)user)); + +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen)); +#else + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); - CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen)); + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen)); +#endif } SRpcMsg rpcMsg = { @@ -684,8 +1005,17 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo *pConn, char CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, tbFName)); +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen)); +#else + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); - CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen)); + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen)); +#endif } SRpcMsg rpcMsg = { @@ -744,7 +1074,21 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SNa .requestId = pConn->requestId, .requestObjRefId = pConn->requestObjRefId, .mgmtEps = vgroupInfo->epSet}; - CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask, reqType, msg, msgLen)); + +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, pTask, reqType, msg, msgLen)); +#else + SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx; + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(ctx->pName, dbFName); + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); + + CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, dbFName, ctx->vgId, reqType, msg, msgLen)); +#endif } SRpcMsg rpcMsg = { @@ -791,7 +1135,20 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S .requestId = pConn->requestId, .requestObjRefId = pConn->requestObjRefId, .mgmtEps = vgroupInfo->epSet}; - CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask, reqType, msg, msgLen)); +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, pTask, reqType, msg, msgLen)); +#else + SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx; + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(ctx->pName, dbFName); + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); + + CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, dbFName, ctx->pVgInfo->vgId, reqType, msg, msgLen)); +#endif } SRpcMsg rpcMsg = { @@ -832,8 +1189,17 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S if (pTask) { CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, (char*)tbFName)); +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen)); +#else + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); - CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen)); + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen)); +#endif } SRpcMsg rpcMsg = { @@ -868,8 +1234,18 @@ int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **ou if (pTask) { CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, NULL)); + +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen)); +#else + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); - CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen)); + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen)); +#endif } SRpcMsg rpcMsg = { diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c index 1f0f074a0f39f1a870dd54ef7c3218fe72803d7b..e61becbe17f6250702cda1ced553a48b5190daab 100644 --- a/source/libs/catalog/src/ctgUtil.c +++ b/source/libs/catalog/src/ctgUtil.c @@ -19,6 +19,39 @@ #include "catalogInt.h" #include "systable.h" +void ctgFreeMsgSendParam(void* param) { + if (NULL == param) { + return; + } + + SCtgTaskCallbackParam* pParam = (SCtgTaskCallbackParam*)param; + taosArrayDestroy(pParam->taskId); + + taosMemoryFree(param); +} + +void ctgFreeBatch(SCtgBatch *pBatch) { + if (NULL == pBatch) { + return; + } + + taosArrayDestroy(pBatch->pMsgs); + taosArrayDestroy(pBatch->pTaskIds); +} + +void ctgFreeBatchs(SHashObj *pBatchs) { + void* p = taosHashIterate(pBatchs, NULL); + while (NULL != p) { + SCtgBatch* pBatch = (SCtgBatch*)p; + + ctgFreeBatch(pBatch); + + p = taosHashIterate(pBatchs, p); + } + + taosHashCleanup(pBatchs); +} + char *ctgTaskTypeStr(CTG_TASK_TYPE type) { switch (type) { case CTG_TASK_GET_QNODE: @@ -612,6 +645,7 @@ void ctgFreeJob(void* job) { uint64_t qid = pJob->queryId; ctgFreeTasks(pJob->pTasks); + ctgFreeBatchs(pJob->pBatchs); ctgFreeSMetaData(&pJob->jobRes); @@ -867,14 +901,10 @@ int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes) { } -int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, SCtgTask* pTask) { - if (msgType == TDMT_VND_TABLE_META) { - SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx; - char dbFName[TSDB_DB_FNAME_LEN]; - tNameGetFullDbName(ctx->pName, dbFName); - +int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, char* dbFName, int32_t vgId) { + if (msgType == TDMT_VND_TABLE_META || msgType == TDMT_VND_TABLE_CFG || msgType == TDMT_VND_BATCH_META) { pMsgSendInfo->target.type = TARGET_TYPE_VNODE; - pMsgSendInfo->target.vgId = ctx->vgId; + pMsgSendInfo->target.vgId = vgId; pMsgSendInfo->target.dbFName = strdup(dbFName); } else { pMsgSendInfo->target.type = TARGET_TYPE_MNODE; diff --git a/source/libs/catalog/test/catalogTests.cpp b/source/libs/catalog/test/catalogTests.cpp index 51b721f818d7404202be539a18234326d5b1372e..0be85333dca130884516c214e324fbab82e33953 100644 --- a/source/libs/catalog/test/catalogTests.cpp +++ b/source/libs/catalog/test/catalogTests.cpp @@ -103,7 +103,7 @@ void sendCreateDbMsg(void *shandle, SEpSet *pEpSet) { createReq.daysToKeep2 = 3650; createReq.minRows = 100; createReq.maxRows = 4096; - createReq.fsyncPeriod = 3000; + createReq.walFsyncPeriod = 3000; createReq.walLevel = 1; createReq.precision = 0; createReq.compression = 2; diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index 3cb2553f2e2be90020c3fcbd06ed00e3935a872d..7c95e71823ca227420adfcc9054cf15cf838a89e 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -225,7 +225,7 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbFName, S "CREATE DATABASE `%s` BUFFER %d CACHEMODEL %d COMP %d DURATION %dm " "FSYNC %d MAXROWS %d MINROWS %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d " "STRICT %d WAL %d VGROUPS %d SINGLE_STABLE %d", - dbFName, pCfg->buffer, pCfg->cacheLast, pCfg->compression, pCfg->daysPerFile, pCfg->fsyncPeriod, + dbFName, pCfg->buffer, pCfg->cacheLast, pCfg->compression, pCfg->daysPerFile, pCfg->walFsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2, pCfg->pages, pCfg->pageSize, prec, pCfg->replications, pCfg->strict, pCfg->walLevel, pCfg->numOfVgroups, 1 == pCfg->numOfStables); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 0beb6f17842ecbb8c414c33a6de5d84270e0fda3..a80c2c2feaf0c9a310d05012d1f3ebbca9926035 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -318,6 +318,7 @@ typedef struct STableScanInfo { int32_t currentTable; int8_t scanMode; int8_t noTable; + int8_t assignBlockUid; } STableScanInfo; typedef struct STableMergeScanInfo { @@ -359,6 +360,8 @@ typedef struct STableMergeScanInfo { // window to check if current data block needs to be loaded. SInterval interval; SSampleExecInfo sample; // sample execution info + + SSortExecInfo sortExecInfo; } STableMergeScanInfo; typedef struct STagScanInfo { @@ -466,7 +469,6 @@ typedef struct SStreamScanInfo { SSDataBlock* pUpdateDataRes; // status for tmq // SSchemaWrapper schema; - STqOffset offset; SNodeList* pGroupTags; SNode* pTagCond; SNode* pTagIndexCond; @@ -802,6 +804,7 @@ typedef struct STagFilterOperatorInfo { typedef struct SJoinOperatorInfo { SSDataBlock *pRes; int32_t joinType; + int32_t inputTsOrder; SSDataBlock *pLeft; int32_t leftPos; @@ -1000,6 +1003,7 @@ int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pStartTs, bool functionNeedToExecute(SqlFunctionCtx* pCtx); bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup); void appendOneRow(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid); +void printDataBlock(SSDataBlock* pBlock, const char* flag); int32_t finalizeResultRowIntoResultDataBlock(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, int32_t numOfExprs, const int32_t* rowCellOffset, @@ -1017,6 +1021,7 @@ void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsCol int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* groupKey); SSDataBlock* createSpecialDataBlock(EStreamType type); +void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput); #ifdef __cplusplus } diff --git a/source/libs/executor/src/dataDeleter.c b/source/libs/executor/src/dataDeleter.c index 3c56abbd15395d7c1a1f8942e8ea9587a4e1a2ce..06b7c13fa2cb52b8255098c5efb652d56ec57974 100644 --- a/source/libs/executor/src/dataDeleter.c +++ b/source/libs/executor/src/dataDeleter.c @@ -90,6 +90,8 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp pRes->uidList = pHandle->pParam->pUidList; pRes->skey = pHandle->pDeleter->deleteTimeRange.skey; pRes->ekey = pHandle->pDeleter->deleteTimeRange.ekey; + strcpy(pRes->tableName, pHandle->pDeleter->tableFName); + strcpy(pRes->tsColName, pHandle->pDeleter->tsColName); pRes->affectedRows = *(int64_t*)pColRes->pData; pBuf->useSize += pEntry->dataLen; @@ -182,7 +184,8 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) { return TSDB_CODE_SUCCESS; } SDataCacheEntry* pEntry = (SDataCacheEntry*)(pDeleter->nextOutput.pData); - memcpy(pOutput->pData, pEntry->data, pEntry->dataLen); + memcpy(pOutput->pData, pEntry->data, pEntry->dataLen); + pDeleter->pParam->pUidList = NULL; pOutput->numOfRows = pEntry->numOfRows; pOutput->numOfCols = pEntry->numOfCols; pOutput->compressed = pEntry->compressed; @@ -205,6 +208,8 @@ static int32_t destroyDataSinker(SDataSinkHandle* pHandle) { SDataDeleterHandle* pDeleter = (SDataDeleterHandle*)pHandle; atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pDeleter->cachedSize); taosMemoryFreeClear(pDeleter->nextOutput.pData); + taosArrayDestroy(pDeleter->pParam->pUidList); + taosMemoryFree(pDeleter->pParam); while (!taosQueueEmpty(pDeleter->pDataBlocks)) { SDataDeleterBuf* pBuf = NULL; taosReadQitem(pDeleter->pDataBlocks, (void**)&pBuf); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index ec8e3c4abba40e8c03b26b21217f21739da2d93e..65df7140f732d955e9f84961b2854fa32cff3aad 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -193,7 +193,7 @@ SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) { pBlock->info.calWin = (STimeWindow){.skey = INT64_MIN, .ekey = INT64_MAX}; for (int32_t i = 0; i < numOfCols; ++i) { - SSlotDescNode* pDescNode = (SSlotDescNode*)nodesListGetNode(pNode->pSlots, i); + SSlotDescNode* pDescNode = (SSlotDescNode*)nodesListGetNode(pNode->pSlots, i); SColumnInfoData idata = createColumnInfoData(pDescNode->dataType.type, pDescNode->dataType.bytes, pDescNode->slotId); idata.info.scale = pDescNode->dataType.scale; @@ -267,8 +267,9 @@ int32_t isQualifiedTable(STableKeyInfo* info, SNode* pTagCond, void* metaHandle, code = metaGetTableEntryByUid(&mr, info->uid); if (TSDB_CODE_SUCCESS != code) { metaReaderClear(&mr); + *pQualified = false; - return terrno; + return TSDB_CODE_SUCCESS; } SNode* pTagCondTmp = nodesCloneNode(pTagCond); @@ -387,7 +388,7 @@ size_t getTableTagsBufLen(const SNodeList* pGroups) { } int32_t getGroupIdFromTagsVal(void* pMeta, uint64_t uid, SNodeList* pGroupNode, char* keyBuf, uint64_t* pGroupId) { - SMetaReader mr = {0}; + SMetaReader mr = {0}; metaReaderInit(&mr, pMeta, 0); metaGetTableEntryByUid(&mr, uid); @@ -395,7 +396,7 @@ int32_t getGroupIdFromTagsVal(void* pMeta, uint64_t uid, SNodeList* pGroupNode, nodesRewriteExprsPostOrder(groupNew, doTranslateTagExpr, &mr); char* isNull = (char*)keyBuf; - char* pStart = (char*)keyBuf + sizeof(int8_t)*LIST_LENGTH(pGroupNode); + char* pStart = (char*)keyBuf + sizeof(int8_t) * LIST_LENGTH(pGroupNode); SNode* pNode; int32_t index = 0; @@ -441,7 +442,7 @@ int32_t getGroupIdFromTagsVal(void* pMeta, uint64_t uid, SNodeList* pGroupNode, } } - int32_t len = (int32_t)(pStart - (char*)keyBuf); + int32_t len = (int32_t)(pStart - (char*)keyBuf); *pGroupId = calcGroupId(keyBuf, len); nodesDestroyList(groupNew); diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index d8cd76d31e236eaeac9bc4fc01f72f1e24c66566..7f88e628c185a18eba3b76dda5847b572a19f986 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -14,12 +14,12 @@ */ #include "executor.h" -#include "tref.h" #include "executorimpl.h" #include "planner.h" #include "tdatablock.h" -#include "vnode.h" +#include "tref.h" #include "tudf.h" +#include "vnode.h" static TdThreadOnce initPoolOnce = PTHREAD_ONCE_INIT; int32_t exchangeObjRefPool = -1; @@ -30,8 +30,7 @@ static void cleanupRefPool() { taosCloseRef(ref); } -static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t numOfBlocks, int32_t type, bool assignUid, - char* id) { +static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t numOfBlocks, int32_t type, char* id) { ASSERT(pOperator != NULL); if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { if (pOperator->numOfDownstream == 0) { @@ -44,12 +43,12 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu return TSDB_CODE_QRY_APP_ERROR; } pOperator->status = OP_NOT_OPENED; - return doSetStreamBlock(pOperator->pDownstream[0], input, numOfBlocks, type, assignUid, id); + return doSetStreamBlock(pOperator->pDownstream[0], input, numOfBlocks, type, id); } else { pOperator->status = OP_NOT_OPENED; SStreamScanInfo* pInfo = pOperator->info; - pInfo->assignBlockUid = assignUid; + /*pInfo->assignBlockUid = assignUid;*/ // TODO: if a block was set but not consumed, // prevent setting a different type of block @@ -95,21 +94,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu } } -#if 0 -int32_t qStreamScanSnapshot(qTaskInfo_t tinfo) { - if (tinfo == NULL) { - return TSDB_CODE_QRY_APP_ERROR; - } - SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - return doSetStreamBlock(pTaskInfo->pRoot, NULL, 0, STREAM_INPUT__TABLE_SCAN, 0, NULL); -} -#endif - -int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input, int32_t type, bool assignUid) { - return qSetMultiStreamInput(tinfo, input, 1, type, assignUid); -} - -int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type, bool assignUid) { +int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type) { if (tinfo == NULL) { return TSDB_CODE_QRY_APP_ERROR; } @@ -120,8 +105,7 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - int32_t code = - doSetStreamBlock(pTaskInfo->pRoot, (void**)pBlocks, numOfBlocks, type, assignUid, GET_TASKID(pTaskInfo)); + int32_t code = doSetStreamBlock(pTaskInfo->pRoot, (void**)pBlocks, numOfBlocks, type, GET_TASKID(pTaskInfo)); if (code != TSDB_CODE_SUCCESS) { qError("%s failed to set the stream block data", GET_TASKID(pTaskInfo)); } else { @@ -258,8 +242,8 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo } // todo refactor STableList - size_t bufLen = (pScanInfo->pGroupTags != NULL)? getTableTagsBufLen(pScanInfo->pGroupTags):0; - char* keyBuf = NULL; + size_t bufLen = (pScanInfo->pGroupTags != NULL) ? getTableTagsBufLen(pScanInfo->pGroupTags) : 0; + char* keyBuf = NULL; if (bufLen > 0) { keyBuf = taosMemoryMalloc(bufLen); if (keyBuf == NULL) { @@ -267,19 +251,25 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo } } - for(int32_t i = 0; i < taosArrayGetSize(qa); ++i) { + for (int32_t i = 0; i < taosArrayGetSize(qa); ++i) { uint64_t* uid = taosArrayGet(qa, i); STableKeyInfo keyInfo = {.uid = *uid, .groupId = 0}; if (bufLen > 0) { code = getGroupIdFromTagsVal(pScanInfo->readHandle.meta, keyInfo.uid, pScanInfo->pGroupTags, keyBuf, - &keyInfo.groupId); + &keyInfo.groupId); if (code != TSDB_CODE_SUCCESS) { return code; } } taosArrayPush(pTaskInfo->tableqinfoList.pTableList, &keyInfo); + if (pTaskInfo->tableqinfoList.map == NULL) { + pTaskInfo->tableqinfoList.map = + taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); + } + + taosHashPut(pTaskInfo->tableqinfoList.map, uid, sizeof(uid), &keyInfo.groupId, sizeof(keyInfo.groupId)); } if (keyBuf != NULL) { @@ -347,9 +337,12 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, } code = dsCreateDataSinker(pSubplan->pDataSink, handle, pSinkParam); + if (code != TSDB_CODE_SUCCESS) { + taosMemoryFreeClear(pSinkParam); + } } - _error: +_error: // if failed to add ref for all tables in this query, abort current query return code; } @@ -416,6 +409,7 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t* useconds) { } if (isTaskKilled(pTaskInfo)) { + atomic_store_64(&pTaskInfo->owner, 0); qDebug("%s already killed, abort", GET_TASKID(pTaskInfo)); return TSDB_CODE_SUCCESS; } @@ -572,11 +566,6 @@ const SSchemaWrapper* qExtractSchemaFromStreamScanner(void* scanner) { return pInfo->tqReader->pSchemaWrapper; } -const STqOffset* qExtractStatusFromStreamScanner(void* scanner) { - SStreamScanInfo* pInfo = scanner; - return &pInfo->offset; -} - void* qStreamExtractMetaMsg(qTaskInfo_t tinfo) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE); @@ -599,12 +588,17 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, const STqOffsetVal* pOffset) { while (1) { uint8_t type = pOperator->operatorType; pOperator->status = OP_OPENED; - if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { - SStreamScanInfo* pInfo = pOperator->info; - if (pOffset->type == TMQ_OFFSET__LOG) { - STableScanInfo* pTSInfo = pInfo->pTableScanOp->info; - tsdbReaderClose(pTSInfo->dataReader); - pTSInfo->dataReader = NULL; + // TODO add more check + if (type != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { + ASSERT(pOperator->numOfDownstream == 1); + pOperator = pOperator->pDownstream[0]; + } + + SStreamScanInfo* pInfo = pOperator->info; + if (pOffset->type == TMQ_OFFSET__LOG) { + STableScanInfo* pTSInfo = pInfo->pTableScanOp->info; + tsdbReaderClose(pTSInfo->dataReader); + pTSInfo->dataReader = NULL; #if 0 if (tOffsetEqual(pOffset, &pTaskInfo->streamInfo.lastStatus) && pInfo->tqReader->pWalReader->curVersion != pOffset->version) { @@ -613,102 +607,74 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, const STqOffsetVal* pOffset) { ASSERT(0); } #endif - if (tqSeekVer(pInfo->tqReader, pOffset->version + 1) < 0) { + if (tqSeekVer(pInfo->tqReader, pOffset->version + 1) < 0) { + return -1; + } + ASSERT(pInfo->tqReader->pWalReader->curVersion == pOffset->version + 1); + } else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { + /*pInfo->blockType = STREAM_INPUT__TABLE_SCAN;*/ + int64_t uid = pOffset->uid; + int64_t ts = pOffset->ts; + + if (uid == 0) { + if (taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList) != 0) { + STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, 0); + uid = pTableInfo->uid; + ts = INT64_MIN; + } else { return -1; } - ASSERT(pInfo->tqReader->pWalReader->curVersion == pOffset->version + 1); - } else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { - /*pInfo->blockType = STREAM_INPUT__TABLE_SCAN;*/ - int64_t uid = pOffset->uid; - int64_t ts = pOffset->ts; - - if (uid == 0) { - if (taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList) != 0) { - STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, 0); - uid = pTableInfo->uid; - ts = INT64_MIN; - } else { - 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 tableSz = taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList); + /*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 tableSz = taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList); #ifndef NDEBUG - qDebug("switch to next table %ld (cursor %d), %ld rows returned", uid, pTableScanInfo->currentTable, - pInfo->pTableScanOp->resultInfo.totalRows); - pInfo->pTableScanOp->resultInfo.totalRows = 0; + qDebug("switch to next table %ld (cursor %d), %ld rows returned", uid, pTableScanInfo->currentTable, + pInfo->pTableScanOp->resultInfo.totalRows); + pInfo->pTableScanOp->resultInfo.totalRows = 0; #endif - bool found = false; - for (int32_t i = 0; i < tableSz; i++) { - STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, i); - if (pTableInfo->uid == uid) { - found = true; - pTableScanInfo->currentTable = i; - break; - } + bool found = false; + for (int32_t i = 0; i < tableSz; i++) { + STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, i); + if (pTableInfo->uid == uid) { + found = true; + pTableScanInfo->currentTable = i; + break; } + } - // TODO after dropping table, table may be not found - ASSERT(found); + // TODO after dropping table, table may be not found + ASSERT(found); - if (pTableScanInfo->dataReader == NULL) { - if (tsdbReaderOpen(pTableScanInfo->readHandle.vnode, &pTableScanInfo->cond, - pTaskInfo->tableqinfoList.pTableList, &pTableScanInfo->dataReader, NULL) < 0 || - pTableScanInfo->dataReader == NULL) { - ASSERT(0); - } + if (pTableScanInfo->dataReader == NULL) { + if (tsdbReaderOpen(pTableScanInfo->readHandle.vnode, &pTableScanInfo->cond, + pTaskInfo->tableqinfoList.pTableList, &pTableScanInfo->dataReader, NULL) < 0 || + pTableScanInfo->dataReader == NULL) { + ASSERT(0); } + } - tsdbSetTableId(pTableScanInfo->dataReader, uid); - int64_t oldSkey = pTableScanInfo->cond.twindows.skey; - pTableScanInfo->cond.twindows.skey = ts + 1; - tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond); - pTableScanInfo->cond.twindows.skey = oldSkey; - pTableScanInfo->scanTimes = 0; + tsdbSetTableId(pTableScanInfo->dataReader, uid); + int64_t oldSkey = pTableScanInfo->cond.twindows.skey; + pTableScanInfo->cond.twindows.skey = ts + 1; + tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond); + pTableScanInfo->cond.twindows.skey = oldSkey; + pTableScanInfo->scanTimes = 0; - qDebug("tsdb reader offset seek to uid %ld ts %ld, table cur set to %d , all table num %d", uid, ts, - pTableScanInfo->currentTable, tableSz); - /*}*/ + qDebug("tsdb reader offset seek to uid %ld ts %ld, table cur set to %d , all table num %d", uid, ts, + pTableScanInfo->currentTable, tableSz); + /*}*/ - } else { - ASSERT(0); - } - return 0; } else { - ASSERT(pOperator->numOfDownstream == 1); - pOperator = pOperator->pDownstream[0]; + ASSERT(0); } + return 0; } } return 0; } - - -#if 0 -int32_t qStreamPrepareTsdbScan(qTaskInfo_t tinfo, uint64_t uid, int64_t ts) { - SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - - if (uid == 0) { - if (taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList) != 0) { - STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, 0); - uid = pTableInfo->uid; - ts = INT64_MIN; - } - } - - return doPrepareScan(pTaskInfo->pRoot, uid, ts); -} - -int32_t qGetStreamScanStatus(qTaskInfo_t tinfo, uint64_t* uid, int64_t* ts) { - SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - - return doGetScanStatus(pTaskInfo->pRoot, uid, ts); -} -#endif - diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 36ae1d19ecbb7759d00657e9519a32c1ead3b81f..525d7bf33658b906c37159047da31d6b947448c1 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -92,7 +92,7 @@ static void setBlockStatisInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlo static void releaseQueryBuf(size_t numOfTables); -static void destroySFillOperatorInfo(void* param, int32_t numOfOutput); +static void destroyFillOperatorInfo(void* param, int32_t numOfOutput); static void destroyProjectOperatorInfo(void* param, int32_t numOfOutput); static void destroyOrderOperatorInfo(void* param, int32_t numOfOutput); static void destroyAggOperatorInfo(void* param, int32_t numOfOutput); @@ -666,6 +666,11 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc pfCtx->pTsOutput = (SColumnInfoData*)pCtx[*outputColIndex].pOutput; } + // link pDstBlock to set selectivity value + if (pfCtx->subsidiaries.num > 0) { + pfCtx->pDstBlock = pResult; + } + numOfRows = pfCtx->fpSet.process(pfCtx); } else if (fmIsAggFunc(pfCtx->functionId)) { // _group_key function for "partition by tbname" + csum(col_name) query @@ -3204,9 +3209,8 @@ static void doHandleRemainBlockFromNewGroup(SFillOperatorInfo* pInfo, SResultInf if (taosFillHasMoreResults(pInfo->pFillInfo)) { int32_t numOfResultRows = pResultInfo->capacity - pInfo->pRes->info.rows; taosFillResultDataBlock(pInfo->pFillInfo, pInfo->pRes, numOfResultRows); - if (pInfo->pRes->info.rows > pResultInfo->threshold) { - return; - } + pInfo->pRes->info.groupId = pInfo->curGroupId; + return; } // handle the cached new group data block @@ -3225,7 +3229,7 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) { blockDataCleanup(pResBlock); doHandleRemainBlockFromNewGroup(pInfo, pResultInfo, pTaskInfo); - if (pResBlock->info.rows > pResultInfo->threshold || pResBlock->info.rows > 0) { + if (pResBlock->info.rows > 0) { pResBlock->info.groupId = pInfo->curGroupId; return pResBlock; } @@ -3431,7 +3435,7 @@ void initBasicInfo(SOptrBasicInfo* pInfo, SSDataBlock* pBlock) { initResultRowInfo(&pInfo->resultRowInfo); } -static void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput) { +void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput) { if (pCtx == NULL) { return NULL; } @@ -3548,16 +3552,17 @@ void destroyAggOperatorInfo(void* param, int32_t numOfOutput) { cleanupBasicInfo(&pInfo->binfo); cleanupAggSup(&pInfo->aggSup); + cleanupExprSupp(&pInfo->scalarExprSup); cleanupGroupResInfo(&pInfo->groupResInfo); taosMemoryFreeClear(param); } -void destroySFillOperatorInfo(void* param, int32_t numOfOutput) { +void destroyFillOperatorInfo(void* param, int32_t numOfOutput) { SFillOperatorInfo* pInfo = (SFillOperatorInfo*)param; pInfo->pFillInfo = taosDestroyFillInfo(pInfo->pFillInfo); pInfo->pRes = blockDataDestroy(pInfo->pRes); taosMemoryFreeClear(pInfo->p); - + taosArrayDestroy(pInfo->pColMatchColInfo); taosMemoryFreeClear(param); } @@ -3648,7 +3653,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doFill, NULL, NULL, destroySFillOperatorInfo, NULL, NULL, NULL); + createOperatorFpSet(operatorDummyOpenFn, doFill, NULL, NULL, destroyFillOperatorInfo, NULL, NULL, NULL); code = appendDownstream(pOperator, &downstream, 1); return pOperator; diff --git a/source/libs/executor/src/joinoperator.c b/source/libs/executor/src/joinoperator.c index f26b2f4f0a0c9e9a4fd33111bd689de82b055a36..8902804fab478e906484be5d54d0cd636d18b814 100644 --- a/source/libs/executor/src/joinoperator.c +++ b/source/libs/executor/src/joinoperator.c @@ -77,6 +77,13 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t pInfo->pCondAfterMerge = NULL; } + pInfo->inputTsOrder = TSDB_ORDER_ASC; + if (pJoinNode->inputTsOrder == ORDER_ASC) { + pInfo->inputTsOrder = TSDB_ORDER_ASC; + } else if (pJoinNode->inputTsOrder == ORDER_DESC) { + pInfo->inputTsOrder = TSDB_ORDER_DESC; + } + pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doMergeJoin, NULL, NULL, destroyMergeJoinOperator, NULL, NULL, NULL); int32_t code = appendDownstream(pOperator, pDownstream, numOfDownstream); @@ -108,81 +115,224 @@ void destroyMergeJoinOperator(void* param, int32_t numOfOutput) { taosMemoryFreeClear(param); } -static void doMergeJoinImpl(struct SOperatorInfo* pOperator, SSDataBlock* pRes) { +static void mergeJoinJoinLeftRight(struct SOperatorInfo* pOperator, SSDataBlock* pRes, int32_t currRow, + SSDataBlock* pLeftBlock, int32_t leftPos, SSDataBlock* pRightBlock, + int32_t rightPos) { SJoinOperatorInfo* pJoinInfo = pOperator->info; - int32_t nrows = 0; + for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) { + SColumnInfoData* pDst = taosArrayGet(pRes->pDataBlock, i); - while (1) { - // todo extract method - if (pJoinInfo->pLeft == NULL || pJoinInfo->leftPos >= pJoinInfo->pLeft->info.rows) { - SOperatorInfo* ds1 = pOperator->pDownstream[0]; - pJoinInfo->pLeft = ds1->fpSet.getNextFn(ds1); + SExprInfo* pExprInfo = &pOperator->exprSupp.pExprInfo[i]; - pJoinInfo->leftPos = 0; - if (pJoinInfo->pLeft == NULL) { - setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); - break; - } + int32_t blockId = pExprInfo->base.pParam[0].pCol->dataBlockId; + int32_t slotId = pExprInfo->base.pParam[0].pCol->slotId; + int32_t rowIndex = -1; + + SColumnInfoData* pSrc = NULL; + if (pLeftBlock->info.blockId == blockId) { + pSrc = taosArrayGet(pLeftBlock->pDataBlock, slotId); + rowIndex = leftPos; + } else { + pSrc = taosArrayGet(pRightBlock->pDataBlock, slotId); + rowIndex = rightPos; } - if (pJoinInfo->pRight == NULL || pJoinInfo->rightPos >= pJoinInfo->pRight->info.rows) { - SOperatorInfo* ds2 = pOperator->pDownstream[1]; - pJoinInfo->pRight = ds2->fpSet.getNextFn(ds2); + if (colDataIsNull_s(pSrc, rowIndex)) { + colDataAppendNULL(pDst, currRow); + } else { + char* p = colDataGetData(pSrc, rowIndex); + colDataAppend(pDst, currRow, p, false); + } + } +} +typedef struct SRowLocation { + SSDataBlock* pDataBlock; + int32_t pos; +} SRowLocation; + +// pBlock[tsSlotId][startPos, endPos) == timestamp, +static int32_t mergeJoinGetBlockRowsEqualTs(SSDataBlock* pBlock, int16_t tsSlotId, int32_t startPos, int64_t timestamp, + int32_t* pEndPos, SArray* rowLocations, SArray* createdBlocks) { + int32_t numRows = pBlock->info.rows; + ASSERT(startPos < numRows); + SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, tsSlotId); + + int32_t i = startPos; + for (; i < numRows; ++i) { + char* pNextVal = colDataGetData(pCol, i); + if (timestamp != *(int64_t*)pNextVal) { + break; + } + } + int32_t endPos = i; + *pEndPos = endPos; + if (endPos - startPos == 0) { + return 0; + } + + SSDataBlock* block = pBlock; + bool createdNewBlock = false; + if (endPos == numRows) { + block = blockDataExtractBlock(pBlock, startPos, endPos-startPos); + taosArrayPush(createdBlocks, &block); + createdNewBlock = true; + } + SRowLocation location = {0}; + for (int32_t j = startPos; j < endPos; ++j) { + location.pDataBlock = block; + location.pos = ( createdNewBlock ? j - startPos : j); + taosArrayPush(rowLocations, &location); + } + return 0; +} + +// whichChild == 0, left child of join; whichChild ==1, right child of join +static int32_t mergeJoinGetDownStreamRowsEqualTimeStamp(SOperatorInfo* pOperator, int32_t whichChild, int16_t tsSlotId, + SSDataBlock* startDataBlock, int32_t startPos, + int64_t timestamp, SArray* rowLocations, + SArray* createdBlocks) { + ASSERT(whichChild == 0 || whichChild == 1); + + SJoinOperatorInfo* pJoinInfo = pOperator->info; + int32_t endPos = -1; + SSDataBlock* dataBlock = startDataBlock; + mergeJoinGetBlockRowsEqualTs(dataBlock, tsSlotId, startPos, timestamp, &endPos, rowLocations, createdBlocks); + while (endPos == dataBlock->info.rows) { + SOperatorInfo* ds = pOperator->pDownstream[whichChild]; + dataBlock = ds->fpSet.getNextFn(ds); + if (whichChild == 0) { + pJoinInfo->leftPos = 0; + pJoinInfo->pLeft = dataBlock; + } else if (whichChild == 1) { pJoinInfo->rightPos = 0; - if (pJoinInfo->pRight == NULL) { - setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); - break; - } + pJoinInfo->pRight = dataBlock; + } + + if (dataBlock == NULL) { + setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); + endPos = -1; + break; + } + + mergeJoinGetBlockRowsEqualTs(dataBlock, tsSlotId, 0, timestamp, &endPos, rowLocations, createdBlocks); + } + if (endPos != -1) { + if (whichChild == 0) { + pJoinInfo->leftPos = endPos; + } else if (whichChild == 1) { + pJoinInfo->rightPos = endPos; } + } + return 0; +} - SColumnInfoData* pLeftCol = taosArrayGet(pJoinInfo->pLeft->pDataBlock, pJoinInfo->leftCol.slotId); - char* pLeftVal = colDataGetData(pLeftCol, pJoinInfo->leftPos); +static int32_t mergeJoinJoinDownstreamTsRanges(SOperatorInfo* pOperator, int64_t timestamp, SSDataBlock* pRes, + int32_t* nRows) { + SJoinOperatorInfo* pJoinInfo = pOperator->info; + SArray* leftRowLocations = taosArrayInit(8, sizeof(SRowLocation)); + SArray* leftCreatedBlocks = taosArrayInit(8, POINTER_BYTES); + + SArray* rightRowLocations = taosArrayInit(8, sizeof(SRowLocation)); + SArray* rightCreatedBlocks = taosArrayInit(8, POINTER_BYTES); + + mergeJoinGetDownStreamRowsEqualTimeStamp(pOperator, 0, pJoinInfo->leftCol.slotId, pJoinInfo->pLeft, + pJoinInfo->leftPos, timestamp, leftRowLocations, leftCreatedBlocks); + mergeJoinGetDownStreamRowsEqualTimeStamp(pOperator, 1, pJoinInfo->rightCol.slotId, pJoinInfo->pRight, + pJoinInfo->rightPos, timestamp, rightRowLocations, rightCreatedBlocks); + + size_t leftNumJoin = taosArrayGetSize(leftRowLocations); + size_t rightNumJoin = taosArrayGetSize(rightRowLocations); + for (int32_t i = 0; i < leftNumJoin; ++i) { + for (int32_t j = 0; j < rightNumJoin; ++j) { + SRowLocation* leftRow = taosArrayGet(leftRowLocations, i); + SRowLocation* rightRow = taosArrayGet(rightRowLocations, j); + mergeJoinJoinLeftRight(pOperator, pRes, *nRows, leftRow->pDataBlock, leftRow->pos, rightRow->pDataBlock, + rightRow->pos); + ++*nRows; + } + } - SColumnInfoData* pRightCol = taosArrayGet(pJoinInfo->pRight->pDataBlock, pJoinInfo->rightCol.slotId); - char* pRightVal = colDataGetData(pRightCol, pJoinInfo->rightPos); + for (int i = 0; i < taosArrayGetSize(rightCreatedBlocks); ++i) { + SSDataBlock* pBlock = taosArrayGetP(rightCreatedBlocks, i); + blockDataDestroy(pBlock); + } + taosArrayDestroy(rightCreatedBlocks); + taosArrayDestroy(rightRowLocations); + for (int i = 0; i < taosArrayGetSize(leftCreatedBlocks); ++i) { + SSDataBlock* pBlock = taosArrayGetP(leftCreatedBlocks, i); + blockDataDestroy(pBlock); + } + taosArrayDestroy(leftCreatedBlocks); + taosArrayDestroy(leftRowLocations); + return TSDB_CODE_SUCCESS; +} - // only the timestamp match support for ordinary table - ASSERT(pLeftCol->info.type == TSDB_DATA_TYPE_TIMESTAMP); - if (*(int64_t*)pLeftVal == *(int64_t*)pRightVal) { - for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) { - SColumnInfoData* pDst = taosArrayGet(pRes->pDataBlock, i); +static bool mergeJoinGetNextTimestamp(SOperatorInfo* pOperator, int64_t* pLeftTs, int64_t* pRightTs) { + SJoinOperatorInfo* pJoinInfo = pOperator->info; - SExprInfo* pExprInfo = &pOperator->exprSupp.pExprInfo[i]; + if (pJoinInfo->pLeft == NULL || pJoinInfo->leftPos >= pJoinInfo->pLeft->info.rows) { + SOperatorInfo* ds1 = pOperator->pDownstream[0]; + pJoinInfo->pLeft = ds1->fpSet.getNextFn(ds1); - int32_t blockId = pExprInfo->base.pParam[0].pCol->dataBlockId; - int32_t slotId = pExprInfo->base.pParam[0].pCol->slotId; - int32_t rowIndex = -1; + pJoinInfo->leftPos = 0; + if (pJoinInfo->pLeft == NULL) { + setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); + return false; + } + } - SColumnInfoData* pSrc = NULL; - if (pJoinInfo->pLeft->info.blockId == blockId) { - pSrc = taosArrayGet(pJoinInfo->pLeft->pDataBlock, slotId); - rowIndex = pJoinInfo->leftPos; - } else { - pSrc = taosArrayGet(pJoinInfo->pRight->pDataBlock, slotId); - rowIndex = pJoinInfo->rightPos; - } + if (pJoinInfo->pRight == NULL || pJoinInfo->rightPos >= pJoinInfo->pRight->info.rows) { + SOperatorInfo* ds2 = pOperator->pDownstream[1]; + pJoinInfo->pRight = ds2->fpSet.getNextFn(ds2); - if (colDataIsNull_s(pSrc, rowIndex)) { - colDataAppendNULL(pDst, nrows); - } else { - char* p = colDataGetData(pSrc, rowIndex); - colDataAppend(pDst, nrows, p, false); - } - } + pJoinInfo->rightPos = 0; + if (pJoinInfo->pRight == NULL) { + setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); + return false; + } + } + // only the timestamp match support for ordinary table + SColumnInfoData* pLeftCol = taosArrayGet(pJoinInfo->pLeft->pDataBlock, pJoinInfo->leftCol.slotId); + char* pLeftVal = colDataGetData(pLeftCol, pJoinInfo->leftPos); + *pLeftTs = *(int64_t*)pLeftVal; + + SColumnInfoData* pRightCol = taosArrayGet(pJoinInfo->pRight->pDataBlock, pJoinInfo->rightCol.slotId); + char* pRightVal = colDataGetData(pRightCol, pJoinInfo->rightPos); + *pRightTs = *(int64_t*)pRightVal; + + ASSERT(pLeftCol->info.type == TSDB_DATA_TYPE_TIMESTAMP); + ASSERT(pRightCol->info.type == TSDB_DATA_TYPE_TIMESTAMP); + return true; +} - pJoinInfo->leftPos += 1; - pJoinInfo->rightPos += 1; +static void doMergeJoinImpl(struct SOperatorInfo* pOperator, SSDataBlock* pRes) { + SJoinOperatorInfo* pJoinInfo = pOperator->info; + + int32_t nrows = pRes->info.rows; + + bool asc = (pJoinInfo->inputTsOrder == TSDB_ORDER_ASC) ? true : false; + + while (1) { + int64_t leftTs = 0; + int64_t rightTs = 0; + bool hasNextTs = mergeJoinGetNextTimestamp(pOperator, &leftTs, &rightTs); + if (!hasNextTs) { + break; + } - nrows += 1; - } else if (*(int64_t*)pLeftVal < *(int64_t*)pRightVal) { + if (leftTs == rightTs) { + mergeJoinJoinLeftRight(pOperator, pRes, nrows, pJoinInfo->pLeft, pJoinInfo->leftPos, pJoinInfo->pRight, + pJoinInfo->rightPos); + mergeJoinJoinDownstreamTsRanges(pOperator, leftTs, pRes, &nrows); + } else if (asc && leftTs < rightTs || !asc && leftTs > rightTs) { pJoinInfo->leftPos += 1; if (pJoinInfo->leftPos >= pJoinInfo->pLeft->info.rows) { continue; } - } else if (*(int64_t*)pLeftVal > *(int64_t*)pRightVal) { + } else if (asc && leftTs > rightTs || !asc && leftTs < rightTs) { pJoinInfo->rightPos += 1; if (pJoinInfo->rightPos >= pJoinInfo->pRight->info.rows) { continue; diff --git a/source/libs/executor/src/projectoperator.c b/source/libs/executor/src/projectoperator.c index 34149d74990275839c79763ef7750e3fedb9a913..53e25c7e9731b7bbef92b85647c36fadf13da257 100644 --- a/source/libs/executor/src/projectoperator.c +++ b/source/libs/executor/src/projectoperator.c @@ -68,10 +68,12 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys pInfo->mergeDataBlocks = pProjPhyNode->mergeDataBlock; // todo remove it soon + if (pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM) { - pInfo->mergeDataBlocks = true; + pInfo->mergeDataBlocks = false; } + int32_t numOfRows = 4096; size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; @@ -181,6 +183,16 @@ static int32_t doIngroupLimitOffset(SLimitInfo* pLimitInfo, uint64_t groupId, SS return PROJECT_RETRIEVE_DONE; } +void printDataBlock1(SSDataBlock* pBlock, const char* flag) { + if (!pBlock || pBlock->info.rows == 0) { + qDebug("===stream===printDataBlock: Block is Null or Empty"); + return; + } + char* pBuf = NULL; + qDebug("%s", dumpBlockData(pBlock, flag, &pBuf)); + taosMemoryFreeClear(pBuf); +} + SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { SProjectOperatorInfo* pProjectInfo = pOperator->info; SOptrBasicInfo* pInfo = &pProjectInfo->binfo; @@ -229,6 +241,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { // for stream interval if (pBlock->info.type == STREAM_RETRIEVE) { + // printDataBlock1(pBlock, "project1"); return pBlock; } @@ -279,7 +292,9 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { // do apply filter doFilter(pProjectInfo->pFilterNode, pFinalRes, NULL); - if (pFinalRes->info.rows > 0 || pRes->info.rows == 0) { + + // 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)) { break; } } else { @@ -302,7 +317,8 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { if (pOperator->cost.openCost == 0) { pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0; } - + + // printDataBlock1(p, "project"); return (p->info.rows > 0) ? p : NULL; } @@ -587,4 +603,4 @@ SSDataBlock* doGenerateSourceData(SOperatorInfo* pOperator) { } return (pRes->info.rows > 0) ? pRes : NULL; -} \ No newline at end of file +} diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 2dcb5558346b1796c295bd8964168d1dfcabbdde..4a2f57d628fe074b68505d0576ab63779a8ee51f 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -408,6 +408,10 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { pBlock->info.groupId = *groupId; } + if (pTableScanInfo->assignBlockUid) { + pBlock->info.groupId = pBlock->info.uid; + } + pOperator->resultInfo.totalRows = pTableScanInfo->readRecorder.totalRows; pTableScanInfo->readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0; @@ -616,6 +620,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, pInfo->scanFlag = MAIN_SCAN; pInfo->pColMatchInfo = pColList; pInfo->currentGroupId = -1; + pInfo->assignBlockUid = pTableScanNode->assignBlockUid; pOperator->name = "TableScanOperator"; // for debug purpose pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN; @@ -1396,13 +1401,11 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNo static void destroyStreamScanOperatorInfo(void* param, int32_t numOfOutput) { SStreamScanInfo* pStreamScan = (SStreamScanInfo*)param; -#if 1 if (pStreamScan->pTableScanOp && pStreamScan->pTableScanOp->info) { STableScanInfo* pTableScanInfo = pStreamScan->pTableScanOp->info; destroyTableScanOperatorInfo(pTableScanInfo, numOfOutput); taosMemoryFreeClear(pStreamScan->pTableScanOp); } -#endif if (pStreamScan->tqReader) { tqCloseReader(pStreamScan->tqReader); } @@ -1528,6 +1531,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->pDeleteDataRes = createSpecialDataBlock(STREAM_DELETE_DATA); pInfo->updateWin = (STimeWindow){.skey = INT64_MAX, .ekey = INT64_MAX}; pInfo->pUpdateDataRes = createSpecialDataBlock(STREAM_CLEAR); + pInfo->assignBlockUid = pTableScanNode->assignBlockUid; pOperator->name = "StreamScanOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN; @@ -2831,6 +2835,13 @@ int32_t stopGroupTableMergeScan(SOperatorInfo* pOperator) { size_t numReaders = taosArrayGetSize(pInfo->dataReaders); + SSortExecInfo sortExecInfo = tsortGetSortExecInfo(pInfo->pSortHandle); + pInfo->sortExecInfo.sortMethod = sortExecInfo.sortMethod; + pInfo->sortExecInfo.sortBuffer = sortExecInfo.sortBuffer; + pInfo->sortExecInfo.loops += sortExecInfo.loops; + pInfo->sortExecInfo.readBytes += sortExecInfo.readBytes; + pInfo->sortExecInfo.writeBytes += sortExecInfo.writeBytes; + for (int32_t i = 0; i < numReaders; ++i) { STableMergeScanSortSourceParam* param = taosArrayGet(pInfo->sortSourceParams, i); blockDataDestroy(param->inputBlock); @@ -2848,7 +2859,8 @@ int32_t stopGroupTableMergeScan(SOperatorInfo* pOperator) { return TSDB_CODE_SUCCESS; } -SSDataBlock* getSortedTableMergeScanBlockData(SSortHandle* pHandle, SSDataBlock* pResBlock, int32_t capacity, SOperatorInfo* pOperator) { +SSDataBlock* getSortedTableMergeScanBlockData(SSortHandle* pHandle, SSDataBlock* pResBlock, int32_t capacity, + SOperatorInfo* pOperator) { STableMergeScanInfo* pInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; @@ -2867,7 +2879,6 @@ SSDataBlock* getSortedTableMergeScanBlockData(SSortHandle* pHandle, SSDataBlock* } } - qDebug("%s get sorted row blocks, rows:%d", GET_TASKID(pTaskInfo), pResBlock->info.rows); return (pResBlock->info.rows > 0) ? pResBlock : NULL; } @@ -2898,7 +2909,8 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { } SSDataBlock* pBlock = NULL; while (pInfo->tableStartIndex < tableListSize) { - pBlock = getSortedTableMergeScanBlockData(pInfo->pSortHandle, pInfo->pResBlock, pOperator->resultInfo.capacity, pOperator); + pBlock = getSortedTableMergeScanBlockData(pInfo->pSortHandle, pInfo->pResBlock, pOperator->resultInfo.capacity, + pOperator); if (pBlock != NULL) { pBlock->info.groupId = pInfo->groupId; pOperator->resultInfo.totalRows += pBlock->info.rows; @@ -2955,7 +2967,7 @@ int32_t getTableMergeScanExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExpla STableMergeScanExecInfo* execInfo = taosMemoryCalloc(1, sizeof(STableMergeScanExecInfo)); STableMergeScanInfo* pInfo = pOptr->info; execInfo->blockRecorder = pInfo->readRecorder; - execInfo->sortExecInfo = tsortGetSortExecInfo(pInfo->pSortHandle); + execInfo->sortExecInfo = pInfo->sortExecInfo; *pOptrExplain = execInfo; *len = sizeof(STableMergeScanExecInfo); diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index 90ffff5fafeed4186ed754c97c4980689d713ced..ff856a48b6f0f04a2cf617a22be812eda1714e8e 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -514,8 +514,15 @@ void* taosDestroyFillInfo(SFillInfo* pFillInfo) { if (pFillInfo == NULL) { return NULL; } - + for (int32_t i = 0; i < taosArrayGetSize(pFillInfo->prev); ++i) { + SGroupKeys* pKey = taosArrayGet(pFillInfo->prev, i); + taosMemoryFree(pKey->pData); + } taosArrayDestroy(pFillInfo->prev); + for (int32_t i = 0; i < taosArrayGetSize(pFillInfo->next); ++i) { + SGroupKeys* pKey = taosArrayGet(pFillInfo->next, i); + taosMemoryFree(pKey->pData); + } taosArrayDestroy(pFillInfo->next); for (int32_t i = 0; i < pFillInfo->numOfTags; ++i) { diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 1e001a29a09ccf08641ea007f498c1fa44b96ed9..cb18eb9fffad5e8b32bbb2c176ca5f881088122b 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -773,9 +773,9 @@ int32_t binarySearch(void* keyList, int num, TSKEY key, int order, __get_value_f } int32_t comparePullWinKey(void* pKey, void* data, int32_t index) { - SArray* res = (SArray*)data; + SArray* res = (SArray*)data; SPullWindowInfo* pos = taosArrayGet(res, index); - SPullWindowInfo* pData = (SPullWindowInfo*) pKey; + SPullWindowInfo* pData = (SPullWindowInfo*)pKey; if (pData->window.skey == pos->window.skey) { if (pData->groupId > pos->groupId) { return 1; @@ -810,7 +810,7 @@ static int32_t savePullWindow(SPullWindowInfo* pPullInfo, SArray* pPullWins) { int32_t compareResKey(void* pKey, void* data, int32_t index) { SArray* res = (SArray*)data; SResKeyPos* pos = taosArrayGetP(res, index); - SWinRes* pData = (SWinRes*) pKey; + SWinRes* pData = (SWinRes*)pKey; if (pData->ts == *(int64_t*)pos->key) { if (pData->groupId > pos->groupId) { return 1; @@ -880,7 +880,7 @@ int64_t getWinReskey(void* data, int32_t index) { int32_t compareWinRes(void* pKey, void* data, int32_t index) { SArray* res = (SArray*)data; SWinRes* pos = taosArrayGetP(res, index); - SResKeyPos* pData = (SResKeyPos*) pKey; + SResKeyPos* pData = (SResKeyPos*)pKey; if (*(int64_t*)pData->key == pos->ts) { if (pData->groupId > pos->groupId) { return 1; @@ -1091,6 +1091,8 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->order, scanFlag, true); + blockDataUpdateTsWindow(pBlock, pInfo->primaryTsIndex); + hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag, NULL); } @@ -1417,15 +1419,15 @@ static void doClearWindows(SAggSupporter* pAggSup, SExprSupp* pSup1, SInterval* SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); pGpDatas = (uint64_t*)pGpCol->pData; } - int32_t step = 0; - int32_t startPos = 0; + int32_t step = 0; + int32_t startPos = 0; for (int32_t i = 0; i < pBlock->info.rows; i++) { SResultRowInfo dumyInfo; dumyInfo.cur.pageId = -1; STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, startTsCols[i], pInterval, TSDB_ORDER_ASC); while (win.ekey <= endTsCols[i]) { uint64_t winGpId = pGpDatas ? pGpDatas[startPos] : pBlock->info.groupId; - bool res = doClearWindow(pAggSup, pSup1, (char*)&win.skey, sizeof(TSKEY), winGpId, numOfOutput); + bool res = doClearWindow(pAggSup, pSup1, (char*)&win.skey, sizeof(TSKEY), winGpId, numOfOutput); if (pUpWins && res) { SWinRes winRes = {.ts = win.skey, .groupId = winGpId}; taosArrayPush(pUpWins, &winRes); @@ -1596,7 +1598,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { } if (pBlock->info.type == STREAM_NORMAL) { - //set input version + // set input version pTaskInfo->version = pBlock->info.version; } @@ -1616,6 +1618,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey); hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, MAIN_SCAN, pUpdated); } + pOperator->status = OP_RES_TO_RETURN; closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, NULL, pUpdated, pInfo->pRecycledPages, pInfo->aggSup.pResultBuf); @@ -1628,6 +1631,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { if (pInfo->pDelRes->info.rows > 0) { return pInfo->pDelRes; } + doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); printDataBlock(pInfo->binfo.pRes, "single interval"); return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes; @@ -1642,7 +1646,7 @@ static void destroyStateWindowOperatorInfo(void* param, int32_t numOfOutput) { } static void freeItem(void* param) { - SGroupKeys *pKey = (SGroupKeys*) param; + SGroupKeys* pKey = (SGroupKeys*)param; taosMemoryFree(pKey->pData); } @@ -2096,9 +2100,11 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp SColumnInfoData* pDst = taosArrayGet(pResBlock->pDataBlock, dstSlot); switch (pSliceInfo->fillType) { - case TSDB_FILL_NULL: + case TSDB_FILL_NULL: { colDataAppendNULL(pDst, rows); + pResBlock->info.rows += 1; break; + } case TSDB_FILL_SET_VALUE: { SVariant* pVar = &pSliceInfo->pFillColInfo[j].fillVal; @@ -2116,9 +2122,11 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp GET_TYPED_DATA(v, int64_t, pVar->nType, &pVar->i); colDataAppend(pDst, rows, (char*)&v, false); } - } break; + pResBlock->info.rows += 1; + break; + } - case TSDB_FILL_LINEAR: + case TSDB_FILL_LINEAR: { #if 0 if (pCtx->start.key == INT64_MIN || pCtx->start.key > pCtx->startTs || pCtx->end.key == INT64_MIN || pCtx->end.key < pCtx->startTs) { @@ -2149,17 +2157,22 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp } } #endif + // TODO: pResBlock->info.rows += 1; break; - + } case TSDB_FILL_PREV: { SGroupKeys* pkey = taosArrayGet(pSliceInfo->pPrevRow, srcSlot); colDataAppend(pDst, rows, pkey->pData, false); - } break; + pResBlock->info.rows += 1; + break; + } case TSDB_FILL_NEXT: { char* p = colDataGetData(pSrc, rowIndex); colDataAppend(pDst, rows, p, colDataIsNull_s(pSrc, rowIndex)); - } break; + pResBlock->info.rows += 1; + break; + } case TSDB_FILL_NONE: default: @@ -2167,7 +2180,6 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp } } - pResBlock->info.rows += 1; } static int32_t initPrevRowsKeeper(STimeSliceOperatorInfo* pInfo, SSDataBlock* pBlock) { @@ -2219,6 +2231,8 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { SInterval* pInterval = &pSliceInfo->interval; SOperatorInfo* downstream = pOperator->pDownstream[0]; + blockDataCleanup(pResBlock); + int32_t numOfRows = 0; while (1) { SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); @@ -2345,10 +2359,10 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode initResultSizeInfo(&pOperator->resultInfo, 4096); pInfo->pFillColInfo = createFillColInfo(pExprInfo, numOfExprs, (SNodeListNode*)pInterpPhyNode->pFillValues); - pInfo->pRes = createResDataBlock(pPhyNode->pOutputDataBlockDesc); - pInfo->win = pInterpPhyNode->timeRange; + pInfo->pRes = createResDataBlock(pPhyNode->pOutputDataBlockDesc); + pInfo->win = pInterpPhyNode->timeRange; pInfo->interval.interval = pInterpPhyNode->interval; - pInfo->current = pInfo->win.skey; + pInfo->current = pInfo->win.skey; pOperator->name = "TimeSliceOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC; @@ -2769,7 +2783,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { SExprSupp* pSup = &pOperator->exprSupp; - qDebug("interval status %d %s", pOperator->status, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi"); + qDebug("interval status %d %s", pOperator->status, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); if (pOperator->status == OP_EXEC_DONE) { return NULL; @@ -2778,7 +2792,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { if (pInfo->pPullDataRes->info.rows != 0) { // process the rest of the data ASSERT(IS_FINAL_OP(pInfo)); - printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi"); + printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); return pInfo->pPullDataRes; } @@ -2793,20 +2807,20 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { } return NULL; } - printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi"); + printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); return pInfo->binfo.pRes; } else { if (!IS_FINAL_OP(pInfo)) { doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); if (pInfo->binfo.pRes->info.rows != 0) { - printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi"); + printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); return pInfo->binfo.pRes; } } if (pInfo->pUpdateRes->info.rows != 0 && pInfo->returnUpdate) { pInfo->returnUpdate = false; ASSERT(!IS_FINAL_OP(pInfo)); - printDataBlock(pInfo->pUpdateRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi"); + printDataBlock(pInfo->pUpdateRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); // process the rest of the data return pInfo->pUpdateRes; } @@ -2814,13 +2828,13 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { // if (pInfo->pPullDataRes->info.rows != 0) { // // process the rest of the data // ASSERT(IS_FINAL_OP(pInfo)); - // printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi"); + // printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); // return pInfo->pPullDataRes; // } doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes); if (pInfo->pDelRes->info.rows != 0) { // process the rest of the data - printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi"); + printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); return pInfo->pDelRes; } } @@ -2831,10 +2845,10 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { clearSpecialDataBlock(pInfo->pUpdateRes); removeDeleteResults(pUpdated, pInfo->pDelWins); pOperator->status = OP_RES_TO_RETURN; - qDebug("%s return data", IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi"); + qDebug("%s return data", IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); break; } - printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "interval Final recv" : "interval Semi recv"); + printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "interval final recv" : "interval semi recv"); maxTs = TMAX(maxTs, pBlock->info.window.ekey); if (pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_PULL_DATA || @@ -2934,20 +2948,20 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { if (pInfo->pPullDataRes->info.rows != 0) { // process the rest of the data ASSERT(IS_FINAL_OP(pInfo)); - printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi"); + printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); return pInfo->pPullDataRes; } doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); if (pInfo->binfo.pRes->info.rows != 0) { - printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi"); + printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); return pInfo->binfo.pRes; } if (pInfo->pUpdateRes->info.rows != 0 && pInfo->returnUpdate) { pInfo->returnUpdate = false; ASSERT(!IS_FINAL_OP(pInfo)); - printDataBlock(pInfo->pUpdateRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi"); + printDataBlock(pInfo->pUpdateRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); // process the rest of the data return pInfo->pUpdateRes; } @@ -2955,7 +2969,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes); if (pInfo->pDelRes->info.rows != 0) { // process the rest of the data - printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi"); + printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); return pInfo->pDelRes; } // ASSERT(false); @@ -2968,8 +2982,8 @@ SSDataBlock* createSpecialDataBlock(EStreamType type) { pBlock->info.groupId = 0; pBlock->info.rows = 0; pBlock->info.type = type; - pBlock->info.rowSize = sizeof(TSKEY) + sizeof(TSKEY) + sizeof(uint64_t) + - sizeof(uint64_t) + sizeof(TSKEY) + sizeof(TSKEY); + pBlock->info.rowSize = + sizeof(TSKEY) + sizeof(TSKEY) + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(TSKEY) + sizeof(TSKEY); pBlock->pDataBlock = taosArrayInit(6, sizeof(SColumnInfoData)); SColumnInfoData infoData = {0}; @@ -3145,6 +3159,8 @@ void destroyStreamSessionAggOperatorInfo(void* param, int32_t numOfOutput) { blockDataDestroy(pInfo->pDelRes); blockDataDestroy(pInfo->pWinBlock); blockDataDestroy(pInfo->pUpdateRes); + destroySqlFunctionCtx(pInfo->pDummyCtx, 0); + taosHashCleanup(pInfo->pStDeleted); taosMemoryFreeClear(param); } @@ -3815,14 +3831,14 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { } else if (pOperator->status == OP_RES_TO_RETURN) { doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); if (pInfo->pDelRes->info.rows > 0) { - printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "Final Session" : "Single Session"); + printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "final session" : "single session"); return pInfo->pDelRes; } doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf); if (pBInfo->pRes->info.rows == 0 || !hasDataInGroupInfo(&pInfo->groupResInfo)) { doSetOperatorCompleted(pOperator); } - printDataBlock(pBInfo->pRes, IS_FINAL_OP(pInfo) ? "Final Session" : "Single Session"); + printDataBlock(pBInfo->pRes, IS_FINAL_OP(pInfo) ? "final session" : "single session"); return pBInfo->pRes->info.rows == 0 ? NULL : pBInfo->pRes; } @@ -3835,7 +3851,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { if (pBlock == NULL) { break; } - printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "Final Session Recv" : "Single Session Recv"); + printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "final session recv" : "single session recv"); if (pBlock->info.type == STREAM_CLEAR) { SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo)); @@ -3912,11 +3928,11 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); if (pInfo->pDelRes->info.rows > 0) { - printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "Final Session" : "Single Session"); + printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "final session" : "single session"); return pInfo->pDelRes; } doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf); - printDataBlock(pBInfo->pRes, IS_FINAL_OP(pInfo) ? "Final Session" : "Single Session"); + printDataBlock(pBInfo->pRes, IS_FINAL_OP(pInfo) ? "final session" : "single session"); return pBInfo->pRes->info.rows == 0 ? NULL : pBInfo->pRes; } @@ -3955,21 +3971,21 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { } else if (pOperator->status == OP_RES_TO_RETURN) { doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf); if (pBInfo->pRes->info.rows > 0) { - printDataBlock(pBInfo->pRes, "Semi Session"); + printDataBlock(pBInfo->pRes, "sems session"); return pBInfo->pRes; } // doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); if (pInfo->pDelRes->info.rows > 0 && !pInfo->returnDelete) { pInfo->returnDelete = true; - printDataBlock(pInfo->pDelRes, "Semi Session"); + printDataBlock(pInfo->pDelRes, "sems session"); return pInfo->pDelRes; } if (pInfo->pUpdateRes->info.rows > 0) { // process the rest of the data pOperator->status = OP_OPENED; - printDataBlock(pInfo->pUpdateRes, "Semi Session"); + printDataBlock(pInfo->pUpdateRes, "sems session"); return pInfo->pUpdateRes; } // semi interval operator clear disk buffer @@ -4033,21 +4049,21 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf); if (pBInfo->pRes->info.rows > 0) { - printDataBlock(pBInfo->pRes, "Semi Session"); + printDataBlock(pBInfo->pRes, "sems session"); return pBInfo->pRes; } // doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); if (pInfo->pDelRes->info.rows > 0 && !pInfo->returnDelete) { pInfo->returnDelete = true; - printDataBlock(pInfo->pDelRes, "Semi Session"); + printDataBlock(pInfo->pDelRes, "sems session"); return pInfo->pDelRes; } if (pInfo->pUpdateRes->info.rows > 0) { // process the rest of the data pOperator->status = OP_OPENED; - printDataBlock(pInfo->pUpdateRes, "Semi Session"); + printDataBlock(pInfo->pUpdateRes, "sems session"); return pInfo->pUpdateRes; } @@ -4321,10 +4337,10 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl } else { return; } - + SStreamAggSupporter* pAggSup = &pInfo->streamAggSup; blockDataEnsureCapacity(pAggSup->pScanBlock, pSDataBlock->info.rows); - SColumnInfoData* pKeyColInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->stateCol.slotId); + SColumnInfoData* pKeyColInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->stateCol.slotId); for (int32_t i = 0; i < pSDataBlock->info.rows; i += winRows) { if (pInfo->ignoreExpiredData && isOverdue(tsCols[i], &pInfo->twAggSup)) { i++; @@ -4339,7 +4355,7 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl &allEqual, pInfo->pSeDeleted); if (!allEqual) { appendOneRow(pAggSup->pScanBlock, &pCurWin->winInfo.win.skey, &pCurWin->winInfo.win.ekey, - &pSDataBlock->info.groupId); + &pSDataBlock->info.groupId); taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition)); deleteWindow(pAggSup->pCurWins, winIndex); continue; diff --git a/source/libs/function/inc/builtins.h b/source/libs/function/inc/builtins.h index 256500ff8ce00e16fe0356da8fa1d7ce279e34ab..f5efcd520620c97e2dcec72e4a3c494124d23ff4 100644 --- a/source/libs/function/inc/builtins.h +++ b/source/libs/function/inc/builtins.h @@ -25,6 +25,7 @@ extern "C" { typedef int32_t (*FTranslateFunc)(SFunctionNode* pFunc, char* pErrBuf, int32_t len); typedef EFuncDataRequired (*FFuncDataRequired)(SFunctionNode* pFunc, STimeWindow* pTimeWindow); typedef int32_t (*FCreateMergeFuncParameters)(SNodeList* pRawParameters, SNode* pPartialRes, SNodeList** pParameters); +typedef EFuncDataRequired (*FFuncDynDataRequired)(void* pRes, STimeWindow* pTimeWindow); typedef struct SBuiltinFuncDefinition { const char* name; @@ -32,6 +33,7 @@ typedef struct SBuiltinFuncDefinition { uint64_t classification; FTranslateFunc translateFunc; FFuncDataRequired dataRequiredFunc; + FFuncDynDataRequired dynDataRequiredFunc; FExecGetEnv getEnvFunc; FExecInit initFunc; FExecProcess processFunc; diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 324a17320ee5baeff0e786589c3be8574376ab7c..01a5e7997ec041782137e89dc73c2e3da9c68b4e 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -557,11 +557,13 @@ static int32_t translateApercentileImpl(SFunctionNode* pFunc, char* pErrBuf, int pFunc->node.resType = (SDataType){.bytes = getApercentileMaxSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; } else { - if (1 != numOfParams) { + // original percent param is reserved + if (2 != numOfParams) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); } uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; - if (TSDB_DATA_TYPE_BINARY != para1Type) { + uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; + if (TSDB_DATA_TYPE_BINARY != para1Type || !IS_INTEGER_TYPE(para2Type)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -621,7 +623,7 @@ static int32_t translateTopBot(SFunctionNode* pFunc, char* pErrBuf, int32_t len) return TSDB_CODE_SUCCESS; } -int32_t topBotCreateMergePara(SNodeList* pRawParameters, SNode* pPartialRes, SNodeList** pParameters) { +static int32_t reserveFirstMergeParam(SNodeList* pRawParameters, SNode* pPartialRes, SNodeList** pParameters) { int32_t code = nodesListMakeAppend(pParameters, pPartialRes); if (TSDB_CODE_SUCCESS == code) { code = nodesListStrictAppend(*pParameters, nodesCloneNode(nodesListGetNode(pRawParameters, 1))); @@ -629,6 +631,14 @@ int32_t topBotCreateMergePara(SNodeList* pRawParameters, SNode* pPartialRes, SNo return TSDB_CODE_SUCCESS; } +int32_t topBotCreateMergeParam(SNodeList* pRawParameters, SNode* pPartialRes, SNodeList** pParameters) { + return reserveFirstMergeParam(pRawParameters, pPartialRes, pParameters); +} + +int32_t apercentileCreateMergeParam(SNodeList* pRawParameters, SNode* pPartialRes, SNodeList** pParameters) { + return reserveFirstMergeParam(pRawParameters, pPartialRes, pParameters); +} + static int32_t translateSpread(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { if (1 != LIST_LENGTH(pFunc->pParameterList)) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); @@ -1532,7 +1542,7 @@ static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { } uint8_t resType; - if (IS_SIGNED_NUMERIC_TYPE(colType) || TSDB_DATA_TYPE_BOOL == colType) { + if (IS_SIGNED_NUMERIC_TYPE(colType) || TSDB_DATA_TYPE_BOOL == colType || TSDB_DATA_TYPE_TIMESTAMP == colType) { resType = TSDB_DATA_TYPE_BIGINT; } else { resType = TSDB_DATA_TYPE_DOUBLE; @@ -2068,7 +2078,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .invertFunc = NULL, .combineFunc = apercentileCombine, .pPartialFunc = "_apercentile_partial", - .pMergeFunc = "_apercentile_merge" + .pMergeFunc = "_apercentile_merge", + .createMergeParaFuc = apercentileCreateMergeParam }, { .name = "_apercentile_partial", @@ -2107,7 +2118,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .combineFunc = topCombine, .pPartialFunc = "top", .pMergeFunc = "top", - .createMergeParaFuc = topBotCreateMergePara + .createMergeParaFuc = topBotCreateMergeParam }, { .name = "bottom", @@ -2122,7 +2133,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .combineFunc = bottomCombine, .pPartialFunc = "bottom", .pMergeFunc = "bottom", - .createMergeParaFuc = topBotCreateMergePara + .createMergeParaFuc = topBotCreateMergeParam }, { .name = "spread", @@ -2220,7 +2231,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "derivative", .type = FUNCTION_TYPE_DERIVATIVE, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateDerivative, .getEnvFunc = getDerivativeFuncEnv, .initFunc = derivativeFuncSetup, @@ -2425,7 +2436,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "diff", .type = FUNCTION_TYPE_DIFF, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateDiff, .getEnvFunc = getDiffFuncEnv, .initFunc = diffFunctionSetup, diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index b6fe5b999801ccdba27f95905004311fbebeb596..200df6bc804fae3cbf487b090b28ee95e0c03704 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -466,7 +466,7 @@ int32_t functionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - pResInfo->isNullRes = (pResInfo->numOfRes == 0) ? 1 : 0; + pResInfo->isNullRes = (pResInfo->isNullRes == 1) ? 1 : (pResInfo->numOfRes == 0); char* in = GET_ROWCELL_INTERBUF(pResInfo); colDataAppend(pCol, pBlock->info.rows, in, pResInfo->isNullRes); @@ -612,8 +612,7 @@ int32_t sumFunction(SqlFunctionCtx* pCtx) { SSumRes* pSumRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); if (IS_NULL_TYPE(type)) { - GET_RES_INFO(pCtx)->isNullRes = 1; - numOfElem = 1; + numOfElem = 0; goto _sum_over; } @@ -663,7 +662,8 @@ int32_t sumFunction(SqlFunctionCtx* pCtx) { // check for overflow if (IS_FLOAT_TYPE(type) && (isinf(pSumRes->dsum) || isnan(pSumRes->dsum))) { - numOfElem = 0; + GET_RES_INFO(pCtx)->isNullRes = 1; + numOfElem = 1; } _sum_over: @@ -1171,8 +1171,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { SMinmaxResInfo* pBuf = GET_ROWCELL_INTERBUF(pResInfo); if (IS_NULL_TYPE(type)) { - GET_RES_INFO(pCtx)->isNullRes = 1; - numOfElems = 1; + numOfElems = 0; goto _min_max_over; } @@ -1605,7 +1604,7 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t currentRow = pBlock->info.rows; SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); - pEntryInfo->isNullRes = (pEntryInfo->numOfRes == 0); + pEntryInfo->isNullRes = (pEntryInfo->isNullRes == 1) ? 1 : (pEntryInfo->numOfRes == 0); if (pCol->info.type == TSDB_DATA_TYPE_FLOAT) { float v = *(double*)&pRes->v; @@ -1624,6 +1623,10 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { } void setNullSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t rowIndex) { + if (pCtx->subsidiaries.num <= 0) { + return; + } + for (int32_t j = 0; j < pCtx->subsidiaries.num; ++j) { SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j]; int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; @@ -1655,8 +1658,6 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple SFunctParam* pFuncParam = &pc->pExpr->base.pParam[0]; int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; - int32_t ps = 0; - SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId); ASSERT(pc->pExpr->base.resSchema.bytes == pDstCol->info.bytes); if (nullList[j]) { @@ -1678,6 +1679,39 @@ void releaseSource(STuplePos* pPos) { // Todo(liuyao) relase row } +// This function append the selectivity to subsidiaries function context directly, without fetching data +// from intermediate disk based buf page +void appendSelectivityValue(SqlFunctionCtx* pCtx, int32_t rowIndex, int32_t pos) { + if (pCtx->subsidiaries.num <= 0) { + return; + } + + for (int32_t j = 0; j < pCtx->subsidiaries.num; ++j) { + SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j]; + + // get data from source col + SFunctParam* pFuncParam = &pc->pExpr->base.pParam[0]; + int32_t srcSlotId = pFuncParam->pCol->slotId; + + SColumnInfoData* pSrcCol = taosArrayGet(pCtx->pSrcBlock->pDataBlock, srcSlotId); + + char* pData = colDataGetData(pSrcCol, rowIndex); + + // append to dest col + int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; + + SColumnInfoData* pDstCol = taosArrayGet(pCtx->pDstBlock->pDataBlock, dstSlotId); + ASSERT(pc->pExpr->base.resSchema.bytes == pDstCol->info.bytes); + + if (colDataIsNull_s(pSrcCol, rowIndex) == true) { + colDataAppendNULL(pDstCol, pos); + } else { + colDataAppend(pDstCol, pos, pData, false); + } + } + +} + void replaceTupleData(STuplePos* pDestPos, STuplePos* pSourcePos) { releaseSource(pDestPos); *pDestPos = *pSourcePos; @@ -2218,6 +2252,7 @@ int32_t leastSQRFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t currentRow = pBlock->info.rows; if (0 == pInfo->num) { + colDataAppendNULL(pCol, currentRow); return 0; } @@ -3154,6 +3189,7 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo colDataAppendInt64(pOutput, pos, &delta); } pDiffInfo->prev.i64 = v; + break; } case TSDB_DATA_TYPE_BOOL: @@ -3247,6 +3283,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) { if (pDiffInfo->hasPrev) { doHandleDiff(pDiffInfo, pInputCol->info.type, pv, pOutput, pos, pCtx->order); + // handle selectivity + if (pCtx->subsidiaries.num > 0) { + appendSelectivityValue(pCtx, i, pos); + } numOfElems++; } else { @@ -3273,6 +3313,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) { // there is a row of previous data block to be handled in the first place. if (pDiffInfo->hasPrev) { doHandleDiff(pDiffInfo, pInputCol->info.type, pv, pOutput, pos, pCtx->order); + // handle selectivity + if (pCtx->subsidiaries.num > 0) { + appendSelectivityValue(pCtx, i, pos); + } numOfElems++; } else { @@ -5723,6 +5767,12 @@ int32_t derivativeFunction(SqlFunctionCtx* pCtx) { if (pTsOutput != NULL) { colDataAppendInt64(pTsOutput, pos, &tsList[i]); } + + // handle selectivity + if (pCtx->subsidiaries.num > 0) { + appendSelectivityValue(pCtx, i, pos); + } + numOfElems++; } } @@ -5755,6 +5805,12 @@ int32_t derivativeFunction(SqlFunctionCtx* pCtx) { if (pTsOutput != NULL) { colDataAppendInt64(pTsOutput, pos, &pDerivInfo->prevTs); } + + // handle selectivity + if (pCtx->subsidiaries.num > 0) { + appendSelectivityValue(pCtx, i, pos); + } + numOfElems++; } } diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index c173522683c7403950d915a9d1fa2d82eb828d1f..020fd648e1e7a404c980a9576d5a6a73ac52487f 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -103,6 +103,13 @@ EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWin return funcMgtBuiltins[pFunc->funcId].dataRequiredFunc(pFunc, pTimeWindow); } +EFuncDataRequired fmFuncDynDataRequired(int32_t funcId, void* pRes, STimeWindow* pTimeWindow) { + if (fmIsUserDefinedFunc(funcId) || funcId < 0 || funcId >= funcMgtBuiltinsNum) { + return TSDB_CODE_FAILED; + } + return funcMgtBuiltins[funcId].dynDataRequiredFunc(pRes, pTimeWindow); +} + int32_t fmGetFuncExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet) { if (fmIsUserDefinedFunc(funcId) || funcId < 0 || funcId >= funcMgtBuiltinsNum) { return TSDB_CODE_FAILED; diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index dae8c99abae609420af28b7b81e2d9b241f3b564..afacb50d3545a5def9e56f9d669b26fd0ea59f37 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -877,7 +877,7 @@ void udfcUvHandleError(SClientUvConn *conn); void onUdfcPipeRead(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf); void onUdfcPipeWrite(uv_write_t *write, int status); void onUdfcPipeConnect(uv_connect_t *connect, int status); -int32_t udfcCreateUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvTaskNode **pUvTask); +int32_t udfcInitializeUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvTaskNode *uvTask); int32_t udfcQueueUvTask(SClientUvTaskNode *uvTask); int32_t udfcStartUvTask(SClientUvTaskNode *uvTask); void udfcAsyncTaskCb(uv_async_t *async); @@ -1376,8 +1376,7 @@ void onUdfcPipeConnect(uv_connect_t *connect, int status) { uv_sem_post(&uvTask->taskSem); } -int32_t udfcCreateUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvTaskNode **pUvTask) { - SClientUvTaskNode *uvTask = taosMemoryCalloc(1, sizeof(SClientUvTaskNode)); +int32_t udfcInitializeUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvTaskNode *uvTask) { uvTask->type = uvTaskType; uvTask->udfc = task->session->udfc; @@ -1412,7 +1411,6 @@ int32_t udfcCreateUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvTaskN } uv_sem_init(&uvTask->taskSem, 0); - *pUvTask = uvTask; return 0; } @@ -1615,10 +1613,10 @@ int32_t udfcClose() { } int32_t udfcRunUdfUvTask(SClientUdfTask *task, int8_t uvTaskType) { - SClientUvTaskNode *uvTask = NULL; - - udfcCreateUvTask(task, uvTaskType, &uvTask); + SClientUvTaskNode *uvTask = taosMemoryCalloc(1, sizeof(SClientUvTaskNode)); fnDebug("udfc client task: %p created uvTask: %p. pipe: %p", task, uvTask, task->session->udfUvPipe); + + udfcInitializeUvTask(task, uvTaskType, uvTask); udfcQueueUvTask(uvTask); udfcGetUdfTaskResultFromUvTask(task, uvTask); if (uvTaskType == UV_TASK_CONNECT) { @@ -1629,6 +1627,8 @@ int32_t udfcRunUdfUvTask(SClientUdfTask *task, int8_t uvTaskType) { taosMemoryFree(uvTask->reqBuf.base); uvTask->reqBuf.base = NULL; taosMemoryFree(uvTask); + fnDebug("udfc freed uvTask: %p", task); + uvTask = NULL; return task->errCode; } diff --git a/source/libs/function/test/udf1.c b/source/libs/function/test/udf1.c index dfbae357efd71c646bff5060d06ee984c05fae63..5be18af553498bf2b05607b69223c302d3826fae 100644 --- a/source/libs/function/test/udf1.c +++ b/source/libs/function/test/udf1.c @@ -1,7 +1,12 @@ #include #include #include - +#ifdef LINUX +#include +#endif +#ifdef WINDOWS +#include +#endif #include "taosudf.h" @@ -35,6 +40,12 @@ DLL_EXPORT int32_t udf1(SUdfDataBlock* block, SUdfColumn *resultCol) { udfColDataSet(resultCol, i, (char *)&luckyNum, false); } } - + //to simulate actual processing delay by udf +#ifdef LINUX + usleep(1 * 1000); // usleep takes sleep time in us (1 millionth of a second) +#endif +#ifdef WINDOWS + Sleep(1); +#endif return 0; } \ No newline at end of file diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c index 7fc41b8dff3a6344186ce0bf82c83762b15d8a81..e1c8ac0204f77f6e4756cd05fba36141b911290f 100644 --- a/source/libs/index/src/indexFilter.c +++ b/source/libs/index/src/indexFilter.c @@ -579,11 +579,13 @@ static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *ou if (ctx->noExec == false) { for (int32_t m = 0; m < node->pParameterList->length; m++) { - // add impl later if (node->condType == LOGIC_COND_TYPE_AND) { taosArrayAddAll(output->result, params[m].result); + // taosArrayDestroy(params[m].result); + // params[m].result = NULL; } else if (node->condType == LOGIC_COND_TYPE_OR) { taosArrayAddAll(output->result, params[m].result); + // params[m].result = NULL; } else if (node->condType == LOGIC_COND_TYPE_NOT) { // taosArrayAddAll(output->result, params[m].result); } @@ -593,6 +595,8 @@ static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *ou } else { for (int32_t m = 0; m < node->pParameterList->length; m++) { output->status = sifMergeCond(node->condType, output->status, params[m].status); + taosArrayDestroy(params[m].result); + params[m].result = NULL; } } _return: @@ -607,6 +611,7 @@ static EDealRes sifWalkFunction(SNode *pNode, void *context) { SIFCtx *ctx = context; ctx->code = sifExecFunction(node, ctx, &output); if (ctx->code != TSDB_CODE_SUCCESS) { + sifFreeParam(&output); return DEAL_RES_ERROR; } @@ -624,6 +629,7 @@ static EDealRes sifWalkLogic(SNode *pNode, void *context) { SIFCtx *ctx = context; ctx->code = sifExecLogic(node, ctx, &output); if (ctx->code) { + sifFreeParam(&output); return DEAL_RES_ERROR; } @@ -640,6 +646,7 @@ static EDealRes sifWalkOper(SNode *pNode, void *context) { SIFCtx *ctx = context; ctx->code = sifExecOper(node, ctx, &output); if (ctx->code) { + sifFreeParam(&output); return DEAL_RES_ERROR; } if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { @@ -698,7 +705,11 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) { } nodesWalkExprPostOrder(pNode, sifCalcWalker, &ctx); - SIF_ERR_RET(ctx.code); + + if (ctx.code != 0) { + sifFreeRes(ctx.pRes); + return ctx.code; + } if (pDst) { SIFParam *res = (SIFParam *)taosHashGet(ctx.pRes, (void *)&pNode, POINTER_BYTES); @@ -714,8 +725,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) { taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES); } sifFreeRes(ctx.pRes); - - SIF_RET(code); + return code; } static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status) { @@ -732,8 +742,10 @@ static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status) { } nodesWalkExprPostOrder(pNode, sifCalcWalker, &ctx); - - SIF_ERR_RET(ctx.code); + if (ctx.code != 0) { + sifFreeRes(ctx.pRes); + return ctx.code; + } SIFParam *res = (SIFParam *)taosHashGet(ctx.pRes, (void *)&pNode, POINTER_BYTES); if (res == NULL) { @@ -745,8 +757,7 @@ static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status) { sifFreeParam(res); taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES); taosHashCleanup(ctx.pRes); - - SIF_RET(code); + return code; } int32_t doFilterTag(SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *result, SIdxFltStatus *status) { @@ -760,7 +771,11 @@ int32_t doFilterTag(SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *result, SArray *output = taosArrayInit(8, sizeof(uint64_t)); SIFParam param = {.arg = *metaArg, .result = output}; - SIF_ERR_RET(sifCalculate((SNode *)pFilterNode, ¶m)); + int32_t code = sifCalculate((SNode *)pFilterNode, ¶m); + if (code != 0) { + sifFreeParam(¶m); + return code; + } taosArrayAddAll(result, param.result); sifFreeParam(¶m); diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 5279d015b438226fe6ceecc386213cd9faaf9b20..5fc94c2642b6d1bc7a9fc4fe90748b0346acef78 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -401,7 +401,8 @@ static int32_t logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModi COPY_SCALAR_FIELD(tableId); COPY_SCALAR_FIELD(stableId); COPY_SCALAR_FIELD(tableType); - COPY_CHAR_ARRAY_FIELD(tableFName); + COPY_CHAR_ARRAY_FIELD(tableName); + COPY_CHAR_ARRAY_FIELD(tsColName); COPY_OBJECT_FIELD(deleteTimeRange, sizeof(STimeWindow)); CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone); CLONE_NODE_LIST_FIELD(pInsertCols); diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 186a51f0001911ef1b0144e404c6dbdc6b7af89c..af3f0c242b45aa19da29ccd37132b20d83582cfd 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -1522,6 +1522,7 @@ static const char* jkTableScanPhysiPlanWatermark = "Watermark"; static const char* jkTableScanPhysiPlanIgnoreExpired = "IgnoreExpired"; static const char* jkTableScanPhysiPlanGroupTags = "GroupTags"; static const char* jkTableScanPhysiPlanGroupSort = "GroupSort"; +static const char* jkTableScanPhysiPlanAssignBlockUid = "AssignBlockUid"; static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj; @@ -1578,6 +1579,9 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkTableScanPhysiPlanGroupSort, pNode->groupSort); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddBoolToObject(pJson, jkTableScanPhysiPlanAssignBlockUid, pNode->assignBlockUid); + } return code; } @@ -1637,6 +1641,9 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBoolValue(pJson, jkTableScanPhysiPlanGroupSort, &pNode->groupSort); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBoolValue(pJson, jkTableScanPhysiPlanAssignBlockUid, &pNode->assignBlockUid); + } return code; } @@ -1712,6 +1719,7 @@ static int32_t jsonToPhysiProjectNode(const SJson* pJson, void* pObj) { } static const char* jkJoinPhysiPlanJoinType = "JoinType"; +static const char* jkJoinPhysiPlanInputTsOrder = "InputTsOrder"; static const char* jkJoinPhysiPlanMergeCondition = "MergeCondition"; static const char* jkJoinPhysiPlanOnConditions = "OnConditions"; static const char* jkJoinPhysiPlanTargets = "Targets"; @@ -1723,6 +1731,9 @@ static int32_t physiJoinNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanJoinType, pNode->joinType); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanInputTsOrder, pNode->inputTsOrder); + } if (TSDB_CODE_SUCCESS == code) { code = tjsonAddObject(pJson, jkJoinPhysiPlanMergeCondition, nodeToJson, pNode->pMergeCondition); } @@ -1742,7 +1753,9 @@ static int32_t jsonToPhysiJoinNode(const SJson* pJson, void* pObj) { int32_t code = jsonToPhysicPlanNode(pJson, pObj); if (TSDB_CODE_SUCCESS == code) { tjsonGetNumberValue(pJson, jkJoinPhysiPlanJoinType, pNode->joinType, code); - ; + } + if (TSDB_CODE_SUCCESS == code) { + tjsonGetNumberValue(pJson, jkJoinPhysiPlanInputTsOrder, pNode->inputTsOrder, code); } if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeObject(pJson, jkJoinPhysiPlanOnConditions, &pNode->pOnConditions); @@ -2326,7 +2339,7 @@ static int32_t physiQueryInsertNodeToJson(const void* pObj, SJson* pJson) { code = tjsonAddIntegerToObject(pJson, jkQueryInsertPhysiPlanTableType, pNode->tableType); } if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddStringToObject(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableFName); + code = tjsonAddStringToObject(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableName); } if (TSDB_CODE_SUCCESS == code) { code = tjsonAddIntegerToObject(pJson, jkQueryInsertPhysiPlanVgId, pNode->vgId); @@ -2355,7 +2368,7 @@ static int32_t jsonToPhysiQueryInsertNode(const SJson* pJson, void* pObj) { code = tjsonGetTinyIntValue(pJson, jkQueryInsertPhysiPlanTableType, &pNode->tableType); } if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetStringValue(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableFName); + code = tjsonGetStringValue(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableName); } if (TSDB_CODE_SUCCESS == code) { code = tjsonGetIntValue(pJson, jkQueryInsertPhysiPlanVgId, &pNode->vgId); @@ -2370,6 +2383,7 @@ static int32_t jsonToPhysiQueryInsertNode(const SJson* pJson, void* pObj) { static const char* jkDeletePhysiPlanTableId = "TableId"; static const char* jkDeletePhysiPlanTableType = "TableType"; static const char* jkDeletePhysiPlanTableFName = "TableFName"; +static const char* jkDeletePhysiPlanTsColName = "TsColName"; static const char* jkDeletePhysiPlanDeleteTimeRangeStartKey = "DeleteTimeRangeStartKey"; static const char* jkDeletePhysiPlanDeleteTimeRangeEndKey = "DeleteTimeRangeEndKey"; static const char* jkDeletePhysiPlanAffectedRows = "AffectedRows"; @@ -2387,6 +2401,9 @@ static int32_t physiDeleteNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddStringToObject(pJson, jkDeletePhysiPlanTableFName, pNode->tableFName); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddStringToObject(pJson, jkDeletePhysiPlanTsColName, pNode->tsColName); + } if (TSDB_CODE_SUCCESS == code) { code = tjsonAddIntegerToObject(pJson, jkDeletePhysiPlanDeleteTimeRangeStartKey, pNode->deleteTimeRange.skey); } @@ -2413,6 +2430,9 @@ static int32_t jsonToPhysiDeleteNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetStringValue(pJson, jkDeletePhysiPlanTableFName, pNode->tableFName); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetStringValue(pJson, jkDeletePhysiPlanTsColName, pNode->tsColName); + } if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBigIntValue(pJson, jkDeletePhysiPlanDeleteTimeRangeStartKey, &pNode->deleteTimeRange.skey); } @@ -4512,7 +4532,6 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: return jsonToPhysiScanNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: - return jsonToPhysiLastRowScanNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN: diff --git a/source/libs/nodes/src/nodesEqualFuncs.c b/source/libs/nodes/src/nodesEqualFuncs.c index 681e99a4526e7da38b2b8bfbf0e003d3f640e281..2442bd8c16e45e6c7d492b2bd1c58d0e713c5a77 100644 --- a/source/libs/nodes/src/nodesEqualFuncs.c +++ b/source/libs/nodes/src/nodesEqualFuncs.c @@ -82,6 +82,7 @@ static bool columnNodeEqual(const SColumnNode* a, const SColumnNode* b) { COMPARE_STRING_FIELD(dbName); COMPARE_STRING_FIELD(tableName); COMPARE_STRING_FIELD(colName); + COMPARE_STRING_FIELD(tableAlias); return true; } diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 12c18733b10d4c7b35f73567fc1f433e65707c26..705ba9d339c83e397bffce7da967b7c3feec93ae 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -55,7 +55,11 @@ typedef enum EDatabaseOptionType { DB_OPTION_VGROUPS, DB_OPTION_SINGLE_STABLE, DB_OPTION_RETENTIONS, - DB_OPTION_SCHEMALESS + DB_OPTION_SCHEMALESS, + DB_OPTION_WAL_RETENTION_PERIOD, + DB_OPTION_WAL_RETENTION_SIZE, + DB_OPTION_WAL_ROLL_PERIOD, + DB_OPTION_WAL_SEGMENT_SIZE } EDatabaseOptionType; typedef enum ETableOptionType { diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 920277370a18730ad455a4c9ea9e2bd206533c0e..f625ebd388ba5d57f8b284ac8c25ed9ab475cbb3 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -176,7 +176,6 @@ db_options(A) ::= db_options(B) CACHESIZE NK_INTEGER(C). db_options(A) ::= db_options(B) COMP NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_COMP, &C); } db_options(A) ::= db_options(B) DURATION NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_DAYS, &C); } db_options(A) ::= db_options(B) DURATION NK_VARIABLE(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_DAYS, &C); } -db_options(A) ::= db_options(B) FSYNC NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_FSYNC, &C); } db_options(A) ::= db_options(B) MAXROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MAXROWS, &C); } db_options(A) ::= db_options(B) MINROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MINROWS, &C); } db_options(A) ::= db_options(B) KEEP integer_list(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_KEEP, C); } @@ -186,11 +185,26 @@ db_options(A) ::= db_options(B) PAGESIZE NK_INTEGER(C). db_options(A) ::= db_options(B) PRECISION NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_PRECISION, &C); } db_options(A) ::= db_options(B) REPLICA NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_REPLICA, &C); } db_options(A) ::= db_options(B) STRICT NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STRICT, &C); } -db_options(A) ::= db_options(B) WAL NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL, &C); } db_options(A) ::= db_options(B) VGROUPS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_VGROUPS, &C); } db_options(A) ::= db_options(B) SINGLE_STABLE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SINGLE_STABLE, &C); } db_options(A) ::= db_options(B) RETENTIONS retention_list(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_RETENTIONS, C); } db_options(A) ::= db_options(B) SCHEMALESS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SCHEMALESS, &C); } +db_options(A) ::= db_options(B) WAL_LEVEL NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL, &C); } +db_options(A) ::= db_options(B) WAL_FSYNC_PERIOD NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_FSYNC, &C); } +db_options(A) ::= db_options(B) WAL_RETENTION_PERIOD NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL_RETENTION_PERIOD, &C); } +db_options(A) ::= db_options(B) WAL_RETENTION_PERIOD NK_MINUS(D) NK_INTEGER(C). { + SToken t = D; + t.n = (C.z + C.n) - D.z; + A = setDatabaseOption(pCxt, B, DB_OPTION_WAL_RETENTION_PERIOD, &t); + } +db_options(A) ::= db_options(B) WAL_RETENTION_SIZE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL_RETENTION_SIZE, &C); } +db_options(A) ::= db_options(B) WAL_RETENTION_SIZE NK_MINUS(D) NK_INTEGER(C). { + SToken t = D; + t.n = (C.z + C.n) - D.z; + A = setDatabaseOption(pCxt, B, DB_OPTION_WAL_RETENTION_SIZE, &t); + } +db_options(A) ::= db_options(B) WAL_ROLL_PERIOD NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL_ROLL_PERIOD, &C); } +db_options(A) ::= db_options(B) WAL_SEGMENT_SIZE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL_SEGMENT_SIZE, &C); } alter_db_options(A) ::= alter_db_option(B). { A = createAlterDatabaseOptions(pCxt); A = setAlterDatabaseOption(pCxt, A, &B); } alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setAlterDatabaseOption(pCxt, B, &C); } @@ -200,13 +214,13 @@ alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). //alter_db_option(A) ::= BUFFER NK_INTEGER(B). { A.type = DB_OPTION_BUFFER; A.val = B; } alter_db_option(A) ::= CACHEMODEL NK_STRING(B). { A.type = DB_OPTION_CACHEMODEL; A.val = B; } alter_db_option(A) ::= CACHESIZE NK_INTEGER(B). { A.type = DB_OPTION_CACHESIZE; A.val = B; } -alter_db_option(A) ::= FSYNC NK_INTEGER(B). { A.type = DB_OPTION_FSYNC; A.val = B; } +alter_db_option(A) ::= WAL_FSYNC_PERIOD NK_INTEGER(B). { A.type = DB_OPTION_FSYNC; A.val = B; } alter_db_option(A) ::= KEEP integer_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; } alter_db_option(A) ::= KEEP variable_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; } //alter_db_option(A) ::= PAGES NK_INTEGER(B). { A.type = DB_OPTION_PAGES; A.val = B; } //alter_db_option(A) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.val = B; } //alter_db_option(A) ::= STRICT NK_STRING(B). { A.type = DB_OPTION_STRICT; A.val = B; } -alter_db_option(A) ::= WAL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; } +alter_db_option(A) ::= WAL_LEVEL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; } %type integer_list { SNodeList* } %destructor integer_list { nodesDestroyList($$); } @@ -462,7 +476,7 @@ 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); } /************************************************ compact *************************************************************/ -cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP. { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } +//cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP. { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } /************************************************ create/drop function ************************************************/ cmd ::= CREATE agg_func_opt(A) FUNCTION not_exists_opt(F) function_name(B) @@ -511,7 +525,7 @@ dnode_list(A) ::= DNODE NK_INTEGER(B). dnode_list(A) ::= dnode_list(B) DNODE NK_INTEGER(C). { A = addNodeToList(pCxt, B, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C)); } /************************************************ syncdb **************************************************************/ -cmd ::= SYNCDB db_name(A) REPLICA. { pCxt->pRootNode = createSyncdbStmt(pCxt, &A); } +//cmd ::= SYNCDB db_name(A) REPLICA. { pCxt->pRootNode = createSyncdbStmt(pCxt, &A); } /************************************************ syncdb **************************************************************/ cmd ::= DELETE FROM full_table_name(A) where_clause_opt(B). { pCxt->pRootNode = createDeleteStmt(pCxt, A, B); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index a54dae1ee98acdbc6dda57855885308c97c8387c..ff2157fe675f84c3d646b402a8de62978b0f9f02 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -894,6 +894,18 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti case DB_OPTION_RETENTIONS: ((SDatabaseOptions*)pOptions)->pRetentions = pVal; break; + case DB_OPTION_WAL_RETENTION_PERIOD: + ((SDatabaseOptions*)pOptions)->walRetentionPeriod = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + break; + case DB_OPTION_WAL_RETENTION_SIZE: + ((SDatabaseOptions*)pOptions)->walRetentionSize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + break; + case DB_OPTION_WAL_ROLL_PERIOD: + ((SDatabaseOptions*)pOptions)->walRollPeriod = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + break; + case DB_OPTION_WAL_SEGMENT_SIZE: + ((SDatabaseOptions*)pOptions)->walSegmentSize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + break; default: break; } diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index b9d907c600f103f4a9ec05e7bc2d0fe842f4babc..db907b1f68a1013d8e44215d04ffb83fdc79cf3f 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -29,287 +29,224 @@ typedef struct SKeyword { // clang-format off // keywords in sql string static SKeyword keywordTable[] = { - {"ACCOUNT", TK_ACCOUNT}, - {"ACCOUNTS", TK_ACCOUNTS}, - {"ADD", TK_ADD}, - {"AGGREGATE", TK_AGGREGATE}, - {"ALL", TK_ALL}, - {"ALTER", TK_ALTER}, - {"ANALYZE", TK_ANALYZE}, - {"AND", TK_AND}, - {"APPS", TK_APPS}, - {"AS", TK_AS}, - {"ASC", TK_ASC}, - {"AT_ONCE", TK_AT_ONCE}, - {"BALANCE", TK_BALANCE}, - {"BETWEEN", TK_BETWEEN}, - {"BINARY", TK_BINARY}, - {"BIGINT", TK_BIGINT}, - {"BNODE", TK_BNODE}, - {"BNODES", TK_BNODES}, - {"BOOL", TK_BOOL}, - {"BUFFER", TK_BUFFER}, - {"BUFSIZE", TK_BUFSIZE}, - {"BY", TK_BY}, - {"CACHE", TK_CACHE}, - {"CACHEMODEL", TK_CACHEMODEL}, - {"CACHESIZE", TK_CACHESIZE}, - {"CAST", TK_CAST}, - {"CLIENT_VERSION", TK_CLIENT_VERSION}, - {"CLUSTER", TK_CLUSTER}, - {"COLUMN", TK_COLUMN}, - {"COMMENT", TK_COMMENT}, - {"COMP", TK_COMP}, - {"COMPACT", TK_COMPACT}, - {"CONNS", TK_CONNS}, - {"CONNECTION", TK_CONNECTION}, - {"CONNECTIONS", TK_CONNECTIONS}, - {"CONSUMER", TK_CONSUMER}, - {"CONSUMERS", TK_CONSUMERS}, - {"CONTAINS", TK_CONTAINS}, - {"COUNT", TK_COUNT}, - {"CREATE", TK_CREATE}, - {"CURRENT_USER", TK_CURRENT_USER}, - {"DATABASE", TK_DATABASE}, - {"DATABASES", TK_DATABASES}, - {"DBS", TK_DBS}, - {"DELETE", TK_DELETE}, - {"DESC", TK_DESC}, - {"DESCRIBE", TK_DESCRIBE}, - {"DISTINCT", TK_DISTINCT}, - {"DISTRIBUTED", TK_DISTRIBUTED}, - {"DNODE", TK_DNODE}, - {"DNODES", TK_DNODES}, - {"DOUBLE", TK_DOUBLE}, - {"DROP", TK_DROP}, - {"DURATION", TK_DURATION}, - {"ENABLE", TK_ENABLE}, - {"EXISTS", TK_EXISTS}, - {"EXPIRED", TK_EXPIRED}, - {"EXPLAIN", TK_EXPLAIN}, - {"EVERY", TK_EVERY}, - {"FILE", TK_FILE}, - {"FILL", TK_FILL}, - {"FIRST", TK_FIRST}, - {"FLOAT", TK_FLOAT}, - {"FLUSH", TK_FLUSH}, - {"FROM", TK_FROM}, - {"FSYNC", TK_FSYNC}, - {"FUNCTION", TK_FUNCTION}, - {"FUNCTIONS", TK_FUNCTIONS}, - {"GRANT", TK_GRANT}, - {"GRANTS", TK_GRANTS}, - {"GROUP", TK_GROUP}, - {"HAVING", TK_HAVING}, - {"IF", TK_IF}, - {"IGNORE", TK_IGNORE}, - {"IMPORT", TK_IMPORT}, - {"IN", TK_IN}, - {"INDEX", TK_INDEX}, - {"INDEXES", TK_INDEXES}, - {"INNER", TK_INNER}, - {"INT", TK_INT}, - {"INSERT", TK_INSERT}, - {"INTEGER", TK_INTEGER}, - {"INTERVAL", TK_INTERVAL}, - {"INTO", TK_INTO}, - {"IS", TK_IS}, - {"JOIN", TK_JOIN}, - {"JSON", TK_JSON}, - {"KEEP", TK_KEEP}, - {"KILL", TK_KILL}, - {"LAST", TK_LAST}, - {"LAST_ROW", TK_LAST_ROW}, - {"LICENCE", TK_LICENCE}, - {"LIKE", TK_LIKE}, - {"LIMIT", TK_LIMIT}, - {"LINEAR", TK_LINEAR}, - {"LOCAL", TK_LOCAL}, - {"MATCH", TK_MATCH}, - {"MAXROWS", TK_MAXROWS}, - {"MAX_DELAY", TK_MAX_DELAY}, - {"MERGE", TK_MERGE}, - {"META", TK_META}, - {"MINROWS", TK_MINROWS}, - {"MINUS", TK_MINUS}, - {"MNODE", TK_MNODE}, - {"MNODES", TK_MNODES}, - {"MODIFY", TK_MODIFY}, - {"MODULES", TK_MODULES}, - {"NCHAR", TK_NCHAR}, - {"NEXT", TK_NEXT}, - {"NMATCH", TK_NMATCH}, - {"NONE", TK_NONE}, - {"NOT", TK_NOT}, - {"NOW", TK_NOW}, - {"NULL", TK_NULL}, - {"NULLS", TK_NULLS}, - {"OFFSET", TK_OFFSET}, - {"ON", TK_ON}, - {"OR", TK_OR}, - {"ORDER", TK_ORDER}, - {"OUTPUTTYPE", TK_OUTPUTTYPE}, - {"PARTITION", TK_PARTITION}, - {"PASS", TK_PASS}, - {"PAGES", TK_PAGES}, - {"PAGESIZE", TK_PAGESIZE}, - {"PORT", TK_PORT}, - {"PPS", TK_PPS}, - {"PRECISION", TK_PRECISION}, - // {"PRIVILEGE", TK_PRIVILEGE}, - {"PREV", TK_PREV}, - {"QNODE", TK_QNODE}, - {"QNODES", TK_QNODES}, - {"QTIME", TK_QTIME}, - {"QUERIES", TK_QUERIES}, - {"QUERY", TK_QUERY}, - {"RANGE", TK_RANGE}, - {"RATIO", TK_RATIO}, - {"READ", TK_READ}, - {"REDISTRIBUTE", TK_REDISTRIBUTE}, - {"RENAME", TK_RENAME}, - {"REPLICA", TK_REPLICA}, - {"RESET", TK_RESET}, - {"RETENTIONS", TK_RETENTIONS}, - {"REVOKE", TK_REVOKE}, - {"ROLLUP", TK_ROLLUP}, - {"SCHEMALESS", TK_SCHEMALESS}, - {"SCORES", TK_SCORES}, - {"SELECT", TK_SELECT}, - {"SERVER_STATUS", TK_SERVER_STATUS}, - {"SERVER_VERSION", TK_SERVER_VERSION}, - {"SESSION", TK_SESSION}, - {"SET", TK_SET}, - {"SHOW", TK_SHOW}, - {"SINGLE_STABLE", TK_SINGLE_STABLE}, - {"SLIDING", TK_SLIDING}, - {"SLIMIT", TK_SLIMIT}, - {"SMA", TK_SMA}, - {"SMALLINT", TK_SMALLINT}, - {"SNODE", TK_SNODE}, - {"SNODES", TK_SNODES}, - {"SOFFSET", TK_SOFFSET}, - {"SPLIT", TK_SPLIT}, - {"STABLE", TK_STABLE}, - {"STABLES", TK_STABLES}, - {"STATE", TK_STATE}, - {"STATE_WINDOW", TK_STATE_WINDOW}, - {"STORAGE", TK_STORAGE}, - {"STREAM", TK_STREAM}, - {"STREAMS", TK_STREAMS}, - {"STRICT", TK_STRICT}, - {"SUBSCRIPTIONS", TK_SUBSCRIPTIONS}, - {"SYNCDB", TK_SYNCDB}, - {"SYSINFO", TK_SYSINFO}, - {"TABLE", TK_TABLE}, - {"TABLES", TK_TABLES}, - {"TAG", TK_TAG}, - {"TAGS", TK_TAGS}, - {"TBNAME", TK_TBNAME}, - {"TIMESTAMP", TK_TIMESTAMP}, - {"TIMEZONE", TK_TIMEZONE}, - {"TINYINT", TK_TINYINT}, - {"TO", TK_TO}, - {"TODAY", TK_TODAY}, - {"TOPIC", TK_TOPIC}, - {"TOPICS", TK_TOPICS}, - {"TRANSACTION", TK_TRANSACTION}, - {"TRANSACTIONS", TK_TRANSACTIONS}, - {"TRIGGER", TK_TRIGGER}, - {"TRIM", TK_TRIM}, - {"TSERIES", TK_TSERIES}, - {"TTL", TK_TTL}, - {"UNION", TK_UNION}, - {"UNSIGNED", TK_UNSIGNED}, - {"USE", TK_USE}, - {"USER", TK_USER}, - {"USERS", TK_USERS}, - {"USING", TK_USING}, - {"VALUE", TK_VALUE}, - {"VALUES", TK_VALUES}, - {"VARCHAR", TK_VARCHAR}, - {"VARIABLES", TK_VARIABLES}, - {"VERBOSE", TK_VERBOSE}, - {"VGROUP", TK_VGROUP}, - {"VGROUPS", TK_VGROUPS}, - {"VNODES", TK_VNODES}, - {"WAL", TK_WAL}, - {"WATERMARK", TK_WATERMARK}, - {"WHERE", TK_WHERE}, - {"WINDOW_CLOSE", TK_WINDOW_CLOSE}, - {"WITH", TK_WITH}, - {"WRITE", TK_WRITE}, - {"_C0", TK_ROWTS}, - {"_QDURATION", TK_QDURATION}, - {"_QEND", TK_QEND}, - {"_QSTART", TK_QSTART}, - {"_ROWTS", TK_ROWTS}, - {"_WDURATION", TK_WDURATION}, - {"_WEND", TK_WEND}, - {"_WSTART", TK_WSTART}, - // {"ID", TK_ID}, - // {"STRING", TK_STRING}, - // {"EQ", TK_EQ}, - // {"NE", TK_NE}, - // {"ISNULL", TK_ISNULL}, - // {"NOTNULL", TK_NOTNULL}, - // {"GLOB", TK_GLOB}, - // {"GT", TK_GT}, - // {"GE", TK_GE}, - // {"LT", TK_LT}, - // {"LE", TK_LE}, - // {"BITAND", TK_BITAND}, - // {"BITOR", TK_BITOR}, - // {"LSHIFT", TK_LSHIFT}, - // {"RSHIFT", TK_RSHIFT}, - // {"PLUS", TK_PLUS}, - // {"DIVIDE", TK_DIVIDE}, - // {"TIMES", TK_TIMES}, - // {"STAR", TK_STAR}, - // {"SLASH", TK_SLASH}, - // {"REM ", TK_REM}, - // {"||", TK_CONCAT}, - // {"UMINUS", TK_UMINUS}, - // {"UPLUS", TK_UPLUS}, - // {"BITNOT", TK_BITNOT}, - // {"DOT", TK_DOT}, - // {"CTIME", TK_CTIME}, - // {"LP", TK_LP}, - // {"RP", TK_RP}, - // {"COMMA", TK_COMMA}, - // {"VARIABLE", TK_VARIABLE}, - // {"UPDATE", TK_UPDATE}, - // {"CHANGE", TK_CHANGE}, - // {"COLON", TK_COLON}, - // {"ABORT", TK_ABORT}, - // {"AFTER", TK_AFTER}, - // {"ATTACH", TK_ATTACH}, - // {"BEFORE", TK_BEFORE}, - // {"BEGIN", TK_BEGIN}, - // {"CASCADE", TK_CASCADE}, - // {"CONFLICT", TK_CONFLICT}, - // {"COPY", TK_COPY}, - // {"DEFERRED", TK_DEFERRED}, - // {"DELIMITERS", TK_DELIMITERS}, - // {"DETACH", TK_DETACH}, - // {"EACH", TK_EACH}, - // {"END", TK_END}, - // {"FAIL", TK_FAIL}, - // {"FOR", TK_FOR}, - // {"IMMEDIATE", TK_IMMEDIATE}, - // {"INITIALLY", TK_INITIALLY}, - // {"INSTEAD", TK_INSTEAD}, - // {"KEY", TK_KEY}, - // {"OF", TK_OF}, - // {"RAISE", TK_RAISE}, - // {"REPLACE", TK_REPLACE}, - // {"RESTRICT", TK_RESTRICT}, - // {"ROW", TK_ROW}, - // {"STATEMENT", TK_STATEMENT}, - // {"VIEW", TK_VIEW}, - // {"SEMI", TK_SEMI}, - // {"PARTITIONS", TK_PARTITIONS}, - // {"MODE", TK_MODE}, + {"ACCOUNT", TK_ACCOUNT}, + {"ACCOUNTS", TK_ACCOUNTS}, + {"ADD", TK_ADD}, + {"AGGREGATE", TK_AGGREGATE}, + {"ALL", TK_ALL}, + {"ALTER", TK_ALTER}, + {"ANALYZE", TK_ANALYZE}, + {"AND", TK_AND}, + {"APPS", TK_APPS}, + {"AS", TK_AS}, + {"ASC", TK_ASC}, + {"AT_ONCE", TK_AT_ONCE}, + {"BALANCE", TK_BALANCE}, + {"BETWEEN", TK_BETWEEN}, + {"BINARY", TK_BINARY}, + {"BIGINT", TK_BIGINT}, + {"BNODE", TK_BNODE}, + {"BNODES", TK_BNODES}, + {"BOOL", TK_BOOL}, + {"BUFFER", TK_BUFFER}, + {"BUFSIZE", TK_BUFSIZE}, + {"BY", TK_BY}, + {"CACHE", TK_CACHE}, + {"CACHEMODEL", TK_CACHEMODEL}, + {"CACHESIZE", TK_CACHESIZE}, + {"CAST", TK_CAST}, + {"CLIENT_VERSION", TK_CLIENT_VERSION}, + {"CLUSTER", TK_CLUSTER}, + {"COLUMN", TK_COLUMN}, + {"COMMENT", TK_COMMENT}, + {"COMP", TK_COMP}, + {"CONNS", TK_CONNS}, + {"CONNECTION", TK_CONNECTION}, + {"CONNECTIONS", TK_CONNECTIONS}, + {"CONSUMER", TK_CONSUMER}, + {"CONSUMERS", TK_CONSUMERS}, + {"CONTAINS", TK_CONTAINS}, + {"COUNT", TK_COUNT}, + {"CREATE", TK_CREATE}, + {"CURRENT_USER", TK_CURRENT_USER}, + {"DATABASE", TK_DATABASE}, + {"DATABASES", TK_DATABASES}, + {"DBS", TK_DBS}, + {"DELETE", TK_DELETE}, + {"DESC", TK_DESC}, + {"DESCRIBE", TK_DESCRIBE}, + {"DISTINCT", TK_DISTINCT}, + {"DISTRIBUTED", TK_DISTRIBUTED}, + {"DNODE", TK_DNODE}, + {"DNODES", TK_DNODES}, + {"DOUBLE", TK_DOUBLE}, + {"DROP", TK_DROP}, + {"DURATION", TK_DURATION}, + {"ENABLE", TK_ENABLE}, + {"EXISTS", TK_EXISTS}, + {"EXPIRED", TK_EXPIRED}, + {"EXPLAIN", TK_EXPLAIN}, + {"EVERY", TK_EVERY}, + {"FILE", TK_FILE}, + {"FILL", TK_FILL}, + {"FIRST", TK_FIRST}, + {"FLOAT", TK_FLOAT}, + {"FLUSH", TK_FLUSH}, + {"FROM", TK_FROM}, + {"FUNCTION", TK_FUNCTION}, + {"FUNCTIONS", TK_FUNCTIONS}, + {"GRANT", TK_GRANT}, + {"GRANTS", TK_GRANTS}, + {"GROUP", TK_GROUP}, + {"HAVING", TK_HAVING}, + {"IF", TK_IF}, + {"IGNORE", TK_IGNORE}, + {"IMPORT", TK_IMPORT}, + {"IN", TK_IN}, + {"INDEX", TK_INDEX}, + {"INDEXES", TK_INDEXES}, + {"INNER", TK_INNER}, + {"INT", TK_INT}, + {"INSERT", TK_INSERT}, + {"INTEGER", TK_INTEGER}, + {"INTERVAL", TK_INTERVAL}, + {"INTO", TK_INTO}, + {"IS", TK_IS}, + {"JOIN", TK_JOIN}, + {"JSON", TK_JSON}, + {"KEEP", TK_KEEP}, + {"KILL", TK_KILL}, + {"LAST", TK_LAST}, + {"LAST_ROW", TK_LAST_ROW}, + {"LICENCE", TK_LICENCE}, + {"LIKE", TK_LIKE}, + {"LIMIT", TK_LIMIT}, + {"LINEAR", TK_LINEAR}, + {"LOCAL", TK_LOCAL}, + {"MATCH", TK_MATCH}, + {"MAXROWS", TK_MAXROWS}, + {"MAX_DELAY", TK_MAX_DELAY}, + {"MERGE", TK_MERGE}, + {"META", TK_META}, + {"MINROWS", TK_MINROWS}, + {"MINUS", TK_MINUS}, + {"MNODE", TK_MNODE}, + {"MNODES", TK_MNODES}, + {"MODIFY", TK_MODIFY}, + {"MODULES", TK_MODULES}, + {"NCHAR", TK_NCHAR}, + {"NEXT", TK_NEXT}, + {"NMATCH", TK_NMATCH}, + {"NONE", TK_NONE}, + {"NOT", TK_NOT}, + {"NOW", TK_NOW}, + {"NULL", TK_NULL}, + {"NULLS", TK_NULLS}, + {"OFFSET", TK_OFFSET}, + {"ON", TK_ON}, + {"OR", TK_OR}, + {"ORDER", TK_ORDER}, + {"OUTPUTTYPE", TK_OUTPUTTYPE}, + {"PARTITION", TK_PARTITION}, + {"PASS", TK_PASS}, + {"PAGES", TK_PAGES}, + {"PAGESIZE", TK_PAGESIZE}, + {"PORT", TK_PORT}, + {"PPS", TK_PPS}, + {"PRECISION", TK_PRECISION}, + {"PREV", TK_PREV}, + {"QNODE", TK_QNODE}, + {"QNODES", TK_QNODES}, + {"QTIME", TK_QTIME}, + {"QUERIES", TK_QUERIES}, + {"QUERY", TK_QUERY}, + {"RANGE", TK_RANGE}, + {"RATIO", TK_RATIO}, + {"READ", TK_READ}, + {"REDISTRIBUTE", TK_REDISTRIBUTE}, + {"RENAME", TK_RENAME}, + {"REPLICA", TK_REPLICA}, + {"RESET", TK_RESET}, + {"RETENTIONS", TK_RETENTIONS}, + {"REVOKE", TK_REVOKE}, + {"ROLLUP", TK_ROLLUP}, + {"SCHEMALESS", TK_SCHEMALESS}, + {"SCORES", TK_SCORES}, + {"SELECT", TK_SELECT}, + {"SERVER_STATUS", TK_SERVER_STATUS}, + {"SERVER_VERSION", TK_SERVER_VERSION}, + {"SESSION", TK_SESSION}, + {"SET", TK_SET}, + {"SHOW", TK_SHOW}, + {"SINGLE_STABLE", TK_SINGLE_STABLE}, + {"SLIDING", TK_SLIDING}, + {"SLIMIT", TK_SLIMIT}, + {"SMA", TK_SMA}, + {"SMALLINT", TK_SMALLINT}, + {"SNODE", TK_SNODE}, + {"SNODES", TK_SNODES}, + {"SOFFSET", TK_SOFFSET}, + {"SPLIT", TK_SPLIT}, + {"STABLE", TK_STABLE}, + {"STABLES", TK_STABLES}, + {"STATE", TK_STATE}, + {"STATE_WINDOW", TK_STATE_WINDOW}, + {"STORAGE", TK_STORAGE}, + {"STREAM", TK_STREAM}, + {"STREAMS", TK_STREAMS}, + {"STRICT", TK_STRICT}, + {"SUBSCRIPTIONS", TK_SUBSCRIPTIONS}, + {"SYSINFO", TK_SYSINFO}, + {"TABLE", TK_TABLE}, + {"TABLES", TK_TABLES}, + {"TAG", TK_TAG}, + {"TAGS", TK_TAGS}, + {"TBNAME", TK_TBNAME}, + {"TIMESTAMP", TK_TIMESTAMP}, + {"TIMEZONE", TK_TIMEZONE}, + {"TINYINT", TK_TINYINT}, + {"TO", TK_TO}, + {"TODAY", TK_TODAY}, + {"TOPIC", TK_TOPIC}, + {"TOPICS", TK_TOPICS}, + {"TRANSACTION", TK_TRANSACTION}, + {"TRANSACTIONS", TK_TRANSACTIONS}, + {"TRIGGER", TK_TRIGGER}, + {"TRIM", TK_TRIM}, + {"TSERIES", TK_TSERIES}, + {"TTL", TK_TTL}, + {"UNION", TK_UNION}, + {"UNSIGNED", TK_UNSIGNED}, + {"USE", TK_USE}, + {"USER", TK_USER}, + {"USERS", TK_USERS}, + {"USING", TK_USING}, + {"VALUE", TK_VALUE}, + {"VALUES", TK_VALUES}, + {"VARCHAR", TK_VARCHAR}, + {"VARIABLES", TK_VARIABLES}, + {"VERBOSE", TK_VERBOSE}, + {"VGROUP", TK_VGROUP}, + {"VGROUPS", TK_VGROUPS}, + {"WAL_FSYNC_PERIOD", TK_WAL_FSYNC_PERIOD}, + {"WAL_LEVEL", TK_WAL_LEVEL}, + {"WAL_RETENTION_PERIOD", TK_WAL_RETENTION_PERIOD}, + {"WAL_RETENTION_SIZE", TK_WAL_RETENTION_SIZE}, + {"WAL_ROLL_PERIOD", TK_WAL_ROLL_PERIOD}, + {"WAL_SEGMENT_SIZE", TK_WAL_SEGMENT_SIZE}, + {"WATERMARK", TK_WATERMARK}, + {"WHERE", TK_WHERE}, + {"WINDOW_CLOSE", TK_WINDOW_CLOSE}, + {"WITH", TK_WITH}, + {"WRITE", TK_WRITE}, + {"_C0", TK_ROWTS}, + {"_QDURATION", TK_QDURATION}, + {"_QEND", TK_QEND}, + {"_QSTART", TK_QSTART}, + {"_ROWTS", TK_ROWTS}, + {"_WDURATION", TK_WDURATION}, + {"_WEND", TK_WEND}, + {"_WSTART", TK_WSTART}, }; // clang-format on diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 3930e46054edca7a13ca74c3499053d669239295..5cba920a43c6a59af14c1e85ccfdb4300980ebac 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -39,6 +39,7 @@ typedef struct STranslateContext { SCmdMsgInfo* pCmdMsg; SHashObj* pDbs; SHashObj* pTables; + SHashObj* pTargetTables; SExplainOptions* pExplainOpt; SParseMetaCache* pMetaCache; bool createStream; @@ -89,10 +90,10 @@ static int32_t collectUseDatabase(const SName* pName, SHashObj* pDbs) { return collectUseDatabaseImpl(dbFName, pDbs); } -static int32_t collectUseTable(const SName* pName, SHashObj* pDbs) { +static int32_t collectUseTable(const SName* pName, SHashObj* pTable) { char fullName[TSDB_TABLE_FNAME_LEN]; tNameExtractFullName(pName, fullName); - return taosHashPut(pDbs, fullName, strlen(fullName), pName, sizeof(SName)); + return taosHashPut(pTable, fullName, strlen(fullName), pName, sizeof(SName)); } static int32_t getTableMetaImpl(STranslateContext* pCxt, const SName* pName, STableMeta** pMeta) { @@ -357,7 +358,8 @@ static int32_t initTranslateContext(SParseContext* pParseCxt, SParseMetaCache* p pCxt->pMetaCache = pMetaCache; pCxt->pDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); pCxt->pTables = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); - if (NULL == pCxt->pNsLevel || NULL == pCxt->pDbs || NULL == pCxt->pTables) { + pCxt->pTargetTables = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + if (NULL == pCxt->pNsLevel || NULL == pCxt->pDbs || NULL == pCxt->pTables || NULL == pCxt->pTargetTables) { return TSDB_CODE_OUT_OF_MEMORY; } return TSDB_CODE_SUCCESS; @@ -2975,7 +2977,7 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS pReq->daysToKeep2 = pStmt->pOptions->keep[2]; pReq->minRows = pStmt->pOptions->minRowsPerBlock; pReq->maxRows = pStmt->pOptions->maxRowsPerBlock; - pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod; + pReq->walFsyncPeriod = pStmt->pOptions->fsyncPeriod; pReq->walLevel = pStmt->pOptions->walLevel; pReq->precision = pStmt->pOptions->precision; pReq->compression = pStmt->pOptions->compressionLevel; @@ -2984,6 +2986,10 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS pReq->cacheLast = pStmt->pOptions->cacheModel; pReq->cacheLastSize = pStmt->pOptions->cacheLastSize; pReq->schemaless = pStmt->pOptions->schemaless; + pReq->walRetentionPeriod = pStmt->pOptions->walRetentionPeriod; + pReq->walRetentionSize = pStmt->pOptions->walRetentionSize; + pReq->walRollPeriod = pStmt->pOptions->walRollPeriod; + pReq->walSegmentSize = pStmt->pOptions->walSegmentSize; pReq->ignoreExist = pStmt->ignoreExists; return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq); } @@ -3184,7 +3190,8 @@ static int32_t checkOptionsDependency(STranslateContext* pCxt, const char* pDbNa daysToKeep0 = (-1 == daysToKeep0 ? dbCfg.daysToKeep0 : daysToKeep0); } if (daysPerFile > daysToKeep0) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DAYS_VALUE); + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, + "Invalid duration value, should be keep2 >= keep1 >= keep0 >= duration"); } return TSDB_CODE_SUCCESS; } @@ -3252,6 +3259,21 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName if (TSDB_CODE_SUCCESS == code) { code = checkDbEnumOption(pCxt, "schemaless", pOptions->schemaless, TSDB_DB_SCHEMALESS_ON, TSDB_DB_SCHEMALESS_OFF); } + if (TSDB_CODE_SUCCESS == code) { + code = checkDbRangeOption(pCxt, "walRetentionPeriod", pOptions->walRetentionPeriod, + TSDB_DB_MIN_WAL_RETENTION_PERIOD, INT32_MAX); + } + if (TSDB_CODE_SUCCESS == code) { + code = checkDbRangeOption(pCxt, "walRetentionSize", pOptions->walRetentionSize, TSDB_DB_MIN_WAL_RETENTION_SIZE, + INT32_MAX); + } + if (TSDB_CODE_SUCCESS == code) { + code = checkDbRangeOption(pCxt, "walRollPeriod", pOptions->walRollPeriod, TSDB_DB_MIN_WAL_ROLL_PERIOD, INT32_MAX); + } + if (TSDB_CODE_SUCCESS == code) { + code = + checkDbRangeOption(pCxt, "walSegmentSize", pOptions->walSegmentSize, TSDB_DB_MIN_WAL_SEGMENT_SIZE, INT32_MAX); + } if (TSDB_CODE_SUCCESS == code) { code = checkOptionsDependency(pCxt, pDbName, pOptions); } @@ -3315,7 +3337,7 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt, pReq->daysToKeep0 = pStmt->pOptions->keep[0]; pReq->daysToKeep1 = pStmt->pOptions->keep[1]; pReq->daysToKeep2 = pStmt->pOptions->keep[2]; - pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod; + pReq->walFsyncPeriod = pStmt->pOptions->fsyncPeriod; pReq->walLevel = pStmt->pOptions->walLevel; pReq->strict = pStmt->pOptions->strict; pReq->cacheLast = pStmt->pOptions->cacheModel; @@ -3914,6 +3936,9 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm SName tableName; tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), pReq->name); int32_t code = collectUseTable(&tableName, pCxt->pTables); + if (TSDB_CODE_SUCCESS == code) { + code = collectUseTable(&tableName, pCxt->pTargetTables); + } if (TSDB_CODE_SUCCESS == code) { code = buildRollupAst(pCxt, pStmt, pReq); } @@ -3934,11 +3959,14 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt } static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* pTableName, bool ignoreNotExists) { - SMDropStbReq dropReq = {0}; - tNameExtractFullName(pTableName, dropReq.name); - dropReq.igNotExists = ignoreNotExists; - - return buildCmdMsg(pCxt, TDMT_MND_DROP_STB, (FSerializeFunc)tSerializeSMDropStbReq, &dropReq); + int32_t code = collectUseTable(pTableName, pCxt->pTargetTables); + if (TSDB_CODE_SUCCESS == code) { + SMDropStbReq dropReq = {0}; + tNameExtractFullName(pTableName, dropReq.name); + dropReq.igNotExists = ignoreNotExists; + code = buildCmdMsg(pCxt, TDMT_MND_DROP_STB, (FSerializeFunc)tSerializeSMDropStbReq, &dropReq); + } + return code; } static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt) { @@ -5540,8 +5568,13 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) { int32_t code = checkCreateTable(pCxt, pStmt, false); SVgroupInfo info = {0}; + SName name; + toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name); if (TSDB_CODE_SUCCESS == code) { - code = getTableHashVgroup(pCxt, pStmt->dbName, pStmt->tableName, &info); + code = getTableHashVgroupImpl(pCxt, &name, &info); + } + if (TSDB_CODE_SUCCESS == code) { + code = collectUseTable(&name, pCxt->pTargetTables); } SArray* pBufArray = NULL; if (TSDB_CODE_SUCCESS == code) { @@ -5810,6 +5843,11 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla if (TSDB_CODE_SUCCESS == code) { code = getTableMeta(pCxt, pStmt->useDbName, pStmt->useTableName, &pSuperTableMeta); } + if (TSDB_CODE_SUCCESS == code) { + SName name; + toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name); + code = collectUseTable(&name, pCxt->pTargetTables); + } STag* pTag = NULL; SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN); @@ -5908,8 +5946,13 @@ static void addDropTbReqIntoVgroup(SHashObj* pVgroupHashmap, SDropTableClause* p static int32_t buildDropTableVgroupHashmap(STranslateContext* pCxt, SDropTableClause* pClause, bool* pIsSuperTable, SHashObj* pVgroupHashmap) { + SName name; + toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &name); STableMeta* pTableMeta = NULL; - int32_t code = getTableMeta(pCxt, pClause->dbName, pClause->tableName, &pTableMeta); + int32_t code = getTableMetaImpl(pCxt, &name, &pTableMeta); + if (TSDB_CODE_SUCCESS == code) { + code = collectUseTable(&name, pCxt->pTargetTables); + } if (TSDB_CODE_SUCCESS == code && TSDB_SUPER_TABLE == pTableMeta->tableType) { *pIsSuperTable = true; @@ -6490,6 +6533,20 @@ static int32_t setRefreshMate(STranslateContext* pCxt, SQuery* pQuery) { pTable = taosHashIterate(pCxt->pTables, pTable); } } + + if (NULL != pCxt->pTargetTables) { + taosArrayDestroy(pQuery->pTargetTableList); + pQuery->pTargetTableList = taosArrayInit(taosHashGetSize(pCxt->pTargetTables), sizeof(SName)); + if (NULL == pQuery->pTargetTableList) { + return TSDB_CODE_OUT_OF_MEMORY; + } + SName* pTable = taosHashIterate(pCxt->pTargetTables, NULL); + while (NULL != pTable) { + taosArrayPush(pQuery->pTargetTableList, pTable); + pTable = taosHashIterate(pCxt->pTargetTables, pTable); + } + } + return TSDB_CODE_SUCCESS; } diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 7c9a8b10dd206d047154b5e1df5d02d119c814c6..79d6f3b8e86572ead7283b81545d3869c7c26363 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -99,8 +99,6 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "Query block has incorrect number of result columns"; case TSDB_CODE_PAR_INCORRECT_TIMESTAMP_VAL: return "Incorrect TIMESTAMP value: %s"; - case TSDB_CODE_PAR_INVALID_DAYS_VALUE: - return "Invalid days value, should be keep2 >= keep1 >= keep0 >= days"; case TSDB_CODE_PAR_OFFSET_LESS_ZERO: return "soffset/offset can not be less than 0"; case TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_BY: diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 6b4c6704f61ca0740fc2444c6486ff150c961c9f..af5a51a903c61bf481404a16fe57b1d5a929fd93 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 379 +#define YYNOCODE 380 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EOrder yy58; - bool yy151; - int8_t yy285; - SNodeList* yy356; - SToken yy361; - SAlterOption yy409; - int64_t yy457; - EFillMode yy494; - EJoinType yy504; - EOperatorType yy526; - SDataType yy600; - ENullOrder yy613; - SNode* yy616; - int32_t yy734; + EOperatorType yy60; + EFillMode yy94; + SToken yy129; + SDataType yy184; + bool yy337; + ENullOrder yy338; + SAlterOption yy405; + SNodeList* yy464; + int32_t yy500; + EJoinType yy532; + int8_t yy543; + int64_t yy549; + EOrder yy658; + SNode* yy712; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -139,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 669 -#define YYNRULE 488 -#define YYNTOKEN 256 -#define YY_MAX_SHIFT 668 -#define YY_MIN_SHIFTREDUCE 970 -#define YY_MAX_SHIFTREDUCE 1457 -#define YY_ERROR_ACTION 1458 -#define YY_ACCEPT_ACTION 1459 -#define YY_NO_ACTION 1460 -#define YY_MIN_REDUCE 1461 -#define YY_MAX_REDUCE 1948 +#define YYNSTATE 666 +#define YYNRULE 492 +#define YYNTOKEN 257 +#define YY_MAX_SHIFT 665 +#define YY_MIN_SHIFTREDUCE 973 +#define YY_MAX_SHIFTREDUCE 1464 +#define YY_ERROR_ACTION 1465 +#define YY_ACCEPT_ACTION 1466 +#define YY_NO_ACTION 1467 +#define YY_MIN_REDUCE 1468 +#define YY_MAX_REDUCE 1959 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,682 +216,664 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2481) +#define YY_ACTTAB_COUNT (2395) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 532, 73, 1459, 440, 555, 441, 1496, 329, 520, 73, - /* 10 */ 1647, 114, 39, 37, 119, 143, 328, 314, 478, 1693, - /* 20 */ 342, 1462, 1257, 1590, 1597, 147, 1645, 555, 1595, 1555, - /* 30 */ 1800, 1591, 124, 1334, 448, 1255, 441, 1496, 548, 558, - /* 40 */ 347, 391, 104, 1640, 1642, 103, 102, 101, 100, 99, - /* 50 */ 98, 97, 96, 95, 439, 124, 1329, 443, 1782, 33, - /* 60 */ 32, 14, 355, 40, 38, 36, 35, 34, 1263, 39, - /* 70 */ 37, 1397, 122, 1283, 1282, 564, 547, 342, 305, 1257, - /* 80 */ 1926, 426, 145, 1926, 1473, 1, 1800, 159, 1868, 1869, - /* 90 */ 1334, 1873, 1255, 163, 584, 122, 1925, 1923, 558, 1751, - /* 100 */ 1923, 583, 64, 1926, 42, 63, 1020, 665, 1019, 557, - /* 110 */ 158, 1868, 1869, 1329, 1873, 560, 162, 81, 14, 1003, - /* 120 */ 1923, 1336, 1337, 30, 263, 1263, 1814, 177, 176, 223, - /* 130 */ 91, 1783, 586, 1785, 1786, 582, 1021, 577, 1588, 63, - /* 140 */ 1860, 1484, 2, 104, 308, 1856, 103, 102, 101, 100, - /* 150 */ 99, 98, 97, 96, 95, 1526, 1926, 489, 488, 1007, - /* 160 */ 1008, 143, 487, 43, 665, 120, 1258, 197, 1256, 164, - /* 170 */ 1598, 484, 1358, 1923, 1152, 1153, 385, 447, 1336, 1337, - /* 180 */ 443, 149, 1751, 63, 1641, 1642, 474, 470, 466, 462, - /* 190 */ 196, 1236, 1237, 1261, 1262, 1363, 1311, 1312, 1314, 1315, - /* 200 */ 1316, 1317, 1318, 1319, 579, 575, 1327, 1328, 1330, 1331, - /* 210 */ 1332, 1333, 1335, 1338, 1020, 1647, 1019, 1926, 74, 489, - /* 220 */ 488, 194, 330, 1258, 487, 1256, 165, 120, 558, 476, - /* 230 */ 162, 1645, 63, 484, 1923, 33, 32, 519, 27, 40, - /* 240 */ 38, 36, 35, 34, 1021, 165, 165, 1692, 555, 302, - /* 250 */ 1261, 1262, 376, 1311, 1312, 1314, 1315, 1316, 1317, 1318, - /* 260 */ 1319, 579, 575, 1327, 1328, 1330, 1331, 1332, 1333, 1335, - /* 270 */ 1338, 39, 37, 1461, 378, 374, 124, 565, 1926, 342, - /* 280 */ 165, 1257, 1782, 193, 186, 1686, 191, 1875, 309, 49, - /* 290 */ 453, 162, 1334, 503, 1255, 1923, 172, 113, 112, 111, - /* 300 */ 110, 109, 108, 107, 106, 105, 501, 1483, 499, 184, - /* 310 */ 1800, 1872, 384, 1296, 383, 1329, 122, 1573, 559, 532, - /* 320 */ 14, 1356, 1482, 1751, 165, 583, 457, 1263, 39, 37, - /* 330 */ 114, 160, 1868, 1869, 532, 1873, 342, 483, 1257, 1523, - /* 340 */ 319, 11, 10, 1418, 2, 55, 445, 1595, 1751, 1334, - /* 350 */ 1814, 1255, 1280, 1394, 92, 1783, 586, 1785, 1786, 582, - /* 360 */ 1737, 577, 1595, 1751, 1860, 1401, 665, 532, 333, 1856, - /* 370 */ 157, 1282, 1329, 165, 1283, 1357, 1647, 457, 167, 1571, - /* 380 */ 1336, 1337, 161, 346, 1263, 541, 1416, 1417, 1419, 1420, - /* 390 */ 1886, 320, 1645, 318, 317, 1595, 480, 1282, 1362, 1481, - /* 400 */ 482, 8, 642, 641, 640, 639, 350, 364, 638, 637, - /* 410 */ 636, 125, 631, 630, 629, 628, 627, 626, 625, 624, - /* 420 */ 136, 620, 481, 665, 1284, 1258, 1370, 1256, 33, 32, - /* 430 */ 165, 549, 40, 38, 36, 35, 34, 1336, 1337, 619, - /* 440 */ 1751, 29, 340, 1351, 1352, 1353, 1354, 1355, 1359, 1360, - /* 450 */ 1361, 1480, 1261, 1262, 1479, 1311, 1312, 1314, 1315, 1316, - /* 460 */ 1317, 1318, 1319, 579, 575, 1327, 1328, 1330, 1331, 1332, - /* 470 */ 1333, 1335, 1338, 33, 32, 218, 619, 40, 38, 36, - /* 480 */ 35, 34, 1258, 482, 1256, 40, 38, 36, 35, 34, - /* 490 */ 1257, 1686, 1751, 33, 32, 1751, 1769, 40, 38, 36, - /* 500 */ 35, 34, 175, 1255, 63, 481, 77, 1765, 22, 1261, - /* 510 */ 1262, 1285, 1311, 1312, 1314, 1315, 1316, 1317, 1318, 1319, - /* 520 */ 579, 575, 1327, 1328, 1330, 1331, 1332, 1333, 1335, 1338, - /* 530 */ 39, 37, 1339, 1761, 1767, 331, 1263, 156, 342, 345, - /* 540 */ 1257, 1782, 165, 1586, 532, 577, 309, 143, 1313, 88, - /* 550 */ 1634, 1334, 1769, 1255, 1765, 389, 1597, 255, 224, 225, - /* 560 */ 33, 32, 121, 1765, 40, 38, 36, 35, 34, 1800, - /* 570 */ 1587, 173, 1595, 1072, 1329, 665, 1393, 559, 1454, 1356, - /* 580 */ 1761, 1767, 1751, 494, 583, 520, 1263, 39, 37, 1761, - /* 590 */ 1767, 337, 577, 532, 1926, 342, 1694, 1257, 504, 71, - /* 600 */ 544, 577, 70, 9, 390, 1478, 1074, 163, 1334, 1814, - /* 610 */ 1255, 1923, 210, 92, 1783, 586, 1785, 1786, 582, 307, - /* 620 */ 577, 1595, 522, 1860, 1477, 665, 497, 333, 1856, 157, - /* 630 */ 491, 1329, 1281, 1357, 1258, 209, 1256, 353, 1428, 1336, - /* 640 */ 1337, 26, 1476, 1263, 235, 165, 1751, 33, 32, 1887, - /* 650 */ 211, 40, 38, 36, 35, 34, 1362, 1691, 1344, 302, - /* 660 */ 9, 1261, 1262, 58, 1282, 1751, 57, 7, 1453, 33, - /* 670 */ 32, 348, 1926, 40, 38, 36, 35, 34, 1926, 143, - /* 680 */ 550, 545, 665, 1751, 1258, 1924, 1256, 615, 1597, 1923, - /* 690 */ 1638, 162, 36, 35, 34, 1923, 1336, 1337, 1502, 29, - /* 700 */ 340, 1351, 1352, 1353, 1354, 1355, 1359, 1360, 1361, 75, - /* 710 */ 307, 1261, 1262, 522, 1311, 1312, 1314, 1315, 1316, 1317, - /* 720 */ 1318, 1319, 579, 575, 1327, 1328, 1330, 1331, 1332, 1333, - /* 730 */ 1335, 1338, 33, 32, 486, 485, 40, 38, 36, 35, - /* 740 */ 34, 1258, 1875, 1256, 635, 633, 660, 1408, 1110, 608, - /* 750 */ 607, 606, 1114, 605, 1116, 1117, 604, 1119, 601, 61, - /* 760 */ 1125, 598, 1127, 1128, 595, 592, 1871, 352, 1261, 1262, - /* 770 */ 1475, 1311, 1312, 1314, 1315, 1316, 1317, 1318, 1319, 579, - /* 780 */ 575, 1327, 1328, 1330, 1331, 1332, 1333, 1335, 1338, 39, - /* 790 */ 37, 304, 1282, 1280, 617, 668, 505, 342, 1472, 1257, - /* 800 */ 419, 616, 1471, 431, 1638, 1470, 1782, 532, 1926, 270, - /* 810 */ 1334, 1751, 1255, 134, 133, 614, 613, 612, 349, 1696, - /* 820 */ 404, 162, 432, 154, 406, 1923, 1469, 532, 658, 654, - /* 830 */ 650, 646, 268, 1329, 1800, 1595, 1647, 1926, 396, 1751, - /* 840 */ 532, 1313, 584, 1751, 611, 1263, 1751, 1751, 532, 583, - /* 850 */ 162, 411, 1646, 1390, 1923, 1595, 1584, 397, 1047, 412, - /* 860 */ 89, 532, 2, 233, 623, 1263, 1567, 1751, 1595, 393, - /* 870 */ 275, 1875, 456, 1625, 1814, 132, 1595, 142, 93, 1783, - /* 880 */ 586, 1785, 1786, 582, 665, 577, 1007, 1008, 1860, 1595, - /* 890 */ 1468, 1048, 1859, 1856, 1572, 1870, 529, 430, 1336, 1337, - /* 900 */ 425, 424, 423, 422, 421, 418, 417, 416, 415, 414, - /* 910 */ 410, 409, 408, 407, 401, 400, 399, 398, 54, 395, - /* 920 */ 394, 1467, 1466, 28, 1880, 1390, 622, 144, 220, 33, - /* 930 */ 32, 1751, 281, 40, 38, 36, 35, 34, 1570, 44, - /* 940 */ 4, 53, 516, 1258, 532, 1256, 279, 60, 1580, 1228, - /* 950 */ 59, 213, 33, 32, 1465, 1592, 40, 38, 36, 35, - /* 960 */ 34, 1464, 1751, 1751, 1582, 1782, 180, 436, 434, 1313, - /* 970 */ 1261, 1262, 1595, 1311, 1312, 1314, 1315, 1316, 1317, 1318, - /* 980 */ 1319, 579, 575, 1327, 1328, 1330, 1331, 1332, 1333, 1335, - /* 990 */ 1338, 617, 532, 1800, 63, 1751, 532, 1513, 532, 562, - /* 1000 */ 634, 584, 1751, 1725, 1266, 41, 1751, 513, 583, 517, - /* 1010 */ 134, 133, 614, 613, 612, 202, 222, 532, 200, 490, - /* 1020 */ 1595, 1265, 560, 128, 1595, 532, 1595, 1508, 530, 1578, - /* 1030 */ 1296, 573, 90, 1814, 217, 617, 531, 91, 1783, 586, - /* 1040 */ 1785, 1786, 582, 379, 577, 1595, 1782, 1860, 1204, 492, - /* 1050 */ 214, 308, 1856, 1595, 134, 133, 614, 613, 612, 226, - /* 1060 */ 339, 338, 532, 1926, 131, 76, 525, 68, 67, 388, - /* 1070 */ 1271, 1506, 171, 264, 1800, 1770, 162, 555, 382, 567, - /* 1080 */ 1923, 1334, 584, 1264, 132, 204, 1765, 1751, 203, 583, - /* 1090 */ 1595, 303, 206, 495, 372, 205, 370, 366, 362, 168, - /* 1100 */ 357, 354, 1772, 208, 1329, 124, 207, 232, 51, 239, - /* 1110 */ 11, 10, 1761, 1767, 1814, 51, 1263, 578, 92, 1783, - /* 1120 */ 586, 1785, 1786, 582, 577, 577, 560, 1103, 1860, 1782, - /* 1130 */ 1456, 1457, 333, 1856, 1939, 165, 41, 1269, 41, 590, - /* 1140 */ 131, 1774, 132, 1894, 116, 122, 131, 610, 512, 87, - /* 1150 */ 1474, 1415, 242, 1556, 1268, 572, 258, 1800, 1364, 84, - /* 1160 */ 253, 1868, 554, 1348, 553, 584, 542, 1926, 475, 506, - /* 1170 */ 1751, 247, 583, 1801, 351, 1635, 1497, 1890, 252, 1320, - /* 1180 */ 164, 274, 1131, 1135, 1923, 1142, 560, 1140, 556, 135, - /* 1190 */ 356, 257, 1782, 260, 3, 262, 5, 1814, 1280, 359, - /* 1200 */ 363, 288, 1783, 586, 1785, 1786, 582, 315, 577, 1072, - /* 1210 */ 316, 1220, 174, 271, 1272, 392, 1267, 413, 1688, 420, - /* 1220 */ 1800, 428, 427, 429, 1286, 433, 435, 1926, 584, 1289, - /* 1230 */ 437, 183, 438, 1751, 1782, 583, 449, 446, 450, 1288, - /* 1240 */ 164, 1275, 1277, 185, 1923, 451, 1290, 1287, 452, 454, - /* 1250 */ 188, 455, 190, 575, 1327, 1328, 1330, 1331, 1332, 1333, - /* 1260 */ 1814, 192, 1800, 72, 92, 1783, 586, 1785, 1786, 582, - /* 1270 */ 584, 577, 458, 195, 1860, 1751, 477, 583, 333, 1856, - /* 1280 */ 1939, 479, 1585, 568, 115, 199, 1581, 201, 137, 1917, - /* 1290 */ 306, 138, 212, 1583, 1579, 139, 272, 1782, 140, 507, - /* 1300 */ 215, 514, 1814, 508, 518, 526, 92, 1783, 586, 1785, - /* 1310 */ 1786, 582, 1730, 577, 219, 511, 1860, 540, 521, 527, - /* 1320 */ 333, 1856, 1939, 230, 1729, 1800, 1698, 129, 523, 273, - /* 1330 */ 327, 1879, 80, 584, 325, 228, 130, 1596, 1751, 1285, - /* 1340 */ 583, 528, 543, 536, 6, 552, 1901, 1782, 1900, 538, - /* 1350 */ 1891, 539, 332, 546, 560, 237, 537, 1882, 246, 535, - /* 1360 */ 534, 241, 1390, 123, 1782, 1814, 1284, 569, 566, 288, - /* 1370 */ 1783, 586, 1785, 1786, 582, 1800, 577, 334, 48, 82, - /* 1380 */ 251, 588, 1639, 584, 1568, 151, 1876, 276, 1751, 661, - /* 1390 */ 583, 267, 1800, 664, 248, 1926, 249, 662, 52, 250, - /* 1400 */ 581, 150, 280, 1841, 289, 1751, 278, 583, 162, 1745, - /* 1410 */ 299, 298, 1923, 1744, 65, 1814, 1743, 1742, 66, 93, - /* 1420 */ 1783, 586, 1785, 1786, 582, 1782, 577, 1741, 358, 1860, - /* 1430 */ 1738, 1922, 1814, 571, 1856, 563, 296, 1783, 586, 1785, - /* 1440 */ 1786, 582, 580, 577, 574, 1832, 1782, 256, 1942, 259, - /* 1450 */ 360, 570, 261, 1800, 1248, 361, 1249, 169, 365, 1736, - /* 1460 */ 367, 584, 369, 368, 1735, 371, 1751, 1734, 583, 373, - /* 1470 */ 1733, 375, 1732, 1715, 1800, 377, 170, 380, 381, 1223, - /* 1480 */ 1222, 1709, 584, 1708, 386, 387, 1707, 1751, 1192, 583, - /* 1490 */ 1706, 1681, 126, 1814, 1680, 1679, 1678, 146, 1783, 586, - /* 1500 */ 1785, 1786, 582, 69, 577, 1677, 1676, 1675, 1674, 1673, - /* 1510 */ 402, 403, 1672, 405, 1814, 1782, 1671, 1670, 93, 1783, - /* 1520 */ 586, 1785, 1786, 582, 1669, 577, 1668, 1782, 1860, 1667, - /* 1530 */ 1666, 1665, 1664, 1857, 1663, 1662, 1661, 1782, 178, 127, - /* 1540 */ 1657, 561, 1940, 1800, 1660, 1659, 1658, 1656, 326, 1655, - /* 1550 */ 1654, 584, 181, 117, 179, 1800, 1751, 1653, 583, 1652, - /* 1560 */ 533, 1651, 1650, 584, 1194, 1800, 1649, 1648, 1751, 1528, - /* 1570 */ 583, 1527, 1525, 584, 1493, 1492, 155, 1010, 1751, 1009, - /* 1580 */ 583, 182, 118, 1814, 1723, 442, 1717, 297, 1783, 586, - /* 1590 */ 1785, 1786, 582, 1782, 577, 1814, 1705, 444, 189, 297, - /* 1600 */ 1783, 586, 1785, 1786, 582, 1814, 577, 1782, 1704, 292, - /* 1610 */ 1783, 586, 1785, 1786, 582, 187, 577, 1690, 1574, 1524, - /* 1620 */ 1040, 1800, 1522, 459, 460, 1520, 461, 463, 464, 584, - /* 1630 */ 465, 1518, 467, 1516, 1751, 1800, 583, 468, 469, 473, - /* 1640 */ 471, 1505, 472, 581, 1504, 1489, 1576, 551, 1751, 50, - /* 1650 */ 583, 1146, 198, 1575, 1145, 1071, 632, 634, 1068, 1067, - /* 1660 */ 1066, 1814, 1514, 1509, 321, 146, 1783, 586, 1785, 1786, - /* 1670 */ 582, 322, 577, 1507, 323, 1814, 493, 1488, 496, 296, - /* 1680 */ 1783, 586, 1785, 1786, 582, 1782, 577, 1487, 1833, 498, - /* 1690 */ 500, 1486, 502, 1722, 94, 1230, 1716, 1782, 509, 141, - /* 1700 */ 1703, 56, 1701, 1702, 216, 1700, 510, 1699, 1697, 324, - /* 1710 */ 1941, 15, 1689, 1800, 221, 227, 84, 229, 341, 515, - /* 1720 */ 78, 584, 79, 41, 524, 1800, 1751, 231, 583, 234, - /* 1730 */ 343, 16, 23, 584, 1430, 236, 245, 238, 1751, 45, - /* 1740 */ 583, 1772, 1412, 240, 47, 1414, 148, 1782, 17, 1240, - /* 1750 */ 243, 24, 244, 1814, 1407, 1387, 83, 297, 1783, 586, - /* 1760 */ 1785, 1786, 582, 25, 577, 1814, 46, 1386, 254, 297, - /* 1770 */ 1783, 586, 1785, 1786, 582, 1800, 577, 1771, 152, 18, - /* 1780 */ 1447, 1442, 1441, 584, 335, 1436, 1446, 1445, 1751, 336, - /* 1790 */ 583, 10, 1273, 19, 1349, 1817, 576, 1782, 1304, 1324, - /* 1800 */ 13, 1322, 31, 153, 1321, 166, 12, 585, 589, 20, - /* 1810 */ 21, 1782, 587, 1132, 344, 1814, 1129, 593, 591, 282, - /* 1820 */ 1783, 586, 1785, 1786, 582, 1800, 577, 594, 596, 1126, - /* 1830 */ 597, 599, 602, 584, 609, 1124, 1109, 1123, 1751, 1800, - /* 1840 */ 583, 1120, 1118, 600, 1122, 1141, 603, 584, 1121, 85, - /* 1850 */ 86, 62, 1751, 1782, 583, 1137, 265, 1038, 1063, 618, - /* 1860 */ 1078, 621, 266, 1782, 1061, 1814, 1060, 1059, 1058, 283, - /* 1870 */ 1783, 586, 1785, 1786, 582, 1057, 577, 1056, 1055, 1814, - /* 1880 */ 1054, 1800, 1073, 284, 1783, 586, 1785, 1786, 582, 584, - /* 1890 */ 577, 1800, 1075, 1051, 1751, 1050, 583, 1049, 1046, 584, - /* 1900 */ 1045, 1044, 1043, 1521, 1751, 643, 583, 645, 644, 1519, - /* 1910 */ 647, 648, 649, 1517, 1515, 651, 652, 653, 655, 656, - /* 1920 */ 657, 1814, 1503, 659, 1000, 291, 1783, 586, 1785, 1786, - /* 1930 */ 582, 1814, 577, 1485, 269, 293, 1783, 586, 1785, 1786, - /* 1940 */ 582, 1782, 577, 1259, 663, 667, 277, 666, 1460, 1460, - /* 1950 */ 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1782, 1460, 1460, - /* 1960 */ 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1800, - /* 1970 */ 1460, 1460, 1460, 1460, 1460, 1460, 1460, 584, 1460, 1460, - /* 1980 */ 1460, 1460, 1751, 1460, 583, 1800, 1460, 1460, 1460, 1460, - /* 1990 */ 1460, 1460, 1460, 584, 1460, 1460, 1460, 1460, 1751, 1460, - /* 2000 */ 583, 1460, 1460, 1460, 1460, 1460, 1460, 1782, 1460, 1814, - /* 2010 */ 1460, 1460, 1460, 285, 1783, 586, 1785, 1786, 582, 1782, - /* 2020 */ 577, 1460, 1460, 1460, 1460, 1814, 1460, 1460, 1460, 294, - /* 2030 */ 1783, 586, 1785, 1786, 582, 1800, 577, 1460, 1460, 1460, - /* 2040 */ 1460, 1460, 1460, 584, 1460, 1460, 1460, 1800, 1751, 1460, - /* 2050 */ 583, 1460, 1460, 1460, 1460, 584, 1460, 1460, 1460, 1460, - /* 2060 */ 1751, 1460, 583, 1460, 1460, 1460, 1460, 1460, 1460, 1460, - /* 2070 */ 1460, 1782, 1460, 1460, 1460, 1814, 1460, 1460, 1460, 286, - /* 2080 */ 1783, 586, 1785, 1786, 582, 1782, 577, 1814, 555, 1460, - /* 2090 */ 1460, 295, 1783, 586, 1785, 1786, 582, 1460, 577, 1800, - /* 2100 */ 1460, 1460, 1460, 1460, 1460, 1460, 1460, 584, 1460, 1460, - /* 2110 */ 1460, 1460, 1751, 1800, 583, 1460, 124, 1460, 1460, 1460, - /* 2120 */ 1460, 584, 1460, 1460, 1460, 1460, 1751, 1460, 583, 1460, - /* 2130 */ 1460, 1460, 1460, 1460, 1460, 1460, 1460, 560, 1460, 1814, - /* 2140 */ 1460, 1782, 1460, 287, 1783, 586, 1785, 1786, 582, 1460, - /* 2150 */ 577, 1782, 1460, 1814, 1460, 1460, 122, 300, 1783, 586, - /* 2160 */ 1785, 1786, 582, 1460, 577, 1460, 1460, 1460, 1460, 1800, - /* 2170 */ 1460, 253, 1868, 554, 1460, 553, 1460, 584, 1926, 1800, - /* 2180 */ 1460, 1460, 1751, 1460, 583, 1460, 1460, 584, 1460, 1460, - /* 2190 */ 1460, 162, 1751, 1460, 583, 1923, 1460, 1460, 1460, 1460, - /* 2200 */ 1460, 1782, 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1814, - /* 2210 */ 1460, 1460, 1460, 301, 1783, 586, 1785, 1786, 582, 1814, - /* 2220 */ 577, 1460, 1460, 1794, 1783, 586, 1785, 1786, 582, 1800, - /* 2230 */ 577, 1460, 1460, 1460, 1460, 1460, 1460, 584, 1460, 1460, - /* 2240 */ 1460, 1460, 1751, 1460, 583, 1460, 1460, 1460, 1460, 1460, - /* 2250 */ 1460, 1460, 1460, 1782, 1460, 1460, 1460, 1460, 1460, 1460, - /* 2260 */ 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1782, 1460, 1814, - /* 2270 */ 1460, 1460, 1460, 1793, 1783, 586, 1785, 1786, 582, 1782, - /* 2280 */ 577, 1800, 1460, 1460, 1460, 1460, 1460, 1460, 1460, 584, - /* 2290 */ 1460, 1460, 1460, 1460, 1751, 1800, 583, 1460, 1460, 1460, - /* 2300 */ 1460, 1460, 1460, 584, 1460, 1460, 1460, 1800, 1751, 1460, - /* 2310 */ 583, 1460, 1460, 1460, 1460, 584, 1460, 1460, 1460, 1460, - /* 2320 */ 1751, 1814, 583, 1460, 1460, 1792, 1783, 586, 1785, 1786, - /* 2330 */ 582, 1782, 577, 1460, 1460, 1814, 1460, 1460, 1460, 312, - /* 2340 */ 1783, 586, 1785, 1786, 582, 1782, 577, 1814, 1460, 1460, - /* 2350 */ 1460, 311, 1783, 586, 1785, 1786, 582, 1460, 577, 1800, - /* 2360 */ 1460, 1460, 1460, 1460, 1460, 1460, 1460, 584, 1460, 1460, - /* 2370 */ 1460, 1460, 1751, 1800, 583, 1460, 1460, 1460, 1460, 1460, - /* 2380 */ 1460, 584, 1460, 1460, 1460, 1460, 1751, 1460, 583, 1460, - /* 2390 */ 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1814, - /* 2400 */ 1460, 1782, 1460, 313, 1783, 586, 1785, 1786, 582, 1460, - /* 2410 */ 577, 1460, 1460, 1814, 1460, 1460, 1460, 310, 1783, 586, - /* 2420 */ 1785, 1786, 582, 1460, 577, 1460, 1460, 1460, 1460, 1800, - /* 2430 */ 1460, 1460, 1460, 1460, 1460, 1460, 1460, 584, 1460, 1460, - /* 2440 */ 1460, 1460, 1751, 1460, 583, 1460, 1460, 1460, 1460, 1460, - /* 2450 */ 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1460, - /* 2460 */ 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1460, 1814, - /* 2470 */ 1460, 1460, 1460, 290, 1783, 586, 1785, 1786, 582, 1460, - /* 2480 */ 577, + /* 0 */ 433, 1937, 434, 1503, 1654, 1655, 1599, 326, 441, 548, + /* 10 */ 434, 1503, 39, 37, 1936, 143, 1709, 1776, 1934, 1937, + /* 20 */ 339, 1469, 1264, 513, 1610, 40, 38, 36, 35, 34, + /* 30 */ 1793, 325, 163, 1341, 1706, 1262, 1934, 124, 1290, 1023, + /* 40 */ 1006, 1022, 104, 1772, 1778, 103, 102, 101, 100, 99, + /* 50 */ 98, 97, 96, 95, 156, 570, 1336, 73, 1811, 344, + /* 60 */ 147, 14, 1653, 1655, 1568, 88, 577, 1647, 1270, 1024, + /* 70 */ 1023, 1762, 1022, 576, 39, 37, 1404, 122, 121, 1604, + /* 80 */ 1010, 1011, 339, 1530, 1264, 469, 1600, 553, 145, 1, + /* 90 */ 1480, 550, 158, 1879, 1880, 1341, 1884, 1262, 1825, 551, + /* 100 */ 1024, 64, 91, 1794, 579, 1796, 1797, 575, 1660, 570, + /* 110 */ 1291, 662, 1871, 1408, 1937, 312, 306, 1867, 1336, 1289, + /* 120 */ 36, 35, 34, 14, 1658, 1343, 1344, 1935, 1937, 104, + /* 130 */ 1270, 1934, 103, 102, 101, 100, 99, 98, 97, 96, + /* 140 */ 95, 164, 450, 1161, 1162, 1934, 639, 638, 637, 636, + /* 150 */ 349, 2, 635, 634, 125, 629, 628, 627, 626, 625, + /* 160 */ 624, 623, 136, 619, 618, 617, 348, 347, 614, 613, + /* 170 */ 1265, 316, 1263, 662, 1491, 33, 32, 1466, 1937, 40, + /* 180 */ 38, 36, 35, 34, 30, 261, 63, 1343, 1344, 432, + /* 190 */ 1290, 163, 436, 1268, 1269, 1934, 1318, 1319, 1321, 1322, + /* 200 */ 1323, 1324, 1325, 1326, 572, 568, 1334, 1335, 1337, 1338, + /* 210 */ 1339, 1340, 1342, 1345, 1468, 1762, 33, 32, 612, 551, + /* 220 */ 40, 38, 36, 35, 34, 1289, 317, 165, 315, 314, + /* 230 */ 610, 473, 1265, 209, 1263, 475, 1425, 354, 113, 112, + /* 240 */ 111, 110, 109, 108, 107, 106, 105, 253, 384, 134, + /* 250 */ 133, 607, 606, 605, 63, 1268, 1269, 474, 1318, 1319, + /* 260 */ 1321, 1322, 1323, 1324, 1325, 1326, 572, 568, 1334, 1335, + /* 270 */ 1337, 1338, 1339, 1340, 1342, 1345, 39, 37, 1937, 534, + /* 280 */ 1423, 1424, 1426, 1427, 339, 303, 1264, 378, 43, 75, + /* 290 */ 305, 162, 221, 515, 1793, 1934, 1320, 1341, 1435, 1262, + /* 300 */ 1119, 601, 600, 599, 1123, 598, 1125, 1126, 597, 1128, + /* 310 */ 594, 487, 1134, 591, 1136, 1137, 588, 585, 440, 1811, + /* 320 */ 1336, 436, 1811, 537, 165, 14, 497, 541, 1937, 1461, + /* 330 */ 577, 1699, 1270, 551, 377, 1762, 376, 576, 39, 37, + /* 340 */ 208, 162, 170, 63, 548, 1934, 339, 49, 1264, 525, + /* 350 */ 665, 1244, 1245, 2, 490, 1490, 222, 223, 484, 1341, + /* 360 */ 55, 1262, 1825, 207, 268, 540, 93, 1794, 579, 1796, + /* 370 */ 1797, 575, 124, 570, 1289, 662, 1871, 1608, 154, 143, + /* 380 */ 1870, 1867, 1336, 655, 651, 647, 643, 266, 1611, 1343, + /* 390 */ 1344, 1270, 165, 1264, 1270, 58, 1762, 216, 57, 1489, + /* 400 */ 543, 538, 42, 39, 37, 1346, 1262, 1780, 496, 1488, + /* 410 */ 548, 339, 122, 1264, 305, 8, 1460, 515, 1776, 89, + /* 420 */ 73, 494, 231, 492, 1341, 542, 1262, 159, 1879, 1880, + /* 430 */ 63, 1884, 77, 119, 1265, 1351, 1263, 662, 124, 1270, + /* 440 */ 1762, 1289, 1603, 63, 1772, 1778, 328, 1336, 479, 478, + /* 450 */ 1762, 1343, 1344, 11, 10, 522, 570, 1268, 1269, 1270, + /* 460 */ 1318, 1319, 1321, 1322, 1323, 1324, 1325, 1326, 572, 568, + /* 470 */ 1334, 1335, 1337, 1338, 1339, 1340, 1342, 1345, 122, 215, + /* 480 */ 9, 165, 662, 482, 481, 165, 171, 218, 1586, 195, + /* 490 */ 120, 633, 631, 160, 1879, 1880, 1265, 1884, 1263, 1660, + /* 500 */ 477, 480, 662, 149, 61, 1236, 327, 211, 467, 463, + /* 510 */ 459, 455, 194, 1585, 76, 1658, 1343, 1344, 71, 1268, + /* 520 */ 1269, 70, 1318, 1319, 1321, 1322, 1323, 1324, 1325, 1326, + /* 530 */ 572, 568, 1334, 1335, 1337, 1338, 1339, 1340, 1342, 1345, + /* 540 */ 165, 1265, 1377, 1263, 74, 1583, 1288, 192, 450, 81, + /* 550 */ 33, 32, 342, 165, 40, 38, 36, 35, 34, 1533, + /* 560 */ 143, 1265, 1584, 1263, 1268, 1269, 621, 512, 165, 1610, + /* 570 */ 1601, 1699, 33, 32, 1010, 1011, 40, 38, 36, 35, + /* 580 */ 34, 165, 173, 604, 1268, 1269, 1081, 1318, 1319, 1321, + /* 590 */ 1322, 1323, 1324, 1325, 1326, 572, 568, 1334, 1335, 1337, + /* 600 */ 1338, 1339, 1340, 1342, 1345, 39, 37, 22, 1937, 191, + /* 610 */ 184, 1793, 189, 339, 610, 1264, 446, 1597, 1320, 1083, + /* 620 */ 513, 162, 612, 482, 481, 1934, 1341, 525, 1262, 1593, + /* 630 */ 120, 1707, 182, 134, 133, 607, 606, 605, 114, 1811, + /* 640 */ 477, 480, 7, 345, 548, 471, 610, 577, 1487, 1336, + /* 650 */ 438, 143, 1762, 525, 576, 1608, 1287, 1595, 419, 352, + /* 660 */ 1610, 1270, 351, 1365, 167, 134, 133, 607, 606, 605, + /* 670 */ 33, 32, 124, 1486, 40, 38, 36, 35, 34, 1825, + /* 680 */ 1485, 1608, 9, 280, 1794, 579, 1796, 1797, 575, 1762, + /* 690 */ 570, 33, 32, 553, 505, 40, 38, 36, 35, 34, + /* 700 */ 1937, 33, 32, 1937, 662, 40, 38, 36, 35, 34, + /* 710 */ 175, 174, 122, 162, 1762, 498, 162, 1934, 1343, 1344, + /* 720 */ 1934, 1762, 1705, 307, 300, 27, 1484, 251, 1879, 547, + /* 730 */ 525, 546, 39, 37, 1937, 1370, 1483, 302, 1886, 1287, + /* 740 */ 339, 114, 1264, 525, 307, 555, 412, 164, 476, 424, + /* 750 */ 1591, 1934, 1303, 1341, 382, 1262, 1937, 212, 1608, 373, + /* 760 */ 1363, 1886, 1883, 1265, 1509, 1263, 397, 1762, 425, 162, + /* 770 */ 399, 1608, 1482, 1934, 1479, 1292, 1336, 1762, 375, 371, + /* 780 */ 1704, 1363, 300, 1415, 1478, 1882, 1268, 1269, 1270, 1318, + /* 790 */ 1319, 1321, 1322, 1323, 1324, 1325, 1326, 572, 568, 1334, + /* 800 */ 1335, 1337, 1338, 1339, 1340, 1342, 1345, 390, 1477, 2, + /* 810 */ 26, 1660, 657, 1762, 1364, 1762, 33, 32, 343, 386, + /* 820 */ 40, 38, 36, 35, 34, 1762, 28, 1658, 1660, 1397, + /* 830 */ 1476, 662, 33, 32, 1475, 1364, 40, 38, 36, 35, + /* 840 */ 34, 622, 1289, 1580, 1659, 1343, 1344, 423, 1474, 1762, + /* 850 */ 418, 417, 416, 415, 414, 411, 410, 409, 408, 407, + /* 860 */ 403, 402, 401, 400, 394, 393, 392, 391, 1473, 388, + /* 870 */ 387, 1762, 475, 1401, 1472, 1762, 29, 337, 1358, 1359, + /* 880 */ 1360, 1361, 1362, 1366, 1367, 1368, 1369, 1886, 608, 1762, + /* 890 */ 1265, 1651, 1263, 609, 474, 571, 1651, 29, 337, 1358, + /* 900 */ 1359, 1360, 1361, 1362, 1366, 1367, 1368, 1369, 1471, 1762, + /* 910 */ 1793, 1881, 233, 1268, 1269, 1762, 1318, 1319, 1321, 1322, + /* 920 */ 1323, 1324, 1325, 1326, 572, 568, 1334, 1335, 1337, 1338, + /* 930 */ 1339, 1340, 1342, 1345, 525, 144, 525, 525, 1811, 1273, + /* 940 */ 279, 525, 1891, 1397, 548, 383, 577, 389, 404, 1762, + /* 950 */ 603, 1762, 405, 576, 277, 60, 273, 132, 59, 1638, + /* 960 */ 44, 4, 1608, 1749, 1608, 1608, 1481, 553, 200, 1608, + /* 970 */ 525, 198, 124, 1520, 178, 429, 427, 1780, 1825, 1515, + /* 980 */ 560, 449, 91, 1794, 579, 1796, 1797, 575, 1776, 570, + /* 990 */ 566, 202, 1871, 553, 201, 483, 306, 1867, 1608, 336, + /* 1000 */ 335, 485, 525, 41, 54, 557, 63, 220, 1937, 1278, + /* 1010 */ 361, 1513, 122, 1605, 1772, 1778, 334, 53, 509, 1320, + /* 1020 */ 1341, 162, 1271, 11, 10, 1934, 570, 251, 1879, 547, + /* 1030 */ 1608, 546, 256, 488, 1937, 525, 204, 1781, 206, 203, + /* 1040 */ 128, 205, 1793, 1336, 90, 131, 1737, 162, 1776, 51, + /* 1050 */ 1213, 1934, 33, 32, 224, 1270, 40, 38, 36, 35, + /* 1060 */ 34, 33, 32, 1608, 132, 40, 38, 36, 35, 34, + /* 1070 */ 1811, 525, 1463, 1464, 1772, 1778, 1276, 1569, 552, 68, + /* 1080 */ 67, 381, 506, 1762, 169, 576, 570, 518, 51, 1783, + /* 1090 */ 615, 535, 230, 1272, 87, 468, 1371, 1400, 565, 1608, + /* 1100 */ 301, 499, 237, 369, 84, 367, 363, 359, 356, 353, + /* 1110 */ 1825, 1112, 1069, 41, 92, 1794, 579, 1796, 1797, 575, + /* 1120 */ 525, 570, 1355, 525, 1871, 525, 525, 525, 330, 1867, + /* 1130 */ 157, 510, 1785, 1050, 523, 1422, 524, 262, 346, 616, + /* 1140 */ 41, 1793, 161, 1303, 165, 245, 350, 1504, 1608, 240, + /* 1150 */ 1897, 1608, 583, 1608, 1608, 1608, 1812, 1279, 131, 1274, + /* 1160 */ 1327, 1067, 1648, 132, 1901, 116, 1051, 549, 250, 1811, + /* 1170 */ 255, 258, 3, 260, 131, 5, 355, 552, 313, 360, + /* 1180 */ 1282, 1284, 1762, 1793, 576, 561, 1229, 272, 172, 269, + /* 1190 */ 385, 1287, 568, 1334, 1335, 1337, 1338, 1339, 1340, 1140, + /* 1200 */ 406, 142, 1701, 413, 421, 1144, 420, 422, 558, 1825, + /* 1210 */ 1151, 1811, 1149, 92, 1794, 579, 1796, 1797, 575, 577, + /* 1220 */ 570, 135, 426, 1871, 1762, 428, 576, 330, 1867, 157, + /* 1230 */ 1275, 1293, 431, 430, 439, 1296, 1793, 1295, 442, 181, + /* 1240 */ 183, 443, 444, 1297, 447, 445, 186, 188, 1294, 1898, + /* 1250 */ 448, 1825, 190, 1793, 72, 92, 1794, 579, 1796, 1797, + /* 1260 */ 575, 193, 570, 451, 1811, 1871, 470, 1742, 500, 330, + /* 1270 */ 1867, 1950, 577, 472, 1598, 304, 197, 1762, 1594, 576, + /* 1280 */ 1905, 1811, 199, 115, 137, 507, 138, 1596, 1592, 577, + /* 1290 */ 210, 139, 270, 501, 1762, 140, 576, 213, 511, 322, + /* 1300 */ 533, 217, 514, 129, 1825, 519, 226, 271, 92, 1794, + /* 1310 */ 579, 1796, 1797, 575, 1292, 570, 1793, 504, 1871, 520, + /* 1320 */ 1741, 1825, 330, 1867, 1950, 92, 1794, 579, 1796, 1797, + /* 1330 */ 575, 228, 570, 1928, 1711, 1871, 516, 130, 324, 330, + /* 1340 */ 1867, 1950, 80, 521, 1811, 1609, 536, 1902, 529, 531, + /* 1350 */ 1890, 235, 577, 239, 6, 532, 1912, 1762, 329, 576, + /* 1360 */ 545, 539, 530, 528, 527, 1397, 1793, 123, 249, 1291, + /* 1370 */ 1887, 562, 1911, 553, 559, 331, 1793, 48, 82, 1893, + /* 1380 */ 581, 1652, 1581, 658, 1825, 274, 659, 246, 286, 1794, + /* 1390 */ 579, 1796, 1797, 575, 1811, 570, 52, 265, 244, 248, + /* 1400 */ 151, 254, 577, 1933, 1811, 1953, 661, 1762, 247, 576, + /* 1410 */ 1852, 150, 577, 276, 1937, 287, 1756, 1762, 1793, 576, + /* 1420 */ 297, 278, 296, 553, 556, 563, 1755, 164, 257, 65, + /* 1430 */ 1754, 1934, 1753, 66, 1825, 259, 1750, 357, 286, 1794, + /* 1440 */ 579, 1796, 1797, 575, 1825, 570, 1811, 358, 93, 1794, + /* 1450 */ 579, 1796, 1797, 575, 574, 570, 1256, 1257, 1871, 1762, + /* 1460 */ 168, 576, 564, 1867, 1937, 362, 1748, 366, 364, 365, + /* 1470 */ 1747, 368, 1793, 370, 1745, 372, 1744, 162, 1746, 374, + /* 1480 */ 1232, 1934, 1231, 1722, 1793, 1721, 1825, 379, 1720, 380, + /* 1490 */ 294, 1794, 579, 1796, 1797, 575, 573, 570, 567, 1843, + /* 1500 */ 1811, 1719, 1201, 1694, 126, 1693, 1692, 1691, 577, 69, + /* 1510 */ 1690, 1689, 1811, 1762, 1688, 576, 1687, 1686, 395, 396, + /* 1520 */ 577, 1685, 398, 1684, 1683, 1762, 1682, 576, 1681, 1680, + /* 1530 */ 1679, 1678, 1677, 1676, 1675, 1674, 1673, 1672, 1671, 1670, + /* 1540 */ 1825, 1793, 127, 1669, 146, 1794, 579, 1796, 1797, 575, + /* 1550 */ 1668, 570, 1825, 180, 176, 1534, 93, 1794, 579, 1796, + /* 1560 */ 1797, 575, 1667, 570, 1666, 1793, 1871, 1203, 1664, 1811, + /* 1570 */ 1665, 1868, 1663, 1662, 323, 1661, 1535, 577, 177, 1532, + /* 1580 */ 1500, 117, 1762, 1793, 576, 1013, 179, 435, 554, 1951, + /* 1590 */ 155, 1012, 437, 1811, 1499, 118, 1735, 1729, 526, 1718, + /* 1600 */ 185, 577, 187, 1717, 1703, 1587, 1762, 1531, 576, 1825, + /* 1610 */ 1043, 1811, 1529, 295, 1794, 579, 1796, 1797, 575, 577, + /* 1620 */ 570, 452, 454, 1527, 1762, 453, 576, 456, 457, 458, + /* 1630 */ 1525, 461, 462, 1825, 1523, 460, 464, 295, 1794, 579, + /* 1640 */ 1796, 1797, 575, 1512, 570, 1793, 1511, 466, 1496, 465, + /* 1650 */ 1589, 1825, 50, 196, 1154, 290, 1794, 579, 1796, 1797, + /* 1660 */ 575, 1155, 570, 1793, 1588, 630, 1080, 632, 1077, 1075, + /* 1670 */ 1076, 1521, 1516, 1811, 318, 319, 486, 1514, 320, 489, + /* 1680 */ 1495, 577, 1494, 1493, 491, 495, 1762, 94, 576, 493, + /* 1690 */ 1734, 1811, 1238, 544, 1728, 502, 1716, 56, 141, 574, + /* 1700 */ 1714, 1715, 1713, 214, 1762, 1712, 576, 15, 503, 321, + /* 1710 */ 219, 1710, 1702, 1825, 225, 1793, 229, 146, 1794, 579, + /* 1720 */ 1796, 1797, 575, 227, 570, 508, 78, 79, 84, 517, + /* 1730 */ 41, 1825, 232, 1793, 23, 294, 1794, 579, 1796, 1797, + /* 1740 */ 575, 1248, 570, 1811, 1844, 1437, 16, 234, 338, 236, + /* 1750 */ 1419, 577, 47, 242, 238, 148, 1762, 1793, 576, 1421, + /* 1760 */ 1414, 1811, 1952, 241, 24, 243, 340, 1783, 83, 577, + /* 1770 */ 25, 1394, 252, 46, 1762, 1393, 576, 1782, 1454, 152, + /* 1780 */ 18, 1443, 1449, 1825, 1448, 1811, 332, 295, 1794, 579, + /* 1790 */ 1796, 1797, 575, 577, 570, 1453, 17, 1452, 1762, 333, + /* 1800 */ 576, 1825, 10, 1280, 1356, 295, 1794, 579, 1796, 1797, + /* 1810 */ 575, 19, 570, 1793, 45, 1331, 13, 1828, 569, 153, + /* 1820 */ 166, 1311, 580, 578, 1329, 1825, 1328, 1793, 31, 281, + /* 1830 */ 1794, 579, 1796, 1797, 575, 12, 570, 20, 582, 21, + /* 1840 */ 341, 1811, 1141, 584, 586, 1138, 587, 589, 1135, 577, + /* 1850 */ 590, 592, 595, 1129, 1762, 1811, 576, 1127, 593, 596, + /* 1860 */ 1118, 85, 1150, 577, 86, 62, 1133, 602, 1762, 1793, + /* 1870 */ 576, 263, 1132, 1146, 1072, 1041, 611, 1071, 1131, 1793, + /* 1880 */ 1070, 1825, 1068, 1066, 1130, 282, 1794, 579, 1796, 1797, + /* 1890 */ 575, 1065, 570, 1064, 1087, 1825, 264, 1811, 620, 289, + /* 1900 */ 1794, 579, 1796, 1797, 575, 577, 570, 1811, 1062, 1061, + /* 1910 */ 1762, 1060, 576, 1059, 1058, 577, 1057, 1056, 1084, 1082, + /* 1920 */ 1762, 1793, 576, 1053, 1047, 1528, 1052, 1526, 1049, 1048, + /* 1930 */ 1046, 640, 641, 644, 645, 1524, 642, 1825, 646, 648, + /* 1940 */ 650, 291, 1794, 579, 1796, 1797, 575, 1825, 570, 1811, + /* 1950 */ 649, 283, 1794, 579, 1796, 1797, 575, 577, 570, 1522, + /* 1960 */ 653, 652, 1762, 654, 576, 1510, 656, 1003, 1492, 267, + /* 1970 */ 660, 1467, 1266, 275, 1793, 663, 664, 1467, 1467, 1467, + /* 1980 */ 1467, 1467, 1467, 1467, 1467, 1467, 1467, 1467, 1467, 1825, + /* 1990 */ 1467, 1467, 1793, 292, 1794, 579, 1796, 1797, 575, 1467, + /* 2000 */ 570, 1467, 1811, 1467, 1467, 1467, 1467, 1467, 1467, 1467, + /* 2010 */ 577, 1467, 1467, 1467, 1467, 1762, 1467, 576, 1467, 1467, + /* 2020 */ 1811, 1467, 1467, 1467, 1467, 1467, 1467, 1467, 577, 1467, + /* 2030 */ 1467, 1467, 1467, 1762, 1467, 576, 1467, 1467, 1467, 1467, + /* 2040 */ 1467, 1467, 1825, 1467, 1793, 1467, 284, 1794, 579, 1796, + /* 2050 */ 1797, 575, 1467, 570, 1793, 1467, 1467, 1467, 1467, 1467, + /* 2060 */ 1825, 1467, 1467, 1467, 293, 1794, 579, 1796, 1797, 575, + /* 2070 */ 1793, 570, 1811, 1467, 1467, 1467, 1467, 1467, 1467, 1467, + /* 2080 */ 577, 1467, 1811, 1467, 1467, 1762, 1467, 576, 1467, 1467, + /* 2090 */ 577, 1467, 1467, 1467, 1467, 1762, 1467, 576, 1811, 1467, + /* 2100 */ 1467, 1467, 1467, 1467, 1467, 1467, 577, 1467, 1467, 1467, + /* 2110 */ 1467, 1762, 1825, 576, 1467, 1467, 285, 1794, 579, 1796, + /* 2120 */ 1797, 575, 1825, 570, 1793, 1467, 298, 1794, 579, 1796, + /* 2130 */ 1797, 575, 1467, 570, 1467, 1467, 1467, 1467, 1825, 1467, + /* 2140 */ 1793, 1467, 299, 1794, 579, 1796, 1797, 575, 1467, 570, + /* 2150 */ 1793, 1467, 1811, 1467, 1467, 1467, 1467, 1467, 1467, 1467, + /* 2160 */ 577, 1467, 1467, 1467, 1467, 1762, 1793, 576, 1811, 1467, + /* 2170 */ 1467, 1467, 1467, 1467, 1467, 1467, 577, 1467, 1811, 1467, + /* 2180 */ 1467, 1762, 1467, 576, 1467, 1467, 577, 1467, 1467, 1467, + /* 2190 */ 1467, 1762, 1825, 576, 1811, 1467, 1805, 1794, 579, 1796, + /* 2200 */ 1797, 575, 577, 570, 1467, 1467, 1467, 1762, 1825, 576, + /* 2210 */ 1467, 1467, 1804, 1794, 579, 1796, 1797, 575, 1825, 570, + /* 2220 */ 1467, 1467, 1803, 1794, 579, 1796, 1797, 575, 1467, 570, + /* 2230 */ 1467, 1467, 1467, 1467, 1825, 1793, 1467, 1467, 310, 1794, + /* 2240 */ 579, 1796, 1797, 575, 1467, 570, 1467, 1467, 1467, 1467, + /* 2250 */ 1467, 1467, 1467, 1793, 1467, 1467, 1467, 1467, 1467, 1467, + /* 2260 */ 1467, 1467, 1467, 1811, 1467, 1467, 1467, 1467, 1467, 1467, + /* 2270 */ 1467, 577, 1467, 1467, 1467, 1467, 1762, 1467, 576, 1467, + /* 2280 */ 1467, 1811, 1467, 1467, 1467, 1467, 1467, 1467, 1467, 577, + /* 2290 */ 1467, 1467, 1467, 1467, 1762, 1467, 576, 1467, 1467, 1467, + /* 2300 */ 1467, 1467, 1467, 1825, 1467, 1793, 1467, 309, 1794, 579, + /* 2310 */ 1796, 1797, 575, 1467, 570, 1793, 1467, 1467, 1467, 1467, + /* 2320 */ 1467, 1825, 1467, 1467, 1467, 311, 1794, 579, 1796, 1797, + /* 2330 */ 575, 1467, 570, 1811, 1467, 1467, 1467, 1467, 1467, 1467, + /* 2340 */ 1467, 577, 1467, 1811, 1467, 1467, 1762, 1467, 576, 1467, + /* 2350 */ 1467, 577, 1467, 1467, 1467, 1467, 1762, 1467, 576, 1467, + /* 2360 */ 1467, 1467, 1467, 1467, 1467, 1467, 1467, 1467, 1467, 1467, + /* 2370 */ 1467, 1467, 1467, 1825, 1467, 1467, 1467, 308, 1794, 579, + /* 2380 */ 1796, 1797, 575, 1825, 570, 1467, 1467, 288, 1794, 579, + /* 2390 */ 1796, 1797, 575, 1467, 570, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 267, 271, 256, 263, 267, 265, 266, 279, 302, 271, - /* 10 */ 287, 278, 12, 13, 284, 287, 310, 294, 285, 313, - /* 20 */ 20, 0, 22, 293, 296, 272, 303, 267, 295, 276, - /* 30 */ 287, 293, 295, 33, 263, 35, 265, 266, 295, 20, - /* 40 */ 298, 267, 21, 301, 302, 24, 25, 26, 27, 28, - /* 50 */ 29, 30, 31, 32, 264, 295, 56, 267, 259, 8, - /* 60 */ 9, 61, 316, 12, 13, 14, 15, 16, 68, 12, - /* 70 */ 13, 14, 335, 20, 20, 43, 333, 20, 304, 22, - /* 80 */ 357, 79, 258, 357, 260, 85, 287, 350, 351, 352, - /* 90 */ 33, 354, 35, 370, 295, 335, 370, 374, 20, 300, - /* 100 */ 374, 302, 4, 357, 85, 85, 20, 107, 22, 349, - /* 110 */ 350, 351, 352, 56, 354, 316, 370, 269, 61, 4, - /* 120 */ 374, 121, 122, 342, 343, 68, 327, 125, 126, 116, - /* 130 */ 331, 332, 333, 334, 335, 336, 50, 338, 290, 85, - /* 140 */ 341, 259, 85, 21, 345, 346, 24, 25, 26, 27, - /* 150 */ 28, 29, 30, 31, 32, 0, 357, 64, 65, 44, - /* 160 */ 45, 287, 69, 85, 107, 72, 166, 33, 168, 370, - /* 170 */ 296, 78, 148, 374, 121, 122, 316, 264, 121, 122, - /* 180 */ 267, 47, 300, 85, 301, 302, 52, 53, 54, 55, - /* 190 */ 56, 178, 179, 193, 194, 171, 196, 197, 198, 199, + /* 0 */ 264, 358, 266, 267, 302, 303, 290, 280, 264, 268, + /* 10 */ 266, 267, 12, 13, 371, 288, 0, 301, 375, 358, + /* 20 */ 20, 0, 22, 303, 297, 12, 13, 14, 15, 16, + /* 30 */ 260, 311, 371, 33, 314, 35, 375, 296, 20, 20, + /* 40 */ 4, 22, 21, 327, 328, 24, 25, 26, 27, 28, + /* 50 */ 29, 30, 31, 32, 287, 339, 56, 272, 288, 299, + /* 60 */ 273, 61, 302, 303, 277, 270, 296, 300, 68, 50, + /* 70 */ 20, 301, 22, 303, 12, 13, 14, 336, 283, 294, + /* 80 */ 44, 45, 20, 0, 22, 35, 291, 317, 259, 89, + /* 90 */ 261, 350, 351, 352, 353, 33, 355, 35, 328, 20, + /* 100 */ 50, 4, 332, 333, 334, 335, 336, 337, 288, 339, + /* 110 */ 20, 111, 342, 14, 358, 295, 346, 347, 56, 20, + /* 120 */ 14, 15, 16, 61, 304, 125, 126, 371, 358, 21, + /* 130 */ 68, 375, 24, 25, 26, 27, 28, 29, 30, 31, + /* 140 */ 32, 371, 60, 125, 126, 375, 63, 64, 65, 66, + /* 150 */ 67, 89, 69, 70, 71, 72, 73, 74, 75, 76, + /* 160 */ 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, + /* 170 */ 170, 37, 172, 111, 260, 8, 9, 257, 358, 12, + /* 180 */ 13, 14, 15, 16, 343, 344, 89, 125, 126, 265, + /* 190 */ 20, 371, 268, 193, 194, 375, 196, 197, 198, 199, /* 200 */ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, - /* 210 */ 210, 211, 212, 213, 20, 287, 22, 357, 84, 64, - /* 220 */ 65, 87, 294, 166, 69, 168, 226, 72, 20, 35, - /* 230 */ 370, 303, 85, 78, 374, 8, 9, 316, 214, 12, - /* 240 */ 13, 14, 15, 16, 50, 226, 226, 312, 267, 314, - /* 250 */ 193, 194, 161, 196, 197, 198, 199, 200, 201, 202, - /* 260 */ 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - /* 270 */ 213, 12, 13, 0, 183, 184, 295, 245, 357, 20, - /* 280 */ 226, 22, 259, 149, 150, 295, 152, 329, 61, 85, - /* 290 */ 156, 370, 33, 21, 35, 374, 306, 24, 25, 26, - /* 300 */ 27, 28, 29, 30, 31, 32, 34, 259, 36, 175, - /* 310 */ 287, 353, 165, 86, 167, 56, 335, 0, 295, 267, - /* 320 */ 61, 94, 259, 300, 226, 302, 60, 68, 12, 13, - /* 330 */ 278, 350, 351, 352, 267, 354, 20, 285, 22, 0, - /* 340 */ 37, 1, 2, 193, 85, 278, 14, 295, 300, 33, - /* 350 */ 327, 35, 20, 4, 331, 332, 333, 334, 335, 336, - /* 360 */ 0, 338, 295, 300, 341, 14, 107, 267, 345, 346, - /* 370 */ 347, 20, 56, 226, 20, 148, 287, 60, 278, 0, - /* 380 */ 121, 122, 359, 294, 68, 235, 236, 237, 238, 239, - /* 390 */ 367, 88, 303, 90, 91, 295, 93, 20, 171, 259, - /* 400 */ 97, 85, 63, 64, 65, 66, 67, 47, 69, 70, - /* 410 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, - /* 420 */ 81, 82, 119, 107, 20, 166, 86, 168, 8, 9, - /* 430 */ 226, 20, 12, 13, 14, 15, 16, 121, 122, 60, - /* 440 */ 300, 214, 215, 216, 217, 218, 219, 220, 221, 222, - /* 450 */ 223, 259, 193, 194, 259, 196, 197, 198, 199, 200, - /* 460 */ 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, - /* 470 */ 211, 212, 213, 8, 9, 56, 60, 12, 13, 14, - /* 480 */ 15, 16, 166, 97, 168, 12, 13, 14, 15, 16, - /* 490 */ 22, 295, 300, 8, 9, 300, 289, 12, 13, 14, - /* 500 */ 15, 16, 306, 35, 85, 119, 87, 300, 43, 193, - /* 510 */ 194, 20, 196, 197, 198, 199, 200, 201, 202, 203, - /* 520 */ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, - /* 530 */ 12, 13, 14, 326, 327, 328, 68, 286, 20, 279, - /* 540 */ 22, 259, 226, 289, 267, 338, 61, 287, 197, 269, - /* 550 */ 299, 33, 289, 35, 300, 278, 296, 153, 116, 117, - /* 560 */ 8, 9, 282, 300, 12, 13, 14, 15, 16, 287, - /* 570 */ 290, 56, 295, 35, 56, 107, 227, 295, 158, 94, - /* 580 */ 326, 327, 300, 4, 302, 302, 68, 12, 13, 326, - /* 590 */ 327, 328, 338, 267, 357, 20, 313, 22, 19, 84, - /* 600 */ 151, 338, 87, 85, 278, 259, 68, 370, 33, 327, - /* 610 */ 35, 374, 33, 331, 332, 333, 334, 335, 336, 177, - /* 620 */ 338, 295, 180, 341, 259, 107, 47, 345, 346, 347, - /* 630 */ 51, 56, 20, 148, 166, 56, 168, 316, 86, 121, - /* 640 */ 122, 2, 259, 68, 153, 226, 300, 8, 9, 367, - /* 650 */ 117, 12, 13, 14, 15, 16, 171, 312, 14, 314, - /* 660 */ 85, 193, 194, 84, 20, 300, 87, 39, 248, 8, - /* 670 */ 9, 279, 357, 12, 13, 14, 15, 16, 357, 287, - /* 680 */ 231, 232, 107, 300, 166, 370, 168, 297, 296, 374, - /* 690 */ 300, 370, 14, 15, 16, 374, 121, 122, 0, 214, - /* 700 */ 215, 216, 217, 218, 219, 220, 221, 222, 223, 176, - /* 710 */ 177, 193, 194, 180, 196, 197, 198, 199, 200, 201, - /* 720 */ 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, - /* 730 */ 212, 213, 8, 9, 273, 274, 12, 13, 14, 15, - /* 740 */ 16, 166, 329, 168, 273, 274, 48, 86, 98, 99, - /* 750 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 3, - /* 760 */ 110, 111, 112, 113, 114, 115, 353, 316, 193, 194, - /* 770 */ 259, 196, 197, 198, 199, 200, 201, 202, 203, 204, - /* 780 */ 205, 206, 207, 208, 209, 210, 211, 212, 213, 12, - /* 790 */ 13, 18, 20, 20, 97, 19, 316, 20, 259, 22, - /* 800 */ 27, 297, 259, 30, 300, 259, 259, 267, 357, 33, - /* 810 */ 33, 300, 35, 116, 117, 118, 119, 120, 278, 0, - /* 820 */ 47, 370, 49, 47, 51, 374, 259, 267, 52, 53, - /* 830 */ 54, 55, 56, 56, 287, 295, 287, 357, 278, 300, - /* 840 */ 267, 197, 295, 300, 96, 68, 300, 300, 267, 302, - /* 850 */ 370, 278, 303, 225, 374, 295, 288, 84, 35, 278, - /* 860 */ 84, 267, 85, 87, 275, 68, 277, 300, 295, 96, - /* 870 */ 280, 329, 278, 283, 327, 43, 295, 153, 331, 332, - /* 880 */ 333, 334, 335, 336, 107, 338, 44, 45, 341, 295, - /* 890 */ 259, 68, 345, 346, 0, 353, 120, 124, 121, 122, - /* 900 */ 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, - /* 910 */ 137, 138, 139, 140, 141, 142, 143, 144, 86, 146, - /* 920 */ 147, 259, 259, 2, 224, 225, 68, 18, 152, 8, - /* 930 */ 9, 300, 23, 12, 13, 14, 15, 16, 0, 42, - /* 940 */ 43, 153, 154, 166, 267, 168, 37, 38, 288, 173, - /* 950 */ 41, 175, 8, 9, 259, 278, 12, 13, 14, 15, - /* 960 */ 16, 259, 300, 300, 288, 259, 57, 58, 59, 197, - /* 970 */ 193, 194, 295, 196, 197, 198, 199, 200, 201, 202, - /* 980 */ 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - /* 990 */ 213, 97, 267, 287, 85, 300, 267, 0, 267, 243, - /* 1000 */ 43, 295, 300, 278, 35, 43, 300, 278, 302, 278, - /* 1010 */ 116, 117, 118, 119, 120, 89, 43, 267, 92, 22, - /* 1020 */ 295, 35, 316, 43, 295, 267, 295, 0, 278, 288, - /* 1030 */ 86, 61, 123, 327, 56, 97, 278, 331, 332, 333, - /* 1040 */ 334, 335, 336, 86, 338, 295, 259, 341, 86, 22, - /* 1050 */ 288, 345, 346, 295, 116, 117, 118, 119, 120, 86, - /* 1060 */ 12, 13, 267, 357, 43, 87, 86, 158, 159, 160, - /* 1070 */ 22, 0, 163, 278, 287, 289, 370, 267, 169, 43, - /* 1080 */ 374, 33, 295, 35, 43, 89, 300, 300, 92, 302, - /* 1090 */ 295, 182, 89, 22, 185, 92, 187, 188, 189, 190, - /* 1100 */ 191, 192, 46, 89, 56, 295, 92, 86, 43, 43, - /* 1110 */ 1, 2, 326, 327, 327, 43, 68, 288, 331, 332, - /* 1120 */ 333, 334, 335, 336, 338, 338, 316, 86, 341, 259, - /* 1130 */ 121, 122, 345, 346, 347, 226, 43, 168, 43, 43, - /* 1140 */ 43, 85, 43, 356, 43, 335, 43, 288, 320, 85, - /* 1150 */ 260, 86, 86, 276, 168, 107, 377, 287, 86, 95, - /* 1160 */ 350, 351, 352, 193, 354, 295, 368, 357, 268, 323, - /* 1170 */ 300, 364, 302, 287, 268, 299, 266, 330, 348, 86, - /* 1180 */ 370, 86, 86, 86, 374, 86, 316, 86, 355, 86, - /* 1190 */ 325, 371, 259, 371, 358, 371, 228, 327, 20, 267, - /* 1200 */ 47, 331, 332, 333, 334, 335, 336, 324, 338, 35, - /* 1210 */ 273, 164, 42, 318, 166, 307, 168, 267, 267, 307, - /* 1220 */ 287, 148, 305, 305, 20, 267, 267, 357, 295, 20, - /* 1230 */ 267, 271, 261, 300, 259, 302, 322, 261, 302, 20, - /* 1240 */ 370, 193, 194, 271, 374, 315, 20, 20, 317, 315, - /* 1250 */ 271, 308, 271, 205, 206, 207, 208, 209, 210, 211, - /* 1260 */ 327, 271, 287, 271, 331, 332, 333, 334, 335, 336, - /* 1270 */ 295, 338, 267, 271, 341, 300, 261, 302, 345, 346, - /* 1280 */ 347, 287, 287, 247, 267, 287, 287, 287, 287, 356, - /* 1290 */ 261, 287, 269, 287, 287, 287, 322, 259, 287, 174, - /* 1300 */ 269, 267, 327, 321, 267, 150, 331, 332, 333, 334, - /* 1310 */ 335, 336, 300, 338, 269, 302, 341, 233, 300, 309, - /* 1320 */ 345, 346, 347, 269, 300, 287, 300, 311, 300, 283, - /* 1330 */ 300, 356, 269, 295, 315, 295, 311, 295, 300, 20, - /* 1340 */ 302, 308, 234, 300, 240, 157, 363, 259, 363, 300, - /* 1350 */ 330, 300, 300, 300, 316, 311, 242, 366, 365, 241, - /* 1360 */ 229, 311, 225, 295, 259, 327, 20, 246, 244, 331, - /* 1370 */ 332, 333, 334, 335, 336, 287, 338, 249, 85, 85, - /* 1380 */ 325, 291, 300, 295, 277, 363, 329, 267, 300, 36, - /* 1390 */ 302, 269, 287, 261, 362, 357, 361, 262, 319, 360, - /* 1400 */ 295, 314, 257, 344, 281, 300, 270, 302, 370, 0, - /* 1410 */ 281, 281, 374, 0, 176, 327, 0, 0, 42, 331, - /* 1420 */ 332, 333, 334, 335, 336, 259, 338, 0, 76, 341, - /* 1430 */ 0, 373, 327, 345, 346, 373, 331, 332, 333, 334, - /* 1440 */ 335, 336, 337, 338, 339, 340, 259, 372, 378, 372, - /* 1450 */ 35, 373, 372, 287, 35, 186, 35, 35, 186, 0, - /* 1460 */ 35, 295, 186, 35, 0, 186, 300, 0, 302, 35, - /* 1470 */ 0, 22, 0, 0, 287, 35, 85, 171, 170, 168, - /* 1480 */ 166, 0, 295, 0, 162, 161, 0, 300, 46, 302, - /* 1490 */ 0, 0, 42, 327, 0, 0, 0, 331, 332, 333, - /* 1500 */ 334, 335, 336, 145, 338, 0, 0, 0, 0, 0, - /* 1510 */ 140, 35, 0, 140, 327, 259, 0, 0, 331, 332, - /* 1520 */ 333, 334, 335, 336, 0, 338, 0, 259, 341, 0, - /* 1530 */ 0, 0, 0, 346, 0, 0, 0, 259, 56, 42, - /* 1540 */ 0, 375, 376, 287, 0, 0, 0, 0, 292, 0, - /* 1550 */ 0, 295, 42, 39, 56, 287, 300, 0, 302, 0, - /* 1560 */ 292, 0, 0, 295, 22, 287, 0, 0, 300, 0, - /* 1570 */ 302, 0, 0, 295, 0, 0, 43, 14, 300, 14, - /* 1580 */ 302, 40, 39, 327, 0, 46, 0, 331, 332, 333, - /* 1590 */ 334, 335, 336, 259, 338, 327, 0, 46, 157, 331, - /* 1600 */ 332, 333, 334, 335, 336, 327, 338, 259, 0, 331, - /* 1610 */ 332, 333, 334, 335, 336, 39, 338, 0, 0, 0, - /* 1620 */ 62, 287, 0, 35, 47, 0, 39, 35, 47, 295, - /* 1630 */ 39, 0, 35, 0, 300, 287, 302, 47, 39, 39, - /* 1640 */ 35, 0, 47, 295, 0, 0, 0, 369, 300, 94, - /* 1650 */ 302, 35, 92, 0, 22, 35, 43, 43, 35, 35, - /* 1660 */ 22, 327, 0, 0, 22, 331, 332, 333, 334, 335, - /* 1670 */ 336, 22, 338, 0, 22, 327, 49, 0, 35, 331, - /* 1680 */ 332, 333, 334, 335, 336, 259, 338, 0, 340, 35, - /* 1690 */ 35, 0, 22, 0, 20, 35, 0, 259, 22, 172, - /* 1700 */ 0, 153, 0, 0, 150, 0, 153, 0, 0, 153, - /* 1710 */ 376, 85, 0, 287, 86, 85, 95, 39, 292, 155, - /* 1720 */ 85, 295, 85, 43, 151, 287, 300, 149, 302, 46, - /* 1730 */ 292, 230, 85, 295, 86, 85, 46, 86, 300, 224, - /* 1740 */ 302, 46, 86, 85, 43, 86, 85, 259, 230, 181, - /* 1750 */ 85, 85, 43, 327, 86, 86, 85, 331, 332, 333, - /* 1760 */ 334, 335, 336, 43, 338, 327, 43, 86, 46, 331, - /* 1770 */ 332, 333, 334, 335, 336, 287, 338, 46, 46, 43, - /* 1780 */ 86, 35, 35, 295, 35, 86, 35, 35, 300, 35, - /* 1790 */ 302, 2, 22, 43, 193, 85, 85, 259, 22, 86, - /* 1800 */ 230, 86, 85, 46, 86, 46, 85, 195, 35, 85, - /* 1810 */ 85, 259, 96, 86, 35, 327, 86, 35, 85, 331, - /* 1820 */ 332, 333, 334, 335, 336, 287, 338, 85, 35, 86, - /* 1830 */ 85, 35, 35, 295, 97, 109, 22, 109, 300, 287, - /* 1840 */ 302, 86, 86, 85, 109, 35, 85, 295, 109, 85, - /* 1850 */ 85, 85, 300, 259, 302, 22, 43, 62, 35, 61, - /* 1860 */ 68, 83, 43, 259, 35, 327, 35, 35, 22, 331, - /* 1870 */ 332, 333, 334, 335, 336, 35, 338, 22, 35, 327, - /* 1880 */ 35, 287, 35, 331, 332, 333, 334, 335, 336, 295, - /* 1890 */ 338, 287, 68, 35, 300, 35, 302, 35, 35, 295, - /* 1900 */ 35, 22, 35, 0, 300, 35, 302, 39, 47, 0, - /* 1910 */ 35, 47, 39, 0, 0, 35, 47, 39, 35, 47, - /* 1920 */ 39, 327, 0, 35, 35, 331, 332, 333, 334, 335, - /* 1930 */ 336, 327, 338, 0, 22, 331, 332, 333, 334, 335, - /* 1940 */ 336, 259, 338, 22, 21, 20, 22, 21, 379, 379, - /* 1950 */ 379, 379, 379, 379, 379, 379, 379, 259, 379, 379, - /* 1960 */ 379, 379, 379, 379, 379, 379, 379, 379, 379, 287, - /* 1970 */ 379, 379, 379, 379, 379, 379, 379, 295, 379, 379, - /* 1980 */ 379, 379, 300, 379, 302, 287, 379, 379, 379, 379, - /* 1990 */ 379, 379, 379, 295, 379, 379, 379, 379, 300, 379, - /* 2000 */ 302, 379, 379, 379, 379, 379, 379, 259, 379, 327, - /* 2010 */ 379, 379, 379, 331, 332, 333, 334, 335, 336, 259, - /* 2020 */ 338, 379, 379, 379, 379, 327, 379, 379, 379, 331, - /* 2030 */ 332, 333, 334, 335, 336, 287, 338, 379, 379, 379, - /* 2040 */ 379, 379, 379, 295, 379, 379, 379, 287, 300, 379, - /* 2050 */ 302, 379, 379, 379, 379, 295, 379, 379, 379, 379, - /* 2060 */ 300, 379, 302, 379, 379, 379, 379, 379, 379, 379, - /* 2070 */ 379, 259, 379, 379, 379, 327, 379, 379, 379, 331, - /* 2080 */ 332, 333, 334, 335, 336, 259, 338, 327, 267, 379, - /* 2090 */ 379, 331, 332, 333, 334, 335, 336, 379, 338, 287, - /* 2100 */ 379, 379, 379, 379, 379, 379, 379, 295, 379, 379, - /* 2110 */ 379, 379, 300, 287, 302, 379, 295, 379, 379, 379, - /* 2120 */ 379, 295, 379, 379, 379, 379, 300, 379, 302, 379, - /* 2130 */ 379, 379, 379, 379, 379, 379, 379, 316, 379, 327, - /* 2140 */ 379, 259, 379, 331, 332, 333, 334, 335, 336, 379, - /* 2150 */ 338, 259, 379, 327, 379, 379, 335, 331, 332, 333, - /* 2160 */ 334, 335, 336, 379, 338, 379, 379, 379, 379, 287, - /* 2170 */ 379, 350, 351, 352, 379, 354, 379, 295, 357, 287, - /* 2180 */ 379, 379, 300, 379, 302, 379, 379, 295, 379, 379, - /* 2190 */ 379, 370, 300, 379, 302, 374, 379, 379, 379, 379, - /* 2200 */ 379, 259, 379, 379, 379, 379, 379, 379, 379, 327, - /* 2210 */ 379, 379, 379, 331, 332, 333, 334, 335, 336, 327, - /* 2220 */ 338, 379, 379, 331, 332, 333, 334, 335, 336, 287, - /* 2230 */ 338, 379, 379, 379, 379, 379, 379, 295, 379, 379, - /* 2240 */ 379, 379, 300, 379, 302, 379, 379, 379, 379, 379, - /* 2250 */ 379, 379, 379, 259, 379, 379, 379, 379, 379, 379, - /* 2260 */ 379, 379, 379, 379, 379, 379, 379, 259, 379, 327, - /* 2270 */ 379, 379, 379, 331, 332, 333, 334, 335, 336, 259, - /* 2280 */ 338, 287, 379, 379, 379, 379, 379, 379, 379, 295, - /* 2290 */ 379, 379, 379, 379, 300, 287, 302, 379, 379, 379, - /* 2300 */ 379, 379, 379, 295, 379, 379, 379, 287, 300, 379, - /* 2310 */ 302, 379, 379, 379, 379, 295, 379, 379, 379, 379, - /* 2320 */ 300, 327, 302, 379, 379, 331, 332, 333, 334, 335, - /* 2330 */ 336, 259, 338, 379, 379, 327, 379, 379, 379, 331, - /* 2340 */ 332, 333, 334, 335, 336, 259, 338, 327, 379, 379, - /* 2350 */ 379, 331, 332, 333, 334, 335, 336, 379, 338, 287, - /* 2360 */ 379, 379, 379, 379, 379, 379, 379, 295, 379, 379, - /* 2370 */ 379, 379, 300, 287, 302, 379, 379, 379, 379, 379, - /* 2380 */ 379, 295, 379, 379, 379, 379, 300, 379, 302, 379, - /* 2390 */ 379, 379, 379, 379, 379, 379, 379, 379, 379, 327, - /* 2400 */ 379, 259, 379, 331, 332, 333, 334, 335, 336, 379, - /* 2410 */ 338, 379, 379, 327, 379, 379, 379, 331, 332, 333, - /* 2420 */ 334, 335, 336, 379, 338, 379, 379, 379, 379, 287, - /* 2430 */ 379, 379, 379, 379, 379, 379, 379, 295, 379, 379, - /* 2440 */ 379, 379, 300, 379, 302, 379, 379, 379, 379, 379, - /* 2450 */ 379, 379, 379, 379, 379, 379, 379, 379, 379, 379, - /* 2460 */ 379, 379, 379, 379, 379, 379, 379, 379, 379, 327, - /* 2470 */ 379, 379, 379, 331, 332, 333, 334, 335, 336, 379, - /* 2480 */ 338, + /* 210 */ 210, 211, 212, 213, 0, 301, 8, 9, 60, 20, + /* 220 */ 12, 13, 14, 15, 16, 20, 92, 227, 94, 95, + /* 230 */ 101, 97, 170, 121, 172, 101, 193, 317, 24, 25, + /* 240 */ 26, 27, 28, 29, 30, 31, 32, 157, 268, 120, + /* 250 */ 121, 122, 123, 124, 89, 193, 194, 123, 196, 197, + /* 260 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, + /* 270 */ 208, 209, 210, 211, 212, 213, 12, 13, 358, 236, + /* 280 */ 237, 238, 239, 240, 20, 305, 22, 317, 89, 177, + /* 290 */ 178, 371, 120, 181, 260, 375, 197, 33, 90, 35, + /* 300 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, + /* 310 */ 112, 4, 114, 115, 116, 117, 118, 119, 265, 288, + /* 320 */ 56, 268, 288, 155, 227, 61, 19, 296, 358, 162, + /* 330 */ 296, 296, 68, 20, 169, 301, 171, 303, 12, 13, + /* 340 */ 33, 371, 307, 89, 268, 375, 20, 89, 22, 268, + /* 350 */ 19, 179, 180, 89, 47, 260, 120, 121, 51, 33, + /* 360 */ 279, 35, 328, 56, 33, 334, 332, 333, 334, 335, + /* 370 */ 336, 337, 296, 339, 20, 111, 342, 296, 47, 288, + /* 380 */ 346, 347, 56, 52, 53, 54, 55, 56, 297, 125, + /* 390 */ 126, 68, 227, 22, 68, 88, 301, 56, 91, 260, + /* 400 */ 232, 233, 89, 12, 13, 14, 35, 290, 21, 260, + /* 410 */ 268, 20, 336, 22, 178, 89, 249, 181, 301, 88, + /* 420 */ 272, 34, 91, 36, 33, 20, 35, 351, 352, 353, + /* 430 */ 89, 355, 91, 285, 170, 14, 172, 111, 296, 68, + /* 440 */ 301, 20, 294, 89, 327, 328, 329, 56, 274, 275, + /* 450 */ 301, 125, 126, 1, 2, 124, 339, 193, 194, 68, + /* 460 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + /* 470 */ 206, 207, 208, 209, 210, 211, 212, 213, 336, 56, + /* 480 */ 89, 227, 111, 64, 65, 227, 56, 156, 0, 33, + /* 490 */ 71, 274, 275, 351, 352, 353, 170, 355, 172, 288, + /* 500 */ 81, 82, 111, 47, 3, 174, 295, 176, 52, 53, + /* 510 */ 54, 55, 56, 0, 91, 304, 125, 126, 88, 193, + /* 520 */ 194, 91, 196, 197, 198, 199, 200, 201, 202, 203, + /* 530 */ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + /* 540 */ 227, 170, 90, 172, 88, 0, 20, 91, 60, 270, + /* 550 */ 8, 9, 280, 227, 12, 13, 14, 15, 16, 0, + /* 560 */ 288, 170, 0, 172, 193, 194, 68, 317, 227, 297, + /* 570 */ 291, 296, 8, 9, 44, 45, 12, 13, 14, 15, + /* 580 */ 16, 227, 307, 100, 193, 194, 35, 196, 197, 198, + /* 590 */ 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, + /* 600 */ 209, 210, 211, 212, 213, 12, 13, 43, 358, 153, + /* 610 */ 154, 260, 156, 20, 101, 22, 160, 289, 197, 68, + /* 620 */ 303, 371, 60, 64, 65, 375, 33, 268, 35, 289, + /* 630 */ 71, 314, 176, 120, 121, 122, 123, 124, 279, 288, + /* 640 */ 81, 82, 39, 280, 268, 286, 101, 296, 260, 56, + /* 650 */ 14, 288, 301, 268, 303, 296, 20, 289, 77, 317, + /* 660 */ 297, 68, 317, 152, 279, 120, 121, 122, 123, 124, + /* 670 */ 8, 9, 296, 260, 12, 13, 14, 15, 16, 328, + /* 680 */ 260, 296, 89, 332, 333, 334, 335, 336, 337, 301, + /* 690 */ 339, 8, 9, 317, 321, 12, 13, 14, 15, 16, + /* 700 */ 358, 8, 9, 358, 111, 12, 13, 14, 15, 16, + /* 710 */ 129, 130, 336, 371, 301, 317, 371, 375, 125, 126, + /* 720 */ 375, 301, 313, 61, 315, 214, 260, 351, 352, 353, + /* 730 */ 268, 355, 12, 13, 358, 224, 260, 18, 330, 20, + /* 740 */ 20, 279, 22, 268, 61, 244, 27, 371, 286, 30, + /* 750 */ 289, 375, 90, 33, 279, 35, 358, 289, 296, 165, + /* 760 */ 98, 330, 354, 170, 0, 172, 47, 301, 49, 371, + /* 770 */ 51, 296, 260, 375, 260, 20, 56, 301, 184, 185, + /* 780 */ 313, 98, 315, 90, 260, 354, 193, 194, 68, 196, + /* 790 */ 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, + /* 800 */ 207, 208, 209, 210, 211, 212, 213, 88, 260, 89, + /* 810 */ 2, 288, 48, 301, 152, 301, 8, 9, 295, 100, + /* 820 */ 12, 13, 14, 15, 16, 301, 2, 304, 288, 226, + /* 830 */ 260, 111, 8, 9, 260, 152, 12, 13, 14, 15, + /* 840 */ 16, 276, 20, 278, 304, 125, 126, 128, 260, 301, + /* 850 */ 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, + /* 860 */ 141, 142, 143, 144, 145, 146, 147, 148, 260, 150, + /* 870 */ 151, 301, 101, 4, 260, 301, 214, 215, 216, 217, + /* 880 */ 218, 219, 220, 221, 222, 223, 224, 330, 298, 301, + /* 890 */ 170, 301, 172, 298, 123, 289, 301, 214, 215, 216, + /* 900 */ 217, 218, 219, 220, 221, 222, 223, 224, 260, 301, + /* 910 */ 260, 354, 157, 193, 194, 301, 196, 197, 198, 199, + /* 920 */ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + /* 930 */ 210, 211, 212, 213, 268, 18, 268, 268, 288, 35, + /* 940 */ 23, 268, 225, 226, 268, 279, 296, 279, 279, 301, + /* 950 */ 289, 301, 279, 303, 37, 38, 281, 43, 41, 284, + /* 960 */ 42, 43, 296, 0, 296, 296, 261, 317, 93, 296, + /* 970 */ 268, 96, 296, 0, 57, 58, 59, 290, 328, 0, + /* 980 */ 43, 279, 332, 333, 334, 335, 336, 337, 301, 339, + /* 990 */ 61, 93, 342, 317, 96, 22, 346, 347, 296, 12, + /* 1000 */ 13, 22, 268, 43, 90, 43, 89, 43, 358, 22, + /* 1010 */ 47, 0, 336, 279, 327, 328, 329, 157, 158, 197, + /* 1020 */ 33, 371, 35, 1, 2, 375, 339, 351, 352, 353, + /* 1030 */ 296, 355, 378, 22, 358, 268, 93, 290, 93, 96, + /* 1040 */ 43, 96, 260, 56, 127, 43, 279, 371, 301, 43, + /* 1050 */ 90, 375, 8, 9, 90, 68, 12, 13, 14, 15, + /* 1060 */ 16, 8, 9, 296, 43, 12, 13, 14, 15, 16, + /* 1070 */ 288, 268, 125, 126, 327, 328, 172, 277, 296, 162, + /* 1080 */ 163, 164, 279, 301, 167, 303, 339, 90, 43, 46, + /* 1090 */ 13, 369, 90, 35, 89, 269, 90, 228, 111, 296, + /* 1100 */ 183, 324, 43, 186, 99, 188, 189, 190, 191, 192, + /* 1110 */ 328, 90, 35, 43, 332, 333, 334, 335, 336, 337, + /* 1120 */ 268, 339, 193, 268, 342, 268, 268, 268, 346, 347, + /* 1130 */ 348, 279, 89, 35, 279, 90, 279, 279, 279, 13, + /* 1140 */ 43, 260, 360, 90, 227, 365, 269, 267, 296, 90, + /* 1150 */ 368, 296, 43, 296, 296, 296, 288, 170, 43, 172, + /* 1160 */ 90, 35, 300, 43, 331, 43, 68, 356, 349, 288, + /* 1170 */ 372, 372, 359, 372, 43, 229, 326, 296, 325, 47, + /* 1180 */ 193, 194, 301, 260, 303, 248, 168, 90, 42, 319, + /* 1190 */ 308, 20, 205, 206, 207, 208, 209, 210, 211, 90, + /* 1200 */ 268, 157, 268, 308, 152, 90, 306, 306, 246, 328, + /* 1210 */ 90, 288, 90, 332, 333, 334, 335, 336, 337, 296, + /* 1220 */ 339, 90, 268, 342, 301, 268, 303, 346, 347, 348, + /* 1230 */ 172, 20, 262, 268, 262, 20, 260, 20, 323, 272, + /* 1240 */ 272, 303, 316, 20, 316, 318, 272, 272, 20, 368, + /* 1250 */ 309, 328, 272, 260, 272, 332, 333, 334, 335, 336, + /* 1260 */ 337, 272, 339, 268, 288, 342, 262, 301, 175, 346, + /* 1270 */ 347, 348, 296, 288, 288, 262, 288, 301, 288, 303, + /* 1280 */ 357, 288, 288, 268, 288, 268, 288, 288, 288, 296, + /* 1290 */ 270, 288, 323, 322, 301, 288, 303, 270, 268, 316, + /* 1300 */ 234, 270, 301, 312, 328, 154, 296, 284, 332, 333, + /* 1310 */ 334, 335, 336, 337, 20, 339, 260, 303, 342, 310, + /* 1320 */ 301, 328, 346, 347, 348, 332, 333, 334, 335, 336, + /* 1330 */ 337, 270, 339, 357, 301, 342, 301, 312, 301, 346, + /* 1340 */ 347, 348, 270, 309, 288, 296, 235, 331, 301, 301, + /* 1350 */ 357, 312, 296, 312, 241, 301, 364, 301, 301, 303, + /* 1360 */ 161, 301, 243, 242, 230, 226, 260, 296, 326, 20, + /* 1370 */ 330, 247, 364, 317, 245, 250, 260, 89, 89, 367, + /* 1380 */ 292, 301, 278, 36, 328, 268, 263, 363, 332, 333, + /* 1390 */ 334, 335, 336, 337, 288, 339, 320, 270, 366, 361, + /* 1400 */ 364, 373, 296, 374, 288, 379, 262, 301, 362, 303, + /* 1410 */ 345, 315, 296, 271, 358, 282, 0, 301, 260, 303, + /* 1420 */ 282, 258, 282, 317, 374, 374, 0, 371, 373, 177, + /* 1430 */ 0, 375, 0, 42, 328, 373, 0, 35, 332, 333, + /* 1440 */ 334, 335, 336, 337, 328, 339, 288, 187, 332, 333, + /* 1450 */ 334, 335, 336, 337, 296, 339, 35, 35, 342, 301, + /* 1460 */ 35, 303, 346, 347, 358, 187, 0, 187, 35, 35, + /* 1470 */ 0, 187, 260, 35, 0, 22, 0, 371, 0, 35, + /* 1480 */ 172, 375, 170, 0, 260, 0, 328, 166, 0, 165, + /* 1490 */ 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, + /* 1500 */ 288, 0, 46, 0, 42, 0, 0, 0, 296, 149, + /* 1510 */ 0, 0, 288, 301, 0, 303, 0, 0, 144, 35, + /* 1520 */ 296, 0, 144, 0, 0, 301, 0, 303, 0, 0, + /* 1530 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 1540 */ 328, 260, 42, 0, 332, 333, 334, 335, 336, 337, + /* 1550 */ 0, 339, 328, 40, 56, 0, 332, 333, 334, 335, + /* 1560 */ 336, 337, 0, 339, 0, 260, 342, 22, 0, 288, + /* 1570 */ 0, 347, 0, 0, 293, 0, 0, 296, 56, 0, + /* 1580 */ 0, 39, 301, 260, 303, 14, 42, 46, 376, 377, + /* 1590 */ 43, 14, 46, 288, 0, 39, 0, 0, 293, 0, + /* 1600 */ 39, 296, 161, 0, 0, 0, 301, 0, 303, 328, + /* 1610 */ 62, 288, 0, 332, 333, 334, 335, 336, 337, 296, + /* 1620 */ 339, 35, 39, 0, 301, 47, 303, 35, 47, 39, + /* 1630 */ 0, 47, 39, 328, 0, 35, 35, 332, 333, 334, + /* 1640 */ 335, 336, 337, 0, 339, 260, 0, 39, 0, 47, + /* 1650 */ 0, 328, 98, 96, 22, 332, 333, 334, 335, 336, + /* 1660 */ 337, 35, 339, 260, 0, 43, 35, 43, 35, 22, + /* 1670 */ 35, 0, 0, 288, 22, 22, 49, 0, 22, 35, + /* 1680 */ 0, 296, 0, 0, 35, 22, 301, 20, 303, 35, + /* 1690 */ 0, 288, 35, 370, 0, 22, 0, 157, 173, 296, + /* 1700 */ 0, 0, 0, 154, 301, 0, 303, 89, 157, 157, + /* 1710 */ 90, 0, 0, 328, 89, 260, 153, 332, 333, 334, + /* 1720 */ 335, 336, 337, 39, 339, 159, 89, 89, 99, 155, + /* 1730 */ 43, 328, 46, 260, 89, 332, 333, 334, 335, 336, + /* 1740 */ 337, 182, 339, 288, 341, 90, 231, 89, 293, 90, + /* 1750 */ 90, 296, 43, 43, 89, 89, 301, 260, 303, 90, + /* 1760 */ 90, 288, 377, 89, 89, 46, 293, 46, 89, 296, + /* 1770 */ 43, 90, 46, 43, 301, 90, 303, 46, 90, 46, + /* 1780 */ 43, 90, 35, 328, 35, 288, 35, 332, 333, 334, + /* 1790 */ 335, 336, 337, 296, 339, 35, 231, 35, 301, 35, + /* 1800 */ 303, 328, 2, 22, 193, 332, 333, 334, 335, 336, + /* 1810 */ 337, 43, 339, 260, 225, 90, 231, 89, 89, 46, + /* 1820 */ 46, 22, 100, 195, 90, 328, 90, 260, 89, 332, + /* 1830 */ 333, 334, 335, 336, 337, 89, 339, 89, 35, 89, + /* 1840 */ 35, 288, 90, 89, 35, 90, 89, 35, 90, 296, + /* 1850 */ 89, 35, 35, 90, 301, 288, 303, 90, 89, 89, + /* 1860 */ 22, 89, 35, 296, 89, 89, 113, 101, 301, 260, + /* 1870 */ 303, 43, 113, 22, 35, 62, 61, 35, 113, 260, + /* 1880 */ 35, 328, 35, 35, 113, 332, 333, 334, 335, 336, + /* 1890 */ 337, 35, 339, 35, 68, 328, 43, 288, 87, 332, + /* 1900 */ 333, 334, 335, 336, 337, 296, 339, 288, 35, 35, + /* 1910 */ 301, 22, 303, 35, 22, 296, 35, 35, 68, 35, + /* 1920 */ 301, 260, 303, 35, 22, 0, 35, 0, 35, 35, + /* 1930 */ 35, 35, 47, 35, 47, 0, 39, 328, 39, 35, + /* 1940 */ 39, 332, 333, 334, 335, 336, 337, 328, 339, 288, + /* 1950 */ 47, 332, 333, 334, 335, 336, 337, 296, 339, 0, + /* 1960 */ 47, 35, 301, 39, 303, 0, 35, 35, 0, 22, + /* 1970 */ 21, 380, 22, 22, 260, 21, 20, 380, 380, 380, + /* 1980 */ 380, 380, 380, 380, 380, 380, 380, 380, 380, 328, + /* 1990 */ 380, 380, 260, 332, 333, 334, 335, 336, 337, 380, + /* 2000 */ 339, 380, 288, 380, 380, 380, 380, 380, 380, 380, + /* 2010 */ 296, 380, 380, 380, 380, 301, 380, 303, 380, 380, + /* 2020 */ 288, 380, 380, 380, 380, 380, 380, 380, 296, 380, + /* 2030 */ 380, 380, 380, 301, 380, 303, 380, 380, 380, 380, + /* 2040 */ 380, 380, 328, 380, 260, 380, 332, 333, 334, 335, + /* 2050 */ 336, 337, 380, 339, 260, 380, 380, 380, 380, 380, + /* 2060 */ 328, 380, 380, 380, 332, 333, 334, 335, 336, 337, + /* 2070 */ 260, 339, 288, 380, 380, 380, 380, 380, 380, 380, + /* 2080 */ 296, 380, 288, 380, 380, 301, 380, 303, 380, 380, + /* 2090 */ 296, 380, 380, 380, 380, 301, 380, 303, 288, 380, + /* 2100 */ 380, 380, 380, 380, 380, 380, 296, 380, 380, 380, + /* 2110 */ 380, 301, 328, 303, 380, 380, 332, 333, 334, 335, + /* 2120 */ 336, 337, 328, 339, 260, 380, 332, 333, 334, 335, + /* 2130 */ 336, 337, 380, 339, 380, 380, 380, 380, 328, 380, + /* 2140 */ 260, 380, 332, 333, 334, 335, 336, 337, 380, 339, + /* 2150 */ 260, 380, 288, 380, 380, 380, 380, 380, 380, 380, + /* 2160 */ 296, 380, 380, 380, 380, 301, 260, 303, 288, 380, + /* 2170 */ 380, 380, 380, 380, 380, 380, 296, 380, 288, 380, + /* 2180 */ 380, 301, 380, 303, 380, 380, 296, 380, 380, 380, + /* 2190 */ 380, 301, 328, 303, 288, 380, 332, 333, 334, 335, + /* 2200 */ 336, 337, 296, 339, 380, 380, 380, 301, 328, 303, + /* 2210 */ 380, 380, 332, 333, 334, 335, 336, 337, 328, 339, + /* 2220 */ 380, 380, 332, 333, 334, 335, 336, 337, 380, 339, + /* 2230 */ 380, 380, 380, 380, 328, 260, 380, 380, 332, 333, + /* 2240 */ 334, 335, 336, 337, 380, 339, 380, 380, 380, 380, + /* 2250 */ 380, 380, 380, 260, 380, 380, 380, 380, 380, 380, + /* 2260 */ 380, 380, 380, 288, 380, 380, 380, 380, 380, 380, + /* 2270 */ 380, 296, 380, 380, 380, 380, 301, 380, 303, 380, + /* 2280 */ 380, 288, 380, 380, 380, 380, 380, 380, 380, 296, + /* 2290 */ 380, 380, 380, 380, 301, 380, 303, 380, 380, 380, + /* 2300 */ 380, 380, 380, 328, 380, 260, 380, 332, 333, 334, + /* 2310 */ 335, 336, 337, 380, 339, 260, 380, 380, 380, 380, + /* 2320 */ 380, 328, 380, 380, 380, 332, 333, 334, 335, 336, + /* 2330 */ 337, 380, 339, 288, 380, 380, 380, 380, 380, 380, + /* 2340 */ 380, 296, 380, 288, 380, 380, 301, 380, 303, 380, + /* 2350 */ 380, 296, 380, 380, 380, 380, 301, 380, 303, 380, + /* 2360 */ 380, 380, 380, 380, 380, 380, 380, 380, 380, 380, + /* 2370 */ 380, 380, 380, 328, 380, 380, 380, 332, 333, 334, + /* 2380 */ 335, 336, 337, 328, 339, 380, 380, 332, 333, 334, + /* 2390 */ 335, 336, 337, 380, 339, }; -#define YY_SHIFT_COUNT (668) +#define YY_SHIFT_COUNT (665) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1933) +#define YY_SHIFT_MAX (1968) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 909, 0, 0, 57, 57, 259, 259, 259, 316, 316, - /* 10 */ 259, 259, 518, 575, 777, 575, 575, 575, 575, 575, - /* 20 */ 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, - /* 30 */ 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, - /* 40 */ 575, 575, 19, 19, 78, 78, 78, 1048, 1048, 54, - /* 50 */ 1048, 1048, 147, 419, 20, 204, 20, 208, 208, 115, - /* 60 */ 115, 98, 53, 20, 20, 208, 208, 208, 208, 208, - /* 70 */ 208, 208, 208, 208, 266, 208, 208, 208, 354, 377, - /* 80 */ 208, 208, 377, 411, 208, 377, 377, 377, 208, 416, - /* 90 */ 773, 227, 485, 485, 122, 468, 468, 468, 468, 468, - /* 100 */ 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, - /* 110 */ 468, 468, 468, 468, 303, 93, 53, 332, 332, 317, - /* 120 */ 538, 379, 404, 404, 404, 538, 612, 612, 354, 819, - /* 130 */ 819, 377, 377, 797, 797, 748, 858, 650, 650, 650, - /* 140 */ 650, 650, 650, 650, 776, 21, 420, 155, 150, 194, - /* 150 */ 533, 449, 351, 644, 86, 842, 386, 491, 700, 628, - /* 160 */ 700, 897, 756, 756, 756, 349, 772, 968, 1178, 1153, - /* 170 */ 1174, 1047, 1170, 1178, 1178, 1170, 1073, 1073, 1178, 1178, - /* 180 */ 1178, 1204, 1204, 1209, 266, 354, 266, 1219, 1226, 266, - /* 190 */ 1219, 266, 1227, 266, 266, 1178, 266, 1204, 377, 377, - /* 200 */ 377, 377, 377, 377, 377, 377, 377, 377, 377, 1178, - /* 210 */ 1204, 797, 1209, 416, 1125, 354, 416, 1178, 1178, 1219, - /* 220 */ 416, 1084, 797, 797, 797, 797, 1084, 797, 1155, 612, - /* 230 */ 1227, 416, 748, 416, 612, 1319, 797, 1108, 1084, 797, - /* 240 */ 797, 1108, 1084, 797, 797, 377, 1104, 1188, 1108, 1114, - /* 250 */ 1118, 1131, 968, 1137, 612, 1346, 1121, 1124, 1128, 1121, - /* 260 */ 1124, 1121, 1124, 1293, 1294, 797, 858, 1178, 416, 1353, - /* 270 */ 1204, 2481, 2481, 2481, 2481, 2481, 2481, 2481, 339, 134, - /* 280 */ 273, 579, 552, 465, 661, 639, 921, 724, 944, 894, - /* 290 */ 51, 51, 51, 51, 51, 51, 51, 51, 938, 697, - /* 300 */ 473, 473, 442, 91, 515, 2, 272, 13, 340, 24, - /* 310 */ 678, 678, 678, 678, 832, 360, 957, 926, 996, 1003, - /* 320 */ 1014, 997, 1027, 1071, 978, 788, 962, 973, 980, 1021, - /* 330 */ 1041, 1065, 1066, 1109, 1009, 32, 1036, 1072, 969, 986, - /* 340 */ 970, 1093, 1056, 1095, 1096, 1097, 1099, 1101, 1103, 1064, - /* 350 */ 823, 698, 1409, 1413, 1238, 1416, 1417, 1376, 1427, 1352, - /* 360 */ 1430, 1415, 1269, 1419, 1421, 1422, 1272, 1459, 1425, 1428, - /* 370 */ 1276, 1464, 1279, 1467, 1434, 1470, 1449, 1472, 1440, 1473, - /* 380 */ 1391, 1306, 1308, 1311, 1314, 1481, 1483, 1322, 1324, 1486, - /* 390 */ 1490, 1442, 1491, 1450, 1494, 1495, 1496, 1358, 1505, 1506, - /* 400 */ 1507, 1508, 1509, 1370, 1476, 1512, 1373, 1516, 1517, 1524, - /* 410 */ 1526, 1529, 1530, 1531, 1532, 1534, 1535, 1536, 1544, 1545, - /* 420 */ 1546, 1497, 1540, 1547, 1549, 1550, 1557, 1559, 1542, 1561, - /* 430 */ 1562, 1566, 1567, 1569, 1482, 1571, 1498, 1572, 1574, 1510, - /* 440 */ 1514, 1533, 1563, 1539, 1565, 1551, 1575, 1541, 1543, 1584, - /* 450 */ 1586, 1596, 1576, 1441, 1608, 1617, 1618, 1558, 1619, 1622, - /* 460 */ 1588, 1577, 1587, 1625, 1592, 1581, 1591, 1631, 1597, 1590, - /* 470 */ 1599, 1633, 1605, 1595, 1600, 1641, 1644, 1645, 1646, 1555, - /* 480 */ 1560, 1616, 1632, 1653, 1620, 1613, 1614, 1623, 1624, 1638, - /* 490 */ 1662, 1642, 1663, 1649, 1627, 1673, 1652, 1643, 1677, 1654, - /* 500 */ 1687, 1655, 1691, 1670, 1674, 1693, 1548, 1660, 1696, 1527, - /* 510 */ 1676, 1553, 1554, 1700, 1702, 1556, 1564, 1703, 1705, 1707, - /* 520 */ 1626, 1628, 1568, 1708, 1630, 1573, 1635, 1712, 1678, 1578, - /* 530 */ 1637, 1621, 1683, 1680, 1501, 1647, 1648, 1650, 1651, 1656, - /* 540 */ 1658, 1701, 1659, 1661, 1665, 1666, 1668, 1709, 1690, 1695, - /* 550 */ 1671, 1720, 1518, 1669, 1681, 1722, 1515, 1723, 1731, 1732, - /* 560 */ 1694, 1736, 1570, 1699, 1746, 1747, 1749, 1751, 1752, 1754, - /* 570 */ 1699, 1789, 1770, 1601, 1750, 1710, 1713, 1711, 1715, 1717, - /* 580 */ 1718, 1757, 1721, 1724, 1759, 1776, 1612, 1725, 1716, 1727, - /* 590 */ 1773, 1779, 1733, 1730, 1782, 1742, 1743, 1793, 1745, 1755, - /* 600 */ 1796, 1758, 1756, 1797, 1761, 1726, 1728, 1735, 1739, 1814, - /* 610 */ 1737, 1764, 1765, 1810, 1766, 1813, 1813, 1833, 1795, 1798, - /* 620 */ 1823, 1792, 1778, 1819, 1829, 1831, 1832, 1846, 1840, 1855, - /* 630 */ 1843, 1845, 1824, 1613, 1847, 1614, 1858, 1860, 1862, 1863, - /* 640 */ 1865, 1879, 1867, 1903, 1870, 1861, 1868, 1909, 1875, 1864, - /* 650 */ 1873, 1913, 1880, 1869, 1878, 1914, 1883, 1872, 1881, 1922, - /* 660 */ 1888, 1889, 1933, 1912, 1923, 1921, 1924, 1926, 1925, + /* 0 */ 917, 0, 0, 62, 62, 264, 264, 264, 326, 326, + /* 10 */ 264, 264, 391, 593, 720, 593, 593, 593, 593, 593, + /* 20 */ 593, 593, 593, 593, 593, 593, 593, 593, 593, 593, + /* 30 */ 593, 593, 593, 593, 593, 593, 593, 593, 593, 593, + /* 40 */ 593, 593, 313, 313, 199, 199, 199, 987, 987, 354, + /* 50 */ 987, 987, 165, 341, 254, 258, 254, 79, 79, 36, + /* 60 */ 36, 97, 18, 254, 254, 79, 79, 79, 79, 79, + /* 70 */ 79, 79, 79, 79, 82, 79, 79, 79, 170, 205, + /* 80 */ 79, 79, 205, 405, 79, 205, 205, 205, 79, 158, + /* 90 */ 719, 662, 683, 683, 108, 371, 371, 371, 371, 371, + /* 100 */ 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, + /* 110 */ 371, 371, 371, 371, 134, 419, 18, 636, 636, 488, + /* 120 */ 551, 562, 90, 90, 90, 551, 526, 526, 170, 16, + /* 130 */ 16, 205, 205, 323, 323, 483, 498, 198, 198, 198, + /* 140 */ 198, 198, 198, 198, 331, 21, 167, 559, 43, 50, + /* 150 */ 112, 168, 99, 421, 19, 530, 771, 755, 717, 603, + /* 160 */ 717, 918, 501, 501, 501, 869, 822, 946, 1132, 1018, + /* 170 */ 1146, 1171, 1171, 1146, 1052, 1052, 1171, 1171, 1171, 1211, + /* 180 */ 1211, 1215, 82, 170, 82, 1217, 1223, 82, 1217, 82, + /* 190 */ 1228, 82, 82, 1171, 82, 1211, 205, 205, 205, 205, + /* 200 */ 205, 205, 205, 205, 205, 205, 205, 1171, 1211, 323, + /* 210 */ 1215, 158, 1093, 170, 158, 1171, 1171, 1217, 158, 1066, + /* 220 */ 323, 323, 323, 323, 1066, 323, 1151, 526, 1228, 158, + /* 230 */ 483, 158, 526, 1294, 323, 1111, 1066, 323, 323, 1111, + /* 240 */ 1066, 323, 323, 205, 1113, 1199, 1111, 1119, 1121, 1134, + /* 250 */ 946, 1139, 526, 1349, 1124, 1129, 1125, 1124, 1129, 1124, + /* 260 */ 1129, 1288, 1289, 323, 498, 1171, 158, 1347, 1211, 2395, + /* 270 */ 2395, 2395, 2395, 2395, 2395, 2395, 83, 456, 214, 307, + /* 280 */ 208, 564, 693, 808, 824, 1044, 1053, 513, 542, 542, + /* 290 */ 542, 542, 542, 542, 542, 542, 545, 129, 13, 13, + /* 300 */ 236, 594, 430, 581, 387, 172, 452, 511, 106, 106, + /* 310 */ 106, 106, 914, 963, 875, 898, 943, 945, 973, 979, + /* 320 */ 1011, 423, 860, 960, 964, 997, 1002, 1021, 1045, 1059, + /* 330 */ 1022, 947, 962, 937, 1006, 904, 1058, 929, 1070, 1043, + /* 340 */ 1097, 1109, 1115, 1120, 1122, 1131, 1005, 1077, 1126, 1098, + /* 350 */ 764, 1416, 1426, 1252, 1430, 1432, 1391, 1436, 1402, 1260, + /* 360 */ 1421, 1422, 1425, 1278, 1466, 1433, 1434, 1280, 1470, 1284, + /* 370 */ 1478, 1438, 1474, 1453, 1476, 1444, 1308, 1312, 1483, 1485, + /* 380 */ 1321, 1324, 1488, 1501, 1456, 1503, 1462, 1505, 1506, 1507, + /* 390 */ 1360, 1510, 1511, 1514, 1516, 1517, 1374, 1484, 1521, 1378, + /* 400 */ 1523, 1524, 1526, 1528, 1529, 1530, 1531, 1532, 1533, 1534, + /* 410 */ 1535, 1536, 1537, 1538, 1500, 1539, 1543, 1550, 1562, 1564, + /* 420 */ 1570, 1545, 1568, 1572, 1573, 1575, 1576, 1498, 1555, 1522, + /* 430 */ 1579, 1580, 1544, 1542, 1547, 1571, 1541, 1577, 1546, 1594, + /* 440 */ 1513, 1556, 1596, 1597, 1599, 1561, 1441, 1603, 1604, 1605, + /* 450 */ 1548, 1607, 1612, 1586, 1578, 1583, 1623, 1592, 1581, 1590, + /* 460 */ 1630, 1600, 1584, 1593, 1634, 1601, 1602, 1608, 1643, 1646, + /* 470 */ 1648, 1650, 1554, 1557, 1626, 1632, 1664, 1631, 1622, 1624, + /* 480 */ 1633, 1635, 1647, 1671, 1652, 1672, 1653, 1627, 1677, 1656, + /* 490 */ 1644, 1680, 1649, 1682, 1654, 1683, 1663, 1667, 1690, 1540, + /* 500 */ 1657, 1694, 1525, 1673, 1551, 1549, 1696, 1700, 1552, 1566, + /* 510 */ 1701, 1702, 1705, 1618, 1620, 1559, 1711, 1625, 1574, 1637, + /* 520 */ 1712, 1684, 1563, 1638, 1629, 1686, 1687, 1515, 1645, 1655, + /* 530 */ 1658, 1659, 1660, 1665, 1709, 1669, 1666, 1674, 1675, 1670, + /* 540 */ 1710, 1719, 1721, 1679, 1727, 1565, 1681, 1685, 1726, 1589, + /* 550 */ 1730, 1731, 1733, 1688, 1737, 1585, 1691, 1747, 1749, 1751, + /* 560 */ 1760, 1762, 1764, 1691, 1800, 1781, 1611, 1768, 1728, 1725, + /* 570 */ 1729, 1734, 1739, 1736, 1773, 1746, 1748, 1774, 1799, 1628, + /* 580 */ 1750, 1722, 1752, 1803, 1805, 1754, 1755, 1809, 1757, 1758, + /* 590 */ 1812, 1761, 1763, 1816, 1769, 1767, 1817, 1770, 1753, 1759, + /* 600 */ 1765, 1771, 1838, 1766, 1772, 1775, 1827, 1776, 1828, 1828, + /* 610 */ 1851, 1813, 1815, 1839, 1842, 1845, 1847, 1848, 1856, 1858, + /* 620 */ 1826, 1811, 1853, 1873, 1874, 1889, 1878, 1892, 1881, 1882, + /* 630 */ 1850, 1622, 1884, 1624, 1888, 1891, 1893, 1894, 1902, 1895, + /* 640 */ 1925, 1896, 1885, 1897, 1927, 1898, 1887, 1899, 1935, 1904, + /* 650 */ 1903, 1901, 1959, 1926, 1913, 1924, 1965, 1931, 1932, 1968, + /* 660 */ 1947, 1949, 1950, 1951, 1954, 1956, }; -#define YY_REDUCE_COUNT (277) -#define YY_REDUCE_MIN (-294) -#define YY_REDUCE_MAX (2142) +#define YY_REDUCE_COUNT (275) +#define YY_REDUCE_MIN (-357) +#define YY_REDUCE_MAX (2055) static const short yy_reduce_ofst[] = { - /* 0 */ -254, -201, 706, 23, 282, 787, 933, 975, 870, 1038, - /* 10 */ 547, 1088, 1105, 1166, 1187, 1256, 1268, 1278, 1334, 1348, - /* 20 */ 1426, 1438, 1488, 1538, 1552, 1594, 1604, 1682, 1698, 1748, - /* 30 */ 1760, 1812, 1826, 1882, 1892, 1942, 1994, 2008, 2020, 2072, - /* 40 */ 2086, 2142, 810, 1821, -240, -263, -19, 207, 263, -277, - /* 50 */ 254, 786, -140, -79, 321, 451, 480, -267, 52, -260, - /* 60 */ -229, -274, -258, 237, 315, 67, 100, 277, 326, 560, - /* 70 */ 573, 581, 594, 677, -270, 725, 729, 731, -294, -272, - /* 80 */ 750, 758, -72, -257, 795, 260, 89, 392, 540, 280, - /* 90 */ -226, -219, -219, -219, -176, -118, 48, 63, 140, 192, - /* 100 */ 195, 346, 365, 383, 511, 539, 543, 546, 567, 631, - /* 110 */ 662, 663, 695, 702, 251, -247, -117, -210, -87, -262, - /* 120 */ 461, -152, -42, 413, 542, 471, -10, 196, 283, -65, - /* 130 */ 345, -126, 549, 390, 504, 590, 589, 568, 660, 676, - /* 140 */ 741, 762, 829, 859, 828, 890, 779, 877, 798, 900, - /* 150 */ 846, 807, 886, 886, 906, 910, 876, 847, 833, 833, - /* 160 */ 833, 830, 820, 822, 824, 836, 886, 865, 932, 883, - /* 170 */ 937, 895, 908, 950, 951, 912, 917, 918, 958, 959, - /* 180 */ 963, 971, 976, 914, 960, 936, 972, 930, 931, 979, - /* 190 */ 934, 981, 943, 990, 992, 1005, 1002, 1015, 994, 995, - /* 200 */ 998, 999, 1000, 1001, 1004, 1006, 1007, 1008, 1011, 1017, - /* 210 */ 1029, 1012, 974, 1023, 982, 1013, 1031, 1034, 1037, 1019, - /* 220 */ 1045, 1016, 1018, 1024, 1026, 1028, 1025, 1030, 1010, 1040, - /* 230 */ 1033, 1054, 1046, 1063, 1042, 1020, 1043, 983, 1044, 1049, - /* 240 */ 1051, 985, 1050, 1052, 1053, 886, 991, 993, 1022, 1032, - /* 250 */ 1035, 1039, 1055, 833, 1068, 1057, 1058, 1075, 1070, 1062, - /* 260 */ 1077, 1078, 1080, 1059, 1090, 1082, 1107, 1120, 1122, 1135, - /* 270 */ 1132, 1079, 1087, 1123, 1129, 1130, 1136, 1145, + /* 0 */ -80, -230, 650, 782, 881, 923, 976, 993, 1056, 1106, + /* 10 */ 34, 1116, 1158, 1212, 1224, 1281, 1305, 1323, 1385, 1403, + /* 20 */ 1455, 1473, 351, 1497, 1553, 1567, 1609, 1619, 1661, 1714, + /* 30 */ 1732, 1784, 1794, 1810, 1864, 1880, 1890, 1906, 1975, 1993, + /* 40 */ 2045, 2055, 376, 676, -259, 76, 142, 117, 687, -180, + /* 50 */ -284, 747, -30, 250, 342, 345, 398, 359, 462, -264, + /* 60 */ -256, -357, -240, -339, -244, 81, 385, 475, 666, 668, + /* 70 */ 669, 673, 702, 734, 148, 767, 803, 852, -280, -273, + /* 80 */ 855, 857, 211, 31, 858, 272, 523, 363, 859, -205, + /* 90 */ -20, -159, -159, -159, -171, -86, 95, 139, 149, 388, + /* 100 */ 413, 420, 466, 476, 512, 514, 524, 548, 570, 574, + /* 110 */ 588, 608, 614, 648, -233, -213, -298, -76, 53, -215, + /* 120 */ 174, 279, 408, 431, 557, 217, 35, 275, 317, 409, + /* 130 */ 467, 91, 540, 590, 595, 675, 565, 328, 340, 368, + /* 140 */ 461, 468, 606, 661, 373, 705, 654, 800, 722, 826, + /* 150 */ 777, 780, 868, 868, 877, 880, 862, 833, 811, 811, + /* 160 */ 811, 819, 798, 799, 801, 813, 868, 850, 853, 870, + /* 170 */ 882, 932, 934, 895, 900, 901, 954, 957, 965, 970, + /* 180 */ 972, 915, 967, 938, 968, 926, 927, 974, 928, 975, + /* 190 */ 941, 980, 982, 995, 989, 1004, 985, 986, 988, 990, + /* 200 */ 994, 996, 998, 999, 1000, 1003, 1007, 1015, 1013, 966, + /* 210 */ 969, 1020, 971, 1014, 1027, 1017, 1030, 983, 1031, 991, + /* 220 */ 1001, 1019, 1033, 1035, 1025, 1037, 1009, 1010, 1034, 1061, + /* 230 */ 1023, 1072, 1049, 1016, 1047, 992, 1039, 1048, 1054, 1008, + /* 240 */ 1041, 1057, 1060, 868, 1012, 1032, 1036, 1024, 1046, 1038, + /* 250 */ 1042, 811, 1071, 1040, 1029, 1028, 1026, 1050, 1055, 1051, + /* 260 */ 1062, 1065, 1088, 1080, 1104, 1117, 1127, 1123, 1144, 1076, + /* 270 */ 1096, 1133, 1138, 1140, 1142, 1163, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 10 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 20 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 30 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 40 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 50 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 60 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 70 */ 1458, 1458, 1458, 1458, 1532, 1458, 1458, 1458, 1458, 1458, - /* 80 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1530, - /* 90 */ 1682, 1458, 1862, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 100 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 110 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1532, - /* 120 */ 1458, 1530, 1874, 1874, 1874, 1458, 1458, 1458, 1458, 1726, - /* 130 */ 1726, 1458, 1458, 1458, 1458, 1624, 1458, 1458, 1458, 1458, - /* 140 */ 1458, 1458, 1458, 1458, 1718, 1458, 1943, 1458, 1458, 1458, - /* 150 */ 1724, 1897, 1458, 1458, 1458, 1458, 1577, 1889, 1866, 1880, - /* 160 */ 1867, 1864, 1928, 1928, 1928, 1883, 1458, 1893, 1458, 1458, - /* 170 */ 1458, 1710, 1687, 1458, 1458, 1687, 1684, 1684, 1458, 1458, - /* 180 */ 1458, 1458, 1458, 1458, 1532, 1458, 1532, 1458, 1458, 1532, - /* 190 */ 1458, 1532, 1458, 1532, 1532, 1458, 1532, 1458, 1458, 1458, - /* 200 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 210 */ 1458, 1458, 1458, 1530, 1720, 1458, 1530, 1458, 1458, 1458, - /* 220 */ 1530, 1902, 1458, 1458, 1458, 1458, 1902, 1458, 1458, 1458, - /* 230 */ 1458, 1530, 1458, 1530, 1458, 1458, 1458, 1904, 1902, 1458, - /* 240 */ 1458, 1904, 1902, 1458, 1458, 1458, 1916, 1912, 1904, 1920, - /* 250 */ 1918, 1895, 1893, 1880, 1458, 1458, 1934, 1930, 1946, 1934, - /* 260 */ 1930, 1934, 1930, 1458, 1593, 1458, 1458, 1458, 1530, 1490, - /* 270 */ 1458, 1712, 1726, 1627, 1627, 1627, 1533, 1463, 1458, 1458, - /* 280 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 290 */ 1799, 1915, 1914, 1838, 1837, 1836, 1834, 1798, 1458, 1589, - /* 300 */ 1797, 1796, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 310 */ 1790, 1791, 1789, 1788, 1458, 1458, 1458, 1458, 1458, 1458, - /* 320 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 330 */ 1458, 1458, 1458, 1863, 1458, 1931, 1935, 1458, 1458, 1458, - /* 340 */ 1458, 1458, 1773, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 350 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 360 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 370 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 380 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 390 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 400 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 410 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 420 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 430 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 440 */ 1458, 1495, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 450 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 460 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 470 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 480 */ 1458, 1458, 1458, 1458, 1458, 1561, 1560, 1458, 1458, 1458, - /* 490 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 500 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 510 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 520 */ 1458, 1458, 1458, 1730, 1458, 1458, 1458, 1458, 1458, 1458, - /* 530 */ 1458, 1458, 1458, 1896, 1458, 1458, 1458, 1458, 1458, 1458, - /* 540 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1773, - /* 550 */ 1458, 1913, 1458, 1873, 1869, 1458, 1458, 1865, 1772, 1458, - /* 560 */ 1458, 1929, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 570 */ 1458, 1858, 1458, 1458, 1831, 1816, 1458, 1458, 1458, 1458, - /* 580 */ 1458, 1458, 1458, 1458, 1458, 1458, 1784, 1458, 1458, 1458, - /* 590 */ 1458, 1458, 1621, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 600 */ 1458, 1458, 1458, 1458, 1458, 1606, 1604, 1603, 1602, 1458, - /* 610 */ 1599, 1458, 1458, 1458, 1458, 1630, 1629, 1458, 1458, 1458, - /* 620 */ 1458, 1458, 1458, 1553, 1458, 1458, 1458, 1458, 1458, 1458, - /* 630 */ 1458, 1458, 1458, 1544, 1458, 1543, 1458, 1458, 1458, 1458, - /* 640 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 650 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, - /* 660 */ 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, 1458, + /* 0 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 10 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 20 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 30 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 40 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 50 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 60 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 70 */ 1465, 1465, 1465, 1465, 1539, 1465, 1465, 1465, 1465, 1465, + /* 80 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1537, + /* 90 */ 1695, 1465, 1873, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 100 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 110 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1539, + /* 120 */ 1465, 1537, 1885, 1885, 1885, 1465, 1465, 1465, 1465, 1738, + /* 130 */ 1738, 1465, 1465, 1465, 1465, 1637, 1465, 1465, 1465, 1465, + /* 140 */ 1465, 1465, 1465, 1465, 1730, 1465, 1954, 1465, 1465, 1465, + /* 150 */ 1736, 1908, 1465, 1465, 1465, 1465, 1590, 1900, 1877, 1891, + /* 160 */ 1878, 1875, 1939, 1939, 1939, 1894, 1465, 1904, 1465, 1723, + /* 170 */ 1700, 1465, 1465, 1700, 1697, 1697, 1465, 1465, 1465, 1465, + /* 180 */ 1465, 1465, 1539, 1465, 1539, 1465, 1465, 1539, 1465, 1539, + /* 190 */ 1465, 1539, 1539, 1465, 1539, 1465, 1465, 1465, 1465, 1465, + /* 200 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 210 */ 1465, 1537, 1732, 1465, 1537, 1465, 1465, 1465, 1537, 1913, + /* 220 */ 1465, 1465, 1465, 1465, 1913, 1465, 1465, 1465, 1465, 1537, + /* 230 */ 1465, 1537, 1465, 1465, 1465, 1915, 1913, 1465, 1465, 1915, + /* 240 */ 1913, 1465, 1465, 1465, 1927, 1923, 1915, 1931, 1929, 1906, + /* 250 */ 1904, 1891, 1465, 1465, 1945, 1941, 1957, 1945, 1941, 1945, + /* 260 */ 1941, 1465, 1606, 1465, 1465, 1465, 1537, 1497, 1465, 1725, + /* 270 */ 1738, 1640, 1640, 1640, 1540, 1470, 1465, 1465, 1465, 1465, + /* 280 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1810, 1926, + /* 290 */ 1925, 1849, 1848, 1847, 1845, 1809, 1465, 1602, 1808, 1807, + /* 300 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1801, 1802, + /* 310 */ 1800, 1799, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 320 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 330 */ 1874, 1465, 1942, 1946, 1465, 1465, 1465, 1465, 1465, 1784, + /* 340 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 350 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 360 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 370 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 380 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 390 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 400 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 410 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 420 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 430 */ 1465, 1465, 1465, 1465, 1502, 1465, 1465, 1465, 1465, 1465, + /* 440 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 450 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 460 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 470 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1574, 1573, + /* 480 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 490 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 500 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 510 */ 1465, 1465, 1465, 1465, 1465, 1465, 1742, 1465, 1465, 1465, + /* 520 */ 1465, 1465, 1465, 1465, 1465, 1465, 1907, 1465, 1465, 1465, + /* 530 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 540 */ 1465, 1465, 1784, 1465, 1924, 1465, 1884, 1880, 1465, 1465, + /* 550 */ 1876, 1783, 1465, 1465, 1940, 1465, 1465, 1465, 1465, 1465, + /* 560 */ 1465, 1465, 1465, 1465, 1869, 1465, 1465, 1842, 1827, 1465, + /* 570 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1795, + /* 580 */ 1465, 1465, 1465, 1465, 1465, 1634, 1465, 1465, 1465, 1465, + /* 590 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1619, 1617, + /* 600 */ 1616, 1615, 1465, 1612, 1465, 1465, 1465, 1465, 1643, 1642, + /* 610 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 620 */ 1465, 1465, 1558, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 630 */ 1465, 1550, 1465, 1549, 1465, 1465, 1465, 1465, 1465, 1465, + /* 640 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 650 */ 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, 1465, + /* 660 */ 1465, 1465, 1465, 1465, 1465, 1465, }; /********** End of lemon-generated parsing tables *****************************/ @@ -980,7 +962,6 @@ static const YYCODETYPE yyFallback[] = { 0, /* COMP => nothing */ 0, /* DURATION => nothing */ 0, /* NK_VARIABLE => nothing */ - 0, /* FSYNC => nothing */ 0, /* MAXROWS => nothing */ 0, /* MINROWS => nothing */ 0, /* KEEP => nothing */ @@ -989,11 +970,16 @@ static const YYCODETYPE yyFallback[] = { 0, /* PRECISION => nothing */ 0, /* REPLICA => nothing */ 0, /* STRICT => nothing */ - 0, /* WAL => nothing */ 0, /* VGROUPS => nothing */ 0, /* SINGLE_STABLE => nothing */ 0, /* RETENTIONS => nothing */ 0, /* SCHEMALESS => nothing */ + 0, /* WAL_LEVEL => nothing */ + 0, /* WAL_FSYNC_PERIOD => nothing */ + 0, /* WAL_RETENTION_PERIOD => nothing */ + 0, /* WAL_RETENTION_SIZE => nothing */ + 0, /* WAL_ROLL_PERIOD => nothing */ + 0, /* WAL_SEGMENT_SIZE => nothing */ 0, /* NK_COLON => nothing */ 0, /* TABLE => nothing */ 0, /* NK_LP => nothing */ @@ -1080,9 +1066,6 @@ static const YYCODETYPE yyFallback[] = { 0, /* NK_BOOL => nothing */ 0, /* RATIO => nothing */ 0, /* NK_FLOAT => nothing */ - 0, /* COMPACT => nothing */ - 0, /* VNODES => nothing */ - 0, /* IN => nothing */ 0, /* OUTPUTTYPE => nothing */ 0, /* AGGREGATE => nothing */ 0, /* BUFSIZE => nothing */ @@ -1101,7 +1084,6 @@ static const YYCODETYPE yyFallback[] = { 0, /* MERGE => nothing */ 0, /* REDISTRIBUTE => nothing */ 0, /* SPLIT => nothing */ - 0, /* SYNCDB => nothing */ 0, /* DELETE => nothing */ 0, /* INSERT => nothing */ 0, /* NULL => nothing */ @@ -1135,6 +1117,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* MATCH => nothing */ 0, /* NMATCH => nothing */ 0, /* CONTAINS => nothing */ + 0, /* IN => nothing */ 0, /* JOIN => nothing */ 0, /* INNER => nothing */ 0, /* SELECT => nothing */ @@ -1162,11 +1145,11 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ID => nothing */ - 250, /* NK_BITNOT => ID */ - 250, /* VALUES => ID */ - 250, /* IMPORT => ID */ - 250, /* NK_SEMI => ID */ - 250, /* FILE => ID */ + 251, /* NK_BITNOT => ID */ + 251, /* VALUES => ID */ + 251, /* IMPORT => ID */ + 251, /* NK_SEMI => ID */ + 251, /* FILE => ID */ }; #endif /* YYFALLBACK */ @@ -1323,128 +1306,128 @@ static const char *const yyTokenName[] = { /* 66 */ "COMP", /* 67 */ "DURATION", /* 68 */ "NK_VARIABLE", - /* 69 */ "FSYNC", - /* 70 */ "MAXROWS", - /* 71 */ "MINROWS", - /* 72 */ "KEEP", - /* 73 */ "PAGES", - /* 74 */ "PAGESIZE", - /* 75 */ "PRECISION", - /* 76 */ "REPLICA", - /* 77 */ "STRICT", - /* 78 */ "WAL", - /* 79 */ "VGROUPS", - /* 80 */ "SINGLE_STABLE", - /* 81 */ "RETENTIONS", - /* 82 */ "SCHEMALESS", - /* 83 */ "NK_COLON", - /* 84 */ "TABLE", - /* 85 */ "NK_LP", - /* 86 */ "NK_RP", - /* 87 */ "STABLE", - /* 88 */ "ADD", - /* 89 */ "COLUMN", - /* 90 */ "MODIFY", - /* 91 */ "RENAME", - /* 92 */ "TAG", - /* 93 */ "SET", - /* 94 */ "NK_EQ", - /* 95 */ "USING", - /* 96 */ "TAGS", - /* 97 */ "COMMENT", - /* 98 */ "BOOL", - /* 99 */ "TINYINT", - /* 100 */ "SMALLINT", - /* 101 */ "INT", - /* 102 */ "INTEGER", - /* 103 */ "BIGINT", - /* 104 */ "FLOAT", - /* 105 */ "DOUBLE", - /* 106 */ "BINARY", - /* 107 */ "TIMESTAMP", - /* 108 */ "NCHAR", - /* 109 */ "UNSIGNED", - /* 110 */ "JSON", - /* 111 */ "VARCHAR", - /* 112 */ "MEDIUMBLOB", - /* 113 */ "BLOB", - /* 114 */ "VARBINARY", - /* 115 */ "DECIMAL", - /* 116 */ "MAX_DELAY", - /* 117 */ "WATERMARK", - /* 118 */ "ROLLUP", - /* 119 */ "TTL", - /* 120 */ "SMA", - /* 121 */ "FIRST", - /* 122 */ "LAST", - /* 123 */ "SHOW", - /* 124 */ "DATABASES", - /* 125 */ "TABLES", - /* 126 */ "STABLES", - /* 127 */ "MNODES", - /* 128 */ "MODULES", - /* 129 */ "QNODES", - /* 130 */ "FUNCTIONS", - /* 131 */ "INDEXES", - /* 132 */ "ACCOUNTS", - /* 133 */ "APPS", - /* 134 */ "CONNECTIONS", - /* 135 */ "LICENCE", - /* 136 */ "GRANTS", - /* 137 */ "QUERIES", - /* 138 */ "SCORES", - /* 139 */ "TOPICS", - /* 140 */ "VARIABLES", - /* 141 */ "BNODES", - /* 142 */ "SNODES", - /* 143 */ "CLUSTER", - /* 144 */ "TRANSACTIONS", - /* 145 */ "DISTRIBUTED", - /* 146 */ "CONSUMERS", - /* 147 */ "SUBSCRIPTIONS", - /* 148 */ "LIKE", - /* 149 */ "INDEX", - /* 150 */ "FUNCTION", - /* 151 */ "INTERVAL", - /* 152 */ "TOPIC", - /* 153 */ "AS", - /* 154 */ "WITH", - /* 155 */ "META", - /* 156 */ "CONSUMER", - /* 157 */ "GROUP", - /* 158 */ "DESC", - /* 159 */ "DESCRIBE", - /* 160 */ "RESET", - /* 161 */ "QUERY", - /* 162 */ "CACHE", - /* 163 */ "EXPLAIN", - /* 164 */ "ANALYZE", - /* 165 */ "VERBOSE", - /* 166 */ "NK_BOOL", - /* 167 */ "RATIO", - /* 168 */ "NK_FLOAT", - /* 169 */ "COMPACT", - /* 170 */ "VNODES", - /* 171 */ "IN", - /* 172 */ "OUTPUTTYPE", - /* 173 */ "AGGREGATE", - /* 174 */ "BUFSIZE", - /* 175 */ "STREAM", - /* 176 */ "INTO", - /* 177 */ "TRIGGER", - /* 178 */ "AT_ONCE", - /* 179 */ "WINDOW_CLOSE", - /* 180 */ "IGNORE", - /* 181 */ "EXPIRED", - /* 182 */ "KILL", - /* 183 */ "CONNECTION", - /* 184 */ "TRANSACTION", - /* 185 */ "BALANCE", - /* 186 */ "VGROUP", - /* 187 */ "MERGE", - /* 188 */ "REDISTRIBUTE", - /* 189 */ "SPLIT", - /* 190 */ "SYNCDB", + /* 69 */ "MAXROWS", + /* 70 */ "MINROWS", + /* 71 */ "KEEP", + /* 72 */ "PAGES", + /* 73 */ "PAGESIZE", + /* 74 */ "PRECISION", + /* 75 */ "REPLICA", + /* 76 */ "STRICT", + /* 77 */ "VGROUPS", + /* 78 */ "SINGLE_STABLE", + /* 79 */ "RETENTIONS", + /* 80 */ "SCHEMALESS", + /* 81 */ "WAL_LEVEL", + /* 82 */ "WAL_FSYNC_PERIOD", + /* 83 */ "WAL_RETENTION_PERIOD", + /* 84 */ "WAL_RETENTION_SIZE", + /* 85 */ "WAL_ROLL_PERIOD", + /* 86 */ "WAL_SEGMENT_SIZE", + /* 87 */ "NK_COLON", + /* 88 */ "TABLE", + /* 89 */ "NK_LP", + /* 90 */ "NK_RP", + /* 91 */ "STABLE", + /* 92 */ "ADD", + /* 93 */ "COLUMN", + /* 94 */ "MODIFY", + /* 95 */ "RENAME", + /* 96 */ "TAG", + /* 97 */ "SET", + /* 98 */ "NK_EQ", + /* 99 */ "USING", + /* 100 */ "TAGS", + /* 101 */ "COMMENT", + /* 102 */ "BOOL", + /* 103 */ "TINYINT", + /* 104 */ "SMALLINT", + /* 105 */ "INT", + /* 106 */ "INTEGER", + /* 107 */ "BIGINT", + /* 108 */ "FLOAT", + /* 109 */ "DOUBLE", + /* 110 */ "BINARY", + /* 111 */ "TIMESTAMP", + /* 112 */ "NCHAR", + /* 113 */ "UNSIGNED", + /* 114 */ "JSON", + /* 115 */ "VARCHAR", + /* 116 */ "MEDIUMBLOB", + /* 117 */ "BLOB", + /* 118 */ "VARBINARY", + /* 119 */ "DECIMAL", + /* 120 */ "MAX_DELAY", + /* 121 */ "WATERMARK", + /* 122 */ "ROLLUP", + /* 123 */ "TTL", + /* 124 */ "SMA", + /* 125 */ "FIRST", + /* 126 */ "LAST", + /* 127 */ "SHOW", + /* 128 */ "DATABASES", + /* 129 */ "TABLES", + /* 130 */ "STABLES", + /* 131 */ "MNODES", + /* 132 */ "MODULES", + /* 133 */ "QNODES", + /* 134 */ "FUNCTIONS", + /* 135 */ "INDEXES", + /* 136 */ "ACCOUNTS", + /* 137 */ "APPS", + /* 138 */ "CONNECTIONS", + /* 139 */ "LICENCE", + /* 140 */ "GRANTS", + /* 141 */ "QUERIES", + /* 142 */ "SCORES", + /* 143 */ "TOPICS", + /* 144 */ "VARIABLES", + /* 145 */ "BNODES", + /* 146 */ "SNODES", + /* 147 */ "CLUSTER", + /* 148 */ "TRANSACTIONS", + /* 149 */ "DISTRIBUTED", + /* 150 */ "CONSUMERS", + /* 151 */ "SUBSCRIPTIONS", + /* 152 */ "LIKE", + /* 153 */ "INDEX", + /* 154 */ "FUNCTION", + /* 155 */ "INTERVAL", + /* 156 */ "TOPIC", + /* 157 */ "AS", + /* 158 */ "WITH", + /* 159 */ "META", + /* 160 */ "CONSUMER", + /* 161 */ "GROUP", + /* 162 */ "DESC", + /* 163 */ "DESCRIBE", + /* 164 */ "RESET", + /* 165 */ "QUERY", + /* 166 */ "CACHE", + /* 167 */ "EXPLAIN", + /* 168 */ "ANALYZE", + /* 169 */ "VERBOSE", + /* 170 */ "NK_BOOL", + /* 171 */ "RATIO", + /* 172 */ "NK_FLOAT", + /* 173 */ "OUTPUTTYPE", + /* 174 */ "AGGREGATE", + /* 175 */ "BUFSIZE", + /* 176 */ "STREAM", + /* 177 */ "INTO", + /* 178 */ "TRIGGER", + /* 179 */ "AT_ONCE", + /* 180 */ "WINDOW_CLOSE", + /* 181 */ "IGNORE", + /* 182 */ "EXPIRED", + /* 183 */ "KILL", + /* 184 */ "CONNECTION", + /* 185 */ "TRANSACTION", + /* 186 */ "BALANCE", + /* 187 */ "VGROUP", + /* 188 */ "MERGE", + /* 189 */ "REDISTRIBUTE", + /* 190 */ "SPLIT", /* 191 */ "DELETE", /* 192 */ "INSERT", /* 193 */ "NULL", @@ -1478,161 +1461,162 @@ static const char *const yyTokenName[] = { /* 221 */ "MATCH", /* 222 */ "NMATCH", /* 223 */ "CONTAINS", - /* 224 */ "JOIN", - /* 225 */ "INNER", - /* 226 */ "SELECT", - /* 227 */ "DISTINCT", - /* 228 */ "WHERE", - /* 229 */ "PARTITION", - /* 230 */ "BY", - /* 231 */ "SESSION", - /* 232 */ "STATE_WINDOW", - /* 233 */ "SLIDING", - /* 234 */ "FILL", - /* 235 */ "VALUE", - /* 236 */ "NONE", - /* 237 */ "PREV", - /* 238 */ "LINEAR", - /* 239 */ "NEXT", - /* 240 */ "HAVING", - /* 241 */ "RANGE", - /* 242 */ "EVERY", - /* 243 */ "ORDER", - /* 244 */ "SLIMIT", - /* 245 */ "SOFFSET", - /* 246 */ "LIMIT", - /* 247 */ "OFFSET", - /* 248 */ "ASC", - /* 249 */ "NULLS", - /* 250 */ "ID", - /* 251 */ "NK_BITNOT", - /* 252 */ "VALUES", - /* 253 */ "IMPORT", - /* 254 */ "NK_SEMI", - /* 255 */ "FILE", - /* 256 */ "cmd", - /* 257 */ "account_options", - /* 258 */ "alter_account_options", - /* 259 */ "literal", - /* 260 */ "alter_account_option", - /* 261 */ "user_name", - /* 262 */ "sysinfo_opt", - /* 263 */ "privileges", - /* 264 */ "priv_level", - /* 265 */ "priv_type_list", - /* 266 */ "priv_type", - /* 267 */ "db_name", - /* 268 */ "dnode_endpoint", - /* 269 */ "not_exists_opt", - /* 270 */ "db_options", - /* 271 */ "exists_opt", - /* 272 */ "alter_db_options", - /* 273 */ "integer_list", - /* 274 */ "variable_list", - /* 275 */ "retention_list", - /* 276 */ "alter_db_option", - /* 277 */ "retention", - /* 278 */ "full_table_name", - /* 279 */ "column_def_list", - /* 280 */ "tags_def_opt", - /* 281 */ "table_options", - /* 282 */ "multi_create_clause", - /* 283 */ "tags_def", - /* 284 */ "multi_drop_clause", - /* 285 */ "alter_table_clause", - /* 286 */ "alter_table_options", - /* 287 */ "column_name", - /* 288 */ "type_name", - /* 289 */ "signed_literal", - /* 290 */ "create_subtable_clause", - /* 291 */ "specific_cols_opt", - /* 292 */ "expression_list", - /* 293 */ "drop_table_clause", - /* 294 */ "col_name_list", - /* 295 */ "table_name", - /* 296 */ "column_def", - /* 297 */ "duration_list", - /* 298 */ "rollup_func_list", - /* 299 */ "alter_table_option", - /* 300 */ "duration_literal", - /* 301 */ "rollup_func_name", - /* 302 */ "function_name", - /* 303 */ "col_name", - /* 304 */ "db_name_cond_opt", - /* 305 */ "like_pattern_opt", - /* 306 */ "table_name_cond", - /* 307 */ "from_db_opt", - /* 308 */ "index_name", - /* 309 */ "index_options", - /* 310 */ "func_list", - /* 311 */ "sliding_opt", - /* 312 */ "sma_stream_opt", - /* 313 */ "func", - /* 314 */ "stream_options", - /* 315 */ "topic_name", - /* 316 */ "query_expression", - /* 317 */ "cgroup_name", - /* 318 */ "analyze_opt", - /* 319 */ "explain_options", - /* 320 */ "agg_func_opt", - /* 321 */ "bufsize_opt", - /* 322 */ "stream_name", - /* 323 */ "into_opt", - /* 324 */ "dnode_list", - /* 325 */ "where_clause_opt", - /* 326 */ "signed", - /* 327 */ "literal_func", - /* 328 */ "literal_list", - /* 329 */ "table_alias", - /* 330 */ "column_alias", - /* 331 */ "expression", - /* 332 */ "pseudo_column", - /* 333 */ "column_reference", - /* 334 */ "function_expression", - /* 335 */ "subquery", - /* 336 */ "star_func", - /* 337 */ "star_func_para_list", - /* 338 */ "noarg_func", - /* 339 */ "other_para_list", - /* 340 */ "star_func_para", - /* 341 */ "predicate", - /* 342 */ "compare_op", - /* 343 */ "in_op", - /* 344 */ "in_predicate_value", - /* 345 */ "boolean_value_expression", - /* 346 */ "boolean_primary", - /* 347 */ "common_expression", - /* 348 */ "from_clause_opt", - /* 349 */ "table_reference_list", - /* 350 */ "table_reference", - /* 351 */ "table_primary", - /* 352 */ "joined_table", - /* 353 */ "alias_opt", - /* 354 */ "parenthesized_joined_table", - /* 355 */ "join_type", - /* 356 */ "search_condition", - /* 357 */ "query_specification", - /* 358 */ "set_quantifier_opt", - /* 359 */ "select_list", - /* 360 */ "partition_by_clause_opt", - /* 361 */ "range_opt", - /* 362 */ "every_opt", - /* 363 */ "fill_opt", - /* 364 */ "twindow_clause_opt", - /* 365 */ "group_by_clause_opt", - /* 366 */ "having_clause_opt", - /* 367 */ "select_item", - /* 368 */ "fill_mode", - /* 369 */ "group_by_list", - /* 370 */ "query_expression_body", - /* 371 */ "order_by_clause_opt", - /* 372 */ "slimit_clause_opt", - /* 373 */ "limit_clause_opt", - /* 374 */ "query_primary", - /* 375 */ "sort_specification_list", - /* 376 */ "sort_specification", - /* 377 */ "ordering_specification_opt", - /* 378 */ "null_ordering_opt", + /* 224 */ "IN", + /* 225 */ "JOIN", + /* 226 */ "INNER", + /* 227 */ "SELECT", + /* 228 */ "DISTINCT", + /* 229 */ "WHERE", + /* 230 */ "PARTITION", + /* 231 */ "BY", + /* 232 */ "SESSION", + /* 233 */ "STATE_WINDOW", + /* 234 */ "SLIDING", + /* 235 */ "FILL", + /* 236 */ "VALUE", + /* 237 */ "NONE", + /* 238 */ "PREV", + /* 239 */ "LINEAR", + /* 240 */ "NEXT", + /* 241 */ "HAVING", + /* 242 */ "RANGE", + /* 243 */ "EVERY", + /* 244 */ "ORDER", + /* 245 */ "SLIMIT", + /* 246 */ "SOFFSET", + /* 247 */ "LIMIT", + /* 248 */ "OFFSET", + /* 249 */ "ASC", + /* 250 */ "NULLS", + /* 251 */ "ID", + /* 252 */ "NK_BITNOT", + /* 253 */ "VALUES", + /* 254 */ "IMPORT", + /* 255 */ "NK_SEMI", + /* 256 */ "FILE", + /* 257 */ "cmd", + /* 258 */ "account_options", + /* 259 */ "alter_account_options", + /* 260 */ "literal", + /* 261 */ "alter_account_option", + /* 262 */ "user_name", + /* 263 */ "sysinfo_opt", + /* 264 */ "privileges", + /* 265 */ "priv_level", + /* 266 */ "priv_type_list", + /* 267 */ "priv_type", + /* 268 */ "db_name", + /* 269 */ "dnode_endpoint", + /* 270 */ "not_exists_opt", + /* 271 */ "db_options", + /* 272 */ "exists_opt", + /* 273 */ "alter_db_options", + /* 274 */ "integer_list", + /* 275 */ "variable_list", + /* 276 */ "retention_list", + /* 277 */ "alter_db_option", + /* 278 */ "retention", + /* 279 */ "full_table_name", + /* 280 */ "column_def_list", + /* 281 */ "tags_def_opt", + /* 282 */ "table_options", + /* 283 */ "multi_create_clause", + /* 284 */ "tags_def", + /* 285 */ "multi_drop_clause", + /* 286 */ "alter_table_clause", + /* 287 */ "alter_table_options", + /* 288 */ "column_name", + /* 289 */ "type_name", + /* 290 */ "signed_literal", + /* 291 */ "create_subtable_clause", + /* 292 */ "specific_cols_opt", + /* 293 */ "expression_list", + /* 294 */ "drop_table_clause", + /* 295 */ "col_name_list", + /* 296 */ "table_name", + /* 297 */ "column_def", + /* 298 */ "duration_list", + /* 299 */ "rollup_func_list", + /* 300 */ "alter_table_option", + /* 301 */ "duration_literal", + /* 302 */ "rollup_func_name", + /* 303 */ "function_name", + /* 304 */ "col_name", + /* 305 */ "db_name_cond_opt", + /* 306 */ "like_pattern_opt", + /* 307 */ "table_name_cond", + /* 308 */ "from_db_opt", + /* 309 */ "index_name", + /* 310 */ "index_options", + /* 311 */ "func_list", + /* 312 */ "sliding_opt", + /* 313 */ "sma_stream_opt", + /* 314 */ "func", + /* 315 */ "stream_options", + /* 316 */ "topic_name", + /* 317 */ "query_expression", + /* 318 */ "cgroup_name", + /* 319 */ "analyze_opt", + /* 320 */ "explain_options", + /* 321 */ "agg_func_opt", + /* 322 */ "bufsize_opt", + /* 323 */ "stream_name", + /* 324 */ "into_opt", + /* 325 */ "dnode_list", + /* 326 */ "where_clause_opt", + /* 327 */ "signed", + /* 328 */ "literal_func", + /* 329 */ "literal_list", + /* 330 */ "table_alias", + /* 331 */ "column_alias", + /* 332 */ "expression", + /* 333 */ "pseudo_column", + /* 334 */ "column_reference", + /* 335 */ "function_expression", + /* 336 */ "subquery", + /* 337 */ "star_func", + /* 338 */ "star_func_para_list", + /* 339 */ "noarg_func", + /* 340 */ "other_para_list", + /* 341 */ "star_func_para", + /* 342 */ "predicate", + /* 343 */ "compare_op", + /* 344 */ "in_op", + /* 345 */ "in_predicate_value", + /* 346 */ "boolean_value_expression", + /* 347 */ "boolean_primary", + /* 348 */ "common_expression", + /* 349 */ "from_clause_opt", + /* 350 */ "table_reference_list", + /* 351 */ "table_reference", + /* 352 */ "table_primary", + /* 353 */ "joined_table", + /* 354 */ "alias_opt", + /* 355 */ "parenthesized_joined_table", + /* 356 */ "join_type", + /* 357 */ "search_condition", + /* 358 */ "query_specification", + /* 359 */ "set_quantifier_opt", + /* 360 */ "select_list", + /* 361 */ "partition_by_clause_opt", + /* 362 */ "range_opt", + /* 363 */ "every_opt", + /* 364 */ "fill_opt", + /* 365 */ "twindow_clause_opt", + /* 366 */ "group_by_clause_opt", + /* 367 */ "having_clause_opt", + /* 368 */ "select_item", + /* 369 */ "fill_mode", + /* 370 */ "group_by_list", + /* 371 */ "query_expression_body", + /* 372 */ "order_by_clause_opt", + /* 373 */ "slimit_clause_opt", + /* 374 */ "limit_clause_opt", + /* 375 */ "query_primary", + /* 376 */ "sort_specification_list", + /* 377 */ "sort_specification", + /* 378 */ "ordering_specification_opt", + /* 379 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1719,415 +1703,419 @@ static const char *const yyRuleName[] = { /* 76 */ "db_options ::= db_options COMP NK_INTEGER", /* 77 */ "db_options ::= db_options DURATION NK_INTEGER", /* 78 */ "db_options ::= db_options DURATION NK_VARIABLE", - /* 79 */ "db_options ::= db_options FSYNC NK_INTEGER", - /* 80 */ "db_options ::= db_options MAXROWS NK_INTEGER", - /* 81 */ "db_options ::= db_options MINROWS NK_INTEGER", - /* 82 */ "db_options ::= db_options KEEP integer_list", - /* 83 */ "db_options ::= db_options KEEP variable_list", - /* 84 */ "db_options ::= db_options PAGES NK_INTEGER", - /* 85 */ "db_options ::= db_options PAGESIZE NK_INTEGER", - /* 86 */ "db_options ::= db_options PRECISION NK_STRING", - /* 87 */ "db_options ::= db_options REPLICA NK_INTEGER", - /* 88 */ "db_options ::= db_options STRICT NK_STRING", - /* 89 */ "db_options ::= db_options WAL NK_INTEGER", - /* 90 */ "db_options ::= db_options VGROUPS NK_INTEGER", - /* 91 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", - /* 92 */ "db_options ::= db_options RETENTIONS retention_list", - /* 93 */ "db_options ::= db_options SCHEMALESS NK_INTEGER", - /* 94 */ "alter_db_options ::= alter_db_option", - /* 95 */ "alter_db_options ::= alter_db_options alter_db_option", - /* 96 */ "alter_db_option ::= CACHEMODEL NK_STRING", - /* 97 */ "alter_db_option ::= CACHESIZE NK_INTEGER", - /* 98 */ "alter_db_option ::= FSYNC NK_INTEGER", - /* 99 */ "alter_db_option ::= KEEP integer_list", - /* 100 */ "alter_db_option ::= KEEP variable_list", - /* 101 */ "alter_db_option ::= WAL NK_INTEGER", - /* 102 */ "integer_list ::= NK_INTEGER", - /* 103 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", - /* 104 */ "variable_list ::= NK_VARIABLE", - /* 105 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", - /* 106 */ "retention_list ::= retention", - /* 107 */ "retention_list ::= retention_list NK_COMMA retention", - /* 108 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", - /* 109 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 110 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 111 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 112 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 113 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 114 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 115 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 116 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 117 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 118 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 119 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 120 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 121 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 122 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 123 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 124 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 125 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", - /* 126 */ "multi_create_clause ::= create_subtable_clause", - /* 127 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 128 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options", - /* 129 */ "multi_drop_clause ::= drop_table_clause", - /* 130 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 131 */ "drop_table_clause ::= exists_opt full_table_name", - /* 132 */ "specific_cols_opt ::=", - /* 133 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", - /* 134 */ "full_table_name ::= table_name", - /* 135 */ "full_table_name ::= db_name NK_DOT table_name", - /* 136 */ "column_def_list ::= column_def", - /* 137 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 138 */ "column_def ::= column_name type_name", - /* 139 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 140 */ "type_name ::= BOOL", - /* 141 */ "type_name ::= TINYINT", - /* 142 */ "type_name ::= SMALLINT", - /* 143 */ "type_name ::= INT", - /* 144 */ "type_name ::= INTEGER", - /* 145 */ "type_name ::= BIGINT", - /* 146 */ "type_name ::= FLOAT", - /* 147 */ "type_name ::= DOUBLE", - /* 148 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 149 */ "type_name ::= TIMESTAMP", - /* 150 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 151 */ "type_name ::= TINYINT UNSIGNED", - /* 152 */ "type_name ::= SMALLINT UNSIGNED", - /* 153 */ "type_name ::= INT UNSIGNED", - /* 154 */ "type_name ::= BIGINT UNSIGNED", - /* 155 */ "type_name ::= JSON", - /* 156 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 157 */ "type_name ::= MEDIUMBLOB", - /* 158 */ "type_name ::= BLOB", - /* 159 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 160 */ "type_name ::= DECIMAL", - /* 161 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 162 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 163 */ "tags_def_opt ::=", - /* 164 */ "tags_def_opt ::= tags_def", - /* 165 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 166 */ "table_options ::=", - /* 167 */ "table_options ::= table_options COMMENT NK_STRING", - /* 168 */ "table_options ::= table_options MAX_DELAY duration_list", - /* 169 */ "table_options ::= table_options WATERMARK duration_list", - /* 170 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", - /* 171 */ "table_options ::= table_options TTL NK_INTEGER", - /* 172 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 173 */ "alter_table_options ::= alter_table_option", - /* 174 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 175 */ "alter_table_option ::= COMMENT NK_STRING", - /* 176 */ "alter_table_option ::= TTL NK_INTEGER", - /* 177 */ "duration_list ::= duration_literal", - /* 178 */ "duration_list ::= duration_list NK_COMMA duration_literal", - /* 179 */ "rollup_func_list ::= rollup_func_name", - /* 180 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", - /* 181 */ "rollup_func_name ::= function_name", - /* 182 */ "rollup_func_name ::= FIRST", - /* 183 */ "rollup_func_name ::= LAST", - /* 184 */ "col_name_list ::= col_name", - /* 185 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 186 */ "col_name ::= column_name", - /* 187 */ "cmd ::= SHOW DNODES", - /* 188 */ "cmd ::= SHOW USERS", - /* 189 */ "cmd ::= SHOW DATABASES", - /* 190 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", - /* 191 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 192 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 193 */ "cmd ::= SHOW MNODES", - /* 194 */ "cmd ::= SHOW MODULES", - /* 195 */ "cmd ::= SHOW QNODES", - /* 196 */ "cmd ::= SHOW FUNCTIONS", - /* 197 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 198 */ "cmd ::= SHOW STREAMS", - /* 199 */ "cmd ::= SHOW ACCOUNTS", - /* 200 */ "cmd ::= SHOW APPS", - /* 201 */ "cmd ::= SHOW CONNECTIONS", - /* 202 */ "cmd ::= SHOW LICENCE", - /* 203 */ "cmd ::= SHOW GRANTS", - /* 204 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 205 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 206 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 207 */ "cmd ::= SHOW QUERIES", - /* 208 */ "cmd ::= SHOW SCORES", - /* 209 */ "cmd ::= SHOW TOPICS", - /* 210 */ "cmd ::= SHOW VARIABLES", - /* 211 */ "cmd ::= SHOW LOCAL VARIABLES", - /* 212 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES", - /* 213 */ "cmd ::= SHOW BNODES", - /* 214 */ "cmd ::= SHOW SNODES", - /* 215 */ "cmd ::= SHOW CLUSTER", - /* 216 */ "cmd ::= SHOW TRANSACTIONS", - /* 217 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 218 */ "cmd ::= SHOW CONSUMERS", - /* 219 */ "cmd ::= SHOW SUBSCRIPTIONS", - /* 220 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", - /* 221 */ "db_name_cond_opt ::=", - /* 222 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 223 */ "like_pattern_opt ::=", - /* 224 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 225 */ "table_name_cond ::= table_name", - /* 226 */ "from_db_opt ::=", - /* 227 */ "from_db_opt ::= FROM db_name", - /* 228 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", - /* 229 */ "cmd ::= DROP INDEX exists_opt index_name", - /* 230 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 231 */ "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", - /* 232 */ "func_list ::= func", - /* 233 */ "func_list ::= func_list NK_COMMA func", - /* 234 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 235 */ "sma_stream_opt ::=", - /* 236 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", - /* 237 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", - /* 238 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", - /* 239 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", - /* 240 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", - /* 241 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", - /* 242 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", - /* 243 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 244 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 245 */ "cmd ::= DESC full_table_name", - /* 246 */ "cmd ::= DESCRIBE full_table_name", - /* 247 */ "cmd ::= RESET QUERY CACHE", - /* 248 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", - /* 249 */ "analyze_opt ::=", - /* 250 */ "analyze_opt ::= ANALYZE", - /* 251 */ "explain_options ::=", - /* 252 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 253 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 254 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", - /* 255 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 256 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 257 */ "agg_func_opt ::=", - /* 258 */ "agg_func_opt ::= AGGREGATE", - /* 259 */ "bufsize_opt ::=", - /* 260 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 261 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression", - /* 262 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 263 */ "into_opt ::=", - /* 264 */ "into_opt ::= INTO full_table_name", - /* 265 */ "stream_options ::=", - /* 266 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 267 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 268 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 269 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 270 */ "stream_options ::= stream_options IGNORE EXPIRED", - /* 271 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 272 */ "cmd ::= KILL QUERY NK_STRING", - /* 273 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 274 */ "cmd ::= BALANCE VGROUP", - /* 275 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 276 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 277 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 278 */ "dnode_list ::= DNODE NK_INTEGER", - /* 279 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 280 */ "cmd ::= SYNCDB db_name REPLICA", - /* 281 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 282 */ "cmd ::= query_expression", - /* 283 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression", - /* 284 */ "cmd ::= INSERT INTO full_table_name query_expression", - /* 285 */ "literal ::= NK_INTEGER", - /* 286 */ "literal ::= NK_FLOAT", - /* 287 */ "literal ::= NK_STRING", - /* 288 */ "literal ::= NK_BOOL", - /* 289 */ "literal ::= TIMESTAMP NK_STRING", - /* 290 */ "literal ::= duration_literal", - /* 291 */ "literal ::= NULL", - /* 292 */ "literal ::= NK_QUESTION", - /* 293 */ "duration_literal ::= NK_VARIABLE", - /* 294 */ "signed ::= NK_INTEGER", - /* 295 */ "signed ::= NK_PLUS NK_INTEGER", - /* 296 */ "signed ::= NK_MINUS NK_INTEGER", - /* 297 */ "signed ::= NK_FLOAT", - /* 298 */ "signed ::= NK_PLUS NK_FLOAT", - /* 299 */ "signed ::= NK_MINUS NK_FLOAT", - /* 300 */ "signed_literal ::= signed", - /* 301 */ "signed_literal ::= NK_STRING", - /* 302 */ "signed_literal ::= NK_BOOL", - /* 303 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 304 */ "signed_literal ::= duration_literal", - /* 305 */ "signed_literal ::= NULL", - /* 306 */ "signed_literal ::= literal_func", - /* 307 */ "signed_literal ::= NK_QUESTION", - /* 308 */ "literal_list ::= signed_literal", - /* 309 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 310 */ "db_name ::= NK_ID", - /* 311 */ "table_name ::= NK_ID", - /* 312 */ "column_name ::= NK_ID", - /* 313 */ "function_name ::= NK_ID", - /* 314 */ "table_alias ::= NK_ID", - /* 315 */ "column_alias ::= NK_ID", - /* 316 */ "user_name ::= NK_ID", - /* 317 */ "index_name ::= NK_ID", - /* 318 */ "topic_name ::= NK_ID", - /* 319 */ "stream_name ::= NK_ID", - /* 320 */ "cgroup_name ::= NK_ID", - /* 321 */ "expression ::= literal", - /* 322 */ "expression ::= pseudo_column", - /* 323 */ "expression ::= column_reference", - /* 324 */ "expression ::= function_expression", - /* 325 */ "expression ::= subquery", - /* 326 */ "expression ::= NK_LP expression NK_RP", - /* 327 */ "expression ::= NK_PLUS expression", - /* 328 */ "expression ::= NK_MINUS expression", - /* 329 */ "expression ::= expression NK_PLUS expression", - /* 330 */ "expression ::= expression NK_MINUS expression", - /* 331 */ "expression ::= expression NK_STAR expression", - /* 332 */ "expression ::= expression NK_SLASH expression", - /* 333 */ "expression ::= expression NK_REM expression", - /* 334 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 335 */ "expression ::= expression NK_BITAND expression", - /* 336 */ "expression ::= expression NK_BITOR expression", - /* 337 */ "expression_list ::= expression", - /* 338 */ "expression_list ::= expression_list NK_COMMA expression", - /* 339 */ "column_reference ::= column_name", - /* 340 */ "column_reference ::= table_name NK_DOT column_name", - /* 341 */ "pseudo_column ::= ROWTS", - /* 342 */ "pseudo_column ::= TBNAME", - /* 343 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 344 */ "pseudo_column ::= QSTART", - /* 345 */ "pseudo_column ::= QEND", - /* 346 */ "pseudo_column ::= QDURATION", - /* 347 */ "pseudo_column ::= WSTART", - /* 348 */ "pseudo_column ::= WEND", - /* 349 */ "pseudo_column ::= WDURATION", - /* 350 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 351 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 352 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", - /* 353 */ "function_expression ::= literal_func", - /* 354 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 355 */ "literal_func ::= NOW", - /* 356 */ "noarg_func ::= NOW", - /* 357 */ "noarg_func ::= TODAY", - /* 358 */ "noarg_func ::= TIMEZONE", - /* 359 */ "noarg_func ::= DATABASE", - /* 360 */ "noarg_func ::= CLIENT_VERSION", - /* 361 */ "noarg_func ::= SERVER_VERSION", - /* 362 */ "noarg_func ::= SERVER_STATUS", - /* 363 */ "noarg_func ::= CURRENT_USER", - /* 364 */ "noarg_func ::= USER", - /* 365 */ "star_func ::= COUNT", - /* 366 */ "star_func ::= FIRST", - /* 367 */ "star_func ::= LAST", - /* 368 */ "star_func ::= LAST_ROW", - /* 369 */ "star_func_para_list ::= NK_STAR", - /* 370 */ "star_func_para_list ::= other_para_list", - /* 371 */ "other_para_list ::= star_func_para", - /* 372 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 373 */ "star_func_para ::= expression", - /* 374 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 375 */ "predicate ::= expression compare_op expression", - /* 376 */ "predicate ::= expression BETWEEN expression AND expression", - /* 377 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 378 */ "predicate ::= expression IS NULL", - /* 379 */ "predicate ::= expression IS NOT NULL", - /* 380 */ "predicate ::= expression in_op in_predicate_value", - /* 381 */ "compare_op ::= NK_LT", - /* 382 */ "compare_op ::= NK_GT", - /* 383 */ "compare_op ::= NK_LE", - /* 384 */ "compare_op ::= NK_GE", - /* 385 */ "compare_op ::= NK_NE", - /* 386 */ "compare_op ::= NK_EQ", - /* 387 */ "compare_op ::= LIKE", - /* 388 */ "compare_op ::= NOT LIKE", - /* 389 */ "compare_op ::= MATCH", - /* 390 */ "compare_op ::= NMATCH", - /* 391 */ "compare_op ::= CONTAINS", - /* 392 */ "in_op ::= IN", - /* 393 */ "in_op ::= NOT IN", - /* 394 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 395 */ "boolean_value_expression ::= boolean_primary", - /* 396 */ "boolean_value_expression ::= NOT boolean_primary", - /* 397 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 398 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 399 */ "boolean_primary ::= predicate", - /* 400 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 401 */ "common_expression ::= expression", - /* 402 */ "common_expression ::= boolean_value_expression", - /* 403 */ "from_clause_opt ::=", - /* 404 */ "from_clause_opt ::= FROM table_reference_list", - /* 405 */ "table_reference_list ::= table_reference", - /* 406 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 407 */ "table_reference ::= table_primary", - /* 408 */ "table_reference ::= joined_table", - /* 409 */ "table_primary ::= table_name alias_opt", - /* 410 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 411 */ "table_primary ::= subquery alias_opt", - /* 412 */ "table_primary ::= parenthesized_joined_table", - /* 413 */ "alias_opt ::=", - /* 414 */ "alias_opt ::= table_alias", - /* 415 */ "alias_opt ::= AS table_alias", - /* 416 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 417 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 418 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 419 */ "join_type ::=", - /* 420 */ "join_type ::= INNER", - /* 421 */ "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", - /* 422 */ "set_quantifier_opt ::=", - /* 423 */ "set_quantifier_opt ::= DISTINCT", - /* 424 */ "set_quantifier_opt ::= ALL", - /* 425 */ "select_list ::= select_item", - /* 426 */ "select_list ::= select_list NK_COMMA select_item", - /* 427 */ "select_item ::= NK_STAR", - /* 428 */ "select_item ::= common_expression", - /* 429 */ "select_item ::= common_expression column_alias", - /* 430 */ "select_item ::= common_expression AS column_alias", - /* 431 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 432 */ "where_clause_opt ::=", - /* 433 */ "where_clause_opt ::= WHERE search_condition", - /* 434 */ "partition_by_clause_opt ::=", - /* 435 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 436 */ "twindow_clause_opt ::=", - /* 437 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 438 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 439 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 440 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 441 */ "sliding_opt ::=", - /* 442 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 443 */ "fill_opt ::=", - /* 444 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 445 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 446 */ "fill_mode ::= NONE", - /* 447 */ "fill_mode ::= PREV", - /* 448 */ "fill_mode ::= NULL", - /* 449 */ "fill_mode ::= LINEAR", - /* 450 */ "fill_mode ::= NEXT", - /* 451 */ "group_by_clause_opt ::=", - /* 452 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 453 */ "group_by_list ::= expression", - /* 454 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 455 */ "having_clause_opt ::=", - /* 456 */ "having_clause_opt ::= HAVING search_condition", - /* 457 */ "range_opt ::=", - /* 458 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", - /* 459 */ "every_opt ::=", - /* 460 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 461 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 462 */ "query_expression_body ::= query_primary", - /* 463 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 464 */ "query_expression_body ::= query_expression_body UNION query_expression_body", - /* 465 */ "query_primary ::= query_specification", - /* 466 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", - /* 467 */ "order_by_clause_opt ::=", - /* 468 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 469 */ "slimit_clause_opt ::=", - /* 470 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 471 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 472 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 473 */ "limit_clause_opt ::=", - /* 474 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 475 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 476 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 477 */ "subquery ::= NK_LP query_expression NK_RP", - /* 478 */ "search_condition ::= common_expression", - /* 479 */ "sort_specification_list ::= sort_specification", - /* 480 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 481 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 482 */ "ordering_specification_opt ::=", - /* 483 */ "ordering_specification_opt ::= ASC", - /* 484 */ "ordering_specification_opt ::= DESC", - /* 485 */ "null_ordering_opt ::=", - /* 486 */ "null_ordering_opt ::= NULLS FIRST", - /* 487 */ "null_ordering_opt ::= NULLS LAST", + /* 79 */ "db_options ::= db_options MAXROWS NK_INTEGER", + /* 80 */ "db_options ::= db_options MINROWS NK_INTEGER", + /* 81 */ "db_options ::= db_options KEEP integer_list", + /* 82 */ "db_options ::= db_options KEEP variable_list", + /* 83 */ "db_options ::= db_options PAGES NK_INTEGER", + /* 84 */ "db_options ::= db_options PAGESIZE NK_INTEGER", + /* 85 */ "db_options ::= db_options PRECISION NK_STRING", + /* 86 */ "db_options ::= db_options REPLICA NK_INTEGER", + /* 87 */ "db_options ::= db_options STRICT NK_STRING", + /* 88 */ "db_options ::= db_options VGROUPS NK_INTEGER", + /* 89 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", + /* 90 */ "db_options ::= db_options RETENTIONS retention_list", + /* 91 */ "db_options ::= db_options SCHEMALESS NK_INTEGER", + /* 92 */ "db_options ::= db_options WAL_LEVEL NK_INTEGER", + /* 93 */ "db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER", + /* 94 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER", + /* 95 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER", + /* 96 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER", + /* 97 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER", + /* 98 */ "db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER", + /* 99 */ "db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER", + /* 100 */ "alter_db_options ::= alter_db_option", + /* 101 */ "alter_db_options ::= alter_db_options alter_db_option", + /* 102 */ "alter_db_option ::= CACHEMODEL NK_STRING", + /* 103 */ "alter_db_option ::= CACHESIZE NK_INTEGER", + /* 104 */ "alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER", + /* 105 */ "alter_db_option ::= KEEP integer_list", + /* 106 */ "alter_db_option ::= KEEP variable_list", + /* 107 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER", + /* 108 */ "integer_list ::= NK_INTEGER", + /* 109 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", + /* 110 */ "variable_list ::= NK_VARIABLE", + /* 111 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", + /* 112 */ "retention_list ::= retention", + /* 113 */ "retention_list ::= retention_list NK_COMMA retention", + /* 114 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", + /* 115 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 116 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 117 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 118 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 119 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 120 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 121 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 122 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 123 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 124 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 125 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 126 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 127 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 128 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 129 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 130 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 131 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", + /* 132 */ "multi_create_clause ::= create_subtable_clause", + /* 133 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 134 */ "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", + /* 135 */ "multi_drop_clause ::= drop_table_clause", + /* 136 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 137 */ "drop_table_clause ::= exists_opt full_table_name", + /* 138 */ "specific_cols_opt ::=", + /* 139 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", + /* 140 */ "full_table_name ::= table_name", + /* 141 */ "full_table_name ::= db_name NK_DOT table_name", + /* 142 */ "column_def_list ::= column_def", + /* 143 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 144 */ "column_def ::= column_name type_name", + /* 145 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 146 */ "type_name ::= BOOL", + /* 147 */ "type_name ::= TINYINT", + /* 148 */ "type_name ::= SMALLINT", + /* 149 */ "type_name ::= INT", + /* 150 */ "type_name ::= INTEGER", + /* 151 */ "type_name ::= BIGINT", + /* 152 */ "type_name ::= FLOAT", + /* 153 */ "type_name ::= DOUBLE", + /* 154 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 155 */ "type_name ::= TIMESTAMP", + /* 156 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 157 */ "type_name ::= TINYINT UNSIGNED", + /* 158 */ "type_name ::= SMALLINT UNSIGNED", + /* 159 */ "type_name ::= INT UNSIGNED", + /* 160 */ "type_name ::= BIGINT UNSIGNED", + /* 161 */ "type_name ::= JSON", + /* 162 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 163 */ "type_name ::= MEDIUMBLOB", + /* 164 */ "type_name ::= BLOB", + /* 165 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 166 */ "type_name ::= DECIMAL", + /* 167 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 168 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 169 */ "tags_def_opt ::=", + /* 170 */ "tags_def_opt ::= tags_def", + /* 171 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 172 */ "table_options ::=", + /* 173 */ "table_options ::= table_options COMMENT NK_STRING", + /* 174 */ "table_options ::= table_options MAX_DELAY duration_list", + /* 175 */ "table_options ::= table_options WATERMARK duration_list", + /* 176 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", + /* 177 */ "table_options ::= table_options TTL NK_INTEGER", + /* 178 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 179 */ "alter_table_options ::= alter_table_option", + /* 180 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 181 */ "alter_table_option ::= COMMENT NK_STRING", + /* 182 */ "alter_table_option ::= TTL NK_INTEGER", + /* 183 */ "duration_list ::= duration_literal", + /* 184 */ "duration_list ::= duration_list NK_COMMA duration_literal", + /* 185 */ "rollup_func_list ::= rollup_func_name", + /* 186 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", + /* 187 */ "rollup_func_name ::= function_name", + /* 188 */ "rollup_func_name ::= FIRST", + /* 189 */ "rollup_func_name ::= LAST", + /* 190 */ "col_name_list ::= col_name", + /* 191 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 192 */ "col_name ::= column_name", + /* 193 */ "cmd ::= SHOW DNODES", + /* 194 */ "cmd ::= SHOW USERS", + /* 195 */ "cmd ::= SHOW DATABASES", + /* 196 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", + /* 197 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 198 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 199 */ "cmd ::= SHOW MNODES", + /* 200 */ "cmd ::= SHOW MODULES", + /* 201 */ "cmd ::= SHOW QNODES", + /* 202 */ "cmd ::= SHOW FUNCTIONS", + /* 203 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 204 */ "cmd ::= SHOW STREAMS", + /* 205 */ "cmd ::= SHOW ACCOUNTS", + /* 206 */ "cmd ::= SHOW APPS", + /* 207 */ "cmd ::= SHOW CONNECTIONS", + /* 208 */ "cmd ::= SHOW LICENCE", + /* 209 */ "cmd ::= SHOW GRANTS", + /* 210 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 211 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 212 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 213 */ "cmd ::= SHOW QUERIES", + /* 214 */ "cmd ::= SHOW SCORES", + /* 215 */ "cmd ::= SHOW TOPICS", + /* 216 */ "cmd ::= SHOW VARIABLES", + /* 217 */ "cmd ::= SHOW LOCAL VARIABLES", + /* 218 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES", + /* 219 */ "cmd ::= SHOW BNODES", + /* 220 */ "cmd ::= SHOW SNODES", + /* 221 */ "cmd ::= SHOW CLUSTER", + /* 222 */ "cmd ::= SHOW TRANSACTIONS", + /* 223 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", + /* 224 */ "cmd ::= SHOW CONSUMERS", + /* 225 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 226 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", + /* 227 */ "db_name_cond_opt ::=", + /* 228 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 229 */ "like_pattern_opt ::=", + /* 230 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 231 */ "table_name_cond ::= table_name", + /* 232 */ "from_db_opt ::=", + /* 233 */ "from_db_opt ::= FROM db_name", + /* 234 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", + /* 235 */ "cmd ::= DROP INDEX exists_opt index_name", + /* 236 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 237 */ "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", + /* 238 */ "func_list ::= func", + /* 239 */ "func_list ::= func_list NK_COMMA func", + /* 240 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 241 */ "sma_stream_opt ::=", + /* 242 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", + /* 243 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", + /* 244 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 245 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", + /* 246 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", + /* 247 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", + /* 248 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", + /* 249 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 250 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 251 */ "cmd ::= DESC full_table_name", + /* 252 */ "cmd ::= DESCRIBE full_table_name", + /* 253 */ "cmd ::= RESET QUERY CACHE", + /* 254 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", + /* 255 */ "analyze_opt ::=", + /* 256 */ "analyze_opt ::= ANALYZE", + /* 257 */ "explain_options ::=", + /* 258 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 259 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 260 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 261 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 262 */ "agg_func_opt ::=", + /* 263 */ "agg_func_opt ::= AGGREGATE", + /* 264 */ "bufsize_opt ::=", + /* 265 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 266 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression", + /* 267 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 268 */ "into_opt ::=", + /* 269 */ "into_opt ::= INTO full_table_name", + /* 270 */ "stream_options ::=", + /* 271 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 272 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 273 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 274 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 275 */ "stream_options ::= stream_options IGNORE EXPIRED", + /* 276 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 277 */ "cmd ::= KILL QUERY NK_STRING", + /* 278 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 279 */ "cmd ::= BALANCE VGROUP", + /* 280 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 281 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 282 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 283 */ "dnode_list ::= DNODE NK_INTEGER", + /* 284 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 285 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 286 */ "cmd ::= query_expression", + /* 287 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression", + /* 288 */ "cmd ::= INSERT INTO full_table_name query_expression", + /* 289 */ "literal ::= NK_INTEGER", + /* 290 */ "literal ::= NK_FLOAT", + /* 291 */ "literal ::= NK_STRING", + /* 292 */ "literal ::= NK_BOOL", + /* 293 */ "literal ::= TIMESTAMP NK_STRING", + /* 294 */ "literal ::= duration_literal", + /* 295 */ "literal ::= NULL", + /* 296 */ "literal ::= NK_QUESTION", + /* 297 */ "duration_literal ::= NK_VARIABLE", + /* 298 */ "signed ::= NK_INTEGER", + /* 299 */ "signed ::= NK_PLUS NK_INTEGER", + /* 300 */ "signed ::= NK_MINUS NK_INTEGER", + /* 301 */ "signed ::= NK_FLOAT", + /* 302 */ "signed ::= NK_PLUS NK_FLOAT", + /* 303 */ "signed ::= NK_MINUS NK_FLOAT", + /* 304 */ "signed_literal ::= signed", + /* 305 */ "signed_literal ::= NK_STRING", + /* 306 */ "signed_literal ::= NK_BOOL", + /* 307 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 308 */ "signed_literal ::= duration_literal", + /* 309 */ "signed_literal ::= NULL", + /* 310 */ "signed_literal ::= literal_func", + /* 311 */ "signed_literal ::= NK_QUESTION", + /* 312 */ "literal_list ::= signed_literal", + /* 313 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 314 */ "db_name ::= NK_ID", + /* 315 */ "table_name ::= NK_ID", + /* 316 */ "column_name ::= NK_ID", + /* 317 */ "function_name ::= NK_ID", + /* 318 */ "table_alias ::= NK_ID", + /* 319 */ "column_alias ::= NK_ID", + /* 320 */ "user_name ::= NK_ID", + /* 321 */ "index_name ::= NK_ID", + /* 322 */ "topic_name ::= NK_ID", + /* 323 */ "stream_name ::= NK_ID", + /* 324 */ "cgroup_name ::= NK_ID", + /* 325 */ "expression ::= literal", + /* 326 */ "expression ::= pseudo_column", + /* 327 */ "expression ::= column_reference", + /* 328 */ "expression ::= function_expression", + /* 329 */ "expression ::= subquery", + /* 330 */ "expression ::= NK_LP expression NK_RP", + /* 331 */ "expression ::= NK_PLUS expression", + /* 332 */ "expression ::= NK_MINUS expression", + /* 333 */ "expression ::= expression NK_PLUS expression", + /* 334 */ "expression ::= expression NK_MINUS expression", + /* 335 */ "expression ::= expression NK_STAR expression", + /* 336 */ "expression ::= expression NK_SLASH expression", + /* 337 */ "expression ::= expression NK_REM expression", + /* 338 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 339 */ "expression ::= expression NK_BITAND expression", + /* 340 */ "expression ::= expression NK_BITOR expression", + /* 341 */ "expression_list ::= expression", + /* 342 */ "expression_list ::= expression_list NK_COMMA expression", + /* 343 */ "column_reference ::= column_name", + /* 344 */ "column_reference ::= table_name NK_DOT column_name", + /* 345 */ "pseudo_column ::= ROWTS", + /* 346 */ "pseudo_column ::= TBNAME", + /* 347 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 348 */ "pseudo_column ::= QSTART", + /* 349 */ "pseudo_column ::= QEND", + /* 350 */ "pseudo_column ::= QDURATION", + /* 351 */ "pseudo_column ::= WSTART", + /* 352 */ "pseudo_column ::= WEND", + /* 353 */ "pseudo_column ::= WDURATION", + /* 354 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 355 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 356 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", + /* 357 */ "function_expression ::= literal_func", + /* 358 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 359 */ "literal_func ::= NOW", + /* 360 */ "noarg_func ::= NOW", + /* 361 */ "noarg_func ::= TODAY", + /* 362 */ "noarg_func ::= TIMEZONE", + /* 363 */ "noarg_func ::= DATABASE", + /* 364 */ "noarg_func ::= CLIENT_VERSION", + /* 365 */ "noarg_func ::= SERVER_VERSION", + /* 366 */ "noarg_func ::= SERVER_STATUS", + /* 367 */ "noarg_func ::= CURRENT_USER", + /* 368 */ "noarg_func ::= USER", + /* 369 */ "star_func ::= COUNT", + /* 370 */ "star_func ::= FIRST", + /* 371 */ "star_func ::= LAST", + /* 372 */ "star_func ::= LAST_ROW", + /* 373 */ "star_func_para_list ::= NK_STAR", + /* 374 */ "star_func_para_list ::= other_para_list", + /* 375 */ "other_para_list ::= star_func_para", + /* 376 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 377 */ "star_func_para ::= expression", + /* 378 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 379 */ "predicate ::= expression compare_op expression", + /* 380 */ "predicate ::= expression BETWEEN expression AND expression", + /* 381 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 382 */ "predicate ::= expression IS NULL", + /* 383 */ "predicate ::= expression IS NOT NULL", + /* 384 */ "predicate ::= expression in_op in_predicate_value", + /* 385 */ "compare_op ::= NK_LT", + /* 386 */ "compare_op ::= NK_GT", + /* 387 */ "compare_op ::= NK_LE", + /* 388 */ "compare_op ::= NK_GE", + /* 389 */ "compare_op ::= NK_NE", + /* 390 */ "compare_op ::= NK_EQ", + /* 391 */ "compare_op ::= LIKE", + /* 392 */ "compare_op ::= NOT LIKE", + /* 393 */ "compare_op ::= MATCH", + /* 394 */ "compare_op ::= NMATCH", + /* 395 */ "compare_op ::= CONTAINS", + /* 396 */ "in_op ::= IN", + /* 397 */ "in_op ::= NOT IN", + /* 398 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 399 */ "boolean_value_expression ::= boolean_primary", + /* 400 */ "boolean_value_expression ::= NOT boolean_primary", + /* 401 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 402 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 403 */ "boolean_primary ::= predicate", + /* 404 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 405 */ "common_expression ::= expression", + /* 406 */ "common_expression ::= boolean_value_expression", + /* 407 */ "from_clause_opt ::=", + /* 408 */ "from_clause_opt ::= FROM table_reference_list", + /* 409 */ "table_reference_list ::= table_reference", + /* 410 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 411 */ "table_reference ::= table_primary", + /* 412 */ "table_reference ::= joined_table", + /* 413 */ "table_primary ::= table_name alias_opt", + /* 414 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 415 */ "table_primary ::= subquery alias_opt", + /* 416 */ "table_primary ::= parenthesized_joined_table", + /* 417 */ "alias_opt ::=", + /* 418 */ "alias_opt ::= table_alias", + /* 419 */ "alias_opt ::= AS table_alias", + /* 420 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 421 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 422 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 423 */ "join_type ::=", + /* 424 */ "join_type ::= INNER", + /* 425 */ "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", + /* 426 */ "set_quantifier_opt ::=", + /* 427 */ "set_quantifier_opt ::= DISTINCT", + /* 428 */ "set_quantifier_opt ::= ALL", + /* 429 */ "select_list ::= select_item", + /* 430 */ "select_list ::= select_list NK_COMMA select_item", + /* 431 */ "select_item ::= NK_STAR", + /* 432 */ "select_item ::= common_expression", + /* 433 */ "select_item ::= common_expression column_alias", + /* 434 */ "select_item ::= common_expression AS column_alias", + /* 435 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 436 */ "where_clause_opt ::=", + /* 437 */ "where_clause_opt ::= WHERE search_condition", + /* 438 */ "partition_by_clause_opt ::=", + /* 439 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 440 */ "twindow_clause_opt ::=", + /* 441 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 442 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 443 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 444 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 445 */ "sliding_opt ::=", + /* 446 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 447 */ "fill_opt ::=", + /* 448 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 449 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 450 */ "fill_mode ::= NONE", + /* 451 */ "fill_mode ::= PREV", + /* 452 */ "fill_mode ::= NULL", + /* 453 */ "fill_mode ::= LINEAR", + /* 454 */ "fill_mode ::= NEXT", + /* 455 */ "group_by_clause_opt ::=", + /* 456 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 457 */ "group_by_list ::= expression", + /* 458 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 459 */ "having_clause_opt ::=", + /* 460 */ "having_clause_opt ::= HAVING search_condition", + /* 461 */ "range_opt ::=", + /* 462 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", + /* 463 */ "every_opt ::=", + /* 464 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 465 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 466 */ "query_expression_body ::= query_primary", + /* 467 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 468 */ "query_expression_body ::= query_expression_body UNION query_expression_body", + /* 469 */ "query_primary ::= query_specification", + /* 470 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", + /* 471 */ "order_by_clause_opt ::=", + /* 472 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 473 */ "slimit_clause_opt ::=", + /* 474 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 475 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 476 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 477 */ "limit_clause_opt ::=", + /* 478 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 479 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 480 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 481 */ "subquery ::= NK_LP query_expression NK_RP", + /* 482 */ "search_condition ::= common_expression", + /* 483 */ "sort_specification_list ::= sort_specification", + /* 484 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 485 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 486 */ "ordering_specification_opt ::=", + /* 487 */ "ordering_specification_opt ::= ASC", + /* 488 */ "ordering_specification_opt ::= DESC", + /* 489 */ "null_ordering_opt ::=", + /* 490 */ "null_ordering_opt ::= NULLS FIRST", + /* 491 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2254,181 +2242,181 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 256: /* cmd */ - case 259: /* literal */ - case 270: /* db_options */ - case 272: /* alter_db_options */ - case 277: /* retention */ - case 278: /* full_table_name */ - case 281: /* table_options */ - case 285: /* alter_table_clause */ - case 286: /* alter_table_options */ - case 289: /* signed_literal */ - case 290: /* create_subtable_clause */ - case 293: /* drop_table_clause */ - case 296: /* column_def */ - case 300: /* duration_literal */ - case 301: /* rollup_func_name */ - case 303: /* col_name */ - case 304: /* db_name_cond_opt */ - case 305: /* like_pattern_opt */ - case 306: /* table_name_cond */ - case 307: /* from_db_opt */ - case 309: /* index_options */ - case 311: /* sliding_opt */ - case 312: /* sma_stream_opt */ - case 313: /* func */ - case 314: /* stream_options */ - case 316: /* query_expression */ - case 319: /* explain_options */ - case 323: /* into_opt */ - case 325: /* where_clause_opt */ - case 326: /* signed */ - case 327: /* literal_func */ - case 331: /* expression */ - case 332: /* pseudo_column */ - case 333: /* column_reference */ - case 334: /* function_expression */ - case 335: /* subquery */ - case 340: /* star_func_para */ - case 341: /* predicate */ - case 344: /* in_predicate_value */ - case 345: /* boolean_value_expression */ - case 346: /* boolean_primary */ - case 347: /* common_expression */ - case 348: /* from_clause_opt */ - case 349: /* table_reference_list */ - case 350: /* table_reference */ - case 351: /* table_primary */ - case 352: /* joined_table */ - case 354: /* parenthesized_joined_table */ - case 356: /* search_condition */ - case 357: /* query_specification */ - case 361: /* range_opt */ - case 362: /* every_opt */ - case 363: /* fill_opt */ - case 364: /* twindow_clause_opt */ - case 366: /* having_clause_opt */ - case 367: /* select_item */ - case 370: /* query_expression_body */ - case 372: /* slimit_clause_opt */ - case 373: /* limit_clause_opt */ - case 374: /* query_primary */ - case 376: /* sort_specification */ + case 257: /* cmd */ + case 260: /* literal */ + case 271: /* db_options */ + case 273: /* alter_db_options */ + case 278: /* retention */ + case 279: /* full_table_name */ + case 282: /* table_options */ + case 286: /* alter_table_clause */ + case 287: /* alter_table_options */ + case 290: /* signed_literal */ + case 291: /* create_subtable_clause */ + case 294: /* drop_table_clause */ + case 297: /* column_def */ + case 301: /* duration_literal */ + case 302: /* rollup_func_name */ + case 304: /* col_name */ + case 305: /* db_name_cond_opt */ + case 306: /* like_pattern_opt */ + case 307: /* table_name_cond */ + case 308: /* from_db_opt */ + case 310: /* index_options */ + case 312: /* sliding_opt */ + case 313: /* sma_stream_opt */ + case 314: /* func */ + case 315: /* stream_options */ + case 317: /* query_expression */ + case 320: /* explain_options */ + case 324: /* into_opt */ + case 326: /* where_clause_opt */ + case 327: /* signed */ + case 328: /* literal_func */ + case 332: /* expression */ + case 333: /* pseudo_column */ + case 334: /* column_reference */ + case 335: /* function_expression */ + case 336: /* subquery */ + case 341: /* star_func_para */ + case 342: /* predicate */ + case 345: /* in_predicate_value */ + case 346: /* boolean_value_expression */ + case 347: /* boolean_primary */ + case 348: /* common_expression */ + case 349: /* from_clause_opt */ + case 350: /* table_reference_list */ + case 351: /* table_reference */ + case 352: /* table_primary */ + case 353: /* joined_table */ + case 355: /* parenthesized_joined_table */ + case 357: /* search_condition */ + case 358: /* query_specification */ + case 362: /* range_opt */ + case 363: /* every_opt */ + case 364: /* fill_opt */ + case 365: /* twindow_clause_opt */ + case 367: /* having_clause_opt */ + case 368: /* select_item */ + case 371: /* query_expression_body */ + case 373: /* slimit_clause_opt */ + case 374: /* limit_clause_opt */ + case 375: /* query_primary */ + case 377: /* sort_specification */ { - nodesDestroyNode((yypminor->yy616)); + nodesDestroyNode((yypminor->yy712)); } break; - case 257: /* account_options */ - case 258: /* alter_account_options */ - case 260: /* alter_account_option */ - case 321: /* bufsize_opt */ + case 258: /* account_options */ + case 259: /* alter_account_options */ + case 261: /* alter_account_option */ + case 322: /* bufsize_opt */ { } break; - case 261: /* user_name */ - case 264: /* priv_level */ - case 267: /* db_name */ - case 268: /* dnode_endpoint */ - case 287: /* column_name */ - case 295: /* table_name */ - case 302: /* function_name */ - case 308: /* index_name */ - case 315: /* topic_name */ - case 317: /* cgroup_name */ - case 322: /* stream_name */ - case 329: /* table_alias */ - case 330: /* column_alias */ - case 336: /* star_func */ - case 338: /* noarg_func */ - case 353: /* alias_opt */ + case 262: /* user_name */ + case 265: /* priv_level */ + case 268: /* db_name */ + case 269: /* dnode_endpoint */ + case 288: /* column_name */ + case 296: /* table_name */ + case 303: /* function_name */ + case 309: /* index_name */ + case 316: /* topic_name */ + case 318: /* cgroup_name */ + case 323: /* stream_name */ + case 330: /* table_alias */ + case 331: /* column_alias */ + case 337: /* star_func */ + case 339: /* noarg_func */ + case 354: /* alias_opt */ { } break; - case 262: /* sysinfo_opt */ + case 263: /* sysinfo_opt */ { } break; - case 263: /* privileges */ - case 265: /* priv_type_list */ - case 266: /* priv_type */ + case 264: /* privileges */ + case 266: /* priv_type_list */ + case 267: /* priv_type */ { } break; - case 269: /* not_exists_opt */ - case 271: /* exists_opt */ - case 318: /* analyze_opt */ - case 320: /* agg_func_opt */ - case 358: /* set_quantifier_opt */ + case 270: /* not_exists_opt */ + case 272: /* exists_opt */ + case 319: /* analyze_opt */ + case 321: /* agg_func_opt */ + case 359: /* set_quantifier_opt */ { } break; - case 273: /* integer_list */ - case 274: /* variable_list */ - case 275: /* retention_list */ - case 279: /* column_def_list */ - case 280: /* tags_def_opt */ - case 282: /* multi_create_clause */ - case 283: /* tags_def */ - case 284: /* multi_drop_clause */ - case 291: /* specific_cols_opt */ - case 292: /* expression_list */ - case 294: /* col_name_list */ - case 297: /* duration_list */ - case 298: /* rollup_func_list */ - case 310: /* func_list */ - case 324: /* dnode_list */ - case 328: /* literal_list */ - case 337: /* star_func_para_list */ - case 339: /* other_para_list */ - case 359: /* select_list */ - case 360: /* partition_by_clause_opt */ - case 365: /* group_by_clause_opt */ - case 369: /* group_by_list */ - case 371: /* order_by_clause_opt */ - case 375: /* sort_specification_list */ + case 274: /* integer_list */ + case 275: /* variable_list */ + case 276: /* retention_list */ + case 280: /* column_def_list */ + case 281: /* tags_def_opt */ + case 283: /* multi_create_clause */ + case 284: /* tags_def */ + case 285: /* multi_drop_clause */ + case 292: /* specific_cols_opt */ + case 293: /* expression_list */ + case 295: /* col_name_list */ + case 298: /* duration_list */ + case 299: /* rollup_func_list */ + case 311: /* func_list */ + case 325: /* dnode_list */ + case 329: /* literal_list */ + case 338: /* star_func_para_list */ + case 340: /* other_para_list */ + case 360: /* select_list */ + case 361: /* partition_by_clause_opt */ + case 366: /* group_by_clause_opt */ + case 370: /* group_by_list */ + case 372: /* order_by_clause_opt */ + case 376: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy356)); + nodesDestroyList((yypminor->yy464)); } break; - case 276: /* alter_db_option */ - case 299: /* alter_table_option */ + case 277: /* alter_db_option */ + case 300: /* alter_table_option */ { } break; - case 288: /* type_name */ + case 289: /* type_name */ { } break; - case 342: /* compare_op */ - case 343: /* in_op */ + case 343: /* compare_op */ + case 344: /* in_op */ { } break; - case 355: /* join_type */ + case 356: /* join_type */ { } break; - case 368: /* fill_mode */ + case 369: /* fill_mode */ { } break; - case 377: /* ordering_specification_opt */ + case 378: /* ordering_specification_opt */ { } break; - case 378: /* null_ordering_opt */ + case 379: /* null_ordering_opt */ { } @@ -2727,494 +2715,498 @@ 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[] = { - { 256, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 256, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 257, 0 }, /* (2) account_options ::= */ - { 257, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 257, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 257, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 257, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 257, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 257, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 257, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 257, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 257, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 258, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 258, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 260, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 260, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 260, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 260, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 260, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 260, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 260, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 260, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 260, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 260, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 256, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ - { 256, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 256, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - { 256, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - { 256, -3 }, /* (28) cmd ::= DROP USER user_name */ - { 262, 0 }, /* (29) sysinfo_opt ::= */ - { 262, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ - { 256, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 256, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 263, -1 }, /* (33) privileges ::= ALL */ - { 263, -1 }, /* (34) privileges ::= priv_type_list */ - { 265, -1 }, /* (35) priv_type_list ::= priv_type */ - { 265, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 266, -1 }, /* (37) priv_type ::= READ */ - { 266, -1 }, /* (38) priv_type ::= WRITE */ - { 264, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 264, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ - { 256, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ - { 256, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - { 256, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ - { 256, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ - { 256, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 256, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 256, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ - { 256, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 268, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ - { 268, -1 }, /* (50) dnode_endpoint ::= NK_ID */ - { 268, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ - { 256, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ - { 256, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 256, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 256, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 256, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 256, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 256, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 256, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 256, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 256, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 256, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 256, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ - { 256, -2 }, /* (64) cmd ::= USE db_name */ - { 256, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 256, -3 }, /* (66) cmd ::= FLUSH DATABASE db_name */ - { 256, -3 }, /* (67) cmd ::= TRIM DATABASE db_name */ - { 269, -3 }, /* (68) not_exists_opt ::= IF NOT EXISTS */ - { 269, 0 }, /* (69) not_exists_opt ::= */ - { 271, -2 }, /* (70) exists_opt ::= IF EXISTS */ - { 271, 0 }, /* (71) exists_opt ::= */ - { 270, 0 }, /* (72) db_options ::= */ - { 270, -3 }, /* (73) db_options ::= db_options BUFFER NK_INTEGER */ - { 270, -3 }, /* (74) db_options ::= db_options CACHEMODEL NK_STRING */ - { 270, -3 }, /* (75) db_options ::= db_options CACHESIZE NK_INTEGER */ - { 270, -3 }, /* (76) db_options ::= db_options COMP NK_INTEGER */ - { 270, -3 }, /* (77) db_options ::= db_options DURATION NK_INTEGER */ - { 270, -3 }, /* (78) db_options ::= db_options DURATION NK_VARIABLE */ - { 270, -3 }, /* (79) db_options ::= db_options FSYNC NK_INTEGER */ - { 270, -3 }, /* (80) db_options ::= db_options MAXROWS NK_INTEGER */ - { 270, -3 }, /* (81) db_options ::= db_options MINROWS NK_INTEGER */ - { 270, -3 }, /* (82) db_options ::= db_options KEEP integer_list */ - { 270, -3 }, /* (83) db_options ::= db_options KEEP variable_list */ - { 270, -3 }, /* (84) db_options ::= db_options PAGES NK_INTEGER */ - { 270, -3 }, /* (85) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 270, -3 }, /* (86) db_options ::= db_options PRECISION NK_STRING */ - { 270, -3 }, /* (87) db_options ::= db_options REPLICA NK_INTEGER */ - { 270, -3 }, /* (88) db_options ::= db_options STRICT NK_STRING */ - { 270, -3 }, /* (89) db_options ::= db_options WAL NK_INTEGER */ - { 270, -3 }, /* (90) db_options ::= db_options VGROUPS NK_INTEGER */ - { 270, -3 }, /* (91) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 270, -3 }, /* (92) db_options ::= db_options RETENTIONS retention_list */ - { 270, -3 }, /* (93) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 272, -1 }, /* (94) alter_db_options ::= alter_db_option */ - { 272, -2 }, /* (95) alter_db_options ::= alter_db_options alter_db_option */ - { 276, -2 }, /* (96) alter_db_option ::= CACHEMODEL NK_STRING */ - { 276, -2 }, /* (97) alter_db_option ::= CACHESIZE NK_INTEGER */ - { 276, -2 }, /* (98) alter_db_option ::= FSYNC NK_INTEGER */ - { 276, -2 }, /* (99) alter_db_option ::= KEEP integer_list */ - { 276, -2 }, /* (100) alter_db_option ::= KEEP variable_list */ - { 276, -2 }, /* (101) alter_db_option ::= WAL NK_INTEGER */ - { 273, -1 }, /* (102) integer_list ::= NK_INTEGER */ - { 273, -3 }, /* (103) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 274, -1 }, /* (104) variable_list ::= NK_VARIABLE */ - { 274, -3 }, /* (105) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 275, -1 }, /* (106) retention_list ::= retention */ - { 275, -3 }, /* (107) retention_list ::= retention_list NK_COMMA retention */ - { 277, -3 }, /* (108) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 256, -9 }, /* (109) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 256, -3 }, /* (110) cmd ::= CREATE TABLE multi_create_clause */ - { 256, -9 }, /* (111) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 256, -3 }, /* (112) cmd ::= DROP TABLE multi_drop_clause */ - { 256, -4 }, /* (113) cmd ::= DROP STABLE exists_opt full_table_name */ - { 256, -3 }, /* (114) cmd ::= ALTER TABLE alter_table_clause */ - { 256, -3 }, /* (115) cmd ::= ALTER STABLE alter_table_clause */ - { 285, -2 }, /* (116) alter_table_clause ::= full_table_name alter_table_options */ - { 285, -5 }, /* (117) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 285, -4 }, /* (118) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 285, -5 }, /* (119) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 285, -5 }, /* (120) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 285, -5 }, /* (121) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 285, -4 }, /* (122) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 285, -5 }, /* (123) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 285, -5 }, /* (124) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 285, -6 }, /* (125) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 282, -1 }, /* (126) multi_create_clause ::= create_subtable_clause */ - { 282, -2 }, /* (127) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 290, -10 }, /* (128) 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 */ - { 284, -1 }, /* (129) multi_drop_clause ::= drop_table_clause */ - { 284, -2 }, /* (130) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 293, -2 }, /* (131) drop_table_clause ::= exists_opt full_table_name */ - { 291, 0 }, /* (132) specific_cols_opt ::= */ - { 291, -3 }, /* (133) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - { 278, -1 }, /* (134) full_table_name ::= table_name */ - { 278, -3 }, /* (135) full_table_name ::= db_name NK_DOT table_name */ - { 279, -1 }, /* (136) column_def_list ::= column_def */ - { 279, -3 }, /* (137) column_def_list ::= column_def_list NK_COMMA column_def */ - { 296, -2 }, /* (138) column_def ::= column_name type_name */ - { 296, -4 }, /* (139) column_def ::= column_name type_name COMMENT NK_STRING */ - { 288, -1 }, /* (140) type_name ::= BOOL */ - { 288, -1 }, /* (141) type_name ::= TINYINT */ - { 288, -1 }, /* (142) type_name ::= SMALLINT */ - { 288, -1 }, /* (143) type_name ::= INT */ - { 288, -1 }, /* (144) type_name ::= INTEGER */ - { 288, -1 }, /* (145) type_name ::= BIGINT */ - { 288, -1 }, /* (146) type_name ::= FLOAT */ - { 288, -1 }, /* (147) type_name ::= DOUBLE */ - { 288, -4 }, /* (148) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 288, -1 }, /* (149) type_name ::= TIMESTAMP */ - { 288, -4 }, /* (150) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 288, -2 }, /* (151) type_name ::= TINYINT UNSIGNED */ - { 288, -2 }, /* (152) type_name ::= SMALLINT UNSIGNED */ - { 288, -2 }, /* (153) type_name ::= INT UNSIGNED */ - { 288, -2 }, /* (154) type_name ::= BIGINT UNSIGNED */ - { 288, -1 }, /* (155) type_name ::= JSON */ - { 288, -4 }, /* (156) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 288, -1 }, /* (157) type_name ::= MEDIUMBLOB */ - { 288, -1 }, /* (158) type_name ::= BLOB */ - { 288, -4 }, /* (159) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 288, -1 }, /* (160) type_name ::= DECIMAL */ - { 288, -4 }, /* (161) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 288, -6 }, /* (162) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 280, 0 }, /* (163) tags_def_opt ::= */ - { 280, -1 }, /* (164) tags_def_opt ::= tags_def */ - { 283, -4 }, /* (165) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 281, 0 }, /* (166) table_options ::= */ - { 281, -3 }, /* (167) table_options ::= table_options COMMENT NK_STRING */ - { 281, -3 }, /* (168) table_options ::= table_options MAX_DELAY duration_list */ - { 281, -3 }, /* (169) table_options ::= table_options WATERMARK duration_list */ - { 281, -5 }, /* (170) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 281, -3 }, /* (171) table_options ::= table_options TTL NK_INTEGER */ - { 281, -5 }, /* (172) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 286, -1 }, /* (173) alter_table_options ::= alter_table_option */ - { 286, -2 }, /* (174) alter_table_options ::= alter_table_options alter_table_option */ - { 299, -2 }, /* (175) alter_table_option ::= COMMENT NK_STRING */ - { 299, -2 }, /* (176) alter_table_option ::= TTL NK_INTEGER */ - { 297, -1 }, /* (177) duration_list ::= duration_literal */ - { 297, -3 }, /* (178) duration_list ::= duration_list NK_COMMA duration_literal */ - { 298, -1 }, /* (179) rollup_func_list ::= rollup_func_name */ - { 298, -3 }, /* (180) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 301, -1 }, /* (181) rollup_func_name ::= function_name */ - { 301, -1 }, /* (182) rollup_func_name ::= FIRST */ - { 301, -1 }, /* (183) rollup_func_name ::= LAST */ - { 294, -1 }, /* (184) col_name_list ::= col_name */ - { 294, -3 }, /* (185) col_name_list ::= col_name_list NK_COMMA col_name */ - { 303, -1 }, /* (186) col_name ::= column_name */ - { 256, -2 }, /* (187) cmd ::= SHOW DNODES */ - { 256, -2 }, /* (188) cmd ::= SHOW USERS */ - { 256, -2 }, /* (189) cmd ::= SHOW DATABASES */ - { 256, -4 }, /* (190) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 256, -4 }, /* (191) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 256, -3 }, /* (192) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 256, -2 }, /* (193) cmd ::= SHOW MNODES */ - { 256, -2 }, /* (194) cmd ::= SHOW MODULES */ - { 256, -2 }, /* (195) cmd ::= SHOW QNODES */ - { 256, -2 }, /* (196) cmd ::= SHOW FUNCTIONS */ - { 256, -5 }, /* (197) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 256, -2 }, /* (198) cmd ::= SHOW STREAMS */ - { 256, -2 }, /* (199) cmd ::= SHOW ACCOUNTS */ - { 256, -2 }, /* (200) cmd ::= SHOW APPS */ - { 256, -2 }, /* (201) cmd ::= SHOW CONNECTIONS */ - { 256, -2 }, /* (202) cmd ::= SHOW LICENCE */ - { 256, -2 }, /* (203) cmd ::= SHOW GRANTS */ - { 256, -4 }, /* (204) cmd ::= SHOW CREATE DATABASE db_name */ - { 256, -4 }, /* (205) cmd ::= SHOW CREATE TABLE full_table_name */ - { 256, -4 }, /* (206) cmd ::= SHOW CREATE STABLE full_table_name */ - { 256, -2 }, /* (207) cmd ::= SHOW QUERIES */ - { 256, -2 }, /* (208) cmd ::= SHOW SCORES */ - { 256, -2 }, /* (209) cmd ::= SHOW TOPICS */ - { 256, -2 }, /* (210) cmd ::= SHOW VARIABLES */ - { 256, -3 }, /* (211) cmd ::= SHOW LOCAL VARIABLES */ - { 256, -4 }, /* (212) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ - { 256, -2 }, /* (213) cmd ::= SHOW BNODES */ - { 256, -2 }, /* (214) cmd ::= SHOW SNODES */ - { 256, -2 }, /* (215) cmd ::= SHOW CLUSTER */ - { 256, -2 }, /* (216) cmd ::= SHOW TRANSACTIONS */ - { 256, -4 }, /* (217) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 256, -2 }, /* (218) cmd ::= SHOW CONSUMERS */ - { 256, -2 }, /* (219) cmd ::= SHOW SUBSCRIPTIONS */ - { 256, -5 }, /* (220) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - { 304, 0 }, /* (221) db_name_cond_opt ::= */ - { 304, -2 }, /* (222) db_name_cond_opt ::= db_name NK_DOT */ - { 305, 0 }, /* (223) like_pattern_opt ::= */ - { 305, -2 }, /* (224) like_pattern_opt ::= LIKE NK_STRING */ - { 306, -1 }, /* (225) table_name_cond ::= table_name */ - { 307, 0 }, /* (226) from_db_opt ::= */ - { 307, -2 }, /* (227) from_db_opt ::= FROM db_name */ - { 256, -8 }, /* (228) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - { 256, -4 }, /* (229) cmd ::= DROP INDEX exists_opt index_name */ - { 309, -10 }, /* (230) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - { 309, -12 }, /* (231) 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 */ - { 310, -1 }, /* (232) func_list ::= func */ - { 310, -3 }, /* (233) func_list ::= func_list NK_COMMA func */ - { 313, -4 }, /* (234) func ::= function_name NK_LP expression_list NK_RP */ - { 312, 0 }, /* (235) sma_stream_opt ::= */ - { 312, -3 }, /* (236) sma_stream_opt ::= stream_options WATERMARK duration_literal */ - { 312, -3 }, /* (237) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ - { 256, -6 }, /* (238) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 256, -7 }, /* (239) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 256, -9 }, /* (240) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 256, -7 }, /* (241) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 256, -9 }, /* (242) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 256, -4 }, /* (243) cmd ::= DROP TOPIC exists_opt topic_name */ - { 256, -7 }, /* (244) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 256, -2 }, /* (245) cmd ::= DESC full_table_name */ - { 256, -2 }, /* (246) cmd ::= DESCRIBE full_table_name */ - { 256, -3 }, /* (247) cmd ::= RESET QUERY CACHE */ - { 256, -4 }, /* (248) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 318, 0 }, /* (249) analyze_opt ::= */ - { 318, -1 }, /* (250) analyze_opt ::= ANALYZE */ - { 319, 0 }, /* (251) explain_options ::= */ - { 319, -3 }, /* (252) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 319, -3 }, /* (253) explain_options ::= explain_options RATIO NK_FLOAT */ - { 256, -6 }, /* (254) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ - { 256, -10 }, /* (255) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 256, -4 }, /* (256) cmd ::= DROP FUNCTION exists_opt function_name */ - { 320, 0 }, /* (257) agg_func_opt ::= */ - { 320, -1 }, /* (258) agg_func_opt ::= AGGREGATE */ - { 321, 0 }, /* (259) bufsize_opt ::= */ - { 321, -2 }, /* (260) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 256, -8 }, /* (261) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ - { 256, -4 }, /* (262) cmd ::= DROP STREAM exists_opt stream_name */ - { 323, 0 }, /* (263) into_opt ::= */ - { 323, -2 }, /* (264) into_opt ::= INTO full_table_name */ - { 314, 0 }, /* (265) stream_options ::= */ - { 314, -3 }, /* (266) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 314, -3 }, /* (267) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 314, -4 }, /* (268) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 314, -3 }, /* (269) stream_options ::= stream_options WATERMARK duration_literal */ - { 314, -3 }, /* (270) stream_options ::= stream_options IGNORE EXPIRED */ - { 256, -3 }, /* (271) cmd ::= KILL CONNECTION NK_INTEGER */ - { 256, -3 }, /* (272) cmd ::= KILL QUERY NK_STRING */ - { 256, -3 }, /* (273) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 256, -2 }, /* (274) cmd ::= BALANCE VGROUP */ - { 256, -4 }, /* (275) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 256, -4 }, /* (276) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 256, -3 }, /* (277) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 324, -2 }, /* (278) dnode_list ::= DNODE NK_INTEGER */ - { 324, -3 }, /* (279) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 256, -3 }, /* (280) cmd ::= SYNCDB db_name REPLICA */ - { 256, -4 }, /* (281) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 256, -1 }, /* (282) cmd ::= query_expression */ - { 256, -7 }, /* (283) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression */ - { 256, -4 }, /* (284) cmd ::= INSERT INTO full_table_name query_expression */ - { 259, -1 }, /* (285) literal ::= NK_INTEGER */ - { 259, -1 }, /* (286) literal ::= NK_FLOAT */ - { 259, -1 }, /* (287) literal ::= NK_STRING */ - { 259, -1 }, /* (288) literal ::= NK_BOOL */ - { 259, -2 }, /* (289) literal ::= TIMESTAMP NK_STRING */ - { 259, -1 }, /* (290) literal ::= duration_literal */ - { 259, -1 }, /* (291) literal ::= NULL */ - { 259, -1 }, /* (292) literal ::= NK_QUESTION */ - { 300, -1 }, /* (293) duration_literal ::= NK_VARIABLE */ - { 326, -1 }, /* (294) signed ::= NK_INTEGER */ - { 326, -2 }, /* (295) signed ::= NK_PLUS NK_INTEGER */ - { 326, -2 }, /* (296) signed ::= NK_MINUS NK_INTEGER */ - { 326, -1 }, /* (297) signed ::= NK_FLOAT */ - { 326, -2 }, /* (298) signed ::= NK_PLUS NK_FLOAT */ - { 326, -2 }, /* (299) signed ::= NK_MINUS NK_FLOAT */ - { 289, -1 }, /* (300) signed_literal ::= signed */ - { 289, -1 }, /* (301) signed_literal ::= NK_STRING */ - { 289, -1 }, /* (302) signed_literal ::= NK_BOOL */ - { 289, -2 }, /* (303) signed_literal ::= TIMESTAMP NK_STRING */ - { 289, -1 }, /* (304) signed_literal ::= duration_literal */ - { 289, -1 }, /* (305) signed_literal ::= NULL */ - { 289, -1 }, /* (306) signed_literal ::= literal_func */ - { 289, -1 }, /* (307) signed_literal ::= NK_QUESTION */ - { 328, -1 }, /* (308) literal_list ::= signed_literal */ - { 328, -3 }, /* (309) literal_list ::= literal_list NK_COMMA signed_literal */ - { 267, -1 }, /* (310) db_name ::= NK_ID */ - { 295, -1 }, /* (311) table_name ::= NK_ID */ - { 287, -1 }, /* (312) column_name ::= NK_ID */ - { 302, -1 }, /* (313) function_name ::= NK_ID */ - { 329, -1 }, /* (314) table_alias ::= NK_ID */ - { 330, -1 }, /* (315) column_alias ::= NK_ID */ - { 261, -1 }, /* (316) user_name ::= NK_ID */ - { 308, -1 }, /* (317) index_name ::= NK_ID */ - { 315, -1 }, /* (318) topic_name ::= NK_ID */ - { 322, -1 }, /* (319) stream_name ::= NK_ID */ - { 317, -1 }, /* (320) cgroup_name ::= NK_ID */ - { 331, -1 }, /* (321) expression ::= literal */ - { 331, -1 }, /* (322) expression ::= pseudo_column */ - { 331, -1 }, /* (323) expression ::= column_reference */ - { 331, -1 }, /* (324) expression ::= function_expression */ - { 331, -1 }, /* (325) expression ::= subquery */ - { 331, -3 }, /* (326) expression ::= NK_LP expression NK_RP */ - { 331, -2 }, /* (327) expression ::= NK_PLUS expression */ - { 331, -2 }, /* (328) expression ::= NK_MINUS expression */ - { 331, -3 }, /* (329) expression ::= expression NK_PLUS expression */ - { 331, -3 }, /* (330) expression ::= expression NK_MINUS expression */ - { 331, -3 }, /* (331) expression ::= expression NK_STAR expression */ - { 331, -3 }, /* (332) expression ::= expression NK_SLASH expression */ - { 331, -3 }, /* (333) expression ::= expression NK_REM expression */ - { 331, -3 }, /* (334) expression ::= column_reference NK_ARROW NK_STRING */ - { 331, -3 }, /* (335) expression ::= expression NK_BITAND expression */ - { 331, -3 }, /* (336) expression ::= expression NK_BITOR expression */ - { 292, -1 }, /* (337) expression_list ::= expression */ - { 292, -3 }, /* (338) expression_list ::= expression_list NK_COMMA expression */ - { 333, -1 }, /* (339) column_reference ::= column_name */ - { 333, -3 }, /* (340) column_reference ::= table_name NK_DOT column_name */ - { 332, -1 }, /* (341) pseudo_column ::= ROWTS */ - { 332, -1 }, /* (342) pseudo_column ::= TBNAME */ - { 332, -3 }, /* (343) pseudo_column ::= table_name NK_DOT TBNAME */ - { 332, -1 }, /* (344) pseudo_column ::= QSTART */ - { 332, -1 }, /* (345) pseudo_column ::= QEND */ - { 332, -1 }, /* (346) pseudo_column ::= QDURATION */ - { 332, -1 }, /* (347) pseudo_column ::= WSTART */ - { 332, -1 }, /* (348) pseudo_column ::= WEND */ - { 332, -1 }, /* (349) pseudo_column ::= WDURATION */ - { 334, -4 }, /* (350) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 334, -4 }, /* (351) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 334, -6 }, /* (352) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ - { 334, -1 }, /* (353) function_expression ::= literal_func */ - { 327, -3 }, /* (354) literal_func ::= noarg_func NK_LP NK_RP */ - { 327, -1 }, /* (355) literal_func ::= NOW */ - { 338, -1 }, /* (356) noarg_func ::= NOW */ - { 338, -1 }, /* (357) noarg_func ::= TODAY */ - { 338, -1 }, /* (358) noarg_func ::= TIMEZONE */ - { 338, -1 }, /* (359) noarg_func ::= DATABASE */ - { 338, -1 }, /* (360) noarg_func ::= CLIENT_VERSION */ - { 338, -1 }, /* (361) noarg_func ::= SERVER_VERSION */ - { 338, -1 }, /* (362) noarg_func ::= SERVER_STATUS */ - { 338, -1 }, /* (363) noarg_func ::= CURRENT_USER */ - { 338, -1 }, /* (364) noarg_func ::= USER */ - { 336, -1 }, /* (365) star_func ::= COUNT */ - { 336, -1 }, /* (366) star_func ::= FIRST */ - { 336, -1 }, /* (367) star_func ::= LAST */ - { 336, -1 }, /* (368) star_func ::= LAST_ROW */ - { 337, -1 }, /* (369) star_func_para_list ::= NK_STAR */ - { 337, -1 }, /* (370) star_func_para_list ::= other_para_list */ - { 339, -1 }, /* (371) other_para_list ::= star_func_para */ - { 339, -3 }, /* (372) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 340, -1 }, /* (373) star_func_para ::= expression */ - { 340, -3 }, /* (374) star_func_para ::= table_name NK_DOT NK_STAR */ - { 341, -3 }, /* (375) predicate ::= expression compare_op expression */ - { 341, -5 }, /* (376) predicate ::= expression BETWEEN expression AND expression */ - { 341, -6 }, /* (377) predicate ::= expression NOT BETWEEN expression AND expression */ - { 341, -3 }, /* (378) predicate ::= expression IS NULL */ - { 341, -4 }, /* (379) predicate ::= expression IS NOT NULL */ - { 341, -3 }, /* (380) predicate ::= expression in_op in_predicate_value */ - { 342, -1 }, /* (381) compare_op ::= NK_LT */ - { 342, -1 }, /* (382) compare_op ::= NK_GT */ - { 342, -1 }, /* (383) compare_op ::= NK_LE */ - { 342, -1 }, /* (384) compare_op ::= NK_GE */ - { 342, -1 }, /* (385) compare_op ::= NK_NE */ - { 342, -1 }, /* (386) compare_op ::= NK_EQ */ - { 342, -1 }, /* (387) compare_op ::= LIKE */ - { 342, -2 }, /* (388) compare_op ::= NOT LIKE */ - { 342, -1 }, /* (389) compare_op ::= MATCH */ - { 342, -1 }, /* (390) compare_op ::= NMATCH */ - { 342, -1 }, /* (391) compare_op ::= CONTAINS */ - { 343, -1 }, /* (392) in_op ::= IN */ - { 343, -2 }, /* (393) in_op ::= NOT IN */ - { 344, -3 }, /* (394) in_predicate_value ::= NK_LP literal_list NK_RP */ - { 345, -1 }, /* (395) boolean_value_expression ::= boolean_primary */ - { 345, -2 }, /* (396) boolean_value_expression ::= NOT boolean_primary */ - { 345, -3 }, /* (397) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 345, -3 }, /* (398) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 346, -1 }, /* (399) boolean_primary ::= predicate */ - { 346, -3 }, /* (400) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 347, -1 }, /* (401) common_expression ::= expression */ - { 347, -1 }, /* (402) common_expression ::= boolean_value_expression */ - { 348, 0 }, /* (403) from_clause_opt ::= */ - { 348, -2 }, /* (404) from_clause_opt ::= FROM table_reference_list */ - { 349, -1 }, /* (405) table_reference_list ::= table_reference */ - { 349, -3 }, /* (406) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 350, -1 }, /* (407) table_reference ::= table_primary */ - { 350, -1 }, /* (408) table_reference ::= joined_table */ - { 351, -2 }, /* (409) table_primary ::= table_name alias_opt */ - { 351, -4 }, /* (410) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 351, -2 }, /* (411) table_primary ::= subquery alias_opt */ - { 351, -1 }, /* (412) table_primary ::= parenthesized_joined_table */ - { 353, 0 }, /* (413) alias_opt ::= */ - { 353, -1 }, /* (414) alias_opt ::= table_alias */ - { 353, -2 }, /* (415) alias_opt ::= AS table_alias */ - { 354, -3 }, /* (416) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 354, -3 }, /* (417) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 352, -6 }, /* (418) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 355, 0 }, /* (419) join_type ::= */ - { 355, -1 }, /* (420) join_type ::= INNER */ - { 357, -12 }, /* (421) 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 */ - { 358, 0 }, /* (422) set_quantifier_opt ::= */ - { 358, -1 }, /* (423) set_quantifier_opt ::= DISTINCT */ - { 358, -1 }, /* (424) set_quantifier_opt ::= ALL */ - { 359, -1 }, /* (425) select_list ::= select_item */ - { 359, -3 }, /* (426) select_list ::= select_list NK_COMMA select_item */ - { 367, -1 }, /* (427) select_item ::= NK_STAR */ - { 367, -1 }, /* (428) select_item ::= common_expression */ - { 367, -2 }, /* (429) select_item ::= common_expression column_alias */ - { 367, -3 }, /* (430) select_item ::= common_expression AS column_alias */ - { 367, -3 }, /* (431) select_item ::= table_name NK_DOT NK_STAR */ - { 325, 0 }, /* (432) where_clause_opt ::= */ - { 325, -2 }, /* (433) where_clause_opt ::= WHERE search_condition */ - { 360, 0 }, /* (434) partition_by_clause_opt ::= */ - { 360, -3 }, /* (435) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 364, 0 }, /* (436) twindow_clause_opt ::= */ - { 364, -6 }, /* (437) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 364, -4 }, /* (438) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - { 364, -6 }, /* (439) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 364, -8 }, /* (440) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 311, 0 }, /* (441) sliding_opt ::= */ - { 311, -4 }, /* (442) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 363, 0 }, /* (443) fill_opt ::= */ - { 363, -4 }, /* (444) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 363, -6 }, /* (445) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 368, -1 }, /* (446) fill_mode ::= NONE */ - { 368, -1 }, /* (447) fill_mode ::= PREV */ - { 368, -1 }, /* (448) fill_mode ::= NULL */ - { 368, -1 }, /* (449) fill_mode ::= LINEAR */ - { 368, -1 }, /* (450) fill_mode ::= NEXT */ - { 365, 0 }, /* (451) group_by_clause_opt ::= */ - { 365, -3 }, /* (452) group_by_clause_opt ::= GROUP BY group_by_list */ - { 369, -1 }, /* (453) group_by_list ::= expression */ - { 369, -3 }, /* (454) group_by_list ::= group_by_list NK_COMMA expression */ - { 366, 0 }, /* (455) having_clause_opt ::= */ - { 366, -2 }, /* (456) having_clause_opt ::= HAVING search_condition */ - { 361, 0 }, /* (457) range_opt ::= */ - { 361, -6 }, /* (458) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ - { 362, 0 }, /* (459) every_opt ::= */ - { 362, -4 }, /* (460) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 316, -4 }, /* (461) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 370, -1 }, /* (462) query_expression_body ::= query_primary */ - { 370, -4 }, /* (463) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 370, -3 }, /* (464) query_expression_body ::= query_expression_body UNION query_expression_body */ - { 374, -1 }, /* (465) query_primary ::= query_specification */ - { 374, -6 }, /* (466) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ - { 371, 0 }, /* (467) order_by_clause_opt ::= */ - { 371, -3 }, /* (468) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 372, 0 }, /* (469) slimit_clause_opt ::= */ - { 372, -2 }, /* (470) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 372, -4 }, /* (471) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 372, -4 }, /* (472) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 373, 0 }, /* (473) limit_clause_opt ::= */ - { 373, -2 }, /* (474) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 373, -4 }, /* (475) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 373, -4 }, /* (476) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 335, -3 }, /* (477) subquery ::= NK_LP query_expression NK_RP */ - { 356, -1 }, /* (478) search_condition ::= common_expression */ - { 375, -1 }, /* (479) sort_specification_list ::= sort_specification */ - { 375, -3 }, /* (480) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 376, -3 }, /* (481) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 377, 0 }, /* (482) ordering_specification_opt ::= */ - { 377, -1 }, /* (483) ordering_specification_opt ::= ASC */ - { 377, -1 }, /* (484) ordering_specification_opt ::= DESC */ - { 378, 0 }, /* (485) null_ordering_opt ::= */ - { 378, -2 }, /* (486) null_ordering_opt ::= NULLS FIRST */ - { 378, -2 }, /* (487) null_ordering_opt ::= NULLS LAST */ + { 257, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 257, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 258, 0 }, /* (2) account_options ::= */ + { 258, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 258, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 258, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 258, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 258, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 258, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 258, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 258, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 258, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 259, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 259, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 261, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 261, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 261, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 261, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 261, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 261, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 261, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 261, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 261, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 261, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 257, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ + { 257, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 257, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + { 257, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + { 257, -3 }, /* (28) cmd ::= DROP USER user_name */ + { 263, 0 }, /* (29) sysinfo_opt ::= */ + { 263, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ + { 257, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 257, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 264, -1 }, /* (33) privileges ::= ALL */ + { 264, -1 }, /* (34) privileges ::= priv_type_list */ + { 266, -1 }, /* (35) priv_type_list ::= priv_type */ + { 266, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 267, -1 }, /* (37) priv_type ::= READ */ + { 267, -1 }, /* (38) priv_type ::= WRITE */ + { 265, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 265, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ + { 257, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ + { 257, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + { 257, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ + { 257, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ + { 257, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 257, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 257, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ + { 257, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 269, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ + { 269, -1 }, /* (50) dnode_endpoint ::= NK_ID */ + { 269, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ + { 257, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ + { 257, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 257, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 257, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 257, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 257, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 257, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 257, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 257, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 257, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 257, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 257, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ + { 257, -2 }, /* (64) cmd ::= USE db_name */ + { 257, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 257, -3 }, /* (66) cmd ::= FLUSH DATABASE db_name */ + { 257, -3 }, /* (67) cmd ::= TRIM DATABASE db_name */ + { 270, -3 }, /* (68) not_exists_opt ::= IF NOT EXISTS */ + { 270, 0 }, /* (69) not_exists_opt ::= */ + { 272, -2 }, /* (70) exists_opt ::= IF EXISTS */ + { 272, 0 }, /* (71) exists_opt ::= */ + { 271, 0 }, /* (72) db_options ::= */ + { 271, -3 }, /* (73) db_options ::= db_options BUFFER NK_INTEGER */ + { 271, -3 }, /* (74) db_options ::= db_options CACHEMODEL NK_STRING */ + { 271, -3 }, /* (75) db_options ::= db_options CACHESIZE NK_INTEGER */ + { 271, -3 }, /* (76) db_options ::= db_options COMP NK_INTEGER */ + { 271, -3 }, /* (77) db_options ::= db_options DURATION NK_INTEGER */ + { 271, -3 }, /* (78) db_options ::= db_options DURATION NK_VARIABLE */ + { 271, -3 }, /* (79) db_options ::= db_options MAXROWS NK_INTEGER */ + { 271, -3 }, /* (80) db_options ::= db_options MINROWS NK_INTEGER */ + { 271, -3 }, /* (81) db_options ::= db_options KEEP integer_list */ + { 271, -3 }, /* (82) db_options ::= db_options KEEP variable_list */ + { 271, -3 }, /* (83) db_options ::= db_options PAGES NK_INTEGER */ + { 271, -3 }, /* (84) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 271, -3 }, /* (85) db_options ::= db_options PRECISION NK_STRING */ + { 271, -3 }, /* (86) db_options ::= db_options REPLICA NK_INTEGER */ + { 271, -3 }, /* (87) db_options ::= db_options STRICT NK_STRING */ + { 271, -3 }, /* (88) db_options ::= db_options VGROUPS NK_INTEGER */ + { 271, -3 }, /* (89) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 271, -3 }, /* (90) db_options ::= db_options RETENTIONS retention_list */ + { 271, -3 }, /* (91) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 271, -3 }, /* (92) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + { 271, -3 }, /* (93) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + { 271, -3 }, /* (94) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + { 271, -4 }, /* (95) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + { 271, -3 }, /* (96) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + { 271, -4 }, /* (97) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + { 271, -3 }, /* (98) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + { 271, -3 }, /* (99) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + { 273, -1 }, /* (100) alter_db_options ::= alter_db_option */ + { 273, -2 }, /* (101) alter_db_options ::= alter_db_options alter_db_option */ + { 277, -2 }, /* (102) alter_db_option ::= CACHEMODEL NK_STRING */ + { 277, -2 }, /* (103) alter_db_option ::= CACHESIZE NK_INTEGER */ + { 277, -2 }, /* (104) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + { 277, -2 }, /* (105) alter_db_option ::= KEEP integer_list */ + { 277, -2 }, /* (106) alter_db_option ::= KEEP variable_list */ + { 277, -2 }, /* (107) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + { 274, -1 }, /* (108) integer_list ::= NK_INTEGER */ + { 274, -3 }, /* (109) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 275, -1 }, /* (110) variable_list ::= NK_VARIABLE */ + { 275, -3 }, /* (111) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 276, -1 }, /* (112) retention_list ::= retention */ + { 276, -3 }, /* (113) retention_list ::= retention_list NK_COMMA retention */ + { 278, -3 }, /* (114) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 257, -9 }, /* (115) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 257, -3 }, /* (116) cmd ::= CREATE TABLE multi_create_clause */ + { 257, -9 }, /* (117) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 257, -3 }, /* (118) cmd ::= DROP TABLE multi_drop_clause */ + { 257, -4 }, /* (119) cmd ::= DROP STABLE exists_opt full_table_name */ + { 257, -3 }, /* (120) cmd ::= ALTER TABLE alter_table_clause */ + { 257, -3 }, /* (121) cmd ::= ALTER STABLE alter_table_clause */ + { 286, -2 }, /* (122) alter_table_clause ::= full_table_name alter_table_options */ + { 286, -5 }, /* (123) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 286, -4 }, /* (124) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 286, -5 }, /* (125) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 286, -5 }, /* (126) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 286, -5 }, /* (127) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 286, -4 }, /* (128) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 286, -5 }, /* (129) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 286, -5 }, /* (130) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 286, -6 }, /* (131) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 283, -1 }, /* (132) multi_create_clause ::= create_subtable_clause */ + { 283, -2 }, /* (133) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 291, -10 }, /* (134) 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 */ + { 285, -1 }, /* (135) multi_drop_clause ::= drop_table_clause */ + { 285, -2 }, /* (136) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 294, -2 }, /* (137) drop_table_clause ::= exists_opt full_table_name */ + { 292, 0 }, /* (138) specific_cols_opt ::= */ + { 292, -3 }, /* (139) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + { 279, -1 }, /* (140) full_table_name ::= table_name */ + { 279, -3 }, /* (141) full_table_name ::= db_name NK_DOT table_name */ + { 280, -1 }, /* (142) column_def_list ::= column_def */ + { 280, -3 }, /* (143) column_def_list ::= column_def_list NK_COMMA column_def */ + { 297, -2 }, /* (144) column_def ::= column_name type_name */ + { 297, -4 }, /* (145) column_def ::= column_name type_name COMMENT NK_STRING */ + { 289, -1 }, /* (146) type_name ::= BOOL */ + { 289, -1 }, /* (147) type_name ::= TINYINT */ + { 289, -1 }, /* (148) type_name ::= SMALLINT */ + { 289, -1 }, /* (149) type_name ::= INT */ + { 289, -1 }, /* (150) type_name ::= INTEGER */ + { 289, -1 }, /* (151) type_name ::= BIGINT */ + { 289, -1 }, /* (152) type_name ::= FLOAT */ + { 289, -1 }, /* (153) type_name ::= DOUBLE */ + { 289, -4 }, /* (154) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 289, -1 }, /* (155) type_name ::= TIMESTAMP */ + { 289, -4 }, /* (156) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 289, -2 }, /* (157) type_name ::= TINYINT UNSIGNED */ + { 289, -2 }, /* (158) type_name ::= SMALLINT UNSIGNED */ + { 289, -2 }, /* (159) type_name ::= INT UNSIGNED */ + { 289, -2 }, /* (160) type_name ::= BIGINT UNSIGNED */ + { 289, -1 }, /* (161) type_name ::= JSON */ + { 289, -4 }, /* (162) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 289, -1 }, /* (163) type_name ::= MEDIUMBLOB */ + { 289, -1 }, /* (164) type_name ::= BLOB */ + { 289, -4 }, /* (165) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 289, -1 }, /* (166) type_name ::= DECIMAL */ + { 289, -4 }, /* (167) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 289, -6 }, /* (168) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 281, 0 }, /* (169) tags_def_opt ::= */ + { 281, -1 }, /* (170) tags_def_opt ::= tags_def */ + { 284, -4 }, /* (171) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 282, 0 }, /* (172) table_options ::= */ + { 282, -3 }, /* (173) table_options ::= table_options COMMENT NK_STRING */ + { 282, -3 }, /* (174) table_options ::= table_options MAX_DELAY duration_list */ + { 282, -3 }, /* (175) table_options ::= table_options WATERMARK duration_list */ + { 282, -5 }, /* (176) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 282, -3 }, /* (177) table_options ::= table_options TTL NK_INTEGER */ + { 282, -5 }, /* (178) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 287, -1 }, /* (179) alter_table_options ::= alter_table_option */ + { 287, -2 }, /* (180) alter_table_options ::= alter_table_options alter_table_option */ + { 300, -2 }, /* (181) alter_table_option ::= COMMENT NK_STRING */ + { 300, -2 }, /* (182) alter_table_option ::= TTL NK_INTEGER */ + { 298, -1 }, /* (183) duration_list ::= duration_literal */ + { 298, -3 }, /* (184) duration_list ::= duration_list NK_COMMA duration_literal */ + { 299, -1 }, /* (185) rollup_func_list ::= rollup_func_name */ + { 299, -3 }, /* (186) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 302, -1 }, /* (187) rollup_func_name ::= function_name */ + { 302, -1 }, /* (188) rollup_func_name ::= FIRST */ + { 302, -1 }, /* (189) rollup_func_name ::= LAST */ + { 295, -1 }, /* (190) col_name_list ::= col_name */ + { 295, -3 }, /* (191) col_name_list ::= col_name_list NK_COMMA col_name */ + { 304, -1 }, /* (192) col_name ::= column_name */ + { 257, -2 }, /* (193) cmd ::= SHOW DNODES */ + { 257, -2 }, /* (194) cmd ::= SHOW USERS */ + { 257, -2 }, /* (195) cmd ::= SHOW DATABASES */ + { 257, -4 }, /* (196) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 257, -4 }, /* (197) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 257, -3 }, /* (198) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 257, -2 }, /* (199) cmd ::= SHOW MNODES */ + { 257, -2 }, /* (200) cmd ::= SHOW MODULES */ + { 257, -2 }, /* (201) cmd ::= SHOW QNODES */ + { 257, -2 }, /* (202) cmd ::= SHOW FUNCTIONS */ + { 257, -5 }, /* (203) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 257, -2 }, /* (204) cmd ::= SHOW STREAMS */ + { 257, -2 }, /* (205) cmd ::= SHOW ACCOUNTS */ + { 257, -2 }, /* (206) cmd ::= SHOW APPS */ + { 257, -2 }, /* (207) cmd ::= SHOW CONNECTIONS */ + { 257, -2 }, /* (208) cmd ::= SHOW LICENCE */ + { 257, -2 }, /* (209) cmd ::= SHOW GRANTS */ + { 257, -4 }, /* (210) cmd ::= SHOW CREATE DATABASE db_name */ + { 257, -4 }, /* (211) cmd ::= SHOW CREATE TABLE full_table_name */ + { 257, -4 }, /* (212) cmd ::= SHOW CREATE STABLE full_table_name */ + { 257, -2 }, /* (213) cmd ::= SHOW QUERIES */ + { 257, -2 }, /* (214) cmd ::= SHOW SCORES */ + { 257, -2 }, /* (215) cmd ::= SHOW TOPICS */ + { 257, -2 }, /* (216) cmd ::= SHOW VARIABLES */ + { 257, -3 }, /* (217) cmd ::= SHOW LOCAL VARIABLES */ + { 257, -4 }, /* (218) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + { 257, -2 }, /* (219) cmd ::= SHOW BNODES */ + { 257, -2 }, /* (220) cmd ::= SHOW SNODES */ + { 257, -2 }, /* (221) cmd ::= SHOW CLUSTER */ + { 257, -2 }, /* (222) cmd ::= SHOW TRANSACTIONS */ + { 257, -4 }, /* (223) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 257, -2 }, /* (224) cmd ::= SHOW CONSUMERS */ + { 257, -2 }, /* (225) cmd ::= SHOW SUBSCRIPTIONS */ + { 257, -5 }, /* (226) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + { 305, 0 }, /* (227) db_name_cond_opt ::= */ + { 305, -2 }, /* (228) db_name_cond_opt ::= db_name NK_DOT */ + { 306, 0 }, /* (229) like_pattern_opt ::= */ + { 306, -2 }, /* (230) like_pattern_opt ::= LIKE NK_STRING */ + { 307, -1 }, /* (231) table_name_cond ::= table_name */ + { 308, 0 }, /* (232) from_db_opt ::= */ + { 308, -2 }, /* (233) from_db_opt ::= FROM db_name */ + { 257, -8 }, /* (234) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 257, -4 }, /* (235) cmd ::= DROP INDEX exists_opt index_name */ + { 310, -10 }, /* (236) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 310, -12 }, /* (237) 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 */ + { 311, -1 }, /* (238) func_list ::= func */ + { 311, -3 }, /* (239) func_list ::= func_list NK_COMMA func */ + { 314, -4 }, /* (240) func ::= function_name NK_LP expression_list NK_RP */ + { 313, 0 }, /* (241) sma_stream_opt ::= */ + { 313, -3 }, /* (242) sma_stream_opt ::= stream_options WATERMARK duration_literal */ + { 313, -3 }, /* (243) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ + { 257, -6 }, /* (244) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 257, -7 }, /* (245) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 257, -9 }, /* (246) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 257, -7 }, /* (247) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 257, -9 }, /* (248) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 257, -4 }, /* (249) cmd ::= DROP TOPIC exists_opt topic_name */ + { 257, -7 }, /* (250) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 257, -2 }, /* (251) cmd ::= DESC full_table_name */ + { 257, -2 }, /* (252) cmd ::= DESCRIBE full_table_name */ + { 257, -3 }, /* (253) cmd ::= RESET QUERY CACHE */ + { 257, -4 }, /* (254) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + { 319, 0 }, /* (255) analyze_opt ::= */ + { 319, -1 }, /* (256) analyze_opt ::= ANALYZE */ + { 320, 0 }, /* (257) explain_options ::= */ + { 320, -3 }, /* (258) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 320, -3 }, /* (259) explain_options ::= explain_options RATIO NK_FLOAT */ + { 257, -10 }, /* (260) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 257, -4 }, /* (261) cmd ::= DROP FUNCTION exists_opt function_name */ + { 321, 0 }, /* (262) agg_func_opt ::= */ + { 321, -1 }, /* (263) agg_func_opt ::= AGGREGATE */ + { 322, 0 }, /* (264) bufsize_opt ::= */ + { 322, -2 }, /* (265) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 257, -8 }, /* (266) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ + { 257, -4 }, /* (267) cmd ::= DROP STREAM exists_opt stream_name */ + { 324, 0 }, /* (268) into_opt ::= */ + { 324, -2 }, /* (269) into_opt ::= INTO full_table_name */ + { 315, 0 }, /* (270) stream_options ::= */ + { 315, -3 }, /* (271) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 315, -3 }, /* (272) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 315, -4 }, /* (273) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 315, -3 }, /* (274) stream_options ::= stream_options WATERMARK duration_literal */ + { 315, -3 }, /* (275) stream_options ::= stream_options IGNORE EXPIRED */ + { 257, -3 }, /* (276) cmd ::= KILL CONNECTION NK_INTEGER */ + { 257, -3 }, /* (277) cmd ::= KILL QUERY NK_STRING */ + { 257, -3 }, /* (278) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 257, -2 }, /* (279) cmd ::= BALANCE VGROUP */ + { 257, -4 }, /* (280) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 257, -4 }, /* (281) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 257, -3 }, /* (282) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 325, -2 }, /* (283) dnode_list ::= DNODE NK_INTEGER */ + { 325, -3 }, /* (284) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 257, -4 }, /* (285) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 257, -1 }, /* (286) cmd ::= query_expression */ + { 257, -7 }, /* (287) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression */ + { 257, -4 }, /* (288) cmd ::= INSERT INTO full_table_name query_expression */ + { 260, -1 }, /* (289) literal ::= NK_INTEGER */ + { 260, -1 }, /* (290) literal ::= NK_FLOAT */ + { 260, -1 }, /* (291) literal ::= NK_STRING */ + { 260, -1 }, /* (292) literal ::= NK_BOOL */ + { 260, -2 }, /* (293) literal ::= TIMESTAMP NK_STRING */ + { 260, -1 }, /* (294) literal ::= duration_literal */ + { 260, -1 }, /* (295) literal ::= NULL */ + { 260, -1 }, /* (296) literal ::= NK_QUESTION */ + { 301, -1 }, /* (297) duration_literal ::= NK_VARIABLE */ + { 327, -1 }, /* (298) signed ::= NK_INTEGER */ + { 327, -2 }, /* (299) signed ::= NK_PLUS NK_INTEGER */ + { 327, -2 }, /* (300) signed ::= NK_MINUS NK_INTEGER */ + { 327, -1 }, /* (301) signed ::= NK_FLOAT */ + { 327, -2 }, /* (302) signed ::= NK_PLUS NK_FLOAT */ + { 327, -2 }, /* (303) signed ::= NK_MINUS NK_FLOAT */ + { 290, -1 }, /* (304) signed_literal ::= signed */ + { 290, -1 }, /* (305) signed_literal ::= NK_STRING */ + { 290, -1 }, /* (306) signed_literal ::= NK_BOOL */ + { 290, -2 }, /* (307) signed_literal ::= TIMESTAMP NK_STRING */ + { 290, -1 }, /* (308) signed_literal ::= duration_literal */ + { 290, -1 }, /* (309) signed_literal ::= NULL */ + { 290, -1 }, /* (310) signed_literal ::= literal_func */ + { 290, -1 }, /* (311) signed_literal ::= NK_QUESTION */ + { 329, -1 }, /* (312) literal_list ::= signed_literal */ + { 329, -3 }, /* (313) literal_list ::= literal_list NK_COMMA signed_literal */ + { 268, -1 }, /* (314) db_name ::= NK_ID */ + { 296, -1 }, /* (315) table_name ::= NK_ID */ + { 288, -1 }, /* (316) column_name ::= NK_ID */ + { 303, -1 }, /* (317) function_name ::= NK_ID */ + { 330, -1 }, /* (318) table_alias ::= NK_ID */ + { 331, -1 }, /* (319) column_alias ::= NK_ID */ + { 262, -1 }, /* (320) user_name ::= NK_ID */ + { 309, -1 }, /* (321) index_name ::= NK_ID */ + { 316, -1 }, /* (322) topic_name ::= NK_ID */ + { 323, -1 }, /* (323) stream_name ::= NK_ID */ + { 318, -1 }, /* (324) cgroup_name ::= NK_ID */ + { 332, -1 }, /* (325) expression ::= literal */ + { 332, -1 }, /* (326) expression ::= pseudo_column */ + { 332, -1 }, /* (327) expression ::= column_reference */ + { 332, -1 }, /* (328) expression ::= function_expression */ + { 332, -1 }, /* (329) expression ::= subquery */ + { 332, -3 }, /* (330) expression ::= NK_LP expression NK_RP */ + { 332, -2 }, /* (331) expression ::= NK_PLUS expression */ + { 332, -2 }, /* (332) expression ::= NK_MINUS expression */ + { 332, -3 }, /* (333) expression ::= expression NK_PLUS expression */ + { 332, -3 }, /* (334) expression ::= expression NK_MINUS expression */ + { 332, -3 }, /* (335) expression ::= expression NK_STAR expression */ + { 332, -3 }, /* (336) expression ::= expression NK_SLASH expression */ + { 332, -3 }, /* (337) expression ::= expression NK_REM expression */ + { 332, -3 }, /* (338) expression ::= column_reference NK_ARROW NK_STRING */ + { 332, -3 }, /* (339) expression ::= expression NK_BITAND expression */ + { 332, -3 }, /* (340) expression ::= expression NK_BITOR expression */ + { 293, -1 }, /* (341) expression_list ::= expression */ + { 293, -3 }, /* (342) expression_list ::= expression_list NK_COMMA expression */ + { 334, -1 }, /* (343) column_reference ::= column_name */ + { 334, -3 }, /* (344) column_reference ::= table_name NK_DOT column_name */ + { 333, -1 }, /* (345) pseudo_column ::= ROWTS */ + { 333, -1 }, /* (346) pseudo_column ::= TBNAME */ + { 333, -3 }, /* (347) pseudo_column ::= table_name NK_DOT TBNAME */ + { 333, -1 }, /* (348) pseudo_column ::= QSTART */ + { 333, -1 }, /* (349) pseudo_column ::= QEND */ + { 333, -1 }, /* (350) pseudo_column ::= QDURATION */ + { 333, -1 }, /* (351) pseudo_column ::= WSTART */ + { 333, -1 }, /* (352) pseudo_column ::= WEND */ + { 333, -1 }, /* (353) pseudo_column ::= WDURATION */ + { 335, -4 }, /* (354) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 335, -4 }, /* (355) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 335, -6 }, /* (356) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ + { 335, -1 }, /* (357) function_expression ::= literal_func */ + { 328, -3 }, /* (358) literal_func ::= noarg_func NK_LP NK_RP */ + { 328, -1 }, /* (359) literal_func ::= NOW */ + { 339, -1 }, /* (360) noarg_func ::= NOW */ + { 339, -1 }, /* (361) noarg_func ::= TODAY */ + { 339, -1 }, /* (362) noarg_func ::= TIMEZONE */ + { 339, -1 }, /* (363) noarg_func ::= DATABASE */ + { 339, -1 }, /* (364) noarg_func ::= CLIENT_VERSION */ + { 339, -1 }, /* (365) noarg_func ::= SERVER_VERSION */ + { 339, -1 }, /* (366) noarg_func ::= SERVER_STATUS */ + { 339, -1 }, /* (367) noarg_func ::= CURRENT_USER */ + { 339, -1 }, /* (368) noarg_func ::= USER */ + { 337, -1 }, /* (369) star_func ::= COUNT */ + { 337, -1 }, /* (370) star_func ::= FIRST */ + { 337, -1 }, /* (371) star_func ::= LAST */ + { 337, -1 }, /* (372) star_func ::= LAST_ROW */ + { 338, -1 }, /* (373) star_func_para_list ::= NK_STAR */ + { 338, -1 }, /* (374) star_func_para_list ::= other_para_list */ + { 340, -1 }, /* (375) other_para_list ::= star_func_para */ + { 340, -3 }, /* (376) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 341, -1 }, /* (377) star_func_para ::= expression */ + { 341, -3 }, /* (378) star_func_para ::= table_name NK_DOT NK_STAR */ + { 342, -3 }, /* (379) predicate ::= expression compare_op expression */ + { 342, -5 }, /* (380) predicate ::= expression BETWEEN expression AND expression */ + { 342, -6 }, /* (381) predicate ::= expression NOT BETWEEN expression AND expression */ + { 342, -3 }, /* (382) predicate ::= expression IS NULL */ + { 342, -4 }, /* (383) predicate ::= expression IS NOT NULL */ + { 342, -3 }, /* (384) predicate ::= expression in_op in_predicate_value */ + { 343, -1 }, /* (385) compare_op ::= NK_LT */ + { 343, -1 }, /* (386) compare_op ::= NK_GT */ + { 343, -1 }, /* (387) compare_op ::= NK_LE */ + { 343, -1 }, /* (388) compare_op ::= NK_GE */ + { 343, -1 }, /* (389) compare_op ::= NK_NE */ + { 343, -1 }, /* (390) compare_op ::= NK_EQ */ + { 343, -1 }, /* (391) compare_op ::= LIKE */ + { 343, -2 }, /* (392) compare_op ::= NOT LIKE */ + { 343, -1 }, /* (393) compare_op ::= MATCH */ + { 343, -1 }, /* (394) compare_op ::= NMATCH */ + { 343, -1 }, /* (395) compare_op ::= CONTAINS */ + { 344, -1 }, /* (396) in_op ::= IN */ + { 344, -2 }, /* (397) in_op ::= NOT IN */ + { 345, -3 }, /* (398) in_predicate_value ::= NK_LP literal_list NK_RP */ + { 346, -1 }, /* (399) boolean_value_expression ::= boolean_primary */ + { 346, -2 }, /* (400) boolean_value_expression ::= NOT boolean_primary */ + { 346, -3 }, /* (401) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 346, -3 }, /* (402) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 347, -1 }, /* (403) boolean_primary ::= predicate */ + { 347, -3 }, /* (404) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 348, -1 }, /* (405) common_expression ::= expression */ + { 348, -1 }, /* (406) common_expression ::= boolean_value_expression */ + { 349, 0 }, /* (407) from_clause_opt ::= */ + { 349, -2 }, /* (408) from_clause_opt ::= FROM table_reference_list */ + { 350, -1 }, /* (409) table_reference_list ::= table_reference */ + { 350, -3 }, /* (410) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 351, -1 }, /* (411) table_reference ::= table_primary */ + { 351, -1 }, /* (412) table_reference ::= joined_table */ + { 352, -2 }, /* (413) table_primary ::= table_name alias_opt */ + { 352, -4 }, /* (414) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 352, -2 }, /* (415) table_primary ::= subquery alias_opt */ + { 352, -1 }, /* (416) table_primary ::= parenthesized_joined_table */ + { 354, 0 }, /* (417) alias_opt ::= */ + { 354, -1 }, /* (418) alias_opt ::= table_alias */ + { 354, -2 }, /* (419) alias_opt ::= AS table_alias */ + { 355, -3 }, /* (420) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 355, -3 }, /* (421) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 353, -6 }, /* (422) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 356, 0 }, /* (423) join_type ::= */ + { 356, -1 }, /* (424) join_type ::= INNER */ + { 358, -12 }, /* (425) 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 */ + { 359, 0 }, /* (426) set_quantifier_opt ::= */ + { 359, -1 }, /* (427) set_quantifier_opt ::= DISTINCT */ + { 359, -1 }, /* (428) set_quantifier_opt ::= ALL */ + { 360, -1 }, /* (429) select_list ::= select_item */ + { 360, -3 }, /* (430) select_list ::= select_list NK_COMMA select_item */ + { 368, -1 }, /* (431) select_item ::= NK_STAR */ + { 368, -1 }, /* (432) select_item ::= common_expression */ + { 368, -2 }, /* (433) select_item ::= common_expression column_alias */ + { 368, -3 }, /* (434) select_item ::= common_expression AS column_alias */ + { 368, -3 }, /* (435) select_item ::= table_name NK_DOT NK_STAR */ + { 326, 0 }, /* (436) where_clause_opt ::= */ + { 326, -2 }, /* (437) where_clause_opt ::= WHERE search_condition */ + { 361, 0 }, /* (438) partition_by_clause_opt ::= */ + { 361, -3 }, /* (439) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 365, 0 }, /* (440) twindow_clause_opt ::= */ + { 365, -6 }, /* (441) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 365, -4 }, /* (442) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + { 365, -6 }, /* (443) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 365, -8 }, /* (444) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 312, 0 }, /* (445) sliding_opt ::= */ + { 312, -4 }, /* (446) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 364, 0 }, /* (447) fill_opt ::= */ + { 364, -4 }, /* (448) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 364, -6 }, /* (449) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 369, -1 }, /* (450) fill_mode ::= NONE */ + { 369, -1 }, /* (451) fill_mode ::= PREV */ + { 369, -1 }, /* (452) fill_mode ::= NULL */ + { 369, -1 }, /* (453) fill_mode ::= LINEAR */ + { 369, -1 }, /* (454) fill_mode ::= NEXT */ + { 366, 0 }, /* (455) group_by_clause_opt ::= */ + { 366, -3 }, /* (456) group_by_clause_opt ::= GROUP BY group_by_list */ + { 370, -1 }, /* (457) group_by_list ::= expression */ + { 370, -3 }, /* (458) group_by_list ::= group_by_list NK_COMMA expression */ + { 367, 0 }, /* (459) having_clause_opt ::= */ + { 367, -2 }, /* (460) having_clause_opt ::= HAVING search_condition */ + { 362, 0 }, /* (461) range_opt ::= */ + { 362, -6 }, /* (462) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ + { 363, 0 }, /* (463) every_opt ::= */ + { 363, -4 }, /* (464) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 317, -4 }, /* (465) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 371, -1 }, /* (466) query_expression_body ::= query_primary */ + { 371, -4 }, /* (467) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 371, -3 }, /* (468) query_expression_body ::= query_expression_body UNION query_expression_body */ + { 375, -1 }, /* (469) query_primary ::= query_specification */ + { 375, -6 }, /* (470) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + { 372, 0 }, /* (471) order_by_clause_opt ::= */ + { 372, -3 }, /* (472) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 373, 0 }, /* (473) slimit_clause_opt ::= */ + { 373, -2 }, /* (474) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 373, -4 }, /* (475) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 373, -4 }, /* (476) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 374, 0 }, /* (477) limit_clause_opt ::= */ + { 374, -2 }, /* (478) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 374, -4 }, /* (479) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 374, -4 }, /* (480) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 336, -3 }, /* (481) subquery ::= NK_LP query_expression NK_RP */ + { 357, -1 }, /* (482) search_condition ::= common_expression */ + { 376, -1 }, /* (483) sort_specification_list ::= sort_specification */ + { 376, -3 }, /* (484) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 377, -3 }, /* (485) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 378, 0 }, /* (486) ordering_specification_opt ::= */ + { 378, -1 }, /* (487) ordering_specification_opt ::= ASC */ + { 378, -1 }, /* (488) ordering_specification_opt ::= DESC */ + { 379, 0 }, /* (489) null_ordering_opt ::= */ + { 379, -2 }, /* (490) null_ordering_opt ::= NULLS FIRST */ + { 379, -2 }, /* (491) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3303,11 +3295,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,257,&yymsp[0].minor); + yy_destructor(yypParser,258,&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,258,&yymsp[0].minor); + yy_destructor(yypParser,259,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3321,20 +3313,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,257,&yymsp[-2].minor); +{ yy_destructor(yypParser,258,&yymsp[-2].minor); { } - yy_destructor(yypParser,259,&yymsp[0].minor); + yy_destructor(yypParser,260,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,260,&yymsp[0].minor); +{ yy_destructor(yypParser,261,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,258,&yymsp[-1].minor); +{ yy_destructor(yypParser,259,&yymsp[-1].minor); { } - yy_destructor(yypParser,260,&yymsp[0].minor); + yy_destructor(yypParser,261,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3348,72 +3340,72 @@ 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,259,&yymsp[0].minor); + yy_destructor(yypParser,260,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy361, &yymsp[-1].minor.yy0, yymsp[0].minor.yy285); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy0, yymsp[0].minor.yy543); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy361, 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.yy361, 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.yy361, 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.yy361); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy129); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy285 = 1; } +{ yymsp[1].minor.yy543 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy285 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy543 = 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.yy457, &yymsp[-2].minor.yy361, &yymsp[0].minor.yy361); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy549, &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.yy457, &yymsp[-2].minor.yy361, &yymsp[0].minor.yy361); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy549, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy457 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy549 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ case 35: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==35); -{ yylhsminor.yy457 = yymsp[0].minor.yy457; } - yymsp[0].minor.yy457 = yylhsminor.yy457; +{ yylhsminor.yy549 = yymsp[0].minor.yy549; } + yymsp[0].minor.yy549 = yylhsminor.yy549; break; case 36: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy457 = yymsp[-2].minor.yy457 | yymsp[0].minor.yy457; } - yymsp[-2].minor.yy457 = yylhsminor.yy457; +{ yylhsminor.yy549 = yymsp[-2].minor.yy549 | yymsp[0].minor.yy549; } + yymsp[-2].minor.yy549 = yylhsminor.yy549; break; case 37: /* priv_type ::= READ */ -{ yymsp[0].minor.yy457 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy549 = PRIVILEGE_TYPE_READ; } break; case 38: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy457 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy549 = PRIVILEGE_TYPE_WRITE; } break; case 39: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy361 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy361 = yylhsminor.yy361; +{ yylhsminor.yy129 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy129 = yylhsminor.yy129; break; case 40: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy361 = yymsp[-2].minor.yy361; } - yymsp[-2].minor.yy361 = yylhsminor.yy361; +{ yylhsminor.yy129 = yymsp[-2].minor.yy129; } + yymsp[-2].minor.yy129 = yylhsminor.yy129; break; case 41: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy361, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy129, NULL); } break; case 42: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy361, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } break; case 43: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 44: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy361); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy129); } break; case 45: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3430,32 +3422,32 @@ static YYACTIONTYPE yy_reduce( case 49: /* dnode_endpoint ::= NK_STRING */ case 50: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==50); case 51: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==51); - case 310: /* db_name ::= NK_ID */ yytestcase(yyruleno==310); - case 311: /* table_name ::= NK_ID */ yytestcase(yyruleno==311); - case 312: /* column_name ::= NK_ID */ yytestcase(yyruleno==312); - case 313: /* function_name ::= NK_ID */ yytestcase(yyruleno==313); - case 314: /* table_alias ::= NK_ID */ yytestcase(yyruleno==314); - case 315: /* column_alias ::= NK_ID */ yytestcase(yyruleno==315); - case 316: /* user_name ::= NK_ID */ yytestcase(yyruleno==316); - case 317: /* index_name ::= NK_ID */ yytestcase(yyruleno==317); - case 318: /* topic_name ::= NK_ID */ yytestcase(yyruleno==318); - case 319: /* stream_name ::= NK_ID */ yytestcase(yyruleno==319); - case 320: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==320); - case 356: /* noarg_func ::= NOW */ yytestcase(yyruleno==356); - case 357: /* noarg_func ::= TODAY */ yytestcase(yyruleno==357); - case 358: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==358); - case 359: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==359); - case 360: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==360); - case 361: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==361); - case 362: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==362); - case 363: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==363); - case 364: /* noarg_func ::= USER */ yytestcase(yyruleno==364); - case 365: /* star_func ::= COUNT */ yytestcase(yyruleno==365); - case 366: /* star_func ::= FIRST */ yytestcase(yyruleno==366); - case 367: /* star_func ::= LAST */ yytestcase(yyruleno==367); - case 368: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==368); -{ yylhsminor.yy361 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy361 = yylhsminor.yy361; + case 314: /* db_name ::= NK_ID */ yytestcase(yyruleno==314); + case 315: /* table_name ::= NK_ID */ yytestcase(yyruleno==315); + case 316: /* column_name ::= NK_ID */ yytestcase(yyruleno==316); + case 317: /* function_name ::= NK_ID */ yytestcase(yyruleno==317); + case 318: /* table_alias ::= NK_ID */ yytestcase(yyruleno==318); + case 319: /* column_alias ::= NK_ID */ yytestcase(yyruleno==319); + case 320: /* user_name ::= NK_ID */ yytestcase(yyruleno==320); + case 321: /* index_name ::= NK_ID */ yytestcase(yyruleno==321); + case 322: /* topic_name ::= NK_ID */ yytestcase(yyruleno==322); + case 323: /* stream_name ::= NK_ID */ yytestcase(yyruleno==323); + case 324: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==324); + case 360: /* noarg_func ::= NOW */ yytestcase(yyruleno==360); + case 361: /* noarg_func ::= TODAY */ yytestcase(yyruleno==361); + case 362: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==362); + case 363: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==363); + case 364: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==364); + case 365: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==365); + case 366: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==366); + case 367: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==367); + case 368: /* noarg_func ::= USER */ yytestcase(yyruleno==368); + case 369: /* star_func ::= COUNT */ yytestcase(yyruleno==369); + case 370: /* star_func ::= FIRST */ yytestcase(yyruleno==370); + case 371: /* star_func ::= LAST */ yytestcase(yyruleno==371); + case 372: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==372); +{ yylhsminor.yy129 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy129 = yylhsminor.yy129; break; case 52: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3488,1238 +3480,1263 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 62: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy151, &yymsp[-1].minor.yy361, yymsp[0].minor.yy616); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy337, &yymsp[-1].minor.yy129, yymsp[0].minor.yy712); } break; case 63: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy151, &yymsp[0].minor.yy361); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy337, &yymsp[0].minor.yy129); } break; case 64: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy361); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy129); } break; case 65: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy361, yymsp[0].minor.yy616); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy712); } break; case 66: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy361); } +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy129); } break; case 67: /* cmd ::= TRIM DATABASE db_name */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[0].minor.yy361); } +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[0].minor.yy129); } break; case 68: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy151 = true; } +{ yymsp[-2].minor.yy337 = true; } break; case 69: /* not_exists_opt ::= */ case 71: /* exists_opt ::= */ yytestcase(yyruleno==71); - case 249: /* analyze_opt ::= */ yytestcase(yyruleno==249); - case 257: /* agg_func_opt ::= */ yytestcase(yyruleno==257); - case 422: /* set_quantifier_opt ::= */ yytestcase(yyruleno==422); -{ yymsp[1].minor.yy151 = false; } + case 255: /* analyze_opt ::= */ yytestcase(yyruleno==255); + case 262: /* agg_func_opt ::= */ yytestcase(yyruleno==262); + case 426: /* set_quantifier_opt ::= */ yytestcase(yyruleno==426); +{ yymsp[1].minor.yy337 = false; } break; case 70: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy151 = true; } +{ yymsp[-1].minor.yy337 = true; } break; case 72: /* db_options ::= */ -{ yymsp[1].minor.yy616 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy712 = createDefaultDatabaseOptions(pCxt); } break; case 73: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 74: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 75: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 76: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 77: /* db_options ::= db_options DURATION NK_INTEGER */ case 78: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==78); -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 79: /* db_options ::= db_options MAXROWS NK_INTEGER */ +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 80: /* db_options ::= db_options MINROWS NK_INTEGER */ +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 81: /* db_options ::= db_options KEEP integer_list */ + case 82: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==82); +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_KEEP, yymsp[0].minor.yy464); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 83: /* db_options ::= db_options PAGES NK_INTEGER */ +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 84: /* db_options ::= db_options PAGESIZE NK_INTEGER */ +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 85: /* db_options ::= db_options PRECISION NK_STRING */ +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 86: /* db_options ::= db_options REPLICA NK_INTEGER */ +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 87: /* db_options ::= db_options STRICT NK_STRING */ +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 79: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 88: /* db_options ::= db_options VGROUPS NK_INTEGER */ +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 80: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 81: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 82: /* db_options ::= db_options KEEP integer_list */ - case 83: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==83); -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_KEEP, yymsp[0].minor.yy356); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 84: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 85: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 86: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 87: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 88: /* db_options ::= db_options STRICT NK_STRING */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 89: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 90: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 91: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 92: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_RETENTIONS, yymsp[0].minor.yy356); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 93: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy616 = setDatabaseOption(pCxt, yymsp[-2].minor.yy616, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 94: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy616 = createAlterDatabaseOptions(pCxt); yylhsminor.yy616 = setAlterDatabaseOption(pCxt, yylhsminor.yy616, &yymsp[0].minor.yy409); } - yymsp[0].minor.yy616 = yylhsminor.yy616; - break; - case 95: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy616 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy616, &yymsp[0].minor.yy409); } - yymsp[-1].minor.yy616 = yylhsminor.yy616; - break; - case 96: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy409.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy409.val = yymsp[0].minor.yy0; } - break; - case 97: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy409.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy409.val = yymsp[0].minor.yy0; } - break; - case 98: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy409.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy409.val = yymsp[0].minor.yy0; } - break; - case 99: /* alter_db_option ::= KEEP integer_list */ - case 100: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==100); -{ yymsp[-1].minor.yy409.type = DB_OPTION_KEEP; yymsp[-1].minor.yy409.pList = yymsp[0].minor.yy356; } - break; - case 101: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy409.type = DB_OPTION_WAL; yymsp[-1].minor.yy409.val = yymsp[0].minor.yy0; } - break; - case 102: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy356 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy356 = yylhsminor.yy356; - break; - case 103: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 279: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==279); -{ yylhsminor.yy356 = addNodeToList(pCxt, yymsp[-2].minor.yy356, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy356 = yylhsminor.yy356; - break; - case 104: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy356 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy356 = yylhsminor.yy356; - break; - case 105: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy356 = addNodeToList(pCxt, yymsp[-2].minor.yy356, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy356 = yylhsminor.yy356; - break; - case 106: /* retention_list ::= retention */ - case 126: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==126); - case 129: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==129); - case 136: /* column_def_list ::= column_def */ yytestcase(yyruleno==136); - case 179: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==179); - case 184: /* col_name_list ::= col_name */ yytestcase(yyruleno==184); - case 232: /* func_list ::= func */ yytestcase(yyruleno==232); - case 308: /* literal_list ::= signed_literal */ yytestcase(yyruleno==308); - case 371: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==371); - case 425: /* select_list ::= select_item */ yytestcase(yyruleno==425); - case 479: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==479); -{ yylhsminor.yy356 = createNodeList(pCxt, yymsp[0].minor.yy616); } - yymsp[0].minor.yy356 = yylhsminor.yy356; - break; - case 107: /* retention_list ::= retention_list NK_COMMA retention */ - case 137: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==137); - case 180: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==180); - case 185: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==185); - case 233: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==233); - case 309: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==309); - case 372: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==372); - case 426: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==426); - case 480: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==480); -{ yylhsminor.yy356 = addNodeToList(pCxt, yymsp[-2].minor.yy356, yymsp[0].minor.yy616); } - yymsp[-2].minor.yy356 = yylhsminor.yy356; - break; - case 108: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy616 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 109: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 111: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==111); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy151, yymsp[-5].minor.yy616, yymsp[-3].minor.yy356, yymsp[-1].minor.yy356, yymsp[0].minor.yy616); } - break; - case 110: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy356); } - break; - case 112: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy356); } - break; - case 113: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy151, yymsp[0].minor.yy616); } - break; - case 114: /* cmd ::= ALTER TABLE alter_table_clause */ - case 282: /* cmd ::= query_expression */ yytestcase(yyruleno==282); -{ pCxt->pRootNode = yymsp[0].minor.yy616; } - break; - case 115: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy616); } - break; - case 116: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy616 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy616, yymsp[0].minor.yy616); } - yymsp[-1].minor.yy616 = yylhsminor.yy616; - break; - case 117: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy616 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy616, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy361, yymsp[0].minor.yy600); } - yymsp[-4].minor.yy616 = yylhsminor.yy616; - break; - case 118: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy616 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy616, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy361); } - yymsp[-3].minor.yy616 = yylhsminor.yy616; - break; - case 119: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy616 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy616, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy361, yymsp[0].minor.yy600); } - yymsp[-4].minor.yy616 = yylhsminor.yy616; + case 89: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 120: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy616 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy616, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy361, &yymsp[0].minor.yy361); } - yymsp[-4].minor.yy616 = yylhsminor.yy616; + case 90: /* db_options ::= db_options RETENTIONS retention_list */ +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_RETENTIONS, yymsp[0].minor.yy464); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 121: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy616 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy616, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy361, yymsp[0].minor.yy600); } - yymsp[-4].minor.yy616 = yylhsminor.yy616; - break; - case 122: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy616 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy616, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy361); } - yymsp[-3].minor.yy616 = yylhsminor.yy616; + case 91: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 123: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy616 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy616, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy361, yymsp[0].minor.yy600); } - yymsp[-4].minor.yy616 = yylhsminor.yy616; + case 92: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 124: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy616 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy616, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy361, &yymsp[0].minor.yy361); } - yymsp[-4].minor.yy616 = yylhsminor.yy616; + case 93: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 125: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy616 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy616, &yymsp[-2].minor.yy361, yymsp[0].minor.yy616); } - yymsp[-5].minor.yy616 = yylhsminor.yy616; + case 94: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ +{ 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 127: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 130: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==130); -{ yylhsminor.yy356 = addNodeToList(pCxt, yymsp[-1].minor.yy356, yymsp[0].minor.yy616); } - yymsp[-1].minor.yy356 = yylhsminor.yy356; + case 95: /* 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.yy712 = setDatabaseOption(pCxt, yymsp[-3].minor.yy712, DB_OPTION_WAL_RETENTION_PERIOD, &t); + } + yymsp[-3].minor.yy712 = yylhsminor.yy712; + break; + case 96: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ +{ 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 97: /* 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.yy712 = setDatabaseOption(pCxt, yymsp[-3].minor.yy712, DB_OPTION_WAL_RETENTION_SIZE, &t); + } + yymsp[-3].minor.yy712 = yylhsminor.yy712; + break; + case 98: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ +{ 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 99: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ +{ 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 100: /* alter_db_options ::= alter_db_option */ +{ yylhsminor.yy712 = createAlterDatabaseOptions(pCxt); yylhsminor.yy712 = setAlterDatabaseOption(pCxt, yylhsminor.yy712, &yymsp[0].minor.yy405); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 101: /* alter_db_options ::= alter_db_options alter_db_option */ +{ yylhsminor.yy712 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy712, &yymsp[0].minor.yy405); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; + break; + case 102: /* alter_db_option ::= CACHEMODEL NK_STRING */ +{ yymsp[-1].minor.yy405.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy405.val = yymsp[0].minor.yy0; } + break; + case 103: /* alter_db_option ::= CACHESIZE NK_INTEGER */ +{ yymsp[-1].minor.yy405.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy405.val = yymsp[0].minor.yy0; } + break; + case 104: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ +{ yymsp[-1].minor.yy405.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy405.val = yymsp[0].minor.yy0; } + break; + case 105: /* alter_db_option ::= KEEP integer_list */ + case 106: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==106); +{ yymsp[-1].minor.yy405.type = DB_OPTION_KEEP; yymsp[-1].minor.yy405.pList = yymsp[0].minor.yy464; } + break; + case 107: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ +{ yymsp[-1].minor.yy405.type = DB_OPTION_WAL; yymsp[-1].minor.yy405.val = yymsp[0].minor.yy0; } + break; + case 108: /* integer_list ::= NK_INTEGER */ +{ yylhsminor.yy464 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy464 = yylhsminor.yy464; + break; + case 109: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ + case 284: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==284); +{ yylhsminor.yy464 = addNodeToList(pCxt, yymsp[-2].minor.yy464, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy464 = yylhsminor.yy464; + break; + case 110: /* variable_list ::= NK_VARIABLE */ +{ yylhsminor.yy464 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy464 = yylhsminor.yy464; + break; + case 111: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ +{ yylhsminor.yy464 = addNodeToList(pCxt, yymsp[-2].minor.yy464, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy464 = yylhsminor.yy464; + break; + case 112: /* retention_list ::= retention */ + case 132: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==132); + case 135: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==135); + case 142: /* column_def_list ::= column_def */ yytestcase(yyruleno==142); + case 185: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==185); + case 190: /* col_name_list ::= col_name */ yytestcase(yyruleno==190); + case 238: /* func_list ::= func */ yytestcase(yyruleno==238); + case 312: /* literal_list ::= signed_literal */ yytestcase(yyruleno==312); + case 375: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==375); + case 429: /* select_list ::= select_item */ yytestcase(yyruleno==429); + case 483: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==483); +{ yylhsminor.yy464 = createNodeList(pCxt, yymsp[0].minor.yy712); } + yymsp[0].minor.yy464 = yylhsminor.yy464; + break; + case 113: /* retention_list ::= retention_list NK_COMMA retention */ + case 143: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==143); + case 186: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==186); + case 191: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==191); + case 239: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==239); + case 313: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==313); + case 376: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==376); + case 430: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==430); + case 484: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==484); +{ yylhsminor.yy464 = addNodeToList(pCxt, yymsp[-2].minor.yy464, yymsp[0].minor.yy712); } + yymsp[-2].minor.yy464 = yylhsminor.yy464; + break; + case 114: /* 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 115: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 117: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==117); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy337, yymsp[-5].minor.yy712, yymsp[-3].minor.yy464, yymsp[-1].minor.yy464, yymsp[0].minor.yy712); } + break; + case 116: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy464); } + break; + case 118: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy464); } + break; + case 119: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy337, yymsp[0].minor.yy712); } + break; + case 120: /* cmd ::= ALTER TABLE alter_table_clause */ + case 286: /* cmd ::= query_expression */ yytestcase(yyruleno==286); +{ pCxt->pRootNode = yymsp[0].minor.yy712; } + break; + case 121: /* cmd ::= ALTER STABLE alter_table_clause */ +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy712); } + break; + case 122: /* 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 123: /* 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 124: /* 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 125: /* 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 126: /* 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 127: /* 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 128: /* 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 129: /* 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 130: /* 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 128: /* 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.yy616 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy151, yymsp[-8].minor.yy616, yymsp[-6].minor.yy616, yymsp[-5].minor.yy356, yymsp[-2].minor.yy356, yymsp[0].minor.yy616); } - yymsp[-9].minor.yy616 = yylhsminor.yy616; + case 131: /* 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 131: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy616 = createDropTableClause(pCxt, yymsp[-1].minor.yy151, yymsp[0].minor.yy616); } - yymsp[-1].minor.yy616 = yylhsminor.yy616; + case 133: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 136: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==136); +{ yylhsminor.yy464 = addNodeToList(pCxt, yymsp[-1].minor.yy464, yymsp[0].minor.yy712); } + yymsp[-1].minor.yy464 = yylhsminor.yy464; break; - case 132: /* specific_cols_opt ::= */ - case 163: /* tags_def_opt ::= */ yytestcase(yyruleno==163); - case 434: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==434); - case 451: /* group_by_clause_opt ::= */ yytestcase(yyruleno==451); - case 467: /* order_by_clause_opt ::= */ yytestcase(yyruleno==467); -{ yymsp[1].minor.yy356 = NULL; } + case 134: /* 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.yy464, yymsp[-2].minor.yy464, yymsp[0].minor.yy712); } + yymsp[-9].minor.yy712 = yylhsminor.yy712; break; - case 133: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy356 = yymsp[-1].minor.yy356; } + case 137: /* 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 134: /* full_table_name ::= table_name */ -{ yylhsminor.yy616 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy361, NULL); } - yymsp[0].minor.yy616 = yylhsminor.yy616; + case 138: /* specific_cols_opt ::= */ + case 169: /* tags_def_opt ::= */ yytestcase(yyruleno==169); + case 438: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==438); + case 455: /* group_by_clause_opt ::= */ yytestcase(yyruleno==455); + case 471: /* order_by_clause_opt ::= */ yytestcase(yyruleno==471); +{ yymsp[1].minor.yy464 = NULL; } break; - case 135: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy616 = createRealTableNode(pCxt, &yymsp[-2].minor.yy361, &yymsp[0].minor.yy361, NULL); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 139: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy464 = yymsp[-1].minor.yy464; } break; - case 138: /* column_def ::= column_name type_name */ -{ yylhsminor.yy616 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy361, yymsp[0].minor.yy600, NULL); } - yymsp[-1].minor.yy616 = yylhsminor.yy616; + case 140: /* full_table_name ::= table_name */ +{ yylhsminor.yy712 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy129, NULL); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 139: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy616 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy361, yymsp[-2].minor.yy600, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy616 = yylhsminor.yy616; + case 141: /* 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 140: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy600 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 144: /* 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 141: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy600 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 145: /* 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 142: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy600 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 146: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 143: /* type_name ::= INT */ - case 144: /* type_name ::= INTEGER */ yytestcase(yyruleno==144); -{ yymsp[0].minor.yy600 = createDataType(TSDB_DATA_TYPE_INT); } + case 147: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 145: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy600 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 148: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 146: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy600 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 149: /* type_name ::= INT */ + case 150: /* type_name ::= INTEGER */ yytestcase(yyruleno==150); +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 147: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy600 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 151: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 148: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy600 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 152: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 149: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy600 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 153: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 150: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy600 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 154: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy184 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 151: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy600 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 155: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 152: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy600 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 156: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy184 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 153: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy600 = createDataType(TSDB_DATA_TYPE_UINT); } + case 157: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy184 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 154: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy600 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 158: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy184 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 155: /* type_name ::= JSON */ -{ yymsp[0].minor.yy600 = createDataType(TSDB_DATA_TYPE_JSON); } + case 159: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy184 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 156: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy600 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 160: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy184 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 157: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy600 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 161: /* type_name ::= JSON */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 158: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy600 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 162: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy184 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 159: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy600 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 163: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 160: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy600 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 164: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 161: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy600 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 165: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy184 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 162: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy600 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 166: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 164: /* tags_def_opt ::= tags_def */ - case 370: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==370); -{ yylhsminor.yy356 = yymsp[0].minor.yy356; } - yymsp[0].minor.yy356 = yylhsminor.yy356; + case 167: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy184 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 165: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy356 = yymsp[-1].minor.yy356; } + case 168: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy184 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 166: /* table_options ::= */ -{ yymsp[1].minor.yy616 = createDefaultTableOptions(pCxt); } + case 170: /* tags_def_opt ::= tags_def */ + case 374: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==374); +{ yylhsminor.yy464 = yymsp[0].minor.yy464; } + yymsp[0].minor.yy464 = yylhsminor.yy464; break; - case 167: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy616 = setTableOption(pCxt, yymsp[-2].minor.yy616, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 171: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy464 = yymsp[-1].minor.yy464; } break; - case 168: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy616 = setTableOption(pCxt, yymsp[-2].minor.yy616, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy356); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 172: /* table_options ::= */ +{ yymsp[1].minor.yy712 = createDefaultTableOptions(pCxt); } break; - case 169: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy616 = setTableOption(pCxt, yymsp[-2].minor.yy616, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy356); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 173: /* 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 170: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy616 = setTableOption(pCxt, yymsp[-4].minor.yy616, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy356); } - yymsp[-4].minor.yy616 = yylhsminor.yy616; + case 174: /* table_options ::= table_options MAX_DELAY duration_list */ +{ yylhsminor.yy712 = setTableOption(pCxt, yymsp[-2].minor.yy712, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy464); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 171: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy616 = setTableOption(pCxt, yymsp[-2].minor.yy616, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 175: /* table_options ::= table_options WATERMARK duration_list */ +{ yylhsminor.yy712 = setTableOption(pCxt, yymsp[-2].minor.yy712, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy464); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 172: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy616 = setTableOption(pCxt, yymsp[-4].minor.yy616, TABLE_OPTION_SMA, yymsp[-1].minor.yy356); } - yymsp[-4].minor.yy616 = yylhsminor.yy616; + case 176: /* 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.yy464); } + yymsp[-4].minor.yy712 = yylhsminor.yy712; break; - case 173: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy616 = createAlterTableOptions(pCxt); yylhsminor.yy616 = setTableOption(pCxt, yylhsminor.yy616, yymsp[0].minor.yy409.type, &yymsp[0].minor.yy409.val); } - yymsp[0].minor.yy616 = yylhsminor.yy616; + case 177: /* 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 174: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy616 = setTableOption(pCxt, yymsp[-1].minor.yy616, yymsp[0].minor.yy409.type, &yymsp[0].minor.yy409.val); } - yymsp[-1].minor.yy616 = yylhsminor.yy616; + case 178: /* 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.yy464); } + yymsp[-4].minor.yy712 = yylhsminor.yy712; break; - case 175: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy409.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy409.val = yymsp[0].minor.yy0; } + case 179: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy712 = createAlterTableOptions(pCxt); yylhsminor.yy712 = setTableOption(pCxt, yylhsminor.yy712, yymsp[0].minor.yy405.type, &yymsp[0].minor.yy405.val); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 176: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy409.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy409.val = yymsp[0].minor.yy0; } + case 180: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy712 = setTableOption(pCxt, yymsp[-1].minor.yy712, yymsp[0].minor.yy405.type, &yymsp[0].minor.yy405.val); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 177: /* duration_list ::= duration_literal */ - case 337: /* expression_list ::= expression */ yytestcase(yyruleno==337); -{ yylhsminor.yy356 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy616)); } - yymsp[0].minor.yy356 = yylhsminor.yy356; + case 181: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy405.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy405.val = yymsp[0].minor.yy0; } break; - case 178: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 338: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==338); -{ yylhsminor.yy356 = addNodeToList(pCxt, yymsp[-2].minor.yy356, releaseRawExprNode(pCxt, yymsp[0].minor.yy616)); } - yymsp[-2].minor.yy356 = yylhsminor.yy356; + case 182: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy405.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy405.val = yymsp[0].minor.yy0; } break; - case 181: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy616 = createFunctionNode(pCxt, &yymsp[0].minor.yy361, NULL); } - yymsp[0].minor.yy616 = yylhsminor.yy616; + case 183: /* duration_list ::= duration_literal */ + case 341: /* expression_list ::= expression */ yytestcase(yyruleno==341); +{ yylhsminor.yy464 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy712)); } + yymsp[0].minor.yy464 = yylhsminor.yy464; break; - case 182: /* rollup_func_name ::= FIRST */ - case 183: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==183); -{ yylhsminor.yy616 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy616 = yylhsminor.yy616; + case 184: /* duration_list ::= duration_list NK_COMMA duration_literal */ + case 342: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==342); +{ yylhsminor.yy464 = addNodeToList(pCxt, yymsp[-2].minor.yy464, releaseRawExprNode(pCxt, yymsp[0].minor.yy712)); } + yymsp[-2].minor.yy464 = yylhsminor.yy464; break; - case 186: /* col_name ::= column_name */ -{ yylhsminor.yy616 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy361); } - yymsp[0].minor.yy616 = yylhsminor.yy616; + case 187: /* rollup_func_name ::= function_name */ +{ yylhsminor.yy712 = createFunctionNode(pCxt, &yymsp[0].minor.yy129, NULL); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 187: /* cmd ::= SHOW DNODES */ + case 188: /* rollup_func_name ::= FIRST */ + case 189: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==189); +{ yylhsminor.yy712 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 192: /* col_name ::= column_name */ +{ yylhsminor.yy712 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 193: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } break; - case 188: /* cmd ::= SHOW USERS */ + case 194: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } break; - case 189: /* cmd ::= SHOW DATABASES */ + case 195: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; - case 190: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy616, yymsp[0].minor.yy616, OP_TYPE_LIKE); } + case 196: /* 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 191: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy616, yymsp[0].minor.yy616, OP_TYPE_LIKE); } + case 197: /* 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 192: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy616, NULL, OP_TYPE_LIKE); } + case 198: /* 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 193: /* cmd ::= SHOW MNODES */ + case 199: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } break; - case 194: /* cmd ::= SHOW MODULES */ + case 200: /* cmd ::= SHOW MODULES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT); } break; - case 195: /* cmd ::= SHOW QNODES */ + case 201: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } break; - case 196: /* cmd ::= SHOW FUNCTIONS */ + case 202: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; - case 197: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy616, yymsp[-1].minor.yy616, OP_TYPE_EQUAL); } + case 203: /* 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 198: /* cmd ::= SHOW STREAMS */ + case 204: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } break; - case 199: /* cmd ::= SHOW ACCOUNTS */ + case 205: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } break; - case 200: /* cmd ::= SHOW APPS */ + case 206: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } break; - case 201: /* cmd ::= SHOW CONNECTIONS */ + case 207: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } break; - case 202: /* cmd ::= SHOW LICENCE */ - case 203: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==203); + case 208: /* cmd ::= SHOW LICENCE */ + case 209: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==209); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT); } break; - case 204: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy361); } + case 210: /* cmd ::= SHOW CREATE DATABASE db_name */ +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy129); } break; - case 205: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy616); } + case 211: /* cmd ::= SHOW CREATE TABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy712); } break; - case 206: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy616); } + case 212: /* cmd ::= SHOW CREATE STABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy712); } break; - case 207: /* cmd ::= SHOW QUERIES */ + case 213: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } break; - case 208: /* cmd ::= SHOW SCORES */ + case 214: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } break; - case 209: /* cmd ::= SHOW TOPICS */ + case 215: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } break; - case 210: /* cmd ::= SHOW VARIABLES */ + case 216: /* cmd ::= SHOW VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } break; - case 211: /* cmd ::= SHOW LOCAL VARIABLES */ + case 217: /* cmd ::= SHOW LOCAL VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; - case 212: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + case 218: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ { pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-1].minor.yy0)); } break; - case 213: /* cmd ::= SHOW BNODES */ + case 219: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } break; - case 214: /* cmd ::= SHOW SNODES */ + case 220: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } break; - case 215: /* cmd ::= SHOW CLUSTER */ + case 221: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } break; - case 216: /* cmd ::= SHOW TRANSACTIONS */ + case 222: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; - case 217: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy616); } + case 223: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy712); } break; - case 218: /* cmd ::= SHOW CONSUMERS */ + case 224: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } break; - case 219: /* cmd ::= SHOW SUBSCRIPTIONS */ + case 225: /* cmd ::= SHOW SUBSCRIPTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; - case 220: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy616, yymsp[-1].minor.yy616, OP_TYPE_EQUAL); } + case 226: /* 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 221: /* db_name_cond_opt ::= */ - case 226: /* from_db_opt ::= */ yytestcase(yyruleno==226); -{ yymsp[1].minor.yy616 = createDefaultDatabaseCondValue(pCxt); } + case 227: /* db_name_cond_opt ::= */ + case 232: /* from_db_opt ::= */ yytestcase(yyruleno==232); +{ yymsp[1].minor.yy712 = createDefaultDatabaseCondValue(pCxt); } break; - case 222: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy616 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy361); } - yymsp[-1].minor.yy616 = yylhsminor.yy616; + case 228: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy129); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 223: /* like_pattern_opt ::= */ - case 263: /* into_opt ::= */ yytestcase(yyruleno==263); - case 403: /* from_clause_opt ::= */ yytestcase(yyruleno==403); - case 432: /* where_clause_opt ::= */ yytestcase(yyruleno==432); - case 436: /* twindow_clause_opt ::= */ yytestcase(yyruleno==436); - case 441: /* sliding_opt ::= */ yytestcase(yyruleno==441); - case 443: /* fill_opt ::= */ yytestcase(yyruleno==443); - case 455: /* having_clause_opt ::= */ yytestcase(yyruleno==455); - case 457: /* range_opt ::= */ yytestcase(yyruleno==457); - case 459: /* every_opt ::= */ yytestcase(yyruleno==459); - case 469: /* slimit_clause_opt ::= */ yytestcase(yyruleno==469); - case 473: /* limit_clause_opt ::= */ yytestcase(yyruleno==473); -{ yymsp[1].minor.yy616 = NULL; } + case 229: /* like_pattern_opt ::= */ + case 268: /* into_opt ::= */ yytestcase(yyruleno==268); + case 407: /* from_clause_opt ::= */ yytestcase(yyruleno==407); + case 436: /* where_clause_opt ::= */ yytestcase(yyruleno==436); + case 440: /* twindow_clause_opt ::= */ yytestcase(yyruleno==440); + case 445: /* sliding_opt ::= */ yytestcase(yyruleno==445); + case 447: /* fill_opt ::= */ yytestcase(yyruleno==447); + case 459: /* having_clause_opt ::= */ yytestcase(yyruleno==459); + case 461: /* range_opt ::= */ yytestcase(yyruleno==461); + case 463: /* every_opt ::= */ yytestcase(yyruleno==463); + case 473: /* slimit_clause_opt ::= */ yytestcase(yyruleno==473); + case 477: /* limit_clause_opt ::= */ yytestcase(yyruleno==477); +{ yymsp[1].minor.yy712 = NULL; } break; - case 224: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy616 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 230: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 225: /* table_name_cond ::= table_name */ -{ yylhsminor.yy616 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy361); } - yymsp[0].minor.yy616 = yylhsminor.yy616; + case 231: /* table_name_cond ::= table_name */ +{ yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy129); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 227: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy616 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy361); } + case 233: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy129); } break; - case 228: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy151, &yymsp[-3].minor.yy361, &yymsp[-1].minor.yy361, NULL, yymsp[0].minor.yy616); } + case 234: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy337, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, NULL, yymsp[0].minor.yy712); } break; - case 229: /* cmd ::= DROP INDEX exists_opt index_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy151, &yymsp[0].minor.yy361); } + case 235: /* cmd ::= DROP INDEX exists_opt index_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy337, &yymsp[0].minor.yy129); } break; - case 230: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy616 = createIndexOption(pCxt, yymsp[-7].minor.yy356, releaseRawExprNode(pCxt, yymsp[-3].minor.yy616), NULL, yymsp[-1].minor.yy616, yymsp[0].minor.yy616); } + case 236: /* 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.yy464, releaseRawExprNode(pCxt, yymsp[-3].minor.yy712), NULL, yymsp[-1].minor.yy712, yymsp[0].minor.yy712); } break; - case 231: /* 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.yy616 = createIndexOption(pCxt, yymsp[-9].minor.yy356, releaseRawExprNode(pCxt, yymsp[-5].minor.yy616), releaseRawExprNode(pCxt, yymsp[-3].minor.yy616), yymsp[-1].minor.yy616, yymsp[0].minor.yy616); } + case 237: /* 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.yy464, releaseRawExprNode(pCxt, yymsp[-5].minor.yy712), releaseRawExprNode(pCxt, yymsp[-3].minor.yy712), yymsp[-1].minor.yy712, yymsp[0].minor.yy712); } break; - case 234: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy616 = createFunctionNode(pCxt, &yymsp[-3].minor.yy361, yymsp[-1].minor.yy356); } - yymsp[-3].minor.yy616 = yylhsminor.yy616; + case 240: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy712 = createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy464); } + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; - case 235: /* sma_stream_opt ::= */ - case 265: /* stream_options ::= */ yytestcase(yyruleno==265); -{ yymsp[1].minor.yy616 = createStreamOptions(pCxt); } + case 241: /* sma_stream_opt ::= */ + case 270: /* stream_options ::= */ yytestcase(yyruleno==270); +{ yymsp[1].minor.yy712 = createStreamOptions(pCxt); } break; - case 236: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ - case 269: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==269); -{ ((SStreamOptions*)yymsp[-2].minor.yy616)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy616); yylhsminor.yy616 = yymsp[-2].minor.yy616; } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 242: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ + case 274: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==274); +{ ((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 237: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy616)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy616); yylhsminor.yy616 = yymsp[-2].minor.yy616; } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 243: /* sma_stream_opt ::= stream_options 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 238: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy151, &yymsp[-2].minor.yy361, yymsp[0].minor.yy616); } + case 244: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy337, &yymsp[-2].minor.yy129, yymsp[0].minor.yy712); } break; - case 239: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy151, &yymsp[-3].minor.yy361, &yymsp[0].minor.yy361, false); } + case 245: /* 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 240: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy151, &yymsp[-5].minor.yy361, &yymsp[0].minor.yy361, true); } + case 246: /* 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 241: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy151, &yymsp[-3].minor.yy361, yymsp[0].minor.yy616, false); } + case 247: /* 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 242: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy151, &yymsp[-5].minor.yy361, yymsp[0].minor.yy616, true); } + case 248: /* 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 243: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy151, &yymsp[0].minor.yy361); } + case 249: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy337, &yymsp[0].minor.yy129); } break; - case 244: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy151, &yymsp[-2].minor.yy361, &yymsp[0].minor.yy361); } + case 250: /* 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 245: /* cmd ::= DESC full_table_name */ - case 246: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==246); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy616); } + case 251: /* cmd ::= DESC full_table_name */ + case 252: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==252); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy712); } break; - case 247: /* cmd ::= RESET QUERY CACHE */ + case 253: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 248: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy151, yymsp[-1].minor.yy616, yymsp[0].minor.yy616); } + case 254: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy337, yymsp[-1].minor.yy712, yymsp[0].minor.yy712); } break; - case 250: /* analyze_opt ::= ANALYZE */ - case 258: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==258); - case 423: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==423); -{ yymsp[0].minor.yy151 = true; } + case 256: /* analyze_opt ::= ANALYZE */ + case 263: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==263); + case 427: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==427); +{ yymsp[0].minor.yy337 = true; } break; - case 251: /* explain_options ::= */ -{ yymsp[1].minor.yy616 = createDefaultExplainOptions(pCxt); } + case 257: /* explain_options ::= */ +{ yymsp[1].minor.yy712 = createDefaultExplainOptions(pCxt); } break; - case 252: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy616 = setExplainVerbose(pCxt, yymsp[-2].minor.yy616, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 258: /* 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 253: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy616 = setExplainRatio(pCxt, yymsp[-2].minor.yy616, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 254: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ -{ pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,273,&yymsp[-1].minor); + case 259: /* 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 255: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy151, yymsp[-8].minor.yy151, &yymsp[-5].minor.yy361, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy600, yymsp[0].minor.yy734); } + case 260: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy337, yymsp[-8].minor.yy337, &yymsp[-5].minor.yy129, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy184, yymsp[0].minor.yy500); } break; - case 256: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy151, &yymsp[0].minor.yy361); } + case 261: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy337, &yymsp[0].minor.yy129); } break; - case 259: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy734 = 0; } + case 264: /* bufsize_opt ::= */ +{ yymsp[1].minor.yy500 = 0; } break; - case 260: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy734 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + case 265: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ +{ yymsp[-1].minor.yy500 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 261: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy151, &yymsp[-4].minor.yy361, yymsp[-2].minor.yy616, yymsp[-3].minor.yy616, yymsp[0].minor.yy616); } + case 266: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy337, &yymsp[-4].minor.yy129, yymsp[-2].minor.yy712, yymsp[-3].minor.yy712, yymsp[0].minor.yy712); } break; - case 262: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy151, &yymsp[0].minor.yy361); } + case 267: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy337, &yymsp[0].minor.yy129); } break; - case 264: /* into_opt ::= INTO full_table_name */ - case 404: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==404); - case 433: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==433); - case 456: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==456); -{ yymsp[-1].minor.yy616 = yymsp[0].minor.yy616; } + case 269: /* into_opt ::= INTO full_table_name */ + case 408: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==408); + case 437: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==437); + case 460: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==460); +{ yymsp[-1].minor.yy712 = yymsp[0].minor.yy712; } break; - case 266: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy616)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy616 = yymsp[-2].minor.yy616; } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 271: /* stream_options ::= stream_options TRIGGER AT_ONCE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy712)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy712 = yymsp[-2].minor.yy712; } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 267: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy616)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy616 = yymsp[-2].minor.yy616; } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 272: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy712)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy712 = yymsp[-2].minor.yy712; } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 268: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy616)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy616)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy616); yylhsminor.yy616 = yymsp[-3].minor.yy616; } - yymsp[-3].minor.yy616 = yylhsminor.yy616; + case 273: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-3].minor.yy712)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy712)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy712); yylhsminor.yy712 = yymsp[-3].minor.yy712; } + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; - case 270: /* stream_options ::= stream_options IGNORE EXPIRED */ -{ ((SStreamOptions*)yymsp[-2].minor.yy616)->ignoreExpired = true; yylhsminor.yy616 = yymsp[-2].minor.yy616; } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 275: /* stream_options ::= stream_options IGNORE EXPIRED */ +{ ((SStreamOptions*)yymsp[-2].minor.yy712)->ignoreExpired = true; yylhsminor.yy712 = yymsp[-2].minor.yy712; } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 271: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 276: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 272: /* cmd ::= KILL QUERY NK_STRING */ + case 277: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 273: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 278: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 274: /* cmd ::= BALANCE VGROUP */ + case 279: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 275: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 280: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 276: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy356); } + case 281: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy464); } break; - case 277: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 282: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 278: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy356 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - break; - case 280: /* cmd ::= SYNCDB db_name REPLICA */ -{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy361); } - break; - case 281: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy616, yymsp[0].minor.yy616); } - break; - case 283: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy616, yymsp[-2].minor.yy356, yymsp[0].minor.yy616); } - break; - case 284: /* cmd ::= INSERT INTO full_table_name query_expression */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy616, NULL, yymsp[0].minor.yy616); } - break; - case 285: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy616 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy616 = yylhsminor.yy616; - break; - case 286: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy616 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy616 = yylhsminor.yy616; - break; - case 287: /* literal ::= NK_STRING */ -{ yylhsminor.yy616 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy616 = yylhsminor.yy616; - break; - case 288: /* literal ::= NK_BOOL */ -{ yylhsminor.yy616 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy616 = yylhsminor.yy616; - break; - case 289: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy616 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy616 = yylhsminor.yy616; - break; - case 290: /* literal ::= duration_literal */ - case 300: /* signed_literal ::= signed */ yytestcase(yyruleno==300); - case 321: /* expression ::= literal */ yytestcase(yyruleno==321); - case 322: /* expression ::= pseudo_column */ yytestcase(yyruleno==322); - case 323: /* expression ::= column_reference */ yytestcase(yyruleno==323); - case 324: /* expression ::= function_expression */ yytestcase(yyruleno==324); - case 325: /* expression ::= subquery */ yytestcase(yyruleno==325); - case 353: /* function_expression ::= literal_func */ yytestcase(yyruleno==353); - case 395: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==395); - case 399: /* boolean_primary ::= predicate */ yytestcase(yyruleno==399); - case 401: /* common_expression ::= expression */ yytestcase(yyruleno==401); - case 402: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==402); - case 405: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==405); - case 407: /* table_reference ::= table_primary */ yytestcase(yyruleno==407); - case 408: /* table_reference ::= joined_table */ yytestcase(yyruleno==408); - case 412: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==412); - case 462: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==462); - case 465: /* query_primary ::= query_specification */ yytestcase(yyruleno==465); -{ yylhsminor.yy616 = yymsp[0].minor.yy616; } - yymsp[0].minor.yy616 = yylhsminor.yy616; - break; - case 291: /* literal ::= NULL */ -{ yylhsminor.yy616 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy616 = yylhsminor.yy616; - break; - case 292: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy616 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy616 = yylhsminor.yy616; - break; - case 293: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy616 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy616 = yylhsminor.yy616; - break; - case 294: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy616 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy616 = yylhsminor.yy616; - break; - case 295: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy616 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - break; - case 296: /* signed ::= NK_MINUS NK_INTEGER */ + case 283: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy464 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + break; + case 285: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy712, yymsp[0].minor.yy712); } + break; + case 287: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy712, yymsp[-2].minor.yy464, yymsp[0].minor.yy712); } + break; + case 288: /* cmd ::= INSERT INTO full_table_name query_expression */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy712, NULL, yymsp[0].minor.yy712); } + break; + case 289: /* 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 290: /* 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 291: /* 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 292: /* 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 293: /* 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 294: /* literal ::= duration_literal */ + case 304: /* signed_literal ::= signed */ yytestcase(yyruleno==304); + case 325: /* expression ::= literal */ yytestcase(yyruleno==325); + case 326: /* expression ::= pseudo_column */ yytestcase(yyruleno==326); + case 327: /* expression ::= column_reference */ yytestcase(yyruleno==327); + case 328: /* expression ::= function_expression */ yytestcase(yyruleno==328); + case 329: /* expression ::= subquery */ yytestcase(yyruleno==329); + case 357: /* function_expression ::= literal_func */ yytestcase(yyruleno==357); + case 399: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==399); + case 403: /* boolean_primary ::= predicate */ yytestcase(yyruleno==403); + case 405: /* common_expression ::= expression */ yytestcase(yyruleno==405); + case 406: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==406); + case 409: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==409); + case 411: /* table_reference ::= table_primary */ yytestcase(yyruleno==411); + case 412: /* table_reference ::= joined_table */ yytestcase(yyruleno==412); + case 416: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==416); + case 466: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==466); + case 469: /* query_primary ::= query_specification */ yytestcase(yyruleno==469); +{ yylhsminor.yy712 = yymsp[0].minor.yy712; } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 295: /* 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 296: /* 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 297: /* 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 298: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 299: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + break; + case 300: /* 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.yy616 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy616 = yylhsminor.yy616; + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 297: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy616 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy616 = yylhsminor.yy616; + case 301: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 298: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy616 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 302: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 299: /* signed ::= NK_MINUS NK_FLOAT */ + case 303: /* 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.yy616 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy616 = yylhsminor.yy616; + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 301: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy616 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy616 = yylhsminor.yy616; + case 305: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 302: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy616 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy616 = yylhsminor.yy616; + case 306: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 303: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy616 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 307: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 304: /* signed_literal ::= duration_literal */ - case 306: /* signed_literal ::= literal_func */ yytestcase(yyruleno==306); - case 373: /* star_func_para ::= expression */ yytestcase(yyruleno==373); - case 428: /* select_item ::= common_expression */ yytestcase(yyruleno==428); - case 478: /* search_condition ::= common_expression */ yytestcase(yyruleno==478); -{ yylhsminor.yy616 = releaseRawExprNode(pCxt, yymsp[0].minor.yy616); } - yymsp[0].minor.yy616 = yylhsminor.yy616; + case 308: /* signed_literal ::= duration_literal */ + case 310: /* signed_literal ::= literal_func */ yytestcase(yyruleno==310); + case 377: /* star_func_para ::= expression */ yytestcase(yyruleno==377); + case 432: /* select_item ::= common_expression */ yytestcase(yyruleno==432); + case 482: /* search_condition ::= common_expression */ yytestcase(yyruleno==482); +{ yylhsminor.yy712 = releaseRawExprNode(pCxt, yymsp[0].minor.yy712); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 305: /* signed_literal ::= NULL */ -{ yylhsminor.yy616 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy616 = yylhsminor.yy616; + case 309: /* signed_literal ::= NULL */ +{ yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 307: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy616 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy616 = yylhsminor.yy616; + case 311: /* signed_literal ::= NK_QUESTION */ +{ yylhsminor.yy712 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 326: /* expression ::= NK_LP expression NK_RP */ - case 400: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==400); -{ yylhsminor.yy616 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy616)); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 330: /* expression ::= NK_LP expression NK_RP */ + case 404: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==404); +{ 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 327: /* expression ::= NK_PLUS expression */ + case 331: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy616)); + 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.yy616 = yylhsminor.yy616; + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 328: /* expression ::= NK_MINUS expression */ + case 332: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy616), 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.yy616 = yylhsminor.yy616; + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 329: /* expression ::= expression NK_PLUS expression */ + case 333: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy616); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), releaseRawExprNode(pCxt, yymsp[0].minor.yy616))); + 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.yy616 = yylhsminor.yy616; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 330: /* expression ::= expression NK_MINUS expression */ + case 334: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy616); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), releaseRawExprNode(pCxt, yymsp[0].minor.yy616))); + 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.yy616 = yylhsminor.yy616; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 331: /* expression ::= expression NK_STAR expression */ + case 335: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy616); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), releaseRawExprNode(pCxt, yymsp[0].minor.yy616))); + 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.yy616 = yylhsminor.yy616; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 332: /* expression ::= expression NK_SLASH expression */ + case 336: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy616); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), releaseRawExprNode(pCxt, yymsp[0].minor.yy616))); + 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.yy616 = yylhsminor.yy616; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 333: /* expression ::= expression NK_REM expression */ + case 337: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy616); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), releaseRawExprNode(pCxt, yymsp[0].minor.yy616))); + 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.yy616 = yylhsminor.yy616; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 334: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 338: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), 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.yy616 = yylhsminor.yy616; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 335: /* expression ::= expression NK_BITAND expression */ + case 339: /* expression ::= expression NK_BITAND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy616); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), releaseRawExprNode(pCxt, yymsp[0].minor.yy616))); + 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.yy616 = yylhsminor.yy616; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 336: /* expression ::= expression NK_BITOR expression */ + case 340: /* expression ::= expression NK_BITOR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy616); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), releaseRawExprNode(pCxt, yymsp[0].minor.yy616))); + 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.yy616 = yylhsminor.yy616; - break; - case 339: /* column_reference ::= column_name */ -{ yylhsminor.yy616 = createRawExprNode(pCxt, &yymsp[0].minor.yy361, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy361)); } - yymsp[0].minor.yy616 = yylhsminor.yy616; - break; - case 340: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy616 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy361, &yymsp[0].minor.yy361, createColumnNode(pCxt, &yymsp[-2].minor.yy361, &yymsp[0].minor.yy361)); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 341: /* pseudo_column ::= ROWTS */ - case 342: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==342); - case 344: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==344); - case 345: /* pseudo_column ::= QEND */ yytestcase(yyruleno==345); - case 346: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==346); - case 347: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==347); - case 348: /* pseudo_column ::= WEND */ yytestcase(yyruleno==348); - case 349: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==349); - case 355: /* literal_func ::= NOW */ yytestcase(yyruleno==355); -{ yylhsminor.yy616 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy616 = yylhsminor.yy616; - break; - case 343: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy616 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy361, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy361)))); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 350: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 351: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==351); -{ yylhsminor.yy616 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy361, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy361, yymsp[-1].minor.yy356)); } - yymsp[-3].minor.yy616 = yylhsminor.yy616; - break; - case 352: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ -{ yylhsminor.yy616 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy616), yymsp[-1].minor.yy600)); } - yymsp[-5].minor.yy616 = yylhsminor.yy616; - break; - case 354: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy616 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy361, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy361, NULL)); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 369: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy356 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy356 = yylhsminor.yy356; - break; - case 374: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 431: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==431); -{ yylhsminor.yy616 = createColumnNode(pCxt, &yymsp[-2].minor.yy361, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; - break; - case 375: /* predicate ::= expression compare_op expression */ - case 380: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==380); + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 343: /* 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 344: /* 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 345: /* pseudo_column ::= ROWTS */ + case 346: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==346); + case 348: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==348); + case 349: /* pseudo_column ::= QEND */ yytestcase(yyruleno==349); + case 350: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==350); + case 351: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==351); + case 352: /* pseudo_column ::= WEND */ yytestcase(yyruleno==352); + case 353: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==353); + case 359: /* literal_func ::= NOW */ yytestcase(yyruleno==359); +{ yylhsminor.yy712 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 347: /* 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 354: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 355: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==355); +{ yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy464)); } + yymsp[-3].minor.yy712 = yylhsminor.yy712; + break; + case 356: /* function_expression ::= CAST NK_LP expression 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 358: /* 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 373: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy464 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy464 = yylhsminor.yy464; + break; + case 378: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 435: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==435); +{ yylhsminor.yy712 = createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 379: /* predicate ::= expression compare_op expression */ + case 384: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==384); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy616); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy526, releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), releaseRawExprNode(pCxt, yymsp[0].minor.yy616))); + 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.yy60, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 376: /* predicate ::= expression BETWEEN expression AND expression */ + case 380: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy616); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy616), releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), releaseRawExprNode(pCxt, yymsp[0].minor.yy616))); + 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.yy616 = yylhsminor.yy616; + yymsp[-4].minor.yy712 = yylhsminor.yy712; break; - case 377: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 381: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy616); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy616), releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), releaseRawExprNode(pCxt, yymsp[0].minor.yy616))); + 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.yy616 = yylhsminor.yy616; + yymsp[-5].minor.yy712 = yylhsminor.yy712; break; - case 378: /* predicate ::= expression IS NULL */ + case 382: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), 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.yy616 = yylhsminor.yy616; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 379: /* predicate ::= expression IS NOT NULL */ + case 383: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy616), 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.yy616 = yylhsminor.yy616; + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; - case 381: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy526 = OP_TYPE_LOWER_THAN; } + case 385: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy60 = OP_TYPE_LOWER_THAN; } break; - case 382: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy526 = OP_TYPE_GREATER_THAN; } + case 386: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy60 = OP_TYPE_GREATER_THAN; } break; - case 383: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy526 = OP_TYPE_LOWER_EQUAL; } + case 387: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy60 = OP_TYPE_LOWER_EQUAL; } break; - case 384: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy526 = OP_TYPE_GREATER_EQUAL; } + case 388: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy60 = OP_TYPE_GREATER_EQUAL; } break; - case 385: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy526 = OP_TYPE_NOT_EQUAL; } + case 389: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy60 = OP_TYPE_NOT_EQUAL; } break; - case 386: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy526 = OP_TYPE_EQUAL; } + case 390: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy60 = OP_TYPE_EQUAL; } break; - case 387: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy526 = OP_TYPE_LIKE; } + case 391: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy60 = OP_TYPE_LIKE; } break; - case 388: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy526 = OP_TYPE_NOT_LIKE; } + case 392: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy60 = OP_TYPE_NOT_LIKE; } break; - case 389: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy526 = OP_TYPE_MATCH; } + case 393: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy60 = OP_TYPE_MATCH; } break; - case 390: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy526 = OP_TYPE_NMATCH; } + case 394: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy60 = OP_TYPE_NMATCH; } break; - case 391: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy526 = OP_TYPE_JSON_CONTAINS; } + case 395: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy60 = OP_TYPE_JSON_CONTAINS; } break; - case 392: /* in_op ::= IN */ -{ yymsp[0].minor.yy526 = OP_TYPE_IN; } + case 396: /* in_op ::= IN */ +{ yymsp[0].minor.yy60 = OP_TYPE_IN; } break; - case 393: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy526 = OP_TYPE_NOT_IN; } + case 397: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy60 = OP_TYPE_NOT_IN; } break; - case 394: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy616 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy356)); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 398: /* 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.yy464)); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 396: /* boolean_value_expression ::= NOT boolean_primary */ + case 400: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy616), 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.yy616 = yylhsminor.yy616; + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 397: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 401: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy616); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), releaseRawExprNode(pCxt, yymsp[0].minor.yy616))); + 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.yy616 = yylhsminor.yy616; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 398: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 402: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy616); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy616); - yylhsminor.yy616 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), releaseRawExprNode(pCxt, yymsp[0].minor.yy616))); + 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.yy616 = yylhsminor.yy616; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 406: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy616 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy616, yymsp[0].minor.yy616, NULL); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 410: /* 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 409: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy616 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy361, &yymsp[0].minor.yy361); } - yymsp[-1].minor.yy616 = yylhsminor.yy616; + case 413: /* 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 410: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy616 = createRealTableNode(pCxt, &yymsp[-3].minor.yy361, &yymsp[-1].minor.yy361, &yymsp[0].minor.yy361); } - yymsp[-3].minor.yy616 = yylhsminor.yy616; + case 414: /* 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 411: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy616 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy616), &yymsp[0].minor.yy361); } - yymsp[-1].minor.yy616 = yylhsminor.yy616; + case 415: /* 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 413: /* alias_opt ::= */ -{ yymsp[1].minor.yy361 = nil_token; } + case 417: /* alias_opt ::= */ +{ yymsp[1].minor.yy129 = nil_token; } break; - case 414: /* alias_opt ::= table_alias */ -{ yylhsminor.yy361 = yymsp[0].minor.yy361; } - yymsp[0].minor.yy361 = yylhsminor.yy361; + case 418: /* alias_opt ::= table_alias */ +{ yylhsminor.yy129 = yymsp[0].minor.yy129; } + yymsp[0].minor.yy129 = yylhsminor.yy129; break; - case 415: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy361 = yymsp[0].minor.yy361; } + case 419: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy129 = yymsp[0].minor.yy129; } break; - case 416: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 417: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==417); -{ yymsp[-2].minor.yy616 = yymsp[-1].minor.yy616; } + case 420: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 421: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==421); +{ yymsp[-2].minor.yy712 = yymsp[-1].minor.yy712; } break; - case 418: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy616 = createJoinTableNode(pCxt, yymsp[-4].minor.yy504, yymsp[-5].minor.yy616, yymsp[-2].minor.yy616, yymsp[0].minor.yy616); } - yymsp[-5].minor.yy616 = yylhsminor.yy616; + case 422: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy712 = createJoinTableNode(pCxt, yymsp[-4].minor.yy532, yymsp[-5].minor.yy712, yymsp[-2].minor.yy712, yymsp[0].minor.yy712); } + yymsp[-5].minor.yy712 = yylhsminor.yy712; break; - case 419: /* join_type ::= */ -{ yymsp[1].minor.yy504 = JOIN_TYPE_INNER; } + case 423: /* join_type ::= */ +{ yymsp[1].minor.yy532 = JOIN_TYPE_INNER; } break; - case 420: /* join_type ::= INNER */ -{ yymsp[0].minor.yy504 = JOIN_TYPE_INNER; } + case 424: /* join_type ::= INNER */ +{ yymsp[0].minor.yy532 = JOIN_TYPE_INNER; } break; - case 421: /* 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 425: /* 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.yy616 = createSelectStmt(pCxt, yymsp[-10].minor.yy151, yymsp[-9].minor.yy356, yymsp[-8].minor.yy616); - yymsp[-11].minor.yy616 = addWhereClause(pCxt, yymsp[-11].minor.yy616, yymsp[-7].minor.yy616); - yymsp[-11].minor.yy616 = addPartitionByClause(pCxt, yymsp[-11].minor.yy616, yymsp[-6].minor.yy356); - yymsp[-11].minor.yy616 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy616, yymsp[-2].minor.yy616); - yymsp[-11].minor.yy616 = addGroupByClause(pCxt, yymsp[-11].minor.yy616, yymsp[-1].minor.yy356); - yymsp[-11].minor.yy616 = addHavingClause(pCxt, yymsp[-11].minor.yy616, yymsp[0].minor.yy616); - yymsp[-11].minor.yy616 = addRangeClause(pCxt, yymsp[-11].minor.yy616, yymsp[-5].minor.yy616); - yymsp[-11].minor.yy616 = addEveryClause(pCxt, yymsp[-11].minor.yy616, yymsp[-4].minor.yy616); - yymsp[-11].minor.yy616 = addFillClause(pCxt, yymsp[-11].minor.yy616, yymsp[-3].minor.yy616); + yymsp[-11].minor.yy712 = createSelectStmt(pCxt, yymsp[-10].minor.yy337, yymsp[-9].minor.yy464, 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.yy464); + 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.yy464); + 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 424: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy151 = false; } + case 428: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy337 = false; } break; - case 427: /* select_item ::= NK_STAR */ -{ yylhsminor.yy616 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy616 = yylhsminor.yy616; + case 431: /* select_item ::= NK_STAR */ +{ yylhsminor.yy712 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 429: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy616 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy616), &yymsp[0].minor.yy361); } - yymsp[-1].minor.yy616 = yylhsminor.yy616; + case 433: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy712 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy712), &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 430: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy616 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), &yymsp[0].minor.yy361); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 434: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy712 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), &yymsp[0].minor.yy129); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 435: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 452: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==452); - case 468: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==468); -{ yymsp[-2].minor.yy356 = yymsp[0].minor.yy356; } + case 439: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 456: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==456); + case 472: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==472); +{ yymsp[-2].minor.yy464 = yymsp[0].minor.yy464; } break; - case 437: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy616 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy616), releaseRawExprNode(pCxt, yymsp[-1].minor.yy616)); } + case 441: /* 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 438: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy616 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy616)); } + case 442: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ +{ yymsp[-3].minor.yy712 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy712)); } break; - case 439: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy616 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy616), NULL, yymsp[-1].minor.yy616, yymsp[0].minor.yy616); } + case 443: /* 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 440: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy616 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy616), releaseRawExprNode(pCxt, yymsp[-3].minor.yy616), yymsp[-1].minor.yy616, yymsp[0].minor.yy616); } + case 444: /* 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 442: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - case 460: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==460); -{ yymsp[-3].minor.yy616 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy616); } + case 446: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + case 464: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==464); +{ yymsp[-3].minor.yy712 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy712); } break; - case 444: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy616 = createFillNode(pCxt, yymsp[-1].minor.yy494, NULL); } + case 448: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy712 = createFillNode(pCxt, yymsp[-1].minor.yy94, NULL); } break; - case 445: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy616 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy356)); } + case 449: /* 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.yy464)); } break; - case 446: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy494 = FILL_MODE_NONE; } + case 450: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy94 = FILL_MODE_NONE; } break; - case 447: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy494 = FILL_MODE_PREV; } + case 451: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy94 = FILL_MODE_PREV; } break; - case 448: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy494 = FILL_MODE_NULL; } + case 452: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy94 = FILL_MODE_NULL; } break; - case 449: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy494 = FILL_MODE_LINEAR; } + case 453: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy94 = FILL_MODE_LINEAR; } break; - case 450: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy494 = FILL_MODE_NEXT; } + case 454: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy94 = FILL_MODE_NEXT; } break; - case 453: /* group_by_list ::= expression */ -{ yylhsminor.yy356 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy616))); } - yymsp[0].minor.yy356 = yylhsminor.yy356; + case 457: /* group_by_list ::= expression */ +{ yylhsminor.yy464 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } + yymsp[0].minor.yy464 = yylhsminor.yy464; break; - case 454: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy356 = addNodeToList(pCxt, yymsp[-2].minor.yy356, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy616))); } - yymsp[-2].minor.yy356 = yylhsminor.yy356; + case 458: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy464 = addNodeToList(pCxt, yymsp[-2].minor.yy464, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } + yymsp[-2].minor.yy464 = yylhsminor.yy464; break; - case 458: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ -{ yymsp[-5].minor.yy616 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy616), releaseRawExprNode(pCxt, yymsp[-1].minor.yy616)); } + case 462: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ +{ yymsp[-5].minor.yy712 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy712), releaseRawExprNode(pCxt, yymsp[-1].minor.yy712)); } break; - case 461: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 465: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy616 = addOrderByClause(pCxt, yymsp[-3].minor.yy616, yymsp[-2].minor.yy356); - yylhsminor.yy616 = addSlimitClause(pCxt, yylhsminor.yy616, yymsp[-1].minor.yy616); - yylhsminor.yy616 = addLimitClause(pCxt, yylhsminor.yy616, yymsp[0].minor.yy616); + yylhsminor.yy712 = addOrderByClause(pCxt, yymsp[-3].minor.yy712, yymsp[-2].minor.yy464); + yylhsminor.yy712 = addSlimitClause(pCxt, yylhsminor.yy712, yymsp[-1].minor.yy712); + yylhsminor.yy712 = addLimitClause(pCxt, yylhsminor.yy712, yymsp[0].minor.yy712); } - yymsp[-3].minor.yy616 = yylhsminor.yy616; + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; - case 463: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy616 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy616, yymsp[0].minor.yy616); } - yymsp[-3].minor.yy616 = yylhsminor.yy616; + case 467: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ 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 464: /* query_expression_body ::= query_expression_body UNION query_expression_body */ -{ yylhsminor.yy616 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy616, yymsp[0].minor.yy616); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 468: /* query_expression_body ::= query_expression_body UNION query_expression_body */ +{ yylhsminor.yy712 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy712, yymsp[0].minor.yy712); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 466: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + case 470: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ { - yymsp[-5].minor.yy616 = addOrderByClause(pCxt, yymsp[-4].minor.yy616, yymsp[-3].minor.yy356); - yymsp[-5].minor.yy616 = addSlimitClause(pCxt, yymsp[-5].minor.yy616, yymsp[-2].minor.yy616); - yymsp[-5].minor.yy616 = addLimitClause(pCxt, yymsp[-5].minor.yy616, yymsp[-1].minor.yy616); + yymsp[-5].minor.yy712 = addOrderByClause(pCxt, yymsp[-4].minor.yy712, yymsp[-3].minor.yy464); + yymsp[-5].minor.yy712 = addSlimitClause(pCxt, yymsp[-5].minor.yy712, yymsp[-2].minor.yy712); + yymsp[-5].minor.yy712 = addLimitClause(pCxt, yymsp[-5].minor.yy712, yymsp[-1].minor.yy712); } break; - case 470: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 474: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==474); -{ yymsp[-1].minor.yy616 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 474: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 478: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==478); +{ yymsp[-1].minor.yy712 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 471: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 475: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==475); -{ yymsp[-3].minor.yy616 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 475: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 479: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==479); +{ yymsp[-3].minor.yy712 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 472: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 476: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==476); -{ yymsp[-3].minor.yy616 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 476: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 480: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==480); +{ yymsp[-3].minor.yy712 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 477: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy616 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy616); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 481: /* 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 481: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy616 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy616), yymsp[-1].minor.yy58, yymsp[0].minor.yy613); } - yymsp[-2].minor.yy616 = yylhsminor.yy616; + case 485: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy712 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), yymsp[-1].minor.yy658, yymsp[0].minor.yy338); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 482: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy58 = ORDER_ASC; } + case 486: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy658 = ORDER_ASC; } break; - case 483: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy58 = ORDER_ASC; } + case 487: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy658 = ORDER_ASC; } break; - case 484: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy58 = ORDER_DESC; } + case 488: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy658 = ORDER_DESC; } break; - case 485: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy613 = NULL_ORDER_DEFAULT; } + case 489: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy338 = NULL_ORDER_DEFAULT; } break; - case 486: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy613 = NULL_ORDER_FIRST; } + case 490: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy338 = NULL_ORDER_FIRST; } break; - case 487: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy613 = NULL_ORDER_LAST; } + case 491: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy338 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parAlterToBalanceTest.cpp b/source/libs/parser/test/parAlterToBalanceTest.cpp index 39052738f6a4def2aff4e5f53ee67b03798d7cd1..1caba6eab0384019b01f0c4957a6b9b9ffa1a5d1 100644 --- a/source/libs/parser/test/parAlterToBalanceTest.cpp +++ b/source/libs/parser/test/parAlterToBalanceTest.cpp @@ -82,12 +82,12 @@ TEST_F(ParserInitialATest, alterDnode) { * BUFFER int_value -- todo: range [3, 16384], default 96, unit MB * | CACHEMODEL {'none' | 'last_row' | 'last_value' | 'both'} -- default 'none' * | CACHESIZE int_value -- range [1, 65536], default 1, unit MB - * | FSYNC int_value -- rang [0, 180000], default 3000, unit ms + * | WAL_FSYNC_PERIOD int_value -- rang [0, 180000], default 3000, unit ms * | KEEP {int_value | duration_value} -- rang [1, 365000], default 3650, unit day * | PAGES int_value -- todo: rang [64, +oo), default 256, unit page * | REPLICA int_value -- todo: enum 1, 3, default 1, unit replica * | STRICT {'off' | 'on'} -- todo: default 'off' - * | WAL int_value -- enum 1, 2, default 1 + * | WAL_LEVEL int_value -- enum 1, 2, default 1 * } */ TEST_F(ParserInitialATest, alterDatabase) { @@ -106,7 +106,7 @@ TEST_F(ParserInitialATest, alterDatabase) { expect.daysToKeep0 = -1; expect.daysToKeep1 = -1; expect.daysToKeep2 = -1; - expect.fsyncPeriod = -1; + expect.walFsyncPeriod = -1; expect.walLevel = -1; expect.strict = -1; expect.cacheLast = -1; @@ -123,7 +123,7 @@ TEST_F(ParserInitialATest, alterDatabase) { expect.daysToKeep1 = (-1 == daysToKeep1 ? expect.daysToKeep0 : daysToKeep1); expect.daysToKeep2 = (-1 == daysToKeep1 ? expect.daysToKeep1 : daysToKeep2); }; - auto setAlterDbFsync = [&](int32_t fsync) { expect.fsyncPeriod = fsync; }; + auto setAlterDbFsync = [&](int32_t fsync) { expect.walFsyncPeriod = fsync; }; auto setAlterDbWal = [&](int8_t wal) { expect.walLevel = wal; }; auto setAlterDbStrict = [&](int8_t strict) { expect.strict = strict; }; auto setAlterDbCacheModel = [&](int8_t cacheModel) { expect.cacheLast = cacheModel; }; @@ -141,7 +141,7 @@ TEST_F(ParserInitialATest, alterDatabase) { ASSERT_EQ(req.daysToKeep0, expect.daysToKeep0); ASSERT_EQ(req.daysToKeep1, expect.daysToKeep1); ASSERT_EQ(req.daysToKeep2, expect.daysToKeep2); - ASSERT_EQ(req.fsyncPeriod, expect.fsyncPeriod); + ASSERT_EQ(req.walFsyncPeriod, expect.walFsyncPeriod); ASSERT_EQ(req.walLevel, expect.walLevel); ASSERT_EQ(req.strict, expect.strict); ASSERT_EQ(req.cacheLast, expect.cacheLast); @@ -157,7 +157,7 @@ TEST_F(ParserInitialATest, alterDatabase) { setAlterDbFsync(200); setAlterDbWal(1); setAlterDbCacheModel(TSDB_CACHE_MODEL_LAST_ROW); - run("ALTER DATABASE test CACHEMODEL 'last_row' CACHESIZE 32 FSYNC 200 KEEP 10 WAL 1"); + run("ALTER DATABASE test CACHEMODEL 'last_row' CACHESIZE 32 WAL_FSYNC_PERIOD 200 KEEP 10 WAL_LEVEL 1"); clearAlterDbReq(); initAlterDb("test"); @@ -182,11 +182,11 @@ TEST_F(ParserInitialATest, alterDatabase) { initAlterDb("test"); setAlterDbFsync(0); - run("ALTER DATABASE test FSYNC 0"); + run("ALTER DATABASE test WAL_FSYNC_PERIOD 0"); setAlterDbFsync(1000); - run("ALTER DATABASE test FSYNC 1000"); + run("ALTER DATABASE test WAL_FSYNC_PERIOD 1000"); setAlterDbFsync(180000); - run("ALTER DATABASE test FSYNC 180000"); + run("ALTER DATABASE test WAL_FSYNC_PERIOD 180000"); clearAlterDbReq(); initAlterDb("test"); @@ -210,9 +210,9 @@ TEST_F(ParserInitialATest, alterDatabase) { initAlterDb("test"); setAlterDbWal(1); - run("ALTER DATABASE test WAL 1"); + run("ALTER DATABASE test WAL_LEVEL 1"); setAlterDbWal(2); - run("ALTER DATABASE test WAL 2"); + run("ALTER DATABASE test WAL_LEVEL 2"); clearAlterDbReq(); } @@ -223,16 +223,16 @@ TEST_F(ParserInitialATest, alterDatabaseSemanticCheck) { run("ALTER DATABASE test CACHESIZE 0", TSDB_CODE_PAR_INVALID_DB_OPTION); run("ALTER DATABASE test CACHESIZE 65537", TSDB_CODE_PAR_INVALID_DB_OPTION); // The syntax limits it to only positive numbers - run("ALTER DATABASE test FSYNC -1", TSDB_CODE_PAR_SYNTAX_ERROR, PARSER_STAGE_PARSE); - run("ALTER DATABASE test FSYNC 180001", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("ALTER DATABASE test WAL_FSYNC_PERIOD -1", TSDB_CODE_PAR_SYNTAX_ERROR, PARSER_STAGE_PARSE); + run("ALTER DATABASE test WAL_FSYNC_PERIOD 180001", TSDB_CODE_PAR_INVALID_DB_OPTION); run("ALTER DATABASE test KEEP 0", TSDB_CODE_PAR_INVALID_DB_OPTION); run("ALTER DATABASE test KEEP 365001", TSDB_CODE_PAR_INVALID_DB_OPTION); run("ALTER DATABASE test KEEP 1000000000s", TSDB_CODE_PAR_INVALID_DB_OPTION); run("ALTER DATABASE test KEEP 1w", TSDB_CODE_PAR_INVALID_DB_OPTION); - run("ALTER DATABASE test WAL 0", TSDB_CODE_PAR_INVALID_DB_OPTION); - run("ALTER DATABASE test WAL 3", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("ALTER DATABASE test WAL_LEVEL 0", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("ALTER DATABASE test WAL_LEVEL 3", TSDB_CODE_PAR_INVALID_DB_OPTION); // Regardless of the specific sentence - run("ALTER DATABASE db WAL 0 # td-14436", TSDB_CODE_PAR_SYNTAX_ERROR, PARSER_STAGE_PARSE); + run("ALTER DATABASE db WAL_LEVEL 0 # td-14436", TSDB_CODE_PAR_SYNTAX_ERROR, PARSER_STAGE_PARSE); } /* diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index a2954b5798fda7ecb29db5ba66b106fb6ea82124..b513ff57edfc0cd1f139805cf4e716992a791300 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -21,12 +21,6 @@ namespace ParserTest { class ParserInitialCTest : public ParserDdlTest {}; -TEST_F(ParserInitialCTest, compact) { - useDb("root", "test"); - - run("COMPACT VNODES IN (1, 2)", TSDB_CODE_PAR_EXPRIE_STATEMENT, PARSER_STAGE_PARSE); -} - TEST_F(ParserInitialCTest, createAccount) { useDb("root", "test"); @@ -64,7 +58,7 @@ TEST_F(ParserInitialCTest, createBnode) { * | CACHESIZE value * | COMP {0 | 1 | 2} * | DURATION value - * | FSYNC value + * | WAL_FSYNC_PERIOD value * | MAXROWS value * | MINROWS value * | KEEP value @@ -74,9 +68,13 @@ TEST_F(ParserInitialCTest, createBnode) { * | REPLICA value * | RETENTIONS ingestion_duration:keep_duration ... * | STRICT {'off' | 'on'} - * | WAL value + * | WAL_LEVEL value * | VGROUPS value * | SINGLE_STABLE {0 | 1} + * | WAL_RETENTION_PERIOD value + * | WAL_ROLL_PERIOD value + * | WAL_RETENTION_SIZE value + * | WAL_SEGMENT_SIZE value * } */ TEST_F(ParserInitialCTest, createDatabase) { @@ -98,7 +96,7 @@ TEST_F(ParserInitialCTest, createDatabase) { expect.cacheLastSize = TSDB_DEFAULT_CACHE_SIZE; expect.compression = TSDB_DEFAULT_COMP_LEVEL; expect.daysPerFile = TSDB_DEFAULT_DAYS_PER_FILE; - expect.fsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD; + expect.walFsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD; expect.maxRows = TSDB_DEFAULT_MAXROWS_FBLOCK; expect.minRows = TSDB_DEFAULT_MINROWS_FBLOCK; expect.daysToKeep0 = TSDB_DEFAULT_KEEP; @@ -120,7 +118,7 @@ TEST_F(ParserInitialCTest, createDatabase) { auto setDbCachelastSize = [&](int8_t cachelastSize) { expect.cacheLastSize = cachelastSize; }; auto setDbCompressionFunc = [&](int8_t compressionLevel) { expect.compression = compressionLevel; }; auto setDbDaysFunc = [&](int32_t daysPerFile) { expect.daysPerFile = daysPerFile; }; - auto setDbFsyncFunc = [&](int32_t fsyncPeriod) { expect.fsyncPeriod = fsyncPeriod; }; + auto setDbFsyncFunc = [&](int32_t fsyncPeriod) { expect.walFsyncPeriod = fsyncPeriod; }; auto setDbMaxRowsFunc = [&](int32_t maxRowsPerBlock) { expect.maxRows = maxRowsPerBlock; }; auto setDbMinRowsFunc = [&](int32_t minRowsPerBlock) { expect.minRows = minRowsPerBlock; }; auto setDbKeepFunc = [&](int32_t keep0, int32_t keep1 = 0, int32_t keep2 = 0) { @@ -149,6 +147,10 @@ TEST_F(ParserInitialCTest, createDatabase) { ++expect.numOfRetensions; }; auto setDbSchemalessFunc = [&](int8_t schemaless) { expect.schemaless = schemaless; }; + auto setDbWalRetentionPeriod = [&](int32_t walRetentionPeriod) { expect.walRetentionPeriod = walRetentionPeriod; }; + auto setDbWalRetentionSize = [&](int32_t walRetentionSize) { expect.walRetentionSize = walRetentionSize; }; + auto setDbWalRollPeriod = [&](int32_t walRollPeriod) { expect.walRollPeriod = walRollPeriod; }; + auto setDbWalSegmentSize = [&](int32_t walSegmentSize) { expect.walSegmentSize = walSegmentSize; }; setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_DATABASE_STMT); @@ -167,7 +169,7 @@ TEST_F(ParserInitialCTest, createDatabase) { ASSERT_EQ(req.daysToKeep2, expect.daysToKeep2); ASSERT_EQ(req.minRows, expect.minRows); ASSERT_EQ(req.maxRows, expect.maxRows); - ASSERT_EQ(req.fsyncPeriod, expect.fsyncPeriod); + ASSERT_EQ(req.walFsyncPeriod, expect.walFsyncPeriod); ASSERT_EQ(req.walLevel, expect.walLevel); ASSERT_EQ(req.precision, expect.precision); ASSERT_EQ(req.compression, expect.compression); @@ -175,6 +177,10 @@ TEST_F(ParserInitialCTest, createDatabase) { ASSERT_EQ(req.strict, expect.strict); ASSERT_EQ(req.cacheLast, expect.cacheLast); ASSERT_EQ(req.cacheLastSize, expect.cacheLastSize); + ASSERT_EQ(req.walRetentionPeriod, expect.walRetentionPeriod); + ASSERT_EQ(req.walRetentionSize, expect.walRetentionSize); + ASSERT_EQ(req.walRollPeriod, expect.walRollPeriod); + ASSERT_EQ(req.walSegmentSize, expect.walSegmentSize); // ASSERT_EQ(req.schemaless, expect.schemaless); ASSERT_EQ(req.ignoreExist, expect.ignoreExist); ASSERT_EQ(req.numOfRetensions, expect.numOfRetensions); @@ -219,13 +225,17 @@ TEST_F(ParserInitialCTest, createDatabase) { setDbVgroupsFunc(100); setDbSingleStableFunc(1); setDbSchemalessFunc(1); + setDbWalRetentionPeriod(-1); + setDbWalRetentionSize(-1); + setDbWalRollPeriod(10); + setDbWalSegmentSize(20); run("CREATE DATABASE IF NOT EXISTS wxy_db " "BUFFER 64 " "CACHEMODEL 'last_value' " "CACHESIZE 20 " "COMP 1 " "DURATION 100 " - "FSYNC 100 " + "WAL_FSYNC_PERIOD 100 " "MAXROWS 1000 " "MINROWS 100 " "KEEP 1440 " @@ -235,10 +245,14 @@ TEST_F(ParserInitialCTest, createDatabase) { "REPLICA 3 " "RETENTIONS 15s:7d,1m:21d,15m:500d " "STRICT 'on' " - "WAL 2 " + "WAL_LEVEL 2 " "VGROUPS 100 " "SINGLE_STABLE 1 " - "SCHEMALESS 1"); + "SCHEMALESS 1 " + "WAL_RETENTION_PERIOD -1 " + "WAL_RETENTION_SIZE -1 " + "WAL_ROLL_PERIOD 10 " + "WAL_SEGMENT_SIZE 20"); clearCreateDbReq(); setCreateDbReqFunc("wxy_db", 1); diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index 849ba14d119ebd6ebb1cc1efab99440c42ef298f..951ca5e40dbac005d67f028beff19bdd16228ab9 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -144,9 +144,9 @@ TEST_F(ParserSelectTest, IndefiniteRowsFunc) { TEST_F(ParserSelectTest, IndefiniteRowsFuncSemanticCheck) { useDb("root", "test"); - run("SELECT DIFF(c1), c2 FROM t1", TSDB_CODE_PAR_NOT_SINGLE_GROUP); + run("SELECT DIFF(c1), c2 FROM t1"); - run("SELECT DIFF(c1), tbname FROM t1", TSDB_CODE_PAR_NOT_SINGLE_GROUP); + run("SELECT DIFF(c1), tbname FROM t1"); run("SELECT DIFF(c1), count(*) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC); diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 30e3b676df5b24080561b51d09741fe7a5064861..d405b750037e980ea05263d4e5aaa457f195d62f 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -1292,8 +1292,8 @@ static int32_t createVnodeModifLogicNodeByDelete(SLogicPlanContext* pCxt, SDelet pModify->modifyType = MODIFY_TABLE_TYPE_DELETE; pModify->tableId = pRealTable->pMeta->uid; pModify->tableType = pRealTable->pMeta->tableType; - snprintf(pModify->tableFName, sizeof(pModify->tableFName), "%d.%s.%s", pCxt->pPlanCxt->acctId, - pRealTable->table.dbName, pRealTable->table.tableName); + snprintf(pModify->tableName, sizeof(pModify->tableName), "%s", pRealTable->table.tableName); + strcpy(pModify->tsColName, pRealTable->pMeta->schema->name); pModify->deleteTimeRange = pDelete->timeRange; pModify->pAffectedRows = nodesCloneNode(pDelete->pCountFunc); if (NULL == pModify->pAffectedRows) { @@ -1342,8 +1342,7 @@ static int32_t createVnodeModifLogicNodeByInsert(SLogicPlanContext* pCxt, SInser pModify->tableId = pRealTable->pMeta->uid; pModify->stableId = pRealTable->pMeta->suid; pModify->tableType = pRealTable->pMeta->tableType; - snprintf(pModify->tableFName, sizeof(pModify->tableFName), "%d.%s.%s", pCxt->pPlanCxt->acctId, - pRealTable->table.dbName, pRealTable->table.tableName); + snprintf(pModify->tableName, sizeof(pModify->tableName), "%s", pRealTable->table.tableName); TSWAP(pModify->pVgroupList, pRealTable->pVgroupList); pModify->pInsertCols = nodesCloneList(pInsert->pCols); if (NULL == pModify->pInsertCols) { diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index fcc395af62b1e05d55707e326dc308bb1b5c9dff..98b0ce2007a41c163a2441e59ee0d31d62bd4604 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -2271,7 +2271,7 @@ static int32_t tagScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubp FOREACH(pAggTarget, pAgg->pTargets) { SNode* pScanTarget = NULL; FOREACH(pScanTarget, pScanNode->node.pTargets) { - if (0 == strcmp(((SColumnNode*)pAggTarget)->colName, ((SColumnNode*)pAggTarget)->colName)) { + if (0 == strcmp(((SColumnNode*)pAggTarget)->colName, ((SColumnNode*)pScanTarget)->colName)) { nodesListAppend(pScanTargets, nodesCloneNode(pScanTarget)); break; } diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 587e5669398474fee5f134a6e87e4d13039a7b9c..2e5c4255e68612a10968118ae8ad339e550632e6 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -553,6 +553,7 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp pTableScan->triggerType = pScanLogicNode->triggerType; pTableScan->watermark = pScanLogicNode->watermark; pTableScan->igExpired = pScanLogicNode->igExpired; + pTableScan->assignBlockUid = pCxt->pPlanCxt->rSmaQuery ? true : false; return createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode); } @@ -632,6 +633,7 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren int32_t code = TSDB_CODE_SUCCESS; pJoin->joinType = pJoinLogicNode->joinType; + pJoin->inputTsOrder = pJoinLogicNode->inputTsOrder; setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pMergeCondition, &pJoin->pMergeCondition); if (TSDB_CODE_SUCCESS == code) { @@ -1586,7 +1588,7 @@ static int32_t createQueryInserter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNod pInserter->tableId = pModify->tableId; pInserter->stableId = pModify->stableId; pInserter->tableType = pModify->tableType; - strcpy(pInserter->tableFName, pModify->tableFName); + strcpy(pInserter->tableName, pModify->tableName); pInserter->vgId = pModify->pVgroupList->vgroups[0].vgId; pInserter->epSet = pModify->pVgroupList->vgroups[0].epSet; vgroupInfoToNodeAddr(pModify->pVgroupList->vgroups, &pSubplan->execNode); @@ -1636,7 +1638,8 @@ static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* pDeleter->tableId = pModify->tableId; pDeleter->tableType = pModify->tableType; - strcpy(pDeleter->tableFName, pModify->tableFName); + strcpy(pDeleter->tableFName, pModify->tableName); + strcpy(pDeleter->tsColName, pModify->tsColName); pDeleter->deleteTimeRange = pModify->deleteTimeRange; int32_t code = setNodeSlotId(pCxt, pRoot->pOutputDataBlockDesc->dataBlockId, -1, pModify->pAffectedRows, diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index d77e42388b454d6a6d6b3c39ee68d8b3963a7dda..d1f8a50dab556067dbc2bfa143a75c8ee2dda9c2 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -283,6 +283,9 @@ int32_t qwGetDeleteResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, SDeleteRes *pRes pRes->skey = pDelRes->skey; pRes->ekey = pDelRes->ekey; pRes->affectedRows = pDelRes->affectedRows; + strcpy(pRes->tableFName, pDelRes->tableName); + strcpy(pRes->tsColName, pDelRes->tsColName); + taosMemoryFree(output.pData); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index b794cb91f549964000cd506a7f766151d4d285da..67050241e36c688414cca38cf2f033cc4c58b1c7 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -230,6 +230,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa SVDeleteRsp rsp = {0}; tDecoderInit(&coder, msg, msgSize); tDecodeSVDeleteRsp(&coder, &rsp); + tDecoderClear(&coder); atomic_add_fetch_32(&pJob->resNumOfRows, rsp.affectedRows); SCH_TASK_DLOG("delete succeed, affectedRows:%" PRId64, rsp.affectedRows); diff --git a/source/libs/scheduler/src/schTask.c b/source/libs/scheduler/src/schTask.c index c40e56ab6f5b4ff349712a13a57c9ca84bbff3ee..025891a26c86672a6ab2ad27dcce150cebf2ea72 100644 --- a/source/libs/scheduler/src/schTask.c +++ b/source/libs/scheduler/src/schTask.c @@ -168,20 +168,20 @@ int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, v return TSDB_CODE_SUCCESS; } -// Note: no more task error processing, handled in function internal int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode) { if (TSDB_CODE_SCH_IGNORE_ERROR == errCode) { return TSDB_CODE_SCH_IGNORE_ERROR; } - int8_t status = 0; - if (schJobNeedToStop(pJob, &status)) { - SCH_TASK_DLOG("no more task failure processing cause of job status %s", jobTaskStatusStr(status)); + int8_t jobStatus = 0; + if (schJobNeedToStop(pJob, &jobStatus)) { + SCH_TASK_DLOG("no more task failure processing cause of job status %s", jobTaskStatusStr(jobStatus)); SCH_ERR_RET(TSDB_CODE_SCH_IGNORE_ERROR); } - if (SCH_GET_TASK_STATUS(pTask) != JOB_TASK_STATUS_EXEC) { - SCH_TASK_ELOG("task already not in EXEC status, status:%s", SCH_GET_TASK_STATUS_STR(pTask)); + int8_t taskStatus = SCH_GET_TASK_STATUS(pTask); + if (taskStatus == JOB_TASK_STATUS_FAIL || taskStatus == JOB_TASK_STATUS_SUCC) { + SCH_TASK_ELOG("task already done, status:%s", jobTaskStatusStr(taskStatus)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } diff --git a/source/libs/stream/inc/streamInc.h b/source/libs/stream/inc/streamInc.h index 093242c610327359b9f3da2907aa245a92b0a981..1ff27f125339569a3bcabc4a0a1d9a7fe4872fe2 100644 --- a/source/libs/stream/inc/streamInc.h +++ b/source/libs/stream/inc/streamInc.h @@ -32,20 +32,20 @@ typedef struct { static SStreamGlobalEnv streamEnv; -int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb); +int32_t streamExec(SStreamTask* pTask); int32_t streamPipelineExec(SStreamTask* pTask, int32_t batchNum); -int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb); +int32_t streamDispatch(SStreamTask* pTask); int32_t streamDispatchReqToData(const SStreamDispatchReq* pReq, SStreamDataBlock* pData); int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock* pData); -int32_t streamBuildDispatchMsg(SStreamTask* pTask, const SStreamDataBlock* data, SRpcMsg* pMsg, SEpSet** ppEpSet); +int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* data); int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock); int32_t tEncodeStreamRetrieveReq(SEncoder* pEncoder, const SStreamRetrieveReq* pReq); SStreamQueueItem* streamAppendQueueItem(SStreamQueueItem* dst, SStreamQueueItem* elem); -void streamFreeQitem(SStreamQueueItem* data); +void streamFreeQitem(SStreamQueueItem* data); #ifdef __cplusplus } diff --git a/source/libs/stream/src/stream.c b/source/libs/stream/src/stream.c index 99a06575a948f19f42cb798fa3ea6dad4d4f7521..31da865a69d8ab6a0efa0b1b305a107624e1f2d0 100644 --- a/source/libs/stream/src/stream.c +++ b/source/libs/stream/src/stream.c @@ -189,7 +189,7 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S #if 0 if (pTask->execType != TASK_EXEC__NONE) { #endif - streamExec(pTask, pTask->pMsgCb); + streamExec(pTask); #if 0 } else { ASSERT(pTask->sinkType != TASK_SINK__NONE); @@ -208,7 +208,7 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S // 3.2 dispatch / sink if (pTask->dispatchType != TASK_DISPATCH__NONE) { ASSERT(pTask->sinkType == TASK_SINK__NONE); - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); } return 0; @@ -219,6 +219,12 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp) { qDebug("task %d receive dispatch rsp", pTask->taskId); + if (pTask->dispatchType == TASK_DISPATCH__SHUFFLE) { + int32_t leftRsp = atomic_sub_fetch_32(&pTask->shuffleDispatcher.waitingRspCnt, 1); + qDebug("task %d is shuffle, left waiting rsp %d", pTask->taskId, leftRsp); + if (leftRsp > 0) return 0; + } + int8_t old = atomic_exchange_8(&pTask->outputStatus, pRsp->inputStatus); ASSERT(old == TASK_OUTPUT_STATUS__WAIT); if (pRsp->inputStatus == TASK_INPUT_STATUS__BLOCKED) { @@ -227,26 +233,55 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp) { return 0; } // continue dispatch - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); return 0; } int32_t streamProcessRunReq(SStreamTask* pTask) { - streamExec(pTask, pTask->pMsgCb); + streamExec(pTask); if (pTask->dispatchType != TASK_DISPATCH__NONE) { - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); } return 0; } -int32_t streamProcessRecoverReq(SStreamTask* pTask, SStreamTaskRecoverReq* pReq, SRpcMsg* pMsg) { - // +int32_t streamProcessRecoverReq(SStreamTask* pTask, SStreamTaskRecoverReq* pReq, SRpcMsg* pRsp) { + void* buf = rpcMallocCont(sizeof(SMsgHead) + sizeof(SStreamTaskRecoverRsp)); + ((SMsgHead*)buf)->vgId = htonl(pReq->upstreamNodeId); + + SStreamTaskRecoverRsp* pCont = POINTER_SHIFT(buf, sizeof(SMsgHead)); + pCont->inputStatus = pTask->inputStatus; + pCont->streamId = pTask->streamId; + pCont->reqTaskId = pTask->taskId; + pCont->rspTaskId = pReq->upstreamTaskId; + + pRsp->pCont = buf; + pRsp->contLen = sizeof(SMsgHead) + sizeof(SStreamTaskRecoverRsp); + tmsgSendRsp(pRsp); return 0; } int32_t streamProcessRecoverRsp(SStreamTask* pTask, SStreamTaskRecoverRsp* pRsp) { - // + if (pRsp->inputStatus == TASK_INPUT_STATUS__NORMAL) { + pTask->outputStatus = TASK_OUTPUT_STATUS__NORMAL; + + streamProcessRunReq(pTask); + + if (pTask->isDataScan) { + // scan data to recover + pTask->inputStatus = TASK_INPUT_STATUS__RECOVER; + pTask->taskStatus = TASK_STATUS__RECOVERING; + qStreamPrepareRecover(pTask->exec.executor, pTask->startVer, pTask->recoverSnapVer); + if (streamPipelineExec(pTask, 100) < 0) { + return -1; + } + } else { + pTask->inputStatus = TASK_INPUT_STATUS__NORMAL; + pTask->taskStatus = TASK_STATUS__NORMAL; + } + } + return 0; } @@ -256,10 +291,10 @@ int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, S streamTaskEnqueueRetrieve(pTask, pReq, pRsp); ASSERT(pTask->execType != TASK_EXEC__NONE); - streamExec(pTask, pTask->pMsgCb); + streamExec(pTask); ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE); - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); return 0; } diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 5d4adb2896cd3612fe73c3fd77fa52adab17d353..ec1dd693e1af740037dd0374958556811ec6180b 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -198,6 +198,172 @@ static int32_t streamAddBlockToDispatchMsg(const SSDataBlock* pBlock, SStreamDis return 0; } +int32_t streamDispatchOneReq(SStreamTask* pTask, const SStreamDispatchReq* pReq, int32_t vgId, SEpSet* pEpSet) { + void* buf = NULL; + int32_t code = -1; + SRpcMsg msg = {0}; + + // serialize + int32_t tlen; + tEncodeSize(tEncodeStreamDispatchReq, pReq, tlen, code); + if (code < 0) goto FAIL; + code = -1; + buf = rpcMallocCont(sizeof(SMsgHead) + tlen); + if (buf == NULL) { + goto FAIL; + } + + ((SMsgHead*)buf)->vgId = htonl(vgId); + void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + + SEncoder encoder; + tEncoderInit(&encoder, abuf, tlen); + if ((code = tEncodeStreamDispatchReq(&encoder, pReq)) < 0) { + goto FAIL; + } + tEncoderClear(&encoder); + + msg.contLen = tlen + sizeof(SMsgHead); + msg.pCont = buf; + msg.msgType = pTask->dispatchMsgType; + + qDebug("dispatch from task %d to task %d node %d", pTask->taskId, pReq->taskId, vgId); + + tmsgSendReq(pEpSet, &msg); + + code = 0; +FAIL: + if (code < 0 && buf) rpcFreeCont(buf); + return 0; +} + +int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pData) { + int32_t code = -1; + int32_t blockNum = taosArrayGetSize(pData->blocks); + ASSERT(blockNum != 0); + + if (pTask->dispatchType == TASK_DISPATCH__FIXED) { + SStreamDispatchReq req = { + .streamId = pTask->streamId, + .dataSrcVgId = pData->srcVgId, + .upstreamTaskId = pTask->taskId, + .upstreamChildId = pTask->selfChildId, + .upstreamNodeId = pTask->nodeId, + .blockNum = blockNum, + }; + + req.data = taosArrayInit(blockNum, sizeof(void*)); + req.dataLen = taosArrayInit(blockNum, sizeof(int32_t)); + if (req.data == NULL || req.dataLen == NULL) { + goto FAIL_FIXED_DISPATCH; + } + + for (int32_t i = 0; i < blockNum; i++) { + SSDataBlock* pDataBlock = taosArrayGet(pData->blocks, i); + if (streamAddBlockToDispatchMsg(pDataBlock, &req) < 0) { + goto FAIL_FIXED_DISPATCH; + } + } + int32_t vgId = pTask->fixedEpDispatcher.nodeId; + SEpSet* pEpSet = &pTask->fixedEpDispatcher.epSet; + int32_t downstreamTaskId = pTask->fixedEpDispatcher.taskId; + + req.taskId = downstreamTaskId; + + qDebug("dispatch from task %d (child id %d) to down stream task %d in vnode %d", pTask->taskId, pTask->selfChildId, + downstreamTaskId, vgId); + + if (streamDispatchOneReq(pTask, &req, vgId, pEpSet) < 0) { + goto FAIL_FIXED_DISPATCH; + } + code = 0; + FAIL_FIXED_DISPATCH: + taosArrayDestroy(req.data); + taosArrayDestroy(req.dataLen); + return code; + + } else if (pTask->dispatchType == TASK_DISPATCH__SHUFFLE) { + int32_t rspCnt = atomic_load_32(&pTask->shuffleDispatcher.waitingRspCnt); + ASSERT(rspCnt == 0); + + SArray* vgInfo = pTask->shuffleDispatcher.dbInfo.pVgroupInfos; + int32_t vgSz = taosArrayGetSize(vgInfo); + SStreamDispatchReq* pReqs = taosMemoryCalloc(vgSz, sizeof(SStreamDispatchReq)); + if (pReqs == NULL) { + return -1; + } + + for (int32_t i = 0; i < vgSz; i++) { + pReqs[i].streamId = pTask->streamId; + pReqs[i].dataSrcVgId = pData->srcVgId; + pReqs[i].upstreamTaskId = pTask->taskId; + pReqs[i].upstreamChildId = pTask->selfChildId; + pReqs[i].upstreamNodeId = pTask->nodeId; + pReqs[i].blockNum = 0; + pReqs[i].data = taosArrayInit(0, sizeof(void*)); + pReqs[i].dataLen = taosArrayInit(0, sizeof(int32_t)); + if (pReqs[i].data == NULL || pReqs[i].dataLen == NULL) { + goto FAIL_SHUFFLE_DISPATCH; + } + SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, i); + pReqs[i].taskId = pVgInfo->taskId; + } + + for (int32_t i = 0; i < blockNum; i++) { + SSDataBlock* pDataBlock = taosArrayGet(pData->blocks, i); + char* ctbName = buildCtbNameByGroupId(pTask->shuffleDispatcher.stbFullName, pDataBlock->info.groupId); + + // TODO: get hash function by hashMethod + uint32_t hashValue = MurmurHash3_32(ctbName, strlen(ctbName)); + + taosMemoryFree(ctbName); + + bool found = false; + // TODO: optimize search + int32_t j; + for (j = 0; j < vgSz; j++) { + SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, j); + ASSERT(pVgInfo->vgId > 0); + if (hashValue >= pVgInfo->hashBegin && hashValue <= pVgInfo->hashEnd) { + if (streamAddBlockToDispatchMsg(pDataBlock, &pReqs[j]) < 0) { + goto FAIL_SHUFFLE_DISPATCH; + } + if (pReqs[j].blockNum == 0) { + atomic_add_fetch_32(&pTask->shuffleDispatcher.waitingRspCnt, 1); + } + pReqs[j].blockNum++; + found = true; + break; + } + } + ASSERT(found); + } + + for (int32_t i = 0; i < vgSz; i++) { + if (pReqs[i].blockNum > 0) { + // send + SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, i); + if (streamDispatchOneReq(pTask, &pReqs[i], pVgInfo->vgId, &pVgInfo->epSet) < 0) { + goto FAIL_SHUFFLE_DISPATCH; + } + } + } + code = 0; + FAIL_SHUFFLE_DISPATCH: + if (pReqs) { + for (int32_t i = 0; i < vgSz; i++) { + taosArrayDestroy(pReqs[i].data); + taosArrayDestroy(pReqs[i].dataLen); + } + taosMemoryFree(pReqs); + } + return code; + } else { + ASSERT(0); + } + return 0; +} + int32_t streamBuildDispatchMsg(SStreamTask* pTask, const SStreamDataBlock* data, SRpcMsg* pMsg, SEpSet** ppEpSet) { void* buf = NULL; int32_t code = -1; @@ -262,29 +428,7 @@ int32_t streamBuildDispatchMsg(SStreamTask* pTask, const SStreamDataBlock* data, qDebug("dispatch from task %d (child id %d) to down stream task %d in vnode %d", pTask->taskId, pTask->selfChildId, downstreamTaskId, vgId); - // serialize - int32_t tlen; - tEncodeSize(tEncodeStreamDispatchReq, &req, tlen, code); - if (code < 0) goto FAIL; - code = -1; - buf = rpcMallocCont(sizeof(SMsgHead) + tlen); - if (buf == NULL) { - goto FAIL; - } - - ((SMsgHead*)buf)->vgId = htonl(vgId); - void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); - - SEncoder encoder; - tEncoderInit(&encoder, abuf, tlen); - if ((code = tEncodeStreamDispatchReq(&encoder, &req)) < 0) { - goto FAIL; - } - tEncoderClear(&encoder); - - pMsg->contLen = tlen + sizeof(SMsgHead); - pMsg->pCont = buf; - pMsg->msgType = pTask->dispatchMsgType; + streamDispatchOneReq(pTask, &req, vgId, *ppEpSet); code = 0; FAIL: @@ -294,7 +438,7 @@ FAIL: return code; } -int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) { +int32_t streamDispatch(SStreamTask* pTask) { ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE); #if 1 int8_t old = @@ -314,6 +458,18 @@ int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) { qDebug("stream continue dispatching: task %d", pTask->taskId); + int32_t code = 0; + if (streamDispatchAllBlocks(pTask, pBlock) < 0) { + ASSERT(0); + code = -1; + // TODO set status fail + goto FREE; + } + /*atomic_store_8(&pTask->outputStatus, TASK_OUTPUT_STATUS__NORMAL);*/ +FREE: + taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes); + taosFreeQitem(pBlock); +#if 0 SRpcMsg dispatchMsg = {0}; SEpSet* pEpSet = NULL; if (streamBuildDispatchMsg(pTask, pBlock, &dispatchMsg, &pEpSet) < 0) { @@ -325,5 +481,6 @@ int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) { taosFreeQitem(pBlock); tmsgSendReq(pEpSet, &dispatchMsg); - return 0; +#endif + return code; } diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index 52b610228eb7bdd2253a47b97457032d9aa0a1a1..196dbd6dc32e1b82c1b6cbd7a4409bbec90ff7d5 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -22,22 +22,22 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes) SStreamQueueItem* pItem = (SStreamQueueItem*)data; if (pItem->type == STREAM_INPUT__GET_RES) { SStreamTrigger* pTrigger = (SStreamTrigger*)data; - qSetMultiStreamInput(exec, pTrigger->pBlock, 1, STREAM_INPUT__DATA_BLOCK, false); + qSetMultiStreamInput(exec, pTrigger->pBlock, 1, STREAM_INPUT__DATA_BLOCK); } else if (pItem->type == STREAM_INPUT__DATA_SUBMIT) { ASSERT(pTask->isDataScan); SStreamDataSubmit* pSubmit = (SStreamDataSubmit*)data; - qDebug("task %d %p set submit input %p %p %d", pTask->taskId, pTask, pSubmit, pSubmit->data, *pSubmit->dataRef); - qSetStreamInput(exec, pSubmit->data, STREAM_INPUT__DATA_SUBMIT, false); + qDebug("task %d %p set submit input %p %p %d 1", pTask->taskId, pTask, pSubmit, pSubmit->data, *pSubmit->dataRef); + qSetMultiStreamInput(exec, pSubmit->data, 1, STREAM_INPUT__DATA_SUBMIT); } else if (pItem->type == STREAM_INPUT__DATA_BLOCK || pItem->type == STREAM_INPUT__DATA_RETRIEVE) { SStreamDataBlock* pBlock = (SStreamDataBlock*)data; SArray* blocks = pBlock->blocks; qDebug("task %d %p set ssdata input", pTask->taskId, pTask); - qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_INPUT__DATA_BLOCK, false); + qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_INPUT__DATA_BLOCK); } else if (pItem->type == STREAM_INPUT__MERGED_SUBMIT) { SStreamMergedSubmit* pMerged = (SStreamMergedSubmit*)data; SArray* blocks = pMerged->reqs; qDebug("task %d %p set submit input (merged), batch num: %d", pTask->taskId, pTask, (int32_t)blocks->size); - qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_INPUT__MERGED_SUBMIT, false); + qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_INPUT__MERGED_SUBMIT); } else { ASSERT(0); } @@ -72,6 +72,8 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes) continue; } + qDebug("task %d(child %d) executed and get block"); + SSDataBlock block = {0}; assignOneDataBlock(&block, output); block.info.childId = pTask->selfChildId; @@ -139,7 +141,7 @@ int32_t streamPipelineExec(SStreamTask* pTask, int32_t batchNum) { if (pTask->dispatchType != TASK_DISPATCH__NONE) { ASSERT(pTask->sinkType == TASK_SINK__NONE); - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); } } @@ -188,7 +190,7 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) { if (pTask->execType == TASK_EXEC__NONE) { ASSERT(((SStreamQueueItem*)data)->type == STREAM_INPUT__DATA_BLOCK); streamTaskOutput(pTask, data); - return pRes; + continue; } qDebug("stream task %d exec begin, msg batch: %d", pTask->taskId, cnt); @@ -227,7 +229,7 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) { } // TODO: handle version -int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) { +int32_t streamExec(SStreamTask* pTask) { SArray* pRes = taosArrayInit(0, sizeof(SSDataBlock)); if (pRes == NULL) return -1; while (1) { diff --git a/source/libs/stream/src/streamRecover.c b/source/libs/stream/src/streamRecover.c index 87b27daf6079dd7ca76835b10e21f422968fbb03..dec23cd151fe687dafe44f53bb3653a4a1d2b75c 100644 --- a/source/libs/stream/src/streamRecover.c +++ b/source/libs/stream/src/streamRecover.c @@ -19,8 +19,8 @@ int32_t tEncodeStreamTaskRecoverReq(SEncoder* pEncoder, const SStreamTaskRecover if (tStartEncode(pEncoder) < 0) return -1; if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1; if (tEncodeI32(pEncoder, pReq->taskId) < 0) return -1; - if (tEncodeI32(pEncoder, pReq->sourceTaskId) < 0) return -1; - if (tEncodeI32(pEncoder, pReq->sourceVg) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->upstreamTaskId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->upstreamNodeId) < 0) return -1; tEndEncode(pEncoder); return pEncoder->pos; } @@ -29,8 +29,8 @@ int32_t tDecodeStreamTaskRecoverReq(SDecoder* pDecoder, SStreamTaskRecoverReq* p if (tStartDecode(pDecoder) < 0) return -1; if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1; if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1; - if (tDecodeI32(pDecoder, &pReq->sourceTaskId) < 0) return -1; - if (tDecodeI32(pDecoder, &pReq->sourceVg) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->upstreamTaskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->upstreamNodeId) < 0) return -1; tEndDecode(pDecoder); return 0; } @@ -38,7 +38,8 @@ int32_t tDecodeStreamTaskRecoverReq(SDecoder* pDecoder, SStreamTaskRecoverReq* p int32_t tEncodeStreamTaskRecoverRsp(SEncoder* pEncoder, const SStreamTaskRecoverRsp* pRsp) { if (tStartEncode(pEncoder) < 0) return -1; if (tEncodeI64(pEncoder, pRsp->streamId) < 0) return -1; - if (tEncodeI32(pEncoder, pRsp->taskId) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->reqTaskId) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->rspTaskId) < 0) return -1; if (tEncodeI8(pEncoder, pRsp->inputStatus) < 0) return -1; tEndEncode(pEncoder); return pEncoder->pos; @@ -47,7 +48,8 @@ int32_t tEncodeStreamTaskRecoverRsp(SEncoder* pEncoder, const SStreamTaskRecover int32_t tDecodeStreamTaskRecoverRsp(SDecoder* pDecoder, SStreamTaskRecoverRsp* pReq) { if (tStartDecode(pDecoder) < 0) return -1; if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1; - if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->reqTaskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->rspTaskId) < 0) return -1; if (tDecodeI8(pDecoder, &pReq->inputStatus) < 0) return -1; tEndDecode(pDecoder); return 0; @@ -125,7 +127,7 @@ int32_t streamProcessFailRecoverReq(SStreamTask* pTask, SMStreamTaskRecoverReq* } if (pTask->taskStatus == TASK_STATUS__RECOVERING) { - if (streamPipelineExec(pTask, 10) < 0) { + if (streamPipelineExec(pTask, 100) < 0) { // set fail return -1; } diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index 5921e44a9c51cc650d122e85e75b98ec0531acac..216e3fa761e910cee7749b4aabf0f4bc7b708b8b 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -64,7 +64,7 @@ int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) { if (tEncodeI32(pEncoder, pTask->selfChildId) < 0) return -1; if (tEncodeI32(pEncoder, pTask->nodeId) < 0) return -1; if (tEncodeSEpSet(pEncoder, &pTask->epSet) < 0) return -1; - if (tEncodeI32(pEncoder, pTask->numOfVgroups) < 0) return -1; + /*if (tEncodeI32(pEncoder, pTask->numOfVgroups) < 0) return -1;*/ int32_t epSz = taosArrayGetSize(pTask->childEpInfo); if (tEncodeI32(pEncoder, epSz) < 0) return -1; @@ -119,7 +119,7 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) { if (tDecodeI32(pDecoder, &pTask->selfChildId) < 0) return -1; if (tDecodeI32(pDecoder, &pTask->nodeId) < 0) return -1; if (tDecodeSEpSet(pDecoder, &pTask->epSet) < 0) return -1; - if (tDecodeI32(pDecoder, &pTask->numOfVgroups) < 0) return -1; + /*if (tDecodeI32(pDecoder, &pTask->numOfVgroups) < 0) return -1;*/ int32_t epSz; if (tDecodeI32(pDecoder, &epSz) < 0) return -1; diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index 64f66e390aafde8efdfcf215ec5387c3cfbd631f..586cfc0f15a00fdb567186a40f7b215842a5c927 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -170,7 +170,7 @@ void syncNodeStart(SSyncNode* pSyncNode); void syncNodeStartStandBy(SSyncNode* pSyncNode); void syncNodeClose(SSyncNode* pSyncNode); int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak); -int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize); +int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize); // option bool syncNodeSnapshotEnable(SSyncNode* pSyncNode); @@ -238,6 +238,7 @@ int32_t syncNodeGetPreIndexTerm(SSyncNode* pSyncNode, SyncIndex index, SyncInd bool syncNodeIsOptimizedOneReplica(SSyncNode* ths, SRpcMsg* pMsg); int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, uint64_t flag); +int32_t syncNodePreCommit(SSyncNode* ths, SSyncRaftEntry* pEntry, int32_t code); int32_t syncNodeUpdateNewConfigIndex(SSyncNode* ths, SSyncCfg* pNewCfg); diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index 4295abeaa1a9eb3b4f0ac448a2c286da13f8a778..7d0f53640cc0a6e441c31dd3c52166c824dae4d6 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -244,22 +244,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { ths->pLogStore->appendEntry(ths->pLogStore, pAppendEntry); // pre commit - SRpcMsg rpcMsg; - syncEntry2OriginalRpc(pAppendEntry, &rpcMsg); - if (ths->pFsm != NULL) { - // if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_SYNC_NOOP) { - if (ths->pFsm->FpPreCommitCb != NULL && syncUtilUserPreCommit(pAppendEntry->originalRpcType)) { - SFsmCbMeta cbMeta = {0}; - cbMeta.index = pAppendEntry->index; - cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, cbMeta.index); - cbMeta.isWeak = pAppendEntry->isWeak; - cbMeta.code = 2; - cbMeta.state = ths->state; - cbMeta.seqNum = pAppendEntry->seqNum; - ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, cbMeta); - } - } - rpcFreeCont(rpcMsg.pCont); + syncNodePreCommit(ths, pAppendEntry, 0); } // free memory @@ -280,22 +265,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { ths->pLogStore->appendEntry(ths->pLogStore, pAppendEntry); // pre commit - SRpcMsg rpcMsg; - syncEntry2OriginalRpc(pAppendEntry, &rpcMsg); - if (ths->pFsm != NULL) { - // if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_SYNC_NOOP) { - if (ths->pFsm->FpPreCommitCb != NULL && syncUtilUserPreCommit(pAppendEntry->originalRpcType)) { - SFsmCbMeta cbMeta = {0}; - cbMeta.index = pAppendEntry->index; - cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, cbMeta.index); - cbMeta.isWeak = pAppendEntry->isWeak; - cbMeta.code = 3; - cbMeta.state = ths->state; - cbMeta.seqNum = pAppendEntry->seqNum; - ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, cbMeta); - } - } - rpcFreeCont(rpcMsg.pCont); + syncNodePreCommit(ths, pAppendEntry, 0); // free memory syncEntryDestory(pAppendEntry); @@ -440,7 +410,7 @@ static int32_t syncNodeDoMakeLogSame(SSyncNode* ths, SyncIndex FromIndex) { return code; } -static int32_t syncNodePreCommit(SSyncNode* ths, SSyncRaftEntry* pEntry) { +int32_t syncNodePreCommit(SSyncNode* ths, SSyncRaftEntry* pEntry, int32_t code) { SRpcMsg rpcMsg; syncEntry2OriginalRpc(pEntry, &rpcMsg); @@ -456,7 +426,7 @@ static int32_t syncNodePreCommit(SSyncNode* ths, SSyncRaftEntry* pEntry) { cbMeta.index = pEntry->index; cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, cbMeta.index); cbMeta.isWeak = pEntry->isWeak; - cbMeta.code = 2; + cbMeta.code = code; cbMeta.state = ths->state; cbMeta.seqNum = pEntry->seqNum; ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, cbMeta); @@ -594,7 +564,7 @@ int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatc return -1; } - code = syncNodePreCommit(ths, pAppendEntry); + code = syncNodePreCommit(ths, pAppendEntry, 0); ASSERT(code == 0); // syncEntryDestory(pAppendEntry); @@ -715,7 +685,7 @@ int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatc return -1; } - code = syncNodePreCommit(ths, pAppendEntry); + code = syncNodePreCommit(ths, pAppendEntry, 0); ASSERT(code == 0); // syncEntryDestory(pAppendEntry); @@ -919,7 +889,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs } // pre commit - code = syncNodePreCommit(ths, pAppendEntry); + code = syncNodePreCommit(ths, pAppendEntry, 0); ASSERT(code == 0); // update match index @@ -1032,7 +1002,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs } // pre commit - code = syncNodePreCommit(ths, pAppendEntry); + code = syncNodePreCommit(ths, pAppendEntry, 0); ASSERT(code == 0); syncEntryDestory(pAppendEntry); diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index b3cdd079a49c6a13bc2b74c9d00f92e235d39ce8..fd6577477f171402f1769a02e18b60b765339e04 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -67,11 +67,6 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { for (SyncIndex index = syncNodeGetLastIndex(pSyncNode); index > pSyncNode->commitIndex; --index) { bool agree = syncAgree(pSyncNode, index); - if (gRaftDetailLog) { - sTrace("syncMaybeAdvanceCommitIndex syncAgree:%d, index:%" PRId64 ", pSyncNode->commitIndex:%" PRId64, agree, - index, pSyncNode->commitIndex); - } - if (agree) { // term SSyncRaftEntry* pEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, index); @@ -82,20 +77,15 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { // update commit index newCommitIndex = index; - if (gRaftDetailLog) { - sTrace("syncMaybeAdvanceCommitIndex maybe to update, newCommitIndex:%" PRId64 - " commit, pSyncNode->commitIndex:%" PRId64, - newCommitIndex, pSyncNode->commitIndex); - } - syncEntryDestory(pEntry); break; } else { - if (gRaftDetailLog) { - sTrace("syncMaybeAdvanceCommitIndex can not commit due to term not equal, pEntry->term:%" PRIu64 - ", pSyncNode->pRaftStore->currentTerm:%" PRIu64, - pEntry->term, pSyncNode->pRaftStore->currentTerm); - } + do { + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "can not commit due to term not equal, index:%ld, term:%lu", pEntry->index, + pEntry->term); + syncNodeEventLog(pSyncNode, logBuf); + } while (0); } syncEntryDestory(pEntry); @@ -107,10 +97,6 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { SyncIndex beginIndex = pSyncNode->commitIndex + 1; SyncIndex endIndex = newCommitIndex; - if (gRaftDetailLog) { - sTrace("syncMaybeAdvanceCommitIndex sync commit %" PRId64, newCommitIndex); - } - // update commit index pSyncNode->commitIndex = newCommitIndex; diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index a453b2572ce0a2b70ecf281d37a5537133f70343..2c6472899865b9ec8b88bfaa7cf097fbd29074e1 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -677,7 +677,7 @@ int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak) { return ret; } -int32_t syncProposeBatch(int64_t rid, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize) { +int32_t syncProposeBatch(int64_t rid, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize) { if (arrSize < 0) { terrno = TSDB_CODE_SYN_INTERNAL_ERROR; return -1; @@ -690,18 +690,18 @@ int32_t syncProposeBatch(int64_t rid, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_ } ASSERT(rid == pSyncNode->rid); - int32_t ret = syncNodeProposeBatch(pSyncNode, pMsgArr, pIsWeakArr, arrSize); + int32_t ret = syncNodeProposeBatch(pSyncNode, pMsgPArr, pIsWeakArr, arrSize); taosReleaseRef(tsNodeRefId, pSyncNode->rid); return ret; } -static bool syncNodeBatchOK(SRpcMsg* pMsgArr, int32_t arrSize) { +static bool syncNodeBatchOK(SRpcMsg** pMsgPArr, int32_t arrSize) { for (int32_t i = 0; i < arrSize; ++i) { - if (pMsgArr[i].msgType == TDMT_SYNC_CONFIG_CHANGE) { + if (pMsgPArr[i]->msgType == TDMT_SYNC_CONFIG_CHANGE) { return false; } - if (pMsgArr[i].msgType == TDMT_SYNC_CONFIG_CHANGE_FINISH) { + if (pMsgPArr[i]->msgType == TDMT_SYNC_CONFIG_CHANGE_FINISH) { return false; } } @@ -709,8 +709,8 @@ static bool syncNodeBatchOK(SRpcMsg* pMsgArr, int32_t arrSize) { return true; } -int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize) { - if (!syncNodeBatchOK(pMsgArr, arrSize)) { +int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize) { + if (!syncNodeBatchOK(pMsgPArr, arrSize)) { syncNodeErrorLog(pSyncNode, "sync propose batch error"); terrno = TSDB_CODE_SYN_BATCH_ERROR; return -1; @@ -736,16 +736,23 @@ int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWe SRaftMeta raftArr[SYNC_MAX_BATCH_SIZE]; for (int i = 0; i < arrSize; ++i) { + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "propose type:%s,%d, batch:%d", TMSG_INFO(pMsgPArr[i]->msgType), + pMsgPArr[i]->msgType, arrSize); + syncNodeEventLog(pSyncNode, eventLog); + } while (0); + SRespStub stub; stub.createTime = taosGetTimestampMs(); - stub.rpcMsg = pMsgArr[i]; + stub.rpcMsg = *(pMsgPArr[i]); uint64_t seqNum = syncRespMgrAdd(pSyncNode->pSyncRespMgr, &stub); raftArr[i].isWeak = pIsWeakArr[i]; raftArr[i].seqNum = seqNum; } - SyncClientRequestBatch* pSyncMsg = syncClientRequestBatchBuild(pMsgArr, raftArr, arrSize, pSyncNode->vgId); + SyncClientRequestBatch* pSyncMsg = syncClientRequestBatchBuild(pMsgPArr, raftArr, arrSize, pSyncNode->vgId); ASSERT(pSyncMsg != NULL); SRpcMsg rpcMsg; @@ -759,7 +766,7 @@ int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWe SRpcMsg* msgArr = syncClientRequestBatchRpcMsgArr(pSyncMsg); ASSERT(arrSize == pSyncMsg->dataCount); for (int i = 0; i < arrSize; ++i) { - pMsgArr[i].info.conn.applyIndex = msgArr[i].info.conn.applyIndex; + pMsgPArr[i]->info.conn.applyIndex = msgArr[i].info.conn.applyIndex; syncRespMgrDel(pSyncNode->pSyncRespMgr, raftArr[i].seqNum); } @@ -790,9 +797,11 @@ int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWe int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) { int32_t ret = 0; - char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "propose type:%s,%d", TMSG_INFO(pMsg->msgType), pMsg->msgType); - syncNodeEventLog(pSyncNode, eventLog); + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "propose type:%s,%d", TMSG_INFO(pMsg->msgType), pMsg->msgType); + syncNodeEventLog(pSyncNode, eventLog); + } while (0); if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { if (pSyncNode->changing && pMsg->msgType != TDMT_SYNC_CONFIG_CHANGE_FINISH) { @@ -860,7 +869,8 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) { } else { ret = -1; terrno = TSDB_CODE_SYN_NOT_LEADER; - sError("vgId:%d, sync propose not leader, %s", pSyncNode->vgId, syncUtilState2String(pSyncNode->state)); + sError("vgId:%d, sync propose not leader, %s, msgtype:%s,%d", pSyncNode->vgId, + syncUtilState2String(pSyncNode->state), TMSG_INFO(pMsg->msgType), pMsg->msgType); goto _END; } @@ -2501,49 +2511,15 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncI // if mulit replica, start replicate right now if (ths->replicaNum > 1) { syncNodeReplicate(ths); - } - // pre commit - SRpcMsg rpcMsg; - syncEntry2OriginalRpc(pEntry, &rpcMsg); - - if (ths->pFsm != NULL) { - if (ths->pFsm->FpPreCommitCb != NULL && syncUtilUserPreCommit(pEntry->originalRpcType)) { - SFsmCbMeta cbMeta = {0}; - cbMeta.index = pEntry->index; - cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, cbMeta.index); - cbMeta.isWeak = pEntry->isWeak; - cbMeta.code = 0; - cbMeta.state = ths->state; - cbMeta.seqNum = pEntry->seqNum; - ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, cbMeta); - } + // pre commit + syncNodePreCommit(ths, pEntry, 0); } - rpcFreeCont(rpcMsg.pCont); // if only myself, maybe commit right now if (ths->replicaNum == 1) { syncMaybeAdvanceCommitIndex(ths); } - - } else { - // pre commit - SRpcMsg rpcMsg; - syncEntry2OriginalRpc(pEntry, &rpcMsg); - - if (ths->pFsm != NULL) { - if (ths->pFsm->FpPreCommitCb != NULL && syncUtilUserPreCommit(pEntry->originalRpcType)) { - SFsmCbMeta cbMeta = {0}; - cbMeta.index = pEntry->index; - cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, cbMeta.index); - cbMeta.isWeak = pEntry->isWeak; - cbMeta.code = 1; - cbMeta.state = ths->state; - cbMeta.seqNum = pEntry->seqNum; - ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, cbMeta); - } - } - rpcFreeCont(rpcMsg.pCont); } if (pRetIndex != NULL) { diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index 42a3290d5ba2d2b0effb655c4aa66f5539e89b86..13adaf055c1c320f56337ea90537e592fafcbe89 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -963,9 +963,9 @@ void syncClientRequestLog2(char* s, const SyncClientRequest* pMsg) { // block2: SRaftMeta array // block3: rpc msg array (with pCont) -SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg* rpcMsgArr, SRaftMeta* raftArr, int32_t arrSize, +SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg** rpcMsgPArr, SRaftMeta* raftArr, int32_t arrSize, int32_t vgId) { - ASSERT(rpcMsgArr != NULL); + ASSERT(rpcMsgPArr != NULL); ASSERT(arrSize > 0); int32_t dataLen = 0; @@ -991,7 +991,7 @@ SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg* rpcMsgArr, SRaftMet raftMetaArr[i].seqNum = raftArr[i].seqNum; // init msgArr - msgArr[i] = rpcMsgArr[i]; + msgArr[i] = *(rpcMsgPArr[i]); } return pMsg; diff --git a/source/libs/sync/test/sh/a.sh b/source/libs/sync/test/sh/a.sh index 44cd2edbec7f2dcca9c20cb2f7e77fe65529cdd3..751b42b9c22077d21cbc694392f1b0bab3a0f7d7 100644 --- a/source/libs/sync/test/sh/a.sh +++ b/source/libs/sync/test/sh/a.sh @@ -22,25 +22,25 @@ done echo "" echo "generate vgId ..." -cat ${logpath}/log.dnode* | grep "vgId:" | grep -v ERROR | awk '{print $5}' | sort | uniq > ${logpath}/log.vgIds.tmp +cat ${logpath}/log.dnode* | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort -T. | uniq | awk -F: '{print $2, $0}' | sort -T. -k1 -n | awk '{print $2}' > ${logpath}/log.vgIds.tmp echo "all vgIds:" > ${logpath}/log.vgIds -cat ${logpath}/log.dnode* | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort | uniq >> ${logpath}/log.vgIds +cat ${logpath}/log.dnode* | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort -T. | uniq | awk -F: '{print $2, $0}' | sort -T. -k1 -n | awk '{print $2}' >> ${logpath}/log.vgIds for dnode in `ls ${logpath} | grep dnode | grep -v log`;do echo "" >> ${logpath}/log.vgIds echo "" >> ${logpath}/log.vgIds echo "${dnode}:" >> ${logpath}/log.vgIds - cat ${logpath}/${dnode}/log/taosdlog.* | grep SYN | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort | uniq >> ${logpath}/log.vgIds + cat ${logpath}/${dnode}/log/taosdlog.* | grep SYN | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort -T. | uniq | awk -F: '{print $2, $0}' | sort -T. -k1 -n | awk '{print $2}' >> ${logpath}/log.vgIds done echo "" echo "generate log.dnode.vgId ..." for logdnode in `ls ${logpath}/log.dnode*`;do for vgId in `cat ${logpath}/log.vgIds.tmp`;do - rowNum=`cat ${logdnode} | grep "${vgId}" | awk 'BEGIN{rowNum=0}{rowNum++}END{print rowNum}'` + rowNum=`cat ${logdnode} | grep "${vgId}," | awk 'BEGIN{rowNum=0}{rowNum++}END{print rowNum}'` #echo "-----${rowNum}" if [ $rowNum -gt 0 ] ; then echo "generate ${logdnode}.${vgId}" - cat ${logdnode} | grep "${vgId}" > ${logdnode}.${vgId} + cat ${logdnode} | grep "${vgId}," > ${logdnode}.${vgId} fi done done @@ -54,7 +54,7 @@ done echo "" echo "generate log.leader.term ..." -cat ${logpath}/*.main | grep "become leader" | grep -v "config change" | awk '{print $5,$0}' | awk -F, '{print $4"_"$0}' | sort -k1 > ${logpath}/log.leader.term +cat ${logpath}/*.main | grep "become leader" | grep -v "config change" | awk '{print $5,$0}' | awk -F, '{print $4"_"$0}' | sort -T. -k1 > ${logpath}/log.leader.term echo "" echo "generate log.index, log.snapshot, log.records, log.actions ..." diff --git a/source/libs/sync/test/syncClientRequestBatchTest.cpp b/source/libs/sync/test/syncClientRequestBatchTest.cpp index ae74baeda4c1451628ad9bad5131668abd338a3d..84d037be01028167584bfcaf912fc090540c0c7e 100644 --- a/source/libs/sync/test/syncClientRequestBatchTest.cpp +++ b/source/libs/sync/test/syncClientRequestBatchTest.cpp @@ -28,12 +28,12 @@ SRpcMsg *createRpcMsg(int32_t i, int32_t dataLen) { } SyncClientRequestBatch *createMsg() { - SRpcMsg rpcMsgArr[5]; - memset(rpcMsgArr, 0, sizeof(rpcMsgArr)); + SRpcMsg *rpcMsgPArr[5]; + memset(rpcMsgPArr, 0, sizeof(rpcMsgPArr)); for (int32_t i = 0; i < 5; ++i) { SRpcMsg *pRpcMsg = createRpcMsg(i, 20); - rpcMsgArr[i] = *pRpcMsg; - taosMemoryFree(pRpcMsg); + rpcMsgPArr[i] = pRpcMsg; + //taosMemoryFree(pRpcMsg); } SRaftMeta raftArr[5]; @@ -43,7 +43,7 @@ SyncClientRequestBatch *createMsg() { raftArr[i].isWeak = i % 2; } - SyncClientRequestBatch *pMsg = syncClientRequestBatchBuild(rpcMsgArr, raftArr, 5, 1234); + SyncClientRequestBatch *pMsg = syncClientRequestBatchBuild(rpcMsgPArr, raftArr, 5, 1234); return pMsg; } diff --git a/source/libs/tdb/src/db/tdbPage.c b/source/libs/tdb/src/db/tdbPage.c index 7a70b621c6f65db2eb58dbc84c48ecbfe087c94a..276b06b147586bbf18fe73f94cdb2592032d97e2 100644 --- a/source/libs/tdb/src/db/tdbPage.c +++ b/source/libs/tdb/src/db/tdbPage.c @@ -76,14 +76,17 @@ int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg) ASSERT(xFree); + for (int iOvfl = 0; iOvfl < pPage->nOverflow; iOvfl++) { + tdbOsFree(pPage->apOvfl[iOvfl]); + } + ptr = pPage->pData; xFree(arg, ptr); return 0; } -void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, - TXN *, SBTree *pBt)) { +void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt)) { pPage->pPageHdr = pPage->pData + szAmHdr; TDB_PAGE_NCELLS_SET(pPage, 0); TDB_PAGE_CCELLS_SET(pPage, pPage->pageSize - sizeof(SPageFtr)); @@ -99,8 +102,7 @@ void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell ASSERT((u8 *)pPage->pPageFtr == pPage->pFreeEnd); } -void tdbPageInit(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, - TXN *, SBTree *pBt)) { +void tdbPageInit(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt)) { pPage->pPageHdr = pPage->pData + szAmHdr; pPage->pCellIdx = pPage->pPageHdr + TDB_PAGE_HDR_SIZE(pPage); pPage->pFreeStart = pPage->pCellIdx + TDB_PAGE_OFFSET_SIZE(pPage) * TDB_PAGE_NCELLS(pPage); @@ -124,9 +126,8 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl nFree = TDB_PAGE_NFREE(pPage); nCells = TDB_PAGE_NCELLS(pPage); - iOvfl = 0; - for (; iOvfl < pPage->nOverflow; iOvfl++) { + for (iOvfl = 0; iOvfl < pPage->nOverflow; ++iOvfl) { if (pPage->aiOvfl[iOvfl] >= idx) { break; } @@ -146,6 +147,8 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl pNewCell = (SCell *)tdbOsMalloc(szCell); memcpy(pNewCell, pCell, szCell); + tdbDebug("tdbPage/new ovfl cell: %p", pNewCell); + pPage->apOvfl[iOvfl] = pNewCell; pPage->aiOvfl[iOvfl] = idx; pPage->nOverflow++; @@ -193,6 +196,8 @@ int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt) { for (; iOvfl < pPage->nOverflow; iOvfl++) { if (pPage->aiOvfl[iOvfl] == idx) { // remove the over flow cell + tdbOsFree(pPage->apOvfl[iOvfl]); + tdbDebug("tdbPage/free ovfl cell: %p", pPage->apOvfl[iOvfl]); for (; (++iOvfl) < pPage->nOverflow;) { pPage->aiOvfl[iOvfl - 1] = pPage->aiOvfl[iOvfl] - 1; pPage->apOvfl[iOvfl - 1] = pPage->apOvfl[iOvfl]; @@ -248,7 +253,7 @@ void tdbPageCopy(SPage *pFromPage, SPage *pToPage) { int tdbPageCapacity(int pageSize, int amHdrSize) { int szPageHdr; - int minCellIndexSize; // at least one cell in cell index + int minCellIndexSize; // at least one cell in cell index if (pageSize < 65536) { szPageHdr = pageMethods.szPageHdr; diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index f256c9603724bcfdeeaa5d007c55e9cb8a2bcd10..a81d6db80fb9d40d4847878c19483ebe3d254b38 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -7,8 +7,7 @@ * * 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. - * + * 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 . */ @@ -211,6 +210,7 @@ typedef struct SConnBuffer { char* buf; int len; int cap; + int left; int total; } SConnBuffer; @@ -282,6 +282,8 @@ int transClearBuffer(SConnBuffer* buf); int transDestroyBuffer(SConnBuffer* buf); int transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf); bool transReadComplete(SConnBuffer* connBuf); +int transResetBuffer(SConnBuffer* connBuf); +int transDumpFromBuffer(SConnBuffer* connBuf, char** buf); int transSetConnOption(uv_tcp_t* stream); diff --git a/source/libs/transport/src/thttp.c b/source/libs/transport/src/thttp.c index c747e6933923ef970097d8ea0bcf11a6335b897a..62277a7569a836f84e2ea143dc648737c208b3c8 100644 --- a/source/libs/transport/src/thttp.c +++ b/source/libs/transport/src/thttp.c @@ -17,6 +17,7 @@ #ifdef USE_UV #include #endif +// clang-format off #include "zlib.h" #include "thttp.h" #include "taoserror.h" @@ -174,7 +175,7 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32 #else int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32_t contLen, EHttpCompFlag flag) { - int32_t code = -1; + int32_t code = -1; TdSocketPtr pSocket = NULL; uint32_t ip = taosGetIpv4FromFqdn(server); @@ -231,4 +232,5 @@ SEND_OVER: return code; } -#endif \ No newline at end of file +// clang-format on +#endif diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 70d56dca139972d33aa3f0e633727dadb0b35ea9..efbe110f6f224b2740281dadf420b1e551fb4c2c 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -1,5 +1,4 @@ /** 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 @@ -16,6 +15,10 @@ #ifdef USE_UV #include "transComm.h" +typedef struct SConnList { + queue conn; +} SConnList; + typedef struct SCliConn { T_REF_DECLARE() uv_connect_t connReq; @@ -26,7 +29,9 @@ typedef struct SCliConn { SConnBuffer readBuf; STransQueue cliMsgs; - queue q; + + queue q; + SConnList* list; STransCtx ctx; bool broken; // link broken or not @@ -56,12 +61,14 @@ typedef struct SCliMsg { } SCliMsg; typedef struct SCliThrd { - TdThread thread; // tid - int64_t pid; // pid - uv_loop_t* loop; - SAsyncPool* asyncPool; - uv_timer_t timer; - void* pool; // conn pool + TdThread thread; // tid + int64_t pid; // pid + uv_loop_t* loop; + SAsyncPool* asyncPool; + uv_idle_t* idle; + uv_prepare_t* prepare; + uv_timer_t timer; + void* pool; // conn pool // msg queue queue msg; @@ -85,10 +92,6 @@ typedef struct SCliObj { SCliThrd** pThreadObj; } SCliObj; -typedef struct SConnList { - queue conn; -} SConnList; - // conn pool // add expire timeout and capacity limit static void* createConnPool(int size); @@ -100,7 +103,7 @@ static void doCloseIdleConn(void* param); static int sockDebugInfo(struct sockaddr* sockname, char* dst) { struct sockaddr_in addr = *(struct sockaddr_in*)sockname; - char buf[20] = {0}; + char buf[16] = {0}; int r = uv_ip4_name(&addr, (char*)buf, sizeof(buf)); sprintf(dst, "%s:%d", buf, ntohs(addr.sin_port)); return r; @@ -116,6 +119,10 @@ static void cliSendCb(uv_write_t* req, int status); // callback after conn to server static void cliConnCb(uv_connect_t* req, int status); static void cliAsyncCb(uv_async_t* handle); +static void cliIdleCb(uv_idle_t* handle); +static void cliPrepareCb(uv_prepare_t* handle); + +static int32_t allocConnRef(SCliConn* conn, bool update); static int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg); @@ -196,7 +203,7 @@ static void cliReleaseUnfinishedMsg(SCliConn* conn) { pThrd = (SCliThrd*)(exh)->pThrd; \ } \ } while (0) -#define CONN_PERSIST_TIME(para) ((para) == 0 ? 3 * 1000 : (para)) +#define CONN_PERSIST_TIME(para) ((para) <= 90000 ? 90000 : (para)) #define CONN_GET_HOST_THREAD(conn) (conn ? ((SCliConn*)conn)->hostThrd : NULL) #define CONN_GET_INST_LABEL(conn) (((STrans*)(((SCliThrd*)(conn)->hostThrd)->pTransInst))->label) #define CONN_SHOULD_RELEASE(conn, head) \ @@ -323,7 +330,8 @@ void cliHandleResp(SCliConn* conn) { SCliThrd* pThrd = conn->hostThrd; STrans* pTransInst = pThrd->pTransInst; - STransMsgHead* pHead = (STransMsgHead*)(conn->readBuf.buf); + STransMsgHead* pHead = NULL; + transDumpFromBuffer(&conn->readBuf, (char**)&pHead); pHead->code = htonl(pHead->code); pHead->msgLen = htonl(pHead->msgLen); @@ -366,7 +374,6 @@ void cliHandleResp(SCliConn* conn) { } } // buf's mem alread translated to transMsg.pCont - transClearBuffer(&conn->readBuf); if (!CONN_NO_PERSIST_BY_APP(conn)) { transMsg.info.handle = (void*)conn->refId; tDebug("%s conn %p ref by app", CONN_GET_INST_LABEL(conn), conn); @@ -497,9 +504,8 @@ void* destroyConnPool(void* pool) { } static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) { - char key[128] = {0}; + char key[32] = {0}; CONN_CONSTRUCT_HASH_KEY(key, ip, port); - SHashObj* pPool = pool; SConnList* plist = taosHashGet(pPool, key, strlen(key)); if (plist == NULL) { @@ -517,13 +523,44 @@ static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) { conn->status = ConnNormal; QUEUE_REMOVE(&conn->q); QUEUE_INIT(&conn->q); - assert(h == &conn->q); transDQCancel(((SCliThrd*)conn->hostThrd)->timeoutQueue, conn->task); conn->task = NULL; return conn; } +static void addConnToPool(void* pool, SCliConn* conn) { + if (conn->status == ConnInPool) { + return; + } + SCliThrd* thrd = conn->hostThrd; + CONN_HANDLE_THREAD_QUIT(thrd); + + allocConnRef(conn, true); + + STrans* pTransInst = thrd->pTransInst; + cliReleaseUnfinishedMsg(conn); + transQueueClear(&conn->cliMsgs); + transCtxCleanup(&conn->ctx); + conn->status = ConnInPool; + + if (conn->list == NULL) { + char key[32] = {0}; + CONN_CONSTRUCT_HASH_KEY(key, conn->ip, conn->port); + tTrace("%s conn %p added to conn pool, read buf cap:%d", CONN_GET_INST_LABEL(conn), conn, conn->readBuf.cap); + conn->list = taosHashGet((SHashObj*)pool, key, strlen(key)); + } + assert(conn->list != NULL); + QUEUE_INIT(&conn->q); + QUEUE_PUSH(&conn->list->conn, &conn->q); + + assert(!QUEUE_IS_EMPTY(&conn->list->conn)); + + STaskArg* arg = taosMemoryCalloc(1, sizeof(STaskArg)); + arg->param1 = conn; + arg->param2 = thrd; + conn->task = transDQSched(thrd->timeoutQueue, doCloseIdleConn, arg, CONN_PERSIST_TIME(pTransInst->idleTime)); +} static int32_t allocConnRef(SCliConn* conn, bool update) { if (update) { transRemoveExHandle(transGetRefMgt(), conn->refId); @@ -554,38 +591,6 @@ static int32_t specifyConnRef(SCliConn* conn, bool update, int64_t handle) { return 0; } -static void addConnToPool(void* pool, SCliConn* conn) { - if (conn->status == ConnInPool) { - return; - } - SCliThrd* thrd = conn->hostThrd; - CONN_HANDLE_THREAD_QUIT(thrd); - - allocConnRef(conn, true); - - STrans* pTransInst = thrd->pTransInst; - cliReleaseUnfinishedMsg(conn); - transQueueClear(&conn->cliMsgs); - transCtxCleanup(&conn->ctx); - conn->status = ConnInPool; - - char key[128] = {0}; - CONN_CONSTRUCT_HASH_KEY(key, conn->ip, conn->port); - tTrace("%s conn %p added to conn pool, read buf cap:%d", CONN_GET_INST_LABEL(conn), conn, conn->readBuf.cap); - - SConnList* plist = taosHashGet((SHashObj*)pool, key, strlen(key)); - // list already create before - assert(plist != NULL); - QUEUE_INIT(&conn->q); - QUEUE_PUSH(&plist->conn, &conn->q); - - assert(!QUEUE_IS_EMPTY(&plist->conn)); - - STaskArg* arg = taosMemoryCalloc(1, sizeof(STaskArg)); - arg->param1 = conn; - arg->param2 = thrd; - conn->task = transDQSched(thrd->timeoutQueue, doCloseIdleConn, arg, CONN_PERSIST_TIME(pTransInst->idleTime)); -} static void cliAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { SCliConn* conn = handle->data; SConnBuffer* pBuf = &conn->readBuf; @@ -600,11 +605,9 @@ static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { SConnBuffer* pBuf = &conn->readBuf; if (nread > 0) { pBuf->len += nread; - if (transReadComplete(pBuf)) { + while (transReadComplete(pBuf)) { tTrace("%s conn %p read complete", CONN_GET_INST_LABEL(conn), conn); cliHandleResp(conn); - } else { - tTrace("%s conn %p read partial packet, continue to read", CONN_GET_INST_LABEL(conn), conn); } return; } @@ -636,6 +639,8 @@ static SCliConn* cliCreateConn(SCliThrd* pThrd) { transReqQueueInit(&conn->wreqQueue); transQueueInit(&conn->cliMsgs, NULL); + + transInitBuffer(&conn->readBuf); QUEUE_INIT(&conn->q); conn->hostThrd = pThrd; conn->status = ConnNormal; @@ -651,8 +656,9 @@ static void cliDestroyConn(SCliConn* conn, bool clear) { QUEUE_REMOVE(&conn->q); QUEUE_INIT(&conn->q); transRemoveExHandle(transGetRefMgt(), conn->refId); - conn->refId = -1; + transDestroyBuffer(&conn->readBuf); + conn->refId = -1; if (conn->task != NULL) transDQCancel(((SCliThrd*)conn->hostThrd)->timeoutQueue, conn->task); if (clear) { @@ -678,7 +684,6 @@ static void cliDestroy(uv_handle_t* handle) { tTrace("%s conn %p destroy successfully", CONN_GET_INST_LABEL(conn), conn); transReqQueueClear(&conn->wreqQueue); - transDestroyBuffer(&conn->readBuf); taosMemoryFree(conn); } static bool cliHandleNoResp(SCliConn* conn) { @@ -960,6 +965,66 @@ static void cliAsyncCb(uv_async_t* handle) { } if (pThrd->stopMsg != NULL) cliHandleQuit(pThrd->stopMsg, pThrd); } +static void cliIdleCb(uv_idle_t* handle) { + SCliThrd* thrd = handle->data; + tTrace("do idle work"); + + SAsyncPool* pool = thrd->asyncPool; + for (int i = 0; i < pool->nAsync; i++) { + uv_async_t* async = &(pool->asyncs[i]); + SAsyncItem* item = async->data; + + queue wq; + taosThreadMutexLock(&item->mtx); + QUEUE_MOVE(&item->qmsg, &wq); + taosThreadMutexUnlock(&item->mtx); + + int count = 0; + while (!QUEUE_IS_EMPTY(&wq)) { + queue* h = QUEUE_HEAD(&wq); + QUEUE_REMOVE(h); + + SCliMsg* pMsg = QUEUE_DATA(h, SCliMsg, q); + if (pMsg == NULL) { + continue; + } + (*cliAsyncHandle[pMsg->type])(pMsg, thrd); + count++; + } + } + tTrace("prepare work end"); + if (thrd->stopMsg != NULL) cliHandleQuit(thrd->stopMsg, thrd); +} +static void cliPrepareCb(uv_prepare_t* handle) { + SCliThrd* thrd = handle->data; + tTrace("prepare work start"); + + SAsyncPool* pool = thrd->asyncPool; + for (int i = 0; i < pool->nAsync; i++) { + uv_async_t* async = &(pool->asyncs[i]); + SAsyncItem* item = async->data; + + queue wq; + taosThreadMutexLock(&item->mtx); + QUEUE_MOVE(&item->qmsg, &wq); + taosThreadMutexUnlock(&item->mtx); + + int count = 0; + while (!QUEUE_IS_EMPTY(&wq)) { + queue* h = QUEUE_HEAD(&wq); + QUEUE_REMOVE(h); + + SCliMsg* pMsg = QUEUE_DATA(h, SCliMsg, q); + if (pMsg == NULL) { + continue; + } + (*cliAsyncHandle[pMsg->type])(pMsg, thrd); + count++; + } + } + tTrace("prepare work end"); + if (thrd->stopMsg != NULL) cliHandleQuit(thrd->stopMsg, thrd); +} static void* cliWorkThread(void* arg) { SCliThrd* pThrd = (SCliThrd*)arg; @@ -1022,6 +1087,16 @@ static SCliThrd* createThrdObj() { uv_timer_init(pThrd->loop, &pThrd->timer); pThrd->timer.data = pThrd; + // pThrd->idle = taosMemoryCalloc(1, sizeof(uv_idle_t)); + // uv_idle_init(pThrd->loop, pThrd->idle); + // pThrd->idle->data = pThrd; + // uv_idle_start(pThrd->idle, cliIdleCb); + + pThrd->prepare = taosMemoryCalloc(1, sizeof(uv_prepare_t)); + uv_prepare_init(pThrd->loop, pThrd->prepare); + pThrd->prepare->data = pThrd; + uv_prepare_start(pThrd->prepare, cliPrepareCb); + pThrd->pool = createConnPool(4); transDQCreate(pThrd->loop, &pThrd->delayQueue); @@ -1043,6 +1118,9 @@ static void destroyThrdObj(SCliThrd* pThrd) { transDQDestroy(pThrd->delayQueue, destroyCmsg); transDQDestroy(pThrd->timeoutQueue, NULL); + + taosMemoryFree(pThrd->idle); + taosMemoryFree(pThrd->prepare); taosMemoryFree(pThrd->loop); taosMemoryFree(pThrd); } diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 155cdd1062afd12093afff9496ae4a36583e93a3..8cf525a506fe856876f2e8577e6f97dedbdb8d26 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -16,6 +16,8 @@ #include "transComm.h" +#define BUFFER_CAP 4096 + static TdThreadOnce transModuleInit = PTHREAD_ONCE_INIT; static int32_t refMgt; @@ -111,12 +113,59 @@ int transGetSockDebugInfo(struct sockaddr* sockname, char* dst) { return r; } int transInitBuffer(SConnBuffer* buf) { - transClearBuffer(buf); + buf->cap = BUFFER_CAP; + buf->buf = taosMemoryCalloc(1, BUFFER_CAP); + buf->left = -1; + buf->len = 0; + buf->total = 0; + return 0; +} +int transDestroyBuffer(SConnBuffer* p) { + taosMemoryFree(p->buf); + p->buf = NULL; return 0; } + int transClearBuffer(SConnBuffer* buf) { - memset(buf, 0, sizeof(*buf)); - buf->total = -1; + SConnBuffer* p = buf; + if (p->cap > BUFFER_CAP) { + p->cap = BUFFER_CAP; + p->buf = taosMemoryRealloc(p->buf, BUFFER_CAP); + } + p->left = -1; + p->len = 0; + p->total = 0; + return 0; +} + +int transDumpFromBuffer(SConnBuffer* connBuf, char** buf) { + SConnBuffer* p = connBuf; + if (p->left != 0) { + return -1; + } + int total = connBuf->total; + *buf = taosMemoryCalloc(1, total); + memcpy(*buf, p->buf, total); + + transResetBuffer(connBuf); + return total; +} + +int transResetBuffer(SConnBuffer* connBuf) { + SConnBuffer* p = connBuf; + if (p->total < p->len) { + int left = p->len - p->total; + memmove(p->buf, p->buf + p->total, left); + p->left = -1; + p->total = 0; + p->len = left; + } else if (p->total == p->len) { + p->left = -1; + p->total = 0; + p->len = 0; + } else { + assert(0); + } return 0; } int transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf) { @@ -126,54 +175,39 @@ int transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf) { * |<------STransMsgHead------->|<-------------------userdata--------------->|<-----auth data----->|<----user * info--->| */ - static const int CAPACITY = sizeof(STransMsgHead); - SConnBuffer* p = connBuf; - if (p->cap == 0) { - p->buf = (char*)taosMemoryCalloc(CAPACITY, sizeof(char)); - tTrace("internal malloc mem:%p, size:%d", p->buf, CAPACITY); - p->len = 0; - p->cap = CAPACITY; - p->total = -1; - - uvBuf->base = p->buf; - uvBuf->len = CAPACITY; - } else if (p->total == -1 && p->len < CAPACITY) { - uvBuf->base = p->buf + p->len; - uvBuf->len = CAPACITY - p->len; - } else { - p->cap = p->total; - p->buf = taosMemoryRealloc(p->buf, p->cap); - tTrace("internal realloc mem:%p, size:%d", p->buf, p->cap); - uvBuf->base = p->buf + p->len; + uvBuf->base = p->buf + p->len; + if (p->left == -1) { uvBuf->len = p->cap - p->len; + } else { + if (p->left < p->cap - p->len) { + uvBuf->len = p->left; + } else { + p->buf = taosMemoryRealloc(p->buf, p->left + p->len); + uvBuf->base = p->buf + p->len; + uvBuf->len = p->left; + } } return 0; } // check whether already read complete bool transReadComplete(SConnBuffer* connBuf) { - if (connBuf->total == -1 && connBuf->len >= sizeof(STransMsgHead)) { - STransMsgHead head; - memcpy((char*)&head, connBuf->buf, sizeof(head)); - int32_t msgLen = (int32_t)htonl(head.msgLen); - connBuf->total = msgLen; - } - if (connBuf->len == connBuf->cap && connBuf->total == connBuf->cap) { - return true; - } - return false; -} -int transPackMsg(STransMsgHead* msgHead, bool sercured, bool auth) { return 0; } - -int transUnpackMsg(STransMsgHead* msgHead) { return 0; } -int transDestroyBuffer(SConnBuffer* buf) { - if (buf->cap > 0) { - taosMemoryFreeClear(buf->buf); + SConnBuffer* p = connBuf; + if (p->len >= sizeof(STransMsgHead)) { + if (p->left == -1) { + STransMsgHead head; + memcpy((char*)&head, connBuf->buf, sizeof(head)); + int32_t msgLen = (int32_t)htonl(head.msgLen); + p->total = msgLen; + } + if (p->total >= p->len) { + p->left = p->total - p->len; + } else { + p->left = 0; + } } - transClearBuffer(buf); - - return 0; + return p->left == 0 ? true : false; } int transSetConnOption(uv_tcp_t* stream) { diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index fe7ab47feebd8e5ac40327f37b9334fa8eb22093..4b579a1f9527bde98f9ac4d21723ed9d17e965d6 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -73,6 +73,7 @@ typedef struct SWorkThrd { uv_os_fd_t fd; uv_loop_t* loop; SAsyncPool* asyncPool; + uv_prepare_t* prepare; queue msg; TdThreadMutex msgMtx; @@ -112,6 +113,7 @@ static void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) static void uvWorkerAsyncCb(uv_async_t* handle); static void uvAcceptAsyncCb(uv_async_t* handle); static void uvShutDownCb(uv_shutdown_t* req, int status); +static void uvPrepareCb(uv_prepare_t* handle); /* * time-consuming task throwed into BG work thread @@ -212,9 +214,10 @@ static void uvHandleActivityTimeout(uv_timer_t* handle) { } static void uvHandleReq(SSvrConn* pConn) { - SConnBuffer* pBuf = &pConn->readBuf; - char* msg = pBuf->buf; - uint32_t msgLen = pBuf->len; + STransMsgHead* msg = NULL; + int msgLen = 0; + + msgLen = transDumpFromBuffer(&pConn->readBuf, (char**)&msg); STransMsgHead* pHead = (STransMsgHead*)msg; pHead->code = htonl(pHead->code); @@ -237,8 +240,6 @@ static void uvHandleReq(SSvrConn* pConn) { transMsg.msgType = pHead->msgType; transMsg.code = pHead->code; - transClearBuffer(&pConn->readBuf); - pConn->inType = pHead->msgType; if (pConn->status == ConnNormal) { if (pHead->persist == 1) { @@ -545,6 +546,52 @@ static void uvShutDownCb(uv_shutdown_t* req, int status) { uv_close((uv_handle_t*)req->handle, uvDestroyConn); taosMemoryFree(req); } +static void uvPrepareCb(uv_prepare_t* handle) { + // prepare callback + SWorkThrd* pThrd = handle->data; + SAsyncPool* pool = pThrd->asyncPool; + + for (int i = 0; i < pool->nAsync; i++) { + uv_async_t* async = &(pool->asyncs[i]); + SAsyncItem* item = async->data; + + queue wq; + taosThreadMutexLock(&item->mtx); + QUEUE_MOVE(&item->qmsg, &wq); + taosThreadMutexUnlock(&item->mtx); + + while (!QUEUE_IS_EMPTY(&wq)) { + queue* head = QUEUE_HEAD(&wq); + QUEUE_REMOVE(head); + + SSvrMsg* msg = QUEUE_DATA(head, SSvrMsg, q); + if (msg == NULL) { + tError("unexcept occurred, continue"); + continue; + } + // release handle to rpc init + if (msg->type == Quit) { + (*transAsyncHandle[msg->type])(msg, pThrd); + continue; + } else { + STransMsg transMsg = msg->msg; + + SExHandle* exh1 = transMsg.info.handle; + int64_t refId = transMsg.info.refId; + SExHandle* exh2 = transAcquireExHandle(transGetRefMgt(), refId); + if (exh2 == NULL || exh1 != exh2) { + tTrace("handle except msg %p, ignore it", exh1); + transReleaseExHandle(transGetRefMgt(), refId); + destroySmsg(msg); + continue; + } + msg->pConn = exh1->handle; + transReleaseExHandle(transGetRefMgt(), refId); + (*transAsyncHandle[msg->type])(msg, pThrd); + } + } + } +} static void uvWorkDoTask(uv_work_t* req) { // doing time-consumeing task @@ -694,13 +741,17 @@ static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) { } uv_pipe_init(pThrd->loop, pThrd->pipe, 1); - // int r = uv_pipe_open(pThrd->pipe, pThrd->fd); pThrd->pipe->data = pThrd; QUEUE_INIT(&pThrd->msg); taosThreadMutexInit(&pThrd->msgMtx, NULL); + pThrd->prepare = taosMemoryCalloc(1, sizeof(uv_prepare_t)); + uv_prepare_init(pThrd->loop, pThrd->prepare); + uv_prepare_start(pThrd->prepare, uvPrepareCb); + pThrd->prepare->data = pThrd; + // conn set QUEUE_INIT(&pThrd->conn); @@ -761,6 +812,7 @@ static SSvrConn* createConn(void* hThrd) { memset(&pConn->regArg, 0, sizeof(pConn->regArg)); pConn->broken = false; pConn->status = ConnNormal; + transInitBuffer(&pConn->readBuf); SExHandle* exh = taosMemoryMalloc(sizeof(SExHandle)); exh->handle = pConn; @@ -984,6 +1036,7 @@ void destroyWorkThrd(SWorkThrd* pThrd) { SRV_RELEASE_UV(pThrd->loop); TRANS_DESTROY_ASYNC_POOL_MSG(pThrd->asyncPool, SSvrMsg, destroySmsg); transAsyncPoolDestroy(pThrd->asyncPool); + taosMemoryFree(pThrd->prepare); taosMemoryFree(pThrd->loop); taosMemoryFree(pThrd); } diff --git a/source/libs/transport/test/CMakeLists.txt b/source/libs/transport/test/CMakeLists.txt index 5645f49284027c17a2b2abc1f085a3140d57bbe4..51be28ba0ec98405293602ece3bcb47d2539b7c3 100644 --- a/source/libs/transport/test/CMakeLists.txt +++ b/source/libs/transport/test/CMakeLists.txt @@ -1,6 +1,7 @@ add_executable(transportTest "") add_executable(transUT "") -add_executable(pushServer "") +add_executable(svrBench "") +add_executable(cliBench "") target_sources(transUT PRIVATE @@ -12,9 +13,13 @@ target_sources(transportTest "transportTests.cpp" ) -target_sources(pushServer +target_sources(svrBench PRIVATE - "pushServer.c" + "svrBench.c" +) +target_sources(cliBench + PRIVATE + "cliBench.c" ) target_include_directories(transportTest @@ -45,13 +50,37 @@ target_include_directories(transUT "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) -target_include_directories(pushServer +target_include_directories(svrBench + PUBLIC + "${TD_SOURCE_DIR}/include/libs/transport" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) +target_include_directories(svrBench + PUBLIC + "${TD_SOURCE_DIR}/include/libs/transport" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) + +target_link_libraries (svrBench + os + util + common + gtest_main + transport +) + +target_include_directories(cliBench + PUBLIC + "${TD_SOURCE_DIR}/include/libs/transport" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) +target_include_directories(cliBench PUBLIC "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) -target_link_libraries (pushServer +target_link_libraries (cliBench os util common diff --git a/source/libs/transport/test/cliBench.c b/source/libs/transport/test/cliBench.c new file mode 100644 index 0000000000000000000000000000000000000000..a296625acef45ae05e4e7b489bdf364a97cebfbc --- /dev/null +++ b/source/libs/transport/test/cliBench.c @@ -0,0 +1,182 @@ +/* + * 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 "os.h" +#include "taoserror.h" +#include "tglobal.h" +#include "transLog.h" +#include "trpc.h" +#include "tutil.h" + +typedef struct { + int index; + SEpSet epSet; + int num; + int numOfReqs; + int msgSize; + tsem_t rspSem; + tsem_t *pOverSem; + TdThread thread; + void *pRpc; +} SInfo; + +static void processResponse(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { + SInfo *pInfo = (SInfo *)pMsg->info.ahandle; + tDebug("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, + pMsg->code); + + if (pEpSet) pInfo->epSet = *pEpSet; + + rpcFreeCont(pMsg->pCont); + tsem_post(&pInfo->rspSem); +} + +static int tcount = 0; + +static void *sendRequest(void *param) { + SInfo *pInfo = (SInfo *)param; + SRpcMsg rpcMsg = {0}; + + tDebug("thread:%d, start to send request", pInfo->index); + + while (pInfo->numOfReqs == 0 || pInfo->num < pInfo->numOfReqs) { + pInfo->num++; + rpcMsg.pCont = rpcMallocCont(pInfo->msgSize); + rpcMsg.contLen = pInfo->msgSize; + rpcMsg.info.ahandle = pInfo; + rpcMsg.msgType = 1; + tDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num); + rpcSendRequest(pInfo->pRpc, &pInfo->epSet, &rpcMsg, NULL); + if (pInfo->num % 20000 == 0) tInfo("thread:%d, %d requests have been sent", pInfo->index, pInfo->num); + tsem_wait(&pInfo->rspSem); + } + + tDebug("thread:%d, it is over", pInfo->index); + tcount++; + + return NULL; +} + +int main(int argc, char *argv[]) { + SRpcInit rpcInit; + SEpSet epSet; + int msgSize = 128; + int numOfReqs = 0; + int appThreads = 1; + char serverIp[40] = "127.0.0.1"; + struct timeval systemTime; + int64_t startTime, endTime; + + // server info + epSet.numOfEps = 1; + epSet.inUse = 0; + epSet.eps[0].port = 7000; + epSet.eps[1].port = 7000; + strcpy(epSet.eps[0].fqdn, serverIp); + strcpy(epSet.eps[1].fqdn, "192.168.0.1"); + + // client info + memset(&rpcInit, 0, sizeof(rpcInit)); + rpcInit.localPort = 0; + rpcInit.label = "APP"; + rpcInit.numOfThreads = 1; + rpcInit.cfp = processResponse; + rpcInit.sessions = 100; + rpcInit.idleTime = tsShellActivityTimer * 1000; + rpcInit.user = "michael"; + rpcInit.connType = TAOS_CONN_CLIENT; + + rpcDebugFlag = 131; + for (int i = 1; i < argc; ++i) { + if (strcmp(argv[i], "-p") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-i") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-t") == 0 && i < argc - 1) { + rpcInit.numOfThreads = atoi(argv[++i]); + } else if (strcmp(argv[i], "-m") == 0 && i < argc - 1) { + msgSize = atoi(argv[++i]); + } else if (strcmp(argv[i], "-s") == 0 && i < argc - 1) { + rpcInit.sessions = atoi(argv[++i]); + } else if (strcmp(argv[i], "-n") == 0 && i < argc - 1) { + numOfReqs = atoi(argv[++i]); + } else if (strcmp(argv[i], "-a") == 0 && i < argc - 1) { + appThreads = atoi(argv[++i]); + } else if (strcmp(argv[i], "-o") == 0 && i < argc - 1) { + tsCompressMsgSize = atoi(argv[++i]); + } else if (strcmp(argv[i], "-u") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-k") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-spi") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-d") == 0 && i < argc - 1) { + rpcDebugFlag = atoi(argv[++i]); + } else { + printf("\nusage: %s [options] \n", argv[0]); + printf(" [-i ip]: first server IP address, default is:%s\n", serverIp); + printf(" [-t threads]: number of rpc threads, default is:%d\n", rpcInit.numOfThreads); + printf(" [-m msgSize]: message body size, default is:%d\n", msgSize); + printf(" [-a threads]: number of app threads, default is:%d\n", appThreads); + printf(" [-n requests]: number of requests per thread, default is:%d\n", numOfReqs); + printf(" [-u user]: user name for the connection, default is:%s\n", rpcInit.user); + printf(" [-d debugFlag]: debug flag, default:%d\n", rpcDebugFlag); + printf(" [-h help]: print out this help\n\n"); + exit(0); + } + } + taosInitLog("client.log", 100000); + + void *pRpc = rpcOpen(&rpcInit); + if (pRpc == NULL) { + tError("failed to initialize RPC"); + return -1; + } + + tInfo("client is initialized"); + tInfo("threads:%d msgSize:%d requests:%d", appThreads, msgSize, numOfReqs); + + int64_t now = taosGetTimestampUs(); + + SInfo *pInfo = (SInfo *)taosMemoryCalloc(1, sizeof(SInfo) * appThreads); + SInfo *p = pInfo; + for (int i = 0; i < appThreads; ++i) { + pInfo->index = i; + pInfo->epSet = epSet; + pInfo->numOfReqs = numOfReqs; + pInfo->msgSize = msgSize; + tsem_init(&pInfo->rspSem, 0, 0); + pInfo->pRpc = pRpc; + + taosThreadCreate(&pInfo->thread, NULL, sendRequest, pInfo); + pInfo++; + } + + do { + taosUsleep(1); + } while (tcount < appThreads); + + float usedTime = (taosGetTimestampUs() - now) / 1000.0f; + + tInfo("it takes %.3f mseconds to send %d requests to server", usedTime, numOfReqs * appThreads); + tInfo("Performance: %.3f requests per second, msgSize:%d bytes", 1000.0 * numOfReqs * appThreads / usedTime, msgSize); + + for (int i = 0; i < appThreads; i++) { + SInfo *pInfo = p; + taosThreadJoin(pInfo->thread, NULL); + p++; + } + int ch = getchar(); + UNUSED(ch); + + taosCloseLog(); + + return 0; +} diff --git a/source/libs/transport/test/pushServer.c b/source/libs/transport/test/svrBench.c similarity index 89% rename from source/libs/transport/test/pushServer.c rename to source/libs/transport/test/svrBench.c index 754433a5e6a1bd3709ef2c45af3762b9c280c3c9..224f527385730dd8a7344d32270ce7883e3280c6 100644 --- a/source/libs/transport/test/pushServer.c +++ b/source/libs/transport/test/svrBench.c @@ -24,12 +24,12 @@ int msgSize = 128; int commit = 0; TdFilePtr pDataFile = NULL; STaosQueue *qhandle = NULL; -STaosQset * qset = NULL; +STaosQset *qset = NULL; void processShellMsg() { static int num = 0; STaosQall *qall; - SRpcMsg * pRpcMsg, rpcMsg; + SRpcMsg *pRpcMsg, rpcMsg; int type; SQueueInfo qinfo = {0}; @@ -77,7 +77,6 @@ void processShellMsg() { taosFreeQitem(pRpcMsg); { - // taosSsleep(1); SRpcMsg nRpcMsg = {0}; nRpcMsg.pCont = rpcMallocCont(msgSize); nRpcMsg.contLen = msgSize; @@ -93,26 +92,6 @@ void processShellMsg() { taosFreeQall(qall); } -int retrieveAuthInfo(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey) { - // app shall retrieve the auth info based on meterID from DB or a data file - // demo code here only for simple demo - int ret = 0; - - if (strcmp(meterId, "michael") == 0) { - *spi = 1; - *encrypt = 0; - strcpy(secret, "mypassword"); - strcpy(ckey, "key"); - } else if (strcmp(meterId, "jeff") == 0) { - *spi = 0; - *encrypt = 0; - } else { - ret = -1; // user not there - } - - return ret; -} - void processRequestMsg(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) { SRpcMsg *pTemp; @@ -131,11 +110,12 @@ int main(int argc, char *argv[]) { memset(&rpcInit, 0, sizeof(rpcInit)); rpcInit.localPort = 7000; + memcpy(rpcInit.localFqdn, "localhost", strlen("localhost")); rpcInit.label = "SER"; rpcInit.numOfThreads = 1; rpcInit.cfp = processRequestMsg; - rpcInit.sessions = 1000; rpcInit.idleTime = 2 * 1500; + rpcDebugFlag = 131; for (int i = 1; i < argc; ++i) { if (strcmp(argv[i], "-p") == 0 && i < argc - 1) { @@ -170,7 +150,7 @@ int main(int argc, char *argv[]) { tsAsyncLog = 0; rpcInit.connType = TAOS_CONN_SERVER; - taosInitLog("server.log", 10); + taosInitLog("server.log", 100000); void *pRpc = rpcOpen(&rpcInit); if (pRpc == NULL) { diff --git a/source/libs/wal/inc/walInt.h b/source/libs/wal/inc/walInt.h index 20667fc91887392c9c67715309094f1b29f4b306..3aebb1c6ba1174a26516abe7c52298bb61642639 100644 --- a/source/libs/wal/inc/walInt.h +++ b/source/libs/wal/inc/walInt.h @@ -61,26 +61,31 @@ static inline int32_t compareWalFileInfo(const void* pLeft, const void* pRight) } static inline int64_t walGetLastFileSize(SWal* pWal) { + if (taosArrayGetSize(pWal->fileInfoSet) == 0) return 0; SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGetLast(pWal->fileInfoSet); return pInfo->fileSize; } static inline int64_t walGetLastFileFirstVer(SWal* pWal) { + if (taosArrayGetSize(pWal->fileInfoSet) == 0) return -1; SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGetLast(pWal->fileInfoSet); return pInfo->firstVer; } static inline int64_t walGetCurFileFirstVer(SWal* pWal) { + if (pWal->writeCur == -1) return -1; SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur); return pInfo->firstVer; } static inline int64_t walGetCurFileLastVer(SWal* pWal) { + if (pWal->writeCur == -1) return -1; SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur); return pInfo->firstVer; } static inline int64_t walGetCurFileOffset(SWal* pWal) { + if (pWal->writeCur == -1) return -1; SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur); return pInfo->fileSize; } @@ -88,6 +93,7 @@ static inline int64_t walGetCurFileOffset(SWal* pWal) { static inline bool walCurFileClosed(SWal* pWal) { return taosArrayGetSize(pWal->fileInfoSet) != pWal->writeCur; } static inline SWalFileInfo* walGetCurFileInfo(SWal* pWal) { + if (pWal->writeCur == -1) return NULL; return (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur); } diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index a5fd3fca35c01b84f0b2c5b7cc4fe3b7bbf76662..a8da6809100fa5789e5b7e57e051631257782e1e 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -139,7 +139,7 @@ int walCheckAndRepairMeta(SWal* pWal) { const char* idxPattern = "^[0-9]+.idx$"; regex_t logRegPattern; regex_t idxRegPattern; - SArray* pLogInfoArray = taosArrayInit(8, sizeof(SWalFileInfo)); + SArray* actualLog = taosArrayInit(8, sizeof(SWalFileInfo)); regcomp(&logRegPattern, logPattern, REG_EXTENDED); regcomp(&idxRegPattern, idxPattern, REG_EXTENDED); @@ -159,7 +159,7 @@ int walCheckAndRepairMeta(SWal* pWal) { SWalFileInfo fileInfo; memset(&fileInfo, -1, sizeof(SWalFileInfo)); sscanf(name, "%" PRId64 ".log", &fileInfo.firstVer); - taosArrayPush(pLogInfoArray, &fileInfo); + taosArrayPush(actualLog, &fileInfo); } } @@ -167,10 +167,10 @@ int walCheckAndRepairMeta(SWal* pWal) { regfree(&logRegPattern); regfree(&idxRegPattern); - taosArraySort(pLogInfoArray, compareWalFileInfo); + taosArraySort(actualLog, compareWalFileInfo); int metaFileNum = taosArrayGetSize(pWal->fileInfoSet); - int actualFileNum = taosArrayGetSize(pLogInfoArray); + int actualFileNum = taosArrayGetSize(actualLog); #if 0 for (int32_t fileNo = actualFileNum - 1; fileNo >= 0; fileNo--) { @@ -196,11 +196,11 @@ int walCheckAndRepairMeta(SWal* pWal) { taosArrayPopFrontBatch(pWal->fileInfoSet, metaFileNum - actualFileNum); } else if (metaFileNum < actualFileNum) { for (int i = metaFileNum; i < actualFileNum; i++) { - SWalFileInfo* pFileInfo = taosArrayGet(pLogInfoArray, i); + SWalFileInfo* pFileInfo = taosArrayGet(actualLog, i); taosArrayPush(pWal->fileInfoSet, pFileInfo); } } - taosArrayDestroy(pLogInfoArray); + taosArrayDestroy(actualLog); pWal->writeCur = actualFileNum - 1; if (actualFileNum > 0) { @@ -221,7 +221,7 @@ int walCheckAndRepairMeta(SWal* pWal) { int code = walSaveMeta(pWal); if (code < 0) { - taosArrayDestroy(pLogInfoArray); + taosArrayDestroy(actualLog); return -1; } } diff --git a/source/libs/wal/src/walMgmt.c b/source/libs/wal/src/walMgmt.c index 85238e87b9f5c5549f2a1cf82435dca8fd85b5a4..c939c8c43685ef3dc6ea0b4fde1cd5fbfb33a8d1 100644 --- a/source/libs/wal/src/walMgmt.c +++ b/source/libs/wal/src/walMgmt.c @@ -83,7 +83,16 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) { // set config memcpy(&pWal->cfg, pCfg, sizeof(SWalCfg)); + pWal->fsyncSeq = pCfg->fsyncPeriod / 1000; + if (pWal->cfg.retentionSize > 0) { + pWal->cfg.retentionSize *= 1024; + } + + if (pWal->cfg.segSize > 0) { + pWal->cfg.segSize *= 1024; + } + if (pWal->fsyncSeq <= 0) pWal->fsyncSeq = 1; tstrncpy(pWal->path, path, sizeof(pWal->path)); @@ -101,8 +110,8 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) { // open meta walResetVer(&pWal->vers); - pWal->pWriteLogTFile = NULL; - pWal->pWriteIdxTFile = NULL; + pWal->pLogFile = NULL; + pWal->pIdxFile = NULL; pWal->writeCur = -1; pWal->fileInfoSet = taosArrayInit(8, sizeof(SWalFileInfo)); if (pWal->fileInfoSet == NULL) { @@ -179,10 +188,10 @@ int32_t walAlter(SWal *pWal, SWalCfg *pCfg) { void walClose(SWal *pWal) { taosThreadMutexLock(&pWal->mutex); - taosCloseFile(&pWal->pWriteLogTFile); - pWal->pWriteLogTFile = NULL; - taosCloseFile(&pWal->pWriteIdxTFile); - pWal->pWriteIdxTFile = NULL; + taosCloseFile(&pWal->pLogFile); + pWal->pLogFile = NULL; + taosCloseFile(&pWal->pIdxFile); + pWal->pIdxFile = NULL; walSaveMeta(pWal); taosArrayDestroy(pWal->fileInfoSet); pWal->fileInfoSet = NULL; @@ -223,7 +232,7 @@ static void walFsyncAll() { if (walNeedFsync(pWal)) { wTrace("vgId:%d, do fsync, level:%d seq:%d rseq:%d", pWal->cfg.vgId, pWal->cfg.level, pWal->fsyncSeq, atomic_load_32(&tsWal.seq)); - int32_t code = taosFsyncFile(pWal->pWriteLogTFile); + int32_t code = taosFsyncFile(pWal->pLogFile); if (code != 0) { wError("vgId:%d, file:%" PRId64 ".log, failed to fsync since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal), strerror(code)); diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index ac62b7d98dfeec5e7df073ef165a79d1ad95b7f6..787c9af31703df50a4b91589e20f5f9373d71c56 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -423,37 +423,38 @@ int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead) { return 0; } -int32_t walReadVer(SWalReader *pRead, int64_t ver) { - wDebug("vgId:%d wal start to read ver %ld", pRead->pWal->cfg.vgId, ver); +int32_t walReadVer(SWalReader *pReader, int64_t ver) { + wDebug("vgId:%d wal start to read ver %ld", pReader->pWal->cfg.vgId, ver); int64_t contLen; + int32_t code; bool seeked = false; - if (pRead->pWal->vers.firstVer == -1) { + if (pReader->pWal->vers.firstVer == -1) { terrno = TSDB_CODE_WAL_LOG_NOT_EXIST; return -1; } - if (ver > pRead->pWal->vers.lastVer || ver < pRead->pWal->vers.firstVer) { - wDebug("vgId:%d, invalid index:%" PRId64 ", first index:%" PRId64 ", last index:%" PRId64, pRead->pWal->cfg.vgId, - ver, pRead->pWal->vers.firstVer, pRead->pWal->vers.lastVer); + if (ver > pReader->pWal->vers.lastVer || ver < pReader->pWal->vers.firstVer) { + wDebug("vgId:%d, invalid index:%" PRId64 ", first index:%" PRId64 ", last index:%" PRId64, pReader->pWal->cfg.vgId, + ver, pReader->pWal->vers.firstVer, pReader->pWal->vers.lastVer); terrno = TSDB_CODE_WAL_LOG_NOT_EXIST; return -1; } - if (pRead->curInvalid || pRead->curVersion != ver) { - if (walReadSeekVer(pRead, ver) < 0) { - wError("vgId:%d, unexpected wal log, index:%" PRId64 ", since %s", pRead->pWal->cfg.vgId, ver, terrstr()); + if (pReader->curInvalid || pReader->curVersion != ver) { + if (walReadSeekVer(pReader, ver) < 0) { + wError("vgId:%d, unexpected wal log, index:%" PRId64 ", since %s", pReader->pWal->cfg.vgId, ver, terrstr()); return -1; } seeked = true; } while (1) { - contLen = taosReadFile(pRead->pLogFile, pRead->pHead, sizeof(SWalCkHead)); + contLen = taosReadFile(pReader->pLogFile, pReader->pHead, sizeof(SWalCkHead)); if (contLen == sizeof(SWalCkHead)) { break; } else if (contLen == 0 && !seeked) { - walReadSeekVerImpl(pRead, ver); + walReadSeekVerImpl(pReader, ver); seeked = true; continue; } else { @@ -467,26 +468,26 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) { } } - contLen = walValidHeadCksum(pRead->pHead); - if (contLen != 0) { - wError("vgId:%d, unexpected wal log, index:%" PRId64 ", since head checksum not passed", pRead->pWal->cfg.vgId, + code = walValidHeadCksum(pReader->pHead); + if (code != 0) { + wError("vgId:%d, unexpected wal log, index:%" PRId64 ", since head checksum not passed", pReader->pWal->cfg.vgId, ver); terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; } - if (pRead->capacity < pRead->pHead->head.bodyLen) { - void *ptr = taosMemoryRealloc(pRead->pHead, sizeof(SWalCkHead) + pRead->pHead->head.bodyLen); + if (pReader->capacity < pReader->pHead->head.bodyLen) { + void *ptr = taosMemoryRealloc(pReader->pHead, sizeof(SWalCkHead) + pReader->pHead->head.bodyLen); if (ptr == NULL) { terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; return -1; } - pRead->pHead = ptr; - pRead->capacity = pRead->pHead->head.bodyLen; + pReader->pHead = ptr; + pReader->capacity = pReader->pHead->head.bodyLen; } - if ((contLen = taosReadFile(pRead->pLogFile, pRead->pHead->head.body, pRead->pHead->head.bodyLen)) != - pRead->pHead->head.bodyLen) { + if ((contLen = taosReadFile(pReader->pLogFile, pReader->pHead->head.body, pReader->pHead->head.bodyLen)) != + pReader->pHead->head.bodyLen) { if (contLen < 0) terrno = TAOS_SYSTEM_ERROR(errno); else { @@ -496,25 +497,28 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) { return -1; } - if (pRead->pHead->head.version != ver) { - wError("vgId:%d, unexpected wal log, index:%" PRId64 ", read request index:%" PRId64, pRead->pWal->cfg.vgId, - pRead->pHead->head.version, ver); - pRead->curInvalid = 1; + if (pReader->pHead->head.version != ver) { + wError("vgId:%d, unexpected wal log, index:%" PRId64 ", read request index:%" PRId64, pReader->pWal->cfg.vgId, + pReader->pHead->head.version, ver); + pReader->curInvalid = 1; terrno = TSDB_CODE_WAL_FILE_CORRUPTED; ASSERT(0); return -1; } - contLen = walValidBodyCksum(pRead->pHead); - if (contLen != 0) { - wError("vgId:%d, unexpected wal log, index:%" PRId64 ", since body checksum not passed", pRead->pWal->cfg.vgId, + code = walValidBodyCksum(pReader->pHead); + if (code != 0) { + wError("vgId:%d, unexpected wal log, index:%" PRId64 ", since body checksum not passed", pReader->pWal->cfg.vgId, ver); - pRead->curInvalid = 1; + uint32_t readCkSum = walCalcBodyCksum(pReader->pHead->head.body, pReader->pHead->head.bodyLen); + uint32_t logCkSum = pReader->pHead->cksumBody; + wError("checksum written into log: %u, checksum calculated: %u", logCkSum, readCkSum); + pReader->curInvalid = 1; terrno = TSDB_CODE_WAL_FILE_CORRUPTED; ASSERT(0); return -1; } - pRead->curVersion++; + pReader->curVersion++; return 0; } diff --git a/source/libs/wal/src/walSeek.c b/source/libs/wal/src/walSeek.c index 78d45c84e2699770bb3453521c72c0d9dfbc6ac9..87ab155065021cb902739ef18c8925afc04c2f07 100644 --- a/source/libs/wal/src/walSeek.c +++ b/source/libs/wal/src/walSeek.c @@ -22,8 +22,8 @@ static int64_t walSeekWritePos(SWal* pWal, int64_t ver) { int64_t code = 0; - TdFilePtr pIdxTFile = pWal->pWriteIdxTFile; - TdFilePtr pLogTFile = pWal->pWriteLogTFile; + TdFilePtr pIdxTFile = pWal->pIdxFile; + TdFilePtr pLogTFile = pWal->pLogFile; // seek position int64_t idxOff = walGetVerIdxOffset(pWal, ver); @@ -68,8 +68,8 @@ int walInitWriteFile(SWal* pWal) { return -1; } // switch file - pWal->pWriteIdxTFile = pIdxTFile; - pWal->pWriteLogTFile = pLogTFile; + pWal->pIdxFile = pIdxTFile; + pWal->pLogFile = pLogTFile; pWal->writeCur = taosArrayGetSize(pWal->fileInfoSet) - 1; return 0; } @@ -78,15 +78,15 @@ int walChangeWrite(SWal* pWal, int64_t ver) { int code; TdFilePtr pIdxTFile, pLogTFile; char fnameStr[WAL_FILE_LEN]; - if (pWal->pWriteLogTFile != NULL) { - code = taosCloseFile(&pWal->pWriteLogTFile); + if (pWal->pLogFile != NULL) { + code = taosCloseFile(&pWal->pLogFile); if (code != 0) { terrno = TAOS_SYSTEM_ERROR(errno); return -1; } } - if (pWal->pWriteIdxTFile != NULL) { - code = taosCloseFile(&pWal->pWriteIdxTFile); + if (pWal->pIdxFile != NULL) { + code = taosCloseFile(&pWal->pIdxFile); if (code != 0) { terrno = TAOS_SYSTEM_ERROR(errno); return -1; @@ -106,7 +106,7 @@ int walChangeWrite(SWal* pWal, int64_t ver) { pIdxTFile = taosOpenFile(fnameStr, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND); if (pIdxTFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); - pWal->pWriteIdxTFile = NULL; + pWal->pIdxFile = NULL; return -1; } walBuildLogName(pWal, fileFirstVer, fnameStr); @@ -114,12 +114,12 @@ int walChangeWrite(SWal* pWal, int64_t ver) { if (pLogTFile == NULL) { taosCloseFile(&pIdxTFile); terrno = TAOS_SYSTEM_ERROR(errno); - pWal->pWriteLogTFile = NULL; + pWal->pLogFile = NULL; return -1; } - pWal->pWriteLogTFile = pLogTFile; - pWal->pWriteIdxTFile = pIdxTFile; + pWal->pLogFile = pLogTFile; + pWal->pIdxFile = pIdxTFile; pWal->writeCur = idx; return fileFirstVer; } diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index 81500d80882f930e253771b835ac0f9e63f0f57b..4eadc92f705da24df20555ffef1bf82d7fca9858 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -32,8 +32,8 @@ int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) { } } - taosCloseFile(&pWal->pWriteLogTFile); - taosCloseFile(&pWal->pWriteIdxTFile); + taosCloseFile(&pWal->pLogFile); + taosCloseFile(&pWal->pIdxFile); if (pWal->vers.firstVer != -1) { int32_t fileSetSize = taosArrayGetSize(pWal->fileInfoSet); @@ -261,14 +261,13 @@ int32_t walEndSnapshot(SWal *pWal) { pWal->vers.snapshotVer = ver; int ts = taosGetTimestampSec(); - int64_t minVerToDelete = ver; - void *pIter = NULL; + void *pIter = NULL; while (1) { pIter = taosHashIterate(pWal->pRefHash, pIter); if (pIter == NULL) break; SWalRef *pRef = *(SWalRef **)pIter; if (pRef->refVer == -1) continue; - minVerToDelete = TMIN(minVerToDelete, pRef->refVer); + ver = TMIN(ver, pRef->refVer); } int deleteCnt = 0; @@ -277,35 +276,44 @@ int32_t walEndSnapshot(SWal *pWal) { tmp.firstVer = ver; // find files safe to delete SWalFileInfo *pInfo = taosArraySearch(pWal->fileInfoSet, &tmp, compareWalFileInfo, TD_LE); - if (ver >= pInfo->lastVer) { - pInfo++; - } - // iterate files, until the searched result - for (SWalFileInfo *iter = pWal->fileInfoSet->pData; iter < pInfo; iter++) { - if ((pWal->cfg.retentionSize != -1 && newTotSize > pWal->cfg.retentionSize) || - (pWal->cfg.retentionPeriod != -1 && iter->closeTs + pWal->cfg.retentionPeriod > ts)) { - // delete according to file size or close time - deleteCnt++; - newTotSize -= iter->fileSize; + if (pInfo) { + if (ver >= pInfo->lastVer) { + pInfo++; + } + // iterate files, until the searched result + for (SWalFileInfo *iter = pWal->fileInfoSet->pData; iter < pInfo; iter++) { + if ((pWal->cfg.retentionSize != -1 && newTotSize > pWal->cfg.retentionSize) || + (pWal->cfg.retentionPeriod != -1 && iter->closeTs + pWal->cfg.retentionPeriod > ts)) { + // delete according to file size or close time + deleteCnt++; + newTotSize -= iter->fileSize; + } + } + int32_t actualDelete = 0; + char fnameStr[WAL_FILE_LEN]; + // remove file + for (int i = 0; i < deleteCnt; i++) { + pInfo = taosArrayGet(pWal->fileInfoSet, i); + walBuildLogName(pWal, pInfo->firstVer, fnameStr); + if (taosRemoveFile(fnameStr) < 0) { + goto UPDATE_META; + } + walBuildIdxName(pWal, pInfo->firstVer, fnameStr); + if (taosRemoveFile(fnameStr) < 0) { + ASSERT(0); + } + actualDelete++; } - } - char fnameStr[WAL_FILE_LEN]; - // remove file - for (int i = 0; i < deleteCnt; i++) { - pInfo = taosArrayGet(pWal->fileInfoSet, i); - walBuildLogName(pWal, pInfo->firstVer, fnameStr); - taosRemoveFile(fnameStr); - walBuildIdxName(pWal, pInfo->firstVer, fnameStr); - taosRemoveFile(fnameStr); - } - // make new array, remove files - taosArrayPopFrontBatch(pWal->fileInfoSet, deleteCnt); - if (taosArrayGetSize(pWal->fileInfoSet) == 0) { - pWal->writeCur = -1; - pWal->vers.firstVer = -1; - } else { - pWal->vers.firstVer = ((SWalFileInfo *)taosArrayGet(pWal->fileInfoSet, 0))->firstVer; + UPDATE_META: + // make new array, remove files + taosArrayPopFrontBatch(pWal->fileInfoSet, actualDelete); + if (taosArrayGetSize(pWal->fileInfoSet) == 0) { + pWal->writeCur = -1; + pWal->vers.firstVer = -1; + } else { + pWal->vers.firstVer = ((SWalFileInfo *)taosArrayGet(pWal->fileInfoSet, 0))->firstVer; + } } pWal->writeCur = taosArrayGetSize(pWal->fileInfoSet) - 1; pWal->totSize = newTotSize; @@ -324,34 +332,34 @@ END: int32_t walRollImpl(SWal *pWal) { int32_t code = 0; - if (pWal->pWriteIdxTFile != NULL) { - code = taosCloseFile(&pWal->pWriteIdxTFile); + if (pWal->pIdxFile != NULL) { + code = taosCloseFile(&pWal->pIdxFile); if (code != 0) { terrno = TAOS_SYSTEM_ERROR(errno); goto END; } } - if (pWal->pWriteLogTFile != NULL) { - code = taosCloseFile(&pWal->pWriteLogTFile); + if (pWal->pLogFile != NULL) { + code = taosCloseFile(&pWal->pLogFile); if (code != 0) { terrno = TAOS_SYSTEM_ERROR(errno); goto END; } } - TdFilePtr pIdxTFile, pLogTFile; + TdFilePtr pIdxFile, pLogFile; // create new file - int64_t newFileFirstVersion = pWal->vers.lastVer + 1; + int64_t newFileFirstVer = pWal->vers.lastVer + 1; char fnameStr[WAL_FILE_LEN]; - walBuildIdxName(pWal, newFileFirstVersion, fnameStr); - pIdxTFile = taosOpenFile(fnameStr, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND); - if (pIdxTFile == NULL) { + walBuildIdxName(pWal, newFileFirstVer, fnameStr); + pIdxFile = taosOpenFile(fnameStr, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND); + if (pIdxFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); code = -1; goto END; } - walBuildLogName(pWal, newFileFirstVersion, fnameStr); - pLogTFile = taosOpenFile(fnameStr, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND); - if (pLogTFile == NULL) { + walBuildLogName(pWal, newFileFirstVer, fnameStr); + pLogFile = taosOpenFile(fnameStr, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND); + if (pLogFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); code = -1; goto END; @@ -363,8 +371,8 @@ int32_t walRollImpl(SWal *pWal) { } // switch file - pWal->pWriteIdxTFile = pIdxTFile; - pWal->pWriteLogTFile = pLogTFile; + pWal->pIdxFile = pIdxFile; + pWal->pLogFile = pLogFile; pWal->writeCur = taosArrayGetSize(pWal->fileInfoSet) - 1; ASSERT(pWal->writeCur >= 0); @@ -378,10 +386,10 @@ END: static int32_t walWriteIndex(SWal *pWal, int64_t ver, int64_t offset) { SWalIdxEntry entry = {.ver = ver, .offset = offset}; - int64_t idxOffset = taosLSeekFile(pWal->pWriteIdxTFile, 0, SEEK_END); + int64_t idxOffset = taosLSeekFile(pWal->pIdxFile, 0, SEEK_END); wDebug("vgId:%d, write index, index:%" PRId64 ", offset:%" PRId64 ", at %" PRId64, pWal->cfg.vgId, ver, offset, idxOffset); - int64_t size = taosWriteFile(pWal->pWriteIdxTFile, &entry, sizeof(SWalIdxEntry)); + int64_t size = taosWriteFile(pWal->pIdxFile, &entry, sizeof(SWalIdxEntry)); if (size != sizeof(SWalIdxEntry)) { terrno = TAOS_SYSTEM_ERROR(errno); // TODO truncate @@ -400,6 +408,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy pWal->writeHead.head.version = index; pWal->writeHead.head.bodyLen = bodyLen; pWal->writeHead.head.msgType = msgType; + pWal->writeHead.head.ingestTs = taosGetTimestampMs(); // sync info for sync module pWal->writeHead.head.syncMeta = syncMeta; @@ -407,7 +416,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy pWal->writeHead.cksumHead = walCalcHeadCksum(&pWal->writeHead); pWal->writeHead.cksumBody = walCalcBodyCksum(body, bodyLen); - if (taosWriteFile(pWal->pWriteLogTFile, &pWal->writeHead, sizeof(SWalCkHead)) != sizeof(SWalCkHead)) { + if (taosWriteFile(pWal->pLogFile, &pWal->writeHead, sizeof(SWalCkHead)) != sizeof(SWalCkHead)) { // TODO ftruncate terrno = TAOS_SYSTEM_ERROR(errno); wError("vgId:%d, file:%" PRId64 ".log, failed to write since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal), @@ -416,7 +425,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy goto END; } - if (taosWriteFile(pWal->pWriteLogTFile, (char *)body, bodyLen) != bodyLen) { + if (taosWriteFile(pWal->pLogFile, (char *)body, bodyLen) != bodyLen) { // TODO ftruncate terrno = TAOS_SYSTEM_ERROR(errno); wError("vgId:%d, file:%" PRId64 ".log, failed to write since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal), @@ -456,14 +465,14 @@ int64_t walAppendLog(SWal *pWal, tmsg_t msgType, SWalSyncInfo syncMeta, const vo return -1; } - if (pWal->pWriteIdxTFile == NULL || pWal->pWriteIdxTFile == NULL || pWal->writeCur < 0) { + if (pWal->pLogFile == NULL || pWal->pIdxFile == NULL || pWal->writeCur < 0) { if (walInitWriteFile(pWal) < 0) { taosThreadMutexUnlock(&pWal->mutex); return -1; } } - ASSERT(pWal->pWriteIdxTFile != NULL && pWal->pWriteLogTFile != NULL && pWal->writeCur >= 0); + ASSERT(pWal->pLogFile != NULL && pWal->pIdxFile != NULL && pWal->writeCur >= 0); if (walWriteImpl(pWal, index, msgType, syncMeta, body, bodyLen) < 0) { taosThreadMutexUnlock(&pWal->mutex); @@ -494,14 +503,14 @@ int32_t walWriteWithSyncInfo(SWal *pWal, int64_t index, tmsg_t msgType, SWalSync return -1; } - if (pWal->pWriteIdxTFile == NULL || pWal->pWriteIdxTFile == NULL || pWal->writeCur < 0) { + if (pWal->pIdxFile == NULL || pWal->pIdxFile == NULL || pWal->writeCur < 0) { if (walInitWriteFile(pWal) < 0) { taosThreadMutexUnlock(&pWal->mutex); return -1; } } - ASSERT(pWal->pWriteIdxTFile != NULL && pWal->pWriteLogTFile != NULL && pWal->writeCur >= 0); + ASSERT(pWal->pIdxFile != NULL && pWal->pLogFile != NULL && pWal->writeCur >= 0); if (walWriteImpl(pWal, index, msgType, syncMeta, body, bodyLen) < 0) { taosThreadMutexUnlock(&pWal->mutex); @@ -524,7 +533,7 @@ int32_t walWrite(SWal *pWal, int64_t index, tmsg_t msgType, const void *body, in void walFsync(SWal *pWal, bool forceFsync) { if (forceFsync || (pWal->cfg.level == TAOS_WAL_FSYNC && pWal->cfg.fsyncPeriod == 0)) { wTrace("vgId:%d, fileId:%" PRId64 ".log, do fsync", pWal->cfg.vgId, walGetCurFileFirstVer(pWal)); - if (taosFsyncFile(pWal->pWriteLogTFile) < 0) { + if (taosFsyncFile(pWal->pLogFile) < 0) { wError("vgId:%d, file:%" PRId64 ".log, fsync failed since %s", pWal->cfg.vgId, walGetCurFileFirstVer(pWal), strerror(errno)); } diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c index 8450e8baea60bca7d1ca2f5d5dde1f1fc1953629..fa94bc6a13d289349f687fd214247151c6a2d6c9 100644 --- a/source/os/src/osSysinfo.c +++ b/source/os/src/osSysinfo.c @@ -374,9 +374,10 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) { size_t size = 0; int32_t done = 0; int32_t code = -1; + float coreCount = 0; TdFilePtr pFile = taosOpenFile("/proc/cpuinfo", TD_FILE_READ | TD_FILE_STREAM); - if (pFile == NULL) return false; + if (pFile == NULL) return code; while (done != 3 && (size = taosGetLineFile(pFile, &line)) != -1) { line[size - 1] = '\0'; @@ -390,11 +391,26 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) { *numOfCores = atof(v); done |= 2; } + if (strncmp(line, "processor", 9) == 0) coreCount += 1; } if (line != NULL) taosMemoryFree(line); taosCloseFile(&pFile); + if (code != 0) { + TdFilePtr pFile1 = taosOpenFile("/proc/device-tree/model", TD_FILE_READ | TD_FILE_STREAM); + if (pFile1 == NULL) return code; + taosGetsFile(pFile1, maxLen, cpuModel); + taosCloseFile(&pFile1); + code = 0; + done |= 1; + } + + if ((done & 2) == 0) { + *numOfCores = coreCount; + done |= 2; + } + return code; #endif } diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index 6095b67588c7794418b4e8ed3d73c945ccf89eea..3c4a0a20bdc4f43b14a4f6d476141cb7416db0e6 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -294,7 +294,7 @@ void taosArraySet(SArray* pArray, size_t index, void* pData) { void taosArrayPopFrontBatch(SArray* pArray, size_t cnt) { assert(cnt <= pArray->size); pArray->size = pArray->size - cnt; - if (pArray->size == 0) { + if (pArray->size == 0 || cnt == 0) { return; } memmove(pArray->pData, (char*)pArray->pData + cnt * pArray->elemSize, pArray->size * pArray->elemSize); diff --git a/source/util/src/tcache.c b/source/util/src/tcache.c index 0975b10d5555a2bd13c96f3d4b2dde4a58bd74e3..7cbc1cd5557714ec07831f5587828bb40b568168 100644 --- a/source/util/src/tcache.c +++ b/source/util/src/tcache.c @@ -266,6 +266,7 @@ static void pushfrontNodeInEntryList(SCacheEntry *pEntry, SCacheNode *pNode) { pNode->pNext = pEntry->next; pEntry->next = pNode; pEntry->num += 1; + ASSERT((pEntry->next && pEntry->num > 0) || (NULL == pEntry->next && pEntry->num == 0)); } static void removeNodeInEntryList(SCacheEntry *pe, SCacheNode *prev, SCacheNode *pNode) { @@ -278,6 +279,7 @@ static void removeNodeInEntryList(SCacheEntry *pe, SCacheNode *prev, SCacheNode pNode->pNext = NULL; pe->num -= 1; + ASSERT((pe->next && pe->num > 0) || (NULL == pe->next && pe->num == 0)); } static FORCE_INLINE SCacheEntry *doFindEntry(SCacheObj *pCacheObj, const void *key, size_t keyLen) { @@ -657,15 +659,18 @@ void doTraverseElems(SCacheObj *pCacheObj, bool (*fp)(void *param, SCacheNode *p taosWLockLatch(&pEntry->latch); + SCacheNode **pPre = &pEntry->next; SCacheNode *pNode = pEntry->next; while (pNode != NULL) { SCacheNode *next = pNode->pNext; if (fp(pSup, pNode)) { + pPre = &pNode->pNext; pNode = pNode->pNext; } else { - pEntry->next = next; + *pPre = next; pEntry->num -= 1; + ASSERT((pEntry->next && pEntry->num > 0) || (NULL == pEntry->next && pEntry->num == 0)); atomic_sub_fetch_ptr(&pCacheObj->numOfElems, 1); pNode = next; diff --git a/source/util/src/terror.c b/source/util/src/terror.c index ad6eff3c122af7b831ecb3b15157bff54dadc41c..f8d8e9d168af8c9b19b7973a278adeb9034c07e4 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -195,8 +195,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_PASS_FORMAT, "Invalid password form TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_USER_FROM_CONN, "Can not get user from conn") TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_USERS, "Too many users") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_ALTER_OPER, "Invalid alter operation") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_AUTH_FAILURE, "Authentication failure") -// mnode-stable-part1 +//mnode-stable-part1 TAOS_DEFINE_ERROR(TSDB_CODE_MND_STB_ALREADY_EXIST, "STable already exists") TAOS_DEFINE_ERROR(TSDB_CODE_MND_STB_NOT_EXIST, "STable not exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_TAGS, "Too many tags") @@ -516,7 +517,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL, "sliding value can no TAOS_DEFINE_ERROR(TSDB_CODE_PAR_ONLY_ONE_JSON_TAG, "Only one tag if there is a json tag") 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_INVALID_DAYS_VALUE, "Invalid days value, should be keep2 >= keep1 >= keep0 >= days") 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_INVALID_TOPIC_QUERY, "Invalid topic query") diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index a71a75eac5844227d6249f0df2dc03d159a482e2..0eb7737e8ee952b8d5ed6d8966e00466bb07d1db 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -16,8 +16,8 @@ #define _DEFAULT_SOURCE #include "tlog.h" #include "os.h" -#include "tutil.h" #include "tconfig.h" +#include "tutil.h" #define LOG_MAX_LINE_SIZE (1024) #define LOG_MAX_LINE_BUFFER_SIZE (LOG_MAX_LINE_SIZE + 3) @@ -40,7 +40,7 @@ #define LOG_BUF_MUTEX(x) ((x)->buffMutex) typedef struct { - char * buffer; + char *buffer; int32_t buffStart; int32_t buffEnd; int32_t buffSize; @@ -59,15 +59,15 @@ typedef struct { int32_t openInProgress; pid_t pid; char logName[LOG_FILE_NAME_LEN]; - SLogBuff * logHandle; + SLogBuff *logHandle; TdThreadMutex logMutex; } SLogObj; extern SConfig *tsCfg; -static int8_t tsLogInited = 0; -static SLogObj tsLogObj = {.fileNum = 1}; -static int64_t tsAsyncLogLostLines = 0; -static int32_t tsWriteInterval = LOG_DEFAULT_INTERVAL; +static int8_t tsLogInited = 0; +static SLogObj tsLogObj = {.fileNum = 1}; +static int64_t tsAsyncLogLostLines = 0; +static int32_t tsWriteInterval = LOG_DEFAULT_INTERVAL; bool tsLogEmbedded = 0; bool tsAsyncLog = true; @@ -106,7 +106,7 @@ int64_t dbgSmallWN = 0; int64_t dbgBigWN = 0; int64_t dbgWSize = 0; -static void * taosAsyncOutputLog(void *param); +static void *taosAsyncOutputLog(void *param); static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msgLen); static SLogBuff *taosLogBuffNew(int32_t bufSize); static void taosCloseLogByFd(TdFilePtr pFile); @@ -128,7 +128,11 @@ int32_t taosInitLog(const char *logName, int32_t maxFiles) { osUpdate(); char fullName[PATH_MAX] = {0}; - snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logName); + if (strlen(tsLogDir) != 0) { + snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logName); + } else { + snprintf(fullName, PATH_MAX, "%s", logName); + } tsLogObj.logHandle = taosLogBuffNew(LOG_DEFAULT_BUF_SIZE); if (tsLogObj.logHandle == NULL) return -1; @@ -704,7 +708,7 @@ int32_t taosCompressFile(char *srcFileName, char *destFileName) { int32_t compressSize = 163840; int32_t ret = 0; int32_t len = 0; - char * data = taosMemoryMalloc(compressSize); + char *data = taosMemoryMalloc(compressSize); // gzFile dstFp = NULL; // srcFp = fopen(srcFileName, "r"); diff --git a/tests/pytest/alter/alter_create_exception.py b/tests/pytest/alter/alter_create_exception.py index 19f1ba9464617fe120740ec26a411a216cfd9a48..d8400c1fa941238f750755883c7e007301064839 100644 --- a/tests/pytest/alter/alter_create_exception.py +++ b/tests/pytest/alter/alter_create_exception.py @@ -47,16 +47,16 @@ class TDTestCase: tdSql.error('create database db comp "1.4"') tdSql.error("create database db blocks '10'") tdSql.error('create database db keep "3650"') - tdSql.error('create database db fsync "3650"') + tdSql.error('create database db wal_fsync_period "3650"') tdSql.execute('create database db precision "us"') tdSql.query('show databases') tdSql.checkData(0,16,'us') tdSql.execute('drop database if exists db') #checking float input exception for create - tdSql.error("create database db fsync 7.3") - tdSql.error("create database db fsync 0.0") - tdSql.error("create database db fsync -5.32") + tdSql.error("create database db wal_fsync_period 7.3") + tdSql.error("create database db wal_fsync_period 0.0") + tdSql.error("create database db wal_fsync_period -5.32") tdSql.error('create database db comp 7.2') tdSql.error("create database db blocks 5.87") tdSql.error('create database db keep 15.4') diff --git a/tests/pytest/crash_gen/crash_gen_main.py b/tests/pytest/crash_gen/crash_gen_main.py index d5ffc1b7c1db1b86d238dffb1eb3b78724892ffe..7ab09383bfd0791aad30b39fa7e65ed66df9d936 100755 --- a/tests/pytest/crash_gen/crash_gen_main.py +++ b/tests/pytest/crash_gen/crash_gen_main.py @@ -371,7 +371,9 @@ class ThreadCoordinator: if isinstance(err, CrashGenError): # our own transition failure Logging.info("State transition error") # TODO: saw an error here once, let's print out stack info for err? - traceback.print_stack() + traceback.print_stack() # Stack frame to here. + Logging.info("Caused by:") + traceback.print_exception(*sys.exc_info()) # Ref: https://www.geeksforgeeks.org/how-to-print-exception-stack-trace-in-python/ transitionFailed = True self._te = None # Not running any more self._execStats.registerFailure("State transition error: {}".format(err)) @@ -741,7 +743,8 @@ class AnyState: sCnt += 1 if (sCnt >= 2): raise CrashGenError( - "Unexpected more than 1 success with task: {}, in task set: {}".format( + "Unexpected more than 1 success at state: {}, with task: {}, in task set: {}".format( + self.__class__.__name__, cls.__name__, # verified just now that isinstance(task, cls) [c.__class__.__name__ for c in tasks] )) @@ -756,8 +759,11 @@ class AnyState: if task.isSuccess(): sCnt += 1 if (exists and sCnt <= 0): - raise CrashGenError("Unexpected zero success for task type: {}, from tasks: {}" - .format(cls, tasks)) + raise CrashGenError("Unexpected zero success at state: {}, with task: {}, in task set: {}".format( + self.__class__.__name__, + cls.__name__, # verified just now that isinstance(task, cls) + [c.__class__.__name__ for c in tasks] + )) def assertNoTask(self, tasks, cls): for task in tasks: @@ -809,8 +815,6 @@ class StateEmpty(AnyState): ] def verifyTasksToState(self, tasks, newState): - if Config.getConfig().ignore_errors: # if we are asked to ignore certain errors, let's not verify CreateDB success. - return if (self.hasSuccess(tasks, TaskCreateDb) ): # at EMPTY, if there's succes in creating DB if (not self.hasTask(tasks, TaskDropDb)): # and no drop_db tasks @@ -995,16 +999,17 @@ class StateMechine: dbc.execute("show dnodes") # Generic Checks, first based on the start state - if self._curState.canCreateDb(): - self._curState.assertIfExistThenSuccess(tasks, TaskCreateDb) - # self.assertAtMostOneSuccess(tasks, CreateDbTask) # not really, in - # case of multiple creation and drops - - if self._curState.canDropDb(): - if gSvcMgr == None: # only if we are running as client-only - self._curState.assertIfExistThenSuccess(tasks, TaskDropDb) - # self.assertAtMostOneSuccess(tasks, DropDbTask) # not really in - # case of drop-create-drop + if not Config.getConfig().ignore_errors: # verify state, only if we are asked not to ignore certain errors. + if self._curState.canCreateDb(): + self._curState.assertIfExistThenSuccess(tasks, TaskCreateDb) + # self.assertAtMostOneSuccess(tasks, CreateDbTask) # not really, in + # case of multiple creation and drops + + if self._curState.canDropDb(): + if gSvcMgr == None: # only if we are running as client-only + self._curState.assertIfExistThenSuccess(tasks, TaskDropDb) + # self.assertAtMostOneSuccess(tasks, DropDbTask) # not really in + # case of drop-create-drop # if self._state.canCreateFixedTable(): # self.assertIfExistThenSuccess(tasks, CreateFixedTableTask) # Not true, DB may be dropped @@ -1026,7 +1031,8 @@ class StateMechine: newState = self._findCurrentState(dbc) Logging.debug("[STT] New DB state determined: {}".format(newState)) # can old state move to new state through the tasks? - self._curState.verifyTasksToState(tasks, newState) + if not Config.getConfig().ignore_errors: # verify state, only if we are asked not to ignore certain errors. + self._curState.verifyTasksToState(tasks, newState) self._curState = newState def pickTaskType(self): @@ -2231,16 +2237,14 @@ class TaskAddData(StateTransitionTask): class ThreadStacks: # stack info for all threads def __init__(self): self._allStacks = {} - allFrames = sys._current_frames() # All current stack frames + allFrames = sys._current_frames() # All current stack frames, keyed with "ident" for th in threading.enumerate(): # For each thread - if th.ident is None: - continue - stack = traceback.extract_stack(allFrames[th.ident]) # Get stack for a thread - shortTid = th.ident % 10000 + stack = traceback.extract_stack(allFrames[th.ident]) #type: ignore # Get stack for a thread + shortTid = th.native_id % 10000 #type: ignore self._allStacks[shortTid] = stack # Was using th.native_id def print(self, filteredEndName = None, filterInternal = False): - for tIdent, stack in self._allStacks.items(): # for each thread, stack frames top to bottom + for shortTid, stack in self._allStacks.items(): # for each thread, stack frames top to bottom lastFrame = stack[-1] if filteredEndName: # we need to filter out stacks that match this name if lastFrame.name == filteredEndName : # end did not match @@ -2252,7 +2256,9 @@ class ThreadStacks: # stack info for all threads '__init__']: # the thread that extracted the stack continue # ignore # Now print - print("\n<----- Thread Info for LWP/ID: {} (most recent call last) <-----".format(tIdent)) + print("\n<----- Thread Info for LWP/ID: {} (most recent call last) <-----".format(shortTid)) + lastSqlForThread = DbConn.fetchSqlForThread(shortTid) + print("Last SQL statement attempted from thread {} is: {}".format(shortTid, lastSqlForThread)) stackFrame = 0 for frame in stack: # was using: reversed(stack) # print(frame) diff --git a/tests/pytest/crash_gen/shared/db.py b/tests/pytest/crash_gen/shared/db.py index 75931ace48ed65708c7dfa97d01a426a0baa8203..6da0216d95cefe17512be8f119888bab1d14b7e8 100644 --- a/tests/pytest/crash_gen/shared/db.py +++ b/tests/pytest/crash_gen/shared/db.py @@ -27,6 +27,26 @@ class DbConn: TYPE_REST = "rest-api" TYPE_INVALID = "invalid" + # class variables + lastSqlFromThreads : dict[int, str] = {} # stored by thread id, obtained from threading.current_thread().ident%10000 + + @classmethod + def saveSqlForCurrentThread(cls, sql: str): + ''' + Let us save the last SQL statement on a per-thread basis, so that when later we + run into a dead-lock situation, we can pick out the deadlocked thread, and use + that information to find what what SQL statement is stuck. + ''' + th = threading.current_thread() + shortTid = th.native_id % 10000 #type: ignore + cls.lastSqlFromThreads[shortTid] = sql # Save this for later + + @classmethod + def fetchSqlForThread(cls, shortTid : int) -> str : + if shortTid not in cls.lastSqlFromThreads: + raise CrashGenError("No last-attempted-SQL found for thread id: {}".format(shortTid)) + return cls.lastSqlFromThreads[shortTid] + @classmethod def create(cls, connType, dbTarget): if connType == cls.TYPE_NATIVE: @@ -163,6 +183,7 @@ class DbConnRest(DbConn): def _doSql(self, sql): self._lastSql = sql # remember this, last SQL attempted + self.saveSqlForCurrentThread(sql) # Save in global structure too. #TODO: combine with above try: r = requests.post(self._url, data = sql, @@ -392,6 +413,7 @@ class DbConnNative(DbConn): "Cannot exec SQL unless db connection is open", CrashGenError.DB_CONNECTION_NOT_OPEN) Logging.debug("[SQL] Executing SQL: {}".format(sql)) self._lastSql = sql + self.saveSqlForCurrentThread(sql) # Save in global structure too. #TODO: combine with above nRows = self._tdSql.execute(sql) cls = self.__class__ cls.totalRequests += 1 @@ -407,6 +429,7 @@ class DbConnNative(DbConn): "Cannot query database until connection is open, restarting?", CrashGenError.DB_CONNECTION_NOT_OPEN) Logging.debug("[SQL] Executing SQL: {}".format(sql)) self._lastSql = sql + self.saveSqlForCurrentThread(sql) # Save in global structure too. #TODO: combine with above nRows = self._tdSql.query(sql) cls = self.__class__ cls.totalRequests += 1 diff --git a/tests/pytest/perfbenchmark/bug3433.py b/tests/pytest/perfbenchmark/bug3433.py index d688dd03106d6ee2b50213d0b3e610dceb7ca1df..7f2dfad40338e0fd710e908e8ccce940c128d4dc 100644 --- a/tests/pytest/perfbenchmark/bug3433.py +++ b/tests/pytest/perfbenchmark/bug3433.py @@ -77,7 +77,7 @@ class TDTestCase: "walLevel": 1, "cachelast": 0, "quorum": 1, - "fsync": 3000, + "wal_fsync_period": 3000, "update": 0 } diff --git a/tests/pytest/perfbenchmark/joinPerformance.py b/tests/pytest/perfbenchmark/joinPerformance.py index 2de5818c59c10038e7af7a9d68588bf55823127f..b85c09926a5c93dae1edca645e02ae223569a933 100644 --- a/tests/pytest/perfbenchmark/joinPerformance.py +++ b/tests/pytest/perfbenchmark/joinPerformance.py @@ -92,7 +92,7 @@ class JoinPerf: "walLevel": 1, "cachelast": 0, "quorum": 1, - "fsync": 3000, + "wal_fsync_period": 3000, "update": 0 } diff --git a/tests/pytest/perfbenchmark/taosdemoInsert.py b/tests/pytest/perfbenchmark/taosdemoInsert.py index 37191b2624acf7003917b588ac18acef42ada039..774103aa853183b923edc0a4157f650a08d1eb76 100644 --- a/tests/pytest/perfbenchmark/taosdemoInsert.py +++ b/tests/pytest/perfbenchmark/taosdemoInsert.py @@ -86,7 +86,7 @@ class Taosdemo: "walLevel": 1, "cachelast": 0, "quorum": 1, - "fsync": 3000, + "wal_fsync_period": 3000, "update": 0 } diff --git a/tests/pytest/query/query1970YearsAf.py b/tests/pytest/query/query1970YearsAf.py index c78324ff5c8a97d20304f8f23e7c534c54f7b6f6..6a5c0796ed1eb766519f4ff0f31d9b7c94f4a49a 100644 --- a/tests/pytest/query/query1970YearsAf.py +++ b/tests/pytest/query/query1970YearsAf.py @@ -68,7 +68,7 @@ class TDTestCase: "walLevel": 1, "cachelast": 0, "quorum": 1, - "fsync": 3000, + "wal_fsync_period": 3000, "update": 0 } diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index 9b72312028aaffaa2c25092e6e82f057a297c9ea..6384195a1b89deba2c93876572ea11fd093e500c 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -18,7 +18,7 @@ import time import socket import json import toml -from .boundary import DataBoundary +from util.boundary import DataBoundary import taos from util.log import * from util.sql import * @@ -80,23 +80,18 @@ class DataSet: self.bool_data.append( bool((i + bool_start) % 2 )) self.vchar_data.append( f"{vchar_prefix}_{i * vchar_step}" ) self.nchar_data.append( f"{nchar_prefix}_{i * nchar_step}") - self.ts_data.append( int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000 - i * ts_step)) - - def get_disorder_set(self, - rows, - int_low :int = INT_MIN, - int_up :int = INT_MAX, - bint_low :int = BIGINT_MIN, - bint_up :int = BIGINT_MAX, - sint_low :int = SMALLINT_MIN, - sint_up :int = SMALLINT_MAX, - tint_low :int = TINYINT_MIN, - tint_up :int = TINYINT_MAX, - ubint_low :int = BIGINT_UN_MIN, - ubint_up :int = BIGINT_UN_MAX, - - - ): + self.ts_data.append( int(datetime.timestamp(datetime.now()) * 1000 - i * ts_step)) + + def get_disorder_set(self, rows, **kwargs): + for k, v in kwargs.items(): + int_low = v if k == "int_low" else INT_MIN + int_up = v if k == "int_up" else INT_MAX + bint_low = v if k == "bint_low" else BIGINT_MIN + bint_up = v if k == "bint_up" else BIGINT_MAX + sint_low = v if k == "sint_low" else SMALLINT_MIN + sint_up = v if k == "sint_up" else SMALLINT_MAX + tint_low = v if k == "tint_low" else TINYINT_MIN + tint_up = v if k == "tint_up" else TINYINT_MAX pass diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 59e247105ce20e130c17da4bda1888d3b806b640..20e4e4abe63059350f1f378362667c6d9f1df3be 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -518,7 +518,7 @@ class TDDnode: if self.running != 0: if platform.system().lower() == 'windows': - psCmd = "for /f %%a in ('wmic process where \"name='taosd.exe' and CommandLine like '%%dnode%d%%'\" get processId ^| xargs echo ^| awk ^'{print $2}^'') do @(ps | grep %%a | awk '{print $1}' | xargs kill -INT )" % (self.index) + psCmd = "for /f %%a in ('wmic process where \"name='taosd.exe' and CommandLine like '%%dnode%d%%'\" get processId ^| xargs echo ^| awk ^'{print $2}^' ^&^& echo aa') do @(ps | grep %%a | awk '{print $1}' )" % (self.index) else: psCmd = "ps -ef|grep -w %s| grep dnode%d|grep -v grep | awk '{print $2}'" % (toBeKilled,self.index) processID = subprocess.check_output( diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index 01955ec93ae05e03c8835fd766f7ceaf0eb2fde3..b9177d22699d8ef4b36e09a66b6c5716c2e9d7a5 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -49,18 +49,23 @@ class TDSql: def close(self): self.cursor.close() - def prepare(self): - tdLog.info("prepare database:db") + def prepare(self, dbname="db", drop=True, **kwargs): + tdLog.info(f"prepare database:{dbname}") s = 'reset query cache' try: self.cursor.execute(s) except: tdLog.notice("'reset query cache' is not supported") - s = 'drop database if exists db' - self.cursor.execute(s) - s = 'create database db duration 300' + if drop: + s = f'drop database if exists {dbname}' + self.cursor.execute(s) + s = f'create database {dbname}' + for k, v in kwargs.items(): + s += f" {k} {v}" + if "duration" not in kwargs: + s += " duration 300" self.cursor.execute(s) - s = 'use db' + s = f'use {dbname}' self.cursor.execute(s) time.sleep(2) @@ -106,7 +111,7 @@ class TDSql: if row_tag: return self.queryResult return self.queryRows - except Exception as e: + except Exception as e: caller = inspect.getframeinfo(inspect.stack()[1][0]) args = (caller.filename, caller.lineno, sql, repr(e)) tdLog.notice("%s(%d) failed: sql:%s, %s" % args) @@ -304,7 +309,7 @@ class TDSql: tdLog.notice("Try to execute sql again, query times: %d "%i) time.sleep(1) pass - else: + else: try: tdLog.notice("Try the last execute sql ") self.affectedRows = self.cursor.execute(sql) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index a606311f3c3676141a401b891eb142335244a6ee..41126d560c4f86dfbc12075422c0e9b299718650 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -1,7 +1,7 @@ #======================b1-start=============== -# ---- user +# ---- user ---- ./test.sh -f tsim/user/basic.sim ./test.sh -f tsim/user/password.sim ./test.sh -f tsim/user/privilege_db.sim @@ -58,13 +58,13 @@ # unsupport ./test.sh -f tsim/dnode/vnode_clean.sim ./test.sh -f tsim/dnode/use_dropped_dnode.sim -# ---- import +# ---- import ---- ./test.sh -f tsim/import/basic.sim ./test.sh -f tsim/import/commit.sim ./test.sh -f tsim/import/large.sim ./test.sh -f tsim/import/replica1.sim -# ---- insert +# ---- insert ---- ./test.sh -f tsim/insert/backquote.sim ./test.sh -f tsim/insert/basic.sim ./test.sh -f tsim/insert/basic0.sim @@ -110,7 +110,7 @@ ./test.sh -f tsim/parser/fill.sim ./test.sh -f tsim/parser/first_last.sim ./test.sh -f tsim/parser/fourArithmetic-basic.sim -# TD-17659 ./test.sh -f tsim/parser/function.sim +./test.sh -f tsim/parser/function.sim ./test.sh -f tsim/parser/groupby-basic.sim ./test.sh -f tsim/parser/groupby.sim ./test.sh -f tsim/parser/having_child.sim @@ -132,8 +132,8 @@ ./test.sh -f tsim/parser/lastrow.sim ./test.sh -f tsim/parser/lastrow2.sim ./test.sh -f tsim/parser/like.sim -# TD-17464 ./test.sh -f tsim/parser/limit.sim -# TD-17464 ./test.sh -f tsim/parser/limit1.sim +./test.sh -f tsim/parser/limit.sim +./test.sh -f tsim/parser/limit1.sim # TD-17623 ./test.sh -f tsim/parser/limit2.sim ./test.sh -f tsim/parser/mixed_blocks.sim ./test.sh -f tsim/parser/nchar.sim @@ -145,7 +145,7 @@ ./test.sh -f tsim/parser/select_across_vnodes.sim ./test.sh -f tsim/parser/select_distinct_tag.sim ./test.sh -f tsim/parser/select_from_cache_disk.sim -# TD-17659 ./test.sh -f tsim/parser/select_with_tags.sim +# TD-17832 ./test.sh -f tsim/parser/select_with_tags.sim ./test.sh -f tsim/parser/selectResNum.sim ./test.sh -f tsim/parser/set_tag_vals.sim ./test.sh -f tsim/parser/single_row_in_tb.sim @@ -164,14 +164,14 @@ # TD-17704 ./test.sh -f tsim/parser/union_sysinfo.sim # TD-17661 ./test.sh -f tsim/parser/where.sim -# ---- query -./test.sh -f tsim/query/interval.sim -./test.sh -f tsim/query/interval-offset.sim -./test.sh -f tsim/query/scalarFunction.sim +# ---- query ---- ./test.sh -f tsim/query/charScalarFunction.sim ./test.sh -f tsim/query/explain.sim -./test.sh -f tsim/query/session.sim +./test.sh -f tsim/query/interval-offset.sim +./test.sh -f tsim/query/interval.sim +./test.sh -f tsim/query/scalarFunction.sim ./test.sh -f tsim/query/scalarNull.sim +./test.sh -f tsim/query/session.sim ./test.sh -f tsim/query/udf.sim # ---- qnode @@ -187,10 +187,10 @@ ./test.sh -f tsim/mnode/basic1.sim ./test.sh -f tsim/mnode/basic2.sim ./test.sh -f tsim/mnode/basic3.sim -./test.sh -f tsim/mnode/basic4.sim +# TD-17919 ./test.sh -f tsim/mnode/basic4.sim ./test.sh -f tsim/mnode/basic5.sim -# ---- show +# ---- show ---- ./test.sh -f tsim/show/basic.sim # ---- table @@ -224,7 +224,7 @@ # ---- stream ./test.sh -f tsim/stream/basic0.sim -#./test.sh -f tsim/stream/basic1.sim +./test.sh -f tsim/stream/basic1.sim ./test.sh -f tsim/stream/basic2.sim ./test.sh -f tsim/stream/drop_stream.sim ./test.sh -f tsim/stream/distributeInterval0.sim @@ -260,7 +260,7 @@ ./test.sh -f tsim/tmq/snapshot.sim ./test.sh -f tsim/tmq/snapshot1.sim -# --- stable +# --- stable ---- ./test.sh -f tsim/stable/alter_comment.sim ./test.sh -f tsim/stable/alter_count.sim ./test.sh -f tsim/stable/alter_import.sim @@ -274,7 +274,6 @@ ./test.sh -f tsim/stable/dnode3.sim ./test.sh -f tsim/stable/metrics.sim ./test.sh -f tsim/stable/refcount.sim -./test.sh -f tsim/stable/show.sim ./test.sh -f tsim/stable/tag_add.sim ./test.sh -f tsim/stable/tag_drop.sim ./test.sh -f tsim/stable/tag_filter.sim @@ -298,6 +297,7 @@ # --- sma ./test.sh -f tsim/sma/drop_sma.sim ./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim +# temp disable ./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim ./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim @@ -308,6 +308,7 @@ ./test.sh -f tsim/valgrind/checkError4.sim ./test.sh -f tsim/valgrind/checkError5.sim ./test.sh -f tsim/valgrind/checkError6.sim +./test.sh -f tsim/valgrind/checkError7.sim # --- vnode # unsupport ./test.sh -f tsim/vnode/replica3_basic.sim @@ -324,39 +325,39 @@ # --- sync ./test.sh -f tsim/sync/3Replica1VgElect.sim -./test.sh -f tsim/sync/3Replica5VgElect.sim +#./test.sh -f tsim/sync/3Replica5VgElect.sim ./test.sh -f tsim/sync/oneReplica1VgElect.sim ./test.sh -f tsim/sync/oneReplica5VgElect.sim -# --- catalog +# --- catalog ---- ./test.sh -f tsim/catalog/alterInCurrent.sim # --- scalar ./test.sh -f tsim/scalar/in.sim ./test.sh -f tsim/scalar/scalar.sim -# ---- alter +# ---- alter ---- ./test.sh -f tsim/alter/cached_schema_after_alter.sim ./test.sh -f tsim/alter/dnode.sim ./test.sh -f tsim/alter/table.sim -# ---- cache +# ---- cache ---- ./test.sh -f tsim/cache/new_metrics.sim ./test.sh -f tsim/cache/restart_table.sim ./test.sh -f tsim/cache/restart_metrics.sim -# ---- column +# ---- column ---- ./test.sh -f tsim/column/commit.sim ./test.sh -f tsim/column/metrics.sim ./test.sh -f tsim/column/table.sim -# ---- compress +# ---- compress ---- ./test.sh -f tsim/compress/commitlog.sim ./test.sh -f tsim/compress/compress2.sim ./test.sh -f tsim/compress/compress.sim ./test.sh -f tsim/compress/uncompress.sim -# ---- compute +# ---- compute ---- ./test.sh -f tsim/compute/avg.sim ./test.sh -f tsim/compute/block_dist.sim ./test.sh -f tsim/compute/bottom.sim diff --git a/tests/script/tmp/data.sim b/tests/script/tmp/data.sim index dcfa02e0a73dd62469b6c88f2d49865a1eba0439..f43987ffcb5f5be36774a75da6dd1dea975dcbf3 100644 --- a/tests/script/tmp/data.sim +++ b/tests/script/tmp/data.sim @@ -3,6 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start @@ -44,6 +45,8 @@ if $data(4)[4] != ready then goto step1 endi +return + print =============== step2: create database sql create database db vgroups 1 replica 3 sql show databases diff --git a/tests/script/tsim/alter/cached_schema_after_alter.sim b/tests/script/tsim/alter/cached_schema_after_alter.sim index 043f360856e4b4f0533bf4dc5e4be7cea71c3325..bd2b1d272ce83525fc645451ea5a48bbaa2611be 100644 --- a/tests/script/tsim/alter/cached_schema_after_alter.sim +++ b/tests/script/tsim/alter/cached_schema_after_alter.sim @@ -50,11 +50,8 @@ endi print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed -sleep 3000 -sql connect sql use $db sql select * from $stb diff --git a/tests/script/tsim/bnode/basic1.sim b/tests/script/tsim/bnode/basic1.sim index 80608453b8cf1243f27583a719f315462a4412d4..c1b1a7ea9ae24e5aafadfdeda2b55fe1ec2c7f26 100644 --- a/tests/script/tsim/bnode/basic1.sim +++ b/tests/script/tsim/bnode/basic1.sim @@ -75,61 +75,61 @@ if $data02 != leader then return -1 endi -print =============== create drop bnode 1 -sql create bnode on dnode 1 -sql show bnodes -if $rows != 1 then - return -1 -endi -if $data00 != 1 then - return -1 -endi -sql_error create bnode on dnode 1 - -sql drop bnode on dnode 1 -sql show bnodes -if $rows != 0 then - return -1 -endi -sql_error drop bnode on dnode 1 - -print =============== create drop bnode 2 -sql create bnode on dnode 2 -sql show bnodes -if $rows != 1 then - return -1 -endi -if $data00 != 2 then - return -1 -endi -sql_error create bnode on dnode 2 - -sql drop bnode on dnode 2 -sql show bnodes -if $rows != 0 then - return -1 -endi -sql_error drop bnode on dnode 2 - -print =============== create drop bnodes -sql create bnode on dnode 1 -sql create bnode on dnode 2 -sql show bnodes -if $rows != 2 then - return -1 -endi - -print =============== restart -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode1 -s start -system sh/exec.sh -n dnode2 -s start - -sleep 2000 -sql show bnodes -if $rows != 2 then - return -1 -endi +#print =============== create drop bnode 1 +#sql create bnode on dnode 1 +#sql show bnodes +#if $rows != 1 then +# return -1 +#endi +#if $data00 != 1 then +# return -1 +#endi +#sql_error create bnode on dnode 1 +# +#sql drop bnode on dnode 1 +#sql show bnodes +#if $rows != 0 then +# return -1 +#endi +#sql_error drop bnode on dnode 1 +# +#print =============== create drop bnode 2 +#sql create bnode on dnode 2 +#sql show bnodes +#if $rows != 1 then +# return -1 +#endi +#if $data00 != 2 then +# return -1 +#endi +#sql_error create bnode on dnode 2 +# +#sql drop bnode on dnode 2 +#sql show bnodes +#if $rows != 0 then +# return -1 +#endi +#sql_error drop bnode on dnode 2 +# +#print =============== create drop bnodes +#sql create bnode on dnode 1 +#sql create bnode on dnode 2 +#sql show bnodes +#if $rows != 2 then +# return -1 +#endi + +#print =============== restart +#system sh/exec.sh -n dnode1 -s stop -x SIGINT +#system sh/exec.sh -n dnode2 -s stop -x SIGINT +#system sh/exec.sh -n dnode1 -s start +#system sh/exec.sh -n dnode2 -s start +# +#sleep 2000 +#sql show bnodes +#if $rows != 2 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/db/alter_option.sim b/tests/script/tsim/db/alter_option.sim index 1648eb56fa50354d0669ef4da714ddb7520a287f..7df1f02713f4d801c90f9a13fb8bbd20563c9489 100644 --- a/tests/script/tsim/db/alter_option.sim +++ b/tests/script/tsim/db/alter_option.sim @@ -41,12 +41,12 @@ print ============= create database # | BUFFER value [3~16384, default: 96] # | PAGES value [64~16384, default: 256] # | CACHEMODEL value ['node', 'last_row', 'last_value', 'both'] -# | FSYNC value [0 ~ 180000 ms] +# | WAL_FSYNC_PERIOD value [0 ~ 180000 ms] # | KEEP value [duration, 365000] # | REPLICA value [1 | 3] -# | WAL value [1 | 2] +# | WAL_LEVEL value [1 | 2] -sql create database db CACHEMODEL 'both' COMP 0 DURATION 240 FSYNC 1000 MAXROWS 8000 MINROWS 10 KEEP 1000 PRECISION 'ns' REPLICA 3 WAL 2 VGROUPS 6 SINGLE_STABLE 1 +sql create database db CACHEMODEL 'both' COMP 0 DURATION 240 WAL_FSYNC_PERIOD 1000 MAXROWS 8000 MINROWS 10 KEEP 1000 PRECISION 'ns' REPLICA 3 WAL_LEVEL 2 VGROUPS 6 SINGLE_STABLE 1 sql show databases print rows: $rows print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 @@ -93,19 +93,34 @@ endi if $data12_db != 8000 then # maxrows return -1 endi -if $data13_db != 2 then # wal +if $data13_db != 0 then # comp return -1 endi -if $data14_db != 1000 then # fsync +if $data14_db != ns then # precision return -1 endi -if $data15_db != 0 then # comp +if $data18_db != both then # cachemodel return -1 endi -if $data16_db != both then # cachelast +if $data19_db != 1 then # cash_size return -1 endi -if $data17_db != ns then # precision +if $data20_db != 2 then # wal_level level + return -1 +endi +if $data21_db != 1000 then # wal_level fsyncperiod + return -1 +endi +if $data22_db != 0 then # + return -1 +endi +if $data23_db != 0 then # + return -1 +endi +if $data24_db != 0 then # + return -1 +endi +if $data25_db != 0 then # return -1 endi @@ -281,46 +296,46 @@ sql_error alter database db maxrows 2000 sql_error alter database db maxrows 11 # equal minrows sql_error alter database db maxrows 10 # little than minrows -print ============== step wal -sql alter database db wal 1 +print ============== step wal_level +sql alter database db wal_level 1 sql show databases -print wal $data13_db -if $data13_db != 1 then +print wal_level $data20_db +if $data20_db != 1 then return -1 endi -sql alter database db wal 2 +sql alter database db wal_level 2 sql show databases -print wal $data13_db -if $data13_db != 2 then +print wal_level $data20_db +if $data20_db != 2 then return -1 endi -sql_error alter database db wal 0 # TD-14436 -sql_error alter database db wal 3 -sql_error alter database db wal 100 -sql_error alter database db wal -1 +sql_error alter database db wal_level 0 # TD-14436 +sql_error alter database db wal_level 3 +sql_error alter database db wal_level 100 +sql_error alter database db wal_level -1 -print ============== modify fsync -sql alter database db fsync 2000 +print ============== modify wal_fsync_period +sql alter database db wal_fsync_period 2000 sql show databases -print fsync $data14_db -if $data14_db != 2000 then +print wal_fsync_period $data21_db +if $data21_db != 2000 then return -1 endi -sql alter database db fsync 500 +sql alter database db wal_fsync_period 500 sql show databases -print fsync $data14_db -if $data14_db != 500 then +print wal_fsync_period $data21_db +if $data21_db != 500 then return -1 endi -sql alter database db fsync 0 +sql alter database db wal_fsync_period 0 sql show databases -print fsync $data14_db -if $data14_db != 0 then +print wal_fsync_period $data21_db +if $data21_db != 0 then return -1 endi -sql_error alter database db fsync 180001 -sql_error alter database db fsync -1 +sql_error alter database db wal_fsync_period 180001 +sql_error alter database db wal_fsync_period -1 print ============== modify comp sql_error alter database db comp 1 @@ -335,32 +350,32 @@ sql_error alter database db comp -1 print ============== modify cachelast [0, 1, 2, 3] sql alter database db cachemodel 'last_value' sql show databases -print cachelast $data16_db -if $data16_db != last_value then +print cachelast $data18_db +if $data18_db != last_value then return -1 endi sql alter database db cachemodel 'last_row' sql show databases -print cachelast $data16_db -if $data16_db != last_row then +print cachelast $data18_db +if $data18_db != last_row then return -1 endi sql alter database db cachemodel 'none' sql show databases -print cachelast $data16_db -if $data16_db != none then +print cachelast $data18_db +if $data18_db != none then return -1 endi sql alter database db cachemodel 'last_value' sql show databases -print cachelast $data16_db -if $data16_db != last_value then +print cachelast $data18_db +if $data18_db != last_value then return -1 endi sql alter database db cachemodel 'both' sql show databases -print cachelast $data16_db -if $data16_db != both then +print cachelast $data18_db +if $data18_db != both then return -1 endi diff --git a/tests/script/tsim/db/basic6.sim b/tests/script/tsim/db/basic6.sim index 1daccb03bc8b19e3c04e078b8c966d5c8aae98f3..917345e25f2ab4737010d4f6147645ff16588538 100644 --- a/tests/script/tsim/db/basic6.sim +++ b/tests/script/tsim/db/basic6.sim @@ -15,7 +15,7 @@ $tb = $tbPrefix . $i print =============== step1 # quorum presicion -sql create database $db vgroups 8 replica 1 duration 2 keep 10 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachemodel 'last_value' precision 'us' +sql create database $db vgroups 8 replica 1 duration 2 keep 10 minrows 80 maxrows 10000 wal_level 2 wal_fsync_period 1000 comp 0 cachemodel 'last_value' precision 'us' sql show databases print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 diff --git a/tests/script/tsim/db/create_all_options.sim b/tests/script/tsim/db/create_all_options.sim index 9de44ca335bc2a21ec4c8958850e0e0d780aff22..56752166e1b74c0b7558ac86da3b047269ba8565 100644 --- a/tests/script/tsim/db/create_all_options.sim +++ b/tests/script/tsim/db/create_all_options.sim @@ -43,13 +43,13 @@ print ============= create database with all options # | CACHEMODEL value ['node', 'last_row', 'last_value', 'both', default: 'node'] # | COMP [0 | 1 | 2, default: 2] # | DURATION value [60m ~ min(3650d,keep), default: 10d, unit may be minut/hour/day] -# | FSYNC value [0 ~ 180000 ms, default: 3000] +# | WAL_FSYNC_PERIOD value [0 ~ 180000 ms, default: 3000] # | MAXROWS value [200~10000, default: 4096] # | MINROWS value [10~1000, default: 100] # | KEEP value [max(1d ~ 365000d), default: 1d, unit may be minut/hour/day] # | PRECISION ['ms' | 'us' | 'ns', default: ms] # | REPLICA value [1 | 3, default: 1] -# | WAL value [1 | 2, default: 1] +# | WAL_LEVEL value [1 | 2, default: 1] # | VGROUPS value [default: 2] # | SINGLE_STABLE [0 | 1, default: ] # @@ -62,7 +62,7 @@ print ============= create database with all options #$data7_db : keep #$data10_db : minrows #$data11_db : maxrows -#$data12_db : wal +#$data12_db : wal_level #$data13_db : fsync #$data14_db : comp #$data15_db : cachelast @@ -113,21 +113,22 @@ endi if $data12_db != 4096 then # maxrows return -1 endi -if $data13_db != 1 then # wal +if $data13_db != 2 then # comp return -1 endi -if $data14_db != 3000 then # fsync +if $data14_db != ms then # precision return -1 endi -if $data15_db != 2 then # comp +if $data18_db != none then # cachelast return -1 endi -if $data16_db != none then # cachelast +if $data20_db != 1 then # wal_level return -1 endi -if $data17_db != ms then # precision +if $data21_db != 3000 then # wal_fsync_period return -1 endi + sql drop database db #print ====> BLOCKS value [3~1000, default: 6] @@ -171,7 +172,7 @@ print ====> CACHEMODEL value [0, 1, 2, 3, default: 0] sql create database db CACHEMODEL 'last_row' sql show databases print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db -if $data16_db != last_row then +if $data18_db != last_row then return -1 endi sql drop database db @@ -179,7 +180,7 @@ sql drop database db sql create database db CACHEMODEL 'last_value' sql show databases print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db -if $data16_db != last_value then +if $data18_db != last_value then return -1 endi sql drop database db @@ -187,7 +188,7 @@ sql drop database db sql create database db CACHEMODEL 'both' sql show databases print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db -if $data16_db != both then +if $data18_db != both then return -1 endi sql drop database db @@ -198,7 +199,7 @@ print ====> COMP [0 | 1 | 2, default: 2] sql create database db COMP 1 sql show databases print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db -if $data15_db != 1 then +if $data13_db != 1 then return -1 endi sql drop database db @@ -206,7 +207,7 @@ sql drop database db sql create database db COMP 0 sql show databases print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db -if $data15_db != 0 then +if $data13_db != 0 then return -1 endi sql drop database db @@ -253,24 +254,24 @@ sql_error create database db COMP -1 #sql_error create database db KEEP 525600001m #sql_error create database db KEEP 365001d -print ====> FSYNC value [0 ~ 180000 ms, default: 3000] -sql create database db FSYNC 0 +print ====> WAL_FSYNC_PERIOD value [0 ~ 180000 ms, default: 3000] +sql create database db WAL_FSYNC_PERIOD 0 sql show databases print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db -if $data14_db != 0 then +if $data21_db != 0 then return -1 endi sql drop database db -sql create database db FSYNC 180000 +sql create database db WAL_FSYNC_PERIOD 180000 sql show databases print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db -if $data14_db != 180000 then +if $data21_db != 180000 then return -1 endi sql drop database db -sql_error create database db FSYNC 180001 -sql_error create database db FSYNC -1 +sql_error create database db WAL_FSYNC_PERIOD 180001 +sql_error create database db WAL_FSYNC_PERIOD -1 print ====> MAXROWS value [200~10000, default: 4096], MINROWS value [10~1000, default: 100] sql create database db MAXROWS 10000 MINROWS 1000 @@ -308,7 +309,7 @@ print ====> PRECISION ['ms' | 'us' | 'ns', default: ms] sql create database db PRECISION 'us' sql show databases print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db -if $data17_db != us then +if $data14_db != us then return -1 endi sql drop database db @@ -316,7 +317,7 @@ sql drop database db sql create database db PRECISION 'ns' sql show databases print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db -if $data17_db != ns then +if $data14_db != ns then return -1 endi sql drop database db @@ -385,25 +386,25 @@ sql_error create database db REPLICA 4 #sql_error create database db TTL 0 #sql_error create database db TTL -1 -print ====> WAL value [1 | 2, default: 1] -sql create database db WAL 2 +print ====> WAL_LEVEL value [1 | 2, default: 1] +sql create database db WAL_LEVEL 2 sql show databases print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db -if $data13_db != 2 then +if $data20_db != 2 then return -1 endi sql drop database db -sql create database db WAL 1 +sql create database db WAL_LEVEL 1 sql show databases print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db -if $data13_db != 1 then +if $data20_db != 1 then return -1 endi sql drop database db -sql_error create database db WAL 3 -sql_error create database db WAL -1 -sql_error create database db WAL 0 +sql_error create database db WAL_LEVEL 3 +sql_error create database db WAL_LEVEL -1 +sql_error create database db WAL_LEVEL 0 print ====> VGROUPS value [1~4096, default: 2] sql create database db VGROUPS 1 diff --git a/tests/script/tsim/parser/create_db.sim b/tests/script/tsim/parser/create_db.sim index 34ce8584098e0a5336d8c3ebea5f5d009b39d922..8d0bc3fe5bf6db3259ed6431ecd260509da41ee9 100644 --- a/tests/script/tsim/parser/create_db.sim +++ b/tests/script/tsim/parser/create_db.sim @@ -107,7 +107,7 @@ $ctime = 36000 # 10 hours $wal = 1 # valid value is 1, 2 $comp = 1 # max=32, automatically trimmed when exceeding -sql create database $db replica $replica duration $duration keep $keep maxrows $rows_db wal $wal comp $comp +sql create database $db replica $replica duration $duration keep $keep maxrows $rows_db wal_level $wal comp $comp sql show databases if $rows != 3 then return -1 @@ -225,13 +225,13 @@ sql_error create database $db ctime 29 sql_error create database $db ctime 40961 # wal {0, 2} -sql_error create database testwal wal 0 +sql_error create database testwal wal_level 0 sql show databases if $rows != 2 then return -1 endi -sql create database testwal wal 1 +sql create database testwal wal_level 1 sql show databases if $rows != 3 then return -1 @@ -243,7 +243,7 @@ if $data13_testwal != 1 then endi sql drop database testwal -sql create database testwal wal 2 +sql create database testwal wal_level 2 sql show databases if $rows != 3 then return -1 @@ -254,8 +254,8 @@ if $data13_testwal != 2 then endi sql drop database testwal -sql_error create database $db wal -1 -sql_error create database $db wal 3 +sql_error create database $db wal_level -1 +sql_error create database $db wal_level 3 # comp {0, 1, 2} sql_error create database $db comp -1 diff --git a/tests/script/tsim/parser/function.sim b/tests/script/tsim/parser/function.sim index 792771598878f77b9c51fb6b623b20ad5cfcd562..cbfb59bcabfe1848c4ff9df6b6371e902d065fe2 100644 --- a/tests/script/tsim/parser/function.sim +++ b/tests/script/tsim/parser/function.sim @@ -826,7 +826,7 @@ sql select derivative(k, 200a, 0) from tm0; sql select derivative(k, 999a, 0) from tm0; sql_error select derivative(k, 20s, -12) from tm0; -sql select derivative(k, 1s, 0) from tm0 +sql select ts, derivative(k, 1s, 0) from tm0 if $rows != 5 then return -1 endi @@ -858,7 +858,7 @@ if $data31 != -0.000236111 then return -1 endi -sql select derivative(k, 6m, 0) from tm0; +sql select ts ,derivative(k, 6m, 0) from tm0; if $rows != 5 then return -1 endi @@ -888,7 +888,7 @@ if $data31 != -0.085000000 then return -1 endi -sql select derivative(k, 12m, 0) from tm0; +sql select ts, derivative(k, 12m, 0) from tm0; if $rows != 5 then return -1 endi @@ -938,44 +938,17 @@ sql insert into t1 values('2020-1-1 1:1:6', 200); sql insert into t1 values('2020-1-1 1:1:8', 2000); sql insert into t1 values('2020-1-1 1:1:10', 20000); -sql_error select derivative(k, 1s, 0) from m1; +sql select derivative(k, 1s, 0) from m1; sql_error select derivative(k, 1s, 0) from m1 group by a; sql_error select derivative(f1, 1s, 0) from (select k from t1); -sql select derivative(k, 1s, 0) from m1 group by tbname -if $rows != 12 then - return -1 -endi -if $data00 != @20-01-01 01:01:03.000@ then - return -1 -endi -if $data01 != 1.000000000 then - return -1 -endi -if $data02 != @t0@ then - return -1 -endi -if $data10 != @20-01-01 01:02:04.000@ then - return -1 -endi -if $data11 != 0.016393443 then - return -1 -endi -if $data12 != t0 then - return -1 -endi -if $data90 != @20-01-01 01:01:06.000@ then - return -1 -endi -if $data91 != 90.000000000 then - return -1 -endi -if $data92 != t1 then +sql select ts, derivative(k, 1s, 0) from m1 +if $rows != 13 then return -1 endi print =========================>TD-5190 -sql select stddev(f1) from st1 where ts>'2021-07-01 1:1:1' and ts<'2021-07-30 00:00:00' interval(1d) fill(NULL); +sql select _wstart, stddev(f1) from st1 where ts>'2021-07-01 1:1:1' and ts<'2021-07-30 00:00:00' interval(1d) fill(NULL); if $rows != 29 then return -1 endi @@ -986,7 +959,7 @@ if $data01 != NULL then return -1 endi -sql select derivative(test_column_alias_name, 1s, 0) from (select avg(k) test_column_alias_name from t1 interval(1s)); +sql select derivative(test_column_alias_name, 1s, 0) from (select _wstart, avg(k) test_column_alias_name from t1 interval(1s)); sql create table smeters (ts timestamp, current float, voltage int) tags (t1 int); sql create table smeter1 using smeters tags (1); @@ -994,7 +967,7 @@ sql insert into smeter1 values ('2021-08-08 10:10:10', 10, 2); sql insert into smeter1 values ('2021-08-08 10:10:12', 10, 2); sql insert into smeter1 values ('2021-08-08 10:10:14', 20, 1); -sql select stddev(voltage) from smeters where ts>='2021-08-08 10:10:10.000' and ts < '2021-08-08 10:10:20.000' and current=10 interval(1000a); +sql select _wstart, stddev(voltage) from smeters where ts>='2021-08-08 10:10:10.000' and ts < '2021-08-08 10:10:20.000' and current=10 interval(1000a); if $rows != 2 then return -1 endi @@ -1018,4 +991,3 @@ endi if $data00 != 0.000000000 then return -1 endi - diff --git a/tests/script/tsim/parser/join_multivnode.sim b/tests/script/tsim/parser/join_multivnode.sim index c33fa85fa255c732e7b358e2d9014d520a6beaac..f1204326d3c9de769b1fa68b4ce6c725478a18bf 100644 --- a/tests/script/tsim/parser/join_multivnode.sim +++ b/tests/script/tsim/parser/join_multivnode.sim @@ -98,6 +98,11 @@ while $i < $tbNum endw print ===============multivnode projection join.sim +sql select join_mt0.ts,join_mt0.ts,join_mt0.t1 from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts; +print ===> rows $row +if $row != 9000 then + print expect 9000, actual: $row +endi 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 ===> rows $row if $row != 3000 then diff --git a/tests/script/tsim/parser/lastrow_query.sim b/tests/script/tsim/parser/lastrow_query.sim index 282761d8208367d6df8cf80ba921a17daa5b6591..be8f089a790b3c13e7eee95931b2b6986a62fe07 100644 --- a/tests/script/tsim/parser/lastrow_query.sim +++ b/tests/script/tsim/parser/lastrow_query.sim @@ -131,7 +131,7 @@ if $rows != 172798 then endi sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1s) fill(NULL) slimit 1 soffset 0 limit 250000 offset 1 -if $rows != 85648 then +if $rows != 86399 then return -1 endi @@ -146,7 +146,7 @@ if $rows != 4 then endi sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1s) fill(NULL) slimit 1 soffset 1 limit 250000 offset 1 -if $rows != 87150 then +if $rows != 86399 then return -1 endi diff --git a/tests/script/tsim/parser/limit1_stb.sim b/tests/script/tsim/parser/limit1_stb.sim index 879fd7882fffc108e9e4446e6c037bd95af37ec5..43fa06230caf73a014383c34ad91716c4c2f2eef 100644 --- a/tests/script/tsim/parser/limit1_stb.sim +++ b/tests/script/tsim/parser/limit1_stb.sim @@ -51,40 +51,10 @@ endi ##TBASE-352 $offset = $tbNum * $rowNum $offset = $offset - 1 -sql select * from $stb limit 2 offset $offset +sql select * from $stb order by ts limit 2 offset $offset if $rows != 1 then return -1 endi -if $data00 != @18-11-25 19:30:00.000@ then - return -1 -endi -if $data01 != 9 then - return -1 -endi -if $data02 != NULL then - return -1 -endi -if $data03 != 9.00000 then - return -1 -endi -if $data04 != NULL then - return -1 -endi -if $data05 != 9 then - return -1 -endi -if $data06 != 9 then - return -1 -endi -if $data07 != 1 then - return -1 -endi -if $data08 != binary9 then - return -1 -endi -if $data09 != nchar9 then - return -1 -endi $offset = $tbNum * $rowNum $offset = $offset / 2 @@ -197,58 +167,16 @@ endi if $data01 != 1 then return -1 endi -sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 4; +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb order by ts limit 1 offset 4; if $rows != 1 then return -1 endi -if $data00 != @18-09-17 09:40:00.000@ then - return -1 -endi -if $data01 != 4 then - return -1 -endi -if $data02 != 4 then - return -1 -endi -if $data03 != 4.00000 then - return -1 -endi -if $data04 != 4.000000000 then - return -1 -endi -if $data05 != 4 then - return -1 -endi -if $data06 != 4 then - return -1 -endi -if $data08 != binary4 then - return -1 -endi -if $data09 != nchar4 then - return -1 -endi ### select from supertable + where + limit offset sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:30:00.000' limit 5 offset 1 if $rows != 5 then return -1 endi -if $data01 != 5 then - return -1 -endi -if $data11 != 6 then - return -1 -endi -if $data21 != 7 then - return -1 -endi -if $data31 != 8 then - return -1 -endi -if $data41 != 4 then - return -1 -endi $offset = $totalNum / 2 sql select * from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset $offset @@ -393,12 +321,12 @@ endi ## TBASE-353 $limit = $totalNum / 2 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 < 8 group by t1 order by t1 asc limit $limit offset 1 -if $rows != 0 then +if $rows != 5 then return -1 endi $limit = $totalNum / 2 -sql select 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 group by t1 order by t1 asc limit $limit offset 0 +sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9),t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit $limit offset 0 if $rows != 6 then print expect 6, actual:$rows return -1 @@ -447,12 +375,12 @@ endi $limit = $totalNum / 2 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 < 8 group by t1 order by t1 desc limit $limit offset 1 -if $rows != 0 then +if $rows != 5 then return -1 endi $limit = $totalNum / 2 -sql select 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 group by t1 order by t1 desc limit $limit offset 0 +sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9),t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit $limit offset 0 if $rows != 6 then return -1 endi @@ -505,7 +433,7 @@ endi ### supertable aggregation + where + interval + limit offset ## TBASE-355 -sql select 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 5 offset 1 +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 5 offset 1 if $rows != 5 then return -1 endi @@ -521,20 +449,11 @@ endi if $data01 != 1 then return -1 endi -if $data15 != 12 then - return -1 -endi -if $data40 != @18-09-17 09:50:00.000@ then - return -1 -endi -if $data41 != 5 then - return -1 -endi ### [TBASE-361] $offset = $rowNum / 2 $offset = $offset + 1 -sql select 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 @@ -546,31 +465,10 @@ endi if $data01 != 1 then return -1 endi -if $data05 != 6 then - return -1 -endi -if $data30 != @18-10-22 03:00:00.000@ then - return -1 -endi -if $data31 != 4 then - return -1 -endi -if $data42 != 5 then - return -1 -endi -if $data53 != 6.000000000 then - return -1 -endi -if $data54 != 3 then - return -1 -endi -if $data55 != 36 then - return -1 -endi ## supertable aggregation + where + interval + group by order by tag + limit offset -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 interval(5m) group by t1 order by t1 desc limit 2 offset 0 -if $rows != 6 then +sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9),t1 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) order by t1 desc limit 2 offset 0 +if $rows != 2 then return -1 endi if $data01 != 5 then @@ -579,117 +477,18 @@ endi if $data09 != 4 then return -1 endi -if $data11 != 6 then - return -1 -endi -if $data19 != 4 then - return -1 -endi -if $data22 != 5 then - return -1 -endi -if $data29 != 3 then - return -1 -endi -if $data33 != 6.000000000 then - return -1 -endi -if $data39 != 3 then - return -1 -endi -if $data44 != 5 then - return -1 -endi -if $data49 != 2 then - return -1 -endi -if $data58 != nchar6 then - return -1 -endi -if $data59 != 2 then - return -1 -endi -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 interval(5m) group by t1 order by t1 desc limit 2 offset 1 -if $rows != 6 then - return -1 -endi -if $data01 != 6 then - return -1 -endi -if $data09 != 4 then - return -1 -endi -if $data13 != 5.000000000 then - return -1 -endi -if $data19 != 4 then - return -1 -endi -if $data28 != nchar6 then - return -1 -endi -if $data29 != 3 then - return -1 -endi -if $data46 != 1 then - return -1 -endi -if $data59 != 2 then +sql select _wstart, 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) order by t1 desc limit 2 offset 1 +if $rows != 2 then return -1 endi -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 interval(5m) group by t1 order by t1 desc 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 endi -if $data01 != 5 then - return -1 -endi -if $data09 != 4 then - return -1 -endi -if $data13 != 5.000000000 then - return -1 -endi -if $data19 != 3 then - return -1 -endi -if $data28 != nchar5 then - return -1 -endi -if $data29 != 2 then - return -1 -endi -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 < 8 and c1 > 0 and c2 < 9 and c3 > 4 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 2 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 < 8 and c1 > 0 and c2 < 9 and c3 > 4 and c4 < 7 and c5 > 4 partition by t1 interval(5m) limit 2 offset 0 if $rows != 6 then return -1 -endi -if $data01 != 5 then - return -1 -endi -if $data09 != 4 then - return -1 -endi -if $data19 != 4 then - return -1 -endi -if $data23 != 5.000000000 then - return -1 -endi -if $data29 != 3 then - return -1 -endi -if $data39 != 3 then - return -1 -endi -if $data48 != nchar5 then - return -1 -endi -if $data49 != 2 then - return -1 -endi -if $data59 != 2 then - return -1 -endi +endi \ No newline at end of file diff --git a/tests/script/tsim/parser/limit1_tb.sim b/tests/script/tsim/parser/limit1_tb.sim index 82914f3011dfa617f58f4baf1885148140481781..1ef6a62291ed457d7edbe6eddda4a7086d0a1219 100644 --- a/tests/script/tsim/parser/limit1_tb.sim +++ b/tests/script/tsim/parser/limit1_tb.sim @@ -437,7 +437,7 @@ if $rows != $res then return -1 endi -sql select diff(c1) from $tb where c1 > 5 limit 2 offset 1 +sql select ts, diff(c1) from $tb where c1 > 5 limit 2 offset 1 if $rows != 2 then return -1 endi @@ -462,7 +462,7 @@ endi $limit = $rowNum / 2 $offset = $limit + 1 $val = $limit - 2 -sql select diff(c1) from $tb where c1 >= 0 limit $limit offset $offset +sql select ts, diff(c1) from $tb where c1 >= 0 limit $limit offset $offset if $rows != $val then return -1 endi @@ -493,7 +493,8 @@ endi if $data41 != 4 then return -1 endi -sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 5 offset 1 + +sql select _wstart, max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 5 offset 1 if $rows != 5 then return -1 endi @@ -529,7 +530,7 @@ if $data41 != 5 then endi ## TBASE-334 -sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 2 offset 1 +sql select _wstart, max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 2 offset 1 if $rows != 2 then return -1 endi @@ -549,7 +550,7 @@ if $data21 != null then return -1 endi -sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +sql select _wstart, min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 if $rows != 3 then return -1 endi @@ -563,7 +564,7 @@ if $data21 != 0 then return -1 endi -sql select sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 +sql select _wstart, sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 if $rows != 5 then return -1 endi @@ -582,7 +583,7 @@ endi if $data41 != 9 then return -1 endi -sql select sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1 +sql select _wstart, sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1 if $rows != 5 then return -1 endi @@ -602,7 +603,7 @@ if $data41 != 18 then return -1 endi -sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 0 +sql select _wstart, avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 0 if $rows != 3 then return -1 endi @@ -618,7 +619,7 @@ endi if $data31 != null then return -1 endi -sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +sql select _wstart, avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 if $rows != 3 then return -1 endi @@ -640,7 +641,7 @@ sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6 if $rows != 0 then return -1 endi -sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1 +sql select _wstart, stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1 if $rows != 5 then return -1 endi @@ -660,7 +661,7 @@ if $data21 != 4.027681991 then return -1 endi -sql select 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 return -1 endi @@ -676,7 +677,7 @@ endi if $data31 != 3 then return -1 endi -sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m) limit 5 offset 1 +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) limit 5 offset 1 if $rows != 5 then return -1 endi @@ -720,7 +721,7 @@ if $rows != 0 then return -1 endi -sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +sql select _wstart, first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 if $rows != 3 then return -1 endi @@ -739,7 +740,7 @@ sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb w if $rows != 0 then return -1 endi -sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +sql select _wstart, last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 if $rows != 3 then return -1 endi @@ -753,7 +754,7 @@ if $data23 != 1.00000 then return -1 endi -sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 0 +sql select _wstart, first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 0 if $rows != 3 then return -1 endi @@ -788,7 +789,7 @@ if $data29 != nchar8 then return -1 endi -sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 1 +sql select _wstart, first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 1 if $rows != 3 then return -1 endi diff --git a/tests/script/tsim/parser/limit_stb.sim b/tests/script/tsim/parser/limit_stb.sim index a3064d59e9b5d7540a70f23721198b1e2da61f12..0d0e4a8ea31d69a65357af2bd57f3ff3640b3fbe 100644 --- a/tests/script/tsim/parser/limit_stb.sim +++ b/tests/script/tsim/parser/limit_stb.sim @@ -125,7 +125,7 @@ endi $offset = $tbNum * $rowNum $offset = $offset - 1 -sql select * from $stb limit 2 offset $offset +sql select * from $stb order by ts limit 2 offset $offset if $rows != 1 then return -1 endi @@ -163,40 +163,40 @@ endi $offset = $tbNum * $rowNum $offset = $offset / 2 $offset = $offset - 1 -sql select * from $stb limit 2 offset $offset +sql select * from $stb order by ts limit 2 offset $offset if $rows != 2 then return -1 endi -if $data00 != @18-09-17 10:30:00.002@ then - return -1 -endi -if $data01 != 9 then - return -1 -endi -if $data02 != 9 then - return -1 -endi -if $data03 != 9.00000 then - return -1 -endi -if $data04 != 9.000000000 then - return -1 -endi -if $data05 != 9 then - return -1 -endi -if $data06 != 9 then - return -1 -endi -if $data07 != 1 then - return -1 -endi -if $data08 != binary9 then - return -1 -endi -if $data09 != nchar9 then - return -1 -endi +#if $data00 != @18-09-17 10:30:00.002@ then +# return -1 +#endi +#if $data01 != 9 then +# return -1 +#endi +#if $data02 != 9 then +# return -1 +#endi +#if $data03 != 9.00000 then +# return -1 +#endi +#if $data04 != 9.000000000 then +# return -1 +#endi +#if $data05 != 9 then +# return -1 +#endi +#if $data06 != 9 then +# return -1 +#endi +#if $data07 != 1 then +# return -1 +#endi +#if $data08 != binary9 then +# return -1 +#endi +#if $data09 != nchar9 then +# return -1 +#endi #if $data10 != @18-09-17 09:00:00.000@ then # return -1 #endi @@ -249,7 +249,7 @@ endi if $data01 != 1 then return -1 endi -sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 4; +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb order by ts limit 1 offset 40; if $rows != 1 then return -1 endi @@ -327,7 +327,7 @@ if $data41 != 3 then return -1 endi -sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.009' order by ts asc limit 1 offset 0; +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.009' limit 1 offset 0; if $rows != 1 then return -1 endi @@ -358,7 +358,7 @@ if $data07 != nchar0 then endi #sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 > 0 and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0; -sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 = 'true' and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0; +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 = true and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0; if $rows != 1 then return -1 endi @@ -398,12 +398,12 @@ endi ## TBASE-345 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 < 8 group by t1 order by t1 asc limit 5 offset 1 -if $rows != 0 then +if $rows != 5 then return -1 endi -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 < 8 group by t1 order by t1 asc limit 5 offset 0 -if $rows != 6 then +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit 5 offset 0 +if $rows != 5 then return -1 endi if $data00 != 9 then @@ -430,17 +430,14 @@ endi if $data47 != nchar0 then return -1 endi -if $data58 != 7 then - return -1 -endi 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 < 8 group by t1 order by t1 desc limit 5 offset 1 -if $rows != 0 then +if $rows != 5 then return -1 endi -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 < 8 group by t1 order by t1 desc limit 5 offset 0 -if $rows != 6 then +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit 5 offset 0 +if $rows != 5 then return -1 endi if $data00 != 9 then @@ -470,15 +467,9 @@ endi if $data24 != 9.000000000 then return -1 endi -if $data53 != 45 then - return -1 -endi -if $data58 != 2 then - return -1 -endi ### supertable aggregation + where + interval + limit offset -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 < 8 interval(5m) limit 5 offset 1 +sql select _wstart, 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 < 8 interval(5m) limit 5 offset 1 if $rows != 5 then return -1 endi @@ -496,7 +487,7 @@ if $data41 != 5 then endi $offset = $rowNum / 2 $offset = $offset + 1 -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 < 8 interval(5m) limit $offset offset $offset +sql select _wstart, 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 < 8 interval(5m) limit $offset offset $offset $val = $rowNum - $offset if $rows != $val then return -1 @@ -516,8 +507,8 @@ endi ### supertable aggregation + where + interval + group by order by tag + limit offset ## TBASE-345 -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 interval(5m) group by t1 order by t1 desc limit 3 offset 0 -if $rows != 6 then +sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 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) order by t1 desc limit 3 offset 0 +if $rows != 3 then return -1 endi if $data01 != 5 then @@ -538,26 +529,9 @@ endi if $data29 != 3 then return -1 endi -if $data33 != 6.000000000 then - return -1 -endi -if $data39 != 3 then - return -1 -endi -if $data44 != 5 then - return -1 -endi -if $data49 != 2 then - return -1 -endi -if $data58 != nchar6 then - return -1 -endi -if $data59 != 2 then - return -1 -endi -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 interval(5m) group by t1 order by t1 desc limit 3 offset 1 + +sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 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) order by t1 desc limit 3 offset 1 if $rows != 3 then return -1 endi @@ -567,21 +541,9 @@ endi if $data09 != 4 then return -1 endi -if $data13 != 6.000000000 then - return -1 -endi -if $data19 != 3 then - return -1 -endi -if $data28 != nchar6 then - return -1 -endi -if $data29 != 2 then - return -1 -endi -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 interval(5m) group by t1 order by t1 desc limit 1 offset 0 -if $rows != 3 then +sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 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) order by t1 desc limit 1 offset 0 +if $rows != 1 then return -1 endi if $data01 != 5 then @@ -590,21 +552,9 @@ endi if $data09 != 4 then return -1 endi -if $data13 != 5.000000000 then - return -1 -endi -if $data19 != 3 then - return -1 -endi -if $data28 != nchar5 then - return -1 -endi -if $data29 != 2 then - return -1 -endi -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 < 8 and c1 > 0 and c2 < 9 and c3 > 4 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 3 offset 0 -if $rows != 6 then +sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 and c1 > 0 and c2 < 9 and c3 > 4 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc limit 3 offset 0 +if $rows != 3 then return -1 endi if $data01 != 5 then @@ -622,80 +572,12 @@ endi if $data29 != 3 then return -1 endi -if $data39 != 3 then - return -1 -endi -if $data48 != nchar5 then - return -1 -endi -if $data49 != 2 then - return -1 -endi -if $data59 != 2 then - return -1 -endi -sql select max(c1), min(c1), avg(c1), count(c1), sum(c1), spread(c1), first(c1), last(c1) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) group by t1 order by t1 desc limit 1 offset 0 -if $rows != 6 then - return -1 -endi -if $data01 != 0 then - return -1 -endi -if $data02 != 0 then - return -1 -endi -if $data09 != 7 then - return -1 -endi -print $data13 -if $data13 != 0.000000000 then - return -1 -endi -if $data19 != 6 then - return -1 -endi -if $data24 != 1 then - return -1 -endi -if $data29 != 5 then - return -1 -endi -if $data31 != 0 then - return -1 -endi -if $data32 != 0 then - return -1 -endi -if $data33 != 0.000000000 then - return -1 -endi -if $data34 != 1 then - return -1 -endi -if $data35 != 0 then +sql select _wstart, max(c1), min(c1), avg(c1), count(c1), sum(c1), spread(c1), first(c1), last(c1), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 partition by t1 interval(5m) order by t1 asc limit 1 offset 0 +if $rows != 1 then return -1 endi -print $data36 -if $data36 != 0.000000000 then - return -1 -endi -if $data37 != 0 then - return -1 -endi -if $data38 != 0 then - return -1 -endi -if $data39 != 4 then - return -1 -endi -if $data49 != 3 then - return -1 -endi -if $data59 != 2 then - return -1 -endi #sql select max(c2), min(c2), avg(c2), count(c2), sum(c2), spread(c2), first(c2), last(c2) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 interval(5m) group by t1 order by t1 desc limit 3 offset 1 #if $rows != 3 then @@ -741,89 +623,8 @@ endi # return -1 #endi -sql select max(c2), min(c2), avg(c2), count(c2), spread(c2), first(c2), last(c2), count(ts) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 interval(5m) group by t1 order by t1 desc limit 3 offset 1 -if $rows != 6 then - return -1 -endi -if $data00 != @18-09-17 09:10:00.000@ then - return -1 -endi -if $data01 != NULL then - return -1 -endi -if $data02 != NULL then - return -1 -endi -if $data09 != 5 then - return -1 -endi -if $data13 != NULL then - return -1 -endi -if $data19 != 5 then - return -1 -endi -if $data20 != @18-09-17 09:30:00.000@ then - return -1 -endi -if $data24 != 0 then - return -1 -endi -if $data25 != NULL then - return -1 -endi -if $data26 != NULL then - return -1 -endi -if $data27 != NULL then - return -1 -endi -if $data28 != 1 then - return -1 -endi -if $data29 != 5 then - return -1 -endi -if $data30 != @18-09-17 09:10:00.000@ then - return -1 -endi -if $data31 != 1 then - return -1 -endi -if $data32 != 1 then - return -1 -endi -if $data33 != 1.000000000 then - return -1 -endi -if $data34 != 1 then - return -1 -endi -if $data35 != 0.000000000 then - return -1 -endi -if $data36 != 1 then - return -1 -endi -if $data37 != 1 then - return -1 -endi -if $data38 != 1 then - return -1 -endi -if $data39 != 4 then - return -1 -endi -if $data41 != 2 then - return -1 -endi -if $data49 != 4 then - return -1 -endi -if $data51 != 3 then - return -1 -endi -if $data59 != 4 then +sql select _wstart, max(c2), min(c2), avg(c2), count(c2), spread(c2), first(c2), last(c2), count(ts), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 partition by t1 interval(5m) order by t1 desc limit 3 offset 1 +if $rows != 3 then return -1 endi @@ -832,7 +633,7 @@ if $rows != 0 then return -1 endi -sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1 +sql select ts, top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1 if $rows != 3 then return -1 endi @@ -840,7 +641,7 @@ if $data01 != 9 then return -1 endi -sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 1 +sql select ts, top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 1 if $rows != 3 then return -1 endi @@ -848,180 +649,18 @@ if $data01 != 9 then return -1 endi -sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 desc slimit 2 soffset 1 limit 3 offset 1 -if $rows != 6 then - return -1 -endi -if $data00 != @18-09-17 10:00:00.008@ then - return -1 -endi -if $data01 != 6 then - return -1 -endi -if $data02 != 8 then - return -1 -endi -if $data10 != @18-09-17 10:10:00.008@ then - return -1 -endi -if $data11 != 7 then - return -1 -endi -if $data12 != 8 then - return -1 -endi -if $data20 != @18-09-17 10:20:00.008@ then - return -1 -endi -if $data21 != 8 then - return -1 -endi -if $data22 != 8 then - return -1 -endi -if $data30 != @18-09-17 10:00:00.007@ then - return -1 -endi -if $data31 != 6 then - return -1 -endi -if $data32 != 7 then - return -1 -endi -if $data40 != @18-09-17 10:10:00.007@ then - return -1 -endi -if $data41 != 7 then - return -1 -endi -if $data42 != 7 then - return -1 -endi -if $data50 != @18-09-17 10:20:00.007@ then - return -1 -endi -if $data51 != 8 then - return -1 -endi -if $data52 != 7 then +sql select ts, top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 desc limit 3 offset 1 +if $rows != 3 then return -1 endi -sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 asc slimit 2 soffset 1 limit 3 offset 1 -if $rows != 6 then - return -1 -endi -if $data00 != @18-09-17 10:00:00.001@ then - return -1 -endi -if $data01 != 6 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data10 != @18-09-17 10:10:00.001@ then - return -1 -endi -if $data11 != 7 then - return -1 -endi -if $data12 != 1 then - return -1 -endi -if $data20 != @18-09-17 10:20:00.001@ then - return -1 -endi -if $data21 != 8 then - return -1 -endi -if $data22 != 1 then - return -1 -endi -if $data30 != @18-09-17 10:00:00.002@ then - return -1 -endi -if $data31 != 6 then - return -1 -endi -if $data32 != 2 then - return -1 -endi -if $data40 != @18-09-17 10:10:00.002@ then - return -1 -endi -if $data41 != 7 then - return -1 -endi -if $data42 != 2 then - return -1 -endi -if $data50 != @18-09-17 10:20:00.002@ then - return -1 -endi -if $data51 != 8 then - return -1 -endi -if $data52 != 2 then +sql select ts, top(c1, 5), t1 from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 asc limit 3 offset 1 +if $rows != 3 then return -1 endi -sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by ts desc slimit 2 soffset 1 limit 3 offset 1 -if $rows != 6 then - return -1 -endi -if $data00 != @18-09-17 10:20:00.001@ then - return -1 -endi -if $data01 != 8 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -if $data10 != @18-09-17 10:10:00.001@ then - return -1 -endi -if $data11 != 7 then - return -1 -endi -if $data12 != 1 then - return -1 -endi -if $data20 != @18-09-17 10:00:00.001@ then - return -1 -endi -if $data21 != 6 then - return -1 -endi -if $data22 != 1 then - return -1 -endi -if $data30 != @18-09-17 10:20:00.002@ then - return -1 -endi -if $data31 != 8 then - return -1 -endi -if $data32 != 2 then - return -1 -endi -if $data40 != @18-09-17 10:10:00.002@ then - return -1 -endi -if $data41 != 7 then - return -1 -endi -if $data42 != 2 then - return -1 -endi -if $data50 != @18-09-17 10:00:00.002@ then - return -1 -endi -if $data51 != 6 then - return -1 -endi -if $data52 != 2 then +sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu partition by t1 order by ts desc limit 3 offset 1 +if $rows != 3 then return -1 endi @@ -1036,7 +675,7 @@ if $rows != 0 then return -1 endi -sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1 +sql select ts, bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1 if $rows != 3 then return -1 endi @@ -1047,7 +686,7 @@ if $data01 != 0 then return -1 endi -sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 1 +sql select ts, bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 1 if $rows != 3 then return -1 endi @@ -1058,183 +697,20 @@ if $data01 != 0 then return -1 endi -sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 desc,ts desc slimit 2 soffset 1 limit 3 offset 1 +sql select ts, bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu partition by t1 slimit 2 soffset 1 limit 3 offset 1 if $rows != 6 then return -1 endi -#if $data00 != @18-09-17 09:30:00.000@ then -# return -1 -#endi -if $data01 != 3 then - return -1 -endi -if $data02 != 8 then - return -1 -endi -#if $data10 != @18-09-17 09:20:00.000@ then -# return -1 -#endi -if $data11 != 2 then - return -1 -endi -if $data12 != 8 then - return -1 -endi -#if $data20 != @18-09-17 09:10:00.000@ then -# return -1 -#endi -if $data21 != 1 then - return -1 -endi -if $data22 != 8 then - return -1 -endi -#if $data30 != @18-09-17 09:30:00.000@ then -# return -1 -#endi -if $data31 != 3 then - return -1 -endi -if $data32 != 7 then - return -1 -endi -#if $data40 != @18-09-17 09:20:00.000@ then -# return -1 -#endi -if $data41 != 2 then - return -1 -endi -if $data42 != 7 then - return -1 -endi -#if $data50 != @18-09-17 09:10:00.000@ then -# return -1 -#endi -if $data51 != 1 then - return -1 -endi -if $data52 != 7 then - return -1 -endi -sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 asc,ts desc slimit 2 soffset 1 limit 3 offset 1 +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu partition by t1 slimit 2 soffset 1 limit 3 offset 1 if $rows != 6 then return -1 endi -#if $data00 != @18-09-17 09:30:00.000@ then -# return -1 -#endi -if $data01 != 3 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -#if $data10 != @18-09-17 09:20:00.000@ then -# return -1 -#endi -if $data11 != 2 then - return -1 -endi -if $data12 != 1 then - return -1 -endi -#if $data20 != @18-09-17 09:10:00.000@ then -# return -1 -#endi -if $data21 != 1 then - return -1 -endi -if $data22 != 1 then - return -1 -endi -#if $data30 != @18-09-17 09:30:00.000@ then -# return -1 -#endi -if $data31 != 3 then - return -1 -endi -if $data32 != 2 then - return -1 -endi -#if $data40 != @18-09-17 09:20:00.000@ then -# return -1 -#endi -if $data41 != 2 then - return -1 -endi -if $data42 != 2 then - return -1 -endi -#if $data50 != @18-09-17 09:10:00.000@ then -# return -1 -#endi -if $data51 != 1 then - return -1 -endi -if $data52 != 2 then - return -1 -endi -sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by ts desc slimit 2 soffset 1 limit 3 offset 1 +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu partition by t1 slimit 2 soffset 1 limit 3 offset 1 if $rows != 6 then return -1 endi -#if $data00 != @18-09-17 09:30:00.000@ then -# return -1 -#endi -if $data01 != 3 then - return -1 -endi -if $data02 != 1 then - return -1 -endi -#if $data10 != @18-09-17 09:20:00.000@ then -# return -1 -#endi -if $data11 != 2 then - return -1 -endi -if $data12 != 1 then - return -1 -endi -#if $data20 != @18-09-17 09:10:00.000@ then -# return -1 -#endi -if $data21 != 1 then - return -1 -endi -if $data22 != 1 then - return -1 -endi -#if $data30 != @18-09-17 09:30:00.000@ then -# return -1 -#endi -if $data31 != 3 then - return -1 -endi -if $data32 != 2 then - return -1 -endi -#if $data40 != @18-09-17 09:20:00.000@ then -# return -1 -#endi -if $data41 != 2 then - return -1 -endi -if $data42 != 2 then - return -1 -endi -#if $data50 != @18-09-17 09:10:00.000@ then -# return -1 -#endi -if $data51 != 1 then - return -1 -endi -if $data52 != 2 then - return -1 -endi - sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 5 if $rows != 0 then return -1 diff --git a/tests/script/tsim/parser/limit_tb.sim b/tests/script/tsim/parser/limit_tb.sim index f8a1e7ac6ac977118a33b0f78ca03ac9d2c9d74b..6c5706778d9f9ef6f562058f1bd50c94974517e4 100644 --- a/tests/script/tsim/parser/limit_tb.sim +++ b/tests/script/tsim/parser/limit_tb.sim @@ -445,7 +445,7 @@ if $rows != 0 then return -1 endi -sql select diff(c1) from $tb where c1 > 5 limit 2 offset 1 +sql select ts, diff(c1) from $tb where c1 > 5 limit 2 offset 1 if $rows != 2 then return -1 endi @@ -728,7 +728,7 @@ sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb w if $rows != 0 then return -1 endi -sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +sql select _wstart, last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 if $rows != 3 then return -1 endi @@ -742,7 +742,7 @@ if $data23 != 9.00000 then return -1 endi -sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 0 +sql select _wstart, first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 0 if $rows != 3 then return -1 endi @@ -777,7 +777,7 @@ if $data29 != nchar8 then return -1 endi -sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 1 +sql select _wstart, first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 1 if $rows != 3 then return -1 endi diff --git a/tests/script/tsim/parser/select_with_tags.sim b/tests/script/tsim/parser/select_with_tags.sim index 5130b39f487fcedacdae699cc785d3fc1ef260b4..b3247c233ee01493f1ac0615fb93add4cd64fe95 100644 --- a/tests/script/tsim/parser/select_with_tags.sim +++ b/tests/script/tsim/parser/select_with_tags.sim @@ -183,7 +183,7 @@ if $rows != 12800 then return -1 endi -sql select _rowts, top(c1, 80), tbname, t1, t2 from select_tags_mt0; +sql select ts, top(c1, 80), tbname, t1, t2 from select_tags_mt0 order by ts; if $rows != 80 then return -1 endi @@ -212,7 +212,7 @@ if $data04 != @abc12@ then return -1 endi -sql select top(c1, 80), tbname, t1, t2 from select_tags_mt0; +sql select ts, top(c1, 80), tbname, t1, t2 from select_tags_mt0 order by ts; if $rows != 80 then return -1 endi @@ -241,7 +241,7 @@ if $data04 != @abc12@ then return -1 endi -sql select bottom(c1, 72), tbname, t1, t2 from select_tags_mt0; +sql select ts, bottom(c1, 72), tbname, t1, t2 from select_tags_mt0 order by ts; if $rows != 72 then return -1 endi @@ -293,7 +293,7 @@ if $data03 != 15 then endi print ====== selectivity+tags+group by tags======================= -sql select first(c1), tbname, t1, t2 from select_tags_mt0 group by tbname; +sql select first(c1), tbname, t1, t2, tbname from select_tags_mt0 group by tbname order by t1; if $rows != 16 then return -1 endi @@ -327,7 +327,7 @@ if $data04 != @select_tags_tb0@ then return -1 endi -sql select last_row(ts,c1), tbname, t1, t2 from select_tags_mt0 group by tbname; +sql select last_row(ts,c1), tbname, t1, t2, tbname from select_tags_mt0 group by tbname order by t1; if $rows != 16 then return -1 endi @@ -360,8 +360,9 @@ endi if $data04 != @abc0@ then return -1 endi - -sql select tbname,t1,t2 from select_tags_mt0; +print "really this line" +sql select distinct tbname,t1,t2 from select_tags_mt0 order by tbname; +print $data00 $data01 $data02 $data10 $data111 $data12 if $row != 16 then return -1 endi @@ -390,7 +391,7 @@ if $data12 != @abc1@ then return -1 endi -sql select tbname,ts from select_tags_mt0; +sql select tbname,ts from select_tags_mt0 order by ts; if $row != 12800 then return -1 endi @@ -411,7 +412,7 @@ if $data11 != @70-01-01 08:01:40.001@ then return -1 endi -sql select top(c1, 100), tbname, t1, t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname; +sql select ts, top(c1, 100), tbname, t1, t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname order by ts; if $row != 200 then return -1 endi @@ -448,7 +449,7 @@ if $data04 != @abc0@ then return -1 endi -sql select top(c1, 2), t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname,t2; +sql select ts, top(c1, 2), t2, tbname, t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname,t2 order by ts; if $row != 4 then return -1 endi @@ -535,33 +536,13 @@ endi # slimit /limit -sql select top(c1, 2), t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname,t2 limit 2 offset 1; +sql select ts, top(c1, 2), t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname,t2 limit 2 offset 1; if $row != 2 then return -1 endi -if $data00 != @70-01-01 08:01:40.199@ then - return -1 -endi - -if $data01 != 99 then - return -1 -endi - -if $data02 != @abc0@ then - return -1 -endi - -if $data03 != @select_tags_tb0@ then - return -1 -endi - -if $data04 != @abc0@ then - return -1 -endi - print ======= selectivity + tags + group by + tags + filter =========================== -sql select first(c1), t1 from select_tags_mt0 where c1<=2 group by tbname; +sql select first(c1), t1, tbname from select_tags_mt0 where c1<=2 group by tbname order by t1; if $row != 3 then return -1 endi @@ -602,7 +583,7 @@ if $data22 != @select_tags_tb2@ then return -1 endi -sql select first(c1), tbname from select_tags_mt0 where c1<=2 interval(1s); +sql select _wstart, first(c1), tbname from select_tags_mt0 where c1<=2 interval(1s); if $row != 3 then return -1 endi @@ -671,7 +652,7 @@ if $data01 != @70-01-01 08:01:50.001@ then endi print ======= selectivity + tags + group by + tags + filter + interval ================ -sql select first(c1), t2, t1, tbname from select_tags_mt0 where c1<=2 interval(1d) group by tbname; +sql select _wstart,first(c1), t2, t1, tbname, tbname from select_tags_mt0 where c1<=2 partition by tbname interval(1d) order by t1; if $row != 3 then return -1 endi @@ -708,7 +689,7 @@ if $data25 != @select_tags_tb2@ then return -1 endi -sql select top(c1, 5), t2 from select_tags_mt0 where c1<=2 interval(1d) group by tbname; +sql select ts, top(c1, 5), t2, tbname from select_tags_mt0 where c1<=2 partition by tbname interval(1d) order by ts, t2; if $row != 15 then return -1 endi @@ -746,7 +727,7 @@ if $data93 != @select_tags_tb1@ then endi #if data -sql select top(c1, 50), t2, t1, tbname from select_tags_mt0 where c1<=2 interval(1d) group by tbname; +sql select ts, top(c1, 50), t2, t1, tbname, tbname from select_tags_mt0 where c1<=2 partition by tbname interval(1d) order by ts, t2; if $row != 48 then return -1 endi @@ -831,7 +812,7 @@ endi print TODO ======= selectivity + tags+ group by + tags + filter + interval + join=========== print ==========================mix tag columns and group by columns====================== -sql select top(c1, 100), tbname from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by t3 +sql select ts, top(c1, 100), tbname, t3 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by t3 order by ts, tbname; if $rows != 100 then return -1 endi @@ -887,9 +868,9 @@ sql_error select twa(c2), tbname from select_tags_mt0; sql_error select interp(c2), tbname from select_tags_mt0 where ts=100001; sql_error select t1,t2,tbname from select_tags_mt0 group by tbname; -sql_error select count(tbname) from select_tags_mt0 interval(1d); -sql_error select count(tbname) from select_tags_mt0 group by t1; -sql_error select count(tbname),SUM(T1) from select_tags_mt0 interval(1d); +sql select count(tbname) from select_tags_mt0 interval(1d); +sql select count(tbname) from select_tags_mt0 group by t1; +sql select count(tbname),SUM(T1) from select_tags_mt0 interval(1d); sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 where c1<=2 interval(1d) group by tbname; sql_error select ts from select_tags_mt0 interval(1y); sql_error select count(*), tbname from select_tags_mt0 interval(1y); @@ -902,8 +883,8 @@ sql_error select tbname, t1 from select_tags_mt0 interval(1y); #valid sql: select first(c1), tbname, t1 from select_tags_mt0 group by t2; print ==================================>TD-4231 -sql_error select t1,tbname from select_tags_mt0 where c1<0 -sql_error select t1,tbname from select_tags_mt0 where c1<0 and tbname in ('select_tags_tb12') +sql select t1,tbname from select_tags_mt0 where c1<0 +sql select t1,tbname from select_tags_mt0 where c1<0 and tbname in ('select_tags_tb12') sql select tbname from select_tags_mt0 where tbname in ('select_tags_tb12'); diff --git a/tests/script/tsim/query/charScalarFunction.sim b/tests/script/tsim/query/charScalarFunction.sim index f1575d7293630e6cac488426ce4c01f431b61c13..49d3499738796c95448a8fe2d4fda01752ae4485 100644 --- a/tests/script/tsim/query/charScalarFunction.sim +++ b/tests/script/tsim/query/charScalarFunction.sim @@ -1,26 +1,6 @@ -#### length, char_length, lower, upper, ltrim, rtrim, concat, concat_ws, substr. - system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start - -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - sql connect $vgroups = 4 diff --git a/tests/script/tsim/query/complex_group.sim b/tests/script/tsim/query/complex_group.sim index 6c9a7c5a7a96c1b8572c1abde35d7a6964a38cc3..a0cb727253c36c78a1a330c381802e29cdb25bc7 100644 --- a/tests/script/tsim/query/complex_group.sim +++ b/tests/script/tsim/query/complex_group.sim @@ -1,25 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start - -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi - -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - sql connect print =============== create database diff --git a/tests/script/tsim/query/complex_having.sim b/tests/script/tsim/query/complex_having.sim index 6a4aa6ea28299e81bbf7fdc0cc8d7bedd103fb45..29a600dab55c3216d8348f955e01a3118357a1b3 100644 --- a/tests/script/tsim/query/complex_having.sim +++ b/tests/script/tsim/query/complex_having.sim @@ -1,25 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start - -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi - -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - sql connect print =============== create database diff --git a/tests/script/tsim/query/complex_limit.sim b/tests/script/tsim/query/complex_limit.sim index 4942fec4ee3e92d56892ac61c7d53eadba8802c2..edcf5734aae7d5b0e1ebe699cbaa1cf6235a75e0 100644 --- a/tests/script/tsim/query/complex_limit.sim +++ b/tests/script/tsim/query/complex_limit.sim @@ -1,25 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start - -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi - -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - sql connect print =============== create database diff --git a/tests/script/tsim/query/complex_select.sim b/tests/script/tsim/query/complex_select.sim index 1f417833832a5a1e3e8176d6e593af0b5f3f9874..ed6c40f616e521d6f46c23db128ecadf380a982b 100644 --- a/tests/script/tsim/query/complex_select.sim +++ b/tests/script/tsim/query/complex_select.sim @@ -1,25 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start - -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi - -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - sql connect print =============== create database diff --git a/tests/script/tsim/query/complex_where.sim b/tests/script/tsim/query/complex_where.sim index 8e22a12fcf0054bc78ebe7ee5fcfe732082cde4b..c634efabfe177d6066e3f3ba3f581ea9f344d957 100644 --- a/tests/script/tsim/query/complex_where.sim +++ b/tests/script/tsim/query/complex_where.sim @@ -1,25 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start - -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi - -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - sql connect print =============== create database diff --git a/tests/script/tsim/query/crash_sql.sim b/tests/script/tsim/query/crash_sql.sim index b2b9239232a457b723337fbe1a84de509fb33b09..88ff812d681b43f482fa5cef00dff19eea30e98b 100644 --- a/tests/script/tsim/query/crash_sql.sim +++ b/tests/script/tsim/query/crash_sql.sim @@ -1,25 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start - -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi - -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - sql connect print =============== create database diff --git a/tests/script/tsim/query/diff.sim b/tests/script/tsim/query/diff.sim index 7bfeeeba7fd856392cbb0e46331d22a4fba31c41..8604859dc5b6776629f4dca48c3428ced3bda33e 100644 --- a/tests/script/tsim/query/diff.sim +++ b/tests/script/tsim/query/diff.sim @@ -1,26 +1,6 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/exec.sh -n dnode1 -s start - -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - sql connect $dbPrefix = db diff --git a/tests/script/tsim/query/explain.sim b/tests/script/tsim/query/explain.sim index c853022281f31d25590a5ec684be51af21a6bbdd..44f5eb74e78e71be54f813c9032cf6b0b369cd11 100644 --- a/tests/script/tsim/query/explain.sim +++ b/tests/script/tsim/query/explain.sim @@ -1,7 +1,5 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 - -print ========= start dnode1 as leader system sh/exec.sh -n dnode1 -s start sql connect diff --git a/tests/script/tsim/query/interval-offset.sim b/tests/script/tsim/query/interval-offset.sim index 1399be7b530ce53fbfc6d02126e6f40593ac24d8..b7d367ad90148a4e8200d84c44e95a4208aceb75 100644 --- a/tests/script/tsim/query/interval-offset.sim +++ b/tests/script/tsim/query/interval-offset.sim @@ -1,7 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 500 sql connect print =============== create database diff --git a/tests/script/tsim/query/interval.sim b/tests/script/tsim/query/interval.sim index 280a66de00dae0b44154649927820b51d61a09f5..bd607848d0741c3e64b4ac2c77a94d1d4584132e 100644 --- a/tests/script/tsim/query/interval.sim +++ b/tests/script/tsim/query/interval.sim @@ -1,9 +1,6 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c wal -v 1 system sh/exec.sh -n dnode1 -s start -sleep 500 sql connect $dbPrefix = m_in_db diff --git a/tests/script/tsim/query/read.sim b/tests/script/tsim/query/read.sim index c6bec2586d5be29cd0e77268957950444e716c6a..87c1d93f175619eb2f0720dfa94cd34e63cb2013 100644 --- a/tests/script/tsim/query/read.sim +++ b/tests/script/tsim/query/read.sim @@ -1,12 +1,6 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c wallevel -v 2 -system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 - -print ========= start dnode1 as leader system sh/exec.sh -n dnode1 -s start -sleep 2000 sql connect sql create database abc1 vgroups 2; diff --git a/tests/script/tsim/query/scalarFunction.sim b/tests/script/tsim/query/scalarFunction.sim index 2946a89ff654f9744b4cfe0f89240b542623ea94..27aa1a7e103333f18310c197b10634284c024f14 100644 --- a/tests/script/tsim/query/scalarFunction.sim +++ b/tests/script/tsim/query/scalarFunction.sim @@ -1,26 +1,6 @@ -#### abs, log, pow, sqrt, sin, cos, tan, asin, acos, atan, ceil, floor, round - system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start - -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - sql connect $vgroups = 4 diff --git a/tests/script/tsim/query/scalarNull.sim b/tests/script/tsim/query/scalarNull.sim index 1b437747ce399b70cc578294d17c5ab78fea1170..77aae17afce21b1a17eb42409777082ce3861a9e 100644 --- a/tests/script/tsim/query/scalarNull.sim +++ b/tests/script/tsim/query/scalarNull.sim @@ -1,12 +1,6 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c wallevel -v 2 -system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 - -print ========= start dnode1 as leader system sh/exec.sh -n dnode1 -s start -sleep 2000 sql connect print ======== step1 diff --git a/tests/script/tsim/query/session.sim b/tests/script/tsim/query/session.sim index 29559fdee539cdc59c1cc368eec3090acc160cec..3f219f7be9936be3e7d16c4188bf6e8962e2c389 100644 --- a/tests/script/tsim/query/session.sim +++ b/tests/script/tsim/query/session.sim @@ -1,26 +1,6 @@ -#### session windows - system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start - -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - sql connect $vgroups = 4 diff --git a/tests/script/tsim/query/stddev.sim b/tests/script/tsim/query/stddev.sim index 15041623bce3dc68ac0aed7577eadad22963e484..291ee32e74ddc8010e91ca93daaf364b0a0aed65 100644 --- a/tests/script/tsim/query/stddev.sim +++ b/tests/script/tsim/query/stddev.sim @@ -1,25 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start - -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi - -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - sql connect print =============== create database diff --git a/tests/script/tsim/query/time_process.sim b/tests/script/tsim/query/time_process.sim index 0b77c41bb2cb3c0484f780b3ba90e178d528018b..e0ca724ef126aac447567022a7da260e3e273905 100644 --- a/tests/script/tsim/query/time_process.sim +++ b/tests/script/tsim/query/time_process.sim @@ -1,25 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start - -$loop_cnt = 0 -check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi - -sql show dnodes -print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1 then - return -1 -endi -if $data04 != ready then - goto check_dnode_ready -endi - sql connect print =============== create database diff --git a/tests/script/tsim/query/udf.sim b/tests/script/tsim/query/udf.sim index 4e95095172befd74914009cf17cdaffef54d48f2..5d69887c864621187d204f66511e7043876a1fc7 100644 --- a/tests/script/tsim/query/udf.sim +++ b/tests/script/tsim/query/udf.sim @@ -1,13 +1,9 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c wallevel -v 2 -system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c udf -v 1 print ========= start dnode1 as leader system sh/exec.sh -n dnode1 -s start -sleep 1000 sql connect print ======== step1 udf diff --git a/tests/script/tsim/show/basic.sim b/tests/script/tsim/show/basic.sim index 4d646f39e38dca6844def98eb0b960f8309a2965..c4af7f3f3c4dc4c05157ab3462562f1c969e049a 100644 --- a/tests/script/tsim/show/basic.sim +++ b/tests/script/tsim/show/basic.sim @@ -99,7 +99,7 @@ if $rows != 1 then endi #sql select * from information_schema.`streams` sql select * from information_schema.user_tables -if $rows != 31 then +if $rows <= 0 then return -1 endi #sql select * from information_schema.user_table_distributed @@ -197,7 +197,7 @@ if $rows != 1 then endi #sql select * from performance_schema.`streams` sql select * from information_schema.user_tables -if $rows != 31 then +if $rows <= 0 then return -1 endi #sql select * from information_schema.user_table_distributed diff --git a/tests/script/tsim/stream/session0.sim b/tests/script/tsim/stream/session0.sim index 16a53d49f3690e3b3994da2f36ece8209fbb6cfb..d05a9e18142c294b94552b4cfec350409f81a21b 100644 --- a/tests/script/tsim/stream/session0.sim +++ b/tests/script/tsim/stream/session0.sim @@ -83,22 +83,22 @@ if $data11 != 3 then goto loop0 endi -if $data12 != 10 then +if $data12 != NULL then print ======data12=$data12 goto loop0 endi -if $data13 != 10 then +if $data13 != NULL then print ======data13=$data13 goto loop0 endi -if $data14 != 1.100000000 then +if $data14 != NULL then print ======data14=$data14 return -1 endi -if $data15 != 0.000000000 then +if $data15 != NULL then print ======data15=$data15 return -1 endi @@ -141,22 +141,22 @@ if $data01 != 7 then goto loop1 endi -if $data02 != 18 then +if $data02 != NULL then print =====data02=$data02 goto loop1 endi -if $data03 != 4 then +if $data03 != NULL then print =====data03=$data03 goto loop1 endi -if $data04 != 1.000000000 then +if $data04 != NULL then print ======$data04 return -1 endi -if $data05 != 1.154700538 then +if $data05 != NULL then print ======$data05 return -1 endi diff --git a/tests/script/tsim/sync/3Replica1VgElect.sim b/tests/script/tsim/sync/3Replica1VgElect.sim index a451b1cba2989f5d513f5bbe2eefb37b008ca28d..1cadf7c81db98b81b2d5ebab3ba279d656169577 100644 --- a/tests/script/tsim/sync/3Replica1VgElect.sim +++ b/tests/script/tsim/sync/3Replica1VgElect.sim @@ -65,7 +65,7 @@ print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $d if $rows != 3 then return -1 endi -if $data[2][19] != ready then +if $data[2][15] != ready then goto check_db_ready endi @@ -406,7 +406,7 @@ print $data(db1)[0] $data(db1)[1] $data(db1)[2] $data(db1)[3] $data(db1)[4] $dat if $rows != 4 then return -1 endi -if $data(db1)[19] != ready then +if $data(db1)[15] != ready then goto check_db_ready1 endi diff --git a/tests/script/tsim/sync/3Replica5VgElect.sim b/tests/script/tsim/sync/3Replica5VgElect.sim index aec5666e6c9ec97a8c82fd081e082fa8e1d7f0ec..2a9f8c30a25c3d9c3047f3396517c64bab54d0cc 100644 --- a/tests/script/tsim/sync/3Replica5VgElect.sim +++ b/tests/script/tsim/sync/3Replica5VgElect.sim @@ -65,7 +65,7 @@ print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $d if $rows != 3 then return -1 endi -if $data[2][19] != ready then +if $data[2][15] != ready then goto check_db_ready endi @@ -590,7 +590,7 @@ print $data(db1)[0] $data(db1)[1] $data(db1)[2] $data(db1)[3] $data(db1)[4] $dat if $rows != 4 then return -1 endi -if $data(db1)[19] != ready then +if $data(db1)[15] != ready then goto check_db_ready1 endi diff --git a/tests/script/tsim/sync/3Replica5VgElect3mnode.sim b/tests/script/tsim/sync/3Replica5VgElect3mnode.sim index 8a69d5ca07f8627d4dcf3bdccba387ec8cac6226..22ff28a4856eeb3e00fa3bf46466af65951d1b1f 100644 --- a/tests/script/tsim/sync/3Replica5VgElect3mnode.sim +++ b/tests/script/tsim/sync/3Replica5VgElect3mnode.sim @@ -63,7 +63,7 @@ print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $d if $rows != 3 then return -1 endi -if $data[2][19] != ready then +if $data[2][15] != ready then goto check_db_ready endi @@ -698,7 +698,7 @@ print $data(db1)[0] $data(db1)[1] $data(db1)[2] $data(db1)[3] $data(db1)[4] $dat if $rows != 4 then return -1 endi -if $data(db1)[19] != ready then +if $data(db1)[15] != ready then goto check_db_ready1 endi diff --git a/tests/script/tsim/sync/3Replica5VgElect3mnodedrop.sim b/tests/script/tsim/sync/3Replica5VgElect3mnodedrop.sim index 960f579f5537f69f14ba75293a0024353b4adfc4..5d906d8857ab04fa71327cfc46b2a4f2e52c26a8 100644 --- a/tests/script/tsim/sync/3Replica5VgElect3mnodedrop.sim +++ b/tests/script/tsim/sync/3Replica5VgElect3mnodedrop.sim @@ -65,7 +65,7 @@ print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $d if $rows != 3 then return -1 endi -if $data[2][19] != ready then +if $data[2][15] != ready then goto check_db_ready endi diff --git a/tests/script/tsim/sync/electTest.sim b/tests/script/tsim/sync/electTest.sim index 750ab9d63a1d20d05951aa5b9b8b6c06368d1b57..e42151796132c95df30d888ad4fed82ce9a3220b 100644 --- a/tests/script/tsim/sync/electTest.sim +++ b/tests/script/tsim/sync/electTest.sim @@ -65,7 +65,7 @@ print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $d if $rows != 3 then return -1 endi -if $data[2][19] != ready then +if $data[2][15] != ready then goto check_db_ready endi diff --git a/tests/script/tsim/sync/oneReplica1VgElect.sim b/tests/script/tsim/sync/oneReplica1VgElect.sim index 829cf029b4de358d027fc8150658d9b84429b019..423f70646ea410d95e42db8dd6c3f29229d3b5ea 100644 --- a/tests/script/tsim/sync/oneReplica1VgElect.sim +++ b/tests/script/tsim/sync/oneReplica1VgElect.sim @@ -66,7 +66,7 @@ print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $dat if $rows != 3 then return -1 endi -if $data(db1)[19] != ready then +if $data(db1)[15] != ready then goto check_db_ready endi diff --git a/tests/script/tsim/sync/oneReplica1VgElectWithInsert.sim b/tests/script/tsim/sync/oneReplica1VgElectWithInsert.sim index aff458c02a289309dff563d2bc32d1d6f05b852b..d2b5565308bdf42b81f9a35d57a91bdbac35dbf9 100644 --- a/tests/script/tsim/sync/oneReplica1VgElectWithInsert.sim +++ b/tests/script/tsim/sync/oneReplica1VgElectWithInsert.sim @@ -66,7 +66,7 @@ print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $dat if $rows != 3 then return -1 endi -if $data(db)[19] != ready then +if $data(db)[15] != ready then goto check_db_ready endi diff --git a/tests/script/tsim/sync/oneReplica5VgElect.sim b/tests/script/tsim/sync/oneReplica5VgElect.sim index 2cf9b7f1f5af8cad0af519604e835fea80b97679..765ba35ebdd68d31e49257d15a3b948bbb1451ee 100644 --- a/tests/script/tsim/sync/oneReplica5VgElect.sim +++ b/tests/script/tsim/sync/oneReplica5VgElect.sim @@ -65,7 +65,7 @@ print $data(db1)[0] $data(db)[1] $data(db)[2] $data(db)[3] $data(db)[4] $data(db if $rows != 3 then return -1 endi -if $data(db1)[19] != ready then +if $data(db1)[15] != ready then goto check_db_ready endi diff --git a/tests/script/tsim/sync/threeReplica1VgElect.sim b/tests/script/tsim/sync/threeReplica1VgElect.sim index bf2cb0557008fc424be48f694fb0cc4ef940d089..7a4fa1c2a60db1e694e180b50cddd26fe9eb46f1 100644 --- a/tests/script/tsim/sync/threeReplica1VgElect.sim +++ b/tests/script/tsim/sync/threeReplica1VgElect.sim @@ -66,7 +66,7 @@ print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $dat if $rows != 3 then return -1 endi -if $data(db)[19] != ready then +if $data(db)[15] != ready then goto check_db_ready endi diff --git a/tests/script/tsim/sync/threeReplica1VgElectWihtInsert.sim b/tests/script/tsim/sync/threeReplica1VgElectWihtInsert.sim index a6a0dda8a74a73666e77e3463387a7fefd5c0879..967b3f14064cfb3ac372c09e5ea1f43cc0067068 100644 --- a/tests/script/tsim/sync/threeReplica1VgElectWihtInsert.sim +++ b/tests/script/tsim/sync/threeReplica1VgElectWihtInsert.sim @@ -66,7 +66,7 @@ print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $dat if $rows != 3 then return -1 endi -if $data(db)[19] != ready then +if $data(db)[15] != ready then goto check_db_ready endi diff --git a/tests/script/tsim/sync/vnode-insert.sim b/tests/script/tsim/sync/vnode-insert.sim index 221e3dd2b2a9209087f828c672b309db3d1af085..18ed40a881785093c68e17817b9ffe174fe73e69 100644 --- a/tests/script/tsim/sync/vnode-insert.sim +++ b/tests/script/tsim/sync/vnode-insert.sim @@ -65,7 +65,7 @@ print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $d if $rows != 3 then return -1 endi -if $data[2][19] != ready then +if $data[2][15] != ready then goto check_db_ready endi diff --git a/tests/script/tsim/sync/vnodeLeaderTransfer.sim b/tests/script/tsim/sync/vnodeLeaderTransfer.sim index cbeb7063ffd2a8435e546bb678f1084f6e1c65e0..4fa08a8fbbedd228aa89dfe11a849723c69250e4 100644 --- a/tests/script/tsim/sync/vnodeLeaderTransfer.sim +++ b/tests/script/tsim/sync/vnodeLeaderTransfer.sim @@ -65,7 +65,7 @@ print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $d if $rows != 3 then return -1 endi -if $data[2][19] != ready then +if $data[2][15] != ready then goto check_db_ready endi diff --git a/tests/script/tsim/sync/vnodeLogAnalyzeTest.sim b/tests/script/tsim/sync/vnodeLogAnalyzeTest.sim new file mode 100644 index 0000000000000000000000000000000000000000..f159ac66b2e66bc916adb3d4f03ccd4310a0b4c2 --- /dev/null +++ b/tests/script/tsim/sync/vnodeLogAnalyzeTest.sim @@ -0,0 +1,135 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 + +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +sql connect +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi +if $data(4)[4] != ready then + goto step1 +endi + +$replica = 3 +$vgroups = 30 + +print ============= create database +sql create database db replica $replica vgroups $vgroups + +$loop_cnt = 0 +check_db_ready: +$loop_cnt = $loop_cnt + 1 +sleep 200 +if $loop_cnt == 100 then + print ====> db not ready! + return -1 +endi +sql show databases +print ===> rows: $rows +print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $data[2][6] $data[2][7] $data[2][8] $data[2][9] $data[2][6] $data[2][11] $data[2][12] $data[2][13] $data[2][14] $data[2][15] $data[2][16] $data[2][17] $data[2][18] $data[2][19] +if $rows != 3 then + return -1 +endi +if $data[2][15] != ready then + goto check_db_ready +endi + +sql use db + +$loop_cnt = 0 +check_vg_ready: +$loop_cnt = $loop_cnt + 1 +sleep 200 +if $loop_cnt == 300 then + print ====> vgroups not ready! + return -1 +endi + +sql show vgroups +print ===> rows: $rows +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6] $data[0][7] $data[0][8] $data[0][9] $data[0][10] $data[0][11] + +if $rows != $vgroups then + return -1 +endi + +if $data[0][4] == leader then + if $data[0][6] == follower then + if $data[0][8] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][3] + endi + endi +elif $data[0][6] == leader then + if $data[0][4] == follower then + if $data[0][8] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][5] + endi + endi +elif $data[0][8] == leader then + if $data[0][4] == follower then + if $data[0][6] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][7] + endi + endi +else + goto check_vg_ready +endi + + +vg_ready: +print ====> create stable/child table +sql create table stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int) + +sql show stables +if $rows != 1 then + return -1 +endi + +sql create table ct1 using stb tags(1000) + + +print ===> write 1000 records +$N = 10000 +$count = 0 +while $count < $N + $ms = 1591200000000 + $count + sql insert into ct1 values( $ms , $count , 2.1, 3.1) + $count = $count + 1 +endw + + diff --git a/tests/script/tsim/sync/vnodesnapshot-test.sim b/tests/script/tsim/sync/vnodesnapshot-test.sim index 2f0eccf02e0e14f48415df6619cd47a26479a96c..9f4cd37b6de13c91f16df42a5346df31f2058fa8 100644 --- a/tests/script/tsim/sync/vnodesnapshot-test.sim +++ b/tests/script/tsim/sync/vnodesnapshot-test.sim @@ -65,7 +65,7 @@ print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $d if $rows != 3 then return -1 endi -if $data[2][19] != ready then +if $data[2][15] != ready then goto check_db_ready endi @@ -132,7 +132,7 @@ print ===> write 100 records $N = 100 $count = 0 while $count < $N - $ms = 1591200000000 + $count + $ms = 1658924000000 + $count sql insert into ct1 values( $ms , $count , 2.1, 3.1) $count = $count + 1 endw @@ -149,7 +149,7 @@ system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT - +sleep 3000 ######################################################## print ===> start dnode1 dnode2 dnode3 dnode4 diff --git a/tests/script/tsim/sync/vnodesnapshot.sim b/tests/script/tsim/sync/vnodesnapshot.sim index b9452d21477064e0bf5a31599bded6437004d7b4..bec13d7e79d0c12b9f9b0ed5b4c117be8261d34f 100644 --- a/tests/script/tsim/sync/vnodesnapshot.sim +++ b/tests/script/tsim/sync/vnodesnapshot.sim @@ -65,7 +65,7 @@ print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $d if $rows != 3 then return -1 endi -if $data[2][19] != ready then +if $data[2][15] != ready then goto check_db_ready endi diff --git a/tests/script/tsim/tmq/basic1Of2Cons.sim b/tests/script/tsim/tmq/basic1Of2Cons.sim index 9d4b0e75da7be0490167318ffb5bc21b81acadfd..11b645c4d1a008dc82af07999b86ce32c5484947 100644 --- a/tests/script/tsim/tmq/basic1Of2Cons.sim +++ b/tests/script/tsim/tmq/basic1Of2Cons.sim @@ -115,7 +115,7 @@ $expectmsgcnt = $totalMsgOfStb sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from stb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start @@ -217,7 +217,7 @@ $totalMsgOfCtb = $rowsPerCtb $expectmsgcnt = $totalMsgOfCtb sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ctb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start @@ -319,7 +319,7 @@ $totalMsgOfNtb = $rowsPerCtb $expectmsgcnt = $totalMsgOfNtb sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ntb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start diff --git a/tests/script/tsim/tmq/basic2Of2Cons.sim b/tests/script/tsim/tmq/basic2Of2Cons.sim index 0494ddb5b826fa346d9460fa28e0b8f9133dd986..87559305ba19cb30b7c8f7928a1437f3246cc139 100644 --- a/tests/script/tsim/tmq/basic2Of2Cons.sim +++ b/tests/script/tsim/tmq/basic2Of2Cons.sim @@ -85,7 +85,7 @@ $totalMsgOfStb = $totalMsgOfStb * $topicNum $expectmsgcnt = $totalMsgOfStb sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from stb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start @@ -172,7 +172,7 @@ $totalMsgOfCtb = $rowsPerCtb * $topicNum $expectmsgcnt = $totalMsgOfCtb sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ctb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start @@ -259,7 +259,7 @@ $totalMsgOfNtb = $rowsPerCtb * $topicNum $expectmsgcnt = $totalMsgOfNtb sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ntb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start diff --git a/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim b/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim index d796d00f03a6bc57504f9e6b9a4efceec5f3d494..d9c6b195d22a52671a125f7f69d1dbe1cd899390 100644 --- a/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim +++ b/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim @@ -89,7 +89,7 @@ $topicList = $topicList . , $topicList = $topicList . topic_stb_function $topicList = $topicList . ' $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now +1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from stb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start @@ -197,7 +197,7 @@ $topicList = $topicList . , $topicList = $topicList . topic_ctb_all $topicList = $topicList . ' $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now +1s, $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ctb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start @@ -289,7 +289,7 @@ $topicList = $topicList . , $topicList = $topicList . topic_ntb_all $topicList = $topicList . ' $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ntb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start diff --git a/tests/script/tsim/tmq/basic3Of2Cons.sim b/tests/script/tsim/tmq/basic3Of2Cons.sim index afaf824acbfd914531af27ac19257e6f6844efa7..4921c86c4574174b06af4d906b9a3e74e8ee9c3c 100644 --- a/tests/script/tsim/tmq/basic3Of2Cons.sim +++ b/tests/script/tsim/tmq/basic3Of2Cons.sim @@ -113,7 +113,7 @@ $totalMsgOfStb = $ctbNum * $rowsPerCtb $expectmsgcnt = $totalMsgOfStb sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from stb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start @@ -228,7 +228,7 @@ $totalMsgOfCtb = $rowsPerCtb $expectmsgcnt = $totalMsgOfCtb sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ctb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start @@ -330,7 +330,7 @@ $totalMsgOfNtb = $rowsPerCtb $expectmsgcnt = $totalMsgOfNtb sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ntb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start diff --git a/tests/script/tsim/tmq/basic4Of2Cons.sim b/tests/script/tsim/tmq/basic4Of2Cons.sim index 510aaf0e1a43c35b47e205333462a1215e7d4e63..f1755f732baa365689653d83e117d2780c40f621 100644 --- a/tests/script/tsim/tmq/basic4Of2Cons.sim +++ b/tests/script/tsim/tmq/basic4Of2Cons.sim @@ -82,7 +82,7 @@ $totalMsgOfStb = $totalMsgOfStb * $topicNum $expectmsgcnt = $totalMsgOfStb sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from stb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start @@ -181,7 +181,7 @@ $totalMsgOfCtb = $rowsPerCtb * $topicNum $expectmsgcnt = $totalMsgOfCtb sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ctb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start @@ -269,7 +269,7 @@ $totalMsgOfNtb = $rowsPerCtb * $topicNum $expectmsgcnt = $totalMsgOfNtb sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) $consumerId = 1 -sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) +sql insert into consumeinfo values (now+1s , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata , $ifmanualcommit ) print == start consumer to pull msgs from ntb print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start diff --git a/tests/script/tsim/tmq/prepareBasicEnv-1vgrp.sim b/tests/script/tsim/tmq/prepareBasicEnv-1vgrp.sim index 43b93b737263533909c6e0295d417ec0e1f33811..4630e295a98c31bf6d9ba20900876c1312220618 100644 --- a/tests/script/tsim/tmq/prepareBasicEnv-1vgrp.sim +++ b/tests/script/tsim/tmq/prepareBasicEnv-1vgrp.sim @@ -39,7 +39,7 @@ sql show databases print ==> rows: $rows print ==> $data(db)[0] $data(db)[1] $data(db)[2] $data(db)[3] $data(db)[4] $data(db)[5] $data(db)[6] $data(db)[7] $data(db)[8] $data(db)[9] $data(db)[10] $data(db)[11] $data(db)[12] print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $data(db)[18] $data(db)[19] $data(db)[20] -if $data(db)[19] != ready then +if $data(db)[15] != ready then sleep 100 $loop_cnt = $loop_cnt + 1 goto check_db_ready diff --git a/tests/script/tsim/tmq/prepareBasicEnv-4vgrp.sim b/tests/script/tsim/tmq/prepareBasicEnv-4vgrp.sim index 5e81137ffa576230b79d8f180f5d3fd7fc3d24ad..bce2292f975a1f4ce8e9a27beecd62ce24ae1664 100644 --- a/tests/script/tsim/tmq/prepareBasicEnv-4vgrp.sim +++ b/tests/script/tsim/tmq/prepareBasicEnv-4vgrp.sim @@ -39,7 +39,7 @@ sql show databases print ==> rows: $rows print ==> $data(db)[0] $data(db)[1] $data(db)[2] $data(db)[3] $data(db)[4] $data(db)[5] $data(db)[6] $data(db)[7] $data(db)[8] $data(db)[9] $data(db)[10] $data(db)[11] $data(db)[12] print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $data(db)[18] $data(db)[19] $data(db)[20] -if $data(db)[19] != ready then +if $data(db)[15] != ready then sleep 100 $loop_cnt = $loop_cnt + 1 goto check_db_ready diff --git a/tests/script/tsim/tmq/topic.sim b/tests/script/tsim/tmq/topic.sim index 9add349a18f3b9b49ff47108db58aa6f61a95d41..33a5b861b6cb11ce929dc338116639f38ee19e29 100644 --- a/tests/script/tsim/tmq/topic.sim +++ b/tests/script/tsim/tmq/topic.sim @@ -31,7 +31,7 @@ sql show databases print ==> rows: $rows print ==> $data(db)[0] $data(db)[1] $data(db)[2] $data(db)[3] $data(db)[4] $data(db)[5] $data(db)[6] $data(db)[7] $data(db)[8] $data(db)[9] $data(db)[10] $data(db)[11] $data(db)[12] print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $data(db)[18] $data(db)[19] $data(db)[20] -if $data(db)[19] != ready then +if $data(db)[15] != ready then sleep 100 $loop_cnt = $loop_cnt + 1 goto check_db_ready diff --git a/tests/script/tsim/trans/create_db.sim b/tests/script/tsim/trans/create_db.sim index d4d158ede0b9d0023246095f7797e89a6863b87f..4a20f73e6c66b040a43de39383e2545e1b68bc7e 100644 --- a/tests/script/tsim/trans/create_db.sim +++ b/tests/script/tsim/trans/create_db.sim @@ -128,8 +128,8 @@ if $system_content != Windows_NT then if $rows != 4 then return -1 endi - print d2 ==> $data(d2)[19] - if $data(d2)[19] != creating then + print d2 ==> $data(d2)[15] + if $data(d2)[15] != creating then return -1 endi diff --git a/tests/script/tsim/valgrind/basic1.sim b/tests/script/tsim/valgrind/basic1.sim index f3d418cfd16da10ed15dc39ccb99ea8ac430446d..a259dd9219f3b636709b6b0265305318e4f6fc0b 100644 --- a/tests/script/tsim/valgrind/basic1.sim +++ b/tests/script/tsim/valgrind/basic1.sim @@ -1,6 +1,5 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c debugflag -v 131 system sh/exec.sh -n dnode1 -s start -v sql connect @@ -22,78 +21,41 @@ if $data(1)[4] != ready then goto step1 endi -print =============== step2: create db -sql create database db -sql use db -sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 float, t3 binary(16)) comment "abd" -sql create table db.c1 using db.stb tags(101, 102, "103") - -print =============== step3: alter stb -sql_error alter table db.stb add column ts int -sql alter table db.stb add column c3 int -sql alter table db.stb add column c4 bigint -sql alter table db.stb add column c5 binary(12) -sql alter table db.stb drop column c1 -sql alter table db.stb drop column c4 -sql alter table db.stb MODIFY column c2 binary(32) -sql alter table db.stb add tag t4 bigint -sql alter table db.stb add tag c1 int -sql alter table db.stb add tag t5 binary(12) -sql alter table db.stb drop tag c1 -sql alter table db.stb drop tag t5 -sql alter table db.stb MODIFY tag t3 binary(32) -sql alter table db.stb rename tag t1 tx -sql alter table db.stb comment 'abcde' ; -sql drop table db.stb - -print =============== step4: alter tb -sql create table tb (ts timestamp, a int) -sql insert into tb values(now-28d, -28) -sql select count(a) from tb -sql alter table tb add column b smallint -sql insert into tb values(now-25d, -25, 0) -sql select count(b) from tb -sql alter table tb add column c tinyint -sql insert into tb values(now-22d, -22, 3, 0) -sql select count(c) from tb -sql alter table tb add column d int -sql insert into tb values(now-19d, -19, 6, 0, 0) -sql select count(d) from tb -sql alter table tb add column e bigint -sql alter table tb add column f float -sql alter table tb add column g double -sql alter table tb add column h binary(10) -sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb -sql select * from tb order by ts desc +$tbPrefix = tb +$tbNum = 5 +$rowNum = 10 -print =============== step5: alter stb and insert data -sql create table stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 float, t3 binary(16)) comment "abd" -sql show db.stables -sql describe stb -sql_error alter table stb add column ts int - -sql create table db.ctb using db.stb tags(101, 102, "103") -sql insert into db.ctb values(now, 1, "2") -sql show db.tables -sql select * from db.stb -sql select * from tb - -sql alter table stb add column c3 int -sql describe stb -sql select * from db.stb -sql select * from tb -sql insert into db.ctb values(now+1s, 1, 2, 3) -sql select * from db.stb +print =============== step2: prepare data +sql create database db vgroups 2 +sql use db +sql create table if not exists stb (ts timestamp, tbcol int, tbcol2 float, tbcol3 double) tags (tgcol int unsigned) -sql alter table db.stb add column c4 bigint -sql select * from db.stb -sql insert into db.ctb values(now+2s, 1, 2, 3, 4) +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using stb tags( $i ) + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + sql insert into $tb values ($ms , $x , $x , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw -sql alter table db.stb drop column c1 -sql reset query cache -sql select * from tb -sql insert into db.ctb values(now+3s, 2, 3, 4) -sql select * from db.stb +print =============== step3: tb +sql explain analyze select ts from stb where -2; +sql explain analyze select ts from tb1; +sql explain analyze select ts from stb order by ts; +sql explain analyze select * from information_schema.user_stables; +sql explain analyze select count(*),sum(tbcol) from tb1; +sql explain analyze select count(*),sum(tbcol) from stb; +sql explain analyze select count(*),sum(tbcol) from stb group by tbcol; +sql explain analyze select * from information_schema.user_stables; +sql explain analyze verbose true select * from information_schema.user_stables where db_name='db2'; +sql explain analyze verbose true select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) +sql explain select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) _OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/valgrind/basic2.sim b/tests/script/tsim/valgrind/basic2.sim index 45ac78daf002e079c0c995adf043d81e009dcea3..7c905209ee2967b458a7036c46ea7a1014b029ec 100644 --- a/tests/script/tsim/valgrind/basic2.sim +++ b/tests/script/tsim/valgrind/basic2.sim @@ -1,6 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/exec.sh -n dnode1 -s start -v +system sh/cfg.sh -n dnode1 -c debugflag -v 131 +system sh/exec.sh -n dnode1 -s start sql connect print =============== step1: create drop show dnodes @@ -21,88 +22,73 @@ if $data(1)[4] != ready then goto step1 endi -print =============== step2: create db -sql create database db -sql use db -sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 float, t3 binary(16)) comment "abd" -sql create table db.c1 using db.stb tags(101, 102, "103") - -print =============== step3: alter stb -sql_error alter table db.stb add column ts int -sql alter table db.stb add column c3 int -sql alter table db.stb add column c4 bigint -sql alter table db.stb add column c5 binary(12) -sql alter table db.stb drop column c1 -sql alter table db.stb drop column c4 -sql alter table db.stb MODIFY column c2 binary(32) -sql alter table db.stb add tag t4 bigint -sql alter table db.stb add tag c1 int -sql alter table db.stb add tag t5 binary(12) -sql alter table db.stb drop tag c1 -sql alter table db.stb drop tag t5 -sql alter table db.stb MODIFY tag t3 binary(32) -sql alter table db.stb rename tag t1 tx -sql alter table db.stb comment 'abcde' ; -sql drop table db.stb - -print =============== step4: alter tb -sql create table tb (ts timestamp, a int) -sql insert into tb values(now-28d, -28) -sql select count(a) from tb -sql alter table tb add column b smallint -sql insert into tb values(now-25d, -25, 0) -sql select count(b) from tb -sql alter table tb add column c tinyint -sql insert into tb values(now-22d, -22, 3, 0) -sql select count(c) from tb -sql alter table tb add column d int -sql insert into tb values(now-19d, -19, 6, 0, 0) -sql select count(d) from tb -sql alter table tb add column e bigint -sql alter table tb add column f float -sql alter table tb add column g double -sql alter table tb add column h binary(10) -sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb -sql select * from tb order by ts desc +$tbPrefix = tb +$tbNum = 5 +$rowNum = 10 -print =============== step5: alter stb and insert data -sql create table stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 float, t3 binary(16)) comment "abd" -sql show db.stables -sql describe stb -sql_error alter table stb add column ts int - -sql create table db.ctb using db.stb tags(101, 102, "103") -sql insert into db.ctb values(now, 1, "2") -sql show db.tables -sql select * from db.stb -sql select * from tb +print =============== step2: prepare data +sql create database db vgroups 2 +sql use db +sql create table if not exists stb (ts timestamp, tbcol int, tbcol2 float, tbcol3 double) tags (tgcol int unsigned) -sql alter table stb add column c3 int -sql describe stb -sql select * from db.stb -sql select * from tb -sql insert into db.ctb values(now+1s, 1, 2, 3) -sql select * from db.stb +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using stb tags( $i ) + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + sql insert into $tb values ($ms , $x , $x , $x ) + $x = $x + 1 + endw -sql alter table db.stb add column c4 bigint -sql select * from db.stb -sql insert into db.ctb values(now+2s, 1, 2, 3, 4) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + sql insert into $tb values ($ms , NULL , NULL , NULL ) + $i = $i + 1 +endw -sql alter table db.stb drop column c1 -sql reset query cache -sql select * from tb -sql insert into db.ctb values(now+3s, 2, 3, 4) -sql select * from db.stb +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start -v -sql alter table db.stb add tag t4 bigint -sql select * from db.stb -sql select * from db.stb -sql_error create table db.ctb2 using db.stb tags(101, "102") -sql create table db.ctb2 using db.stb tags(101, 102, "103", 104) -sql insert into db.ctb2 values(now, 1, 2, 3) +print =============== step3: tb +sql select avg(tbcol) from tb1 +sql select avg(tbcol) from tb1 where ts <= 1601481840000 +sql select avg(tbcol) as b from tb1 +sql select avg(tbcol) as b from tb1 interval(1d) +sql select avg(tbcol) as b from tb1 where ts <= 1601481840000 interval(1m) +sql select bottom(tbcol, 2) from tb1 where ts <= 1601481840000 +sql select top(tbcol, 2) from tb1 where ts <= 1601481840000 +sql select percentile(tbcol, 2) from tb1 where ts <= 1601481840000 +sql select leastsquares(tbcol, 1, 1) as b from tb1 where ts <= 1601481840000 +sql show table distributed tb1 +sql select count(tbcol) as b from tb1 where ts <= 1601481840000 interval(1m) +sql select diff(tbcol) from tb1 where ts <= 1601481840000 +sql select diff(tbcol) from tb1 where tbcol > 5 and tbcol < 20 +sql select first(tbcol), last(tbcol) as b from tb1 where ts <= 1601481840000 interval(1m) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from tb1 where ts <= 1601481840000 partition by tgcol interval(1m) +#sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) +sql select last_row(*) from tb1 where tbcol > 5 and tbcol < 20 -print =============== step6: query data -sql select * from db.stb where tbname = 'ctb2'; +print =============== step4: stb +sql select avg(tbcol) as c from stb +sql select avg(tbcol) as c from stb where ts <= 1601481840000 +sql select avg(tbcol) as c from stb where tgcol < 5 and ts <= 1601481840000 +sql select avg(tbcol) as c from stb interval(1m) +sql select avg(tbcol) as c from stb interval(1d) +sql select avg(tbcol) as b from stb where ts <= 1601481840000 interval(1m) +sql select avg(tbcol) as c from stb group by tgcol +sql select avg(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m) +sql show table distributed stb +sql select count(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m) +sql select diff(tbcol) from stb where ts <= 1601481840000 +sql select first(tbcol), last(tbcol) as c from stb group by tgcol +sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 and tbcol2 is null partition by tgcol interval(1m) +sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from stb where ts <= 1601481840000 partition by tgcol interval(1m) +#sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) +sql select last_row(tbcol), stddev(tbcol) from stb where tbcol > 5 and tbcol < 20 group by tgcol _OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/valgrind/basic3.sim b/tests/script/tsim/valgrind/basic3.sim index d513eee3cf111072c0dc570d6afd4af74b28764f..b9ed1641c89eb855e231dc2f9f662613bcf742b9 100644 --- a/tests/script/tsim/valgrind/basic3.sim +++ b/tests/script/tsim/valgrind/basic3.sim @@ -1,5 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c debugflag -v 131 system sh/exec.sh -n dnode1 -s start -v sql connect @@ -44,20 +45,11 @@ while $i < $tbNum $i = $i + 1 endw -print =============== step3: avg -sql select avg(tbcol) from tb1 -sql select avg(tbcol) from tb1 where ts <= 1601481840000 -sql select avg(tbcol) as b from tb1 -sql select avg(tbcol) as b from tb1 interval(1d) -sql select avg(tbcol) as b from tb1 where ts <= 1601481840000s interval(1m) -sql select avg(tbcol) as c from stb -sql select avg(tbcol) as c from stb where ts <= 1601481840000 -sql select avg(tbcol) as c from stb where tgcol < 5 and ts <= 1601481840000 -sql select avg(tbcol) as c from stb interval(1m) -sql select avg(tbcol) as c from stb interval(1d) -sql select avg(tbcol) as b from stb where ts <= 1601481840000s interval(1m) -sql select avg(tbcol) as c from stb group by tgcol -sql select avg(tbcol) as b from stb where ts <= 1601481840000s partition by tgcol interval(1m) +print =============== step3: tb +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) + +print =============== step4: stb +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) _OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/valgrind/basic4.sim b/tests/script/tsim/valgrind/basic4.sim new file mode 100644 index 0000000000000000000000000000000000000000..8be96f769b0cf265f646e88d37de312c2ccb20d0 --- /dev/null +++ b/tests/script/tsim/valgrind/basic4.sim @@ -0,0 +1,74 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c debugflag -v 131 +system sh/exec.sh -n dnode1 -s start -v +sql connect + +print =============== step1: create drop show dnodes +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ---> dnode not ready! + return -1 + endi +sql show dnodes +print ---> $data00 $data01 $data02 $data03 $data04 $data05 +if $rows != 1 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi + +print =============== step2: create db +sql create database d1 vgroups 2 buffer 3 +sql show databases +sql use d1 +sql show vgroups + +print =============== step3: create show stable +sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned) +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== step4: create show table +sql create table ct1 using stb tags(1000) +sql create table ct2 using stb tags(2000) +sql create table ct3 using stb tags(3000) +sql show tables +if $rows != 3 then + return -1 +endi + +print =============== step5: insert data (null / update) +sql insert into ct1 values(now+0s, 10, 2.0, 3.0) +sql insert into ct1 values(now+1s, 11, 2.1, NULL)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3) +sql insert into ct2 values(now+0s, 10, 2.0, 3.0) +sql insert into ct2 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3) +sql insert into ct3 values('2021-01-01 00:00:00.000', NULL, NULL, 3.0) +sql insert into ct3 values('2022-03-02 16:59:00.010', 3 , 4, 5), ('2022-03-02 16:59:00.010', 33 , 4, 5), ('2022-04-01 16:59:00.011', 4, 4, 5), ('2022-04-01 16:59:00.011', 6, 4, 5), ('2022-03-06 16:59:00.013', 8, 4, 5); +sql insert into ct3 values('2022-03-02 16:59:00.010', 103, 1, 2), ('2022-03-02 16:59:00.010', 303, 3, 4), ('2022-04-01 16:59:00.011', 40, 5, 6), ('2022-04-01 16:59:00.011', 60, 4, 5), ('2022-03-06 16:59:00.013', 80, 4, 5); + +print =============== step6: query data= + +sql select * from stb where t1 between 1000 and 2500 + + +_OVER: +system sh/exec.sh -n dnode1 -s stop -x SIGINT +print =============== check +$null= + +system_content sh/checkValgrind.sh -n dnode1 +print cmd return result ----> [ $system_content ] +if $system_content > 0 then + return -1 +endi + +if $system_content == $null then + return -1 +endi diff --git a/tests/script/tsim/valgrind/checkError1.sim b/tests/script/tsim/valgrind/checkError1.sim index 83ae2807219c0483db85e602ee5d272e4020b79a..059808e4be1d67242382e00dead2c77e5affe5f5 100644 --- a/tests/script/tsim/valgrind/checkError1.sim +++ b/tests/script/tsim/valgrind/checkError1.sim @@ -105,7 +105,7 @@ if $rows != 1 then endi sql select * from information_schema.user_tables -if $rows != 31 then +if $rows <= 0 then return -1 endi diff --git a/tests/script/tsim/valgrind/checkError2.sim b/tests/script/tsim/valgrind/checkError2.sim index e81d702d828433fd18e81a07798a57bac4f4eb6a..e3322f03660a5e63b6bcf955766ad817d2469095 100644 --- a/tests/script/tsim/valgrind/checkError2.sim +++ b/tests/script/tsim/valgrind/checkError2.sim @@ -62,6 +62,8 @@ sql select * from ct1 where ts < now -1d and ts > now +1d sql select * from stb where ts < now -1d and ts > now +1d sql select * from ct1 where ts < now -1d and ts > now +1d order by ts desc sql select * from stb where ts < now -1d and ts > now +1d order by ts desc +sql select * from ct1 where t1 between 1000 and 2500 +sql select * from stb where t1 between 1000 and 2500 print =============== step7: count sql select count(*) from ct1; diff --git a/tests/script/tsim/valgrind/checkError3.sim b/tests/script/tsim/valgrind/checkError3.sim index e8b25098d65f7252292a33be0accd69672fdc359..41623896b3b93dc84b8348f39feb2ff5ef20e964 100644 --- a/tests/script/tsim/valgrind/checkError3.sim +++ b/tests/script/tsim/valgrind/checkError3.sim @@ -37,6 +37,7 @@ sql show stables if $rows != 4 then return -1 endi +sql show stables like 'stb' print =============== step4: ccreate child table sql create table c1 using stb tags(true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) diff --git a/tests/script/tsim/valgrind/checkError5.sim b/tests/script/tsim/valgrind/checkError5.sim index 6eef185fd3eec169f9556d196ef0f8d39094300f..f0786587d9597c14971f9d49ce4144014aef6d81 100644 --- a/tests/script/tsim/valgrind/checkError5.sim +++ b/tests/script/tsim/valgrind/checkError5.sim @@ -105,6 +105,39 @@ sql insert into db.ctb2 values(now, 1, 2, 3) print =============== step6: query data sql select * from db.stb where tbname = 'ctb2'; + +print =============== step7: normal table +sql create database d1 replica 1 duration 7 keep 50 +sql use d1 +sql create table tb (ts timestamp, a int) +sql insert into tb values(now-28d, -28) +sql alter table tb add column b smallint +sql insert into tb values(now-25d, -25, 0) +sql alter table tb add column c tinyint +sql insert into tb values(now-22d, -22, 3, 0) +sql alter table tb add column d int +sql insert into tb values(now-19d, -19, 6, 0, 0) +sql alter table tb add column e bigint +sql insert into tb values(now-16d, -16, 9, 0, 0, 0) +sql alter table tb add column f float +sql insert into tb values(now-13d, -13, 12, 0, 0, 0, 0) +sql alter table tb add column g double +sql insert into tb values(now-10d, -10, 15, 0, 0, 0, 0, 0) +sql alter table tb add column h binary(10) +sql insert into tb values(now-7d, -7, 18, 0, 0, 0, 0, 0, '0') +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from d1.tb; +sql alter table tb drop column a +sql insert into tb values(now-4d, 1, 1, 1, 1, 1, 1, '1') +sql alter table tb drop column b +sql insert into tb values(now-3d, 1, 1, 1, 1, 1, '1') +sql alter table tb drop column c +sql insert into tb values(now-2d, 1, 1, 1, 1, '1') +sql alter table tb drop column d +sql insert into tb values(now-1d, 1, 1, 1, '1') +sql alter table tb drop column e +sql insert into tb values(now, 1, 1, '1') +sql select count(h) from tb + _OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT print =============== check diff --git a/tests/script/tsim/valgrind/checkError6.sim b/tests/script/tsim/valgrind/checkError6.sim index 4681345839981624732f1af37864c40beb46218a..ec8ca0ad8c6b615b6cd6748743f51aad603f7073 100644 --- a/tests/script/tsim/valgrind/checkError6.sim +++ b/tests/script/tsim/valgrind/checkError6.sim @@ -29,7 +29,7 @@ $rowNum = 10 print =============== step2: prepare data sql create database db vgroups 2 sql use db -sql create table if not exists stb (ts timestamp, tbcol int, tbcol2 float, tbcol3 double) tags (tgcol int unsigned) +sql create table if not exists stb (ts timestamp, tbcol int, tbcol2 float, tbcol3 double, tbcol4 binary(30), tbcol5 binary(30)) tags (tgcol int unsigned) $i = 0 while $i < $tbNum @@ -39,26 +39,108 @@ while $i < $tbNum while $x < $rowNum $cc = $x * 60000 $ms = 1601481600000 + $cc - sql insert into $tb values ($ms , $x , $x , $x ) + sql insert into $tb values ($ms , $x , $x , $x , "abcd1234=-+*" , "123456 0" ) $x = $x + 1 endw + + $cc = $x * 60000 + $ms = 1601481600000 + $cc + sql insert into $tb values ($ms , NULL , NULL , NULL , NULL , NULL ) $i = $i + 1 endw -print =============== step3: avg +print =============== step3: tb sql select avg(tbcol) from tb1 sql select avg(tbcol) from tb1 where ts <= 1601481840000 sql select avg(tbcol) as b from tb1 sql select avg(tbcol) as b from tb1 interval(1d) -sql select avg(tbcol) as b from tb1 where ts <= 1601481840000s interval(1m) +sql select avg(tbcol) as b from tb1 where ts <= 1601481840000 interval(1m) +sql select bottom(tbcol, 2) from tb1 where ts <= 1601481840000 +sql select top(tbcol, 2) from tb1 where ts <= 1601481840000 +sql select percentile(tbcol, 2) from tb1 where ts <= 1601481840000 +sql select leastsquares(tbcol, 1, 1) as b from tb1 where ts <= 1601481840000 +sql show table distributed tb1 +sql select count(1) from tb1 +sql select count(tbcol) as b from tb1 where ts <= 1601481840000 interval(1m) +sql select diff(tbcol) from tb1 where ts <= 1601481840000 +sql select diff(tbcol) from tb1 where tbcol > 5 and tbcol < 20 order by ts +sql select first(tbcol), last(tbcol) as b from tb1 where ts <= 1601481840000 interval(1m) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from tb1 where ts <= 1601481840000 partition by tgcol order by tgcol +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from tb1 where ts <= 1601481840000 partition by tgcol interval(1m) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) +sql select last_row(*) from tb1 where tbcol > 5 and tbcol < 20 +sql select _wstart, _wend, _wduration, _qstart, _qend, count(*) from tb1 interval(10s, 2s) sliding(10s) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) order by tgcol desc +sql select log(tbcol), abs(tbcol), pow(tbcol, 2), sqrt(tbcol), sin(tbcol), cos(tbcol), tan(tbcol), asin(tbcol), acos(tbcol), atan(tbcol), ceil(tbcol), floor(tbcol), round(tbcol), atan(tbcol) from tb1 +sql select length("abcd1234"), char_length("abcd1234=-+*") from tb1 +sql select tbcol4, length(tbcol4), lower(tbcol4), upper(tbcol4), ltrim(tbcol4), rtrim(tbcol4), concat(tbcol4, tbcol5), concat_ws('_', tbcol4, tbcol5), substr(tbcol4, 1, 4) from tb1 +sql select * from tb1 where tbcol not in (1,2,3,null); +sql select * from tb1 where tbcol + 3 <> null; + +print =============== step4: stb +sql select avg(tbcol) as c from stb +sql select avg(tbcol) as c from stb where ts <= 1601481840000 +sql select avg(tbcol) as c from stb where tgcol < 5 and ts <= 1601481840000 +sql select avg(tbcol) as c from stb interval(1m) +sql select avg(tbcol) as c from stb interval(1d) +sql select avg(tbcol) as b from stb where ts <= 1601481840000 interval(1m) +sql select avg(tbcol) as c from stb group by tgcol +sql select avg(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m) +sql show table distributed stb +sql select count(1) from stb +sql select count(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m) +sql select diff(tbcol) from stb where ts <= 1601481840000 +sql select first(tbcol), last(tbcol) as c from stb group by tgcol +sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 and tbcol2 is null partition by tgcol interval(1m) +sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from stb where ts <= 1601481840000 partition by tgcol interval(1m) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 and tgcol = 1 partition by tgcol interval(1m) fill(value, 0) order by tgcol desc +sql select last_row(tbcol), stddev(tbcol) from stb where tbcol > 5 and tbcol < 20 group by tgcol +sql select _wstart, _wend, _wduration, _qstart, _qend, count(*) from stb interval(10s, 2s) sliding(10s) +sql select log(tbcol), abs(tbcol), pow(tbcol, 2), sqrt(tbcol), sin(tbcol), cos(tbcol), tan(tbcol), asin(tbcol), acos(tbcol), atan(tbcol), ceil(tbcol), floor(tbcol), round(tbcol), atan(tbcol) from stb +sql select length("abcd1234"), char_length("abcd1234=-+*") from stb +sql select tbcol4, length(tbcol4), lower(tbcol4), upper(tbcol4), ltrim(tbcol4), rtrim(tbcol4), concat(tbcol4, tbcol5), concat_ws('_', tbcol4, tbcol5), substr(tbcol4, 1, 4) from stb +sql select * from stb where tbcol not in (1,2,3,null); +sql select * from stb where tbcol + 3 <> null; + +print =============== step5: explain + + +print =============== check +$null= + +system_content sh/checkValgrind.sh -n dnode1 +print cmd return result ----> [ $system_content ] +if $system_content > 0 then + return -1 +endi + +if $system_content == $null then + return -1 +endi + +print =============== restart +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start -v + sql select avg(tbcol) as c from stb sql select avg(tbcol) as c from stb where ts <= 1601481840000 sql select avg(tbcol) as c from stb where tgcol < 5 and ts <= 1601481840000 sql select avg(tbcol) as c from stb interval(1m) sql select avg(tbcol) as c from stb interval(1d) -sql select avg(tbcol) as b from stb where ts <= 1601481840000s interval(1m) +sql select avg(tbcol) as b from stb where ts <= 1601481840000 interval(1m) sql select avg(tbcol) as c from stb group by tgcol -sql select avg(tbcol) as b from stb where ts <= 1601481840000s partition by tgcol interval(1m) +sql select avg(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m) +sql show table distributed stb +sql select count(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m) +sql select diff(tbcol) from stb where ts <= 1601481840000 +sql select first(tbcol), last(tbcol) as c from stb group by tgcol +sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 and tbcol2 is null partition by tgcol interval(1m) +sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from stb where ts <= 1601481840000 partition by tgcol interval(1m) +sql select last_row(tbcol), stddev(tbcol) from stb where tbcol > 5 and tbcol < 20 group by tgcol _OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/show.sim b/tests/script/tsim/valgrind/checkError7.sim similarity index 79% rename from tests/script/tsim/stable/show.sim rename to tests/script/tsim/valgrind/checkError7.sim index d3ab75adf5ac08dbd4c2a8a0870cfe4fbfd62a4d..a66ddb30df063416e0f04da0dd58de9bebed186d 100644 --- a/tests/script/tsim/stable/show.sim +++ b/tests/script/tsim/valgrind/checkError7.sim @@ -1,6 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start -v sql connect print ======================== create stable @@ -58,4 +58,18 @@ if $rows != 424 then return -1 endi + +_OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT +print =============== check +$null= + +system_content sh/checkValgrind.sh -n dnode1 +print cmd return result ----> [ $system_content ] +if $system_content > 2 then + return -1 +endi + +if $system_content == $null then + return -1 +endi diff --git a/tests/system-test/0-others/cachemodel.py b/tests/system-test/0-others/cachemodel.py index 09538e6678f16d7eebbafce45fad6046e551a6bc..102a34612d2473e7bd3f73432d045c56a95baeac 100644 --- a/tests/system-test/0-others/cachemodel.py +++ b/tests/system-test/0-others/cachemodel.py @@ -90,7 +90,7 @@ class TDTestCase: for db_info in databases_infos: dbname = db_info[0] # print(dbname) - cache_last_value = db_info[16] + cache_last_value = db_info[18] # print(cache_last_value) if dbname in ["information_schema" , "performance_schema"]: continue diff --git a/tests/system-test/0-others/fsync.py b/tests/system-test/0-others/fsync.py index 964550cdbc8eb5e9a6ce6b1c01884078b68263b8..fcc790040c57a6307c69895b8021a81d464ac81f 100644 --- a/tests/system-test/0-others/fsync.py +++ b/tests/system-test/0-others/fsync.py @@ -43,41 +43,41 @@ class TDTestCase: fsync_index = 0 tdSql.query("show databases") for i in range(tdSql.queryCols): - if tdSql.cursor.description[i][0] == "wal": + if tdSql.cursor.description[i][0] == "wal_level": wal_index = i - if tdSql.cursor.description[i][0] == "fsync": + if tdSql.cursor.description[i][0] == "wal_fsync_period": fsync_index = i tdSql.execute("drop database if exists db1") - tdSql.execute("create database db1 wal 1") + tdSql.execute("create database db1 wal_level 1") tdSql.query("show databases") for i in range(tdSql.queryRows): if tdSql.queryResult[i][0] == "db1": tdSql.checkData(i, wal_index, 1) tdSql.execute("drop database if exists db1") - tdSql.execute("create database db1 wal 2") + tdSql.execute("create database db1 wal_level 2") tdSql.query("show databases") for i in range(tdSql.queryRows): if tdSql.queryResult[i][0] == "db1": tdSql.checkData(i, wal_index, 2) tdSql.execute("drop database if exists db1") - tdSql.execute("create database db1 fsync 0") + tdSql.execute("create database db1 wal_fsync_period 0") tdSql.query("show databases") for i in range(tdSql.queryRows): if tdSql.queryResult[i][0] == "db1": tdSql.checkData(i, fsync_index, 0) tdSql.execute("drop database if exists db1") - tdSql.execute("create database db1 fsync 3000") + tdSql.execute("create database db1 wal_fsync_period 3000") tdSql.query("show databases") for i in range(tdSql.queryRows): if tdSql.queryResult[i][0] == "db1": tdSql.checkData(i, fsync_index, 3000) tdSql.execute("drop database if exists db1") - tdSql.execute("create database db1 fsync 180000") + tdSql.execute("create database db1 wal_fsync_period 180000") tdSql.query("show databases") for i in range(tdSql.queryRows): if tdSql.queryResult[i][0] == "db1": @@ -85,7 +85,7 @@ class TDTestCase: tdSql.execute("drop database if exists db1") - tdSql.execute("create database db1 wal 1 fsync 6000") + tdSql.execute("create database db1 wal_level 1 wal_fsync_period 6000") tdSql.query("show databases") for i in range(tdSql.queryRows): if tdSql.queryResult[i][0] == "db1": @@ -93,49 +93,49 @@ class TDTestCase: tdSql.checkData(i, wal_index, 1) tdSql.execute("drop database if exists db1") - tdSql.execute("create database db1 wal 2 fsync 3000") + tdSql.execute("create database db1 wal_level 2 wal_fsync_period 3000") tdSql.query("show databases") for i in range(tdSql.queryRows): if tdSql.queryResult[i][0] == "db1": tdSql.checkData(i, fsync_index, 3000) tdSql.checkData(i, wal_index, 2) - tdSql.execute("alter database db1 wal 1") + tdSql.execute("alter database db1 wal_level 1") tdSql.query("show databases") for i in range(tdSql.queryRows): if tdSql.queryResult[i][0] == "db1": tdSql.checkData(i, fsync_index, 3000) tdSql.checkData(i, wal_index, 1) - tdSql.execute("alter database db1 wal 2") + tdSql.execute("alter database db1 wal_level 2") tdSql.query("show databases") for i in range(tdSql.queryRows): if tdSql.queryResult[i][0] == "db1": tdSql.checkData(i, fsync_index, 3000) tdSql.checkData(i, wal_index, 2) - tdSql.execute("alter database db1 fsync 0") + tdSql.execute("alter database db1 wal_fsync_period 0") tdSql.query("show databases") for i in range(tdSql.queryRows): if tdSql.queryResult[i][0] == "db1": tdSql.checkData(i, fsync_index, 0) tdSql.checkData(i, wal_index, 2) - tdSql.execute("alter database db1 fsync 3000") + tdSql.execute("alter database db1 wal_fsync_period 3000") tdSql.query("show databases") for i in range(tdSql.queryRows): if tdSql.queryResult[i][0] == "db1": tdSql.checkData(i, fsync_index, 3000) tdSql.checkData(i, wal_index, 2) - tdSql.execute("alter database db1 fsync 18000") + tdSql.execute("alter database db1 wal_fsync_period 18000") tdSql.query("show databases") for i in range(tdSql.queryRows): if tdSql.queryResult[i][0] == "db1": tdSql.checkData(i, fsync_index, 18000) tdSql.checkData(i, wal_index, 2) - tdSql.execute("alter database db1 wal 1 fsync 3000") + tdSql.execute("alter database db1 wal_level 1 wal_fsync_period 3000") tdSql.query("show databases") for i in range(tdSql.queryRows): if tdSql.queryResult[i][0] == "db1": @@ -147,29 +147,29 @@ class TDTestCase: @property def fsync_create_err(self): return [ - "create database db1 wal 0", - "create database db1 wal 3", - "create database db1 wal null", - "create database db1 wal true", - "create database db1 wal 1.1", - "create database db1 fsync -1", - "create database db1 fsync 180001", - "create database db1 fsync 10.111", - "create database db1 fsync true", + "create database db1 wal_level 0", + "create database db1 wal_level 3", + "create database db1 wal_level null", + "create database db1 wal_level true", + "create database db1 wal_level 1.1", + "create database db1 wal_fsync_period -1", + "create database db1 wal_fsync_period 180001", + "create database db1 wal_fsync_period 10.111", + "create database db1 wal_fsync_period true", ] @property def fsync_alter_err(self): return [ - "alter database db1 wal 0", - "alter database db1 wal 3", - "alter database db1 wal null", - "alter database db1 wal true", - "alter database db1 wal 1.1", - "alter database db1 fsync -1", - "alter database db1 fsync 180001", - "alter database db1 fsync 10.111", - "alter database db1 fsync true", + "alter database db1 wal_level 0", + "alter database db1 wal_level 3", + "alter database db1 wal_level null", + "alter database db1 wal_level true", + "alter database db1 wal_level 1.1", + "alter database db1 wal_fsync_period -1", + "alter database db1 wal_fsync_period 180001", + "alter database db1 wal_fsync_period 10.111", + "alter database db1 wal_fsync_period true", ] def test_fsync_err(self): @@ -290,7 +290,7 @@ class TDTestCase: # tdSql.execute("use db") - tdLog.printNoPrefix("==========step4:after wal, all check again ") + tdLog.printNoPrefix("==========step4:after wal_level, all check again ") self.all_test() def stop(self): diff --git a/tests/system-test/1-insert/mutil_stage.py b/tests/system-test/1-insert/mutil_stage.py new file mode 100644 index 0000000000000000000000000000000000000000..fcad114edde773ebd059f30ca852accceb404b63 --- /dev/null +++ b/tests/system-test/1-insert/mutil_stage.py @@ -0,0 +1,257 @@ +from datetime import datetime +import time + +from typing import List, Any, Tuple +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * + +PRIMARY_COL = "ts" + +INT_COL = "c_int" +BINT_COL = "c_bint" +SINT_COL = "c_sint" +TINT_COL = "c_tint" +FLOAT_COL = "c_float" +DOUBLE_COL = "c_double" +BOOL_COL = "c_bool" +TINT_UN_COL = "c_utint" +SINT_UN_COL = "c_usint" +BINT_UN_COL = "c_ubint" +INT_UN_COL = "c_uint" +BINARY_COL = "c_binary" +NCHAR_COL = "c_nchar" +TS_COL = "c_ts" + +NUM_COL = [INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ] +CHAR_COL = [BINARY_COL, NCHAR_COL, ] +BOOLEAN_COL = [BOOL_COL, ] +TS_TYPE_COL = [TS_COL, ] + +INT_TAG = "t_int" + +TAG_COL = [INT_TAG] +# insert data args: +TIME_STEP = 10000 +NOW = int(datetime.timestamp(datetime.now()) * 1000) + +# init db/table +DBNAME = "db" +STBNAME = "stb1" +CTB_PRE = "ct" +NTB_PRE = "nt" + +L0 = 0 +L1 = 1 +L2 = 2 + +PRIMARY_DIR = 1 +NON_PRIMARY_DIR = 0 + +DATA_PRE0 = f"data0" +DATA_PRE1 = f"data1" +DATA_PRE2 = f"data2" + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), False) + self.taos_cfg_path = tdDnodes.dnodes[0].cfgPath + self.taos_data_dir = tdDnodes.dnodes[0].dataDir + + + def cfg(self, filename, **update_dict): + cmd = "echo " + for k, v in update_dict.items(): + cmd += f"{k} {v}\n" + + cmd += f" >> {filename}" + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def cfg_str(self, filename, update_str): + cmd = f'echo "{update_str}" >> {filename}' + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def cfg_str_list(self, filename, update_list): + for update_str in update_list: + self.cfg_str(filename, update_str) + + def del_old_datadir(self, filename): + cmd = f"sed -i '/^dataDir/d' {filename}" + if os.system(cmd) != 0: + tdLog.exit(cmd) + + @property + def __err_cfg(self): + cfg_list = [] + err_case1 = [ + f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {NON_PRIMARY_DIR}", + f"dataDir {self.taos_data_dir}/{DATA_PRE1}1 {L1} {PRIMARY_DIR}", + f"dataDir {self.taos_data_dir}/{DATA_PRE2}2 {L2} {NON_PRIMARY_DIR}" + ] + err_case2 = [ + f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {NON_PRIMARY_DIR}", + f"dataDir {self.taos_data_dir}/{DATA_PRE1}1 {L1} {NON_PRIMARY_DIR}", + f"dataDir {self.taos_data_dir}/{DATA_PRE2}2 {L2} {PRIMARY_DIR}" + ] + err_case3 = [ + f"dataDir {self.taos_data_dir}/data33 3 {NON_PRIMARY_DIR}" + ] + err_case4 = [ + f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {NON_PRIMARY_DIR}", + f"dataDir {self.taos_data_dir}/{DATA_PRE1}1 {L1} {NON_PRIMARY_DIR}", + f"dataDir {self.taos_data_dir}/{DATA_PRE2}2 {L2} {NON_PRIMARY_DIR}", + f"dataDir {self.taos_data_dir}/{DATA_PRE2}2 {L1} {NON_PRIMARY_DIR}" + ] + err_case5 = [f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {PRIMARY_DIR}"] + for i in range(16): + err_case5.append(f"dataDir {self.taos_data_dir}/{DATA_PRE0}{i+1} {L0} {NON_PRIMARY_DIR}") + + err_case6 = [ + f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {PRIMARY_DIR}", + f"dataDir {self.taos_data_dir}/{DATA_PRE0}1 {L0} {PRIMARY_DIR}", + ] + err_case7 = [ + f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {PRIMARY_DIR}", + f"dataDir {self.taos_data_dir}/{DATA_PRE2}2 {L2} {PRIMARY_DIR}", + ] + err_case8 = [ + f"dataDir {self.taos_data_dir}/data33 3 {PRIMARY_DIR}" + ] + err_case9 = [ + f"dataDir {self.taos_data_dir}/data33 -1 {NON_PRIMARY_DIR}" + ] + + cfg_list.append(err_case1) + cfg_list.append(err_case2) + cfg_list.append(err_case3) + cfg_list.append(err_case4) + cfg_list.append(err_case5) + cfg_list.append(err_case6) + cfg_list.append(err_case7) + cfg_list.append(err_case8) + cfg_list.append(err_case9) + + return cfg_list + + @property + def __current_cfg(self): + cfg_list = [] + current_case1 = [ + f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {PRIMARY_DIR}", + f"dataDir {self.taos_data_dir}/{DATA_PRE0}1 {L0} {NON_PRIMARY_DIR}", + f"dataDir {self.taos_data_dir}/{DATA_PRE1}1 {L1} {NON_PRIMARY_DIR}", + f"dataDir {self.taos_data_dir}/{DATA_PRE2}2 {L2} {NON_PRIMARY_DIR}" + ] + + current_case2 = [f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {PRIMARY_DIR}"] + for i in range(9): + current_case2.append(f"dataDir {self.taos_data_dir}/{DATA_PRE0}{i+1} {L0} {NON_PRIMARY_DIR}") + + # TD-17773bug + current_case3 = [ + f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 ", + f"dataDir {self.taos_data_dir}/{DATA_PRE0}1 {L0} {NON_PRIMARY_DIR}", + f"dataDir {self.taos_data_dir}/{DATA_PRE1}0 {L1} {NON_PRIMARY_DIR}", + f"dataDir {self.taos_data_dir}/{DATA_PRE2}0 {L2} {NON_PRIMARY_DIR}", + ] + cfg_list.append(current_case1) + cfg_list.append(current_case3) + + # case2 must in last of least, because use this cfg as data uniformity test + cfg_list.append(current_case2) + + return cfg_list + + def cfg_check(self): + for cfg_case in self.__err_cfg: + self.del_old_datadir(filename=self.taos_cfg_path) + tdDnodes.stop(1) + tdDnodes.deploy(1) + self.cfg_str_list(filename=self.taos_cfg_path, update_list=cfg_case) + tdDnodes.starttaosd(1) + time.sleep(2) + tdSql.error(f"show databases") + + for cfg_case in self.__current_cfg: + self.del_old_datadir(filename=self.taos_cfg_path) + tdDnodes.stop(1) + tdDnodes.deploy(1) + self.cfg_str_list(filename=self.taos_cfg_path, update_list=cfg_case) + tdDnodes.start(1) + tdSql.query(f"show databases") + + def __create_tb(self, stb=STBNAME, ctb_pre = CTB_PRE, ctb_num=20, ntb_pre=NTB_PRE, ntbnum=1, dbname=DBNAME): + tdLog.printNoPrefix("==========step: create table") + create_stb_sql = f'''create table {dbname}.{stb}( + ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, + {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, + {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp, + {TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned, + {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned + ) tags ({INT_TAG} int) + ''' + tdSql.execute(create_stb_sql) + + for i in range(ntbnum): + create_ntb_sql = f'''create table {dbname}.{ntb_pre}{i+1}( + ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, + {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, + {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp, + {TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned, + {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned + ) + ''' + tdSql.execute(create_ntb_sql) + + for i in range(ctb_num): + tdSql.execute(f'create table {dbname}.{ctb_pre}{i+1} using {dbname}.{stb} tags ( {i+1} )') + + def __insert_data(self, rows, dbname=DBNAME, ctb_num=20): + data = DataSet() + data.get_order_set(rows) + + tdLog.printNoPrefix("==========step: start inser data into tables now.....") + for i in range(self.rows): + row_data = f''' + {data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]}, + {data.bool_data[i]}, '{data.vchar_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {data.utint_data[i]}, + {data.usint_data[i]}, {data.uint_data[i]}, {data.ubint_data[i]} + ''' + neg_row_data = f''' + {-1 * data.int_data[i]}, {-1 * data.bint_data[i]}, {-1 * data.sint_data[i]}, {-1 * data.tint_data[i]}, {-1 * data.float_data[i]}, {-1 * data.double_data[i]}, + {data.bool_data[i]}, '{data.vchar_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {1 * data.utint_data[i]}, + {1 * data.usint_data[i]}, {1 * data.uint_data[i]}, {1 * data.ubint_data[i]} + ''' + + for j in range(ctb_num): + tdSql.execute( + f"insert into {dbname}.{CTB_PRE}{j + 1} values ( {NOW - i * TIME_STEP}, {row_data} )") + + # tdSql.execute( + # f"insert into {dbname}.{CTB_PRE}2 values ( {NOW - i * int(TIME_STEP * 0.6)}, {neg_row_data} )") + # tdSql.execute( + # f"insert into {dbname}.{CTB_PRE}4 values ( {NOW - i * int(TIME_STEP * 0.8) }, {row_data} )") + tdSql.execute( + f"insert into {dbname}.{NTB_PRE}1 values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )") + + def run(self): + self.rows = 10 + self.cfg_check() + tdSql.prepare(dbname=DBNAME, **{"keep": "1d, 1500m, 26h", "duration":"1h", "vgroups": 10}) + self.__create_tb(dbname=DBNAME) + self.__insert_data(rows=self.rows, dbname=DBNAME) + tdSql.query(f"select count(*) from {DBNAME}.{NTB_PRE}1") + tdSql.execute(f"flush database {DBNAME}") + + 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/1-insert/time_range_wise.py b/tests/system-test/1-insert/time_range_wise.py index f945bafe3b9b4347d8bb9b11fa57ef4d2e716d67..e65dded6013fdecf3075e9fbbbb8e0321e28cb7b 100644 --- a/tests/system-test/1-insert/time_range_wise.py +++ b/tests/system-test/1-insert/time_range_wise.py @@ -1,4 +1,5 @@ import datetime +import time from dataclasses import dataclass from typing import List, Any, Tuple @@ -328,11 +329,15 @@ class TDTestCase: tdSql.query("select database()") dbname = tdSql.getData(0,0) tdSql.query("show databases") + for index , value in enumerate(tdSql.cursor.description): + if value[0] == "retention": + r_index = index + break for row in tdSql.queryResult: if row[0] == dbname: - if row[-1] is None: + if row[r_index] is None: continue - if ":" in row[-1]: + if ":" in row[r_index]: sma.rollup_db = True if sma.rollup_db : return False @@ -393,8 +398,6 @@ class TDTestCase: else: tdSql.error(self.__create_sma_index(sma)) - - def __drop_sma_index(self, sma:SMAschema): sql = f"{sma.drop} {sma.drop_flag} {sma.index_name}" return sql @@ -416,8 +419,7 @@ class TDTestCase: self.sma_created_index = list(filter(lambda x: x != sma.index_name, self.sma_created_index)) tdSql.query("show streams") tdSql.checkRows(self.sma_count) - - + time.sleep(1) else: tdSql.error(self.__drop_sma_index(sma)) diff --git a/tests/system-test/2-query/cast.py b/tests/system-test/2-query/cast.py index bdac2b6175fc5a4157bc58bf2329848c36fb204b..4045b6ad88106e9fed718d00f08b3c113236ac91 100644 --- a/tests/system-test/2-query/cast.py +++ b/tests/system-test/2-query/cast.py @@ -566,8 +566,7 @@ class TDTestCase: if data_ct4_c10[i] is None: tdSql.checkData( i, 0, None ) else: - # time2str = str(int((data_ct4_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000)) - time2str = str(int((datetime.datetime.timestamp(data_ct4_c10[i])-datetime.datetime.timestamp(datetime.datetime.fromtimestamp(0)))*1000)) + time2str = str(int((data_ct4_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000)) tdSql.checkData( i, 0, time2str ) tdSql.query(f"select cast(c10 as nchar(32)) as b from {self.dbname}.t1") for i in range(len(data_t1_c10)): @@ -576,8 +575,7 @@ class TDTestCase: elif i == 10: continue else: - # time2str = str(int((data_t1_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000)) - time2str = str(int((datetime.datetime.timestamp(data_t1_c10[i])-datetime.datetime.timestamp(datetime.datetime.fromtimestamp(0)))*1000)) + time2str = str(int((data_t1_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000)) tdSql.checkData( i, 0, time2str ) tdLog.printNoPrefix("==========step38: cast timestamp to binary, expect no changes ") @@ -586,8 +584,7 @@ class TDTestCase: if data_ct4_c10[i] is None: tdSql.checkData( i, 0, None ) else: - # time2str = str(int((data_ct4_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000)) - time2str = str(int((datetime.datetime.timestamp(data_ct4_c10[i])-datetime.datetime.timestamp(datetime.datetime.fromtimestamp(0)))*1000)) + time2str = str(int((data_ct4_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000)) tdSql.checkData( i, 0, time2str ) tdSql.query(f"select cast(c10 as binary(32)) as b from {self.dbname}.t1") for i in range(len(data_t1_c10)): @@ -596,8 +593,7 @@ class TDTestCase: elif i == 10: continue else: - # time2str = str(int((data_t1_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000)) - time2str = str(int((datetime.datetime.timestamp(data_t1_c10[i])-datetime.datetime.timestamp(datetime.datetime.fromtimestamp(0)))*1000)) + time2str = str(int((data_t1_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000)) tdSql.checkData( i, 0, time2str ) tdLog.printNoPrefix("==========step39: cast constant operation to bigint, expect change to int ") diff --git a/tests/system-test/2-query/concat.py b/tests/system-test/2-query/concat.py index 59fae9b59d62599e3bca23c393ecc854aed9c186..23b964012ab24ae4eb4ed34b0fc679813a070e37 100644 --- a/tests/system-test/2-query/concat.py +++ b/tests/system-test/2-query/concat.py @@ -136,23 +136,23 @@ class TDTestCase: return sqls - def __test_current(self): # sourcery skip: use-itertools-product + def __test_current(self, dbname="db"): # sourcery skip: use-itertools-product tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") tbname = [ - "ct1", - "ct2", - "ct4", + f"{dbname}.ct1", + f"{dbname}.ct2", + f"{dbname}.ct4", ] for tb in tbname: for i in range(2,8): self.__concat_check(tb,i) tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========") - def __test_error(self): + def __test_error(self, dbname="db"): tdLog.printNoPrefix("==========err sql condition check , must return error==========") tbname = [ - "t1", - "stb1", + f"{dbname}.t1", + f"{dbname}.stb1", ] for tb in tbname: @@ -163,22 +163,20 @@ class TDTestCase: tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========") - def all_test(self): - self.__test_current() - self.__test_error() + def all_test(self, dbname="db"): + self.__test_current(dbname) + self.__test_error(dbname) - - def __create_tb(self): - tdSql.prepare() + def __create_tb(self, dbname="db"): tdLog.printNoPrefix("==========step1:create table") - create_stb_sql = f'''create table stb1( + create_stb_sql = f'''create table {dbname}.stb1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp ) tags (t1 int) ''' - create_ntb_sql = f'''create table t1( + create_ntb_sql = f'''create table {dbname}.t1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp @@ -188,29 +186,29 @@ class TDTestCase: tdSql.execute(create_ntb_sql) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') - def __insert_data(self, rows): + def __insert_data(self, rows, dbname="db"): now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) for i in range(rows): tdSql.execute( - f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f'''insert into ct1 values + f'''insert into {dbname}.ct1 values ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ''' ) tdSql.execute( - f'''insert into ct4 values + f'''insert into {dbname}.ct4 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -226,7 +224,7 @@ class TDTestCase: ) tdSql.execute( - f'''insert into ct2 values + f'''insert into {dbname}.ct2 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -242,13 +240,13 @@ class TDTestCase: ) for i in range(rows): - insert_data = f'''insert into t1 values + insert_data = f'''insert into {dbname}.t1 values ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) ''' tdSql.execute(insert_data) tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -268,22 +266,23 @@ class TDTestCase: tdSql.prepare() tdLog.printNoPrefix("==========step1:create table") - self.__create_tb() + self.__create_tb(dbname="db") tdLog.printNoPrefix("==========step2:insert data") self.rows = 10 - self.__insert_data(self.rows) + self.__insert_data(self.rows, dbname="db") tdLog.printNoPrefix("==========step3:all check") - self.all_test() + self.all_test(dbname="db") - tdDnodes.stop(1) - tdDnodes.start(1) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.execute("flush database db") tdSql.execute("use db") tdLog.printNoPrefix("==========step4:after wal, all check again ") - self.all_test() + self.all_test(dbname="db") def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/concat2.py b/tests/system-test/2-query/concat2.py index 717766e7ffcaafcc164cc1519d0a3a657d5e387c..544222007607e5dddb10f9347f86a603b6aebdd3 100644 --- a/tests/system-test/2-query/concat2.py +++ b/tests/system-test/2-query/concat2.py @@ -137,22 +137,22 @@ class TDTestCase: return sqls - def __test_current(self): # sourcery skip: use-itertools-product + def __test_current(self, dbname="db"): tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") tbname = [ - "t1", - "stb1", + f"{dbname}.t1", + f"{dbname}.stb1", ] for tb in tbname: for i in range(2,8): self.__concat_check(tb,i) tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========") - def __test_error(self): + def __test_error(self, dbname="db"): tdLog.printNoPrefix("==========err sql condition check , must return error==========") tbname = [ - "ct1", - "ct4", + f"{dbname}.ct1", + f"{dbname}.ct4", ] for tb in tbname: @@ -163,22 +163,20 @@ class TDTestCase: tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========") - def all_test(self): - self.__test_current() - self.__test_error() + def all_test(self, dbname="db"): + self.__test_current(dbname) + self.__test_error(dbname) - - def __create_tb(self): - tdSql.prepare() + def __create_tb(self, dbname="db"): tdLog.printNoPrefix("==========step1:create table") - create_stb_sql = f'''create table stb1( + create_stb_sql = f'''create table {dbname}.stb1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp ) tags (t1 int) ''' - create_ntb_sql = f'''create table t1( + create_ntb_sql = f'''create table {dbname}.t1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp @@ -188,29 +186,29 @@ class TDTestCase: tdSql.execute(create_ntb_sql) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') - def __insert_data(self, rows): + def __insert_data(self, rows, dbname="db"): now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) for i in range(rows): tdSql.execute( - f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f'''insert into ct1 values + f'''insert into {dbname}.ct1 values ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ''' ) tdSql.execute( - f'''insert into ct4 values + f'''insert into {dbname}.ct4 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -226,7 +224,7 @@ class TDTestCase: ) tdSql.execute( - f'''insert into ct2 values + f'''insert into {dbname}.ct2 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -242,13 +240,13 @@ class TDTestCase: ) for i in range(rows): - insert_data = f'''insert into t1 values + insert_data = f'''insert into {dbname}.t1 values ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) ''' tdSql.execute(insert_data) tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -268,23 +266,23 @@ class TDTestCase: tdSql.prepare() tdLog.printNoPrefix("==========step1:create table") - self.__create_tb() + self.__create_tb(dbname="db") tdLog.printNoPrefix("==========step2:insert data") self.rows = 10 - self.__insert_data(self.rows) + self.__insert_data(self.rows, dbname="db") tdLog.printNoPrefix("==========step3:all check") - self.all_test() + self.all_test(dbname="db") - tdDnodes.stop(1) - tdDnodes.start(1) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.execute("flush database db") tdSql.execute("use db") tdLog.printNoPrefix("==========step4:after wal, all check again ") - self.all_test() - + self.all_test(dbname="db") def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/2-query/concat_ws.py b/tests/system-test/2-query/concat_ws.py index 2c179b97ce0757670f31498c4dfa3926018854d9..ad784d92ec28ffc8da74eaa5bffa15a78c46a019 100644 --- a/tests/system-test/2-query/concat_ws.py +++ b/tests/system-test/2-query/concat_ws.py @@ -137,23 +137,23 @@ class TDTestCase: return sqls - def __test_current(self): # sourcery skip: use-itertools-product + def __test_current(self,dbname="db"): # sourcery skip: use-itertools-product tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") tbname = [ - "t1", - "stb1" + f"{dbname}.t1", + f"{dbname}.stb1" ] for tb in tbname: for i in range(2,8): self.__concat_ws_check(tb,i) tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========") - def __test_error(self): + def __test_error(self, dbname="db"): tdLog.printNoPrefix("==========err sql condition check , must return error==========") tbname = [ - "ct1", - "ct2", - "ct4", + f"{dbname}.ct1", + f"{dbname}.ct2", + f"{dbname}.ct4", ] for tb in tbname: @@ -164,22 +164,21 @@ class TDTestCase: tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========") - def all_test(self): - self.__test_current() - self.__test_error() + def all_test(self,dbname="db"): + self.__test_current(dbname) + self.__test_error(dbname) - def __create_tb(self): - tdSql.prepare() + def __create_tb(self, dbname="db"): tdLog.printNoPrefix("==========step1:create table") - create_stb_sql = f'''create table stb1( + create_stb_sql = f'''create table {dbname}.stb1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp ) tags (t1 int) ''' - create_ntb_sql = f'''create table t1( + create_ntb_sql = f'''create table {dbname}.t1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp @@ -189,29 +188,29 @@ class TDTestCase: tdSql.execute(create_ntb_sql) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') - def __insert_data(self, rows): + def __insert_data(self, rows, dbname="db"): now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) for i in range(rows): tdSql.execute( - f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f'''insert into ct1 values + f'''insert into {dbname}.ct1 values ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ''' ) tdSql.execute( - f'''insert into ct4 values + f'''insert into {dbname}.ct4 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -227,7 +226,7 @@ class TDTestCase: ) tdSql.execute( - f'''insert into ct2 values + f'''insert into {dbname}.ct2 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -243,13 +242,13 @@ class TDTestCase: ) for i in range(rows): - insert_data = f'''insert into t1 values + insert_data = f'''insert into {dbname}.t1 values ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) ''' tdSql.execute(insert_data) tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -269,22 +268,23 @@ class TDTestCase: tdSql.prepare() tdLog.printNoPrefix("==========step1:create table") - self.__create_tb() + self.__create_tb(dbname="db") tdLog.printNoPrefix("==========step2:insert data") self.rows = 10 - self.__insert_data(self.rows) + self.__insert_data(self.rows, dbname="db") tdLog.printNoPrefix("==========step3:all check") - self.all_test() + self.all_test(dbname="db") - tdDnodes.stop(1) - tdDnodes.start(1) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.execute("flush database db") tdSql.execute("use db") tdLog.printNoPrefix("==========step4:after wal, all check again ") - self.all_test() + self.all_test(dbname="db") def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/concat_ws2.py b/tests/system-test/2-query/concat_ws2.py index 477e5d1b557de513473adb31fc8cec9536b683f6..caaae6cecb655a69bddb64919eb5509a4b4faa9a 100644 --- a/tests/system-test/2-query/concat_ws2.py +++ b/tests/system-test/2-query/concat_ws2.py @@ -137,23 +137,23 @@ class TDTestCase: return sqls - def __test_current(self): # sourcery skip: use-itertools-product + def __test_current(self, dbname="db"): # sourcery skip: use-itertools-product tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") tbname = [ - "ct1", - "ct2", - "ct4", + f"{dbname}.ct1", + f"{dbname}.ct2", + f"{dbname}.ct4", ] for tb in tbname: for i in range(2,8): self.__concat_ws_check(tb,i) tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========") - def __test_error(self): + def __test_error(self, dbname="db"): tdLog.printNoPrefix("==========err sql condition check , must return error==========") tbname = [ - "t1", - "stb1" + f"{dbname}.t1", + f"{dbname}.stb1" ] for tb in tbname: @@ -164,22 +164,21 @@ class TDTestCase: tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========") - def all_test(self): - self.__test_current() - self.__test_error() + def all_test(self, dbname="db"): + self.__test_current(dbname="db") + self.__test_error(dbname="db") - def __create_tb(self): - tdSql.prepare() + def __create_tb(self, dbname="db"): tdLog.printNoPrefix("==========step1:create table") - create_stb_sql = f'''create table stb1( + create_stb_sql = f'''create table {dbname}.stb1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp ) tags (t1 int) ''' - create_ntb_sql = f'''create table t1( + create_ntb_sql = f'''create table {dbname}.t1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp @@ -189,29 +188,29 @@ class TDTestCase: tdSql.execute(create_ntb_sql) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') - def __insert_data(self, rows): + def __insert_data(self, rows, dbname="db"): now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) for i in range(rows): tdSql.execute( - f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f'''insert into ct1 values + f'''insert into {dbname}.ct1 values ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ''' ) tdSql.execute( - f'''insert into ct4 values + f'''insert into {dbname}.ct4 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -227,7 +226,7 @@ class TDTestCase: ) tdSql.execute( - f'''insert into ct2 values + f'''insert into {dbname}.ct2 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -243,13 +242,13 @@ class TDTestCase: ) for i in range(rows): - insert_data = f'''insert into t1 values + insert_data = f'''insert into {dbname}.t1 values ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) ''' tdSql.execute(insert_data) tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -269,22 +268,23 @@ class TDTestCase: tdSql.prepare() tdLog.printNoPrefix("==========step1:create table") - self.__create_tb() + self.__create_tb(dbname="db") tdLog.printNoPrefix("==========step2:insert data") self.rows = 10 - self.__insert_data(self.rows) + self.__insert_data(self.rows, dbname="db") tdLog.printNoPrefix("==========step3:all check") - self.all_test() + self.all_test(dbname="db") - tdDnodes.stop(1) - tdDnodes.start(1) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.execute("flush database db") tdSql.execute("use db") tdLog.printNoPrefix("==========step4:after wal, all check again ") - self.all_test() + self.all_test(dbname="db") def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/cos.py b/tests/system-test/2-query/cos.py index e0941b91579a76c85ff8896364bc2e8b525ceb09..ab6814727e597f03b1989770bbb3e29af4ab2669 100644 --- a/tests/system-test/2-query/cos.py +++ b/tests/system-test/2-query/cos.py @@ -9,48 +9,48 @@ from util.cases import * class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} + # updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + # "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, + # "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, powSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) - def prepare_datas(self): + def prepare_datas(self, dbname="db"): tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) ''' ) tdSql.execute( - ''' - create table t1 + f''' + create table {dbname}.t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') for i in range(9): tdSql.execute( - f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) @@ -84,12 +84,17 @@ class TDTestCase: auto_result.append(row_check) check_status = True + print("========",pow_query, origin_query ) for row_index , row in enumerate(pow_result): for col_index , elem in enumerate(row): - if auto_result[row_index][col_index] == None and not (auto_result[row_index][col_index] == None and elem == None): + if auto_result[row_index][col_index] == None and elem: check_status = False - elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001): + elif auto_result[row_index][col_index] != None and ((auto_result[row_index][col_index] != elem) and (str(auto_result[row_index][col_index])[:6] != str(elem)[:6] )): + # elif auto_result[row_index][col_index] != None and (abs(auto_result[row_index][col_index] - elem) > 0.000001): + print("=====") + print(row_index, col_index) + print(auto_result[row_index][col_index], elem, origin_result[row_index][col_index]) check_status = False else: pass @@ -99,68 +104,68 @@ class TDTestCase: else: tdLog.info("cos value check pass , it work as expected ,sql is \"%s\" "%pow_query ) - def test_errors(self): + def test_errors(self, dbname="db"): error_sql_lists = [ - "select cos from t1", - # "select cos(-+--+c1 ) from t1", - # "select +-cos(c1) from t1", - # "select ++-cos(c1) from t1", - # "select ++--cos(c1) from t1", - # "select - -cos(c1)*0 from t1", - # "select cos(tbname+1) from t1 ", - "select cos(123--123)==1 from t1", - "select cos(c1) as 'd1' from t1", - "select cos(c1 ,c2) from t1", - "select cos(c1 ,NULL ) from t1", - "select cos(,) from t1;", - "select cos(cos(c1) ab from t1)", - "select cos(c1 ) as int from t1", - "select cos from stb1", - # "select cos(-+--+c1) from stb1", - # "select +-cos(c1) from stb1", - # "select ++-cos(c1) from stb1", - # "select ++--cos(c1) from stb1", - # "select - -cos(c1)*0 from stb1", - # "select cos(tbname+1) from stb1 ", - "select cos(123--123)==1 from stb1", - "select cos(c1) as 'd1' from stb1", - "select cos(c1 ,c2 ) from stb1", - "select cos(c1 ,NULL) from stb1", - "select cos(,) from stb1;", - "select cos(cos(c1) ab from stb1)", - "select cos(c1) as int from stb1" + f"select cos from {dbname}.t1", + # f"select cos(-+--+c1 ) from {dbname}.t1", + # f"select +-cos(c1) from {dbname}.t1", + # f"select ++-cos(c1) from {dbname}.t1", + # f"select ++--cos(c1) from {dbname}.t1", + # f"select - -cos(c1)*0 from {dbname}.t1", + # f"select cos(tbname+1) from {dbname}.t1 ", + f"select cos(123--123)==1 from {dbname}.t1", + f"select cos(c1) as 'd1' from {dbname}.t1", + f"select cos(c1 ,c2) from {dbname}.t1", + f"select cos(c1 ,NULL ) from {dbname}.t1", + f"select cos(,) from {dbname}.t1;", + f"select cos(cos(c1) ab from {dbname}.t1)", + f"select cos(c1 ) as int from {dbname}.t1", + f"select cos from {dbname}.stb1", + # f"select cos(-+--+c1) from {dbname}.stb1", + # f"select +-cos(c1) from {dbname}.stb1", + # f"select ++-cos(c1) from {dbname}.stb1", + # f"select ++--cos(c1) from {dbname}.stb1", + # f"select - -cos(c1)*0 from {dbname}.stb1", + # f"select cos(tbname+1) from {dbname}.stb1 ", + f"select cos(123--123)==1 from {dbname}.stb1", + f"select cos(c1) as 'd1' from {dbname}.stb1", + f"select cos(c1 ,c2 ) from {dbname}.stb1", + f"select cos(c1 ,NULL) from {dbname}.stb1", + f"select cos(,) from {dbname}.stb1;", + f"select cos(cos(c1) ab from {dbname}.stb1)", + f"select cos(c1) as int from {dbname}.stb1" ] for error_sql in error_sql_lists: tdSql.error(error_sql) - def support_types(self): + def support_types(self, dbname="db"): type_error_sql_lists = [ - "select cos(ts) from t1" , - "select cos(c7) from t1", - "select cos(c8) from t1", - "select cos(c9) from t1", - "select cos(ts) from ct1" , - "select cos(c7) from ct1", - "select cos(c8) from ct1", - "select cos(c9) from ct1", - "select cos(ts) from ct3" , - "select cos(c7) from ct3", - "select cos(c8) from ct3", - "select cos(c9) from ct3", - "select cos(ts) from ct4" , - "select cos(c7) from ct4", - "select cos(c8) from ct4", - "select cos(c9) from ct4", - "select cos(ts) from stb1" , - "select cos(c7) from stb1", - "select cos(c8) from stb1", - "select cos(c9) from stb1" , - - "select cos(ts) from stbbb1" , - "select cos(c7) from stbbb1", - - "select cos(ts) from tbname", - "select cos(c9) from tbname" + f"select cos(ts) from {dbname}.t1" , + f"select cos(c7) from {dbname}.t1", + f"select cos(c8) from {dbname}.t1", + f"select cos(c9) from {dbname}.t1", + f"select cos(ts) from {dbname}.ct1" , + f"select cos(c7) from {dbname}.ct1", + f"select cos(c8) from {dbname}.ct1", + f"select cos(c9) from {dbname}.ct1", + f"select cos(ts) from {dbname}.ct3" , + f"select cos(c7) from {dbname}.ct3", + f"select cos(c8) from {dbname}.ct3", + f"select cos(c9) from {dbname}.ct3", + f"select cos(ts) from {dbname}.ct4" , + f"select cos(c7) from {dbname}.ct4", + f"select cos(c8) from {dbname}.ct4", + f"select cos(c9) from {dbname}.ct4", + f"select cos(ts) from {dbname}.stb1" , + f"select cos(c7) from {dbname}.stb1", + f"select cos(c8) from {dbname}.stb1", + f"select cos(c9) from {dbname}.stb1" , + + f"select cos(ts) from {dbname}.stbbb1" , + f"select cos(c7) from {dbname}.stbbb1", + + f"select cos(ts) from {dbname}.tbname", + f"select cos(c9) from {dbname}.tbname" ] @@ -169,103 +174,103 @@ class TDTestCase: type_sql_lists = [ - "select cos(c1) from t1", - "select cos(c2) from t1", - "select cos(c3) from t1", - "select cos(c4) from t1", - "select cos(c5) from t1", - "select cos(c6) from t1", - - "select cos(c1) from ct1", - "select cos(c2) from ct1", - "select cos(c3) from ct1", - "select cos(c4) from ct1", - "select cos(c5) from ct1", - "select cos(c6) from ct1", - - "select cos(c1) from ct3", - "select cos(c2) from ct3", - "select cos(c3) from ct3", - "select cos(c4) from ct3", - "select cos(c5) from ct3", - "select cos(c6) from ct3", - - "select cos(c1) from stb1", - "select cos(c2) from stb1", - "select cos(c3) from stb1", - "select cos(c4) from stb1", - "select cos(c5) from stb1", - "select cos(c6) from stb1", - - "select cos(c6) as alisb from stb1", - "select cos(c6) alisb from stb1", + f"select cos(c1) from {dbname}.t1", + f"select cos(c2) from {dbname}.t1", + f"select cos(c3) from {dbname}.t1", + f"select cos(c4) from {dbname}.t1", + f"select cos(c5) from {dbname}.t1", + f"select cos(c6) from {dbname}.t1", + + f"select cos(c1) from {dbname}.ct1", + f"select cos(c2) from {dbname}.ct1", + f"select cos(c3) from {dbname}.ct1", + f"select cos(c4) from {dbname}.ct1", + f"select cos(c5) from {dbname}.ct1", + f"select cos(c6) from {dbname}.ct1", + + f"select cos(c1) from {dbname}.ct3", + f"select cos(c2) from {dbname}.ct3", + f"select cos(c3) from {dbname}.ct3", + f"select cos(c4) from {dbname}.ct3", + f"select cos(c5) from {dbname}.ct3", + f"select cos(c6) from {dbname}.ct3", + + f"select cos(c1) from {dbname}.stb1", + f"select cos(c2) from {dbname}.stb1", + f"select cos(c3) from {dbname}.stb1", + f"select cos(c4) from {dbname}.stb1", + f"select cos(c5) from {dbname}.stb1", + f"select cos(c6) from {dbname}.stb1", + + f"select cos(c6) as alisb from {dbname}.stb1", + f"select cos(c6) alisb from {dbname}.stb1", ] for type_sql in type_sql_lists: tdSql.query(type_sql) - def basic_cosin_function(self): + def basic_cos_function(self, dbname="db"): # basic query - tdSql.query("select c1 from ct3") + tdSql.query(f"select c1 from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select c1 from t1") + tdSql.query(f"select c1 from {dbname}.t1") tdSql.checkRows(12) - tdSql.query("select c1 from stb1") + tdSql.query(f"select c1 from {dbname}.stb1") tdSql.checkRows(25) # used for empty table , ct3 is empty - tdSql.query("select cos(c1) from ct3") + tdSql.query(f"select cos(c1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select cos(c2) from ct3") + tdSql.query(f"select cos(c2) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select cos(c3) from ct3") + tdSql.query(f"select cos(c3) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select cos(c4) from ct3") + tdSql.query(f"select cos(c4) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select cos(c5) from ct3") + tdSql.query(f"select cos(c5) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select cos(c6) from ct3") + tdSql.query(f"select cos(c6) from {dbname}.ct3") tdSql.checkRows(0) # # used for regular table - tdSql.query("select cos(c1) from t1") + tdSql.query(f"select cos(c1) from {dbname}.t1") tdSql.checkData(0, 0, None) tdSql.checkData(1 , 0, 0.540302306) tdSql.checkData(3 , 0, -0.989992497) tdSql.checkData(5 , 0, None) - tdSql.query("select c1, c2, c3 , c4, c5 from t1") + tdSql.query(f"select c1, c2, c3 , c4, c5 from {dbname}.t1") tdSql.checkData(1, 4, 1.11000) tdSql.checkData(3, 3, 33) tdSql.checkData(5, 4, None) - tdSql.query("select ts,c1, c2, c3 , c4, c5 from t1") + tdSql.query(f"select ts,c1, c2, c3 , c4, c5 from {dbname}.t1") tdSql.checkData(1, 5, 1.11000) tdSql.checkData(3, 4, 33) tdSql.checkData(5, 5, None) - self.check_result_auto_cos( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from t1", "select cos(abs(c1)), cos(abs(c2)) ,cos(abs(c3)), cos(abs(c4)), cos(abs(c5)) from t1") + self.check_result_auto_cos( f"select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from {dbname}.t1", f"select cos(abs(c1)), cos(abs(c2)) ,cos(abs(c3)), cos(abs(c4)), cos(abs(c5)) from {dbname}.t1") # used for sub table - tdSql.query("select c2 ,cos(c2) from ct1") + tdSql.query(f"select c2 ,cos(c2) from {dbname}.ct1") tdSql.checkData(0, 1, 0.975339851) tdSql.checkData(1 , 1, -0.830564903) tdSql.checkData(3 , 1, 0.602244939) tdSql.checkData(4 , 1, 1.000000000) - tdSql.query("select c1, c5 ,cos(c5) from ct4") + tdSql.query(f"select c1, c5 ,cos(c5) from {dbname}.ct4") tdSql.checkData(0 , 2, None) tdSql.checkData(1 , 2, -0.855242438) tdSql.checkData(2 , 2, 0.083882969) tdSql.checkData(3 , 2, 0.929841474) tdSql.checkData(5 , 2, None) - self.check_result_auto_cos( "select c1, c2, c3 , c4, c5 from ct1", "select cos(c1), cos(c2) ,cos(c3), cos(c4), cos(c5) from ct1") + self.check_result_auto_cos( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select cos(c1), cos(c2) ,cos(c3), cos(c4), cos(c5) from {dbname}.ct1") # nest query for cos functions - tdSql.query("select c4 , cos(c4) ,cos(cos(c4)) , cos(cos(cos(c4))) from ct1;") + tdSql.query(f"select c4 , cos(c4) ,cos(cos(c4)) , cos(cos(cos(c4))) from {dbname}.ct1;") tdSql.checkData(0 , 0 , 88) tdSql.checkData(0 , 1 , 0.999373284) tdSql.checkData(0 , 2 , 0.540829563) @@ -283,22 +288,22 @@ class TDTestCase: # used for stable table - tdSql.query("select cos(c1) from stb1") + tdSql.query(f"select cos(c1) from {dbname}.stb1") tdSql.checkRows(25) # used for not exists table - tdSql.error("select cos(c1) from stbbb1") - tdSql.error("select cos(c1) from tbname") - tdSql.error("select cos(c1) from ct5") + tdSql.error(f"select cos(c1) from {dbname}.stbbb1") + tdSql.error(f"select cos(c1) from {dbname}.tbname") + tdSql.error(f"select cos(c1) from {dbname}.ct5") # mix with common col - tdSql.query("select c1, cos(c1) from ct1") - tdSql.query("select c2, cos(c2) from ct4") + tdSql.query(f"select c1, cos(c1) from {dbname}.ct1") + tdSql.query(f"select c2, cos(c2) from {dbname}.ct4") # mix with common functions - tdSql.query("select c1, cos(c1),cos(c1), cos(cos(c1)) from ct4 ") + tdSql.query(f"select c1, cos(c1),cos(c1), cos(cos(c1)) from {dbname}.ct4 ") tdSql.checkData(0 , 0 ,None) tdSql.checkData(0 , 1 ,None) tdSql.checkData(0 , 2 ,None) @@ -309,24 +314,24 @@ class TDTestCase: tdSql.checkData(3 , 2 ,0.960170287) tdSql.checkData(3 , 3 ,0.573380480) - tdSql.query("select c1, cos(c1),c5, floor(c5) from stb1 ") + tdSql.query(f"select c1, cos(c1),c5, floor(c5) from {dbname}.stb1 ") # # mix with agg functions , not support - tdSql.error("select c1, cos(c1),c5, count(c5) from stb1 ") - tdSql.error("select c1, cos(c1),c5, count(c5) from ct1 ") - tdSql.error("select cos(c1), count(c5) from stb1 ") - tdSql.error("select cos(c1), count(c5) from ct1 ") - tdSql.error("select c1, count(c5) from ct1 ") - tdSql.error("select c1, count(c5) from stb1 ") + tdSql.error(f"select c1, cos(c1),c5, count(c5) from {dbname}.stb1 ") + tdSql.error(f"select c1, cos(c1),c5, count(c5) from {dbname}.ct1 ") + tdSql.error(f"select cos(c1), count(c5) from {dbname}.stb1 ") + tdSql.error(f"select cos(c1), count(c5) from {dbname}.ct1 ") + tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ") + tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ") # agg functions mix with agg functions - tdSql.query("select max(c5), count(c5) from stb1") - tdSql.query("select max(c5), count(c5) from ct1") + tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1") + tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1") # # bug fix for compute - tdSql.query("select c1, cos(c1) -0 ,cos(c1-4)-0 from ct4 ") + tdSql.query(f"select c1, cos(c1) -0 ,cos(c1-4)-0 from {dbname}.ct4 ") tdSql.checkData(0, 0, None) tdSql.checkData(0, 1, None) tdSql.checkData(0, 2, None) @@ -334,43 +339,42 @@ class TDTestCase: tdSql.checkData(1, 1, -0.145500034) tdSql.checkData(1, 2, -0.653643621) - tdSql.query(" select c1, cos(c1) -0 ,cos(c1-0.1)-0.1 from ct4") + tdSql.query(f" select c1, cos(c1) -0 ,cos(c1-0.1)-0.1 from {dbname}.ct4") tdSql.checkData(0, 0, None) tdSql.checkData(0, 1, None) tdSql.checkData(0, 2, None) tdSql.checkData(1, 0, 8) tdSql.checkData(1, 1, -0.145500034) tdSql.checkData(1, 2, -0.146002126) + tdSql.query(f"select c1, cos(c1), c2, cos(c2), c3, cos(c3) from {dbname}.ct1") - tdSql.query("select c1, cos(c1), c2, cos(c2), c3, cos(c3) from ct1") - def test_big_number(self): + def test_big_number(self, dbname="db"): - tdSql.query("select c1, cos(100000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, cos(100000000) from {dbname}.ct1") # bigint to double data overflow tdSql.checkData(4, 1, math.cos(100000000)) - - tdSql.query("select c1, cos(10000000000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, cos(10000000000000) from {dbname}.ct1") # bigint to double data overflow tdSql.checkData(4, 1, math.cos(10000000000000)) - tdSql.query("select c1, cos(10000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, cos(10000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, cos(10000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, cos(10000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(1, 1, math.cos(10000000000000000000000000.0)) - tdSql.query("select c1, cos(10000000000000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, cos(10000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, cos(10000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, cos(10000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(4, 1, math.cos(10000000000000000000000000000000000.0)) - tdSql.query("select c1, cos(10000000000000000000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, cos(10000000000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, cos(10000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, cos(10000000000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(4, 1, math.cos(10000000000000000000000000000000000000000.0)) - tdSql.query("select c1, cos(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, cos(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow - def abs_func_filter(self): - tdSql.execute("use db") - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(cos(c1)-0.5) from ct4 where c1>5 ") + def abs_func_filter(self, dbname="db"): + tdSql.execute(f"use {dbname}") + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(cos(c1)-0.5) from {dbname}.ct4 where c1>5 ") tdSql.checkRows(3) tdSql.checkData(0,0,8) tdSql.checkData(0,1,8.000000000) @@ -378,7 +382,7 @@ class TDTestCase: tdSql.checkData(0,3,7.900000000) tdSql.checkData(0,4,0.000000000) - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(cos(c1)-0.5) from ct4 where c1=5 ") + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(cos(c1)-0.5) from {dbname}.ct4 where c1=5 ") tdSql.checkRows(1) tdSql.checkData(0,0,5) tdSql.checkData(0,1,5.000000000) @@ -386,7 +390,7 @@ class TDTestCase: tdSql.checkData(0,3,4.900000000) tdSql.checkData(0,4,0.000000000) - tdSql.query("select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(cos(c1)-0.5) from ct4 where c1>cos(c1) limit 1 ") + tdSql.query(f"select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(cos(c1)-0.5) from {dbname}.ct4 where c1>cos(c1) limit 1 ") tdSql.checkRows(1) tdSql.checkData(0,0,8) tdSql.checkData(0,1,88888) @@ -395,44 +399,38 @@ class TDTestCase: tdSql.checkData(0,4,7.900000000) tdSql.checkData(0,5,0.000000000) - def pow_Arithmetic(self): - pass - - def check_boundary_values(self): + def check_boundary_values(self, dbname="bound_test"): PI=3.1415926 - tdSql.execute("drop database if exists bound_test") - tdSql.execute("create database if not exists bound_test") + tdSql.execute(f"drop database if exists {dbname}") + tdSql.execute(f"create database if not exists {dbname}") time.sleep(3) - tdSql.execute("use bound_test") + tdSql.execute(f"use {dbname}") tdSql.execute( - "create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" + f"create table {dbname}.stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" ) - tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )') + tdSql.execute(f'create table {dbname}.sub1_bound using {dbname}.stb_bound tags ( 1 )') tdSql.execute( - f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" - ) - tdSql.error( - f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) - self.check_result_auto_cos( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from sub1_bound ", "select cos(abs(c1)), cos(abs(c2)) ,cos(abs(c3)), cos(abs(c4)), cos(abs(c5)) from sub1_bound") + # self.check_result_auto_cos( f"select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from {dbname}.sub1_bound ", f"select cos(abs(c1)), cos(abs(c2)) ,cos(abs(c3)), cos(abs(c4)), cos(abs(c5)) from {dbname}.sub1_bound") - self.check_result_auto_cos( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select cos(c1), cos(c2) ,cos(c3), cos(c3), cos(c2) ,cos(c1) from sub1_bound") + self.check_result_auto_cos( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select cos(c1), cos(c2) ,cos(c3), cos(c3), cos(c2) ,cos(c1) from {dbname}.sub1_bound") - self.check_result_auto_cos("select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from sub1_bound" , "select cos(abs(c1)) from sub1_bound" ) + self.check_result_auto_cos(f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select cos(abs(c1)) from {dbname}.sub1_bound" ) # check basic elem for table per row - tdSql.query("select cos(abs(c1)) ,cos(abs(c2)) , cos(abs(c3)) , cos(abs(c4)), cos(abs(c5)), cos(abs(c6)) from sub1_bound ") + tdSql.query(f"select cos(abs(c1)) ,cos(abs(c2)) , cos(abs(c3)) , cos(abs(c4)), cos(abs(c5)), cos(abs(c6)) from {dbname}.sub1_bound ") tdSql.checkData(0,0,math.cos(2147483647)) tdSql.checkData(0,1,math.cos(9223372036854775807)) tdSql.checkData(0,2,math.cos(32767)) @@ -450,45 +448,44 @@ class TDTestCase: tdSql.checkData(3,4,math.cos(339999995214436424907732413799364296704.00000)) # check + - * / in functions - tdSql.query("select cos(abs(c1+1)) ,cos(abs(c2)) , cos(abs(c3*1)) , cos(abs(c4/2)), cos(abs(c5))/2, cos(abs(c6)) from sub1_bound ") + tdSql.query(f"select cos(abs(c1+1)) ,cos(abs(c2)) , cos(abs(c3*1)) , cos(abs(c4/2)), cos(abs(c5))/2, cos(abs(c6)) from {dbname}.sub1_bound ") tdSql.checkData(0,0,math.cos(2147483648.000000000)) tdSql.checkData(0,1,math.cos(9223372036854775807)) tdSql.checkData(0,2,math.cos(32767.000000000)) tdSql.checkData(0,3,math.cos(63.500000000)) - tdSql.execute("create stable st (ts timestamp, num1 float, num2 double) tags (t1 int);") - tdSql.execute(f'create table tb1 using st tags (1)') - tdSql.execute(f'create table tb2 using st tags (2)') - tdSql.execute(f'create table tb3 using st tags (3)') - tdSql.execute('insert into tb1 values (now()-40s, {}, {})'.format(PI/2 ,PI/2 )) - tdSql.execute('insert into tb1 values (now()-30s, {}, {})'.format(PI ,PI )) - tdSql.execute('insert into tb1 values (now()-20s, {}, {})'.format(PI*1.5 ,PI*1.5)) - tdSql.execute('insert into tb1 values (now()-10s, {}, {})'.format(PI*2 ,PI*2)) - tdSql.execute('insert into tb1 values (now(), {}, {})'.format(PI*2.5 ,PI*2.5)) - - tdSql.execute('insert into tb2 values (now()-40s, {}, {})'.format(PI/2 ,PI/2 )) - tdSql.execute('insert into tb2 values (now()-30s, {}, {})'.format(PI ,PI )) - tdSql.execute('insert into tb2 values (now()-20s, {}, {})'.format(PI*1.5 ,PI*1.5)) - tdSql.execute('insert into tb2 values (now()-10s, {}, {})'.format(PI*2 ,PI*2)) - tdSql.execute('insert into tb2 values (now(), {}, {})'.format(PI*2.5 ,PI*2.5)) + tdSql.execute(f"create stable {dbname}.st (ts timestamp, num1 float, num2 double) tags (t1 int);") + tdSql.execute(f'create table {dbname}.tb1 using {dbname}.st tags (1)') + tdSql.execute(f'create table {dbname}.tb2 using {dbname}.st tags (2)') + tdSql.execute(f'create table {dbname}.tb3 using {dbname}.st tags (3)') + tdSql.execute(f'insert into {dbname}.tb1 values (now()-40s, {PI/2}, {PI/2})') + tdSql.execute(f'insert into {dbname}.tb1 values (now()-30s, {PI}, {PI})') + tdSql.execute(f'insert into {dbname}.tb1 values (now()-20s, {PI*1.5}, {PI*1.5})') + tdSql.execute(f'insert into {dbname}.tb1 values (now()-10s, {PI*2}, {PI*2})') + tdSql.execute(f'insert into {dbname}.tb1 values (now(), {PI*2.5}, {PI*2.5})') + + tdSql.execute(f'insert into {dbname}.tb2 values (now()-40s, {PI/2}, {PI/2})') + tdSql.execute(f'insert into {dbname}.tb2 values (now()-30s, {PI}, {PI})') + tdSql.execute(f'insert into {dbname}.tb2 values (now()-20s, {PI*1.5}, {PI*1.5})') + tdSql.execute(f'insert into {dbname}.tb2 values (now()-10s, {PI*2}, {PI*2})') + tdSql.execute(f'insert into {dbname}.tb2 values (now(), {PI*2.5}, {PI*2.5})') for i in range(100): - tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) + tdSql.execute(f'insert into {dbname}.tb3 values (now()+{i}s, {PI*(5+i)/2}, {PI*(5+i)/2})') - self.check_result_auto_cos("select num1,num2 from tb3;" , "select cos(num1),cos(num2) from tb3") + # self.check_result_auto_cos(f"select num1,num2 from {dbname}.tb3;" , f"select cos(num1),cos(num2) from {dbname}.tb3") - def support_super_table_test(self): - tdSql.execute(" use db ") - self.check_result_auto_cos( " select c5 from stb1 order by ts " , "select cos(c5) from stb1 order by ts" ) - self.check_result_auto_cos( " select c5 from stb1 order by tbname " , "select cos(c5) from stb1 order by tbname" ) - self.check_result_auto_cos( " select c5 from stb1 where c1 > 0 order by tbname " , "select cos(c5) from stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_cos( " select c5 from stb1 where c1 > 0 order by tbname " , "select cos(c5) from stb1 where c1 > 0 order by tbname" ) + def support_super_table_test(self, dbname="db"): + tdSql.execute(f" use {dbname} ") + self.check_result_auto_cos( f" select c5 from {dbname}.stb1 order by ts " , f"select cos(c5) from {dbname}.stb1 order by ts" ) + self.check_result_auto_cos( f" select c5 from {dbname}.stb1 order by tbname " , f"select cos(c5) from {dbname}.stb1 order by tbname" ) + self.check_result_auto_cos( f" select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select cos(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_cos( f" select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select cos(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_cos( " select t1,c5 from stb1 order by ts " , "select cos(t1), cos(c5) from stb1 order by ts" ) - self.check_result_auto_cos( " select t1,c5 from stb1 order by tbname " , "select cos(t1) ,cos(c5) from stb1 order by tbname" ) - self.check_result_auto_cos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select cos(t1) ,cos(c5) from stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_cos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select cos(t1) , cos(c5) from stb1 where c1 > 0 order by tbname" ) - pass + self.check_result_auto_cos( f" select t1,c5 from {dbname}.stb1 order by ts " , f"select cos(t1), cos(c5) from {dbname}.stb1 order by ts" ) + self.check_result_auto_cos( f" select t1,c5 from {dbname}.stb1 order by tbname " , f"select cos(t1) ,cos(c5) from {dbname}.stb1 order by tbname" ) + self.check_result_auto_cos( f" select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select cos(t1) ,cos(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_cos( f" select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select cos(t1) , cos(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -507,7 +504,7 @@ class TDTestCase: tdLog.printNoPrefix("==========step4: cos basic query ============") - self.basic_cosin_function() + self.basic_cos_function() tdLog.printNoPrefix("==========step5: big number cos query ============") diff --git a/tests/system-test/2-query/count.py b/tests/system-test/2-query/count.py index e047225c1f762be80a7cb0749c7b0dd617ba25c4..4d2a1cf07ce530f0cfd156981f8dcf1c5d5f135a 100644 --- a/tests/system-test/2-query/count.py +++ b/tests/system-test/2-query/count.py @@ -5,13 +5,14 @@ from util.sqlset import * class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(),logSql) + tdSql.init(conn.cursor(),False) self.setsql = TDSetSql() self.rowNum = 10 self.ts = 1537146000000 - self.ntbname = 'ntb' - self.stbname = 'stb' + dbname = "db" + self.ntbname = f'{dbname}.ntb' + self.stbname = f'{dbname}.stb' self.column_dict = { 'ts':'timestamp', 'c1':'int', diff --git a/tests/system-test/2-query/count_partition.py b/tests/system-test/2-query/count_partition.py index a25b4c09c14d92f4bd11d5a838f43ef776b91a28..90a6d9225b76fcc500c886645e9f304299d4180c 100644 --- a/tests/system-test/2-query/count_partition.py +++ b/tests/system-test/2-query/count_partition.py @@ -11,17 +11,17 @@ class TDTestCase: self.row_nums = 10 self.tb_nums = 10 self.ts = 1537146000000 - - def prepare_datas(self, stb_name , tb_nums , row_nums ): - tdSql.execute(" use db ") - tdSql.execute(f" create stable {stb_name} (ts timestamp , c1 int , c2 bigint , c3 float , c4 double , c5 smallint , c6 tinyint , c7 bool , c8 binary(36) , c9 nchar(36) , uc1 int unsigned,\ + + def prepare_datas(self, stb_name , tb_nums , row_nums, dbname="db" ): + tdSql.execute(f" use {dbname} ") + tdSql.execute(f" create stable {dbname}.{stb_name} (ts timestamp , c1 int , c2 bigint , c3 float , c4 double , c5 smallint , c6 tinyint , c7 bool , c8 binary(36) , c9 nchar(36) , uc1 int unsigned,\ uc2 bigint unsigned ,uc3 smallint unsigned , uc4 tinyint unsigned ) tags(t1 timestamp , t2 int , t3 bigint , t4 float , t5 double , t6 smallint , t7 tinyint , t8 bool , t9 binary(36)\ , t10 nchar(36) , t11 int unsigned , t12 bigint unsigned ,t13 smallint unsigned , t14 tinyint unsigned ) ") - + for i in range(tb_nums): - tbname = f"sub_{stb_name}_{i}" + tbname = f"{dbname}.sub_{stb_name}_{i}" ts = self.ts + i*10000 - tdSql.execute(f"create table {tbname} using {stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )") + tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )") for row in range(row_nums): ts = self.ts + row*1000 @@ -30,143 +30,144 @@ class TDTestCase: for null in range(5): ts = self.ts + row_nums*1000 + null*1000 tdSql.execute(f"insert into {tbname} values({ts} , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL )") - - def basic_query(self): - tdSql.query("select count(*) from stb") + + def basic_query(self, dbname="db"): + tdSql.query(f"select count(*) from {dbname}.stb") tdSql.checkData(0,0,(self.row_nums + 5 )*self.tb_nums) - tdSql.query("select count(c1) from stb") + tdSql.query(f"select count(c1) from {dbname}.stb") tdSql.checkData(0,0,(self.row_nums )*self.tb_nums) - tdSql.query(" select tbname , count(*) from stb partition by tbname ") + tdSql.query(f"select tbname , count(*) from {dbname}.stb partition by tbname ") tdSql.checkRows(self.tb_nums) - tdSql.query(" select count(c1) from stb group by t1 order by t1 ") + tdSql.query(f"select count(c1) from {dbname}.stb group by t1 order by t1 ") tdSql.checkRows(self.tb_nums) - tdSql.error(" select count(c1) from stb group by c1 order by t1 ") - tdSql.error(" select count(t1) from stb group by c1 order by t1 ") - tdSql.query(" select count(c1) from stb group by tbname order by tbname ") + tdSql.error(f"select count(c1) from {dbname}.stb group by c1 order by t1 ") + tdSql.error(f"select count(t1) from {dbname}.stb group by c1 order by t1 ") + tdSql.query(f"select count(c1) from {dbname}.stb group by tbname order by tbname ") tdSql.checkRows(self.tb_nums) - # bug need fix - # tdSql.query(" select count(t1) from stb group by t2 order by t2 ") + # bug need fix + # tdSql.query(f"select count(t1) from {dbname}.stb group by t2 order by t2 ") # tdSql.checkRows(self.tb_nums) - tdSql.query(" select count(c1) from stb group by c1 order by c1 ") + tdSql.query(f"select count(c1) from {dbname}.stb group by c1 order by c1 ") tdSql.checkRows(self.row_nums+1) - tdSql.query(" select c1 , count(c1) from stb group by c1 order by c1 ") + tdSql.query(f"select c1 , count(c1) from {dbname}.stb group by c1 order by c1 ") tdSql.checkRows(self.row_nums+1) - tdSql.query("select count(c1) from stb group by abs(c1) order by abs(c1)") + tdSql.query(f"select count(c1) from {dbname}.stb group by abs(c1) order by abs(c1)") tdSql.checkRows(self.row_nums+1) - tdSql.query("select abs(c1+c3), count(c1+c3) from stb group by abs(c1+c3) order by abs(c1+c3)") + tdSql.query(f"select abs(c1+c3), count(c1+c3) from {dbname}.stb group by abs(c1+c3) order by abs(c1+c3)") tdSql.checkRows(self.row_nums+1) - tdSql.query("select count(c1+c3)+max(c2) ,abs(c1) from stb group by abs(c1) order by abs(c1)") + tdSql.query(f"select count(c1+c3)+max(c2) ,abs(c1) from {dbname}.stb group by abs(c1) order by abs(c1)") tdSql.checkRows(self.row_nums+1) - tdSql.error("select count(c1+c3)+max(c2) ,abs(c1) ,abs(t1) from stb group by abs(c1) order by abs(t1)+c2") - tdSql.error("select count(c1+c3)+max(c2) ,abs(c1) from stb group by abs(c1) order by abs(c1)+c2") - tdSql.query("select abs(c1+c3)+abs(c2) , count(c1+c3)+count(c2) from stb group by abs(c1+c3)+abs(c2) order by abs(c1+c3)+abs(c2)") + tdSql.error(f"select count(c1+c3)+max(c2) ,abs(c1) ,abs(t1) from {dbname}.stb group by abs(c1) order by abs(t1)+c2") + tdSql.error(f"select count(c1+c3)+max(c2) ,abs(c1) from {dbname}.stb group by abs(c1) order by abs(c1)+c2") + tdSql.query(f"select abs(c1+c3)+abs(c2) , count(c1+c3)+count(c2) from {dbname}.stb group by abs(c1+c3)+abs(c2) order by abs(c1+c3)+abs(c2)") tdSql.checkRows(self.row_nums+1) - tdSql.query("select count(c1) , count(t2) from stb where abs(c1+t2)=1 partition by tbname") + tdSql.query(f"select count(c1) , count(t2) from {dbname}.stb where abs(c1+t2)=1 partition by tbname") tdSql.checkRows(2) - tdSql.query("select count(c1) from stb where abs(c1+t2)=1 partition by tbname") + tdSql.query(f"select count(c1) from {dbname}.stb where abs(c1+t2)=1 partition by tbname") tdSql.checkRows(2) - - tdSql.query("select tbname , count(c1) from stb partition by tbname order by tbname") + + tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname order by tbname") tdSql.checkRows(self.tb_nums) tdSql.checkData(0,1,self.row_nums) - tdSql.error("select tbname , count(c1) from stb partition by t1 order by t1") - tdSql.error("select tbname , count(t1) from stb partition by t1 order by t1") - tdSql.error("select tbname , count(t1) from stb partition by t2 order by t2") + tdSql.error(f"select tbname , count(c1) from {dbname}.stb partition by t1 order by t1") + tdSql.error(f"select tbname , count(t1) from {dbname}.stb partition by t1 order by t1") + tdSql.error(f"select tbname , count(t1) from {dbname}.stb partition by t2 order by t2") - # # bug need fix - # tdSql.query("select t2 , count(t1) from stb partition by t2 order by t2") + # # bug need fix + # tdSql.query(f"select t2 , count(t1) from {dbname}.stb partition by t2 order by t2") # tdSql.checkRows(self.tb_nums) - tdSql.query("select tbname , count(c1) from stb partition by tbname order by tbname") + tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname order by tbname") tdSql.checkRows(self.tb_nums) tdSql.checkData(0,1,self.row_nums) - - tdSql.error("select tbname , count(c1) from stb partition by t2 order by t2") - tdSql.query("select c2, count(c1) from stb partition by c2 order by c2 desc") + tdSql.error(f"select tbname , count(c1) from {dbname}.stb partition by t2 order by t2") + + tdSql.query(f"select c2, count(c1) from {dbname}.stb partition by c2 order by c2 desc") tdSql.checkRows(self.tb_nums+1) tdSql.checkData(0,1,self.tb_nums) - tdSql.error("select tbname , count(c1) from stb partition by c1 order by c2") + tdSql.error(f"select tbname , count(c1) from {dbname}.stb partition by c1 order by c2") - tdSql.query("select tbname , abs(t2) from stb partition by c2 order by t2") + tdSql.query(f"select tbname , abs(t2) from {dbname}.stb partition by c2 order by t2") tdSql.checkRows(self.tb_nums*(self.row_nums+5)) - tdSql.query("select count(c1) , count(t2) from stb partition by c2 ") + tdSql.query(f"select count(c1) , count(t2) from {dbname}.stb partition by c2 ") tdSql.checkRows(self.row_nums+1) tdSql.checkData(0,1,self.row_nums) - tdSql.query("select count(c1) , count(t2) ,c2 from stb partition by c2 order by c2") + tdSql.query(f"select count(c1) , count(t2) ,c2 from {dbname}.stb partition by c2 order by c2") tdSql.checkRows(self.row_nums+1) - tdSql.query("select count(c1) , count(t1) ,max(c2) ,tbname from stb partition by tbname order by tbname") + tdSql.query(f"select count(c1) , count(t1) ,max(c2) ,tbname from {dbname}.stb partition by tbname order by tbname") tdSql.checkRows(self.tb_nums) tdSql.checkCols(4) - tdSql.query("select count(c1) , count(t2) ,t1 from stb partition by t1 order by t1") + tdSql.query(f"select count(c1) , count(t2) ,t1 from {dbname}.stb partition by t1 order by t1") tdSql.checkRows(self.tb_nums) tdSql.checkData(0,0,self.row_nums) - # bug need fix - # tdSql.query("select count(c1) , count(t1) ,abs(c1) from stb partition by abs(c1) order by abs(c1)") + # bug need fix + # tdSql.query(f"select count(c1) , count(t1) ,abs(c1) from {dbname}.stb partition by abs(c1) order by abs(c1)") # tdSql.checkRows(self.row_nums+1) - - tdSql.query("select count(ceil(c2)) , count(floor(t2)) ,count(floor(c2)) from stb partition by abs(c2) order by abs(c2)") + + tdSql.query(f"select count(ceil(c2)) , count(floor(t2)) ,count(floor(c2)) from {dbname}.stb partition by abs(c2) order by abs(c2)") tdSql.checkRows(self.row_nums+1) - tdSql.query("select count(ceil(c1-2)) , count(floor(t2+1)) ,max(c2-c1) from stb partition by abs(floor(c1)) order by abs(floor(c1))") + tdSql.query(f"select count(ceil(c1-2)) , count(floor(t2+1)) ,max(c2-c1) from {dbname}.stb partition by abs(floor(c1)) order by abs(floor(c1))") tdSql.checkRows(self.row_nums+1) - - # interval - tdSql.query("select count(c1) from stb interval(2s) sliding(1s)") + + # interval + tdSql.query(f"select count(c1) from {dbname}.stb interval(2s) sliding(1s)") # bug need fix - tdSql.query('select max(c1) from stb where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s) fill(NULL)') + tdSql.query(f'select max(c1) from {dbname}.stb where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s) fill(NULL)') - tdSql.query(" select tbname , count(c1) from stb partition by tbname interval(10s) slimit 5 soffset 1 ") + tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname interval(10s) slimit 5 soffset 1 ") - tdSql.query("select tbname , count(c1) from stb partition by tbname interval(10s)") + tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname interval(10s)") - tdSql.query("select tbname , count(c1) from sub_stb_1 partition by tbname interval(10s)") + tdSql.query(f"select tbname , count(c1) from {dbname}.sub_stb_1 partition by tbname interval(10s)") tdSql.checkData(0,0,'sub_stb_1') tdSql.checkData(0,1,self.row_nums) - # tdSql.query(" select tbname , count(c1) from stb partition by tbname order by tbname slimit 5 soffset 0 ") + # tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname order by tbname slimit 5 soffset 0 ") + # tdSql.checkRows(5) + + # tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname order by tbname slimit 5 soffset 1 ") # tdSql.checkRows(5) - - # tdSql.query(" select tbname , count(c1) from stb partition by tbname order by tbname slimit 5 soffset 1 ") - # tdSql.checkRows(5) - - tdSql.query(" select tbname , count(c1) from sub_stb_1 partition by tbname interval(10s) sliding(5s) ") - - tdSql.query(f'select max(c1) from stb where ts>={self.ts} and ts < {self.ts}+10000 partition by tbname interval(50s) sliding(30s)') - tdSql.query(f'select max(c1) from stb where ts>={self.ts} and ts < {self.ts}+10000 interval(50s) sliding(30s)') - tdSql.query(f'select tbname , count(c1) from stb where ts>={self.ts} and ts < {self.ts}+10000 partition by tbname interval(50s) sliding(30s)') + + tdSql.query(f"select tbname , count(c1) from {dbname}.sub_stb_1 partition by tbname interval(10s) sliding(5s) ") + + tdSql.query(f'select max(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+10000 partition by tbname interval(50s) sliding(30s)') + tdSql.query(f'select max(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+10000 interval(50s) sliding(30s)') + tdSql.query(f'select tbname , count(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+10000 partition by tbname interval(50s) sliding(30s)') def run(self): tdSql.prepare() self.prepare_datas("stb",self.tb_nums,self.row_nums) self.basic_query() + dbname="db" + + # # coverage case for taosd crash about bug fix + tdSql.query(f"select sum(c1) from {dbname}.stb where t2+10 >1 ") + tdSql.query(f"select count(c1),count(t1) from {dbname}.stb where -t2<1 ") + tdSql.query(f"select tbname ,max(ceil(c1)) from {dbname}.stb group by tbname ") + tdSql.query(f"select avg(abs(c1)) , tbname from {dbname}.stb group by tbname ") + tdSql.query(f"select t1,c1 from {dbname}.stb where abs(t2+c1)=1 ") - # # coverage case for taosd crash about bug fix - tdSql.query(" select sum(c1) from stb where t2+10 >1 ") - tdSql.query(" select count(c1),count(t1) from stb where -t2<1 ") - tdSql.query(" select tbname ,max(ceil(c1)) from stb group by tbname ") - tdSql.query(" select avg(abs(c1)) , tbname from stb group by tbname ") - tdSql.query(" select t1,c1 from stb where abs(t2+c1)=1 ") - def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/system-test/2-query/csum.py b/tests/system-test/2-query/csum.py index bdb8c095e6b99a2c7f09d08dd9c0a8942cc49d7f..260528be0405c86aa6b92240ce4661fef5f27729 100644 --- a/tests/system-test/2-query/csum.py +++ b/tests/system-test/2-query/csum.py @@ -30,7 +30,7 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - def csum_query_form(self, col="c1", alias="", table_expr="t1", condition=""): + def csum_query_form(self, col="c1", alias="", table_expr="db.t1", condition=""): ''' csum function: @@ -44,7 +44,7 @@ class TDTestCase: return f"select csum({col}) {alias} from {table_expr} {condition}" - def checkcsum(self,col="c1", alias="", table_expr="t1", condition="" ): + def checkcsum(self,col="c1", alias="", table_expr="db.t1", condition="" ): line = sys._getframe().f_back.f_lineno pre_sql = self.csum_query_form( col=col, table_expr=table_expr, condition=condition @@ -59,11 +59,11 @@ class TDTestCase: tdSql.checkRows(0) return - if "order by tbname" in condition: - tdSql.error(self.csum_query_form( - col=col, alias=alias, table_expr=table_expr, condition=condition - )) - return + # if "order by tbname" in condition: + # tdSql.error(self.csum_query_form( + # col=col, alias=alias, table_expr=table_expr, condition=condition + # )) + # return if "group" in condition: @@ -123,7 +123,8 @@ class TDTestCase: return else: - tdSql.query(f"select {col} from {table_expr} {re.sub('limit [0-9]*|offset [0-9]*','',condition)}") + + tdSql.query(f"select {col} from {table_expr} {re.sub('limit [0-9]*|offset [0-9]*','',condition)} " ) offset_val = condition.split("offset")[1].split(" ")[1] if "offset" in condition else 0 pre_result = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] if (platform.system().lower() == 'windows' and pre_result.dtype == 'int32'): @@ -161,12 +162,12 @@ class TDTestCase: self.checkcsum(**case6) # case7~8: nested query - # case7 = {"table_expr": "(select c1 from stb1)"} - # self.checkcsum(**case7) - # case8 = {"table_expr": "(select csum(c1) c1 from stb1 group by tbname)"} - # self.checkcsum(**case8) + case7 = {"table_expr": "(select c1 from db.stb1 order by tbname ,ts )"} + self.checkcsum(**case7) + case8 = {"table_expr": "(select csum(c1) c1 from db.t1 partition by tbname)"} + self.checkcsum(**case8) - # case9~10: mix with tbname/ts/tag/col + # case9~10: mix with tbname/ts/tag/col not support , must partition by alias ,such as select tbname ,csum(c1) partition by tbname # case9 = {"alias": ", tbname"} # self.checkcsum(**case9) # case10 = {"alias": ", _c0"} @@ -196,37 +197,37 @@ class TDTestCase: } self.checkcsum(**case17) # case18~19: with group by - # case18 = { - # "table_expr": "t1", - # "condition": "group by c6" - # } - # self.checkcsum(**case18) - # case19 = { - # "table_expr": "stb1", - # "condition": "partition by tbname" # partition by tbname - # } - # self.checkcsum(**case19) - - # # case20~21: with order by - # case20 = {"condition": "order by ts"} - # self.checkcsum(**case20) - - # # case22: with union - # case22 = { - # "condition": "union all select csum(c1) from t2" - # } - # self.checkcsum(**case22) + case18 = { + "table_expr": "db.t1", + "condition": "where c6 <0 partition by c6 order by c6" + } + self.checkcsum(**case18) + case19 = { + "table_expr": "db.t1", + "condition": " " # partition by tbname + } + self.checkcsum(**case19) + + # case20~21: with order by + case20 = {"condition": "partition by tbname order by tbname "} + # self.checkcsum(**case20) # order by without order by tbname ,because check will random failed + + # case22: with union + case22 = { + "condition": "union all select csum(c1) from db.t2" + } + # self.checkcsum(**case22) union all without check result becasue ,it will random return table_records # case23: with limit/slimit case23 = { "condition": "limit 1" } self.checkcsum(**case23) - # case24 = { - # "table_expr": "stb1", - # "condition": "group by tbname slimit 1 soffset 1" - # } - # self.checkcsum(**case24) + case24 = { + "table_expr": "db.t1", + "condition": "partition by tbname " + } + self.checkcsum(**case24) pass @@ -291,17 +292,17 @@ class TDTestCase: } tdSql.error(self.csum_query_form(**interval_sql)) # interval group_normal_col = { - "table_expr": "t1", + "table_expr": "db.t1", "condition": "group by c6" } tdSql.error(self.csum_query_form(**group_normal_col)) # group by normal col slimit_soffset_sql = { - "table_expr": "stb1", + "table_expr": "db.stb1", "condition": "group by tbname slimit 1 soffset 1" } # tdSql.error(self.csum_query_form(**slimit_soffset_sql)) order_by_tbname_sql = { - "table_expr": "stb1", + "table_expr": "db.stb1", "condition": "group by tbname order by tbname" } tdSql.error(self.csum_query_form(**order_by_tbname_sql)) @@ -346,8 +347,8 @@ class TDTestCase: "create stable db.stb2 (ts timestamp, c1 int) tags(st2 int)" ) for i in range(tbnum): - tdSql.execute(f"create table t{i} using stb1 tags({i})") - tdSql.execute(f"create table tt{i} using stb2 tags({i})") + tdSql.execute(f"create table db.t{i} using db.stb1 tags({i})") + tdSql.execute(f"create table db.tt{i} using db.stb2 tags({i})") pass @@ -364,25 +365,25 @@ class TDTestCase: tdLog.printNoPrefix("######## insert only NULL test:") for i in range(tbnum): - tdSql.execute(f"insert into t{i}(ts) values ({nowtime - 5})") - tdSql.execute(f"insert into t{i}(ts) values ({nowtime + 5})") + tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime - 5})") + tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime + 5})") self.csum_current_query() self.csum_error_query() tdLog.printNoPrefix("######## insert data in the range near the max(bigint/double):") self.csum_test_table(tbnum) - tdSql.execute(f"insert into t1(ts, c1,c2,c5,c7) values " + tdSql.execute(f"insert into db.t1(ts, c1,c2,c5,c7) values " f"({nowtime - (per_table_rows + 1) * 10}, {2**31-1}, {3.4*10**38}, {1.7*10**308}, {2**63-1})") - tdSql.execute(f"insert into t1(ts, c1,c2,c5,c7) values " + tdSql.execute(f"insert into db.t1(ts, c1,c2,c5,c7) values " f"({nowtime - (per_table_rows + 2) * 10}, {2**31-1}, {3.4*10**38}, {1.7*10**308}, {2**63-1})") self.csum_current_query() self.csum_error_query() tdLog.printNoPrefix("######## insert data in the range near the min(bigint/double):") self.csum_test_table(tbnum) - tdSql.execute(f"insert into t1(ts, c1,c2,c5,c7) values " + tdSql.execute(f"insert into db.t1(ts, c1,c2,c5,c7) values " f"({nowtime - (per_table_rows + 1) * 10}, {1-2**31}, {-3.4*10**38}, {-1.7*10**308}, {1-2**63})") - tdSql.execute(f"insert into t1(ts, c1,c2,c5,c7) values " + tdSql.execute(f"insert into db.t1(ts, c1,c2,c5,c7) values " f"({nowtime - (per_table_rows + 2) * 10}, {1-2**31}, {-3.4*10**38}, {-1.7*10**308}, {512-2**63})") self.csum_current_query() self.csum_error_query() @@ -396,9 +397,9 @@ class TDTestCase: tdLog.printNoPrefix("######## insert data mix with NULL test:") for i in range(tbnum): - tdSql.execute(f"insert into t{i}(ts) values ({nowtime})") - tdSql.execute(f"insert into t{i}(ts) values ({nowtime-(per_table_rows+3)*10})") - tdSql.execute(f"insert into t{i}(ts) values ({nowtime+(per_table_rows+3)*10})") + tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime})") + tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime-(per_table_rows+3)*10})") + tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime+(per_table_rows+3)*10})") self.csum_current_query() self.csum_error_query() @@ -411,65 +412,65 @@ class TDTestCase: tdDnodes.start(index) self.csum_current_query() self.csum_error_query() - tdSql.query("select csum(1) from t1 ") + tdSql.query("select csum(1) from db.t1 ") tdSql.checkRows(7) tdSql.checkData(0,0,1) tdSql.checkData(1,0,2) tdSql.checkData(2,0,3) tdSql.checkData(3,0,4) - tdSql.query("select csum(abs(c1))+2 from t1 ") + tdSql.query("select csum(abs(c1))+2 from db.t1 ") tdSql.checkRows(4) def csum_support_stable(self): - tdSql.query(" select csum(1) from stb1 ") + tdSql.query(" select csum(1) from db.stb1 ") tdSql.checkRows(70) - tdSql.query("select csum(c1) from stb1 partition by tbname ") + tdSql.query("select csum(c1) from db.stb1 partition by tbname ") tdSql.checkRows(40) - tdSql.query("select csum(st1) from stb1 partition by tbname") + tdSql.query("select csum(st1) from db.stb1 partition by tbname") tdSql.checkRows(70) - tdSql.query("select csum(st1+c1) from stb1 partition by tbname") + tdSql.query("select csum(st1+c1) from db.stb1 partition by tbname") tdSql.checkRows(40) - tdSql.query("select csum(st1+c1) from stb1 partition by tbname") + tdSql.query("select csum(st1+c1) from db.stb1 partition by tbname") tdSql.checkRows(40) - tdSql.query("select csum(st1+c1) from stb1 partition by tbname") + tdSql.query("select csum(st1+c1) from db.stb1 partition by tbname") tdSql.checkRows(40) # # bug need fix - tdSql.query("select csum(st1+c1) from stb1 partition by tbname slimit 1 ") + tdSql.query("select csum(st1+c1) from db.stb1 partition by tbname slimit 1 ") tdSql.checkRows(4) - # tdSql.error("select csum(st1+c1) from stb1 partition by tbname limit 1 ") + # tdSql.error("select csum(st1+c1) from db.stb1 partition by tbname limit 1 ") # bug need fix - tdSql.query("select csum(st1+c1) from stb1 partition by tbname") + tdSql.query("select csum(st1+c1) from db.stb1 partition by tbname") tdSql.checkRows(40) # bug need fix - tdSql.query("select tbname , csum(c1) from stb1 partition by tbname") + tdSql.query("select tbname , csum(c1) from db.stb1 partition by tbname") tdSql.checkRows(40) - tdSql.query("select tbname , csum(st1) from stb1 partition by tbname") + tdSql.query("select tbname , csum(st1) from db.stb1 partition by tbname") tdSql.checkRows(70) - tdSql.query("select tbname , csum(st1) from stb1 partition by tbname slimit 1") + tdSql.query("select tbname , csum(st1) from db.stb1 partition by tbname slimit 1") tdSql.checkRows(7) # partition by tags - tdSql.query("select st1 , csum(c1) from stb1 partition by st1") + tdSql.query("select st1 , csum(c1) from db.stb1 partition by st1") tdSql.checkRows(40) - tdSql.query("select csum(c1) from stb1 partition by st1") + tdSql.query("select csum(c1) from db.stb1 partition by st1") tdSql.checkRows(40) - tdSql.query("select st1 , csum(c1) from stb1 partition by st1 slimit 1") + tdSql.query("select st1 , csum(c1) from db.stb1 partition by st1 slimit 1") tdSql.checkRows(4) - tdSql.query("select csum(c1) from stb1 partition by st1 slimit 1") + tdSql.query("select csum(c1) from db.stb1 partition by st1 slimit 1") tdSql.checkRows(4) # partition by col - # tdSql.query("select c1 , csum(c1) from stb1 partition by c1") + # tdSql.query("select c1 , csum(c1) from db.stb1 partition by c1") # tdSql.checkRows(41) - # tdSql.query("select csum(c1) from stb1 partition by c1") + # tdSql.query("select csum(c1) from db.stb1 partition by c1") # tdSql.checkRows(41) - # tdSql.query("select c1 , csum(c1) from stb1 partition by st1 slimit 1") + # tdSql.query("select c1 , csum(c1) from db.stb1 partition by st1 slimit 1") # tdSql.checkRows(4) - # tdSql.query("select csum(c1) from stb1 partition by st1 slimit 1") + # tdSql.query("select csum(c1) from db.stb1 partition by st1 slimit 1") # tdSql.checkRows(4) diff --git a/tests/system-test/2-query/db.py b/tests/system-test/2-query/db.py index a4d603bada851fab2870a6331cb215ee90738e53..f2d85ebf6599970f99c302f080cda0b3ef6f3320 100644 --- a/tests/system-test/2-query/db.py +++ b/tests/system-test/2-query/db.py @@ -10,9 +10,6 @@ import random class TDTestCase: - updatecfgDict = {'debugFlag': 143, "cDebugFlag": 143, "uDebugFlag": 143, "rpcDebugFlag": 143, "tmrDebugFlag": 143, - "jniDebugFlag": 143, "simDebugFlag": 143, "dDebugFlag": 143, "dDebugFlag": 143, "vDebugFlag": 143, "mDebugFlag": 143, "qDebugFlag": 143, - "wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "udfDebugFlag": 143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") @@ -26,22 +23,22 @@ class TDTestCase: tdSql.execute("create table dbms.ntb (ts timestamp, c1 int, c2 bigint)") tdSql.execute("create table dbus.ntb (ts timestamp, c1 int, c2 bigint)") tdSql.execute("create table dbns.ntb (ts timestamp, c1 int, c2 bigint)") - + tdSql.execute("insert into dbms.ntb values ('2022-01-01 08:00:00.001', 1, 2)") tdSql.execute("insert into dbms.ntb values ('2022-01-01 08:00:00.002', 3, 4)") - + tdSql.execute("insert into dbus.ntb values ('2022-01-01 08:00:00.000001', 1, 2)") tdSql.execute("insert into dbus.ntb values ('2022-01-01 08:00:00.000002', 3, 4)") - + tdSql.execute("insert into dbns.ntb values ('2022-01-01 08:00:00.000000001', 1, 2)") tdSql.execute("insert into dbns.ntb values ('2022-01-01 08:00:00.000000002', 3, 4)") - + tdSql.query("select count(c1) from dbms.ntb interval(1a)") tdSql.checkRows(2) - + tdSql.query("select count(c1) from dbus.ntb interval(1u)") tdSql.checkRows(2) - + tdSql.query("select count(c1) from dbns.ntb interval(1b)") tdSql.checkRows(2) diff --git a/tests/system-test/2-query/diff.py b/tests/system-test/2-query/diff.py index 30b588fa97025f4ee50f7f0e8bf2f07331e4711c..76d4891a1c8c3e7d90c0c498f70a7b1fd7b59d6a 100644 --- a/tests/system-test/2-query/diff.py +++ b/tests/system-test/2-query/diff.py @@ -18,116 +18,117 @@ class TDTestCase: def run(self): tdSql.prepare() + dbname = "db" tdSql.execute( - "create table ntb(ts timestamp,c1 int,c2 double,c3 float)") + f"create table {dbname}.ntb(ts timestamp,c1 int,c2 double,c3 float)") tdSql.execute( - "insert into ntb values(now,1,1.0,10.5)(now+1s,10,-100.0,5.1)(now+10s,-1,15.1,5.0)") + f"insert into {dbname}.ntb values(now,1,1.0,10.5)(now+1s,10,-100.0,5.1)(now+10s,-1,15.1,5.0)") - tdSql.query("select diff(c1,0) from ntb") + tdSql.query(f"select diff(c1,0) from {dbname}.ntb") tdSql.checkRows(2) tdSql.checkData(0, 0, 9) tdSql.checkData(1, 0, -11) - tdSql.query("select diff(c1,1) from ntb") + tdSql.query(f"select diff(c1,1) from {dbname}.ntb") tdSql.checkRows(2) tdSql.checkData(0, 0, 9) tdSql.checkData(1, 0, None) - tdSql.query("select diff(c2,0) from ntb") + tdSql.query(f"select diff(c2,0) from {dbname}.ntb") tdSql.checkRows(2) tdSql.checkData(0, 0, -101) tdSql.checkData(1, 0, 115.1) - tdSql.query("select diff(c2,1) from ntb") + tdSql.query(f"select diff(c2,1) from {dbname}.ntb") tdSql.checkRows(2) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, 115.1) - tdSql.query("select diff(c3,0) from ntb") + tdSql.query(f"select diff(c3,0) from {dbname}.ntb") tdSql.checkRows(2) tdSql.checkData(0, 0, -5.4) tdSql.checkData(1, 0, -0.1) - tdSql.query("select diff(c3,1) from ntb") + tdSql.query(f"select diff(c3,1) from {dbname}.ntb") tdSql.checkRows(2) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) - tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + tdSql.execute(f'''create table {dbname}.stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') - tdSql.execute("create table stb_1 using stb tags('beijing')") + tdSql.execute(f"create table {dbname}.stb_1 using {dbname}.stb tags('beijing')") tdSql.execute( - "insert into stb_1 values(%d, 0, 0, 0, 0, 0.0, 0.0, False, ' ', ' ', 0, 0, 0, 0)" % (self.ts - 1)) + f"insert into {dbname}.stb_1 values(%d, 0, 0, 0, 0, 0.0, 0.0, False, ' ', ' ', 0, 0, 0, 0)" % (self.ts - 1)) # diff verifacation - tdSql.query("select diff(col1) from stb_1") + tdSql.query(f"select diff(col1) from {dbname}.stb_1") tdSql.checkRows(0) - tdSql.query("select diff(col2) from stb_1") + tdSql.query(f"select diff(col2) from {dbname}.stb_1") tdSql.checkRows(0) - tdSql.query("select diff(col3) from stb_1") + tdSql.query(f"select diff(col3) from {dbname}.stb_1") tdSql.checkRows(0) - tdSql.query("select diff(col4) from stb_1") + tdSql.query(f"select diff(col4) from {dbname}.stb_1") tdSql.checkRows(0) - tdSql.query("select diff(col5) from stb_1") + tdSql.query(f"select diff(col5) from {dbname}.stb_1") tdSql.checkRows(0) - tdSql.query("select diff(col6) from stb_1") + tdSql.query(f"select diff(col6) from {dbname}.stb_1") tdSql.checkRows(0) - tdSql.query("select diff(col7) from stb_1") + tdSql.query(f"select diff(col7) from {dbname}.stb_1") tdSql.checkRows(0) for i in range(self.rowNum): - tdSql.execute("insert into stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + tdSql.execute(f"insert into {dbname}.stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) - tdSql.error("select diff(ts) from stb") - tdSql.error("select diff(ts) from stb_1") + tdSql.error(f"select diff(ts) from {dbname}.stb") + tdSql.error(f"select diff(ts) from {dbname}.stb_1") - # tdSql.error("select diff(col7) from stb") + # tdSql.error(f"select diff(col7) from {dbname}.stb") - tdSql.error("select diff(col8) from stb") - tdSql.error("select diff(col8) from stb_1") - tdSql.error("select diff(col9) from stb") - tdSql.error("select diff(col9) from stb_1") - tdSql.error("select diff(col11) from stb_1") - tdSql.error("select diff(col12) from stb_1") - tdSql.error("select diff(col13) from stb_1") - tdSql.error("select diff(col14) from stb_1") - tdSql.error("select ts,diff(col1),ts from stb_1") + tdSql.error(f"select diff(col8) from {dbname}.stb") + tdSql.error(f"select diff(col8) from {dbname}.stb_1") + tdSql.error(f"select diff(col9) from {dbname}.stb") + tdSql.error(f"select diff(col9) from {dbname}.stb_1") + tdSql.error(f"select diff(col11) from {dbname}.stb_1") + tdSql.error(f"select diff(col12) from {dbname}.stb_1") + tdSql.error(f"select diff(col13) from {dbname}.stb_1") + tdSql.error(f"select diff(col14) from {dbname}.stb_1") + tdSql.query(f"select ts,diff(col1),ts from {dbname}.stb_1") - tdSql.query("select diff(col1) from stb_1") + tdSql.query(f"select diff(col1) from {dbname}.stb_1") tdSql.checkRows(10) - tdSql.query("select diff(col2) from stb_1") + tdSql.query(f"select diff(col2) from {dbname}.stb_1") tdSql.checkRows(10) - tdSql.query("select diff(col3) from stb_1") + tdSql.query(f"select diff(col3) from {dbname}.stb_1") tdSql.checkRows(10) - tdSql.query("select diff(col4) from stb_1") + tdSql.query(f"select diff(col4) from {dbname}.stb_1") tdSql.checkRows(10) - tdSql.query("select diff(col5) from stb_1") + tdSql.query(f"select diff(col5) from {dbname}.stb_1") tdSql.checkRows(10) - tdSql.query("select diff(col6) from stb_1") + tdSql.query(f"select diff(col6) from {dbname}.stb_1") tdSql.checkRows(10) - tdSql.execute('''create table stb1(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + tdSql.execute(f'''create table {dbname}.stb1(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') - tdSql.execute("create table stb1_1 using stb tags('shanghai')") + tdSql.execute(f"create table {dbname}.stb1_1 using {dbname}.stb tags('shanghai')") for i in range(self.rowNum): - tdSql.execute("insert into stb1_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + tdSql.execute(f"insert into {dbname}.stb1_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) for i in range(self.rowNum): - tdSql.execute("insert into stb1_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + tdSql.execute(f"insert into {dbname}.stb1_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" % (self.ts - i-1, i-1, i-1, i-1, i-1, -i - 0.1, -i - 0.1, -i % 2, i - 1, i - 1, i + 1, i + 1, i + 1, i + 1)) - tdSql.query("select diff(col1,0) from stb1_1") + tdSql.query(f"select diff(col1,0) from {dbname}.stb1_1") tdSql.checkRows(19) - tdSql.query("select diff(col1,1) from stb1_1") + tdSql.query(f"select diff(col1,1) from {dbname}.stb1_1") tdSql.checkRows(19) tdSql.checkData(0,0,None) diff --git a/tests/system-test/2-query/distinct.py b/tests/system-test/2-query/distinct.py index 937ff78c71eba9ec617ddd9a05b04f22e2229820..7214caec969f89090f7cc1db28ae787a5de84b17 100644 --- a/tests/system-test/2-query/distinct.py +++ b/tests/system-test/2-query/distinct.py @@ -16,6 +16,8 @@ class TDTestCase: def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() + dbname = "db" + tdLog.printNoPrefix("==========step1:create table") tdSql.execute("create stable db.stb1 (ts timestamp, c1 int, c2 int) tags(t0 tinyint, t1 int, t2 int)") tdSql.execute("create stable db.stb2 (ts timestamp, c2 int, c3 binary(16)) tags(t2 binary(16), t3 binary(16), t4 int)") @@ -34,223 +36,224 @@ class TDTestCase: tdSql.execute(f"insert into db.t0{i} values (now-9d, {i}, '{(i+2)%3}')") tdSql.execute(f"insert into db.t0{i} values (now-8d, {i}, '{(i)%3}')") tdSql.execute(f"insert into db.t0{i} (ts )values (now-7d)") - # tdSql.execute("create table db.t100num using db.stb1 tags(null, null, null)") - # tdSql.execute("create table db.t0100num using db.stb2 tags(null, null, null)") - # tdSql.execute(f"insert into db.t100num values (now-10d, {tbnum-1}, 1)") - # tdSql.execute(f"insert into db.t100num values (now-9d, {tbnum-1}, 0)") - # tdSql.execute(f"insert into db.t100num values (now-8d, {tbnum-1}, 2)") - # tdSql.execute(f"insert into db.t100num (ts )values (now-7d)") - # tdSql.execute(f"insert into db.t0100num values (now-10d, {tbnum-1}, 1)") - # tdSql.execute(f"insert into db.t0100num values (now-9d, {tbnum-1}, 0)") - # tdSql.execute(f"insert into db.t0100num values (now-8d, {tbnum-1}, 2)") - # tdSql.execute(f"insert into db.t0100num (ts )values (now-7d)") + tdSql.execute("create table db.t100num using db.stb1 tags(null, null, null)") + tdSql.execute("create table db.t0100num using db.stb2 tags(null, null, null)") + tdSql.execute(f"insert into db.t100num values (now-10d, {tbnum-1}, 1)") + tdSql.execute(f"insert into db.t100num values (now-9d, {tbnum-1}, 0)") + tdSql.execute(f"insert into db.t100num values (now-8d, {tbnum-1}, 2)") + tdSql.execute(f"insert into db.t100num (ts )values (now-7d)") + tdSql.execute(f"insert into db.t0100num values (now-10d, {tbnum-1}, 1)") + tdSql.execute(f"insert into db.t0100num values (now-9d, {tbnum-1}, 0)") + tdSql.execute(f"insert into db.t0100num values (now-8d, {tbnum-1}, 2)") + tdSql.execute(f"insert into db.t0100num (ts )values (now-7d)") - #========== distinct multi-data-coloumn ========== - # tdSql.query(f"select distinct c1 from stb1 where c1 <{tbnum}") - # tdSql.checkRows(tbnum) - # tdSql.query(f"select distinct c2 from stb1") - # tdSql.checkRows(4) - # tdSql.query(f"select distinct c1,c2 from stb1 where c1 <{tbnum}") - # tdSql.checkRows(tbnum*3) - # tdSql.query(f"select distinct c1,c1 from stb1 where c1 <{tbnum}") - # tdSql.checkRows(tbnum) - # tdSql.query(f"select distinct c1,c2 from stb1 where c1 <{tbnum} limit 3") - # tdSql.checkRows(3) - # tdSql.query(f"select distinct c1,c2 from stb1 where c1 <{tbnum} limit 3 offset {tbnum*3-2}") - # tdSql.checkRows(2) + # #========== distinct multi-data-coloumn ========== + tdSql.query(f"select distinct c1 from {dbname}.stb1 where c1 <{tbnum}") + tdSql.checkRows(tbnum) + tdSql.query(f"select distinct c2 from {dbname}.stb1") + tdSql.checkRows(4) + tdSql.query(f"select distinct c1,c2 from {dbname}.stb1 where c1 <{tbnum}") + tdSql.checkRows(tbnum*3) + tdSql.query(f"select distinct c1,c1 from {dbname}.stb1 where c1 <{tbnum}") + tdSql.checkRows(tbnum) + tdSql.query(f"select distinct c1,c2 from {dbname}.stb1 where c1 <{tbnum} limit 3") + tdSql.checkRows(3) + tdSql.query(f"select distinct c1,c2 from {dbname}.stb1 where c1 <{tbnum} limit 3 offset {tbnum*3-2}") + tdSql.checkRows(2) - tdSql.query(f"select distinct c1 from t1 where c1 <{tbnum}") + tdSql.query(f"select distinct c1 from {dbname}.t1 where c1 <{tbnum}") tdSql.checkRows(1) - tdSql.query(f"select distinct c2 from t1") + tdSql.query(f"select distinct c2 from {dbname}.t1") tdSql.checkRows(4) - tdSql.query(f"select distinct c1,c2 from t1 where c1 <{tbnum}") + tdSql.query(f"select distinct c1,c2 from {dbname}.t1 where c1 <{tbnum}") tdSql.checkRows(3) - tdSql.query(f"select distinct c1,c1 from t1 ") + tdSql.query(f"select distinct c1,c1 from {dbname}.t1 ") tdSql.checkRows(2) - tdSql.query(f"select distinct c1,c1 from t1 where c1 <{tbnum}") + tdSql.query(f"select distinct c1,c1 from {dbname}.t1 where c1 <{tbnum}") tdSql.checkRows(1) - tdSql.query(f"select distinct c1,c2 from t1 where c1 <{tbnum} limit 3") + tdSql.query(f"select distinct c1,c2 from {dbname}.t1 where c1 <{tbnum} limit 3") tdSql.checkRows(3) - tdSql.query(f"select distinct c1,c2 from t1 where c1 <{tbnum} limit 3 offset 2") + tdSql.query(f"select distinct c1,c2 from {dbname}.t1 where c1 <{tbnum} limit 3 offset 2") tdSql.checkRows(1) - # tdSql.query(f"select distinct c3 from stb2 where c2 <{tbnum} ") + # tdSql.query(f"select distinct c3 from {dbname}.stb2 where c2 <{tbnum} ") # tdSql.checkRows(3) - # tdSql.query(f"select distinct c3, c2 from stb2 where c2 <{tbnum} limit 2") + # tdSql.query(f"select distinct c3, c2 from {dbname}.stb2 where c2 <{tbnum} limit 2") # tdSql.checkRows(2) - # tdSql.error("select distinct c5 from stb1") - tdSql.error("select distinct c5 from t1") - tdSql.error("select distinct c1 from db.*") - tdSql.error("select c2, distinct c1 from stb1") - tdSql.error("select c2, distinct c1 from t1") - tdSql.error("select distinct c2 from ") - tdSql.error("distinct c2 from stb1") - tdSql.error("distinct c2 from t1") - tdSql.error("select distinct c1, c2, c3 from stb1") - tdSql.error("select distinct c1, c2, c3 from t1") - tdSql.error("select distinct stb1.c1, stb1.c2, stb2.c2, stb2.c3 from stb1") - tdSql.error("select distinct stb1.c1, stb1.c2, stb2.c2, stb2.c3 from t1") - tdSql.error("select distinct t1.c1, t1.c2, t2.c1, t2.c2 from t1") - # tdSql.query(f"select distinct c1 c2, c2 c3 from stb1 where c1 <{tbnum}") - # tdSql.checkRows(tbnum*3) - tdSql.query(f"select distinct c1 c2, c2 c3 from t1 where c1 <{tbnum}") + # tdSql.error(f"select distinct c5 from {dbname}.stb1") + tdSql.error(f"select distinct c5 from {dbname}.t1") + tdSql.error(f"select distinct c1 from db.*") + tdSql.error(f"select c2, distinct c1 from {dbname}.stb1") + tdSql.error(f"select c2, distinct c1 from {dbname}.t1") + tdSql.error(f"select distinct c2 from ") + tdSql.error("distinct c2 from {dbname}.stb1") + tdSql.error("distinct c2 from {dbname}.t1") + tdSql.error(f"select distinct c1, c2, c3 from {dbname}.stb1") + tdSql.error(f"select distinct c1, c2, c3 from {dbname}.t1") + tdSql.error(f"select distinct stb1.c1, stb1.c2, stb2.c2, stb2.c3 from {dbname}.stb1") + tdSql.error(f"select distinct stb1.c1, stb1.c2, stb2.c2, stb2.c3 from {dbname}.t1") + tdSql.error(f"select distinct t1.c1, t1.c2, t2.c1, t2.c2 from {dbname}.t1") + tdSql.query(f"select distinct c1 c2, c2 c3 from {dbname}.stb1 where c1 <{tbnum}") + tdSql.checkRows(tbnum*3) + tdSql.query(f"select distinct c1 c2, c2 c3 from {dbname}.t1 where c1 <{tbnum}") tdSql.checkRows(3) - # tdSql.error("select distinct c1, c2 from stb1 order by ts") - tdSql.error("select distinct c1, c2 from t1 order by ts") - # tdSql.error("select distinct c1, ts from stb1 group by c2") - tdSql.error("select distinct c1, ts from t1 group by c2") - # tdSql.error("select distinct c1, max(c2) from stb1 ") - # tdSql.error("select distinct c1, max(c2) from t1 ") - # tdSql.error("select max(c2), distinct c1 from stb1 ") - tdSql.error("select max(c2), distinct c1 from t1 ") - # tdSql.error("select distinct c1, c2 from stb1 where c1 > 3 group by t0") - tdSql.error("select distinct c1, c2 from t1 where c1 > 3 group by t0") - # tdSql.error("select distinct c1, c2 from stb1 where c1 > 3 interval(1d) ") - tdSql.error("select distinct c1, c2 from t1 where c1 > 3 interval(1d) ") - # tdSql.error("select distinct c1, c2 from stb1 where c1 > 3 interval(1d) fill(next)") - tdSql.error("select distinct c1, c2 from t1 where c1 > 3 interval(1d) fill(next)") - # tdSql.error("select distinct c1, c2 from stb1 where ts > now-10d and ts < now interval(1d) fill(next)") - tdSql.error("select distinct c1, c2 from t1 where ts > now-10d and ts < now interval(1d) fill(next)") - # tdSql.error("select distinct c1, c2 from stb1 where c1 > 3 slimit 1") - # tdSql.error("select distinct c1, c2 from t1 where c1 > 3 slimit 1") - # tdSql.query(f"select distinct c1, c2 from stb1 where c1 between {tbnum-2} and {tbnum} ") - # tdSql.checkRows(6) - tdSql.query(f"select distinct c1, c2 from t1 where c1 between {tbnum-2} and {tbnum} ") + tdSql.error(f"select distinct c1, c2 from {dbname}.stb1 order by ts") + tdSql.error(f"select distinct c1, c2 from {dbname}.t1 order by ts") + tdSql.error(f"select distinct c1, ts from {dbname}.stb1 group by c2") + tdSql.error(f"select distinct c1, ts from {dbname}.t1 group by c2") + tdSql.query(f"select distinct c1, max(c2) from {dbname}.stb1 ") + tdSql.query(f"select distinct c1, max(c2) from {dbname}.t1 ") + tdSql.error(f"select max(c2), distinct c1 from {dbname}.stb1 ") + tdSql.error(f"select max(c2), distinct c1 from {dbname}.t1 ") + tdSql.error(f"select distinct c1, c2 from {dbname}.stb1 where c1 > 3 group by t0") + tdSql.error(f"select distinct c1, c2 from {dbname}.t1 where c1 > 3 group by t0") + tdSql.error(f"select distinct c1, c2 from {dbname}.stb1 where c1 > 3 interval(1d) ") + tdSql.error(f"select distinct c1, c2 from {dbname}.t1 where c1 > 3 interval(1d) ") + tdSql.error(f"select distinct c1, c2 from {dbname}.stb1 where c1 > 3 interval(1d) fill(next)") + tdSql.error(f"select distinct c1, c2 from {dbname}.t1 where c1 > 3 interval(1d) fill(next)") + tdSql.error(f"select distinct c1, c2 from {dbname}.stb1 where ts > now-10d and ts < now interval(1d) fill(next)") + tdSql.error(f"select distinct c1, c2 from {dbname}.t1 where ts > now-10d and ts < now interval(1d) fill(next)") + tdSql.error(f"select distinct c1, c2 from {dbname}.stb1 where c1 > 3 slimit 1") + tdSql.error(f"select distinct c1, c2 from {dbname}.t1 where c1 > 3 slimit 1") + tdSql.query(f"select distinct c1, c2 from {dbname}.stb1 where c1 between {tbnum-2} and {tbnum} ") + tdSql.checkRows(6) + tdSql.query(f"select distinct c1, c2 from {dbname}.t1 where c1 between {tbnum-2} and {tbnum} ") # tdSql.checkRows(1) - # tdSql.query("select distinct c1, c2 from stb1 where c1 in (1,2,3,4,5)") - # tdSql.checkRows(15) - tdSql.query("select distinct c1, c2 from t1 where c1 in (1,2,3,4,5)") + tdSql.query(f"select distinct c1, c2 from {dbname}.stb1 where c1 in (1,2,3,4,5)") + tdSql.checkRows(15) + tdSql.query(f"select distinct c1, c2 from {dbname}.t1 where c1 in (1,2,3,4,5)") # tdSql.checkRows(1) - # tdSql.query("select distinct c1, c2 from stb1 where c1 in (100,1000,10000)") - # tdSql.checkRows(3) - tdSql.query("select distinct c1, c2 from t1 where c1 in (100,1000,10000)") - # tdSql.checkRows(0) + tdSql.query(f"select distinct c1, c2 from {dbname}.stb1 where c1 in (100,1000,10000)") + tdSql.checkRows(3) + tdSql.query(f"select distinct c1, c2 from {dbname}.t1 where c1 in (100,1000,10000)") + tdSql.checkRows(0) - # tdSql.query(f"select distinct c1,c2 from (select * from stb1 where c1 > {tbnum-2}) ") - # tdSql.checkRows(3) - # tdSql.query(f"select distinct c1,c2 from (select * from t1 where c1 < {tbnum}) ") - # tdSql.checkRows(3) - # tdSql.query(f"select distinct c1,c2 from (select * from stb1 where t2 !=0 and t2 != 1) ") - # tdSql.checkRows(0) - # tdSql.error("select distinct c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) ") - # tdSql.error("select c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) ") - # tdSql.query("select distinct c1, c2 from (select c2, c1 from stb1 where c1 > 2 ) where c1 < 4") - # tdSql.checkRows(3) - # tdSql.error("select distinct c1, c2 from (select c1 from stb1 where t0 > 2 ) where t1 < 3") - # tdSql.error("select distinct c1, c2 from (select c2, c1 from stb1 where c1 > 2 order by ts)") - # tdSql.error("select distinct c1, c2 from (select c2, c1 from t1 where c1 > 2 order by ts)") - # tdSql.error("select distinct c1, c2 from (select c2, c1 from stb1 where c1 > 2 group by c1)") - # tdSql.error("select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from stb1 group by c1)") - # tdSql.error("select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from t1 group by c1)") - # tdSql.query("select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from stb1 )") - # tdSql.checkRows(1) - # tdSql.query("select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from t1 )") - # tdSql.checkRows(1) - # tdSql.error("select distinct stb1.c1, stb1.c2 from stb1 , stb2 where stb1.ts=stb2.ts and stb1.t2=stb2.t4") - # tdSql.error("select distinct t1.c1, t1.c2 from t1 , t2 where t1.ts=t2.ts ") + tdSql.query(f"select distinct c1,c2 from (select * from {dbname}.stb1 where c1 > {tbnum-2}) ") + tdSql.checkRows(3) + tdSql.query(f"select distinct c1,c2 from (select * from {dbname}.t1 where c1 < {tbnum}) ") + tdSql.checkRows(3) + tdSql.query(f"select distinct c1,c2 from (select * from {dbname}.stb1 where t2 !=0 and t2 != 1) ") + tdSql.checkRows(0) + tdSql.query(f"select distinct c1, c2 from (select distinct c1, c2 from {dbname}.stb1 where t0 > 2 and t1 < 3) ") + tdSql.query(f"select c1, c2 from (select distinct c1, c2 from {dbname}.stb1 where t0 > 2 and t1 < 3) ") + tdSql.query(f"select distinct c1, c2 from (select c2, c1 from {dbname}.stb1 where c1 > 2 ) where c1 < 4") + tdSql.checkRows(3) + tdSql.error(f"select distinct c1, c2 from (select c1 from {dbname}.stb1 where t0 > 2 ) where t1 < 3") + tdSql.query(f"select distinct c1, c2 from (select c2, c1 from {dbname}.stb1 where c1 > 2 order by ts)") + tdSql.query(f"select distinct c1, c2 from (select c2, c1 from {dbname}.t1 where c1 > 2 order by ts)") + tdSql.error(f"select distinct c1, c2 from (select c2, c1 from {dbname}.stb1 where c1 > 2 group by c1)") + tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.stb1 group by c1)") + tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.t1 group by c1)") + tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.stb1 )") + tdSql.checkRows(1) + tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.t1 )") + tdSql.checkRows(1) + tdSql.query(f"select distinct stb1.c1, stb1.c2 from {dbname}.stb1, {dbname}.stb2 where stb1.ts=stb2.ts and stb1.t2=stb2.t4") + tdSql.query(f"select distinct t1.c1, t1.c2 from {dbname}.t1, {dbname}.t2 where t1.ts=t2.ts ") - # tdSql.error("select distinct c1, c2 from (select count(c1) c1, count(c2) c2 from stb1 group by ts)") - # tdSql.error("select distinct c1, c2 from (select count(c1) c1, count(c2) c2 from t1 group by ts)") + tdSql.query(f"select distinct c1, c2 from (select count(c1) c1, count(c2) c2 from {dbname}.stb1 group by ts)") + tdSql.query(f"select distinct c1, c2 from (select count(c1) c1, count(c2) c2 from {dbname}.t1 group by ts)") - # #========== suport distinct multi-tags-coloumn ========== - # tdSql.query("select distinct t1 from stb1") - # tdSql.checkRows(maxRemainderNum+1) - # tdSql.query("select distinct t0, t1 from stb1") - # tdSql.checkRows(maxRemainderNum+1) - # tdSql.query("select distinct t1, t0 from stb1") - # tdSql.checkRows(maxRemainderNum+1) - # tdSql.query("select distinct t1, t2 from stb1") - # tdSql.checkRows(maxRemainderNum*2+1) - # tdSql.query("select distinct t0, t1, t2 from stb1") - # tdSql.checkRows(maxRemainderNum*2+1) - # tdSql.query("select distinct t0 t1, t1 t2 from stb1") - # tdSql.checkRows(maxRemainderNum+1) - # tdSql.query("select distinct t0, t0, t0 from stb1") - # tdSql.checkRows(maxRemainderNum+1) - # tdSql.query("select distinct t0, t1 from t1") - # tdSql.checkRows(1) - # tdSql.query("select distinct t0, t1 from t100num") - # tdSql.checkRows(1) + #========== suport distinct multi-tags-coloumn ========== + tdSql.query(f"select distinct t1 from {dbname}.stb1") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query(f"select distinct t0, t1 from {dbname}.stb1") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query(f"select distinct t1, t0 from {dbname}.stb1") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query(f"select distinct t1, t2 from {dbname}.stb1") + tdSql.checkRows(maxRemainderNum*2+1) + tdSql.query(f"select distinct t0, t1, t2 from {dbname}.stb1") + tdSql.checkRows(maxRemainderNum*2+1) + tdSql.query(f"select distinct t0 t1, t1 t2 from {dbname}.stb1") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query(f"select distinct t0, t0, t0 from {dbname}.stb1") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query(f"select distinct t0, t1 from {dbname}.t1") + tdSql.checkRows(1) + tdSql.query(f"select distinct t0, t1 from {dbname}.t100num") + tdSql.checkRows(1) - # tdSql.query("select distinct t3 from stb2") - # tdSql.checkRows(maxRemainderNum+1) - # tdSql.query("select distinct t2, t3 from stb2") - # tdSql.checkRows(maxRemainderNum+1) - # tdSql.query("select distinct t3, t2 from stb2") - # tdSql.checkRows(maxRemainderNum+1) - # tdSql.query("select distinct t4, t2 from stb2") - # tdSql.checkRows(maxRemainderNum*3+1) - # tdSql.query("select distinct t2, t3, t4 from stb2") - # tdSql.checkRows(maxRemainderNum*3+1) - # tdSql.query("select distinct t2 t1, t3 t2 from stb2") - # tdSql.checkRows(maxRemainderNum+1) - # tdSql.query("select distinct t3, t3, t3 from stb2") - # tdSql.checkRows(maxRemainderNum+1) - # tdSql.query("select distinct t2, t3 from t01") - # tdSql.checkRows(1) - # tdSql.query("select distinct t3, t4 from t0100num") - # tdSql.checkRows(1) + tdSql.query(f"select distinct t3 from {dbname}.stb2") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query(f"select distinct t2, t3 from {dbname}.stb2") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query(f"select distinct t3, t2 from {dbname}.stb2") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query(f"select distinct t4, t2 from {dbname}.stb2") + tdSql.checkRows(maxRemainderNum*3+1) + tdSql.query(f"select distinct t2, t3, t4 from {dbname}.stb2") + tdSql.checkRows(maxRemainderNum*3+1) + tdSql.query(f"select distinct t2 t1, t3 t2 from {dbname}.stb2") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query(f"select distinct t3, t3, t3 from {dbname}.stb2") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query(f"select distinct t2, t3 from {dbname}.t01") + tdSql.checkRows(1) + tdSql.query(f"select distinct t3, t4 from {dbname}.t0100num") + tdSql.checkRows(1) - # ########## should be error ######### - # tdSql.error("select distinct from stb1") - # tdSql.error("select distinct t3 from stb1") - # tdSql.error("select distinct t1 from db.*") - # tdSql.error("select distinct t2 from ") - # tdSql.error("distinct t2 from stb1") - # tdSql.error("select distinct stb1") - # tdSql.error("select distinct t0, t1, t2, t3 from stb1") - # tdSql.error("select distinct stb1.t0, stb1.t1, stb2.t2, stb2.t3 from stb1") + ########## should be error ######### + tdSql.error(f"select distinct from {dbname}.stb1") + tdSql.error(f"select distinct t3 from {dbname}.stb1") + tdSql.error(f"select distinct t1 from db.*") + tdSql.error(f"select distinct t2 from ") + tdSql.error(f"distinct t2 from {dbname}.stb1") + tdSql.error(f"select distinct stb1") + tdSql.error(f"select distinct t0, t1, t2, t3 from {dbname}.stb1") + tdSql.error(f"select distinct stb1.t0, stb1.t1, stb2.t2, stb2.t3 from {dbname}.stb1") - # tdSql.error("select dist t0 from stb1") - # tdSql.error("select distinct stb2.t2, stb2.t3 from stb1") - # tdSql.error("select distinct stb2.t2 t1, stb2.t3 t2 from stb1") + tdSql.error(f"select dist t0 from {dbname}.stb1") + tdSql.error(f"select distinct stb2.t2, stb2.t3 from {dbname}.stb1") + tdSql.error(f"select distinct stb2.t2 t1, stb2.t3 t2 from {dbname}.stb1") - # tdSql.error("select distinct t0, t1 from t1 where t0 < 7") + tdSql.query(f"select distinct t0, t1 from {dbname}.t1 where t0 < 7") - # ########## add where condition ########## - # tdSql.query("select distinct t0, t1 from stb1 where t1 > 3") - # tdSql.checkRows(3) - # tdSql.query("select distinct t0, t1 from stb1 where t1 > 3 limit 2") - # tdSql.checkRows(2) - # tdSql.query("select distinct t0, t1 from stb1 where t1 > 3 limit 2 offset 2") - # tdSql.checkRows(1) - # tdSql.query("select distinct t0, t1 from stb1 where t1 > 3 slimit 2") - # tdSql.checkRows(3) - # tdSql.error("select distinct t0, t1 from stb1 where c1 > 2") - # tdSql.query("select distinct t0, t1 from stb1 where t1 > 3 and t1 < 5") - # tdSql.checkRows(1) - # tdSql.error("select distinct stb1.t0, stb1.t1 from stb1, stb2 where stb1.t2=stb2.t4") - # tdSql.error("select distinct t0, t1 from stb1 where stb2.t4 > 2") - # tdSql.error("select distinct t0, t1 from stb1 where t1 > 3 group by t0") - # tdSql.error("select distinct t0, t1 from stb1 where t1 > 3 interval(1d) ") - # tdSql.error("select distinct t0, t1 from stb1 where t1 > 3 interval(1d) fill(next)") - # tdSql.error("select distinct t0, t1 from stb1 where ts > now-10d and ts < now interval(1d) fill(next)") + ########## add where condition ########## + tdSql.query(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3") + tdSql.checkRows(3) + tdSql.query(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3 limit 2") + tdSql.checkRows(2) + tdSql.query(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3 limit 2 offset 2") + tdSql.checkRows(1) + tdSql.error(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3 slimit 2") + tdSql.query(f"select distinct t0, t1 from {dbname}.stb1 where c1 > 2") + tdSql.query(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3 and t1 < 5") + tdSql.checkRows(1) + tdSql.error(f"select distinct stb1.t0, stb1.t1 from {dbname}.stb1, {dbname}.stb2 where stb1.t2=stb2.t4") + tdSql.error(f"select distinct t0, t1 from {dbname}.stb1 where stb2.t4 > 2") + tdSql.error(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3 group by t0") + tdSql.error(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3 interval(1d) ") + tdSql.error(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3 interval(1d) fill(next)") + tdSql.error(f"select distinct t0, t1 from {dbname}.stb1 where ts > now-10d and ts < now interval(1d) fill(next)") - # tdSql.error("select max(c1), distinct t0 from stb1 where t0 > 2") - # tdSql.error("select distinct t0, max(c1) from stb1 where t0 > 2") - # tdSql.error("select distinct t0 from stb1 where t0 in (select t0 from stb1 where t0 > 2)") - # tdSql.query("select distinct t0, t1 from stb1 where t0 in (1,2,3,4,5)") - # tdSql.checkRows(5) - # tdSql.query("select distinct t1 from (select t0, t1 from stb1 where t0 > 2) ") - # tdSql.checkRows(4) - # tdSql.error("select distinct t1 from (select distinct t0, t1 from stb1 where t0 > 2 and t1 < 3) ") - # tdSql.error("select distinct t1 from (select distinct t0, t1 from stb1 where t0 > 2 ) where t1 < 3") - # tdSql.query("select distinct t1 from (select t0, t1 from stb1 where t0 > 2 ) where t1 < 3") - # tdSql.checkRows(1) - # tdSql.error("select distinct t1, t0 from (select t1 from stb1 where t0 > 2 ) where t1 < 3") - # tdSql.error("select distinct t1, t0 from (select max(t1) t1, max(t0) t0 from stb1 group by t1)") - # tdSql.error("select distinct t1, t0 from (select max(t1) t1, max(t0) t0 from stb1)") - # tdSql.query("select distinct t1, t0 from (select t1,t0 from stb1 where t0 > 2 ) where t1 < 3") - # tdSql.checkRows(1) - # tdSql.error(" select distinct t1, t0 from (select t1,t0 from stb1 where t0 > 2 order by ts) where t1 < 3") - # tdSql.error("select t1, t0 from (select distinct t1,t0 from stb1 where t0 > 2 ) where t1 < 3") - # tdSql.error(" select distinct t1, t0 from (select t1,t0 from stb1 where t0 > 2 group by ts) where t1 < 3") - # tdSql.error("select distinct stb1.t1, stb1.t2 from stb1 , stb2 where stb1.ts=stb2.ts and stb1.t2=stb2.t4") - # tdSql.error("select distinct t1.t1, t1.t2 from t1 , t2 where t1.ts=t2.ts ") + tdSql.error(f"select max(c1), distinct t0 from {dbname}.stb1 where t0 > 2") + tdSql.query(f"select distinct t0, max(c1) from {dbname}.stb1 where t0 > 2") + tdSql.error(f"select distinct t0 from {dbname}.stb1 where t0 in (select t0 from {dbname}.stb1 where t0 > 2)") + tdSql.query(f"select distinct t0, t1 from {dbname}.stb1 where t0 in (1,2,3,4,5)") + tdSql.checkRows(5) + tdSql.query(f"select distinct t1 from (select t0, t1 from {dbname}.stb1 where t0 > 2) ") + tdSql.checkRows(4) + tdSql.query(f"select distinct t1 from (select distinct t0, t1 from {dbname}.stb1 where t0 > 2 and t1 < 3) ") + # TODO: BUG of TD-17561 + # tdSql.query(f"select distinct t1 from (select distinct t0, t1 from {dbname}.stb1 where t0 > 2 ) where t1 < 3") + tdSql.query(f"select distinct t1 from (select t0, t1 from {dbname}.stb1 where t0 > 2 ) where t1 < 3") + tdSql.checkRows(1) + tdSql.error(f"select distinct t1, t0 from (select t1 from {dbname}.stb1 where t0 > 2 ) where t1 < 3") + tdSql.query(f"select distinct t1, t0 from (select max(t1) t1, max(t0) t0 from {dbname}.stb1 group by t1)") + tdSql.query(f"select distinct t1, t0 from (select max(t1) t1, max(t0) t0 from {dbname}.stb1)") + tdSql.query(f"select distinct t1, t0 from (select t1,t0 from {dbname}.stb1 where t0 > 2 ) where t1 < 3") + tdSql.checkRows(1) + tdSql.query(f"select distinct t1, t0 from (select t1,t0 from {dbname}.stb1 where t0 > 2 order by ts) where t1 < 3") + # TODO: BUG of TD-17561 + # tdSql.error(f"select t1, t0 from (select distinct t1,t0 from {dbname}.stb1 where t0 > 2 ) where t1 < 3") + tdSql.error(f"select distinct t1, t0 from (select t1,t0 from {dbname}.stb1 where t0 > 2 group by ts) where t1 < 3") + tdSql.query(f"select distinct stb1.t1, stb1.t2 from {dbname}.stb1, {dbname}.stb2 where stb1.ts=stb2.ts and stb1.t2=stb2.t4") + tdSql.query(f"select distinct t1.t1, t1.t2 from {dbname}.t1, {dbname}.t2 where t1.ts=t2.ts ") diff --git a/tests/system-test/2-query/distribute_agg_apercentile.py b/tests/system-test/2-query/distribute_agg_apercentile.py index eb5e8333c20803c424941bd75321aaa7e1ea1d52..1fd853f9eb193ac6ab9601f9ae8963d13e10f94c 100644 --- a/tests/system-test/2-query/distribute_agg_apercentile.py +++ b/tests/system-test/2-query/distribute_agg_apercentile.py @@ -6,86 +6,60 @@ import random class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, - "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } + updatecfgDict = {"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor()) self.vnode_disbutes = None self.ts = 1537146000000 - def prepare_datas_of_distribute(self): + def prepare_datas_of_distribute(self, dbname="testdb"): # prepate datas for 20 tables distributed at different vgroups - tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") - tdSql.execute(" use testdb ") + tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5") + tdSql.execute(f" use {dbname} ") tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) ''' ) - tdSql.execute( - ''' - create table t1 - (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) - ''' - ) for i in range(20): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') for i in range(9): tdSql.execute( - f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) for i in range(1,21): if i ==1 or i == 4: continue else: - tbname = "ct"+f'{i}' + tbname = f"{dbname}.ct{i}" for j in range(9): tdSql.execute( f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - - tdSql.execute( - f'''insert into t1 values - ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) - ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) - ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a ) - ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a ) - ( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a ) - ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a ) - ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) - ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) - ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) - ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ''' - ) + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdLog.info(" prepare data for distributed_aggregate done! ") - def check_distribute_datas(self): + def check_distribute_datas(self, dbname="testdb"): # get vgroup_ids of all - tdSql.query("show vgroups ") + tdSql.query(f"show {dbname}.vgroups ") vgroups = tdSql.queryResult vnode_tables={} @@ -95,7 +69,7 @@ class TDTestCase: # check sub_table of per vnode ,make sure sub_table has been distributed - tdSql.query("show tables like 'ct%'") + tdSql.query(f"show {dbname}.tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: @@ -109,28 +83,28 @@ class TDTestCase: if count < 2: tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") - def distribute_agg_query(self): + def distribute_agg_query(self, dbname="testdb"): # basic filter - tdSql.query("select apercentile(c1 , 20) from stb1 where c1 is null") + tdSql.query(f"select apercentile(c1 , 20) from {dbname}.stb1 where c1 is null") tdSql.checkRows(0) - tdSql.query("select apercentile(c1 , 20) from stb1 where t1=1") + tdSql.query(f"select apercentile(c1 , 20) from {dbname}.stb1 where t1=1") tdSql.checkData(0,0,2.800000000) - tdSql.query("select apercentile(c1+c2 ,100) from stb1 where c1 =1 ") + tdSql.query(f"select apercentile(c1+c2 ,100) from {dbname}.stb1 where c1 =1 ") tdSql.checkData(0,0,11112.000000000) - tdSql.query("select apercentile(c1 ,10 ) from stb1 where tbname=\"ct2\"") + tdSql.query(f"select apercentile(c1 ,10 ) from {dbname}.stb1 where tbname=\"ct2\"") tdSql.checkData(0,0,2.000000000) - tdSql.query("select apercentile(c1,20) from stb1 partition by tbname") + tdSql.query(f"select apercentile(c1,20) from {dbname}.stb1 partition by tbname") tdSql.checkRows(20) - tdSql.query("select apercentile(c1,20) from stb1 where t1> 4 partition by tbname") + tdSql.query(f"select apercentile(c1,20) from {dbname}.stb1 where t1> 4 partition by tbname") tdSql.checkRows(15) # union all - tdSql.query("select apercentile(c1,20) from stb1 union all select apercentile(c1,20) from stb1 ") + tdSql.query(f"select apercentile(c1,20) from {dbname}.stb1 union all select apercentile(c1,20) from {dbname}.stb1 ") tdSql.checkRows(2) tdSql.checkData(0,0,7.389181281) @@ -138,44 +112,44 @@ class TDTestCase: tdSql.execute(" create database if not exists db ") tdSql.execute(" use db ") - tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") - tdSql.execute(" create table tb1 using st tags(1) ") - tdSql.execute(" create table tb2 using st tags(2) ") + tdSql.execute(" create stable db.st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") + tdSql.execute(" create table db.tb1 using db.st tags(1) ") + tdSql.execute(" create table db.tb2 using db.st tags(2) ") for i in range(10): ts = i*10 + self.ts - tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") - tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into db.tb1 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into db.tb2 values({ts},{i},{i}.0)") - tdSql.query("select apercentile(tb1.c1,100), apercentile(tb2.c2,100) from tb1, tb2 where tb1.ts=tb2.ts") + tdSql.query(f"select apercentile(tb1.c1,100), apercentile(tb2.c2,100) from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts") tdSql.checkRows(1) tdSql.checkData(0,0,9.000000000) tdSql.checkData(0,0,9.000000000) # group by - tdSql.execute(" use testdb ") - tdSql.query(" select max(c1),c1 from stb1 group by t1 ") + tdSql.execute(f"use {dbname} ") + tdSql.query(f" select max(c1),c1 from {dbname}.stb1 group by t1 ") tdSql.checkRows(20) - tdSql.query(" select max(c1),c1 from stb1 group by c1 ") + tdSql.query(f" select max(c1),c1 from {dbname}.stb1 group by c1 ") tdSql.checkRows(30) - tdSql.query(" select max(c1),c2 from stb1 group by c2 ") + tdSql.query(f" select max(c1),c2 from {dbname}.stb1 group by c2 ") tdSql.checkRows(31) # partition by tbname or partition by tag - tdSql.query("select apercentile(c1 ,10)from stb1 partition by tbname") + tdSql.query(f"select apercentile(c1 ,10)from {dbname}.stb1 partition by tbname") query_data = tdSql.queryResult # nest query for support max - tdSql.query("select apercentile(c2+2,10)+1 from (select max(c1) c2 from stb1)") + tdSql.query(f"select apercentile(c2+2,10)+1 from (select max(c1) c2 from {dbname}.stb1)") tdSql.checkData(0,0,31.000000000) - tdSql.query("select apercentile(c1+2,10)+1 as c2 from (select ts ,c1 ,c2 from stb1)") + tdSql.query(f"select apercentile(c1+2,10)+1 as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)") tdSql.checkData(0,0,7.560701700) - tdSql.query("select apercentile(a+2,10)+1 as c2 from (select ts ,abs(c1) a ,c2 from stb1)") + tdSql.query(f"select apercentile(a+2,10)+1 as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)") tdSql.checkData(0,0,7.560701700) # mixup with other functions - tdSql.query("select max(c1),count(c1),last(c2,c3),spread(c1), apercentile(c1,10) from stb1") + tdSql.query(f"select max(c1),count(c1),last(c2,c3),spread(c1), apercentile(c1,10) from {dbname}.stb1") tdSql.checkData(0,0,28) tdSql.checkData(0,1,184) tdSql.checkData(0,2,-99999) diff --git a/tests/system-test/2-query/distribute_agg_avg.py b/tests/system-test/2-query/distribute_agg_avg.py index 2f449595bd34653ea035867dd3625ca6ea778cbd..3892ae0da15269f3aa9b7d89e4fbef9824aab723 100644 --- a/tests/system-test/2-query/distribute_agg_avg.py +++ b/tests/system-test/2-query/distribute_agg_avg.py @@ -7,11 +7,8 @@ import platform class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, - "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } + updatecfgDict = {"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor()) @@ -34,75 +31,52 @@ class TDTestCase: tdSql.query(avg_sql) tdSql.checkData(0,0,pre_avg) - def prepare_datas_of_distribute(self): + def prepare_datas_of_distribute(self, dbname="testdb"): # prepate datas for 20 tables distributed at different vgroups - tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") - tdSql.execute(" use testdb ") + tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5") + tdSql.execute(f" use {dbname} ") tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) ''' ) - tdSql.execute( - ''' - create table t1 - (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) - ''' - ) for i in range(20): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') for i in range(9): tdSql.execute( - f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) for i in range(1,21): if i ==1 or i == 4: continue else: - tbname = "ct"+f'{i}' + tbname = f"{dbname}.ct{i}" for j in range(9): tdSql.execute( f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - - tdSql.execute( - f'''insert into t1 values - ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) - ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) - ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a ) - ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a ) - ( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a ) - ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a ) - ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) - ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) - ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) - ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ''' - ) + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdLog.info(" prepare data for distributed_aggregate done! ") - def check_distribute_datas(self): + def check_distribute_datas(self, dbname="testdb"): # get vgroup_ids of all - tdSql.query("show vgroups ") + tdSql.query(f"show {dbname}.vgroups ") vgroups = tdSql.queryResult vnode_tables={} @@ -112,7 +86,7 @@ class TDTestCase: # check sub_table of per vnode ,make sure sub_table has been distributed - tdSql.query("show tables like 'ct%'") + tdSql.query(f"show {dbname}.tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: @@ -126,7 +100,7 @@ class TDTestCase: if count < 2: tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") - def check_avg_distribute_diff_vnode(self,col_name): + def check_avg_distribute_diff_vnode(self,col_name, dbname="testdb"): vgroup_ids = [] for k ,v in self.vnode_disbutes.items(): @@ -144,9 +118,9 @@ class TDTestCase: tbname_filters = tbname_ins[:-1] - avg_sql = f"select avg({col_name}) from stb1 where tbname in ({tbname_filters});" + avg_sql = f"select avg({col_name}) from {dbname}.stb1 where tbname in ({tbname_filters});" - same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) and {col_name} is not null " + same_sql = f"select {col_name} from {dbname}.stb1 where tbname in ({tbname_filters}) and {col_name} is not null " tdSql.query(same_sql) pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] @@ -157,16 +131,16 @@ class TDTestCase: tdSql.query(avg_sql) tdSql.checkData(0,0,pre_avg) - def check_avg_status(self): + def check_avg_status(self, dbname="testdb"): # check max function work status - tdSql.query("show tables like 'ct%'") + tdSql.query(f"show {dbname}.tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: - tablenames.append(table_name[0]) + tablenames.append(f"{dbname}.{table_name[0]}") - tdSql.query("desc stb1") + tdSql.query(f"desc {dbname}.stb1") col_names = tdSql.queryResult colnames = [] @@ -182,41 +156,41 @@ class TDTestCase: for colname in colnames: if colname.startswith("c"): - self.check_avg_distribute_diff_vnode(colname) + self.check_avg_distribute_diff_vnode(colname, dbname) else: - # self.check_avg_distribute_diff_vnode(colname) # bug for tag + # self.check_avg_distribute_diff_vnode(colname, dbname) # bug for tag pass - def distribute_agg_query(self): + def distribute_agg_query(self, dbname="testdb"): # basic filter - tdSql.query(" select avg(c1) from stb1 ") + tdSql.query(f"select avg(c1) from {dbname}.stb1 ") tdSql.checkData(0,0,14.086956522) - tdSql.query(" select avg(a) from (select avg(c1) a from stb1 partition by tbname) ") + tdSql.query(f"select avg(a) from (select avg(c1) a from {dbname}.stb1 partition by tbname) ") tdSql.checkData(0,0,14.292307692) - tdSql.query(" select avg(c1) from stb1 where t1=1") + tdSql.query(f"select avg(c1) from {dbname}.stb1 where t1=1") tdSql.checkData(0,0,6.000000000) - tdSql.query("select avg(c1+c2) from stb1 where c1 =1 ") + tdSql.query(f"select avg(c1+c2) from {dbname}.stb1 where c1 =1 ") tdSql.checkData(0,0,11112.000000000) - tdSql.query("select avg(c1) from stb1 where tbname=\"ct2\"") + tdSql.query(f"select avg(c1) from {dbname}.stb1 where tbname=\"ct2\"") tdSql.checkData(0,0,6.000000000) - tdSql.query("select avg(c1) from stb1 partition by tbname") + tdSql.query(f"select avg(c1) from {dbname}.stb1 partition by tbname") tdSql.checkRows(20) - tdSql.query("select avg(c1) from stb1 where t1> 4 partition by tbname") + tdSql.query(f"select avg(c1) from {dbname}.stb1 where t1> 4 partition by tbname") tdSql.checkRows(15) # union all - tdSql.query("select avg(c1) from stb1 union all select avg(c1) from stb1 ") + tdSql.query(f"select avg(c1) from {dbname}.stb1 union all select avg(c1) from {dbname}.stb1 ") tdSql.checkRows(2) tdSql.checkData(0,0,14.086956522) - tdSql.query("select avg(a) from (select avg(c1) a from stb1 union all select avg(c1) a from stb1)") + tdSql.query(f"select avg(a) from (select avg(c1) a from {dbname}.stb1 union all select avg(c1) a from {dbname}.stb1)") tdSql.checkRows(1) tdSql.checkData(0,0,14.086956522) @@ -224,38 +198,38 @@ class TDTestCase: tdSql.execute(" create database if not exists db ") tdSql.execute(" use db ") - tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") - tdSql.execute(" create table tb1 using st tags(1) ") - tdSql.execute(" create table tb2 using st tags(2) ") + tdSql.execute(" create stable db.st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") + tdSql.execute(" create table db.tb1 using db.st tags(1) ") + tdSql.execute(" create table db.tb2 using db.st tags(2) ") for i in range(10): ts = i*10 + self.ts - tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") - tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into db.tb1 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into db.tb2 values({ts},{i},{i}.0)") - tdSql.query("select avg(tb1.c1), avg(tb2.c2) from tb1, tb2 where tb1.ts=tb2.ts") + tdSql.query(f"select avg(tb1.c1), avg(tb2.c2) from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts") tdSql.checkRows(1) tdSql.checkData(0,0,4.500000000) tdSql.checkData(0,1,4.500000000) # group by - tdSql.execute(" use testdb ") + tdSql.execute(f" use {dbname} ") # partition by tbname or partition by tag - tdSql.query("select avg(c1) from stb1 partition by tbname") + tdSql.query(f"select avg(c1) from {dbname}.stb1 partition by tbname") tdSql.checkRows(20) # nest query for support max - tdSql.query("select avg(c2+2)+1 from (select avg(c1) c2 from stb1)") + tdSql.query(f"select avg(c2+2)+1 from (select avg(c1) c2 from {dbname}.stb1)") tdSql.checkData(0,0,17.086956522) - tdSql.query("select avg(c1+2) as c2 from (select ts ,c1 ,c2 from stb1)") + tdSql.query(f"select avg(c1+2) as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)") tdSql.checkData(0,0,16.086956522) - tdSql.query("select avg(a+2) as c2 from (select ts ,abs(c1) a ,c2 from stb1)") + tdSql.query(f"select avg(a+2) as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)") tdSql.checkData(0,0,16.086956522) # mixup with other functions - tdSql.query("select max(c1),count(c1),last(c2,c3),sum(c1+c2),avg(c1) from stb1") + tdSql.query(f"select max(c1),count(c1),last(c2,c3),sum(c1+c2),avg(c1) from {dbname}.stb1") tdSql.checkData(0,0,28) tdSql.checkData(0,1,184) tdSql.checkData(0,2,-99999) diff --git a/tests/system-test/2-query/distribute_agg_count.py b/tests/system-test/2-query/distribute_agg_count.py index 67f7e283258cac6db3e2fc2454e60977ccb034b7..835d1eeb5734f84319f8087262acb7a35fd4a6e8 100644 --- a/tests/system-test/2-query/distribute_agg_count.py +++ b/tests/system-test/2-query/distribute_agg_count.py @@ -6,11 +6,8 @@ import random class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, - "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } + updatecfgDict = {"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor()) @@ -35,76 +32,52 @@ class TDTestCase: else: tdLog.info(" count function work as expected, sql : %s "% max_sql) - - def prepare_datas_of_distribute(self): + def prepare_datas_of_distribute(self, dbname="testdb"): # prepate datas for 20 tables distributed at different vgroups - tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") - tdSql.execute(" use testdb ") + tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5") + tdSql.execute(f" use {dbname} ") tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) ''' ) - tdSql.execute( - ''' - create table t1 - (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) - ''' - ) for i in range(20): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') for i in range(9): tdSql.execute( - f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) for i in range(1,21): if i ==1 or i == 4: continue else: - tbname = "ct"+f'{i}' + tbname = f"{dbname}.ct{i}" for j in range(9): tdSql.execute( f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - - tdSql.execute( - f'''insert into t1 values - ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) - ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) - ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a ) - ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a ) - ( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a ) - ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a ) - ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) - ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) - ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) - ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ''' - ) + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdLog.info(" prepare data for distributed_aggregate done! ") - def check_distribute_datas(self): + def check_distribute_datas(self, dbname="testdb"): # get vgroup_ids of all - tdSql.query("show vgroups ") + tdSql.query(f"show {dbname}.vgroups ") vgroups = tdSql.queryResult vnode_tables={} @@ -114,7 +87,7 @@ class TDTestCase: # check sub_table of per vnode ,make sure sub_table has been distributed - tdSql.query("show tables like 'ct%'") + tdSql.query(f"show {dbname}.tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: @@ -128,7 +101,7 @@ class TDTestCase: if count < 2: tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") - def check_count_distribute_diff_vnode(self,col_name): + def check_count_distribute_diff_vnode(self,col_name, dbname="testdb"): vgroup_ids = [] for k ,v in self.vnode_disbutes.items(): @@ -146,9 +119,9 @@ class TDTestCase: tbname_filters = tbname_ins[:-1] - max_sql = f"select count({col_name}) from stb1 where tbname in ({tbname_filters});" + max_sql = f"select count({col_name}) from {dbname}.stb1 where tbname in ({tbname_filters});" - same_sql = f"select sum(c) from (select {col_name} ,1 as c from stb1 where tbname in ({tbname_filters}) and {col_name} is not null) " + same_sql = f"select sum(c) from (select {col_name} ,1 as c from {dbname}.stb1 where tbname in ({tbname_filters}) and {col_name} is not null) " tdSql.query(max_sql) max_result = tdSql.queryResult @@ -161,16 +134,16 @@ class TDTestCase: else: tdLog.info(" count function work as expected, sql : %s "% max_sql) - def check_count_status(self): + def check_count_status(self, dbname="testdb"): # check max function work status - tdSql.query("show tables like 'ct%'") + tdSql.query(f"show {dbname}.tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: - tablenames.append(table_name[0]) + tablenames.append(f"{dbname}.{table_name[0]}") - tdSql.query("desc stb1") + tdSql.query(f"desc {dbname}.stb1") col_names = tdSql.queryResult colnames = [] @@ -186,34 +159,33 @@ class TDTestCase: for colname in colnames: if colname.startswith("c"): - self.check_count_distribute_diff_vnode(colname) + self.check_count_distribute_diff_vnode(colname, dbname) else: - # self.check_count_distribute_diff_vnode(colname) # bug for tag + # self.check_count_distribute_diff_vnode(colname, dbname) # bug for tag pass - - def distribute_agg_query(self): + def distribute_agg_query(self, dbname="testdb"): # basic filter - tdSql.query("select count(c1) from stb1 ") + tdSql.query(f"select count(c1) from {dbname}.stb1 ") tdSql.checkData(0,0,184) - tdSql.query("select count(c1) from stb1 where t1=1") + tdSql.query(f"select count(c1) from {dbname}.stb1 where t1=1") tdSql.checkData(0,0,9) - tdSql.query("select count(c1+c2) from stb1 where c1 =1 ") + tdSql.query(f"select count(c1+c2) from {dbname}.stb1 where c1 =1 ") tdSql.checkData(0,0,2) - tdSql.query("select count(c1) from stb1 where tbname=\"ct2\"") + tdSql.query(f"select count(c1) from {dbname}.stb1 where tbname=\"ct2\"") tdSql.checkData(0,0,9) - tdSql.query("select count(c1) from stb1 partition by tbname") + tdSql.query(f"select count(c1) from {dbname}.stb1 partition by tbname") tdSql.checkRows(20) - tdSql.query("select count(c1) from stb1 where t1> 4 partition by tbname") + tdSql.query(f"select count(c1) from {dbname}.stb1 where t1> 4 partition by tbname") tdSql.checkRows(15) # union all - tdSql.query("select count(c1) from stb1 union all select count(c1) from stb1 ") + tdSql.query(f"select count(c1) from {dbname}.stb1 union all select count(c1) from {dbname}.stb1 ") tdSql.checkRows(2) tdSql.checkData(0,0,184) @@ -221,60 +193,60 @@ class TDTestCase: tdSql.execute(" create database if not exists db ") tdSql.execute(" use db ") - tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") - tdSql.execute(" create table tb1 using st tags(1) ") - tdSql.execute(" create table tb2 using st tags(2) ") + tdSql.execute(" create stable db.st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") + tdSql.execute(" create table db.tb1 using db.st tags(1) ") + tdSql.execute(" create table db.tb2 using db.st tags(2) ") for i in range(10): ts = i*10 + self.ts - tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") - tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into db.tb1 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into db.tb2 values({ts},{i},{i}.0)") - tdSql.query("select count(tb1.c1), count(tb2.c2) from tb1, tb2 where tb1.ts=tb2.ts") + tdSql.query(f"select count(tb1.c1), count(tb2.c2) from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts") tdSql.checkRows(1) tdSql.checkData(0,0,10) tdSql.checkData(0,1,10) # group by - tdSql.execute(" use testdb ") + tdSql.execute(f" use {dbname} ") - tdSql.query(" select count(*) from stb1 ") + tdSql.query(f"select count(*) from {dbname}.stb1 ") tdSql.checkData(0,0,187) - tdSql.query(" select count(*) from stb1 group by t1 ") + tdSql.query(f"select count(*) from {dbname}.stb1 group by t1 ") tdSql.checkRows(20) - tdSql.query(" select count(*) from stb1 group by c1 ") + tdSql.query(f"select count(*) from {dbname}.stb1 group by c1 ") tdSql.checkRows(30) - tdSql.query(" select count(*) from stb1 group by c2 ") + tdSql.query(f"select count(*) from {dbname}.stb1 group by c2 ") tdSql.checkRows(31) # partition by tbname or partition by tag - tdSql.query("select max(c1),tbname from stb1 partition by tbname") + tdSql.query(f"select max(c1),tbname from {dbname}.stb1 partition by tbname") query_data = tdSql.queryResult for row in query_data: - tbname = row[1] - tdSql.query(" select max(c1) from %s "%tbname) + tbname = f"{dbname}.{row[1]}" + tdSql.query(f"select max(c1) from %s "%tbname) tdSql.checkData(0,0,row[0]) - tdSql.query("select max(c1),tbname from stb1 partition by t1") + tdSql.query(f"select max(c1),tbname from {dbname}.stb1 partition by t1") query_data = tdSql.queryResult for row in query_data: - tbname = row[1] - tdSql.query(" select max(c1) from %s "%tbname) + tbname = f"{dbname}.{row[1]}" + tdSql.query(f"select max(c1) from %s "%tbname) tdSql.checkData(0,0,row[0]) # nest query for support max - tdSql.query("select abs(c2+2)+1 from (select count(c1) c2 from stb1)") + tdSql.query(f"select abs(c2+2)+1 from (select count(c1) c2 from {dbname}.stb1)") tdSql.checkData(0,0,187.000000000) - tdSql.query("select count(c1+2) as c2 from (select ts ,c1 ,c2 from stb1)") + tdSql.query(f"select count(c1+2) as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)") tdSql.checkData(0,0,184) - tdSql.query("select count(a+2) as c2 from (select ts ,abs(c1) a ,c2 from stb1)") + tdSql.query(f"select count(a+2) as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)") tdSql.checkData(0,0,184) # mixup with other functions - tdSql.query("select max(c1),count(c1),last(c2,c3) from stb1") + tdSql.query(f"select max(c1),count(c1),last(c2,c3) from {dbname}.stb1") tdSql.checkData(0,0,28) tdSql.checkData(0,1,184) tdSql.checkData(0,2,-99999) diff --git a/tests/system-test/2-query/distribute_agg_max.py b/tests/system-test/2-query/distribute_agg_max.py index d4b71dbdd77e32bc57f6129ad91d9263cad055c7..a7b31a2084af6665a83fac722c8ca1cb653d5dd9 100644 --- a/tests/system-test/2-query/distribute_agg_max.py +++ b/tests/system-test/2-query/distribute_agg_max.py @@ -6,10 +6,8 @@ import random class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, - "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } + + updatecfgDict = {"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) @@ -36,75 +34,52 @@ class TDTestCase: tdLog.info(" max function work as expected, sql : %s "% max_sql) - def prepare_datas_of_distribute(self): + def prepare_datas_of_distribute(self, dbname="testdb"): # prepate datas for 20 tables distributed at different vgroups - tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") - tdSql.execute(" use testdb ") + tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5") + tdSql.execute(f" use {dbname} ") tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) ''' ) - tdSql.execute( - ''' - create table t1 - (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) - ''' - ) for i in range(20): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') for i in range(9): tdSql.execute( - f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) for i in range(1,21): if i ==1 or i == 4: continue else: - tbname = "ct"+f'{i}' + tbname = f"{dbname}.ct{i}" for j in range(9): tdSql.execute( f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - - tdSql.execute( - f'''insert into t1 values - ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) - ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) - ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a ) - ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a ) - ( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a ) - ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a ) - ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) - ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) - ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) - ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ''' - ) + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdLog.info(" prepare data for distributed_aggregate done! ") - def check_distribute_datas(self): + def check_distribute_datas(self, dbname="testdb"): # get vgroup_ids of all - tdSql.query("show vgroups ") + tdSql.query(f"show {dbname}.vgroups ") vgroups = tdSql.queryResult vnode_tables={} @@ -112,9 +87,8 @@ class TDTestCase: for vgroup_id in vgroups: vnode_tables[vgroup_id[0]]=[] - # check sub_table of per vnode ,make sure sub_table has been distributed - tdSql.query("show tables like 'ct%'") + tdSql.query(f"show {dbname}.tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: @@ -128,7 +102,7 @@ class TDTestCase: if count < 2: tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") - def check_max_distribute_diff_vnode(self,col_name): + def check_max_distribute_diff_vnode(self,col_name, dbname="testdb"): vgroup_ids = [] for k ,v in self.vnode_disbutes.items(): @@ -146,9 +120,9 @@ class TDTestCase: tbname_filters = tbname_ins[:-1] - max_sql = f"select max({col_name}) from stb1 where tbname in ({tbname_filters});" + max_sql = f"select max({col_name}) from {dbname}.stb1 where tbname in ({tbname_filters});" - same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) order by {col_name} desc limit 1" + same_sql = f"select {col_name} from {dbname}.stb1 where tbname in ({tbname_filters}) order by {col_name} desc limit 1" tdSql.query(max_sql) max_result = tdSql.queryResult @@ -161,16 +135,16 @@ class TDTestCase: else: tdLog.info(" max function work as expected, sql : %s "% max_sql) - def check_max_status(self): + def check_max_status(self, dbname="testdb"): # check max function work status - tdSql.query("show tables like 'ct%'") + tdSql.query(f"show {dbname}.tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: - tablenames.append(table_name[0]) + tablenames.append(f"{dbname}.{table_name[0]}") - tdSql.query("desc stb1") + tdSql.query(f"desc {dbname}.stb1") col_names = tdSql.queryResult colnames = [] @@ -186,34 +160,33 @@ class TDTestCase: for colname in colnames: if colname.startswith("c"): - self.check_max_distribute_diff_vnode(colname) + self.check_max_distribute_diff_vnode(colname, dbname) else: - # self.check_max_distribute_diff_vnode(colname) # bug for tag + # self.check_max_distribute_diff_vnode(colname, dbname) # bug for tag pass - - def distribute_agg_query(self): + def distribute_agg_query(self, dbname="testdb"): # basic filter - tdSql.query("select max(c1) from stb1 where c1 is null") + tdSql.query(f"select max(c1) from {dbname}.stb1 where c1 is null") tdSql.checkRows(0) - tdSql.query("select max(c1) from stb1 where t1=1") + tdSql.query(f"select max(c1) from {dbname}.stb1 where t1=1") tdSql.checkData(0,0,10) - tdSql.query("select max(c1+c2) from stb1 where c1 =1 ") + tdSql.query(f"select max(c1+c2) from {dbname}.stb1 where c1 =1 ") tdSql.checkData(0,0,11112.000000000) - tdSql.query("select max(c1) from stb1 where tbname=\"ct2\"") + tdSql.query(f"select max(c1) from {dbname}.stb1 where tbname=\"ct2\"") tdSql.checkData(0,0,10) - tdSql.query("select max(c1) from stb1 partition by tbname") + tdSql.query(f"select max(c1) from {dbname}.stb1 partition by tbname") tdSql.checkRows(20) - tdSql.query("select max(c1) from stb1 where t1> 4 partition by tbname") + tdSql.query(f"select max(c1) from {dbname}.stb1 where t1> 4 partition by tbname") tdSql.checkRows(15) # union all - tdSql.query("select max(c1) from stb1 union all select max(c1) from stb1 ") + tdSql.query(f"select max(c1) from {dbname}.stb1 union all select max(c1) from {dbname}.stb1 ") tdSql.checkRows(2) tdSql.checkData(0,0,28) @@ -221,45 +194,45 @@ class TDTestCase: tdSql.execute(" create database if not exists db ") tdSql.execute(" use db ") - tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") - tdSql.execute(" create table tb1 using st tags(1) ") - tdSql.execute(" create table tb2 using st tags(2) ") + tdSql.execute(" create stable db.st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") + tdSql.execute(" create table db.tb1 using db.st tags(1) ") + tdSql.execute(" create table db.tb2 using db.st tags(2) ") for i in range(10): ts = i*10 + self.ts - tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") - tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into db.tb1 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into db.tb2 values({ts},{i},{i}.0)") - tdSql.query("select max(tb1.c1), tb2.c2 from tb1, tb2 where tb1.ts=tb2.ts") + tdSql.query(f"select max(tb1.c1), tb2.c2 from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts") tdSql.checkRows(1) tdSql.checkData(0,0,9) tdSql.checkData(0,0,9.00000) # group by - tdSql.execute(" use testdb ") - tdSql.query(" select max(c1),c1 from stb1 group by t1 ") + tdSql.execute("use testdb ") + tdSql.query(f"select max(c1),c1 from {dbname}.stb1 group by t1 ") tdSql.checkRows(20) - tdSql.query(" select max(c1),c1 from stb1 group by c1 ") + tdSql.query(f"select max(c1),c1 from {dbname}.stb1 group by c1 ") tdSql.checkRows(30) - tdSql.query(" select max(c1),c2 from stb1 group by c2 ") + tdSql.query(f"select max(c1),c2 from {dbname}.stb1 group by c2 ") tdSql.checkRows(31) # selective common cols of datas - tdSql.query("select max(c1),c2,c3,c5 from stb1") + tdSql.query(f"select max(c1),c2,c3,c5 from {dbname}.stb1") tdSql.checkRows(1) tdSql.checkData(0,0,28) tdSql.checkData(0,1,311108) tdSql.checkData(0,2,3108) tdSql.checkData(0,3,31.08000) - tdSql.query("select max(c1),t1,c2,t3 from stb1") + tdSql.query(f"select max(c1),t1,c2,t3 from {dbname}.stb1") tdSql.checkRows(1) tdSql.checkData(0,0,28) tdSql.checkData(0,1,19) tdSql.checkData(0,2,311108) - tdSql.query("select max(c1),ceil(t1),pow(c2,1)+2,abs(t3) from stb1") + tdSql.query(f"select max(c1),ceil(t1),pow(c2,1)+2,abs(t3) from {dbname}.stb1") tdSql.checkRows(1) tdSql.checkData(0,0,28) tdSql.checkData(0,1,19) @@ -267,32 +240,32 @@ class TDTestCase: tdSql.checkData(0,3,2109) # partition by tbname or partition by tag - tdSql.query("select max(c1),tbname from stb1 partition by tbname") + tdSql.query(f"select max(c1),tbname from {dbname}.stb1 partition by tbname") query_data = tdSql.queryResult for row in query_data: - tbname = row[1] - tdSql.query(" select max(c1) from %s "%tbname) + tbname = f"{dbname}.{row[1]}" + tdSql.query(f"select max(c1) from %s "%tbname) tdSql.checkData(0,0,row[0]) - tdSql.query("select max(c1),tbname from stb1 partition by t1") + tdSql.query(f"select max(c1),tbname from {dbname}.stb1 partition by t1") query_data = tdSql.queryResult for row in query_data: - tbname = row[1] - tdSql.query(" select max(c1) from %s "%tbname) + tbname = f"{dbname}.{row[1]}" + tdSql.query(f"select max(c1) from %s "%tbname) tdSql.checkData(0,0,row[0]) # nest query for support max - tdSql.query("select abs(c2+2)+1 from (select max(c1) c2 from stb1)") + tdSql.query(f"select abs(c2+2)+1 from (select max(c1) c2 from {dbname}.stb1)") tdSql.checkData(0,0,31.000000000) - tdSql.query("select max(c1+2)+1 as c2 from (select ts ,c1 ,c2 from stb1)") + tdSql.query(f"select max(c1+2)+1 as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)") tdSql.checkData(0,0,31.000000000) - tdSql.query("select max(a+2)+1 as c2 from (select ts ,abs(c1) a ,c2 from stb1)") + tdSql.query(f"select max(a+2)+1 as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)") tdSql.checkData(0,0,31.000000000) # mixup with other functions - tdSql.query("select max(c1),count(c1),last(c2,c3) from stb1") + tdSql.query(f"select max(c1),count(c1),last(c2,c3) from {dbname}.stb1") tdSql.checkData(0,0,28) tdSql.checkData(0,1,184) tdSql.checkData(0,2,-99999) diff --git a/tests/system-test/2-query/distribute_agg_min.py b/tests/system-test/2-query/distribute_agg_min.py index 059efe02cddeddc794a70ea255b8460b9d1fa9e1..cc50092451167bcf72ad57480b03cae370a7b297 100644 --- a/tests/system-test/2-query/distribute_agg_min.py +++ b/tests/system-test/2-query/distribute_agg_min.py @@ -6,10 +6,8 @@ import random class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, - "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } + + updatecfgDict = {"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) @@ -35,76 +33,52 @@ class TDTestCase: else: tdLog.info(" min function work as expected, sql : %s "% min_sql) - - def prepare_datas_of_distribute(self): + def prepare_datas_of_distribute(self, dbname="testdb"): # prepate datas for 20 tables distributed at different vgroups - tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") - tdSql.execute(" use testdb ") + tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5") + tdSql.execute(f" use {dbname} ") tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) ''' ) - tdSql.execute( - ''' - create table t1 - (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) - ''' - ) for i in range(20): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') for i in range(9): tdSql.execute( - f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) for i in range(1,21): if i ==1 or i == 4: continue else: - tbname = "ct"+f'{i}' + tbname = f"{dbname}.ct{i}" for j in range(9): tdSql.execute( f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - - tdSql.execute( - f'''insert into t1 values - ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) - ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) - ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a ) - ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a ) - ( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a ) - ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a ) - ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) - ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) - ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) - ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ''' - ) + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdLog.info(" prepare data for distributed_aggregate done! ") - def check_distribute_datas(self): + def check_distribute_datas(self, dbname="testdb"): # get vgroup_ids of all - tdSql.query("show vgroups ") + tdSql.query(f"show {dbname}.vgroups ") vgroups = tdSql.queryResult vnode_tables={} @@ -112,9 +86,8 @@ class TDTestCase: for vgroup_id in vgroups: vnode_tables[vgroup_id[0]]=[] - # check sub_table of per vnode ,make sure sub_table has been distributed - tdSql.query("show tables like 'ct%'") + tdSql.query(f"show {dbname}.tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: @@ -128,7 +101,7 @@ class TDTestCase: if count < 2: tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") - def check_min_distribute_diff_vnode(self,col_name): + def check_min_distribute_diff_vnode(self,col_name, dbname="testdb"): vgroup_ids = [] for k ,v in self.vnode_disbutes.items(): @@ -146,9 +119,9 @@ class TDTestCase: tbname_filters = tbname_ins[:-1] - min_sql = f"select min({col_name}) from stb1 where tbname in ({tbname_filters});" + min_sql = f"select min({col_name}) from {dbname}.stb1 where tbname in ({tbname_filters});" - same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) and {col_name} is not null order by {col_name} asc limit 1" + same_sql = f"select {col_name} from {dbname}.stb1 where tbname in ({tbname_filters}) and {col_name} is not null order by {col_name} asc limit 1" tdSql.query(min_sql) min_result = tdSql.queryResult @@ -161,16 +134,16 @@ class TDTestCase: else: tdLog.info(" min function work as expected, sql : %s "% min_sql) - def check_min_status(self): - # check max function work status + def check_min_status(self, dbname="testdb"): + # check min function work status - tdSql.query("show tables like 'ct%'") + tdSql.query(f"show {dbname}.tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: - tablenames.append(table_name[0]) + tablenames.append(f"{dbname}.{table_name[0]}") - tdSql.query("desc stb1") + tdSql.query(f"desc {dbname}.stb1") col_names = tdSql.queryResult colnames = [] @@ -182,119 +155,117 @@ class TDTestCase: for colname in colnames: self.check_min_functions(tablename,colname) - # check max function for different vnode + # check min function for different vnode for colname in colnames: if colname.startswith("c"): - self.check_min_distribute_diff_vnode(colname) + self.check_min_distribute_diff_vnode(colname, dbname) else: - # self.check_min_distribute_diff_vnode(colname) # bug for tag + # self.check_min_distribute_diff_vnode(colname, dbname) # bug for tag pass - - def distribute_agg_query(self): + def distribute_agg_query(self, dbname="testdb"): # basic filter - tdSql.query("select min(c1) from stb1 where c1 is null") + tdSql.query(f"select min(c1) from {dbname}.stb1 where c1 is null") tdSql.checkRows(0) - tdSql.query("select min(c1) from stb1 where t1=1") + tdSql.query(f"select min(c1) from {dbname}.stb1 where t1=1") tdSql.checkData(0,0,2) - tdSql.query("select min(c1+c2) from stb1 where c1 =1 ") + tdSql.query(f"select min(c1+c2) from {dbname}.stb1 where c1 =1 ") tdSql.checkData(0,0,11112.000000000) - tdSql.query("select min(c1) from stb1 where tbname=\"ct2\"") - tdSql.checkData(0,0,2) + tdSql.query(f"select min(c1) from {dbname}.stb1 where tbname=\"ct2\"") + tdSql.checkData(0, 0, 2) - tdSql.query("select min(c1) from stb1 partition by tbname") + tdSql.query(f"select min(c1) from {dbname}.stb1 partition by tbname") tdSql.checkRows(20) - tdSql.query("select min(c1) from stb1 where t1> 4 partition by tbname") + tdSql.query(f"select min(c1) from {dbname}.stb1 where t1> 4 partition by tbname") tdSql.checkRows(15) # union all - tdSql.query("select min(c1) from stb1 union all select min(c1) from stb1 ") + tdSql.query(f"select min(c1) from {dbname}.stb1 union all select min(c1) from {dbname}.stb1 ") tdSql.checkRows(2) - tdSql.checkData(0,0,0) + tdSql.checkData(0, 0, 0) # join tdSql.execute(" create database if not exists db ") tdSql.execute(" use db ") - tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") - tdSql.execute(" create table tb1 using st tags(1) ") - tdSql.execute(" create table tb2 using st tags(2) ") + tdSql.execute(" create stable db.st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") + tdSql.execute(" create table db.tb1 using db.st tags(1) ") + tdSql.execute(" create table db.tb2 using db.st tags(2) ") for i in range(10): ts = i*10 + self.ts - tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") - tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into db.tb1 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into db.tb2 values({ts},{i},{i}.0)") - tdSql.query("select min(tb1.c1), tb2.c2 from tb1, tb2 where tb1.ts=tb2.ts") + tdSql.query(f"select min(tb1.c1), tb2.c2 from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts") tdSql.checkRows(1) tdSql.checkData(0,0,0) tdSql.checkData(0,0,0.00000) # group by - tdSql.execute(" use testdb ") - tdSql.query(" select min(c1),c1 from stb1 group by t1 ") + tdSql.execute(f"use {dbname} ") + tdSql.query(f"select min(c1),c1 from {dbname}.stb1 group by t1 ") tdSql.checkRows(20) - tdSql.query(" select min(c1),c1 from stb1 group by c1 ") + tdSql.query(f"select min(c1),c1 from {dbname}.stb1 group by c1 ") tdSql.checkRows(30) - tdSql.query(" select min(c1),c2 from stb1 group by c2 ") + tdSql.query(f"select min(c1),c2 from {dbname}.stb1 group by c2 ") tdSql.checkRows(31) # selective common cols of datas - tdSql.query("select min(c1),c2,c3,c5 from stb1") + tdSql.query(f"select min(c1),c2,c3,c5 from {dbname}.stb1") tdSql.checkRows(1) tdSql.checkData(0,0,0) tdSql.checkData(0,1,0) tdSql.checkData(0,2,0) tdSql.checkData(0,3,0) - tdSql.query("select min(c1),t1,c2,t3 from stb1 where c1 >5") + tdSql.query(f"select min(c1),t1,c2,t3 from {dbname}.stb1 where c1 > 5") tdSql.checkRows(1) tdSql.checkData(0,0,6) tdSql.checkData(0,2,66666) - tdSql.query("select min(c1),ceil(t1),pow(c2,1)+2,abs(t3) from stb1 where c1>12") + tdSql.query(f"select min(c1),ceil(t1),pow(c2,1)+2,abs(t3) from {dbname}.stb1 where c1 > 12") tdSql.checkRows(1) tdSql.checkData(0,0,13) tdSql.checkData(0,2,144445.000000000) # partition by tbname or partition by tag - tdSql.query("select min(c1),tbname from stb1 partition by tbname") + tdSql.query(f"select min(c1),tbname from {dbname}.stb1 partition by tbname") query_data = tdSql.queryResult for row in query_data: - tbname = row[1] - tdSql.query(" select min(c1) from %s "%tbname) + tbname = f"{dbname}.{row[1]}" + tdSql.query(f"select min(c1) from %s "%tbname) tdSql.checkData(0,0,row[0]) - tdSql.query("select min(c1),tbname from stb1 partition by t1") + tdSql.query(f"select min(c1),tbname from {dbname}.stb1 partition by t1") query_data = tdSql.queryResult for row in query_data: - tbname = row[1] - tdSql.query(" select min(c1) from %s "%tbname) + tbname = f"{dbname}.{row[1]}" + tdSql.query(f"select min(c1) from %s "%tbname) tdSql.checkData(0,0,row[0]) - # nest query for support max - tdSql.query("select abs(c2+2)+1 from (select min(c1) c2 from stb1)") + # nest query for support min + tdSql.query(f"select abs(c2+2)+1 from (select min(c1) c2 from {dbname}.stb1)") tdSql.checkData(0,0,3.000000000) - tdSql.query("select min(c1+2)+1 as c2 from (select ts ,c1 ,c2 from stb1)") + tdSql.query(f"select min(c1+2)+1 as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)") tdSql.checkData(0,0,3.000000000) - tdSql.query("select min(a+2)+1 as c2 from (select ts ,abs(c1) a ,c2 from stb1)") + tdSql.query(f"select min(a+2)+1 as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)") tdSql.checkData(0,0,3.000000000) # mixup with other functions - tdSql.query("select max(c1),count(c1),last(c2,c3),min(c1) from stb1") + tdSql.query(f"select max(c1),count(c1),last(c2,c3) from {dbname}.stb1") tdSql.checkData(0,0,28) tdSql.checkData(0,1,184) tdSql.checkData(0,2,-99999) tdSql.checkData(0,3,-999) - tdSql.checkData(0,4,0) def run(self): diff --git a/tests/system-test/2-query/function_diff.py b/tests/system-test/2-query/function_diff.py index 5e95510c1d7337cfe81850249a375d35ba307c7c..99e87e6cd647a9731052014cc848d890d81c9362 100644 --- a/tests/system-test/2-query/function_diff.py +++ b/tests/system-test/2-query/function_diff.py @@ -283,14 +283,14 @@ class TDTestCase: tdSql.error(self.diff_query_form(alias=", diff(c1)")) # mix with calculation function 2 # tdSql.error(self.diff_query_form(alias=" + 2")) # mix with arithmetic 1 tdSql.error(self.diff_query_form(alias=" + avg(c1)")) # mix with arithmetic 2 - tdSql.error(self.diff_query_form(alias=", c2")) # mix with other 1 + tdSql.query(self.diff_query_form(alias=", c2")) # mix with other 1 # tdSql.error(self.diff_query_form(table_expr="stb1")) # select stb directly stb_join = { "col": "stb1.c1", "table_expr": "stb1, stb2", "condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts" } - tdSql.error(self.diff_query_form(**stb_join)) # stb join + tdSql.query(self.diff_query_form(**stb_join)) # stb join interval_sql = { "condition": "where ts>0 and ts < now interval(1h) fill(next)" } diff --git a/tests/system-test/2-query/join.py b/tests/system-test/2-query/join.py index 2348873a34283572116e6eb97760733d400c6914..9d30e1946a16c487f22e43fe03461d559dc7c945 100644 --- a/tests/system-test/2-query/join.py +++ b/tests/system-test/2-query/join.py @@ -377,11 +377,11 @@ class TDTestCase: tdSql.query("select ct1.c_int from db.ct1 as ct1 join db1.ct1 as cy1 on ct1.ts=cy1.ts") tdSql.checkRows(self.rows) tdSql.query("select ct1.c_int from db.stb1 as ct1 join db1.ct1 as cy1 on ct1.ts=cy1.ts") - tdSql.checkRows(self.rows) + tdSql.checkRows(self.rows + int(self.rows * 0.6 //3)+ int(self.rows * 0.8 // 4)) tdSql.query("select ct1.c_int from db.nt1 as ct1 join db1.nt1 as cy1 on ct1.ts=cy1.ts") tdSql.checkRows(self.rows + 3) tdSql.query("select ct1.c_int from db.stb1 as ct1 join db1.stb1 as cy1 on ct1.ts=cy1.ts") - tdSql.checkRows(self.rows * 3 + 6) + tdSql.checkRows(50) tdSql.query("select count(*) from db.ct1") tdSql.checkData(0, 0, self.rows) diff --git a/tests/system-test/2-query/max_partition.py b/tests/system-test/2-query/max_partition.py index 109c9075f54d60ee2071a889975e322fde37d09f..4b9996d9c3b1d45f52e184f1da4ec8e59714feaa 100644 --- a/tests/system-test/2-query/max_partition.py +++ b/tests/system-test/2-query/max_partition.py @@ -193,20 +193,11 @@ class TDTestCase: tdSql.query("select c1 , DERIVATIVE(c1,2,1) from stb partition by c1 order by c1") tdSql.checkRows(90) # bug need fix - # tdSql.checkData(0,1,None) - - - - - - + tdSql.checkData(0,1,None) - # bug need fix - # tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname slimit 5 soffset 0 ") - # tdSql.checkRows(5) - # tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname slimit 5 soffset 1 ") - # tdSql.checkRows(5) + tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname slimit 5 soffset 0 ") + tdSql.checkRows(10) tdSql.query(" select tbname , max(c1) from sub_stb_1 partition by tbname interval(10s) sliding(5s) ") diff --git a/tests/system-test/6-cluster/5dnode3mnodeRecreateMnode.py b/tests/system-test/6-cluster/5dnode3mnodeRecreateMnode.py new file mode 100644 index 0000000000000000000000000000000000000000..48ee90fad2a755862561bcde88feff27a6b68639 --- /dev/null +++ b/tests/system-test/6-cluster/5dnode3mnodeRecreateMnode.py @@ -0,0 +1,246 @@ +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +from numpy import row_stack +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * +sys.path.append("./6-cluster") +from clusterCommonCreate import * +from clusterCommonCheck import clusterComCheck + +import time +import socket +import subprocess +from multiprocessing import Process +import threading +import time +import inspect +import ctypes + +class TDTestCase: + + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + self.TDDnodes = None + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + + + def 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): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def _async_raise(self, tid, exctype): + """raises the exception, performs cleanup if needed""" + if not inspect.isclass(exctype): + exctype = type(exctype) + res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype)) + if res == 0: + raise ValueError("invalid thread id") + elif res != 1: + # """if it returns a number greater than one, you're in trouble, + # and you should call it again with exc=NULL to revert the effect""" + ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) + raise SystemError("PyThreadState_SetAsyncExc failed") + + def stopThread(self,thread): + self._async_raise(thread.ident, SystemExit) + + + def insertData(self,countstart,countstop): + # fisrt add data : db\stable\childtable\general table + + for couti in range(countstart,countstop): + tdLog.debug("drop database if exists db%d" %couti) + tdSql.execute("drop database if exists db%d" %couti) + print("create database if not exists db%d replica 1 duration 300" %couti) + tdSql.execute("create database if not exists db%d replica 1 duration 300" %couti) + tdSql.execute("use db%d" %couti) + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + tdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + ''' + ) + for i in range(4): + tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + + + def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'db0_0', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'replica': 1, + 'stbName': 'stb', + 'stbNumbers': 2, + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 200, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + "rowsPerTbl": 100, + "batchNum": 5000 + } + username="user1" + passwd="123" + + dnodeNumbers=int(dnodeNumbers) + mnodeNums=int(mnodeNums) + vnodeNumbers = int(dnodeNumbers-mnodeNums) + allctbNumbers=(paraDict['stbNumbers']*paraDict["ctbNum"]) + rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"] + rowsall=rowsPerStb*paraDict['stbNumbers'] + dbNumbers = 1 + + tdLog.info("first check dnode and mnode") + tdSql.query("show dnodes;") + tdSql.checkData(0,1,'%s:6030'%self.host) + tdSql.checkData(4,1,'%s:6430'%self.host) + clusterComCheck.checkDnodes(dnodeNumbers) + clusterComCheck.checkMnodeStatus(1) + + # fisr add three mnodes; + tdLog.info("fisr add three mnodes and check mnode status") + tdSql.execute("create mnode on dnode 2") + clusterComCheck.checkMnodeStatus(2) + tdSql.execute("create mnode on dnode 3") + clusterComCheck.checkMnodeStatus(3) + + # add some error operations and + tdLog.info("Confirm the status of the dnode again") + tdSql.error("create mnode on dnode 2") + tdSql.query("show dnodes;") + print(tdSql.queryResult) + clusterComCheck.checkDnodes(dnodeNumbers) + + # recreate mnode + tdSql.execute("drop dnode 2;") + tdSql.execute('create dnode "%s:6130";'%self.host) + tdDnodes=cluster.dnodes + tdDnodes[1].stoptaosd() + tdDnodes[1].deploy() + + tdDnodes[1].starttaosd() + clusterComCheck.checkDnodes(dnodeNumbers) + + tdSql.execute("create mnode on dnode 6") + tdSql.error("drop dnode 1;") + + # check status of clusters + clusterComCheck.checkMnodeStatus(3) + tdSql.execute("create user %s pass '%s' ;"%(username,passwd)) + tdSql.query("show users") + for i in range(tdSql.queryRows): + if tdSql.queryResult[i][0] == "%s"%username : + tdLog.info("create user:%s successfully"%username) + + # # create database and stable + # clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) + # tdLog.info("Take turns stopping Mnodes ") + + # tdDnodes=cluster.dnodes + # stopcount =0 + # threads=[] + + # # create stable:stb_0 + # stableName= paraDict['stbName'] + # newTdSql=tdCom.newTdSql() + # clusterComCreate.create_stables(newTdSql, paraDict["dbName"],stableName,paraDict['stbNumbers']) + # #create child table:ctb_0 + # for i in range(paraDict['stbNumbers']): + # stableName= '%s_%d'%(paraDict['stbName'],i) + # newTdSql=tdCom.newTdSql() + # clusterComCreate.create_ctable(newTdSql, paraDict["dbName"],stableName,stableName, paraDict['ctbNum']) + # #insert date + # for i in range(paraDict['stbNumbers']): + # stableName= '%s_%d'%(paraDict['stbName'],i) + # newTdSql=tdCom.newTdSql() + # threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]))) + # for tr in threads: + # tr.start() + # for tr in threads: + # tr.join() + + # while stopcount < restartNumbers: + # tdLog.info(" restart loop: %d"%stopcount ) + # if stopRole == "mnode": + # for i in range(mnodeNums): + # tdDnodes[i].stoptaosd() + # # sleep(10) + # tdDnodes[i].starttaosd() + # # sleep(10) + # elif stopRole == "vnode": + # for i in range(vnodeNumbers): + # tdDnodes[i+mnodeNums].stoptaosd() + # # sleep(10) + # tdDnodes[i+mnodeNums].starttaosd() + # # sleep(10) + # elif stopRole == "dnode": + # for i in range(dnodeNumbers): + # tdDnodes[i].stoptaosd() + # # sleep(10) + # tdDnodes[i].starttaosd() + # # sleep(10) + + # # dnodeNumbers don't include database of schema + # if clusterComCheck.checkDnodes(dnodeNumbers): + # tdLog.info("dnode is ready") + # else: + # print("dnodes is not ready") + # self.stopThread(threads) + # tdLog.exit("one or more of dnodes failed to start ") + # # self.check3mnode() + # stopcount+=1 + + + # clusterComCheck.checkDnodes(dnodeNumbers) + # clusterComCheck.checkDbRows(dbNumbers) + # # clusterComCheck.checkDb(dbNumbers,1,paraDict["dbName"]) + + # tdSql.execute("use %s" %(paraDict["dbName"])) + # tdSql.query("show stables") + # tdSql.checkRows(paraDict["stbNumbers"]) + # # for i in range(paraDict['stbNumbers']): + # # stableName= '%s_%d'%(paraDict['stbName'],i) + # # tdSql.query("select * from %s"%stableName) + # # tdSql.checkRows(rowsPerStb) + + def run(self): + # print(self.master_dnode.cfgDict) + self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode') + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py b/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py index 587049e44edf7174e9ba2fc56b79e53329060c1d..8ae09dce1601965277f04e3f1da7f7273193f42b 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py +++ b/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py @@ -190,10 +190,9 @@ class TDTestCase: # dnodeNumbers don't include database of schema if clusterComCheck.checkDnodes(dnodeNumbers): - tdLog.info("123") + tdLog.info("dnode is ready") else: - print("456") - + print("dnodes is not ready") self.stopThread(threads) tdLog.exit("one or more of dnodes failed to start ") # self.check3mnode() @@ -207,10 +206,11 @@ class TDTestCase: tdSql.execute("use %s" %(paraDict["dbName"])) tdSql.query("show stables") tdSql.checkRows(paraDict["stbNumbers"]) - for i in range(paraDict['stbNumbers']): - stableName= '%s_%d'%(paraDict['stbName'],i) - tdSql.query("select * from %s"%stableName) - tdSql.checkRows(rowsPerStb) + # for i in range(paraDict['stbNumbers']): + # stableName= '%s_%d'%(paraDict['stbName'],i) + # tdSql.query("select * from %s"%stableName) + # tdSql.checkRows(rowsPerStb) + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode') diff --git a/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py b/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py new file mode 100644 index 0000000000000000000000000000000000000000..87d108cdeb418f19b6f588a506195c786f366f75 --- /dev/null +++ b/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py @@ -0,0 +1,224 @@ +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +from numpy import row_stack +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * +sys.path.append("./6-cluster") +from clusterCommonCreate import * +from clusterCommonCheck import clusterComCheck + +import time +import socket +import subprocess +from multiprocessing import Process +import threading +import time +import inspect +import ctypes + +class TDTestCase: + + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + self.TDDnodes = None + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + + + def 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): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def _async_raise(self, tid, exctype): + """raises the exception, performs cleanup if needed""" + if not inspect.isclass(exctype): + exctype = type(exctype) + res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype)) + if res == 0: + raise ValueError("invalid thread id") + elif res != 1: + # """if it returns a number greater than one, you're in trouble, + # and you should call it again with exc=NULL to revert the effect""" + ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) + raise SystemError("PyThreadState_SetAsyncExc failed") + + def stopThread(self,thread): + self._async_raise(thread.ident, SystemExit) + + + def insertData(self,countstart,countstop): + # fisrt add data : db\stable\childtable\general table + + for couti in range(countstart,countstop): + tdLog.debug("drop database if exists db%d" %couti) + tdSql.execute("drop database if exists db%d" %couti) + print("create database if not exists db%d replica 1 duration 300" %couti) + tdSql.execute("create database if not exists db%d replica 1 duration 300" %couti) + tdSql.execute("use db%d" %couti) + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + tdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + ''' + ) + for i in range(4): + tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + + + def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'db0_0', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'replica': 1, + 'stbName': 'stb', + 'stbNumbers': 2, + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 200, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + "rowsPerTbl": 100, + "batchNum": 5000 + } + + dnodeNumbers=int(dnodeNumbers) + mnodeNums=int(mnodeNums) + vnodeNumbers = int(dnodeNumbers-mnodeNums) + allctbNumbers=(paraDict['stbNumbers']*paraDict["ctbNum"]) + rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"] + rowsall=rowsPerStb*paraDict['stbNumbers'] + dbNumbers = 1 + + tdLog.info("first check dnode and mnode") + tdSql.query("show dnodes;") + tdSql.checkData(0,1,'%s:6030'%self.host) + tdSql.checkData(4,1,'%s:6430'%self.host) + clusterComCheck.checkDnodes(dnodeNumbers) + clusterComCheck.checkMnodeStatus(1) + + # fisr add three mnodes; + tdLog.info("fisr add three mnodes and check mnode status") + tdSql.execute("create mnode on dnode 2") + clusterComCheck.checkMnodeStatus(2) + tdSql.execute("create mnode on dnode 3") + clusterComCheck.checkMnodeStatus(3) + + # add some error operations and + tdLog.info("Confirm the status of the dnode again") + tdSql.error("create mnode on dnode 2") + tdSql.query("show dnodes;") + print(tdSql.queryResult) + clusterComCheck.checkDnodes(dnodeNumbers) + + # create database and stable + clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) + tdLog.info("Take turns stopping Mnodes ") + + tdDnodes=cluster.dnodes + stopcount =0 + threads=[] + + # create stable:stb_0 + stableName= paraDict['stbName'] + newTdSql=tdCom.newTdSql() + clusterComCreate.create_stables(newTdSql, paraDict["dbName"],stableName,paraDict['stbNumbers']) + #create child table:ctb_0 + for i in range(paraDict['stbNumbers']): + stableName= '%s_%d'%(paraDict['stbName'],i) + newTdSql=tdCom.newTdSql() + clusterComCreate.create_ctable(newTdSql, paraDict["dbName"],stableName,stableName, paraDict['ctbNum']) + #insert date + for i in range(paraDict['stbNumbers']): + stableName= '%s_%d'%(paraDict['stbName'],i) + newTdSql=tdCom.newTdSql() + threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]))) + for tr in threads: + tr.start() + + + while stopcount < restartNumbers: + tdLog.info(" restart loop: %d"%stopcount ) + if stopRole == "mnode": + for i in range(mnodeNums): + tdDnodes[i].stoptaosd() + # sleep(10) + tdDnodes[i].starttaosd() + # sleep(10) + elif stopRole == "vnode": + for i in range(vnodeNumbers): + tdDnodes[i+mnodeNums].stoptaosd() + # sleep(10) + tdDnodes[i+mnodeNums].starttaosd() + # sleep(10) + elif stopRole == "dnode": + for i in range(dnodeNumbers): + tdDnodes[i].stoptaosd() + # sleep(10) + tdDnodes[i].starttaosd() + # sleep(10) + + # dnodeNumbers don't include database of schema + if clusterComCheck.checkDnodes(dnodeNumbers): + tdLog.info("dnode is ready") + else: + print("dnodes is not ready") + self.stopThread(threads) + tdLog.exit("one or more of dnodes failed to start ") + # self.check3mnode() + stopcount+=1 + + for tr in threads: + tr.join() + + clusterComCheck.checkDnodes(dnodeNumbers) + clusterComCheck.checkDbRows(dbNumbers) + # clusterComCheck.checkDb(dbNumbers,1,paraDict["dbName"]) + + tdSql.execute("use %s" %(paraDict["dbName"])) + tdSql.query("show stables") + tdSql.checkRows(paraDict["stbNumbers"]) + # for i in range(paraDict['stbNumbers']): + # stableName= '%s_%d'%(paraDict['stbName'],i) + # tdSql.query("select * from %s"%stableName) + # tdSql.checkRows(rowsPerStb) + + def run(self): + # print(self.master_dnode.cfgDict) + self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode') + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py index 1788f24c3f34db6d1586ffe682ff5f406a3a74a8..d39bae68f966ea7f6329060ecdaa91f4b83cb37a 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py +++ b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py @@ -98,8 +98,10 @@ class TDTestCase: # fisr add three mnodes; tdLog.info("fisr add three mnodes and check mnode status") + tdSql.info("create mnode on dnode 2") tdSql.execute("create mnode on dnode 2") clusterComCheck.checkMnodeStatus(2) + tdSql.info("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) diff --git a/tests/system-test/6-cluster/5dnode3mnodeStop2Follower.py b/tests/system-test/6-cluster/5dnode3mnodeStop2Follower.py index 954e1ae003984904cc0aaf5def49ecf2fcfbb0a4..fef26333b7f81a9a1a689bb74cf4f1acd8c8e783 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStop2Follower.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStop2Follower.py @@ -68,7 +68,7 @@ class TDTestCase: 'showRow': 1} dnodenumbers=int(dnodenumbers) mnodeNums=int(mnodeNums) - dbNumbers = int(dnodenumbers * restartNumber) + dbNumbers = 1 tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") @@ -104,7 +104,7 @@ class TDTestCase: tdDnodes[1].starttaosd() tdDnodes[2].starttaosd() - clusterComCheck.checkMnodeStatus(3) + clusterComCheck.checkMnodeStatus(mnodeNums) def run(self): diff --git a/tests/system-test/6-cluster/5dnode3mnodeStopConnect.py b/tests/system-test/6-cluster/5dnode3mnodeStopConnect.py index 247bd29ed99458620a10173e685cdddb7674e18e..f1eb2a4587d6c60b05c4e6f108ada1a2697b1dc7 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStopConnect.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStopConnect.py @@ -111,14 +111,14 @@ class TDTestCase: # seperate vnode and mnode in different dnodes. # create database and stable stopcount =0 - while stopcount <= 2: + while stopcount < restartNumber: tdLog.info("first restart loop") for i in range(dnodenumbers): tdDnodes[i].stoptaosd() tdDnodes[i].starttaosd() stopcount+=1 clusterComCheck.checkDnodes(dnodenumbers) - clusterComCheck.checkMnodeStatus(3) + clusterComCheck.checkMnodeStatus(mnodeNums) def run(self): # print(self.master_dnode.cfgDict) diff --git a/tests/system-test/6-cluster/5dnode3mnodeStopFollowerLeader.py b/tests/system-test/6-cluster/5dnode3mnodeStopFollowerLeader.py new file mode 100644 index 0000000000000000000000000000000000000000..59a1a8f697e0991aaaf4291c0e46cf862b11bed1 --- /dev/null +++ b/tests/system-test/6-cluster/5dnode3mnodeStopFollowerLeader.py @@ -0,0 +1,122 @@ +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * +from test import tdDnodes +sys.path.append("./6-cluster") + +from clusterCommonCreate import * +from clusterCommonCheck import * +import time +import socket +import subprocess +from multiprocessing import Process + + +class TDTestCase: + + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + + + 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): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def fiveDnodeThreeMnode(self,dnodenumbers,mnodeNums,restartNumber): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'db0_0', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'replica': 1, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 1, + 'rowsPerTbl': 10000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1} + dnodenumbers=int(dnodenumbers) + mnodeNums=int(mnodeNums) + dbNumbers = 1 + + tdLog.info("first check dnode and mnode") + tdSql.query("show dnodes;") + tdSql.checkData(0,1,'%s:6030'%self.host) + tdSql.checkData(4,1,'%s:6430'%self.host) + clusterComCheck.checkDnodes(dnodenumbers) + clusterComCheck.checkMnodeStatus(1) + + # fisr add three mnodes; + tdLog.info("fisr add three mnodes and check mnode status") + tdSql.execute("create mnode on dnode 2") + clusterComCheck.checkMnodeStatus(2) + tdSql.execute("create mnode on dnode 3") + clusterComCheck.checkMnodeStatus(3) + + # add some error operations and + tdLog.info("Confirm the status of the dnode again") + tdSql.error("create mnode on dnode 2") + tdSql.query("show dnodes;") + # print(tdSql.queryResult) + clusterComCheck.checkDnodes(dnodenumbers) + # restart all taosd + tdDnodes=cluster.dnodes + tdLog.info("stop two mnode ") + + tdDnodes[0].stoptaosd() + tdDnodes[1].stoptaosd() + + # tdLog.info("check whether 2 mnode status is offline") + # clusterComCheck.check3mnode2off() + # tdSql.error("create user user1 pass '123';") + + tdLog.info("start one mnode" ) + tdDnodes[0].starttaosd() + clusterComCheck.check3mnodeoff(2) + + clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) + clusterComCheck.checkDb(dbNumbers,1,'db0') + + + + def run(self): + # print(self.master_dnode.cfgDict) + self.fiveDnodeThreeMnode(dnodenumbers=5,mnodeNums=3,restartNumber=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/6-cluster/clusterCommonCheck.py b/tests/system-test/6-cluster/clusterCommonCheck.py index 294f7cf61c5a3c084c23390d4fc3caa1e5873642..b758e6e71f1c045b090c641b20df10529e2a841a 100644 --- a/tests/system-test/6-cluster/clusterCommonCheck.py +++ b/tests/system-test/6-cluster/clusterCommonCheck.py @@ -40,7 +40,7 @@ class ClusterComCheck: def checkDnodes(self,dnodeNumbers): count=0 # print(tdSql) - while count < 5: + while count < 30: tdSql.query("show dnodes") # tdLog.debug(tdSql.queryResult) status=0 @@ -50,13 +50,14 @@ class ClusterComCheck: tdLog.info(status) if status == dnodeNumbers: - tdLog.success("it find cluster with %d dnodes and check that all cluster dnodes are ready within 5s! " %dnodeNumbers) + tdLog.success("it find cluster with %d dnodes and check that all cluster dnodes are ready within 30s! " %dnodeNumbers) return True count+=1 time.sleep(1) else: + tdSql.query("show dnodes") tdLog.debug(tdSql.queryResult) - tdLog.exit("it find cluster with %d dnodes but check that there dnodes are not ready within 5s ! "%dnodeNumbers) + tdLog.exit("it find cluster with %d dnodes but check that there dnodes are not ready within 30s ! "%dnodeNumbers) def checkDbRows(self,dbNumbers): dbNumbers=int(dbNumbers) @@ -82,7 +83,7 @@ class ClusterComCheck: for i in range(alldbNumbers): tdSql.query("show databases;") if "%s_%d"%(dbNameIndex,j) == tdSql.queryResult[i][0] : - if tdSql.queryResult[i][19] == "ready": + if tdSql.queryResult[i][15] == "ready": query_status+=1 tdLog.debug("check %s_%d that status is ready "%(dbNameIndex,j)) else: @@ -111,7 +112,7 @@ class ClusterComCheck: def checkMnodeStatus(self,mnodeNums): self.mnodeNums=int(mnodeNums) # self.leaderDnode=int(leaderDnode) - + tdLog.debug("start to check status of mnodes") count=0 while count < 10: diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py index e6192ba31360a1d01f8cbea79c96bd950504c30f..14494f1171aaf31d1bac26c2fe8d2fad483f0954 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py @@ -65,14 +65,14 @@ class TDTestCase: is_leader=True if count==1 and is_leader: - tdLog.info("===== depoly cluster success with 1 mnode as leader =====") + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") else: tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") for k ,v in self.dnode_list.items(): if k == mnode_name: if v[3]==0: - tdLog.info("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: @@ -115,7 +115,7 @@ class TDTestCase: for k , v in vgroups_infos.items(): if len(v) ==1 and v[0]=="leader": - tdLog.info(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py index d5fef08945cc33b3549d6755df112072b599ed35..9a21dab855276ef569a917c36dccb61872aa2d65 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py @@ -71,14 +71,14 @@ class TDTestCase: is_leader=True if count==1 and is_leader: - tdLog.info("===== depoly cluster success with 1 mnode as leader =====") + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") else: tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") for k ,v in self.dnode_list.items(): if k == mnode_name: if v[3]==0: - tdLog.info("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: @@ -121,7 +121,7 @@ class TDTestCase: for k , v in vgroups_infos.items(): if len(v) ==1 and v[0]=="leader": - tdLog.info(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) @@ -129,7 +129,7 @@ class TDTestCase: drop_db_sql = "drop database if exists {}".format(dbname) create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) - tdLog.info(" ==== create database {} and insert rows begin =====".format(dbname)) + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) tdSql.execute(drop_db_sql) tdSql.execute(create_db_sql) tdSql.execute("use {}".format(dbname)) @@ -155,7 +155,7 @@ class TDTestCase: ts = self.ts + 1000*row_num tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") - tdLog.info(" ==== create database {} and insert rows execute end =====".format(dbname)) + tdLog.notice(" ==== create database {} and insert rows execute end =====".format(dbname)) def check_insert_status(self, dbname, tb_nums , row_nums): tdSql.execute("use {}".format(dbname)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py index 00bd8a48d95a28382574a69cc64634ae70890a12..0b6ab8721a9d53cbdb9c42ea53d386ac44c17008 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py @@ -71,14 +71,14 @@ class TDTestCase: is_leader=True if count==1 and is_leader: - tdLog.info("===== depoly cluster success with 1 mnode as leader =====") + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") else: tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") for k ,v in self.dnode_list.items(): if k == mnode_name: if v[3]==0: - tdLog.info("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: @@ -121,7 +121,7 @@ class TDTestCase: for k , v in vgroups_infos.items(): if len(v) ==1 and v[0]=="leader": - tdLog.info(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) @@ -129,7 +129,7 @@ class TDTestCase: drop_db_sql = "drop database if exists {}".format(dbname) create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) - tdLog.info(" ==== create database {} and insert rows begin =====".format(dbname)) + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) tdSql.execute(drop_db_sql) tdSql.execute(create_db_sql) tdSql.execute("use {}".format(dbname)) @@ -155,7 +155,7 @@ class TDTestCase: ts = self.ts + 1000*row_num tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") - tdLog.info(" ==== create database {} and insert rows execute end =====".format(dbname)) + tdLog.notice(" ==== create database {} and insert rows execute end =====".format(dbname)) def check_insert_status(self, dbname, tb_nums , row_nums): tdSql.execute("use {}".format(dbname)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py index 22d3ba6dbc68c61bd8823ace82c7c50ffcdbdccc..3d6b548bddb1edf9bcdf9bc8febadcc74f1ab8e3 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py @@ -80,14 +80,14 @@ class TDTestCase: is_leader=True if count==1 and is_leader: - tdLog.info("===== depoly cluster success with 1 mnode as leader =====") + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") else: tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") for k ,v in self.dnode_list.items(): if k == mnode_name: if v[3]==0: - tdLog.info("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: @@ -130,7 +130,7 @@ class TDTestCase: for k , v in vgroups_infos.items(): if len(v) ==1 and v[0]=="leader": - tdLog.info(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) @@ -138,7 +138,7 @@ class TDTestCase: drop_db_sql = "drop database if exists {}".format(dbname) create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) - tdLog.info(" ==== create database {} and insert rows begin =====".format(dbname)) + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) tdSql.execute(drop_db_sql) tdSql.execute(create_db_sql) tdSql.execute("use {}".format(dbname)) @@ -161,7 +161,7 @@ class TDTestCase: ts = self.ts + self.ts_step*row_num tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") - tdLog.info(" ==== stable {} insert rows execute end =====".format(stablename)) + tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): @@ -170,7 +170,7 @@ class TDTestCase: for row_num in range(append_nums): tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") - tdLog.info(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) + tdLog.notice(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): @@ -197,7 +197,7 @@ class TDTestCase: time.sleep(0.1) tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) - tdLog.info(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) + tdLog.debug(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) count += 1 @@ -218,7 +218,7 @@ class TDTestCase: time.sleep(0.1) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) - tdLog.info(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) + tdLog.debug(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) count += 1 def _get_stop_dnode_id(self,dbname): tdSql.query("show {}.vgroups".format(dbname)) @@ -255,8 +255,8 @@ class TDTestCase: while status !="offline": time.sleep(0.1) status = _get_status() - # tdLog.info("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) - tdLog.info("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , id is {} ====".format(self.stop_dnode_id)) def wait_start_dnode_OK(self): @@ -277,8 +277,8 @@ class TDTestCase: while status !="ready": time.sleep(0.1) status = _get_status() - # tdLog.info("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) - tdLog.info("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , id is {} ====".format(self.stop_dnode_id)) def _parse_datetime(self,timestr): try: @@ -342,9 +342,9 @@ class TDTestCase: elif isinstance(data, str): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % (sql, row, col, tdSql.queryResult[row][col], data)) - elif isinstance(data, datetime.date): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (sql, row, col, tdSql.queryResult[row][col], data)) + # elif isinstance(data, datetime.date): + # tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + # (sql, row, col, tdSql.queryResult[row][col], data)) elif isinstance(data, float): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % (sql, row, col, tdSql.queryResult[row][col], data)) @@ -389,15 +389,15 @@ class TDTestCase: # append rows of stablename when dnode stop tbname = "sub_{}_{}".format(stablename , 0) - tdLog.info(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) - tdLog.info(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=100) # create new stables - tdLog.info(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb1' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) # begin start dnode @@ -409,9 +409,9 @@ class TDTestCase: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) # create new stables again - tdLog.info(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) def unsync_run_case(self): @@ -447,7 +447,7 @@ class TDTestCase: self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) + tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) # create sync threading and start it self.current_thread = _create_threading(db_name) @@ -457,21 +457,21 @@ class TDTestCase: self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0) tbname = "sub_{}_{}".format(stablename , 0) - tdLog.info(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) - tdLog.info(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=100) # create new stables - tdLog.info(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb1' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) # create new stables again - tdLog.info(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.current_thread.join() diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py index 28198b95293d5c999f381be58bf3baf328708e29..8ec634987980dd445bb206c4ba846dc7c95e0738 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py @@ -80,14 +80,14 @@ class TDTestCase: is_leader=True if count==1 and is_leader: - tdLog.info("===== depoly cluster success with 1 mnode as leader =====") + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") else: tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") for k ,v in self.dnode_list.items(): if k == mnode_name: if v[3]==0: - tdLog.info("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: @@ -130,7 +130,7 @@ class TDTestCase: for k , v in vgroups_infos.items(): if len(v) ==1 and v[0]=="leader": - tdLog.info(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) @@ -138,7 +138,7 @@ class TDTestCase: drop_db_sql = "drop database if exists {}".format(dbname) create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) - tdLog.info(" ==== create database {} and insert rows begin =====".format(dbname)) + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) tdSql.execute(drop_db_sql) tdSql.execute(create_db_sql) tdSql.execute("use {}".format(dbname)) @@ -161,7 +161,7 @@ class TDTestCase: ts = self.ts + self.ts_step*row_num tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") - tdLog.info(" ==== stable {} insert rows execute end =====".format(stablename)) + tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): @@ -170,7 +170,7 @@ class TDTestCase: for row_num in range(append_nums): tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") - tdLog.info(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) + tdLog.notice(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): @@ -197,7 +197,7 @@ class TDTestCase: time.sleep(0.1) tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) - tdLog.info(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) + tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) count += 1 @@ -218,7 +218,7 @@ class TDTestCase: time.sleep(0.1) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) - tdLog.info(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) + tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) count += 1 def _get_stop_dnode_id(self,dbname): @@ -256,8 +256,8 @@ class TDTestCase: while status !="offline": time.sleep(0.1) status = _get_status() - # tdLog.info("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) - tdLog.info("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) def wait_start_dnode_OK(self): @@ -278,8 +278,8 @@ class TDTestCase: while status !="ready": time.sleep(0.1) status = _get_status() - # tdLog.info("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) - tdLog.info("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) def _parse_datetime(self,timestr): try: @@ -343,9 +343,9 @@ class TDTestCase: elif isinstance(data, str): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % (sql, row, col, tdSql.queryResult[row][col], data)) - elif isinstance(data, datetime.date): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (sql, row, col, tdSql.queryResult[row][col], data)) + # elif isinstance(data, datetime.date): + # tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + # (sql, row, col, tdSql.queryResult[row][col], data)) elif isinstance(data, float): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % (sql, row, col, tdSql.queryResult[row][col], data)) @@ -390,15 +390,15 @@ class TDTestCase: # append rows of stablename when dnode stop tbname = "sub_{}_{}".format(stablename , 0) - tdLog.info(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) - tdLog.info(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=100) # create new stables - tdLog.info(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb1' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) # begin start dnode @@ -410,9 +410,9 @@ class TDTestCase: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) # create new stables again - tdLog.info(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) def unsync_run_case(self): @@ -448,7 +448,7 @@ class TDTestCase: self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) + tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) # create sync threading and start it self.current_thread = _create_threading(db_name) @@ -458,21 +458,21 @@ class TDTestCase: self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0) tbname = "sub_{}_{}".format(stablename , 0) - tdLog.info(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) - tdLog.info(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=100) # create new stables - tdLog.info(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb1' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) # create new stables again - tdLog.info(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.current_thread.join() diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py index 83faba45782e0bac1c6525917a8b585080267543..fa7e5292de668ab578f502c643ea9eb5be9a2d8e 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py @@ -80,14 +80,14 @@ class TDTestCase: is_leader=True if count==1 and is_leader: - tdLog.info("===== depoly cluster success with 1 mnode as leader =====") + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") else: tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") for k ,v in self.dnode_list.items(): if k == mnode_name: if v[3]==0: - tdLog.info("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: @@ -130,7 +130,7 @@ class TDTestCase: for k , v in vgroups_infos.items(): if len(v) ==1 and v[0]=="leader": - tdLog.info(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) @@ -138,7 +138,7 @@ class TDTestCase: drop_db_sql = "drop database if exists {}".format(dbname) create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) - tdLog.info(" ==== create database {} and insert rows begin =====".format(dbname)) + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) tdSql.execute(drop_db_sql) tdSql.execute(create_db_sql) tdSql.execute("use {}".format(dbname)) @@ -161,7 +161,7 @@ class TDTestCase: ts = self.ts + self.ts_step*row_num tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") - tdLog.info(" ==== stable {} insert rows execute end =====".format(stablename)) + tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): @@ -170,7 +170,7 @@ class TDTestCase: for row_num in range(append_nums): tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") - tdLog.info(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) + tdLog.notice(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): @@ -197,7 +197,7 @@ class TDTestCase: time.sleep(0.1) tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) - tdLog.info(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) + tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) count += 1 @@ -218,7 +218,7 @@ class TDTestCase: time.sleep(0.1) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) - tdLog.info(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) + tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) count += 1 def _get_stop_dnode_id(self,dbname): @@ -256,8 +256,8 @@ class TDTestCase: while status !="offline": time.sleep(0.1) status = _get_status() - # tdLog.info("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) - tdLog.info("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) def wait_start_dnode_OK(self): @@ -278,8 +278,8 @@ class TDTestCase: while status !="ready": time.sleep(0.1) status = _get_status() - # tdLog.info("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) - tdLog.info("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) def _parse_datetime(self,timestr): try: @@ -343,9 +343,9 @@ class TDTestCase: elif isinstance(data, str): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % (sql, row, col, tdSql.queryResult[row][col], data)) - elif isinstance(data, datetime.date): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (sql, row, col, tdSql.queryResult[row][col], data)) + # elif isinstance(data, datetime.date): + # tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + # (sql, row, col, tdSql.queryResult[row][col], data)) elif isinstance(data, float): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % (sql, row, col, tdSql.queryResult[row][col], data)) @@ -390,15 +390,15 @@ class TDTestCase: # append rows of stablename when dnode stop tbname = "sub_{}_{}".format(stablename , 0) - tdLog.info(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) - tdLog.info(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=100) # create new stables - tdLog.info(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb1' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) # begin start dnode @@ -410,9 +410,9 @@ class TDTestCase: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) # create new stables again - tdLog.info(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) def unsync_run_case(self): @@ -453,7 +453,7 @@ class TDTestCase: self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) + tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) # create sync threading and start it self.current_thread = _create_threading(db_name) @@ -463,21 +463,21 @@ class TDTestCase: self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0) tbname = "sub_{}_{}".format(stablename , 0) - tdLog.info(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) - tdLog.info(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=100) # create new stables - tdLog.info(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb1' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) # create new stables again - tdLog.info(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.current_thread.join() @@ -493,7 +493,7 @@ class TDTestCase: else: continue if port: - tdLog.info(" ==== dnode {} will be force stop by kill -9 ====".format(dnode_id)) + tdLog.notice(" ==== dnode {} will be force stop by kill -9 ====".format(dnode_id)) psCmd = '''netstat -anp|grep -w LISTEN|grep -w %s |grep -o "LISTEN.*"|awk '{print $2}'|cut -d/ -f1|head -n1''' %(port) processID = subprocess.check_output( psCmd, shell=True).decode("utf-8") diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py index c0aafa7978ba79c6618088bd4bd7ed2f141b201a..2e4b299fc620b4912c292a8ed7c2f4d18a3e9265 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py @@ -114,9 +114,9 @@ class TDTestCase: elif isinstance(data, str): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % (sql, row, col, tdSql.queryResult[row][col], data)) - elif isinstance(data, datetime.date): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (sql, row, col, tdSql.queryResult[row][col], data)) + # elif isinstance(data, datetime.date): + # tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + # (sql, row, col, tdSql.queryResult[row][col], data)) elif isinstance(data, float): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % (sql, row, col, tdSql.queryResult[row][col], data)) @@ -163,146 +163,20 @@ class TDTestCase: is_leader=True if count==1 and is_leader: - tdLog.info("===== depoly cluster success with 1 mnode as leader =====") + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") else: tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") for k ,v in self.dnode_list.items(): if k == mnode_name: if v[3]==0: - tdLog.info("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: continue - def create_db_check_vgroups(self): - - tdSql.execute("drop database if exists test") - tdSql.execute("create database if not exists test replica 1 duration 300") - tdSql.execute("use test") - tdSql.execute( - '''create table stb1 - (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) - tags (t1 int) - ''' - ) - tdSql.execute( - ''' - create table t1 - (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) - ''' - ) - - for i in range(5): - tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) - tdSql.query("show stables") - tdSql.checkRows(1) - tdSql.query("show tables") - tdSql.checkRows(6) - - tdSql.query("show test.vgroups;") - vgroups_infos = {} # key is id: value is info list - for vgroup_info in tdSql.queryResult: - vgroup_id = vgroup_info[0] - tmp_list = [] - for role in vgroup_info[3:-4]: - if role in ['leader','follower']: - tmp_list.append(role) - vgroups_infos[vgroup_id]=tmp_list - - for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": - tdLog.info(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) - else: - tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) - - def create_database(self, dbname, replica_num ,vgroup_nums ): - drop_db_sql = "drop database if exists {}".format(dbname) - create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) - - tdLog.info(" ==== create database {} and insert rows begin =====".format(dbname)) - tdSql.execute(drop_db_sql) - tdSql.execute(create_db_sql) - tdSql.execute("use {}".format(dbname)) - - def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): - tdSql.execute("use {}".format(dbname)) - tdSql.execute( - '''create table {} - (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) - tags (t1 int) - '''.format(stablename) - ) - - for i in range(tb_nums): - sub_tbname = "sub_{}_{}".format(stablename,i) - tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) - # insert datas about new database - - for row_num in range(row_nums): - ts = self.ts + self.ts_step*row_num - tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") - - tdLog.info(" ==== stable {} insert rows execute end =====".format(stablename)) - - def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): - - tdSql.execute("use {}".format(dbname)) - - for row_num in range(append_nums): - tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") - # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") - tdLog.info(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) - os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) - - def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): - - tdSql.execute("use {}".format(dbname)) - - tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) - - while not tdSql.queryResult: - time.sleep(0.1) - tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) - - status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) - - count = 0 - while not status_OK : - if count > self.try_check_times: - os.system("taos -s ' show {}.vgroups; '".format(dbname)) - tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname)) - break - time.sleep(0.1) - tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) - while not tdSql.queryResult: - time.sleep(0.1) - tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) - status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) - tdLog.info(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) - count += 1 - - tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) - while not tdSql.queryResult: - time.sleep(0.1) - tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) - status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) - count = 0 - while not status_OK : - if count > self.try_check_times: - os.system("taos -s ' show {}.vgroups;'".format(dbname)) - tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname)) - break - time.sleep(0.1) - tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) - while not tdSql.queryResult: - time.sleep(0.1) - tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) - status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) - tdLog.info(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) - count += 1 def _get_stop_dnode_id(self,dbname): newTdSql=tdCom.newTdSql() newTdSql.query("show {}.vgroups".format(dbname)) @@ -339,8 +213,8 @@ class TDTestCase: while status !="offline": time.sleep(0.1) status = _get_status() - # tdLog.info("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) - tdLog.info("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) def wait_start_dnode_OK(self): @@ -361,8 +235,8 @@ class TDTestCase: while status !="ready": time.sleep(0.1) status = _get_status() - # tdLog.info("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) - tdLog.info("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) def get_leader_infos(self ,dbname): @@ -389,166 +263,96 @@ class TDTestCase: if role==self.stop_dnode_id: if vgroup_info[ind+1] =="offline" and "leader" in vgroup_info: - tdLog.info(" === revote leader ok , leader is {} now ====".format(vgroup_info[list(vgroup_info).index("leader")-1])) + tdLog.notice(" === revote leader ok , leader is {} now ====".format(vgroup_info[list(vgroup_info).index("leader")-1])) check_status = True elif vgroup_info[ind+1] !="offline": - tdLog.info(" === dnode {} should be offline ".format(self.stop_dnode_id)) + tdLog.notice(" === dnode {} should be offline ".format(self.stop_dnode_id)) else: continue break return check_status - def sync_run_case(self): + def start_benchmark_inserts(self,dbname , json_file): + benchmark_build_path = self.getBuildPath() + '/build/bin/taosBenchmark' + tdLog.notice("==== start taosBenchmark insert datas of database {} ==== ".format(dbname)) + os.system(" {} -f {} >>/dev/null 2>&1 ".format(benchmark_build_path , json_file)) + + def stop_leader_when_Benchmark_inserts(self,dbname , total_rows , json_file ): # stop follower and insert datas , update tables and create new stables tdDnodes=cluster.dnodes - for loop in range(self.loop_restart_times): - db_name = "sync_db_{}".format(loop) - stablename = 'stable_{}'.format(loop) - self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1) - self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 ) - self.stop_dnode_id = self._get_stop_dnode_id(db_name) - - # check rows of datas - - self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0) - - # get leader info before stop - before_leader_infos = self.get_leader_infos(db_name) - - # begin stop dnode - - tdDnodes[self.stop_dnode_id-1].stoptaosd() - - self.wait_stop_dnode_OK() - - # vote leaders check - - # get leader info after stop - after_leader_infos = self.get_leader_infos(db_name) - - revote_status = self.check_revote_leader_success(db_name ,before_leader_infos , after_leader_infos) - - # append rows of stablename when dnode stop make sure revote leaders - - while not revote_status: - after_leader_infos = self.get_leader_infos(db_name) - revote_status = self.check_revote_leader_success(db_name ,before_leader_infos , after_leader_infos) - - - if revote_status: - tbname = "sub_{}_{}".format(stablename , 0) - tdLog.info(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) - self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) - tdLog.info(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) - self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=100) - - # create new stables - tdLog.info(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) - self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb1' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) - self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - else: - tdLog.info("===== leader of database {} is not ok , append rows fail =====".format(db_name)) - - # begin start dnode - start = time.time() - tdDnodes[self.stop_dnode_id-1].starttaosd() - self.wait_start_dnode_OK() - end = time.time() - time_cost = int(end -start) - if time_cost > self.max_restart_time: - tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) - - # create new stables again - tdLog.info(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) - self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) - self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - - def unsync_run_case(self): - - def _restart_dnode_of_db_unsync(dbname): - - tdDnodes=cluster.dnodes - self.stop_dnode_id = self._get_stop_dnode_id(dbname) - # begin restart dnode - - tdDnodes[self.stop_dnode_id-1].stoptaosd() - - tbname = "sub_{}_{}".format(stablename , 0) - tdLog.info(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) - self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) - tdLog.info(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) - self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=100) - - # create new stables - tdLog.info(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) - self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb1' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) - self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - - # create new stables again - tdLog.info(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) - self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) - self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) - - # # get leader info before stop - # before_leader_infos = self.get_leader_infos(db_name) - # self.wait_stop_dnode_OK() - - # check revote leader when restart servers - # # get leader info after stop - # after_leader_infos = self.get_leader_infos(db_name) - # revote_status = self.check_revote_leader_success(db_name ,before_leader_infos , after_leader_infos) - # # append rows of stablename when dnode stop make sure revote leaders - # while not revote_status: - # after_leader_infos = self.get_leader_infos(db_name) - # revote_status = self.check_revote_leader_success(db_name ,before_leader_infos , after_leader_infos) - tdDnodes[self.stop_dnode_id-1].starttaosd() - start = time.time() - self.wait_start_dnode_OK() - end = time.time() - time_cost = int(end-start) - - if time_cost > self.max_restart_time: - tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) - - - def _create_threading(dbname): - self.current_thread = threading.Thread(target=_restart_dnode_of_db_unsync, args=(dbname,)) - return self.current_thread - - - ''' - in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive - ''' - for loop in range(self.loop_restart_times): - db_name = "unsync_db_{}".format(loop) - stablename = 'stable_{}'.format(loop) - self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1) - self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 ) - - tdLog.info(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) - - # create sync threading and start it - self.current_thread = _create_threading(db_name) - self.current_thread.start() - - # check rows of datas - self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0) - - - self.current_thread.join() + tdSql.execute(" drop database if exists {} ".format(dbname)) + tdSql.execute(" create database {} replica {} vgroups {}".format(dbname , self.replica , self.vgroups)) + + # start insert datas using taosBenchmark ,expect insert 10000 rows + + self.current_thread = threading.Thread(target=self.start_benchmark_inserts, args=(dbname,json_file)) + self.current_thread.start() + tdSql.query(" show databases ") + + # make sure create database ok + while (tdSql.queryRows!=3): + time.sleep(0.5) + tdSql.query(" show databases ") + + # # make sure create stable ok + tdSql.query(" show {}.stables ".format(dbname)) + while (tdSql.queryRows!=1): + time.sleep(0.5) + tdSql.query(" show {}.stables ".format(dbname)) + + # stop leader of database when insert 10% rows + # os.system("taos -s 'show databases';") + tdSql.query(" select count(*) from {}.{} ".format(dbname,"stb1")) + + while not tdSql.queryResult: + tdSql.query(" select count(*) from {}.{} ".format(dbname,"stb1")) + tdLog.debug(" === current insert {} rows in database {} === ".format(tdSql.queryResult[0][0] , dbname)) + + while (tdSql.queryResult[0][0] < total_rows/10): + if tdSql.queryResult: + tdLog.debug(" === current insert {} rows in database {} === ".format(tdSql.queryResult[0][0] , dbname)) + time.sleep(0.01) + tdSql.query(" select count(*) from {}.{} ".format(dbname,"stb1")) + + tdLog.debug(" === database {} has write {} rows at least ====".format(dbname,total_rows/10)) + + self.stop_dnode_id = self._get_stop_dnode_id(dbname) + + # prepare stop leader of database + before_leader_infos = self.get_leader_infos(dbname) + + tdDnodes[self.stop_dnode_id-1].stoptaosd() + # self.current_thread.join() + after_leader_infos = self.get_leader_infos(dbname) + + start = time.time() + revote_status = self.check_revote_leader_success(dbname ,before_leader_infos , after_leader_infos) + while not revote_status: + after_leader_infos = self.get_leader_infos(dbname) + revote_status = self.check_revote_leader_success(dbname ,before_leader_infos , after_leader_infos) + end = time.time() + time_cost = end - start + tdLog.debug(" ==== revote leader of database {} cost time {} ====".format(dbname , time_cost)) + + self.current_thread.join() + + tdDnodes[self.stop_dnode_id-1].starttaosd() + self.wait_start_dnode_OK() + + tdSql.query(" select count(*) from {}.{} ".format(dbname,"stb1")) + tdLog.debug(" ==== expected insert {} rows of database {} , really is {}".format(total_rows, dbname , tdSql.queryResult[0][0])) + def run(self): # basic insert and check of cluster - self.check_setup_cluster_status() - self.create_db_check_vgroups() - self.sync_run_case() - # self.unsync_run_case() + # self.check_setup_cluster_status() + json = os.path.dirname(__file__) + '/insert_10W_rows.json' + self.stop_leader_when_Benchmark_inserts('db_1' , 100000 ,json) + # tdLog.notice( " ===== start insert 100W rows ==== ") + # json = os.path.dirname(__file__) + '/insert_100W_rows.json' + # self.stop_leader_when_Benchmark_inserts('db_2' , 1000000 ,json) def stop(self): tdSql.close() diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py index d6edfda770f52b2de23e0f5904465889fc87cec6..c19a308f1c78a0dbf3036bc752a4ccb160dc43ea 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py @@ -114,9 +114,9 @@ class TDTestCase: elif isinstance(data, str): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % (sql, row, col, tdSql.queryResult[row][col], data)) - elif isinstance(data, datetime.date): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (sql, row, col, tdSql.queryResult[row][col], data)) + # elif isinstance(data, datetime.date): + # tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + # (sql, row, col, tdSql.queryResult[row][col], data)) elif isinstance(data, float): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % (sql, row, col, tdSql.queryResult[row][col], data)) @@ -163,14 +163,14 @@ class TDTestCase: is_leader=True if count==1 and is_leader: - tdLog.info("===== depoly cluster success with 1 mnode as leader =====") + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") else: tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") for k ,v in self.dnode_list.items(): if k == mnode_name: if v[3]==0: - tdLog.info("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: @@ -213,7 +213,7 @@ class TDTestCase: for k , v in vgroups_infos.items(): if len(v) ==1 and v[0]=="leader": - tdLog.info(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) @@ -221,7 +221,7 @@ class TDTestCase: drop_db_sql = "drop database if exists {}".format(dbname) create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) - tdLog.info(" ==== create database {} and insert rows begin =====".format(dbname)) + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) tdSql.execute(drop_db_sql) tdSql.execute(create_db_sql) tdSql.execute("use {}".format(dbname)) @@ -244,7 +244,7 @@ class TDTestCase: ts = self.ts + self.ts_step*row_num tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") - tdLog.info(" ==== stable {} insert rows execute end =====".format(stablename)) + tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): @@ -253,7 +253,7 @@ class TDTestCase: for row_num in range(append_nums): tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") - tdLog.info(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) + tdLog.notice(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): @@ -280,7 +280,7 @@ class TDTestCase: time.sleep(0.1) tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) - tdLog.info(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) + tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {} ====".format(count , dbname)) count += 1 @@ -301,7 +301,7 @@ class TDTestCase: time.sleep(0.1) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) - tdLog.info(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) + tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) count += 1 def _get_stop_dnode_id(self,dbname): @@ -340,8 +340,8 @@ class TDTestCase: while status !="offline": time.sleep(0.1) status = _get_status() - # tdLog.info("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) - tdLog.info("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) def wait_start_dnode_OK(self): @@ -362,8 +362,8 @@ class TDTestCase: while status !="ready": time.sleep(0.1) status = _get_status() - # tdLog.info("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) - tdLog.info("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) def get_leader_infos(self ,dbname): @@ -390,10 +390,10 @@ class TDTestCase: if role==self.stop_dnode_id: if vgroup_info[ind+1] =="offline" and "leader" in vgroup_info: - tdLog.info(" === revote leader ok , leader is {} now ====".format(vgroup_info[list(vgroup_info).index("leader")-1])) + tdLog.notice(" === revote leader ok , leader is {} now ====".format(vgroup_info[list(vgroup_info).index("leader")-1])) check_status = True elif vgroup_info[ind+1] !="offline": - tdLog.info(" === dnode {} should be offline ".format(self.stop_dnode_id)) + tdLog.notice(" === dnode {} should be offline ".format(self.stop_dnode_id)) else: continue break @@ -410,7 +410,7 @@ class TDTestCase: else: continue if port: - tdLog.info(" ==== dnode {} will be force stop by kill -9 ====".format(dnode_id)) + tdLog.notice(" ==== dnode {} will be force stop by kill -9 ====".format(dnode_id)) psCmd = '''netstat -anp|grep -w LISTEN|grep -w %s |grep -o "LISTEN.*"|awk '{print $2}'|cut -d/ -f1|head -n1''' %(port) processID = subprocess.check_output( psCmd, shell=True).decode("utf-8") @@ -457,18 +457,18 @@ class TDTestCase: if revote_status: tbname = "sub_{}_{}".format(stablename , 0) - tdLog.info(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) - tdLog.info(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=100) # create new stables - tdLog.info(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb1' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) else: - tdLog.info("===== leader of database {} is not ok , append rows fail =====".format(db_name)) + tdLog.notice("===== leader of database {} is not ok , append rows fail =====".format(db_name)) # begin start dnode start = time.time() @@ -480,9 +480,9 @@ class TDTestCase: tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) # create new stables again - tdLog.info(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) def unsync_run_case(self): @@ -509,21 +509,21 @@ class TDTestCase: revote_status = self.check_revote_leader_success(db_name ,before_leader_infos , after_leader_infos) tbname = "sub_{}_{}".format(stablename , 0) - tdLog.info(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) - tdLog.info(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) + tdLog.notice(" ==== check append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=100) # create new stables - tdLog.info(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb1' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) # create new stables again - tdLog.info(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) + tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) @@ -551,7 +551,7 @@ class TDTestCase: self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 ) - tdLog.info(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) + tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) # create sync threading and start it self.current_thread = _create_threading(db_name) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower.py new file mode 100644 index 0000000000000000000000000000000000000000..2bfe5447494d8f5fa72004d5442e4eae4fd6309d --- /dev/null +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower.py @@ -0,0 +1,416 @@ +# author : wenzhouwww +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * + +import datetime +import inspect +import time +import socket +import subprocess +import threading +sys.path.append(os.path.dirname(__file__)) + +class TDTestCase: + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + self.mnode_list = {} + self.dnode_list = {} + self.ts = 1483200000000 + self.ts_step =1000 + self.db_name ='testdb' + self.replica = 3 + self.vgroups = 1 + self.tb_nums = 10 + self.row_nums = 100 + self.stop_dnode_id = None + self.loop_restart_times = 5 + self.thread_list = [] + self.max_restart_time = 10 + self.try_check_times = 10 + self.query_times = 100 + + + 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): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def check_setup_cluster_status(self): + tdSql.query("show mnodes") + for mnode in tdSql.queryResult: + name = mnode[1] + info = mnode + self.mnode_list[name] = info + + tdSql.query("show dnodes") + for dnode in tdSql.queryResult: + name = dnode[1] + info = dnode + self.dnode_list[name] = info + + count = 0 + is_leader = False + mnode_name = '' + for k,v in self.mnode_list.items(): + count +=1 + # only for 1 mnode + mnode_name = k + + if v[2] =='leader': + is_leader=True + + if count==1 and is_leader: + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") + else: + tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") + + for k ,v in self.dnode_list.items(): + if k == mnode_name: + if v[3]==0: + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + continue + + def create_database(self, dbname, replica_num ,vgroup_nums ): + drop_db_sql = "drop database if exists {}".format(dbname) + create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) + + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) + tdSql.execute(drop_db_sql) + tdSql.execute(create_db_sql) + tdSql.execute("use {}".format(dbname)) + + def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): + tdSql.execute("use {}".format(dbname)) + tdSql.execute( + '''create table {} + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + tags (t1 int) + '''.format(stablename) + ) + + for i in range(tb_nums): + sub_tbname = "sub_{}_{}".format(stablename,i) + tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) + # insert datas about new database + + for row_num in range(row_nums): + ts = self.ts + self.ts_step*row_num + tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + + tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) + + def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): + + tdSql.execute("use {}".format(dbname)) + + for row_num in range(append_nums): + tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + tdLog.notice(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) + os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) + + def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): + + tdSql.execute("use {}".format(dbname)) + + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + + status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) + + count = 0 + while not status_OK : + if count > self.try_check_times: + os.system("taos -s ' show {}.vgroups; '".format(dbname)) + tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname)) + break + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) + tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) + count += 1 + + + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) + count = 0 + while not status_OK : + if count > self.try_check_times: + os.system("taos -s ' show {}.vgroups;'".format(dbname)) + tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname)) + break + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) + tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) + count += 1 + + def _get_stop_dnode_id(self,dbname): + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + leader_infos = vgroup_info[3:-4] + # print(vgroup_info) + for ind ,role in enumerate(leader_infos): + if role =='follower': + # print(ind,leader_infos) + self.stop_dnode_id = leader_infos[ind-1] + break + + + return self.stop_dnode_id + + def wait_stop_dnode_OK(self): + + def _get_status(): + newTdSql=tdCom.newTdSql() + + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="offline": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) + + def wait_start_dnode_OK(self): + + def _get_status(): + newTdSql=tdCom.newTdSql() + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="ready": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) + + def _parse_datetime(self,timestr): + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S.%f') + except ValueError: + pass + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S') + except ValueError: + pass + + def mycheckRowCol(self, sql, row, col): + caller = inspect.getframeinfo(inspect.stack()[2][0]) + if row < 0: + args = (caller.filename, caller.lineno, sql, row) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is smaller than zero" % args) + if col < 0: + args = (caller.filename, caller.lineno, sql, row) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is smaller than zero" % args) + if row > tdSql.queryRows: + args = (caller.filename, caller.lineno, sql, row, tdSql.queryRows) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args) + if col > tdSql.queryCols: + args = (caller.filename, caller.lineno, sql, col, tdSql.queryCols) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args) + + def mycheckData(self, sql ,row, col, data): + check_status = True + self.mycheckRowCol(sql ,row, col) + if tdSql.queryResult[row][col] != data: + if tdSql.cursor.istype(col, "TIMESTAMP"): + # suppose user want to check nanosecond timestamp if a longer data passed + if (len(data) >= 28): + if pd.to_datetime(tdSql.queryResult[row][col]) == pd.to_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + else: + if tdSql.queryResult[row][col] == self._parse_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + + if str(tdSql.queryResult[row][col]) == str(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + elif isinstance(data, float) and abs(tdSql.queryResult[row][col] - data) <= 0.000001: + tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, row, col, tdSql.queryResult[row][col], data) + tdLog.info("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + + check_status = False + + if data is None: + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + elif isinstance(data, str): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + # elif isinstance(data, datetime.date): + # tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + # (sql, row, col, tdSql.queryResult[row][col], data)) + elif isinstance(data, float): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + else: + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%d" % + (sql, row, col, tdSql.queryResult[row][col], data)) + + return check_status + + def mycheckRows(self, sql, expectRows): + check_status = True + if len(tdSql.queryResult) == expectRows: + tdLog.info("sql:%s, queryRows:%d == expect:%d" % (sql, len(tdSql.queryResult), expectRows)) + return True + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, len(tdSql.queryResult), expectRows) + tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) + check_status = False + return check_status + + + def force_stop_dnode(self, dnode_id ): + + tdSql.query("show dnodes") + port = None + for dnode_info in tdSql.queryResult: + if dnode_id == dnode_info[0]: + port = dnode_info[1].split(":")[-1] + break + else: + continue + if port: + tdLog.notice(" ==== dnode {} will be force stop by kill -9 ====".format(dnode_id)) + psCmd = '''netstat -anp|grep -w LISTEN|grep -w %s |grep -o "LISTEN.*"|awk '{print $2}'|cut -d/ -f1|head -n1''' %(port) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + ps_kill_taosd = ''' kill -9 {} '''.format(processID) + # print(ps_kill_taosd) + os.system(ps_kill_taosd) + + def basic_query_task(self,dbname ,stablename): + + sql = "select * from {}.{} ;".format(dbname , stablename) + + count = 0 + while count < self.query_times: + os.system(''' taos -s '{}' >>/dev/null '''.format(sql)) + count += 1 + + def multi_thread_query_task(self, thread_nums ,dbname , stablename ): + + for i in range(thread_nums): + task = threading.Thread(target = self.basic_query_task, args=(dbname ,stablename)) + self.thread_list.append(task) + + for thread in self.thread_list: + + thread.start() + return self.thread_list + + + def stop_follower_when_query_going(self): + + tdDnodes = cluster.dnodes + self.create_database(dbname = self.db_name ,replica_num= self.replica , vgroup_nums= 1) + self.create_stable_insert_datas(dbname = self.db_name , stablename = "stb1" , tb_nums= self.tb_nums ,row_nums= self.row_nums) + + # let query task start + self.thread_list = self.multi_thread_query_task(10 ,self.db_name ,'stb1' ) + + # force stop follower + for loop in range(self.loop_restart_times): + tdLog.debug(" ==== this is {}_th restart follower of database {} ==== ".format(loop ,self.db_name)) + self.stop_dnode_id = self._get_stop_dnode_id(self.db_name) + tdDnodes[self.stop_dnode_id-1].stoptaosd() + self.wait_stop_dnode_OK() + + start = time.time() + tdDnodes[self.stop_dnode_id-1].starttaosd() + self.wait_start_dnode_OK() + end = time.time() + time_cost = int(end-start) + + if time_cost > self.max_restart_time: + tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) + + for thread in self.thread_list: + thread.join() + + + def run(self): + + # basic check of cluster + self.check_setup_cluster_status() + self.stop_follower_when_query_going() + + + + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower_force_stop.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower_force_stop.py new file mode 100644 index 0000000000000000000000000000000000000000..2a4e43d904f1ca6b3627e12d84094270b99f9259 --- /dev/null +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower_force_stop.py @@ -0,0 +1,416 @@ +# author : wenzhouwww +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * + +import datetime +import inspect +import time +import socket +import subprocess +import threading +sys.path.append(os.path.dirname(__file__)) + +class TDTestCase: + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + self.mnode_list = {} + self.dnode_list = {} + self.ts = 1483200000000 + self.ts_step =1000 + self.db_name ='testdb' + self.replica = 3 + self.vgroups = 1 + self.tb_nums = 10 + self.row_nums = 100 + self.stop_dnode_id = None + self.loop_restart_times = 5 + self.thread_list = [] + self.max_restart_time = 10 + self.try_check_times = 10 + self.query_times = 100 + + + 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): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def check_setup_cluster_status(self): + tdSql.query("show mnodes") + for mnode in tdSql.queryResult: + name = mnode[1] + info = mnode + self.mnode_list[name] = info + + tdSql.query("show dnodes") + for dnode in tdSql.queryResult: + name = dnode[1] + info = dnode + self.dnode_list[name] = info + + count = 0 + is_leader = False + mnode_name = '' + for k,v in self.mnode_list.items(): + count +=1 + # only for 1 mnode + mnode_name = k + + if v[2] =='leader': + is_leader=True + + if count==1 and is_leader: + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") + else: + tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") + + for k ,v in self.dnode_list.items(): + if k == mnode_name: + if v[3]==0: + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + continue + + def create_database(self, dbname, replica_num ,vgroup_nums ): + drop_db_sql = "drop database if exists {}".format(dbname) + create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) + + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) + tdSql.execute(drop_db_sql) + tdSql.execute(create_db_sql) + tdSql.execute("use {}".format(dbname)) + + def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): + tdSql.execute("use {}".format(dbname)) + tdSql.execute( + '''create table {} + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + tags (t1 int) + '''.format(stablename) + ) + + for i in range(tb_nums): + sub_tbname = "sub_{}_{}".format(stablename,i) + tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) + # insert datas about new database + + for row_num in range(row_nums): + ts = self.ts + self.ts_step*row_num + tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + + tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) + + def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): + + tdSql.execute("use {}".format(dbname)) + + for row_num in range(append_nums): + tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + tdLog.notice(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) + os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) + + def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): + + tdSql.execute("use {}".format(dbname)) + + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + + status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) + + count = 0 + while not status_OK : + if count > self.try_check_times: + os.system("taos -s ' show {}.vgroups; '".format(dbname)) + tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname)) + break + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) + tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) + count += 1 + + + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) + count = 0 + while not status_OK : + if count > self.try_check_times: + os.system("taos -s ' show {}.vgroups;'".format(dbname)) + tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname)) + break + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) + tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) + count += 1 + + def _get_stop_dnode_id(self,dbname): + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + leader_infos = vgroup_info[3:-4] + # print(vgroup_info) + for ind ,role in enumerate(leader_infos): + if role =='follower': + # print(ind,leader_infos) + self.stop_dnode_id = leader_infos[ind-1] + break + + + return self.stop_dnode_id + + def wait_stop_dnode_OK(self): + + def _get_status(): + newTdSql=tdCom.newTdSql() + + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="offline": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) + + def wait_start_dnode_OK(self): + + def _get_status(): + newTdSql=tdCom.newTdSql() + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="ready": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) + + def _parse_datetime(self,timestr): + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S.%f') + except ValueError: + pass + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S') + except ValueError: + pass + + def mycheckRowCol(self, sql, row, col): + caller = inspect.getframeinfo(inspect.stack()[2][0]) + if row < 0: + args = (caller.filename, caller.lineno, sql, row) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is smaller than zero" % args) + if col < 0: + args = (caller.filename, caller.lineno, sql, row) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is smaller than zero" % args) + if row > tdSql.queryRows: + args = (caller.filename, caller.lineno, sql, row, tdSql.queryRows) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args) + if col > tdSql.queryCols: + args = (caller.filename, caller.lineno, sql, col, tdSql.queryCols) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args) + + def mycheckData(self, sql ,row, col, data): + check_status = True + self.mycheckRowCol(sql ,row, col) + if tdSql.queryResult[row][col] != data: + if tdSql.cursor.istype(col, "TIMESTAMP"): + # suppose user want to check nanosecond timestamp if a longer data passed + if (len(data) >= 28): + if pd.to_datetime(tdSql.queryResult[row][col]) == pd.to_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + else: + if tdSql.queryResult[row][col] == self._parse_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + + if str(tdSql.queryResult[row][col]) == str(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + elif isinstance(data, float) and abs(tdSql.queryResult[row][col] - data) <= 0.000001: + tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, row, col, tdSql.queryResult[row][col], data) + tdLog.info("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + + check_status = False + + if data is None: + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + elif isinstance(data, str): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + # elif isinstance(data, datetime.date): + # tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + # (sql, row, col, tdSql.queryResult[row][col], data)) + elif isinstance(data, float): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + else: + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%d" % + (sql, row, col, tdSql.queryResult[row][col], data)) + + return check_status + + def mycheckRows(self, sql, expectRows): + check_status = True + if len(tdSql.queryResult) == expectRows: + tdLog.info("sql:%s, queryRows:%d == expect:%d" % (sql, len(tdSql.queryResult), expectRows)) + return True + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, len(tdSql.queryResult), expectRows) + tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) + check_status = False + return check_status + + + def force_stop_dnode(self, dnode_id ): + + tdSql.query("show dnodes") + port = None + for dnode_info in tdSql.queryResult: + if dnode_id == dnode_info[0]: + port = dnode_info[1].split(":")[-1] + break + else: + continue + if port: + tdLog.notice(" ==== dnode {} will be force stop by kill -9 ====".format(dnode_id)) + psCmd = '''netstat -anp|grep -w LISTEN|grep -w %s |grep -o "LISTEN.*"|awk '{print $2}'|cut -d/ -f1|head -n1''' %(port) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + ps_kill_taosd = ''' kill -9 {} '''.format(processID) + # print(ps_kill_taosd) + os.system(ps_kill_taosd) + + def basic_query_task(self,dbname ,stablename): + + sql = "select * from {}.{} ;".format(dbname , stablename) + + count = 0 + while count < self.query_times: + os.system(''' taos -s '{}' >>/dev/null '''.format(sql)) + count += 1 + + def multi_thread_query_task(self, thread_nums ,dbname , stablename ): + + for i in range(thread_nums): + task = threading.Thread(target = self.basic_query_task, args=(dbname ,stablename)) + self.thread_list.append(task) + + for thread in self.thread_list: + + thread.start() + return self.thread_list + + + def stop_follower_when_query_going(self): + + tdDnodes = cluster.dnodes + self.create_database(dbname = self.db_name ,replica_num= self.replica , vgroup_nums= 1) + self.create_stable_insert_datas(dbname = self.db_name , stablename = "stb1" , tb_nums= self.tb_nums ,row_nums= self.row_nums) + + # let query task start + self.thread_list = self.multi_thread_query_task(10 ,self.db_name ,'stb1' ) + + # force stop follower + for loop in range(self.loop_restart_times): + tdLog.debug(" ==== this is {}_th restart follower of database {} ==== ".format(loop ,self.db_name)) + self.stop_dnode_id = self._get_stop_dnode_id(self.db_name) + self.force_stop_dnode(self.stop_dnode_id) + self.wait_stop_dnode_OK() + + start = time.time() + tdDnodes[self.stop_dnode_id-1].starttaosd() + self.wait_start_dnode_OK() + end = time.time() + time_cost = int(end-start) + + if time_cost > self.max_restart_time: + tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) + + for thread in self.thread_list: + thread.join() + + + def run(self): + + # basic check of cluster + self.check_setup_cluster_status() + self.stop_follower_when_query_going() + + + + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader.py new file mode 100644 index 0000000000000000000000000000000000000000..41606946f6e8b537b5273894c7c791891131e828 --- /dev/null +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader.py @@ -0,0 +1,470 @@ +# author : wenzhouwww +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * + +import datetime +import inspect +import time +import socket +import subprocess +import threading +sys.path.append(os.path.dirname(__file__)) + +class TDTestCase: + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + self.mnode_list = {} + self.dnode_list = {} + self.ts = 1483200000000 + self.ts_step =1000 + self.db_name ='testdb' + self.replica = 3 + self.vgroups = 1 + self.tb_nums = 10 + self.row_nums = 100 + self.stop_dnode_id = None + self.loop_restart_times = 5 + self.thread_list = [] + self.max_restart_time = 10 + self.try_check_times = 10 + self.query_times = 100 + + + 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): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def check_setup_cluster_status(self): + tdSql.query("show mnodes") + for mnode in tdSql.queryResult: + name = mnode[1] + info = mnode + self.mnode_list[name] = info + + tdSql.query("show dnodes") + for dnode in tdSql.queryResult: + name = dnode[1] + info = dnode + self.dnode_list[name] = info + + count = 0 + is_leader = False + mnode_name = '' + for k,v in self.mnode_list.items(): + count +=1 + # only for 1 mnode + mnode_name = k + + if v[2] =='leader': + is_leader=True + + if count==1 and is_leader: + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") + else: + tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") + + for k ,v in self.dnode_list.items(): + if k == mnode_name: + if v[3]==0: + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + continue + + def create_database(self, dbname, replica_num ,vgroup_nums ): + drop_db_sql = "drop database if exists {}".format(dbname) + create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) + + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) + tdSql.execute(drop_db_sql) + tdSql.execute(create_db_sql) + tdSql.execute("use {}".format(dbname)) + + def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): + tdSql.execute("use {}".format(dbname)) + tdSql.execute( + '''create table {} + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + tags (t1 int) + '''.format(stablename) + ) + + for i in range(tb_nums): + sub_tbname = "sub_{}_{}".format(stablename,i) + tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) + # insert datas about new database + + for row_num in range(row_nums): + ts = self.ts + self.ts_step*row_num + tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + + tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) + + def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): + + tdSql.execute("use {}".format(dbname)) + + for row_num in range(append_nums): + tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + tdLog.notice(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) + os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) + + def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): + + tdSql.execute("use {}".format(dbname)) + + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + + status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) + + count = 0 + while not status_OK : + if count > self.try_check_times: + os.system("taos -s ' show {}.vgroups; '".format(dbname)) + tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname)) + break + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) + tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) + count += 1 + + + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) + count = 0 + while not status_OK : + if count > self.try_check_times: + os.system("taos -s ' show {}.vgroups;'".format(dbname)) + tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname)) + break + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) + tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) + count += 1 + + def _get_stop_dnode_id(self,dbname): + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + leader_infos = vgroup_info[3:-4] + # print(vgroup_info) + for ind ,role in enumerate(leader_infos): + if role =='leader': + # print(ind,leader_infos) + self.stop_dnode_id = leader_infos[ind-1] + break + + + return self.stop_dnode_id + + def wait_stop_dnode_OK(self): + + def _get_status(): + newTdSql=tdCom.newTdSql() + + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="offline": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) + + def check_revote_leader_success(self, dbname, before_leader_infos , after_leader_infos): + check_status = False + vote_act = set(set(after_leader_infos)-set(before_leader_infos)) + if not vote_act: + print("=======before_revote_leader_infos ======\n" , before_leader_infos) + print("=======after_revote_leader_infos ======\n" , after_leader_infos) + tdLog.info(" ===maybe revote not occured , there is no dnode offline ====") + else: + for vgroup_info in vote_act: + for ind , role in enumerate(vgroup_info): + if role==self.stop_dnode_id: + + if vgroup_info[ind+1] =="offline" and "leader" in vgroup_info: + tdLog.notice(" === revote leader ok , leader is {} now ====".format(vgroup_info[list(vgroup_info).index("leader")-1])) + check_status = True + elif vgroup_info[ind+1] !="offline": + tdLog.notice(" === dnode {} should be offline ".format(self.stop_dnode_id)) + else: + continue + break + return check_status + + def wait_start_dnode_OK(self): + + def _get_status(): + newTdSql=tdCom.newTdSql() + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="ready": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) + + def _parse_datetime(self,timestr): + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S.%f') + except ValueError: + pass + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S') + except ValueError: + pass + + def mycheckRowCol(self, sql, row, col): + caller = inspect.getframeinfo(inspect.stack()[2][0]) + if row < 0: + args = (caller.filename, caller.lineno, sql, row) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is smaller than zero" % args) + if col < 0: + args = (caller.filename, caller.lineno, sql, row) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is smaller than zero" % args) + if row > tdSql.queryRows: + args = (caller.filename, caller.lineno, sql, row, tdSql.queryRows) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args) + if col > tdSql.queryCols: + args = (caller.filename, caller.lineno, sql, col, tdSql.queryCols) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args) + + def mycheckData(self, sql ,row, col, data): + check_status = True + self.mycheckRowCol(sql ,row, col) + if tdSql.queryResult[row][col] != data: + if tdSql.cursor.istype(col, "TIMESTAMP"): + # suppose user want to check nanosecond timestamp if a longer data passed + if (len(data) >= 28): + if pd.to_datetime(tdSql.queryResult[row][col]) == pd.to_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + else: + if tdSql.queryResult[row][col] == self._parse_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + + if str(tdSql.queryResult[row][col]) == str(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + elif isinstance(data, float) and abs(tdSql.queryResult[row][col] - data) <= 0.000001: + tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, row, col, tdSql.queryResult[row][col], data) + tdLog.info("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + + check_status = False + + if data is None: + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + elif isinstance(data, str): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + # elif isinstance(data, datetime.date): + # tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + # (sql, row, col, tdSql.queryResult[row][col], data)) + elif isinstance(data, float): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + else: + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%d" % + (sql, row, col, tdSql.queryResult[row][col], data)) + + return check_status + + def mycheckRows(self, sql, expectRows): + check_status = True + if len(tdSql.queryResult) == expectRows: + tdLog.info("sql:%s, queryRows:%d == expect:%d" % (sql, len(tdSql.queryResult), expectRows)) + return True + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, len(tdSql.queryResult), expectRows) + tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) + check_status = False + return check_status + + + def get_leader_infos(self ,dbname): + + newTdSql=tdCom.newTdSql() + newTdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = newTdSql.queryResult + + leader_infos = set() + for vgroup_info in vgroup_infos: + leader_infos.add(vgroup_info[3:-4]) + + return leader_infos + + def force_stop_dnode(self, dnode_id ): + + tdSql.query("show dnodes") + port = None + for dnode_info in tdSql.queryResult: + if dnode_id == dnode_info[0]: + port = dnode_info[1].split(":")[-1] + break + else: + continue + if port: + tdLog.notice(" ==== dnode {} will be force stop by kill -9 ====".format(dnode_id)) + psCmd = '''netstat -anp|grep -w LISTEN|grep -w %s |grep -o "LISTEN.*"|awk '{print $2}'|cut -d/ -f1|head -n1''' %(port) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + ps_kill_taosd = ''' kill -9 {} '''.format(processID) + # print(ps_kill_taosd) + os.system(ps_kill_taosd) + + def basic_query_task(self,dbname ,stablename): + + sql = "select * from {}.{} ;".format(dbname , stablename) + + count = 0 + while count < self.query_times: + os.system(''' taos -s '{}' >>/dev/null '''.format(sql)) + count += 1 + + def multi_thread_query_task(self, thread_nums ,dbname , stablename ): + + for i in range(thread_nums): + task = threading.Thread(target = self.basic_query_task, args=(dbname ,stablename)) + self.thread_list.append(task) + + for thread in self.thread_list: + + thread.start() + return self.thread_list + + + def stop_follower_when_query_going(self): + + tdDnodes = cluster.dnodes + self.create_database(dbname = self.db_name ,replica_num= self.replica , vgroup_nums= 1) + self.create_stable_insert_datas(dbname = self.db_name , stablename = "stb1" , tb_nums= self.tb_nums ,row_nums= self.row_nums) + + # let query task start + self.thread_list = self.multi_thread_query_task(10 ,self.db_name ,'stb1' ) + + # force stop follower + for loop in range(self.loop_restart_times): + tdLog.debug(" ==== this is {}_th restart follower of database {} ==== ".format(loop ,self.db_name)) + + # get leader info before stop + before_leader_infos = self.get_leader_infos(self.db_name) + + self.stop_dnode_id = self._get_stop_dnode_id(self.db_name) + tdDnodes[self.stop_dnode_id-1].stoptaosd() + + + start = time.time() + # get leader info after stop + after_leader_infos = self.get_leader_infos(self.db_name) + + revote_status = self.check_revote_leader_success(self.db_name ,before_leader_infos , after_leader_infos) + + while not revote_status: + after_leader_infos = self.get_leader_infos(self.db_name) + revote_status = self.check_revote_leader_success(self.db_name ,before_leader_infos , after_leader_infos) + + end = time.time() + time_cost = end - start + tdLog.debug(" ==== revote leader of database {} cost time {} ====".format(self.db_name , time_cost)) + + self.wait_stop_dnode_OK() + + start = time.time() + tdDnodes[self.stop_dnode_id-1].starttaosd() + self.wait_start_dnode_OK() + end = time.time() + time_cost = int(end-start) + + if time_cost > self.max_restart_time: + tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) + + for thread in self.thread_list: + thread.join() + + + def run(self): + + # basic check of cluster + self.check_setup_cluster_status() + self.stop_follower_when_query_going() + + + + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader_force_stop.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader_force_stop.py new file mode 100644 index 0000000000000000000000000000000000000000..5ddcf1c70e0b5003d792931099ddab9b8d202dff --- /dev/null +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader_force_stop.py @@ -0,0 +1,470 @@ +# author : wenzhouwww +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * + +import datetime +import inspect +import time +import socket +import subprocess +import threading +sys.path.append(os.path.dirname(__file__)) + +class TDTestCase: + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + self.mnode_list = {} + self.dnode_list = {} + self.ts = 1483200000000 + self.ts_step =1000 + self.db_name ='testdb' + self.replica = 3 + self.vgroups = 1 + self.tb_nums = 10 + self.row_nums = 100 + self.stop_dnode_id = None + self.loop_restart_times = 5 + self.thread_list = [] + self.max_restart_time = 10 + self.try_check_times = 10 + self.query_times = 100 + + + 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): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def check_setup_cluster_status(self): + tdSql.query("show mnodes") + for mnode in tdSql.queryResult: + name = mnode[1] + info = mnode + self.mnode_list[name] = info + + tdSql.query("show dnodes") + for dnode in tdSql.queryResult: + name = dnode[1] + info = dnode + self.dnode_list[name] = info + + count = 0 + is_leader = False + mnode_name = '' + for k,v in self.mnode_list.items(): + count +=1 + # only for 1 mnode + mnode_name = k + + if v[2] =='leader': + is_leader=True + + if count==1 and is_leader: + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") + else: + tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") + + for k ,v in self.dnode_list.items(): + if k == mnode_name: + if v[3]==0: + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) + else: + continue + + def create_database(self, dbname, replica_num ,vgroup_nums ): + drop_db_sql = "drop database if exists {}".format(dbname) + create_db_sql = "create database {} replica {} vgroups {}".format(dbname,replica_num,vgroup_nums) + + tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname)) + tdSql.execute(drop_db_sql) + tdSql.execute(create_db_sql) + tdSql.execute("use {}".format(dbname)) + + def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): + tdSql.execute("use {}".format(dbname)) + tdSql.execute( + '''create table {} + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) + tags (t1 int) + '''.format(stablename) + ) + + for i in range(tb_nums): + sub_tbname = "sub_{}_{}".format(stablename,i) + tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) + # insert datas about new database + + for row_num in range(row_nums): + ts = self.ts + self.ts_step*row_num + tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + + tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) + + def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): + + tdSql.execute("use {}".format(dbname)) + + for row_num in range(append_nums): + tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") + tdLog.notice(" ==== append new rows of table {} belongs to stable {} execute end =====".format(tbname,stablename)) + os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) + + def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): + + tdSql.execute("use {}".format(dbname)) + + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + + status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) + + count = 0 + while not status_OK : + if count > self.try_check_times: + os.system("taos -s ' show {}.vgroups; '".format(dbname)) + tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname)) + break + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) + tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) + count += 1 + + + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) + count = 0 + while not status_OK : + if count > self.try_check_times: + os.system("taos -s ' show {}.vgroups;'".format(dbname)) + tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname)) + break + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + while not tdSql.queryResult: + time.sleep(0.1) + tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) + status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) + tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) + count += 1 + + def _get_stop_dnode_id(self,dbname): + tdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = tdSql.queryResult + for vgroup_info in vgroup_infos: + leader_infos = vgroup_info[3:-4] + # print(vgroup_info) + for ind ,role in enumerate(leader_infos): + if role =='leader': + # print(ind,leader_infos) + self.stop_dnode_id = leader_infos[ind-1] + break + + + return self.stop_dnode_id + + def wait_stop_dnode_OK(self): + + def _get_status(): + newTdSql=tdCom.newTdSql() + + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="offline": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) + + def check_revote_leader_success(self, dbname, before_leader_infos , after_leader_infos): + check_status = False + vote_act = set(set(after_leader_infos)-set(before_leader_infos)) + if not vote_act: + print("=======before_revote_leader_infos ======\n" , before_leader_infos) + print("=======after_revote_leader_infos ======\n" , after_leader_infos) + tdLog.info(" ===maybe revote not occured , there is no dnode offline ====") + else: + for vgroup_info in vote_act: + for ind , role in enumerate(vgroup_info): + if role==self.stop_dnode_id: + + if vgroup_info[ind+1] =="offline" and "leader" in vgroup_info: + tdLog.notice(" === revote leader ok , leader is {} now ====".format(vgroup_info[list(vgroup_info).index("leader")-1])) + check_status = True + elif vgroup_info[ind+1] !="offline": + tdLog.notice(" === dnode {} should be offline ".format(self.stop_dnode_id)) + else: + continue + break + return check_status + + def wait_start_dnode_OK(self): + + def _get_status(): + newTdSql=tdCom.newTdSql() + status = "" + newTdSql.query("show dnodes") + dnode_infos = newTdSql.queryResult + for dnode_info in dnode_infos: + id = dnode_info[0] + dnode_status = dnode_info[4] + if id == self.stop_dnode_id: + status = dnode_status + break + return status + + status = _get_status() + while status !="ready": + time.sleep(0.1) + status = _get_status() + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , id is {}".format(self.stop_dnode_id)) + + def _parse_datetime(self,timestr): + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S.%f') + except ValueError: + pass + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S') + except ValueError: + pass + + def mycheckRowCol(self, sql, row, col): + caller = inspect.getframeinfo(inspect.stack()[2][0]) + if row < 0: + args = (caller.filename, caller.lineno, sql, row) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is smaller than zero" % args) + if col < 0: + args = (caller.filename, caller.lineno, sql, row) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is smaller than zero" % args) + if row > tdSql.queryRows: + args = (caller.filename, caller.lineno, sql, row, tdSql.queryRows) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args) + if col > tdSql.queryCols: + args = (caller.filename, caller.lineno, sql, col, tdSql.queryCols) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args) + + def mycheckData(self, sql ,row, col, data): + check_status = True + self.mycheckRowCol(sql ,row, col) + if tdSql.queryResult[row][col] != data: + if tdSql.cursor.istype(col, "TIMESTAMP"): + # suppose user want to check nanosecond timestamp if a longer data passed + if (len(data) >= 28): + if pd.to_datetime(tdSql.queryResult[row][col]) == pd.to_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + else: + if tdSql.queryResult[row][col] == self._parse_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + + if str(tdSql.queryResult[row][col]) == str(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + elif isinstance(data, float) and abs(tdSql.queryResult[row][col] - data) <= 0.000001: + tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" % + (sql, row, col, tdSql.queryResult[row][col], data)) + return + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, row, col, tdSql.queryResult[row][col], data) + tdLog.info("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + + check_status = False + + if data is None: + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + elif isinstance(data, str): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + # elif isinstance(data, datetime.date): + # tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + # (sql, row, col, tdSql.queryResult[row][col], data)) + elif isinstance(data, float): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (sql, row, col, tdSql.queryResult[row][col], data)) + else: + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%d" % + (sql, row, col, tdSql.queryResult[row][col], data)) + + return check_status + + def mycheckRows(self, sql, expectRows): + check_status = True + if len(tdSql.queryResult) == expectRows: + tdLog.info("sql:%s, queryRows:%d == expect:%d" % (sql, len(tdSql.queryResult), expectRows)) + return True + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, len(tdSql.queryResult), expectRows) + tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) + check_status = False + return check_status + + + def get_leader_infos(self ,dbname): + + newTdSql=tdCom.newTdSql() + newTdSql.query("show {}.vgroups".format(dbname)) + vgroup_infos = newTdSql.queryResult + + leader_infos = set() + for vgroup_info in vgroup_infos: + leader_infos.add(vgroup_info[3:-4]) + + return leader_infos + + def force_stop_dnode(self, dnode_id ): + + tdSql.query("show dnodes") + port = None + for dnode_info in tdSql.queryResult: + if dnode_id == dnode_info[0]: + port = dnode_info[1].split(":")[-1] + break + else: + continue + if port: + tdLog.notice(" ==== dnode {} will be force stop by kill -9 ====".format(dnode_id)) + psCmd = '''netstat -anp|grep -w LISTEN|grep -w %s |grep -o "LISTEN.*"|awk '{print $2}'|cut -d/ -f1|head -n1''' %(port) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + ps_kill_taosd = ''' kill -9 {} '''.format(processID) + # print(ps_kill_taosd) + os.system(ps_kill_taosd) + + def basic_query_task(self,dbname ,stablename): + + sql = "select * from {}.{} ;".format(dbname , stablename) + + count = 0 + while count < self.query_times: + os.system(''' taos -s '{}' >>/dev/null '''.format(sql)) + count += 1 + + def multi_thread_query_task(self, thread_nums ,dbname , stablename ): + + for i in range(thread_nums): + task = threading.Thread(target = self.basic_query_task, args=(dbname ,stablename)) + self.thread_list.append(task) + + for thread in self.thread_list: + + thread.start() + return self.thread_list + + + def stop_follower_when_query_going(self): + + tdDnodes = cluster.dnodes + self.create_database(dbname = self.db_name ,replica_num= self.replica , vgroup_nums= 1) + self.create_stable_insert_datas(dbname = self.db_name , stablename = "stb1" , tb_nums= self.tb_nums ,row_nums= self.row_nums) + + # let query task start + self.thread_list = self.multi_thread_query_task(10 ,self.db_name ,'stb1' ) + + # force stop follower + for loop in range(self.loop_restart_times): + tdLog.debug(" ==== this is {}_th restart follower of database {} ==== ".format(loop ,self.db_name)) + + # get leader info before stop + before_leader_infos = self.get_leader_infos(self.db_name) + + self.stop_dnode_id = self._get_stop_dnode_id(self.db_name) + self.force_stop_dnode(self.stop_dnode_id) + + + start = time.time() + # get leader info after stop + after_leader_infos = self.get_leader_infos(self.db_name) + + revote_status = self.check_revote_leader_success(self.db_name ,before_leader_infos , after_leader_infos) + + while not revote_status: + after_leader_infos = self.get_leader_infos(self.db_name) + revote_status = self.check_revote_leader_success(self.db_name ,before_leader_infos , after_leader_infos) + + end = time.time() + time_cost = end - start + tdLog.debug(" ==== revote leader of database {} cost time {} ====".format(self.db_name , time_cost)) + + self.wait_stop_dnode_OK() + + start = time.time() + tdDnodes[self.stop_dnode_id-1].starttaosd() + self.wait_start_dnode_OK() + end = time.time() + time_cost = int(end-start) + + if time_cost > self.max_restart_time: + tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) + + for thread in self.thread_list: + thread.join() + + + def run(self): + + # basic check of cluster + self.check_setup_cluster_status() + self.stop_follower_when_query_going() + + + + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py index 5529a5e256541b36be376b34d6b20d290618c062..78f6ee153b17fb50a4e0e1074b12f9cea5d14b3d 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py @@ -71,14 +71,14 @@ class TDTestCase: is_leader=True if count==1 and is_leader: - tdLog.info("===== depoly cluster success with 1 mnode as leader =====") + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") else: tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") for k ,v in self.dnode_list.items(): if k == mnode_name: if v[3]==0: - tdLog.info("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: @@ -121,7 +121,7 @@ class TDTestCase: for k , v in vgroups_infos.items(): if len(v) ==1 and v[0]=="leader": - tdLog.info(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) @@ -152,10 +152,10 @@ class TDTestCase: time.sleep(0.1) status = self.check_vgroups_init_done(dbname) - # tdLog.info("=== database {} show vgroups vote the leader is in progress ===".format(dbname)) + # tdLog.notice("=== database {} show vgroups vote the leader is in progress ===".format(dbname)) end = time.time() cost_time = end - start - tdLog.info(" ==== database %s vote the leaders success , cost time is %.3f second ====="%(dbname,cost_time) ) + tdLog.notice(" ==== database %s vote the leaders success , cost time is %.3f second ====="%(dbname,cost_time) ) # os.system("taos -s 'show {}.vgroups;'".format(dbname)) if cost_time >= self.max_vote_time_cost: tdLog.exit(" ==== database %s vote the leaders cost too large time , cost time is %.3f second ===="%(dbname,cost_time) ) @@ -165,28 +165,28 @@ class TDTestCase: def test_init_vgroups_time_costs(self): - tdLog.info(" ====start check time cost about vgroups vote leaders ==== ") - tdLog.info(" ==== current max time cost is set value : {} =======".format(self.max_vote_time_cost)) + tdLog.notice(" ====start check time cost about vgroups vote leaders ==== ") + tdLog.notice(" ==== current max time cost is set value : {} =======".format(self.max_vote_time_cost)) # create database replica 3 vgroups 1 db1 = 'db_1' create_db_replica_3_vgroups_1 = "create database {} replica 3 vgroups 1".format(db1) - tdLog.info('=======database {} replica 3 vgroups 1 ======'.format(db1)) + tdLog.notice('=======database {} replica 3 vgroups 1 ======'.format(db1)) tdSql.execute(create_db_replica_3_vgroups_1) self.vote_leader_time_costs(db1) # create database replica 3 vgroups 10 db2 = 'db_2' create_db_replica_3_vgroups_10 = "create database {} replica 3 vgroups 10".format(db2) - tdLog.info('=======database {} replica 3 vgroups 10 ======'.format(db2)) + tdLog.notice('=======database {} replica 3 vgroups 10 ======'.format(db2)) tdSql.execute(create_db_replica_3_vgroups_10) self.vote_leader_time_costs(db2) # create database replica 3 vgroups 100 db3 = 'db_3' create_db_replica_3_vgroups_100 = "create database {} replica 3 vgroups 100".format(db3) - tdLog.info('=======database {} replica 3 vgroups 100 ======'.format(db3)) + tdLog.notice('=======database {} replica 3 vgroups 100 ======'.format(db3)) tdSql.execute(create_db_replica_3_vgroups_100) self.vote_leader_time_costs(db3) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py index 3be36c067e70487a44cfdbcd1d45bce9bbaf3c70..32ee0a87114cada83107134fd86d8f9584a5ef72 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py @@ -74,14 +74,14 @@ class TDTestCase: is_leader=True if count==1 and is_leader: - tdLog.info("===== depoly cluster success with 1 mnode as leader =====") + tdLog.notice("===== depoly cluster success with 1 mnode as leader =====") else: tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====") for k ,v in self.dnode_list.items(): if k == mnode_name: if v[3]==0: - tdLog.info("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) + tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3])) else: @@ -124,7 +124,7 @@ class TDTestCase: for k , v in vgroups_infos.items(): if len(v) ==1 and v[0]=="leader": - tdLog.info(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) + tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) @@ -148,7 +148,7 @@ class TDTestCase: if ind%2==0: if role == stop_dnode_id and vgroups_leader_follower[ind+1]=="offline": - tdLog.info("====== dnode {} has offline , endpoint is {}".format(stop_dnode_id , self.stop_dnode)) + tdLog.notice("====== dnode {} has offline , endpoint is {}".format(stop_dnode_id , self.stop_dnode)) elif role == stop_dnode_id : tdLog.exit("====== dnode {} has not offline , endpoint is {}".format(stop_dnode_id , self.stop_dnode)) else: @@ -180,8 +180,8 @@ class TDTestCase: while status !="offline": time.sleep(0.1) status = _get_status() - # tdLog.info("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) - tdLog.info("==== stop_dnode has stopped , endpoint is {}".format(self.stop_dnode)) + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has stopped , endpoint is {}".format(self.stop_dnode)) def wait_start_dnode_OK(self): @@ -202,15 +202,15 @@ class TDTestCase: while status !="ready": time.sleep(0.1) status = _get_status() - # tdLog.info("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) - tdLog.info("==== stop_dnode has restart , endpoint is {}".format(self.stop_dnode)) + # tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode)) + tdLog.notice("==== stop_dnode has restart , endpoint is {}".format(self.stop_dnode)) def random_stop_One_dnode(self): self.stop_dnode = self._get_stop_dnode() stop_dnode_id = self.dnode_list[self.stop_dnode][0] - tdLog.info(" ==== dnode {} will offline ,endpoints is {} ====".format(stop_dnode_id , self.stop_dnode)) + tdLog.notice(" ==== dnode {} will offline ,endpoints is {} ====".format(stop_dnode_id , self.stop_dnode)) tdDnodes=cluster.dnodes tdDnodes[stop_dnode_id-1].stoptaosd() self.wait_stop_dnode_OK() @@ -250,10 +250,10 @@ class TDTestCase: time.sleep(0.1) status = self.check_vgroups_init_done(dbname) - # tdLog.info("=== database {} show vgroups vote the leader is in progress ===".format(dbname)) + # tdLog.notice("=== database {} show vgroups vote the leader is in progress ===".format(dbname)) end = time.time() cost_time = end - start - tdLog.info(" ==== database %s vote the leaders success , cost time is %.3f second ====="%(dbname,cost_time) ) + tdLog.notice(" ==== database %s vote the leaders success , cost time is %.3f second ====="%(dbname,cost_time) ) # os.system("taos -s 'show {}.vgroups;'".format(dbname)) if cost_time >= self.max_vote_time_cost: tdLog.exit(" ==== database %s vote the leaders cost too large time , cost time is %.3f second ===="%(dbname,cost_time) ) @@ -269,10 +269,10 @@ class TDTestCase: time.sleep(0.1) status = self.check_vgroups_revote_leader(dbname) - # tdLog.info("=== database {} show vgroups vote the leader is in progress ===".format(dbname)) + # tdLog.notice("=== database {} show vgroups vote the leader is in progress ===".format(dbname)) end = time.time() cost_time = end - start - tdLog.info(" ==== database %s revote the leaders success , cost time is %.3f second ====="%(dbname,cost_time) ) + tdLog.notice(" ==== database %s revote the leaders success , cost time is %.3f second ====="%(dbname,cost_time) ) # os.system("taos -s 'show {}.vgroups;'".format(dbname)) if cost_time >= self.max_vote_time_cost: tdLog.exit(" ==== database %s revote the leaders cost too large time , cost time is %.3f second ===="%(dbname,cost_time) ) @@ -306,7 +306,7 @@ class TDTestCase: if role==self.dnode_list[self.stop_dnode][0]: if vgroup_info[ind+1] =="offline" and "leader" in vgroup_info: - tdLog.info(" === revote leader ok , leader is {} now ====".format(list(vgroup_info).index("leader")-1)) + tdLog.notice(" === revote leader ok , leader is {} now ====".format(list(vgroup_info).index("leader")-1)) elif vgroup_info[ind+1] !="offline": tdLog.exit(" === dnode {} should be offline ".format(self.stop_dnode)) else: @@ -319,14 +319,14 @@ class TDTestCase: self.Restart_stop_dnode() def test_init_vgroups_time_costs(self): - tdLog.info(" ====start check time cost about vgroups vote leaders ==== ") - tdLog.info(" ==== current max time cost is set value : {} =======".format(self.max_vote_time_cost)) + tdLog.notice(" ====start check time cost about vgroups vote leaders ==== ") + tdLog.notice(" ==== current max time cost is set value : {} =======".format(self.max_vote_time_cost)) # create database replica 3 vgroups 1 db1 = 'db_1' create_db_replica_3_vgroups_1 = "create database {} replica 3 vgroups 1".format(db1) - tdLog.info('=======database {} replica 3 vgroups 1 ======'.format(db1)) + tdLog.notice('=======database {} replica 3 vgroups 1 ======'.format(db1)) tdSql.execute(create_db_replica_3_vgroups_1) self.vote_leader_time_costs(db1) self.exec_revote_action(db1) @@ -334,7 +334,7 @@ class TDTestCase: # create database replica 3 vgroups 10 db2 = 'db_2' create_db_replica_3_vgroups_10 = "create database {} replica 3 vgroups 10".format(db2) - tdLog.info('=======database {} replica 3 vgroups 10 ======'.format(db2)) + tdLog.notice('=======database {} replica 3 vgroups 10 ======'.format(db2)) tdSql.execute(create_db_replica_3_vgroups_10) self.vote_leader_time_costs(db2) self.exec_revote_action(db2) @@ -342,7 +342,7 @@ class TDTestCase: # create database replica 3 vgroups 100 db3 = 'db_3' create_db_replica_3_vgroups_100 = "create database {} replica 3 vgroups 100".format(db3) - tdLog.info('=======database {} replica 3 vgroups 100 ======'.format(db3)) + tdLog.notice('=======database {} replica 3 vgroups 100 ======'.format(db3)) tdSql.execute(create_db_replica_3_vgroups_100) self.vote_leader_time_costs(db3) self.exec_revote_action(db3) diff --git a/tests/system-test/6-cluster/vnode/insert_100W_rows.json b/tests/system-test/6-cluster/vnode/insert_100W_rows.json new file mode 100644 index 0000000000000000000000000000000000000000..4b49c38fb672ca926ea65af78a25ffb292f19633 --- /dev/null +++ b/tests/system-test/6-cluster/vnode/insert_100W_rows.json @@ -0,0 +1,118 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos/", + "host": "localhost", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "create_table_thread_count": 10, + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 1000, + "num_of_records_per_req": 1000, + "databases": [ + { + "dbinfo": { + "name": "db_2", + "drop": "no", + "vgroups": 1, + "replica": 3 + }, + "super_tables": [ + { + "name": "stb1", + "childtable_count": 10, + "childtable_prefix": "sub_", + "auto_create_table": "yes", + "batch_create_tbl_num": 5000, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100000, + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1000000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "2015-05-01 00:00:00.000", + "sample_format": "csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [ + { + "type": "INT", + "count": 1 + }, + { + "type": "TINYINT", + "count": 1 + }, + { + "type": "SMALLINT", + "count": 1 + }, + { + "type": "BIGINT", + "count": 1 + }, + { + "type": "UINT", + "count": 1 + }, + { + "type": "UTINYINT", + "count": 1 + }, + { + "type": "USMALLINT", + "count": 1 + }, + { + "type": "UBIGINT", + "count": 1 + }, + { + "type": "DOUBLE", + "count": 1 + }, + { + "type": "FLOAT", + "count": 1 + }, + { + "type": "BINARY", + "len": 40, + "count": 1 + }, + { + "type": "VARCHAR", + "len": 200, + "count": 1 + }, + { + "type": "nchar", + "len": 200, + "count": 1 + } + ], + "tags": [ + { + "type": "INT", + "count": 1 + }, + { + "type": "BINARY", + "len": 100, + "count": 1 + }, + { + "type": "BOOL", + "count": 1 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/system-test/6-cluster/vnode/insert_10W_rows.json b/tests/system-test/6-cluster/vnode/insert_10W_rows.json new file mode 100644 index 0000000000000000000000000000000000000000..b3b63aed1261fd13c016b0772fc967e38f36d23a --- /dev/null +++ b/tests/system-test/6-cluster/vnode/insert_10W_rows.json @@ -0,0 +1,118 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos/", + "host": "localhost", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 1, + "create_table_thread_count": 1, + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 1000, + "num_of_records_per_req": 1000, + "databases": [ + { + "dbinfo": { + "name": "db_1", + "drop": "no", + "vgroups": 1, + "replica": 3 + }, + "super_tables": [ + { + "name": "stb1", + "childtable_count": 10, + "childtable_prefix": "sub_", + "auto_create_table": "yes", + "batch_create_tbl_num": 5000, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10000, + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1000000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "2015-05-01 00:00:00.000", + "sample_format": "csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [ + { + "type": "INT", + "count": 1 + }, + { + "type": "TINYINT", + "count": 1 + }, + { + "type": "SMALLINT", + "count": 1 + }, + { + "type": "BIGINT", + "count": 1 + }, + { + "type": "UINT", + "count": 1 + }, + { + "type": "UTINYINT", + "count": 1 + }, + { + "type": "USMALLINT", + "count": 1 + }, + { + "type": "UBIGINT", + "count": 1 + }, + { + "type": "DOUBLE", + "count": 1 + }, + { + "type": "FLOAT", + "count": 1 + }, + { + "type": "BINARY", + "len": 40, + "count": 1 + }, + { + "type": "VARCHAR", + "len": 200, + "count": 1 + }, + { + "type": "nchar", + "len": 200, + "count": 1 + } + ], + "tags": [ + { + "type": "INT", + "count": 1 + }, + { + "type": "BINARY", + "len": 100, + "count": 1 + }, + { + "type": "BOOL", + "count": 1 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/system-test/7-tmq/basic5.py b/tests/system-test/7-tmq/basic5.py index 4ed3be967eb1611b3cddd967b5d141ef770e19d3..70813eba9644bcb6d57fe49022a6b157cdd69528 100644 --- a/tests/system-test/7-tmq/basic5.py +++ b/tests/system-test/7-tmq/basic5.py @@ -265,7 +265,7 @@ class TDTestCase: else: continue - if tdSql.getData(index,19) == 'ready': + if tdSql.getData(index,15) == 'ready': print("******************** index: %d"%index) break @@ -395,7 +395,7 @@ class TDTestCase: while 1: tdSql.query("show databases") if tdSql.getRows() == 5: - print ('==================================================') + print ('==================================================dbname: %s'%parameterDict['dbName']) print (tdSql.getData(0,0), tdSql.getData(1,0),tdSql.getData(2,0),tdSql.getData(3,0),tdSql.getData(4,0)) index = 0 if tdSql.getData(0,0) == parameterDict['dbName']: @@ -409,9 +409,9 @@ class TDTestCase: elif tdSql.getData(4,0) == parameterDict['dbName']: index = 4 else: - continue + continue - if tdSql.getData(index,19) == 'ready': + if tdSql.getData(index,15) == 'ready': print("******************** index: %d"%index) break diff --git a/tests/system-test/7-tmq/db.py b/tests/system-test/7-tmq/db.py index fd793fd841f76a402ba35fed68013167133d9a62..1fd0638d172fe6dfb6f19c1617e1eebc38ccac41 100644 --- a/tests/system-test/7-tmq/db.py +++ b/tests/system-test/7-tmq/db.py @@ -118,7 +118,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 -1 wal_retention_size -1"%(dbName, vgroups, replica)) tdLog.debug("complete to create database %s"%(dbName)) return diff --git a/tests/system-test/7-tmq/TD-17803.py b/tests/system-test/7-tmq/dropDbR3ConflictTransaction.py similarity index 95% rename from tests/system-test/7-tmq/TD-17803.py rename to tests/system-test/7-tmq/dropDbR3ConflictTransaction.py index 771ff83a29a02867c319a4b7ee6267b24eba24a5..4dac872fdea51f284c3edde04db7416721a70936 100644 --- a/tests/system-test/7-tmq/TD-17803.py +++ b/tests/system-test/7-tmq/dropDbR3ConflictTransaction.py @@ -100,14 +100,9 @@ class TDTestCase: # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) # tmqCom.asyncInsertDataByInterlace(paraDict) - tdLog.printNoPrefix("11111111111111111111111") tmqCom.create_ntable(tdSql, dbname=paraDict["dbName"], tbname_prefix="ntb", tbname_index_start_num = 1, column_elm_list=paraDict["colSchema"], colPrefix='c', tblNum=1) - tdLog.printNoPrefix("222222222222222") tmqCom.insert_rows_into_ntbl(tdSql, dbname=paraDict["dbName"], tbname_prefix="ntb", tbname_index_start_num = 1, column_ele_list=paraDict["colSchema"], startTs=paraDict["startTs"], tblNum=1, rows=2) # tdLog.info("restart taosd to ensure that the data falls into the disk") - - tdLog.printNoPrefix("333333333333333333333") tdSql.query("drop database %s"%paraDict["dbName"]) - tdLog.printNoPrefix("44444444444444444") return def tmqCase1(self): diff --git a/tests/system-test/7-tmq/tmqDelete-1ctb.py b/tests/system-test/7-tmq/tmqDelete-1ctb.py index a2a429771cc4fddcbf8ba86c64e0d5cfc90ff7cd..bedb36e505fa0f0d136d33aeeb472287d7566c54 100644 --- a/tests/system-test/7-tmq/tmqDelete-1ctb.py +++ b/tests/system-test/7-tmq/tmqDelete-1ctb.py @@ -52,7 +52,7 @@ class TDTestCase: paraDict['rowsPerTbl'] = self.rowsPerTbl tmqCom.initConsumerTable() - tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1,wal_retention_size=-1, wal_retention_period=-1) 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/tmqDelete-multiCtb.py b/tests/system-test/7-tmq/tmqDelete-multiCtb.py index fa32efbd0b6b44d8077b182b5dd6c7dbe81aab2c..94ca16bc6f4b6abf260f291380e1c1f0079d5fa1 100644 --- a/tests/system-test/7-tmq/tmqDelete-multiCtb.py +++ b/tests/system-test/7-tmq/tmqDelete-multiCtb.py @@ -52,7 +52,7 @@ class TDTestCase: paraDict['rowsPerTbl'] = self.rowsPerTbl tmqCom.initConsumerTable() - tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1,wal_retention_size=-1, wal_retention_period=-1) 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/tmqDnodeRestart.py b/tests/system-test/7-tmq/tmqDnodeRestart.py index 5117ee3d24c289e695eb3113e643e94a6eb01e53..9a11106e3ea464415815dc020870f60cbaf21fb7 100644 --- a/tests/system-test/7-tmq/tmqDnodeRestart.py +++ b/tests/system-test/7-tmq/tmqDnodeRestart.py @@ -53,7 +53,7 @@ class TDTestCase: paraDict['rowsPerTbl'] = self.rowsPerTbl tmqCom.initConsumerTable() - tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1,wal_retention_size=-1, wal_retention_period=-1) 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/tmqShow.py b/tests/system-test/7-tmq/tmqShow.py index 6b7e7375ffeca382bb77e4e8b8ab1704a83854f3..6f8183bf06cfa501f62c22c82c2915638ea7414b 100644 --- a/tests/system-test/7-tmq/tmqShow.py +++ b/tests/system-test/7-tmq/tmqShow.py @@ -51,32 +51,32 @@ class TDTestCase: tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) # tdLog.info("insert data") # tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) - + tdLog.info("create 4 topics") sqlString = "create topic %s as database %s" %(topicNameList[0], paraDict['dbName']) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + sqlString = "create topic %s as stable %s.%s" %(topicNameList[1], paraDict['dbName'], paraDict['stbName']) tdLog.info("create topic sql: %s"%sqlString) - tdSql.execute(sqlString) + tdSql.execute(sqlString) queryString = "select * from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[2], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) - + 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[3], queryString) tdLog.info("create topic sql: %s"%sqlString) tdSql.execute(sqlString) tdSql.query("show topics") - tdLog.debug(tdSql.queryResult) + tdLog.debug(tdSql.queryResult) rows = tdSql.getRows() if rows != len(consumerIdList): tdLog.exit("topic rows error") - + for i in range (rows): topicName = tdSql.getData(i,0) matchFlag = 0 @@ -87,24 +87,24 @@ class TDTestCase: break if matchFlag == 0: tdLog.exit("topic name: %s is error", topicName) - + # init consume info, and start tmq_sim, then check consume result tdLog.info("insert consume info to consume processor") expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] topicList = topicNameList[0] ifcheckdata = 0 - ifManualCommit = 0 + ifManualCommit = 0 keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[0] tmqCom.insertConsumerInfo(consumerIdList[0], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + topicList = topicNameList[1] keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[1] tmqCom.insertConsumerInfo(consumerIdList[1], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + topicList = topicNameList[2] keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[2] tmqCom.insertConsumerInfo(consumerIdList[2], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) - + topicList = topicNameList[3] keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[3] tmqCom.insertConsumerInfo(consumerIdList[3], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) @@ -118,27 +118,27 @@ class TDTestCase: time.sleep(5) tdLog.info("check show consumers") tdSql.query("show consumers") - # tdLog.info(tdSql.queryResult) + # tdLog.info(tdSql.queryResult) rows = tdSql.getRows() tdLog.info("show consumers rows: %d"%rows) if rows != len(topicNameList): tdLog.exit("show consumers rows error") - - tdLog.info("check show subscriptions") + + tdLog.info("check show subscriptions") tdSql.query("show subscriptions") - # tdLog.debug(tdSql.queryResult) + # tdLog.debug(tdSql.queryResult) rows = tdSql.getRows() tdLog.info("show subscriptions rows: %d"%rows) if rows != paraDict['vgroups'] * len(topicNameList): tdLog.exit("show subscriptions rows error") pThread.join() - + tdLog.info("insert process end, and start to check consume result") expectRows = len(consumerIdList) _ = tmqCom.selectConsumeResult(expectRows) - - time.sleep(10) + + time.sleep(10) for i in range(len(topicNameList)): tdSql.query("drop topic %s"%topicNameList[i]) diff --git a/tests/system-test/7-tmq/tmqSubscribeStb-r3.py b/tests/system-test/7-tmq/tmqSubscribeStb-r3.py new file mode 100644 index 0000000000000000000000000000000000000000..6461ee9644e926193086c35b94f1ab1f38b7f553 --- /dev/null +++ b/tests/system-test/7-tmq/tmqSubscribeStb-r3.py @@ -0,0 +1,302 @@ +from distutils.log import error +import taos +import sys +import time +import socket +import os +import threading +import subprocess +import platform + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * +from util.common import * +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + def __init__(self): + self.snapshot = 0 + self.replica = 3 + self.vgroups = 4 + self.ctbNum = 1000 + self.rowsPerTbl = 100 + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + #tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def checkFileContent(self, consumerId, queryString): + buildPath = tdCom.getBuildPath() + cfgPath = tdCom.getClientCfgPath() + dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId) + cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) + tdLog.info(cmdStr) + os.system(cmdStr) + + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) + tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) + + consumeFile = open(consumeRowsFile, mode='r') + queryFile = open(dstFile, mode='r') + + # skip first line for it is schema + queryFile.readline() + + while True: + dst = queryFile.readline() + src = consumeFile.readline() + + if dst: + if dst != src: + tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId) + else: + break + return + + 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': 100, + 'rowsPerTbl': 1000, + 'batchNum': 100, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 3, + 'showMsg': 1, + 'showRow': 1, + 'snapshot': 0} + + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + + tmqCom.initConsumerTable() + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=self.replica) + 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']) + # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx", + # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], + # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + tmqCom.asyncInsertDataByInterlace(paraDict) + + tdLog.info("wait some data inserted") + exitFlag = 1 + while exitFlag: + queryString = "select count(*) from %s.%s"%(paraDict["dbName"],paraDict["stbName"]) + tdSql.query(queryString) + if tdSql.getRows() > 0: + rowsInserted = tdSql.getData(0,0) + if (rowsInserted > ((self.ctbNum * self.rowsPerTbl)/5)): + exitFlag = 0 + time.sleep(0.1) + + tdLog.info("inserted rows: %d"%tdSql.getData(0,0)) + # tdDnodes=cluster.dnodes + tdLog.info("================= restart dnode 2===========================") + cluster.dnodes[1].stoptaosd() + cluster.dnodes[1].starttaosd() + tdLog.info("================= restart dnode 3===========================") + cluster.dnodes[2].stoptaosd() + cluster.dnodes[2].starttaosd() + tdLog.info("================= restart dnode 4===========================") + cluster.dnodes[3].stoptaosd() + cluster.dnodes[3].starttaosd() + tdLog.info("================= restart dnode 5===========================") + cluster.dnodes[4].stoptaosd() + cluster.dnodes[4].starttaosd() + + # tdLog.info("restart taosd to ensure that the data falls into the disk") + # tdSql.query("flush database %s"%(paraDict['dbName'])) + return + + def tmqCase1(self): + tdLog.printNoPrefix("======== test case 1: ") + + # create and start thread + 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': 100, + 'rowsPerTbl': 1000, + 'batchNum': 100, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 15, + 'showMsg': 1, + 'showRow': 1, + 'snapshot': 0} + + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + + 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']) + sqlString = "create topic %s as %s" %(topicFromStb1, queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + + consumerId = 0 + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 0 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) + + 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 totalConsumeRows != totalRowsFromQuery: + tdLog.exit("tmq consume rows error!") + + # tmqCom.checkFileContent(consumerId, queryString) + + tmqCom.waitSubscriptionExit(tdSql, topicFromStb1) + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 1 end ...... ") + + def tmqCase2(self): + tdLog.printNoPrefix("======== test case 2: ") + + # create and start thread + 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': 100, + 'rowsPerTbl': 1000, + 'batchNum': 100, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 15, + 'showMsg': 1, + 'showRow': 1, + 'snapshot': 1} + + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + + 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']) + sqlString = "create topic %s as %s" %(topicFromStb1, queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + + consumerId = 0 + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 0 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) + + tdLog.info("================= restart dnode 2===========================") + cluster.dnodes[1].stoptaosd() + cluster.dnodes[1].starttaosd() + tdLog.info("================= restart dnode 3===========================") + cluster.dnodes[2].stoptaosd() + cluster.dnodes[2].starttaosd() + tdLog.info("================= restart dnode 4===========================") + cluster.dnodes[3].stoptaosd() + cluster.dnodes[3].starttaosd() + tdLog.info("================= restart dnode 5===========================") + cluster.dnodes[4].stoptaosd() + cluster.dnodes[4].starttaosd() + + 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 totalConsumeRows != totalRowsFromQuery: + tdLog.exit("tmq consume rows error!") + + # tmqCom.checkFileContent(consumerId, queryString) + + tmqCom.waitSubscriptionExit(tdSql, topicFromStb1) + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 2 end ...... ") + + def run(self): + self.prepareTestEnv() + self.tmqCase1() + self.tmqCase2() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/tmqUpdateWithConsume.py b/tests/system-test/7-tmq/tmqUpdateWithConsume.py index 4f21beffc40e825ce143bf23060f566048ec16b4..2dd3a061c62bf5ac63a135e99424ac549ef83a54 100644 --- a/tests/system-test/7-tmq/tmqUpdateWithConsume.py +++ b/tests/system-test/7-tmq/tmqUpdateWithConsume.py @@ -52,7 +52,7 @@ class TDTestCase: paraDict['rowsPerTbl'] = self.rowsPerTbl tmqCom.initConsumerTable() - tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1, wal_retention_size=-1, wal_retention_period=-1) 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/tmq_taosx.py b/tests/system-test/7-tmq/tmq_taosx.py new file mode 100644 index 0000000000000000000000000000000000000000..2a819f810697179ecf1e37323d778d9d176b7d21 --- /dev/null +++ b/tests/system-test/7-tmq/tmq_taosx.py @@ -0,0 +1,91 @@ + +import taos +import sys +import time +import socket +import os +import threading + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + #tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def checkFileContent(self): + buildPath = tdCom.getBuildPath() + cfgPath = tdCom.getClientCfgPath() + cmdStr = '%s/build/bin/tmq_taosx_ci -c %s'%(buildPath, cfgPath) + tdLog.info(cmdStr) + os.system(cmdStr) + + srcFile = '%s/../log/tmq_taosx_tmp.source'%(cfgPath) + dstFile = '%s/../log/tmq_taosx_tmp.result'%(cfgPath) + tdLog.info("compare file: %s, %s"%(srcFile, dstFile)) + + consumeFile = open(srcFile, mode='r') + queryFile = open(dstFile, mode='r') + + while True: + dst = queryFile.readline() + src = consumeFile.readline() + + if dst: + if dst != src: + tdLog.exit("compare error: %s != %s"%src, dst) + else: + break + + tdSql.execute('use db_taosx') + tdSql.query("select * from ct3 order by c1 desc") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 51) + tdSql.checkData(0, 4, 940) + tdSql.checkData(1, 1, 23) + tdSql.checkData(1, 4, None) + + tdSql.query("select * from ct1") + tdSql.checkRows(4) + + tdSql.query("select * from ct2") + tdSql.checkRows(0) + + tdSql.query("select * from ct0 order by c1 ") + tdSql.checkRows(2) + tdSql.checkData(0, 3, "a") + tdSql.checkData(1, 4, None) + + tdSql.query("select * from n1 order by ts") + tdSql.checkRows(2) + tdSql.checkData(0, 1, "eeee") + tdSql.checkData(1, 2, 940) + + tdSql.query("select * from jt order by i desc;") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 11) + tdSql.checkData(0, 2, None) + tdSql.checkData(1, 1, 1) + tdSql.checkData(1, 2, '{"k1":1,"k2":"hello"}') + + return + + def run(self): + tdSql.prepare() + self.checkFileContent() + + 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/fulltest.sh b/tests/system-test/fulltest.sh index f074bd885045553cbe94029bd128dbc2235aea7a..458951b81566cc63664e422c95805c631a2caba8 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -59,17 +59,44 @@ python3 ./test.py -f 2-query/ceil.py python3 ./test.py -f 2-query/ceil.py -R python3 ./test.py -f 2-query/char_length.py python3 ./test.py -f 2-query/char_length.py -R -python3 ./test.py -f 2-query/check_tsdb.py -python3 ./test.py -f 2-query/check_tsdb.py -R +# python3 ./test.py -f 2-query/check_tsdb.py +# python3 ./test.py -f 2-query/check_tsdb.py -R +python3 ./test.py -f 2-query/concat.py +python3 ./test.py -f 2-query/concat.py -R +python3 ./test.py -f 2-query/concat_ws.py +python3 ./test.py -f 2-query/concat_ws.py -R +python3 ./test.py -f 2-query/concat_ws2.py +python3 ./test.py -f 2-query/concat_ws2.py -R +python3 ./test.py -f 2-query/cos.py +python3 ./test.py -f 2-query/cos.py -R +python3 ./test.py -f 2-query/count_partition.py +python3 ./test.py -f 2-query/count_partition.py -R +python3 ./test.py -f 2-query/count.py +python3 ./test.py -f 2-query/count.py -R +python3 ./test.py -f 2-query/db.py +python3 ./test.py -f 2-query/db.py -R +python3 ./test.py -f 2-query/diff.py +python3 ./test.py -f 2-query/diff.py -R +python3 ./test.py -f 2-query/distinct.py +python3 ./test.py -f 2-query/distinct.py -R +python3 ./test.py -f 2-query/distribute_agg_apercentile.py +python3 ./test.py -f 2-query/distribute_agg_apercentile.py -R +python3 ./test.py -f 2-query/distribute_agg_avg.py +python3 ./test.py -f 2-query/distribute_agg_avg.py -R +python3 ./test.py -f 2-query/distribute_agg_count.py +python3 ./test.py -f 2-query/distribute_agg_count.py -R +python3 ./test.py -f 2-query/distribute_agg_max.py +python3 ./test.py -f 2-query/distribute_agg_max.py -R +python3 ./test.py -f 2-query/distribute_agg_min.py +python3 ./test.py -f 2-query/distribute_agg_min.py -R + + + python3 ./test.py -f 1-insert/update_data.py python3 ./test.py -f 1-insert/delete_data.py -python3 ./test.py -f 2-query/db.py - -python3 ./test.py -f 2-query/db.py -python3 ./test.py -f 2-query/distinct.py python3 ./test.py -f 2-query/varchar.py python3 ./test.py -f 2-query/ltrim.py python3 ./test.py -f 2-query/rtrim.py @@ -81,10 +108,7 @@ python3 ./test.py -f 2-query/join2.py python3 ./test.py -f 2-query/substr.py python3 ./test.py -f 2-query/union.py python3 ./test.py -f 2-query/union1.py -python3 ./test.py -f 2-query/concat.py python3 ./test.py -f 2-query/concat2.py -python3 ./test.py -f 2-query/concat_ws.py -python3 ./test.py -f 2-query/concat_ws2.py python3 ./test.py -f 2-query/spread.py python3 ./test.py -f 2-query/hyperloglog.py python3 ./test.py -f 2-query/explain.py @@ -97,13 +121,11 @@ python3 ./test.py -f 2-query/Now.py python3 ./test.py -f 2-query/Today.py python3 ./test.py -f 2-query/max.py python3 ./test.py -f 2-query/min.py -python3 ./test.py -f 2-query/count.py python3 ./test.py -f 2-query/last.py python3 ./test.py -f 2-query/first.py python3 ./test.py -f 2-query/To_iso8601.py python3 ./test.py -f 2-query/To_unixtimestamp.py python3 ./test.py -f 2-query/timetruncate.py -python3 ./test.py -f 2-query/diff.py python3 ./test.py -f 2-query/Timediff.py python3 ./test.py -f 2-query/json_tag.py @@ -115,7 +137,6 @@ python3 ./test.py -f 2-query/log.py python3 ./test.py -f 2-query/pow.py python3 ./test.py -f 2-query/sqrt.py python3 ./test.py -f 2-query/sin.py -python3 ./test.py -f 2-query/cos.py python3 ./test.py -f 2-query/tan.py python3 ./test.py -f 2-query/query_cols_tags_and_or.py # python3 ./test.py -f 2-query/nestedQuery.py @@ -126,7 +147,6 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py python3 ./test.py -f 2-query/elapsed.py python3 ./test.py -f 2-query/csum.py python3 ./test.py -f 2-query/mavg.py -python3 ./test.py -f 2-query/diff.py python3 ./test.py -f 2-query/sample.py python3 ./test.py -f 2-query/function_diff.py python3 ./test.py -f 2-query/unique.py @@ -135,21 +155,16 @@ python3 ./test.py -f 2-query/function_stateduration.py python3 ./test.py -f 2-query/statecount.py python3 ./test.py -f 2-query/tail.py python3 ./test.py -f 2-query/ttl_comment.py -python3 ./test.py -f 2-query/distribute_agg_count.py -python3 ./test.py -f 2-query/distribute_agg_max.py -python3 ./test.py -f 2-query/distribute_agg_min.py python3 ./test.py -f 2-query/distribute_agg_sum.py python3 ./test.py -f 2-query/distribute_agg_spread.py -python3 ./test.py -f 2-query/distribute_agg_apercentile.py -python3 ./test.py -f 2-query/distribute_agg_avg.py python3 ./test.py -f 2-query/distribute_agg_stddev.py python3 ./test.py -f 2-query/twa.py python3 ./test.py -f 2-query/irate.py -python3 ./test.py -f 2-query/count_partition.py python3 ./test.py -f 2-query/function_null.py python3 ./test.py -f 2-query/queryQnode.py python3 ./test.py -f 2-query/max_partition.py python3 ./test.py -f 2-query/last_row.py +python3 ./test.py -f 2-query/tsbsQuery.py python3 ./test.py -f 6-cluster/5dnode1mnode.py python3 ./test.py -f 6-cluster/5dnode2mnode.py -N 5 -M 3 @@ -157,23 +172,29 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeStop2Follower.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeStopLoop.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py -N 5 -M 3 -python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 5 -M 3 +# python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -M 3 -# python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py -N 5 -M 3 +python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertData.py -N 5 -M 3 +python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py -N 5 -M 3 # python3 ./test.py -f 6-cluster/5dnode3mnodeRestartMnodeInsertData.py -N 5 -M 3 # python3 ./test.py -f 6-cluster/5dnode3mnodeRestartVnodeInsertData.py -N 5 -M 3 -python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5 +python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py # python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py -N 5 # python3 test.py -f 6-cluster/5dnode3mnodeStopConnect.py -N 5 -M 3 - +python3 ./test.py -f 6-cluster/5dnode3mnodeRecreateMnode.py -N 5 -M 3 +python3 ./test.py -f 6-cluster/5dnode3mnodeStopFollowerLeader.py -N 5 -M 3 +python3 ./test.py -f 6-cluster/5dnode3mnodeStop2Follower.py -N 5 -M 3 + + +python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3 python3 ./test.py -f 7-tmq/basic5.py python3 ./test.py -f 7-tmq/subscribeDb.py python3 ./test.py -f 7-tmq/subscribeDb0.py @@ -202,15 +223,15 @@ python3 ./test.py -f 7-tmq/tmqConsFromTsdb1.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb-1ctb.py -python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-1ctb.py +# python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-1ctb.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py -python3 ./test.py -f 7-tmq/tmqAutoCreateTbl.py -python3 ./test.py -f 7-tmq/tmqDnodeRestart.py +#python3 ./test.py -f 7-tmq/tmqAutoCreateTbl.py +#python3 ./test.py -f 7-tmq/tmqDnodeRestart.py python3 ./test.py -f 7-tmq/tmqUpdate-1ctb.py python3 ./test.py -f 7-tmq/tmqUpdateWithConsume.py python3 ./test.py -f 7-tmq/tmqUpdate-multiCtb-snapshot0.py @@ -227,6 +248,7 @@ python3 ./test.py -f 7-tmq/tmqUdf-multCtb-snapshot1.py python3 ./test.py -f 7-tmq/stbTagFilter-1ctb.py python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py +python3 ./test.py -f 7-tmq/tmq_taosx.py # python3 ./test.py -f 7-tmq/stbTagFilter-multiCtb.py #------------querPolicy 2----------- @@ -250,7 +272,7 @@ python3 ./test.py -f 2-query/concat.py -Q 2 python3 ./test.py -f 2-query/concat2.py -Q 2 python3 ./test.py -f 2-query/concat_ws.py -Q 2 python3 ./test.py -f 2-query/concat_ws2.py -Q 2 -python3 ./test.py -f 2-query/check_tsdb.py -Q 2 +#python3 ./test.py -f 2-query/check_tsdb.py -Q 2 python3 ./test.py -f 2-query/spread.py -Q 2 python3 ./test.py -f 2-query/hyperloglog.py -Q 2 python3 ./test.py -f 2-query/explain.py -Q 2 @@ -295,7 +317,6 @@ python3 ./test.py -f 2-query/avg.py -Q 2 # python3 ./test.py -f 2-query/elapsed.py -Q 2 python3 ./test.py -f 2-query/csum.py -Q 2 python3 ./test.py -f 2-query/mavg.py -Q 2 -python3 ./test.py -f 2-query/diff.py -Q 2 python3 ./test.py -f 2-query/sample.py -Q 2 python3 ./test.py -f 2-query/function_diff.py -Q 2 python3 ./test.py -f 2-query/unique.py -Q 2 @@ -318,7 +339,7 @@ python3 ./test.py -f 2-query/function_null.py -Q 2 python3 ./test.py -f 2-query/count_partition.py -Q 2 python3 ./test.py -f 2-query/max_partition.py -Q 2 python3 ./test.py -f 2-query/last_row.py -Q 2 - +python3 ./test.py -f 2-query/tsbsQuery.py -Q 2 #------------querPolicy 3----------- python3 ./test.py -f 2-query/between.py -Q 3 @@ -340,7 +361,7 @@ python3 ./test.py -f 2-query/concat.py -Q 3 python3 ./test.py -f 2-query/concat2.py -Q 3 python3 ./test.py -f 2-query/concat_ws.py -Q 3 python3 ./test.py -f 2-query/concat_ws2.py -Q 3 -python3 ./test.py -f 2-query/check_tsdb.py -Q 3 +#python3 ./test.py -f 2-query/check_tsdb.py -Q 3 python3 ./test.py -f 2-query/spread.py -Q 3 python3 ./test.py -f 2-query/hyperloglog.py -Q 3 python3 ./test.py -f 2-query/explain.py -Q 3 @@ -383,7 +404,6 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 3 # python3 ./test.py -f 2-query/elapsed.py -Q 3 python3 ./test.py -f 2-query/csum.py -Q 3 python3 ./test.py -f 2-query/mavg.py -Q 3 -python3 ./test.py -f 2-query/diff.py -Q 3 python3 ./test.py -f 2-query/sample.py -Q 3 python3 ./test.py -f 2-query/function_diff.py -Q 3 python3 ./test.py -f 2-query/unique.py -Q 3 @@ -406,3 +426,4 @@ python3 ./test.py -f 2-query/function_null.py -Q 3 python3 ./test.py -f 2-query/count_partition.py -Q 3 python3 ./test.py -f 2-query/max_partition.py -Q 3 python3 ./test.py -f 2-query/last_row.py -Q 3 +python3 ./test.py -f 2-query/tsbsQuery.py -Q 3 \ No newline at end of file diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt index 5db97a0f0fc21486c642c5c4ea6b92c5edf184e9..605eef9be3bc15580858922c0001352fb3b8f079 100644 --- a/tests/test/c/CMakeLists.txt +++ b/tests/test/c/CMakeLists.txt @@ -1,6 +1,7 @@ add_executable(tmq_demo tmqDemo.c) add_executable(tmq_sim tmqSim.c) add_executable(create_table createTable.c) +add_executable(tmq_taosx_ci tmq_taosx_ci.c) target_link_libraries( create_table PUBLIC taos_static @@ -22,6 +23,13 @@ target_link_libraries( PUBLIC common PUBLIC os ) +target_link_libraries( + tmq_taosx_ci + PUBLIC taos_static + PUBLIC util + PUBLIC common + PUBLIC os +) add_executable(sdbDump sdbDump.c) target_link_libraries( diff --git a/tests/test/c/sdbDump.c b/tests/test/c/sdbDump.c index 4d0f582dc604a5271bb58e7dae46debae8afdfeb..aef50560316c87ca91d766a99bc7acc0509e0866 100644 --- a/tests/test/c/sdbDump.c +++ b/tests/test/c/sdbDump.c @@ -79,8 +79,6 @@ void dumpDb(SSdb *pSdb, SJson *json) { tjsonAddIntegerToObject(item, "daysToKeep2", pObj->cfg.daysToKeep2); tjsonAddIntegerToObject(item, "minRows", pObj->cfg.minRows); tjsonAddIntegerToObject(item, "maxRows", pObj->cfg.maxRows); - tjsonAddIntegerToObject(item, "fsyncPeriod", pObj->cfg.fsyncPeriod); - tjsonAddIntegerToObject(item, "walLevel", pObj->cfg.walLevel); tjsonAddIntegerToObject(item, "precision", pObj->cfg.precision); tjsonAddIntegerToObject(item, "compression", pObj->cfg.compression); tjsonAddIntegerToObject(item, "replications", pObj->cfg.replications); @@ -89,7 +87,13 @@ void dumpDb(SSdb *pSdb, SJson *json) { tjsonAddIntegerToObject(item, "hashMethod", pObj->cfg.hashMethod); tjsonAddIntegerToObject(item, "numOfRetensions", pObj->cfg.numOfRetensions); tjsonAddIntegerToObject(item, "schemaless", pObj->cfg.schemaless); - + tjsonAddIntegerToObject(item, "walLevel", pObj->cfg.walLevel); + tjsonAddIntegerToObject(item, "walFsyncPeriod", pObj->cfg.walFsyncPeriod); + tjsonAddIntegerToObject(item, "walRetentionPeriod", pObj->cfg.walRetentionPeriod); + tjsonAddIntegerToObject(item, "walRetentionSize", pObj->cfg.walRetentionSize); + tjsonAddIntegerToObject(item, "walRollPeriod", pObj->cfg.walRollPeriod); + tjsonAddIntegerToObject(item, "walSegmentSize", pObj->cfg.walSegmentSize); + sdbRelease(pSdb, pObj); } } diff --git a/tests/test/c/tmqSim.c b/tests/test/c/tmqSim.c index 6a18263d502addf2515ac2939e07bb6920c0b4b1..d39ade7e91495d2b3ff1924efdb78103d7b423cc 100644 --- a/tests/test/c/tmqSim.c +++ b/tests/test/c/tmqSim.c @@ -630,7 +630,7 @@ static int32_t meta_msg_process(TAOS_RES* msg, SThreadInfo* pInfo, int32_t msgIn { tmq_raw_data raw = {0}; - int32_t code = tmq_get_raw_meta(msg, &raw); + int32_t code = tmq_get_raw(msg, &raw); if(code == TSDB_CODE_SUCCESS){ int retCode = queryDB(pInfo->taos, "use metadb"); @@ -641,7 +641,7 @@ static int32_t meta_msg_process(TAOS_RES* msg, SThreadInfo* pInfo, int32_t msgIn } taosFprintfFile(g_fp, "raw:%p\n", &raw); - taos_write_raw_meta(pInfo->taos, raw); + tmq_write_raw(pInfo->taos, raw); } char* result = tmq_get_json_meta(msg); diff --git a/tests/test/c/tmq_taosx_ci.c b/tests/test/c/tmq_taosx_ci.c new file mode 100644 index 0000000000000000000000000000000000000000..ece7ad4819f2947cb0a474491255dd296136581b --- /dev/null +++ b/tests/test/c/tmq_taosx_ci.c @@ -0,0 +1,520 @@ +/* + * 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 +#include +#include "taos.h" +#include "types.h" + +static int running = 1; +TdFilePtr g_fp = NULL; +char dir[64]={0}; + +static TAOS* use_db(){ + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); + if (pConn == NULL) { + return NULL; + } + + TAOS_RES* pRes = taos_query(pConn, "use db_taosx"); + if (taos_errno(pRes) != 0) { + printf("error in use db_taosx, reason:%s\n", taos_errstr(pRes)); + return NULL; + } + taos_free_result(pRes); + return pConn; +} + +static void msg_process(TAOS_RES* msg) { + /*memset(buf, 0, 1024);*/ + printf("-----------topic-------------: %s\n", tmq_get_topic_name(msg)); + printf("db: %s\n", tmq_get_db_name(msg)); + printf("vg: %d\n", tmq_get_vgroup_id(msg)); + TAOS *pConn = use_db(); + if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META) { + char* result = tmq_get_json_meta(msg); + if (result) { + printf("meta result: %s\n", result); + } + taosFprintfFile(g_fp, result); + taosFprintfFile(g_fp, "\n"); + tmq_free_json_meta(result); + } + + tmq_raw_data raw = {0}; + tmq_get_raw(msg, &raw); + int32_t ret = tmq_write_raw(pConn, raw); + printf("write raw data: %s\n", tmq_err2str(ret)); + +// else{ +// while(1){ +// int numOfRows = 0; +// void *pData = NULL; +// taos_fetch_raw_block(msg, &numOfRows, &pData); +// if(numOfRows == 0) break; +// printf("write data: tbname:%s, numOfRows:%d\n", tmq_get_table_name(msg), numOfRows); +// int ret = taos_write_raw_block(pConn, numOfRows, pData, tmq_get_table_name(msg)); +// printf("write raw data: %s\n", tmq_err2str(ret)); +// } +// } + + taos_close(pConn); +} + +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_taosx"); + 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_taosx vgroups 1"); + 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, "drop database if exists abc1"); + if (taos_errno(pRes) != 0) { + printf("error in drop db, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1"); + if (taos_errno(pRes) != 0) { + printf("error in create db, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "use abc1"); + if (taos_errno(pRes) != 0) { + printf("error in use db, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, + "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 " + "nchar(8), t4 bool)"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table if not exists ct0 using st1 tags(1000, \"ttt\", true)"); + if (taos_errno(pRes) != 0) { + printf("failed to create child table tu1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into ct0 values(1626006833600, 1, 2, 'a')"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into ct0, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table if not exists ct1 using st1(t1) tags(2000)"); + if (taos_errno(pRes) != 0) { + printf("failed to create child table ct1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table if not exists ct2 using st1(t1) tags(NULL)"); + if (taos_errno(pRes) != 0) { + printf("failed to create child table ct2, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into ct1 values(1626006833600, 3, 4, 'b')"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into ct1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table if not exists ct3 using st1(t1) tags(3000)"); + if (taos_errno(pRes) != 0) { + printf("failed to create child table ct3, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into ct3 values(1626006833600, 5, 6, 'c') ct1 values(1626006833601, 2, 3, 'sds') (1626006833602, 4, 5, 'ddd') ct0 values(1626006833602, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "alter table st1 add column c4 bigint"); + if (taos_errno(pRes) != 0) { + printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "alter table st1 modify column c3 binary(64)"); + if (taos_errno(pRes) != 0) { + printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into ct3 values(1626006833605, 53, 63, 'cffffffffffffffffffffffffffff', 8989898899999) (1626006833609, 51, 62, 'c333', 940)"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into ct3 select * from ct1"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "alter table st1 add tag t2 binary(64)"); + if (taos_errno(pRes) != 0) { + printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "alter table ct3 set tag t1=5000"); + if (taos_errno(pRes) != 0) { + printf("failed to slter child table ct3, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "delete from abc1 .ct3 where ts < 1626006833606"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table if not exists n1(ts timestamp, c1 int, c2 nchar(4))"); + if (taos_errno(pRes) != 0) { + printf("failed to create normal table n1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "alter table n1 add column c3 bigint"); + if (taos_errno(pRes) != 0) { + printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "alter table n1 modify column c2 nchar(8)"); + if (taos_errno(pRes) != 0) { + printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "alter table n1 rename column c3 cc3"); + if (taos_errno(pRes) != 0) { + printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "alter table n1 comment 'hello'"); + if (taos_errno(pRes) != 0) { + printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "alter table n1 drop column c1"); + if (taos_errno(pRes) != 0) { + printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into n1 values(now, 'eeee', 8989898899999) (now+9s, 'c333', 940)"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into n1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table jt(ts timestamp, i int) tags(t json)"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table jt, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table jt1 using jt tags('{\"k1\":1, \"k2\":\"hello\"}')"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table jt, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table jt2 using jt tags('')"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table jt2, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into jt1 values(now, 1)"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table jt1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into jt2 values(now, 11)"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table jt2, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + taos_close(pConn); + return 0; +} + +int32_t create_topic() { + printf("create topic\n"); + TAOS_RES* pRes; + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); + if (pConn == NULL) { + return -1; + } + + pRes = taos_query(pConn, "use abc1"); + if (taos_errno(pRes) != 0) { + printf("error in use db, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create topic topic_ctb_column with meta as database abc1"); + if (taos_errno(pRes) != 0) { + printf("failed to create topic topic_ctb_column, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + taos_close(pConn); + return 0; +} + +void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) { + printf("commit %d tmq %p param %p\n", code, tmq, param); +} + +tmq_t* build_consumer() { +#if 0 + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); + assert(pConn != NULL); + + TAOS_RES* pRes = taos_query(pConn, "use abc1"); + if (taos_errno(pRes) != 0) { + printf("error in use db, reason:%s\n", taos_errstr(pRes)); + } + taos_free_result(pRes); +#endif + + tmq_conf_t* conf = tmq_conf_new(); + tmq_conf_set(conf, "group.id", "tg2"); + tmq_conf_set(conf, "client.id", "my app 1"); + tmq_conf_set(conf, "td.connect.user", "root"); + tmq_conf_set(conf, "td.connect.pass", "taosdata"); + tmq_conf_set(conf, "msg.with.table.name", "true"); + tmq_conf_set(conf, "enable.auto.commit", "true"); + tmq_conf_set(conf, "enable.heartbeat.background", "true"); + + /*tmq_conf_set(conf, "experimental.snapshot.enable", "true");*/ + + tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); + tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); + assert(tmq); + tmq_conf_destroy(conf); + return tmq; +} + +tmq_list_t* build_topic_list() { + tmq_list_t* topic_list = tmq_list_new(); + tmq_list_append(topic_list, "topic_ctb_column"); + /*tmq_list_append(topic_list, "tmq_test_db_multi_insert_topic");*/ + return topic_list; +} + +void basic_consume_loop(tmq_t* tmq, tmq_list_t* topics) { + int32_t code; + + if ((code = tmq_subscribe(tmq, topics))) { + fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(code)); + printf("subscribe err\n"); + return; + } + int32_t cnt = 0; + while (running) { + TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 1000); + if (tmqmessage) { + cnt++; + msg_process(tmqmessage); + /*if (cnt >= 2) break;*/ + /*printf("get data\n");*/ + taos_free_result(tmqmessage); + /*} else {*/ + /*break;*/ + /*tmq_commit_sync(tmq, NULL);*/ + }else{ + break; + } + } + + code = tmq_consumer_close(tmq); + if (code) + fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(code)); + else + fprintf(stderr, "%% Consumer closed\n"); +} + +void sync_consume_loop(tmq_t* tmq, tmq_list_t* topics) { + static const int MIN_COMMIT_COUNT = 1; + + int msg_count = 0; + int32_t code; + + if ((code = tmq_subscribe(tmq, topics))) { + fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(code)); + return; + } + + tmq_list_t* subList = NULL; + tmq_subscription(tmq, &subList); + char** subTopics = tmq_list_to_c_array(subList); + int32_t sz = tmq_list_get_size(subList); + printf("subscribed topics: "); + for (int32_t i = 0; i < sz; i++) { + printf("%s, ", subTopics[i]); + } + printf("\n"); + tmq_list_destroy(subList); + + while (running) { + TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 1000); + if (tmqmessage) { + msg_process(tmqmessage); + taos_free_result(tmqmessage); + + /*tmq_commit_sync(tmq, NULL);*/ + /*if ((++msg_count % MIN_COMMIT_COUNT) == 0) tmq_commit(tmq, NULL, 0);*/ + } + } + + code = tmq_consumer_close(tmq); + if (code) + fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(code)); + else + fprintf(stderr, "%% Consumer closed\n"); +} + +void initLogFile() { + char f1[256] = {0}; + char f2[256] = {0}; + + sprintf(f1, "%s/../log/tmq_taosx_tmp.source", dir); + sprintf(f2, "%s/../log/tmq_taosx_tmp.result", dir); + TdFilePtr pFile = taosOpenFile(f1, TD_FILE_TEXT | TD_FILE_TRUNC | TD_FILE_STREAM); + if (NULL == pFile) { + fprintf(stderr, "Failed to open %s for save result\n", f1); + exit(-1); + } + g_fp = pFile; + + TdFilePtr pFile2 = taosOpenFile(f2, TD_FILE_TEXT | TD_FILE_TRUNC | TD_FILE_STREAM); + if (NULL == pFile2) { + fprintf(stderr, "Failed to open %s for save result\n", f2); + exit(-1); + } + char *result[] = { + "{\"type\":\"create\",\"tableName\":\"st1\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":16}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1}]}", + "{\"type\":\"create\",\"tableName\":\"ct0\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":1000},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"ttt\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]}", + "{\"type\":\"create\",\"tableName\":\"ct1\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2000}]}", + "{\"type\":\"create\",\"tableName\":\"ct2\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[]}", + "{\"type\":\"create\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":3000}]}", + "{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":5,\"colName\":\"c4\",\"colType\":5}", + "{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":7,\"colName\":\"c3\",\"colType\":8,\"colLength\":64}", + "{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":1,\"colName\":\"t2\",\"colType\":8,\"colLength\":64}", + "{\"type\":\"alter\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"alterType\":4,\"colName\":\"t1\",\"colValue\":\"5000\",\"colValueNull\":false}", + "{\"type\":\"create\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":10,\"length\":4}],\"tags\":[]}", + "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":5,\"colName\":\"c3\",\"colType\":5}", + "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":7,\"colName\":\"c2\",\"colType\":10,\"colLength\":8}", + "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":10,\"colName\":\"c3\",\"colNewName\":\"cc3\"}", + "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":9}", + "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":6,\"colName\":\"c1\"}", + "{\"type\":\"create\",\"tableName\":\"jt\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"i\",\"type\":4}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", + "{\"type\":\"create\",\"tableName\":\"jt1\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[{\"name\":\"t\",\"type\":15,\"value\":\"{\\\"k1\\\":1,\\\"k2\\\":\\\"hello\\\"}\"}]}", + "{\"type\":\"create\",\"tableName\":\"jt2\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[]}" + }; + + for(int i = 0; i < sizeof(result)/sizeof(result[0]); i++){ + taosFprintfFile(pFile2, result[i]); + taosFprintfFile(pFile2, "\n"); + } + taosCloseFile(&pFile2); +} + +int main(int argc, char* argv[]) { + if(argc == 3 && strcmp(argv[1], "-c") == 0) { + strcpy(dir, argv[2]); + }else{ + strcpy(dir, "../../../sim/psim/cfg"); + } + + printf("env init\n"); + initLogFile(); + + if (init_env() < 0) { + return -1; + } + create_topic(); + + tmq_t* tmq = build_consumer(); + tmq_list_t* topic_list = build_topic_list(); + basic_consume_loop(tmq, topic_list); + /*sync_consume_loop(tmq, topic_list);*/ + taosCloseFile(&g_fp); +} diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 2dc5870c4a0b578b6823f73affd4332e12c8de02..488b623f89162b4948ea913100737ac96bf0f148 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -24,4 +24,7 @@ target_include_directories( PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) +IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + add_dependencies(taosd jemalloc) +ENDIF () SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos)