diff --git a/.lgtm.yml b/.lgtm.yml new file mode 100644 index 0000000000000000000000000000000000000000..fbcedead432f57b7f9ed2161a4a1e500446b489f --- /dev/null +++ b/.lgtm.yml @@ -0,0 +1,402 @@ +########################################################################################## +# Customize file classifications. # +# Results from files under any classifier will be excluded from LGTM # +# statistics. # +########################################################################################## + +########################################################################################## +# Use the `path_classifiers` block to define changes to the default classification of # +# files. # +########################################################################################## + +path_classifiers: + # docs: + # Identify the top-level file called `generate_javadoc.py` as documentation-related. + test: + # Override LGTM's default classification of test files by excluding all files. + - exclude: / + # Classify all files in the top-level directories tests/ and testsuites/ as test code. + - tests + # - testsuites + # Classify all files with suffix `.test` as test code. + # Note: use only forward slash / as a path separator. + # Use ** to indicate an arbitrary parent path. + # Use * to indicate any sequence of characters excluding /. + # Always enclose the expression in double quotes if it includes *. + # - "**/*.test" + # Refine the classifications above by excluding files in test/util/. + # - exclude: test/util + # The default behavior is to tag all files created during the + # build as `generated`. Results are hidden for generated code. You can tag + # further files as being generated by adding them to the `generated` section. + generated: + # Exclude all `*.c` files under the `ui/` directory from classification as + # generated code. + # - exclude: ui/**/*.c + # By default, all files not checked into the repository are considered to be + # 'generated'. + # The default behavior is to tag library code as `library`. Results are hidden + # for library code. You can tag further files as being library code by adding them + # to the `library` section. + library: + - exclude: deps/ + # The default behavior is to tag template files as `template`. Results are hidden + # for template files. You can tag further files as being template files by adding + # them to the `template` section. + template: + #- exclude: path/to/template/code/**/*.c + # Define your own category, for example: 'some_custom_category'. + some_custom_category: + # Classify all files in the top-level directory tools/ (or the top-level file + # called tools). + # - tools + +######################################################################################### +# Use the `queries` block to change the default display of query results. # +######################################################################################### + + # queries: + # Start by hiding the results of all queries. + # - exclude: "*" + # Then include all queries tagged 'security' and 'correctness', and with a severity of + # 'error'. + # - include: + # tags: + # - "security" + # - "correctness" + # severity: "error" + # Specifically hide the results of two queries. + # - exclude: cpp/use-of-goto + # - exclude: java/equals-on-unrelated-types + # Refine by including the `java/command-line-injection` query. + # - include: java/command-line-injection + +######################################################################################### +# Define changes to the default code extraction process. # +# Each block configures the extraction of a single language, and modifies actions in a # +# named step. Every named step includes automatic default actions, # +# except for the 'prepare' step. The steps are performed in the following sequence: # +# prepare # +# after_prepare # +# configure (C/C++ only) # +# python_setup (Python only) # +# before_index # +# index # +########################################################################################## + +######################################################################################### +# Environment variables available to the steps: # +######################################################################################### + +# LGTM_SRC +# The root of the source tree. +# LGTM_WORKSPACE +# An existing (initially empty) folder outside the source tree. +# Used for temporary download and setup commands. + +######################################################################################### +# Use the extraction block to define changes to the default code extraction process # +# for one or more languages. The settings for each language are defined in a child # +# block, with one or more steps. # +######################################################################################### + +extraction: + # Define settings for C/C++ analysis + ##################################### + cpp: + # The `prepare` step exists for customization on LGTM.com only. + prepare: + # # The `packages` section is valid for LGTM.com only. It names Ubuntu packages to + # # be installed. + packages: + - cmake + # Add an `after-prepare` step if you need to run commands after the prepare step. + # Each command should be listed on a separate line. + # This step is useful for C/C++ analysis where you want to prepare the environment + # for the `configure` step without changing the default behavior for that step. + # after_prepare: + #- export GNU_MAKE=make + #- export GIT=true + # The `configure` step generates build configuration files which the `index` step + # then uses to build the codebase. + configure: + command: + - mkdir build + - cd build + - cmake .. + # - ./prepare_deps + # Optional step. You should add a `before_index` step if you need to run commands + # before the `index` step. + # before_index: + # - export BOOST_DIR=$LGTM_SRC/boost + # - export GTEST_DIR=$LGTM_SRC/googletest + # - export HUNSPELL_DIR=$LGTM_SRC/hunspell + # - export CRYPTOPP_DIR=$LGTM_SRC/cryptopp + # The `index` step builds the code and extracts information during the build + # process. + index: + # Override the autobuild process by specifying a list of custom build commands + # to use instead. + build_command: + - cd build + - make + # - $GNU_MAKE -j2 -s + # Specify that all project or solution files should be used for extraction. + # Default: false. + # all_solutions: true + # Specify a list of one or more project or solution files for extraction. + # Default: LGTM chooses the file closest to the root of the repository (this may + # fail if there are multiple candidates). + # solution: + # - myProject.sln + # Specify MSBuild settings + # msbuild: + # Specify a list of additional arguments to MSBuild. Default: empty. + # arguments: /p:Platform=x64 /p:Configuration=Release + # Specify the MSBuild configuration to use, for example, debug or release. + # Default: read from the solution file or files. + # configuration: + # Specify the platform to target, for example: x86, x64, or Any CPU. + # Default: read from the solution file or files. + # platform: + # Specify the MSBuild target. Default: rebuild. + # target: + # Specify whether or not to perform a NuGet restore for extraction. Default: true. + # nuget_restore: false + # Specify a version of Microsoft Visual Studio to use for MSBuild or any custom + # build commands (build_command). For example: + # 10 for Visual Studio 2010 + # 12 for Visual Studio 2012 + # 14 for Visual Studio 2015 + # 15 for Visual Studio 2017 + # Default: read from project files. + # vstools_version: 10 + + # Define settings for C# analysis + ################################## + # csharp: + # The `prepare` step exists for customization on LGTM.com only. + # prepare: + # packages: + # - example_package + # Add an `after-prepare` step if you need to run commands after the `prepare` step. + # Each command should be listed on a separate line. + # after_prepare: + # - export PATH=$LGTM_WORKSPACE/tools:$PATH + # The `index` step builds the code and extracts information during the build + # process. + #index: + # Specify that all project or solution files should be used for extraction. + # Default: false. + # all_solutions: true + # Specify a list of one or more project or solution files for extraction. + # Default: LGTM chooses the file closest to the root of the repository (this may + # fail if there are multiple candidates). + # solution: + # - myProject.sln + # Override the autobuild process by specifying a list of custom build commands + # to use instead. + # build_command: + # - ./example-compile-all.sh + # By default, LGTM analyzes the code by building it. You can override this, + # and tell LGTM not to build the code. Beware that this can lead + # to less accurate results. + # buildless: true + # Specify .NET Core settings. + # dotnet: + # Specify additional arguments to `dotnet build`. + # Default: empty. + # arguments: "example_arg" + # Specify the version of .NET Core SDK to use. + # Default: The version installed on the build machine. + # version: 2.1 + # Specify MSBuild settings. + # msbuild: + # Specify a list of additional arguments to MSBuild. Default: empty. + # arguments: /P:WarningLevel=2 + # Specify the MSBuild configuration to use, for example, debug or release. + # Default: read from the solution file or files. + # configuration: release + # Specify the platform to target, for example: x86, x64, or Any CPU. + # Default: read from the solution file or files. + # platform: x86 + # Specify the MSBuild target. Default: rebuild. + # target: notest + # Specify whether or not to perform a NuGet restore for extraction. Default: true. + # nuget_restore: false + # Specify a version of Microsoft Visual Studio to use for MSBuild or any custom + # build commands (build_command). For example: + # 10 for Visual Studio 2010 + # 12 for Visual Studio 2012 + # 14 for Visual Studio 2015 + # 15 for Visual Studio 2017 + # Default: read from project files + # vstools_version: 10 + # Specify additional options for the extractor, + # for example --fast to perform a faster extraction that produces a smaller + # database. + # extractor: "--fast" + + # Define settings for Go analysis + ################################## + # go: + # The `prepare` step exists for customization on LGTM.com only. + # prepare: + # packages: + # - example_package + # Add an `after-prepare` step if you need to run commands after the `prepare` step. + # Each command should be listed on a separate line. + # after_prepare: + # - export PATH=$LGTM_WORKSPACE/tools:$PATH + # The `index` step builds the code and extracts information during the build + # process. + # index: + # Override the autobuild process by specifying a list of custom build commands + # to use instead. + # build_command: + # - ./compile-all.sh + + # Define settings for Java analysis + #################################### + # java: + # The `prepare` step exists for customization on LGTM.com only. + # prepare: + # packages: + # - example_package + # Add an `after-prepare` step if you need to run commands after the prepare step. + # Each command should be listed on a separate line. + # after_prepare: + # - export PATH=$LGTM_WORKSPACE/tools:$PATH + # The `index` step extracts information from the files in the codebase. + # index: + # Specify Gradle settings. + # gradle: + # Specify the required Gradle version. + # Default: determined automatically. + # version: 4.4 + # Override the autobuild process by specifying a list of custom build commands + # to use instead. + # build_command: ./compile-all.sh + # Specify the Java version required to build the project. + # java_version: 11 + # Specify whether to extract Java .properties files + # Default: false + # properties_files: true + # Specify Maven settings. + # maven: + # Specify the path (absolute or relative) of a Maven settings file to use. + # Default: Maven uses a settings file in the default location, if it exists. + # settings_file: /opt/share/settings.xml + # Specify the path of a Maven toolchains file. + # Default: Maven uses a toolchains file in the default location, if it exists. + # toolchains_file: /opt/share/toolchains.xml + # Specify the required Maven version. + # Default: the Maven version is determined automatically, where feasible. + # version: 3.5.2 + # Specify how XML files should be extracted: + # all = extract all XML files. + # default = only extract XML files named `AndroidManifest.xml`, `pom.xml`, and `web.xml`. + # disabled = do not extract any XML files. + # xml_mode: all + + # Define settings for JavaScript analysis + ########################################## + # javascript: + # The `prepare` step exists for customization on LGTM.com only. + # prepare: + # packages: + # - example_package + # Add an `after-prepare` step if you need to run commands after the prepare step. + # Each command should be listed on a separate line. + # after_prepare: + # - export PATH=$LGTM_WORKSPACE/tools:$PATH + # The `index` step extracts information from the files in the codebase. + # index: + # Specify a list of files and folders to extract. + # Default: The project root directory. + # include: + # - src/js + # Specify a list of files and folders to exclude from extraction. + # exclude: + # - thirdparty/lib + # You can add additional file types for LGTM to extract, by mapping file + # extensions (including the leading dot) to file types. The usual + # include/exclude patterns apply, so, for example, `.jsm` files under + # `thirdparty/lib` will not be extracted. + # filetypes: + # ".jsm": "js" + # ".tmpl": "html" + # Specify a list of glob patterns to include/exclude files from extraction; this + # is applied on top of the include/exclude paths from above; patterns are + # processed in the same way as for path classifiers above. + # Default: include all files with known extensions (such as .js, .ts and .html), + # but exclude files ending in `-min.js` or `.min.js` and folders named `node_modules` + # or `bower_components` + # filters: + # exclude any *.ts files anywhere. + # - exclude: "**/*.ts" + # but include *.ts files under src/js/typescript. + # - include: "src/js/typescript/**/*.ts" + # Specify how TypeScript files should be extracted: + # none = exclude all TypeScript files. + # basic = extract syntactic information from TypeScript files. + # full = extract syntactic and type information from TypeScript files. + # Default: full. + # typescript: basic + # By default, LGTM doesn't extract any XML files. You can override this by + # using the `xml_mode` property and setting it to `all`. + # xml_mode: all + + # Define settings for Python analysis + ###################################### + # python: + # # The `prepare` step exists for customization on LGTM.com only. + # # prepare: + # # # The `packages` section is valid for LGTM.com only. It names packages to + # # # be installed. + # # packages: libpng-dev + # # This step is useful for Python analysis where you want to prepare the + # # environment for the `python_setup` step without changing the default behavior + # # for that step. + # after_prepare: + # - export PATH=$LGTM_WORKSPACE/tools:$PATH + # # This sets up the Python interpreter and virtual environment, ready for the + # # `index` step to extract the codebase. + # python_setup: + # # Specify packages that should NOT be installed despite being mentioned in the + # # requirements.txt file. + # # Default: no package marked for exclusion. + # exclude_requirements: + # - pywin32 + # # Specify a list of pip packages to install. + # # If any of these packages cannot be installed, the extraction will fail. + # requirements: + # - Pillow + # # Specify a list of requirements text files to use to set up the environment, + # # or false for none. Default: any requirements.txt, test-requirements.txt, + # # and similarly named files identified in the codebase are used. + # requirements_files: + # - required-packages.txt + # # Specify a setup.py file to use to set up the environment, or false for none. + # # Default: any setup.py files identified in the codebase are used in preference + # # to any requirements text files. + # setup_py: new-setup.py + # # Override the version of the Python interpreter used for setup and extraction + # # Default: Python 3. + # version: 2 + # # Optional step. You should add a `before_index` step if you need to run commands + # # before the `index` step. + # before_index: + # - antlr4 -Dlanguage=Python3 Grammar.g4 + # # The `index` step extracts information from the files in the codebase. + # index: + # # Specify a list of files and folders to exclude from extraction. + # # Default: Git submodules and Subversion externals. + # exclude: + # - legacy-implementation + # - thirdparty/libs + # filters: + # - exclude: "**/documentation/examples/snippets/*.py" + # - include: "**/documentation/examples/test_application/*" + # include: + # - example/to/include diff --git a/.travis.yml b/.travis.yml index 6e49709c85e9d26d89cd7d7ab8ec8fa78297ef96..eb69370418a9c83c7b8bfe5daa1d6ead19150243 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,8 @@ matrix: - python3-setuptools - valgrind - psmisc + - unixodbc + - unixodbc-dev before_script: - export TZ=Asia/Harbin @@ -54,6 +56,7 @@ matrix: py3ver=`python3 --version|awk '{print $2}'|cut -d "." -f 1,2` && apt install python$py3ver-dev pip3 install psutil + pip3 install guppy3 pip3 install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python3/ cd ${TRAVIS_BUILD_DIR}/tests diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000000000000000000000000000000000..ea50d6ef5a13fed2114868f8a36cd0acace78dd5 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,143 @@ +pipeline { + agent none + environment{ + WK = '/var/lib/jenkins/workspace/TDinternal' + WKC= '/var/lib/jenkins/workspace/TDinternal/community' + } + + stages { + stage('Parallel test stage') { + parallel { + stage('pytest') { + agent{label '184'} + steps { + sh ''' + date + cd ${WKC} + git checkout develop + git pull + git submodule update + cd ${WK} + git checkout develop + git pull + export TZ=Asia/Harbin + date + rm -rf ${WK}/debug + mkdir debug + cd debug + cmake .. > /dev/null + make > /dev/null + cd ${WKC}/tests + #./test-all.sh smoke + ./test-all.sh pytest + date''' + } + } + stage('test_b1') { + agent{label 'master'} + steps { + sh ''' + cd ${WKC} + git checkout develop + git pull + + git submodule update + cd ${WK} + git checkout develop + git pull + export TZ=Asia/Harbin + date + rm -rf ${WK}/debug + mkdir debug + cd debug + cmake .. > /dev/null + make > /dev/null + cd ${WKC}/tests + #./test-all.sh smoke + ./test-all.sh b1 + date''' + } + } + + stage('test_crash_gen') { + agent{label "185"} + steps { + sh ''' + cd ${WKC} + git checkout develop + git pull + + git submodule update + cd ${WK} + git checkout develop + git pull + export TZ=Asia/Harbin + + rm -rf ${WK}/debug + mkdir debug + cd debug + cmake .. > /dev/null + make > /dev/null + cd ${WKC}/tests/pytest + ./crash_gen.sh -a -p -t 4 -s 2000 + date + cd ${WKC}/tests + ./test-all.sh b2 + date + ''' + } + } + + stage('test_valgrind') { + agent{label "186"} + + steps { + sh ''' + cd ${WKC} + git checkout develop + git pull + + git submodule update + cd ${WK} + git checkout develop + git pull + export TZ=Asia/Harbin + date + rm -rf ${WK}/debug + mkdir debug + cd debug + cmake .. > /dev/null + make > /dev/null + cd ${WKC}/tests/pytest + ./valgrind-test.sh 2>&1 > mem-error-out.log + ./handle_val_log.sh + + date + cd ${WKC}/tests + ./test-all.sh b3 + date''' + } + } + stage('connector'){ + agent{label "release"} + steps{ + sh''' + cd ${WORKSPACE} + git checkout develop + cd tests/gotest + bash batchtest.sh + cd ${WORKSPACE}/tests/examples/JDBC/JDBCDemo/ + mvn clean package assembly:single >/dev/null + java -jar target/jdbcChecker-SNAPSHOT-jar-with-dependencies.jar -host 127.0.0.1 + cd ${WORKSPACE}/tests/examples/python/PYTHONConnectorChecker + python3 PythonChecker.py + ''' + } + } + + } + } + + } + +} \ No newline at end of file diff --git a/README.md b/README.md index 522fc0ebc1277684b77589c5c62d061f7b33ce32..36436dd549e22f58caefd82c4a9be4e8aed8d869 100644 --- a/README.md +++ b/README.md @@ -83,12 +83,18 @@ sudo dnf install -y maven ## Get the source codes -- github: +First of all, you may clone the source codes from github: ```bash git clone https://github.com/taosdata/TDengine.git cd TDengine ``` +The connectors for go & grafana have been moved to separated repositories, +so you should run this command in the TDengine directory to install them: +```bash +git submodule update --init --recursive +``` + ## Build TDengine ### On Linux platform diff --git a/alert/README.md b/alert/README.md index 23179669349ebf94f3774c6101c06c2e375ef059..547f3a0381a74714b1f6c8c74b861678b3805619 100644 --- a/alert/README.md +++ b/alert/README.md @@ -61,7 +61,7 @@ The use of each configuration item is: * **port**: This is the `http` service port which enables other application to manage rules by `restful API`. * **database**: rules are stored in a `sqlite` database, this is the path of the database file (if the file does not exist, the alert application creates it automatically). -* **tdengine**: connection string of `TDEngine` server, note in most cases the database information should be put in a rule, thus it should NOT be included here. +* **tdengine**: connection string of `TDEngine` server, note the database name should be put in the `sql` field of a rule in most cases, thus it should NOT be included in the string. * **log > level**: log level, could be `production` or `debug`. * **log > path**: log output file path. * **receivers > alertManager**: the alert application pushes alerts to `AlertManager` at this URL. diff --git a/alert/README_cn.md b/alert/README_cn.md index ec6e4566c8eb9fa2142c37b2b3e1b1a04f783a9a..938b23a58406f5d6f279191a47dc957c446911ce 100644 --- a/alert/README_cn.md +++ b/alert/README_cn.md @@ -58,7 +58,7 @@ $ go build * **port**:报警监测程序支持使用 `restful API` 对规则进行管理,这个参数用于配置 `http` 服务的侦听端口。 * **database**:报警监测程序将规则保存到了一个 `sqlite` 数据库中,这个参数用于指定数据库文件的路径(不需要提前创建这个文件,如果它不存在,程序会自动创建它)。 -* **tdengine**:`TDEngine` 的连接信息,一般来说,数据库信息应该在报警规则中指定,所以这里 **不** 应包含这一部分信息。 +* **tdengine**:`TDEngine` 的连接字符串,一般来说,数据库名应该在报警规则的 `sql` 语句中指定,所以这个字符串中 **不** 应包含数据库名。 * **log > level**:日志的记录级别,可选 `production` 或 `debug`。 * **log > path**:日志文件的路径。 * **receivers > alertManager**:报警监测程序会将报警推送到 `AlertManager`,在这里指定 `AlertManager` 的接收地址。 diff --git a/cmake/define.inc b/cmake/define.inc index 84df6f54055cff0b6fe7f1820d46958787ca3c46..6e64c2709abee366856a61916c6905363ea2002d 100755 --- a/cmake/define.inc +++ b/cmake/define.inc @@ -48,6 +48,7 @@ ENDIF () IF (TD_LINUX_64) ADD_DEFINITIONS(-D_M_X64) ADD_DEFINITIONS(-D_TD_LINUX_64) + MESSAGE(STATUS "linux64 is defined") SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g3 -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") ADD_DEFINITIONS(-DUSE_LIBICONV) ENDIF () @@ -55,30 +56,38 @@ ENDIF () IF (TD_LINUX_32) ADD_DEFINITIONS(-D_TD_LINUX_32) ADD_DEFINITIONS(-DUSE_LIBICONV) - SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -munaligned-access -fpack-struct=8 -latomic -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") + MESSAGE(STATUS "linux32 is defined") + SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -munaligned-access -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") ENDIF () IF (TD_ARM_64) ADD_DEFINITIONS(-D_M_X64) - ADD_DEFINITIONS(-D_TD_ARM_64_) + ADD_DEFINITIONS(-D_TD_ARM_64) ADD_DEFINITIONS(-D_TD_ARM_) ADD_DEFINITIONS(-DUSE_LIBICONV) + MESSAGE(STATUS "arm64 is defined") SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") ENDIF () IF (TD_ARM_32) - ADD_DEFINITIONS(-D_TD_ARM_32_) + ADD_DEFINITIONS(-D_TD_ARM_32) ADD_DEFINITIONS(-D_TD_ARM_) - SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") + ADD_DEFINITIONS(-DUSE_LIBICONV) + MESSAGE(STATUS "arm32 is defined") + SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types ") ENDIF () IF (TD_MIPS_64) ADD_DEFINITIONS(-D_TD_MIPS_64_) + ADD_DEFINITIONS(-DUSE_LIBICONV) + MESSAGE(STATUS "mips64 is defined") SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g3 -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") ENDIF () IF (TD_MIPS_32) ADD_DEFINITIONS(-D_TD_MIPS_32_) + ADD_DEFINITIONS(-DUSE_LIBICONV) + MESSAGE(STATUS "mips32 is defined") SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g3 -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") ENDIF () @@ -86,6 +95,7 @@ IF (TD_APLHINE) SET(COMMON_FLAGS "${COMMON_FLAGS} -largp") link_libraries(/usr/lib/libargp.a) ADD_DEFINITIONS(-D_ALPINE) + MESSAGE(STATUS "aplhine is defined") ENDIF () IF (TD_LINUX) @@ -95,7 +105,7 @@ IF (TD_LINUX) ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT) IF (TD_NINGSI_60) - ADD_DEFINITIONS(-D_TD_NINGSI_60_) + ADD_DEFINITIONS(-D_TD_NINGSI_60) MESSAGE(STATUS "set ningsi macro to true") ENDIF () @@ -118,6 +128,7 @@ IF (TD_DARWIN_64) ADD_DEFINITIONS(-DDARWIN) ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT) ADD_DEFINITIONS(-DUSE_LIBICONV) + MESSAGE(STATUS "darwin64 is defined") SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -Wno-missing-braces -fPIC -g -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") SET(DEBUG_FLAGS "-O0 -DDEBUG") SET(RELEASE_FLAGS "-O0") @@ -147,11 +158,13 @@ IF (TD_WINDOWS_64) ADD_DEFINITIONS(-D_M_X64) ADD_DEFINITIONS(-D_TD_WINDOWS_64) ADD_DEFINITIONS(-DUSE_LIBICONV) + MESSAGE(STATUS "windows64 is defined") ENDIF () IF (TD_WINDOWS_32) ADD_DEFINITIONS(-D_TD_WINDOWS_32) ADD_DEFINITIONS(-DUSE_LIBICONV) + MESSAGE(STATUS "windows32 is defined") ENDIF () INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc) diff --git a/cmake/env.inc b/cmake/env.inc index 67b934119d0e2de95c2ec60741cc4b78b7dbb267..18a6fea51d7ab4c6a4068efafc478360737df9be 100755 --- a/cmake/env.inc +++ b/cmake/env.inc @@ -45,7 +45,7 @@ IF (${CMAKE_BUILD_TYPE} MATCHES "Debug") ELSEIF (${CMAKE_BUILD_TYPE} MATCHES "Release") MESSAGE(STATUS "Build Release Version") ELSE () - IF (TD_WINDOWS_64) + IF (TD_WINDOWS) SET(CMAKE_BUILD_TYPE "Release") MESSAGE(STATUS "Build Release Version in Windows as default") ELSE () diff --git a/cmake/install.inc b/cmake/install.inc index 0531d4004839b6f61115d0551414f91fb13f2db6..dfca758b9362c96bec0ce45aa385d54a4e75a9e5 100755 --- a/cmake/install.inc +++ b/cmake/install.inc @@ -10,31 +10,28 @@ ELSEIF (TD_WINDOWS) SET(CMAKE_INSTALL_PREFIX C:/TDengine) ENDIF () - IF (NOT TD_GODLL) - #INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/go DESTINATION connector) - #INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/grafana DESTINATION connector) - INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/python DESTINATION connector) - INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/tests/examples DESTINATION .) - INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/packaging/cfg DESTINATION .) - INSTALL(FILES ${TD_COMMUNITY_DIR}/src/inc/taos.h DESTINATION include) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp DESTINATION driver) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.dll DESTINATION driver) + INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/go DESTINATION connector) + INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/nodejs DESTINATION connector) + INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/python DESTINATION connector) + INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/tests/examples DESTINATION .) + INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/packaging/cfg DESTINATION .) + INSTALL(FILES ${TD_COMMUNITY_DIR}/src/inc/taos.h DESTINATION include) + INSTALL(FILES ${TD_COMMUNITY_DIR}/src/inc/taoserror.h DESTINATION include) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp DESTINATION driver) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.dll DESTINATION driver) - IF (TD_POWER) - INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/power.exe DESTINATION .) - ELSE () - INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .) - ENDIF () + IF (TD_POWER) + INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/power.exe DESTINATION .) + ELSE () + INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .) + INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taosdemo.exe DESTINATION .) + ENDIF () - #INSTALL(TARGETS taos RUNTIME DESTINATION driver) - #INSTALL(TARGETS shell RUNTIME DESTINATION .) - IF (TD_MVN_INSTALLED) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.0-dist.jar DESTINATION connector/jdbc) - ENDIF () - ELSE () - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/libtaos.dll DESTINATION driver) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/libtaos.dll.a DESTINATION driver) + #INSTALL(TARGETS taos RUNTIME DESTINATION driver) + #INSTALL(TARGETS shell RUNTIME DESTINATION .) + IF (TD_MVN_INSTALLED) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.8-dist.jar DESTINATION connector/jdbc) ENDIF () ELSEIF (TD_DARWIN) SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh") diff --git a/cmake/version.inc b/cmake/version.inc index 52d62fca6581a4c496531335ee836342b5cc1f24..a248f76f48ede5f1f483943c08fce6604756b6d4 100644 --- a/cmake/version.inc +++ b/cmake/version.inc @@ -4,7 +4,7 @@ PROJECT(TDengine) IF (DEFINED VERNUMBER) SET(TD_VER_NUMBER ${VERNUMBER}) ELSE () - SET(TD_VER_NUMBER "2.0.3.0") + SET(TD_VER_NUMBER "2.0.6.0") ENDIF () IF (DEFINED VERCOMPATIBLE) @@ -42,6 +42,12 @@ IF (DEFINED CPUTYPE) ELSE () IF (TD_WINDOWS_32) SET(TD_VER_CPUTYPE "x86") + ELSEIF (TD_LINUX_32) + SET(TD_VER_CPUTYPE "x86") + ELSEIF (TD_ARM_32) + SET(TD_VER_CPUTYPE "x86") + ELSEIF (TD_MIPS_32) + SET(TD_VER_CPUTYPE "x86") ELSE () SET(TD_VER_CPUTYPE "x64") ENDIF () diff --git a/deps/zlib-1.2.11/CMakeLists.txt b/deps/zlib-1.2.11/CMakeLists.txt index 5502070819894480a0d7a7320d0f113cc545a0ce..f83aa70085491fb6575c0a6bf93252192cddd040 100644 --- a/deps/zlib-1.2.11/CMakeLists.txt +++ b/deps/zlib-1.2.11/CMakeLists.txt @@ -1,8 +1,11 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) -IF (TD_LINUX) - INCLUDE_DIRECTORIES(inc) - AUX_SOURCE_DIRECTORY(src SRC) - ADD_LIBRARY(z ${SRC}) -ENDIF () \ No newline at end of file +IF (TD_WINDOWS) + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /WX-") + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /WX-") +ENDIF() + +INCLUDE_DIRECTORIES(inc) +AUX_SOURCE_DIRECTORY(src SRC) +ADD_LIBRARY(z ${SRC}) diff --git a/deps/zlib-1.2.11/inc/zconf.h b/deps/zlib-1.2.11/inc/zconf.h index 9b83d3a898662f8802154e4bd600cc2dde545756..b056fc5cf45fc34818827449b649ca48f62b216b 100644 --- a/deps/zlib-1.2.11/inc/zconf.h +++ b/deps/zlib-1.2.11/inc/zconf.h @@ -472,7 +472,7 @@ typedef uint64_t z_crc_t; #endif #ifndef Z_SOLO #if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) -#if (_WIN64) +#if defined(_WIN64) || defined(_WIN32) #include #include #else diff --git a/deps/zlib-1.2.11/src/zconf.h b/deps/zlib-1.2.11/src/zconf.h index 361c098281905400d304372852df52989d51f463..937d2b70ca7c303bae39f938d09b193d335b06e0 100644 --- a/deps/zlib-1.2.11/src/zconf.h +++ b/deps/zlib-1.2.11/src/zconf.h @@ -472,7 +472,7 @@ typedef uLong FAR uLongf; #endif #ifndef Z_SOLO # if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) -#if (_WIN64) +#if defined(_WIN64) || defined(_WIN32) #include #include #else diff --git a/documentation/tdenginedocs-cn/advanced-features/index.html b/documentation/tdenginedocs-cn/advanced-features/index.html index 9a1b908cd5bae690f747c27e46416e12e110480e..b4953b4dd482341ce937f56b806b682ff7145409 100644 --- a/documentation/tdenginedocs-cn/advanced-features/index.html +++ b/documentation/tdenginedocs-cn/advanced-features/index.html @@ -51,8 +51,8 @@ INTERVAL(1M)
  • mseconds:查询数据库更新的时间间隔,单位为毫秒。一般设置为1000毫秒。返回值为指向TDengine_SUB 结构的指针,如果返回为空,表示失败。

  • TAOS_ROW taos_consume(TAOS_SUB *tsub)

    该函数用来获取订阅的结果,用户应用程序将其置于一个无限循环语句。如果数据库有新记录到达,该API将返回该最新的记录。如果没有新的记录,该API将阻塞。如果返回值为空,说明系统出错。参数说明:

    • tsub:taos_subscribe的结构体指针。

  • void taos_unsubscribe(TAOS_SUB *tsub)

    取消订阅。应用程序退出时,务必调用该函数以避免资源泄露。

  • -
  • int taos_num_subfields(TAOS_SUB *tsub)

    获取返回的一行记录中数据包含多少列。

  • -
  • TAOS_FIELD *taos_fetch_subfields(TAOS_SUB *tsub)

    获取每列数据的属性(数据类型、名字、长度),与taos_num_subfileds配合使用,可解析返回的每行数据。

  • +
  • int taos_num_fields(TAOS_SUB *tsub)

    获取返回的一行记录中数据包含多少列。

  • +
  • TAOS_FIELD *taos_fetch_fields(TAOS_SUB *tsub)

    获取每列数据的属性(数据类型、名字、长度),与taos_num_subfileds配合使用,可解析返回的每行数据。

  • 示例代码:请看安装包中的的示范程序

    缓存 (Cache)

    TDengine采用时间驱动缓存管理策略(First-In-First-Out,FIFO),又称为写驱动的缓存管理机制。这种策略有别于读驱动的数据缓存模式(Least-Recent-Use,LRU),直接将最近写入的数据保存在系统的缓存中。当缓存达到临界值的时候,将最早的数据批量写入磁盘。一般意义上来说,对于物联网数据的使用,用户最为关心最近产生的数据,即当前状态。TDengine充分利用了这一特性,将最近到达的(当前状态)数据保存在缓存中。

    diff --git a/documentation/tdenginedocs-cn/connector/index.html b/documentation/tdenginedocs-cn/connector/index.html index 3167c1521f099f8acd7ae237cc37bd5867ee209a..34ea19813fbd7a9f70074ff109308b37ba7b647a 100644 --- a/documentation/tdenginedocs-cn/connector/index.html +++ b/documentation/tdenginedocs-cn/connector/index.html @@ -64,9 +64,9 @@

    该API用来获取最新消息,应用程序一般会将其置于一个无限循环语句中。其中参数tsub是taos_subscribe的返回值。如果数据库有新的记录,该API将返回,返回参数是一行记录。如果没有新的记录,该API将阻塞。如果返回值为空,说明系统出错,需要检查系统是否还在正常运行。

  • void taos_unsubscribe(TAOS_SUB *tsub)

    该API用于取消订阅,参数tsub是taos_subscribe的返回值。应用程序退出时,需要调用该API,否则有资源泄露。

  • -
  • int taos_num_subfields(TAOS_SUB *tsub)

    +
  • int taos_num_fields(TAOS_SUB *tsub)

    该API用来获取返回的一排数据中数据的列数

  • -
  • TAOS_FIELD *taos_fetch_subfields(TAOS_RES *res)

    +
  • TAOS_FIELD *taos_fetch_fields(TAOS_RES *res)

    该API用来获取每列数据的属性(数据类型、名字、字节数),与taos_num_subfileds配合使用,可用来解析返回的一排数据。

  • Java Connector

    @@ -259,4 +259,4 @@ conn.close() _ "taosSql" )

    taosSql驱动包内采用cgo模式,调用了TDengine的C/C++同步接口,与TDengine进行交互,因此,在数据库操作执行完成之前,客户端应用将处于阻塞状态。单个数据库连接,在同一时刻只能有一个线程调用API。客户应用可以建立多个连接,进行多线程的数据写入或查询处理。

    -

    更多使用的细节,请参考下载目录中的示例源码。

    回去 \ No newline at end of file +

    更多使用的细节,请参考下载目录中的示例源码。

    回去 diff --git a/documentation/tdenginedocs-en/connector/index.html b/documentation/tdenginedocs-en/connector/index.html index 0f9e6b4717c1c32716046a38bef18268cc2e0408..ea1f75ae00300a84560b93156853152ac8f77398 100644 --- a/documentation/tdenginedocs-en/connector/index.html +++ b/documentation/tdenginedocs-en/connector/index.html @@ -72,9 +72,9 @@ The API is used to start a subscription session by given a handle. The parameter The API used to get the new data from a TDengine server. It should be put in an infinite loop. The parameter tsub is the handle returned by taos_subscribe. If new data are updated, the API will return a row of the result. Otherwise, the API is blocked until new data arrives. If NULL pointer is returned, it means an error occurs.

  • void taos_unsubscribe(TAOS_SUB *tsub) Stop a subscription session by the handle returned by taos_subscribe.

  • -
  • int taos_num_subfields(TAOS_SUB *tsub) +

  • int taos_num_fields(TAOS_SUB *tsub) The API used to get the number of fields in a row.

  • -
  • TAOS_FIELD *taos_fetch_subfields(TAOS_RES *res) +

  • TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) The API used to get the description of each column.

  • Java Connector

    @@ -351,4 +351,4 @@ promise2.then(function(result) { })

    Example

    An example of using the NodeJS connector to create a table with weather data and create and execute queries can be found here (The preferred method for using the connector)

    -

    An example of using the NodeJS connector to achieve the same things but without all the object wrappers that wrap around the data returned to achieve higher functionality can be found here

    Back \ No newline at end of file +

    An example of using the NodeJS connector to achieve the same things but without all the object wrappers that wrap around the data returned to achieve higher functionality can be found here

    Back diff --git a/documentation20/webdocs/markdowndocs/Evaluation-ch.md b/documentation20/webdocs/markdowndocs/Evaluation-ch.md index 7d09d0dd33a332d4b74dd16bd64cb4e9503fd07d..9e7e0ec6aa8b60bfa9dbe603a45a265a1d1eba00 100644 --- a/documentation20/webdocs/markdowndocs/Evaluation-ch.md +++ b/documentation20/webdocs/markdowndocs/Evaluation-ch.md @@ -11,7 +11,7 @@ TDengine的模块之一是时序数据库。但除此之外,为减少研发的 * __全栈时序数据处理引擎__:将数据库、消息队列、缓存、流式计算等功能融为一体,应用无需再集成Kafka/Redis/HBase/Spark/HDFS等软件,大幅降低应用开发和维护的复杂度成本。 * __强大的分析功能__:无论是十年前还是一秒钟前的数据,指定时间范围即可查询。数据可在时间轴上或多个设备上进行聚合。即席查询可通过Shell, Python, R, Matlab随时进行。 * __与第三方工具无缝连接__:不用一行代码,即可与Telegraf, Grafana, EMQ, Prometheus, Matlab, R等集成。后续将支持OPC, Hadoop, Spark等, BI工具也将无缝连接。 -* __零运维成本、零学习成本__:安装、集群一秒搞定,无需分库分表,实时备份。标准SQL,支持JDBC, RESTful, 支持Python/Java/C/C++/Go, 与MySQL相似,零学习成本。 +* __零运维成本、零学习成本__:安装集群简单快捷,无需分库分表,实时备份。类似标准SQL,支持RESTful, 支持Python/Java/C/C++/C#/Go/Node.js, 与MySQL相似,零学习成本。 采用TDengine,可将典型的物联网、车联网、工业互联网大数据平台的总拥有成本大幅降低。但需要指出的是,因充分利用了物联网时序数据的特点,它无法用来处理网络爬虫、微博、微信、电商、ERP、CRM等通用型数据。 diff --git a/documentation20/webdocs/markdowndocs/Getting Started-ch.md b/documentation20/webdocs/markdowndocs/Getting Started-ch.md index 210f0921bab40990ddb7b18e3a60586c028b58d2..beb0c639ae7f5d6b5535b194f70d806305208492 100644 --- a/documentation20/webdocs/markdowndocs/Getting Started-ch.md +++ b/documentation20/webdocs/markdowndocs/Getting Started-ch.md @@ -30,13 +30,13 @@ TDengine软件分为服务器、客户端和报警模块三部分,目前2.0版 - TDengine-alert-2.0.0-Linux-x64.tar.gz (8.1M) -目前,TDengine只支持在使用[`systemd`](https://en.wikipedia.org/wiki/Systemd)做进程服务管理的linux系统上安装。其他linux系统的支持正在开发中。用`which`命令来检测系统中是否存在`systemd`: +目前,TDengine只支持在使用[`systemd`](https://en.wikipedia.org/wiki/Systemd)做进程服务管理的linux系统上安装。其他linux系统的支持正在开发中。用`which systemctl`命令来检测系统中是否存在`systemd`包: ```cmd -which systemd +which systemctl ``` -如果系统中不存在`systemd`命令,请考虑[通过源码安装](#通过源码安装)TDengine。 +如果系统中不存在`systemd`包,请考虑[通过源码安装](#通过源码安装)TDengine。 具体的安装过程,请参见TDengine多种安装包的安装和卸载。 @@ -68,7 +68,7 @@ systemctl status taosd taos ``` -如果TDengine终端链接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考[FAQ](https://www.taosdata.com/cn/faq/)来解决终端链接服务端失败的问题)。TDengine终端的提示符号如下: +如果TDengine终端连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考[FAQ](https://www.taosdata.com/cn/faq/)来解决终端连接服务端失败的问题)。TDengine终端的提示符号如下: ```cmd taos> @@ -99,8 +99,8 @@ Query OK, 2 row(s) in set (0.001700s) - -c, --config-dir: 指定配置文件目录,默认为_/etc/taos_ - -h, --host: 指定服务的IP地址,默认为本地服务 - -s, --commands: 在不进入终端的情况下运行TDengine命令 -- -u, -- user: 链接TDengine服务器的用户名,缺省为root -- -p, --password: 链接TDengine服务器的密码,缺省为taosdata +- -u, -- user: 连接TDengine服务器的用户名,缺省为root +- -p, --password: 连接TDengine服务器的密码,缺省为taosdata - -?, --help: 打印出所有命令行参数 示例: diff --git a/documentation20/webdocs/markdowndocs/Getting Started.md b/documentation20/webdocs/markdowndocs/Getting Started.md index 00d97d3d9cd3d2ce8317938eb9e46ae74b48dab1..4d34cb49f4a84ac6c9d63e47bc8230c150b9013e 100644 --- a/documentation20/webdocs/markdowndocs/Getting Started.md +++ b/documentation20/webdocs/markdowndocs/Getting Started.md @@ -16,13 +16,13 @@ Three different packages are provided, please pick up the one you like.
  • TDengine DEB package (1.7M)
  • TDengine Tarball (3.0M)
  • -For the time being, TDengine only supports installation on Linux systems using [`systemd`](https://en.wikipedia.org/wiki/Systemd) as the service manager. To check if your system has *systemd*, use the _which_ command. +For the time being, TDengine only supports installation on Linux systems using [`systemd`](https://en.wikipedia.org/wiki/Systemd) as the service manager. To check if your system has *systemd* package, use the _which systemctl_ command. ```cmd -which systemd +which systemctl ``` -If the `systemd` command is not found, please [install from source code](#Install-from-Source). +If the `systemd` package is not found, please [install from source code](#Install-from-Source). ### Running TDengine diff --git a/documentation20/webdocs/markdowndocs/Model-ch.md b/documentation20/webdocs/markdowndocs/Model-ch.md index bf04ce8388145d5b66d9658897744a9a93cdfaf0..d698e3daaf60c02a76da8470d11fc292b93df058 100644 --- a/documentation20/webdocs/markdowndocs/Model-ch.md +++ b/documentation20/webdocs/markdowndocs/Model-ch.md @@ -19,7 +19,7 @@ CREATE DATABASE power KEEP 365 DAYS 10 BLOCKS 4; USE power; ``` -就当前链接里操作的库换为power,否则对具体表操作前,需要使用“库名.表名”来指定库的名字。 +就当前连接里操作的库换为power,否则对具体表操作前,需要使用“库名.表名”来指定库的名字。 **注意:** diff --git a/documentation20/webdocs/markdowndocs/More on System Architecture-ch.md b/documentation20/webdocs/markdowndocs/More on System Architecture-ch.md index 8e5eeee1c5a6c96ddda1281110766a12a56b8d12..44d572268de04662c190a6a5975c784b38aad117 100644 --- a/documentation20/webdocs/markdowndocs/More on System Architecture-ch.md +++ b/documentation20/webdocs/markdowndocs/More on System Architecture-ch.md @@ -196,7 +196,7 @@ TDengine是基于硬件、软件系统不可靠、一定会有故障的假设进 **对外服务地址**:TDengine集群可以容纳单台、多台甚至几千台物理节点。应用只需要向集群中任何一个物理节点的publicIp发起连接即可。启动CLI应用taos时,选项-h需要提供的就是publicIp。 -**master/secondIp**:每一个dnode都需要配置一个masterIp。dnode启动后,将对配置的masterIp发起加入集群的连接请求。masterIp是已经创建的集群中的任何一个节点的privateIp,对于集群中的第一个节点,就是它自己的privateIp。为保证连接成功,每个dnode还可配置secondIp, 该IP地址也是已创建的集群中的任何一个节点的privateIp。如果一个节点连接masterIp失败,它将试图链接secondIp。 +**master/secondIp**:每一个dnode都需要配置一个masterIp。dnode启动后,将对配置的masterIp发起加入集群的连接请求。masterIp是已经创建的集群中的任何一个节点的privateIp,对于集群中的第一个节点,就是它自己的privateIp。为保证连接成功,每个dnode还可配置secondIp, 该IP地址也是已创建的集群中的任何一个节点的privateIp。如果一个节点连接masterIp失败,它将试图连接secondIp。 dnode启动后,会获知集群的mnode IP列表,并且定时向mnode发送状态信息。 @@ -245,4 +245,4 @@ vnode(虚拟数据节点)保存采集的时序数据,而且查询、计算都 -**Note:**目前集群功能仅仅限于企业版 \ No newline at end of file +**Note:**目前集群功能仅仅限于企业版 diff --git a/documentation20/webdocs/markdowndocs/Queries-ch.md b/documentation20/webdocs/markdowndocs/Queries-ch.md index 1394338f5420d9b2e2dbc2206879ac36a5c52cf8..960bb39e6323fe590905de62d2a1021adb19d176 100644 --- a/documentation20/webdocs/markdowndocs/Queries-ch.md +++ b/documentation20/webdocs/markdowndocs/Queries-ch.md @@ -29,23 +29,9 @@ Query OK, 2 row(s) in set (0.001100s) 具体的查询语法请看TAOS SQL 。 ## 多表聚合查询 +物联网场景中,往往同一个类型的数据采集点有多个。TDengine采用超级表(STable)的概念来描述某一个类型的数据采集点,一张普通的表来描述一个具体的数据采集点。同时TDengine使用标签来描述数据采集点的静态属性,一个具体的数据采集点有具体的标签值。通过指定标签的过滤条件,TDengine提供了一高效的方法将超级表(某一类型的数据采集点)所属的子表进行聚合查询。对普通表的聚合函数以及绝大部分操作都适用于超级表,语法完全一样。 -TDengine对每个数据采集点单独建表,但在实际应用中经常需要对不同的采集点数据进行聚合。为高效的进行聚合操作,TDengine引入超级表(STable)的概念。超级表用来代表一特定类型的数据采集点,它是包含多张表的表集合,集合里每张表的模式(schema)完全一致,但每张表都带有自己的静态标签,标签可以多个,可以随时增加、删除和修改。 - -应用可通过指定标签的过滤条件,对一个STable下的全部或部分表进行聚合或统计操作,这样大大简化应用的开发。其具体流程如下图所示: - -
    - -
    多表聚合查询原理图
    - -1:应用将一个查询条件发往系统;2: taosc将超级表的名字发往 Meta Node(管理节点);3:管理节点将超级表所拥有的 vnode 列表发回 taosc;4:taosc将计算的请求连同标签过滤条件发往这些vnode对应的多个数据节点;5:每个vnode先在内存里查找出自己节点里符合标签过滤条件的表的集合,然后扫描存储的时序数据,完成相应的聚合计算,将结果返回给taosc;6:taosc将多个数据节点返回的结果做最后的聚合,将其返回给应用。 - -由于TDengine在vnode内将标签数据与时序数据分离存储,通过先在内存里过滤标签数据,将需要扫描的数据集大幅减少,大幅提升聚合计算速度。同时,由于数据分布在多个vnode/dnode,聚合计算操作在多个vnode里并发进行,又进一步提升了聚合的速度。 - -对普通表的聚合函数以及绝大部分操作都适用于超级表,语法完全一样,细节请看 TAOS SQL。 - -比如:在TAOS Shell,查找所有智能电表采集的电压平均值,并按照location分组 - +**示例1**:在TAOS Shell,查找北京所有智能电表采集的电压平均值,并按照location分组 ```mysql taos> SELECT AVG(voltage) FROM meters GROUP BY location; avg(voltage) | location | @@ -55,6 +41,18 @@ taos> SELECT AVG(voltage) FROM meters GROUP BY location; Query OK, 2 row(s) in set (0.002136s) ``` +**示例2**:在TAOS shell, 查找groupId为2的所有智能电表过去24小时的记录条数,电流的最大值 + +```mysql +taos> SELECT count(*), max(current) FROM meters where groupId = 2 and ts > now - 24h; + cunt(*) | max(current) | +================================== + 5 | 13.4 | +Query OK, 1 row(s) in set (0.002136s) +``` + +TDengine仅容许对属于同一个超级表的表之间进行聚合查询,不同超级表之间的聚合查询不支持。在TAOS SQL 一章,查询类操作都会注明是否支持超级表。 + ## 降采样查询、插值 物联网场景里,经常需要通过降采样(down sampling)将采集的数据按时间段进行聚合。TDengine 提供了一个简便的关键词 interval 让按照时间窗口的查询操作变得极为简单。比如,将智能电表 d1001 采集的电流值每10秒钟求和 @@ -66,9 +64,9 @@ taos> SELECT sum(current) FROM d1001 INTERVAL(10s); 2018-10-03 14:38:10.000 | 24.900000572 | Query OK, 2 row(s) in set (0.000883s) ``` -降采样操作也适用于超级表,比如:将所有智能电表采集的电流值每秒钟求和 +降采样操作也适用于超级表,比如:将北京所有智能电表采集的电流值每秒钟求和 ```mysql -taos> SELECT SUM(current) FROM meters INTERVAL(1s); +taos> SELECT SUM(current) FROM meters where location like "Beijing%" INTERVAL(1s); ts | sum(current) | ====================================================== 2018-10-03 14:38:04.000 | 10.199999809 | diff --git a/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md b/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md index 3c7f6987c72c064810c0666a55bd53511d4f67a4..4082d72f112e8ff62d2e8b2c8b15391dd6f39d8a 100644 --- a/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md +++ b/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md @@ -98,12 +98,12 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic KEEP参数是指修改数据文件保存的天数,缺省值为3650,取值范围[days, 365000],必须大于或等于days参数值。 ```mysql - ALTER DATABASE db_name QUORUM 365; + ALTER DATABASE db_name QUORUM 2; ``` QUORUM参数是指数据写入成功所需要的确认数。取值范围[1, 3]。对于异步复制,quorum设为1,具有master角色的虚拟节点自己确认即可。对于同步复制,需要至少大于等于2。原则上,Quorum >=1 并且 Quorum <= replica(副本数),这个参数在启动一个同步模块实例时需要提供。 ```mysql - ALTER DATABASE db_name BLOCKS 365; + ALTER DATABASE db_name BLOCKS 100; ``` BLOCKS参数是每个VNODE (TSDB) 中有多少cache大小的内存块,因此一个VNODE的用的内存大小粗略为(cache * blocks)。取值范围[3, 1000]。 @@ -124,7 +124,8 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic 说明: 1) 表的第一个字段必须是TIMESTAMP,并且系统自动将其设为主键; 2) 表名最大长度为193; - 3) 表的每行长度不能超过16k个字符; + 3) 表的每行长度不能超过16k个字符; + 4) 子表名只能由字母、数字和下划线组成,且不能以数字开头 5) 使用数据类型binary或nchar,需指定其最长的字节数,如binary(20),表示20字节; - **删除数据表** @@ -1019,5 +1020,5 @@ SELECT AVG(current),MAX(current),LEASTSQUARES(current, start_val, step_val), PER - 表名最大长度为193,每行数据最大长度16k个字符 - 列名最大长度为65,最多允许1024列,最少需要2列,第一列必须是时间戳 - 标签最多允许128个,可以0个,标签总长度不超过16k个字符 -- SQL语句最大长度65480个字符,但可通过系统配置参数maxSQLLength修改,最长可配置为8M +- SQL语句最大长度65480个字符,但可通过系统配置参数maxSQLLength修改,最长可配置为1M - 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制 diff --git a/documentation20/webdocs/markdowndocs/administrator-ch.md b/documentation20/webdocs/markdowndocs/administrator-ch.md index 50b388650b361fcfc0a5faca852f08f54fb0d26b..4b274e05e6e392879fc887ec1137968270a8e4b8 100644 --- a/documentation20/webdocs/markdowndocs/administrator-ch.md +++ b/documentation20/webdocs/markdowndocs/administrator-ch.md @@ -82,8 +82,7 @@ TDengine系统后台服务由taosd提供,可以在配置文件taos.cfg里修 下面仅仅列出一些重要的配置参数,更多的参数请看配置文件里的说明。各个参数的详细介绍及作用请看前述章节,而且这些参数的缺省配置都是工作的,一般无需设置。**注意:配置修改后,需要重启*taosd*服务才能生效。** -- firstEp: taosd启动时,主动连接的集群中第一个dnode的end point, 默认值为localhost:6030。 -- secondEp: taosd启动时,如果first连接不上,尝试连接集群中第二个dnode的end point, 默认值为空。 +- firstEp: taosd启动时,主动连接的集群中首个dnode的end point, 默认值为localhost:6030。 - fqdn:数据节点的FQDN,缺省为操作系统配置的第一个hostname。如果习惯IP地址访问,可设置为该节点的IP地址。 - serverPort:taosd启动后,对外服务的端口号,默认值为6030。 - httpPort: RESTful服务使用的端口号,所有的HTTP请求(TCP)都需要向该接口发起查询/写入请求, 默认值为6041。 @@ -130,9 +129,25 @@ TDengine集群中加入一个新的dnode时,涉及集群相关的一些参数 - statusInterval: dnode向mnode报告状态时长。单位为秒,默认值:1。 - maxTablesPerVnode: 每个vnode中能够创建的最大表个数。默认值:1000000。 - maxVgroupsPerDb: 每个数据库中能够使用的最大vnode个数。 -- arbitrator: 系统中裁决器的end point,缺省为空 +- arbitrator: 系统中裁决器的end point,缺省为空。 - timezone、locale、charset 的配置见客户端配置。 +为方便调试,可通过SQL语句临时调整每个dnode的日志配置,系统重启后会失效: + +```mysql +ALTER DNODE +``` + +- dnode_id: 可以通过SQL语句"SHOW DNODES"命令获取 +- config: 要调整的日志参数,在如下列表中取值 + > resetlog 截断旧日志文件,创建一个新日志文件 + > debugFlag < 131 | 135 | 143 > 设置debugFlag为131、135或者143 + +例如: +``` + alter dnode 1 debugFlag 135; +``` + ## 客户端配置 TDengine系统的前台交互客户端应用程序为taos,它与taosd共享同一个配置文件taos.cfg。运行taos时,使用参数-c指定配置文件目录,如taos -c /home/cfg,表示使用/home/cfg/目录下的taos.cfg配置文件中的参数,缺省目录是/etc/taos。本节主要说明 taos 客户端应用在配置文件 taos.cfg 文件中使用到的参数。 @@ -140,76 +155,80 @@ TDengine系统的前台交互客户端应用程序为taos,它与taosd共享同 客户端配置参数 - firstEp: taos启动时,主动连接的集群中第一个taosd实例的end point, 缺省值为 localhost:6030。 -- secondEp: taos启动时,如果first连接不上,尝试连接集群中第二个taosd实例的end point, 缺省值为空。 - locale - > 默认值:系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过API设置 + 默认值:系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过API设置 -TDengine为存储中文、日文、韩文等非ASCII编码的宽字符,提供一种专门的字段类型nchar。写入nchar字段的数据将统一采用UCS4-LE格式进行编码并发送到服务器。需要注意的是,编码正确性是客户端来保证。因此,如果用户想要正常使用nchar字段来存储诸如中文、日文、韩文等非ASCII字符,需要正确设置客户端的编码格式。 + TDengine为存储中文、日文、韩文等非ASCII编码的宽字符,提供一种专门的字段类型nchar。写入nchar字段的数据将统一采用UCS4-LE格式进行编码并发送到服务器。需要注意的是,编码正确性是客户端来保证。因此,如果用户想要正常使用nchar字段来存储诸如中文、日文、韩文等非ASCII字符,需要正确设置客户端的编码格式。 -客户端的输入的字符均采用操作系统当前默认的编码格式,在Linux系统上多为UTF-8,部分中文系统编码则可能是GB18030或GBK等。在docker环境中默认的编码是POSIX。在中文版Windows系统中,编码则是CP936。客户端需要确保正确设置自己所使用的字符集,即客户端运行的操作系统当前编码字符集,才能保证nchar中的数据正确转换为UCS4-LE编码格式。 + 客户端的输入的字符均采用操作系统当前默认的编码格式,在Linux系统上多为UTF-8,部分中文系统编码则可能是GB18030或GBK等。在docker环境中默认的编码是POSIX。在中文版Windows系统中,编码则是CP936。客户端需要确保正确设置自己所使用的字符集,即客户端运行的操作系统当前编码字符集,才能保证nchar中的数据正确转换为UCS4-LE编码格式。 -在 Linux 中 locale 的命名规则为: <语言>_<地区>.<字符集编码> 如:zh_CN.UTF-8,zh代表中文,CN代表大陆地区,UTF-8表示字符集。字符集编码为客户端正确解析本地字符串提供编码转换的说明。Linux系统与 Mac OSX 系统可以通过设置locale来确定系统的字符编码,由于Windows使用的locale中不是POSIX标准的locale格式,因此在Windows下需要采用另一个配置参数charset来指定字符编码。在Linux 系统中也可以使用charset来指定字符编码。 + 在 Linux 中 locale 的命名规则为: <语言>_<地区>.<字符集编码> 如:zh_CN.UTF-8,zh代表中文,CN代表大陆地区,UTF-8表示字符集。字符集编码为客户端正确解析本地字符串提供编码转换的说明。Linux系统与 Mac OSX 系统可以通过设置locale来确定系统的字符编码,由于Windows使用的locale中不是POSIX标准的locale格式,因此在Windows下需要采用另一个配置参数charset来指定字符编码。在Linux 系统中也可以使用charset来指定字符编码。 - charset - > 默认值:系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过API设置 + 默认值:系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过API设置 -如果配置文件中不设置charset,在Linux系统中,taos在启动时候,自动读取系统当前的locale信息,并从locale信息中解析提取charset编码格式。如果自动读取locale信息失败,则尝试读取charset配置,如果读取charset配置也失败,则中断启动过程。 + 如果配置文件中不设置charset,在Linux系统中,taos在启动时候,自动读取系统当前的locale信息,并从locale信息中解析提取charset编码格式。如果自动读取locale信息失败,则尝试读取charset配置,如果读取charset配置也失败,则中断启动过程。 -在Linux系统中,locale信息包含了字符编码信息,因此正确设置了Linux系统locale以后可以不用再单独设置charset。例如: -``` + 在Linux系统中,locale信息包含了字符编码信息,因此正确设置了Linux系统locale以后可以不用再单独设置charset。例如: + ``` locale zh_CN.UTF-8 -``` -在Windows系统中,无法从locale获取系统当前编码。如果无法从配置文件中读取字符串编码信息,taos默认设置为字符编码为CP936。其等效在配置文件中添加如下配置: -``` + ``` + 在Windows系统中,无法从locale获取系统当前编码。如果无法从配置文件中读取字符串编码信息,taos默认设置为字符编码为CP936。其等效在配置文件中添加如下配置: + ``` charset CP936 -``` -如果需要调整字符编码,请查阅当前操作系统使用的编码,并在配置文件中正确设置。 + ``` + 如果需要调整字符编码,请查阅当前操作系统使用的编码,并在配置文件中正确设置。 -在Linux系统中,如果用户同时设置了locale和字符集编码charset,并且locale和charset的不一致,后设置的值将覆盖前面设置的值。 -``` + 在Linux系统中,如果用户同时设置了locale和字符集编码charset,并且locale和charset的不一致,后设置的值将覆盖前面设置的值。 + ``` locale zh_CN.UTF-8 charset GBK -``` -则charset的有效值是GBK。 -``` + ``` + 则charset的有效值是GBK。 + ``` charset GBK locale zh_CN.UTF-8 -``` -charset的有效值是UTF-8。 + ``` + charset的有效值是UTF-8。 -日志的配置参数,与server 的配置参数完全一样。 + 日志的配置参数,与server 的配置参数完全一样。 - timezone 默认值:从系统中动态获取当前的时区设置 -客户端运行系统所在的时区。为应对多时区的数据写入和查询问题,TDengine 采用 Unix 时间戳(Unix Timestamp)来记录和存储时间戳。Unix 时间戳的特点决定了任一时刻不论在任何时区,产生的时间戳均一致。需要注意的是,Unix时间戳是在客户端完成转换和记录。为了确保客户端其他形式的时间转换为正确的 Unix 时间戳,需要设置正确的时区。 + 客户端运行系统所在的时区。为应对多时区的数据写入和查询问题,TDengine 采用 Unix 时间戳(Unix Timestamp)来记录和存储时间戳。Unix 时间戳的特点决定了任一时刻不论在任何时区,产生的时间戳均一致。需要注意的是,Unix时间戳是在客户端完成转换和记录。为了确保客户端其他形式的时间转换为正确的 Unix 时间戳,需要设置正确的时区。 -在Linux系统中,客户端会自动读取系统设置的时区信息。用户也可以采用多种方式在配置文件设置时区。例如: -``` + 在Linux系统中,客户端会自动读取系统设置的时区信息。用户也可以采用多种方式在配置文件设置时区。例如: + ``` timezone UTC-8 timezone GMT-8 timezone Asia/Shanghai -``` -均是合法的设置东八区时区的格式。 + ``` + 均是合法的设置东八区时区的格式。 -时区的设置对于查询和写入SQL语句中非Unix时间戳的内容(时间戳字符串、关键词now的解析)产生影响。例如: -``` + 时区的设置对于查询和写入SQL语句中非Unix时间戳的内容(时间戳字符串、关键词now的解析)产生影响。例如: + ``` SELECT count(*) FROM table_name WHERE TS<'2019-04-11 12:01:08'; -``` -在东八区,SQL语句等效于 -``` + ``` + 在东八区,SQL语句等效于 + ``` SELECT count(*) FROM table_name WHERE TS<1554955268000; -``` -在UTC时区,SQL语句等效于 -``` + ``` + 在UTC时区,SQL语句等效于 + ``` SELECT count(*) FROM table_name WHERE TS<1554984068000; -``` -为了避免使用字符串时间格式带来的不确定性,也可以直接使用Unix时间戳。此外,还可以在SQL语句中使用带有时区的时间戳字符串,例如:RFC3339格式的时间戳字符串,2013-04-12T15:52:01.123+08:00或者ISO-8601格式时间戳字符串2013-04-12T15:52:01.123+0800。上述两个字符串转化为Unix时间戳不受系统所在时区的影响。 + ``` + 为了避免使用字符串时间格式带来的不确定性,也可以直接使用Unix时间戳。此外,还可以在SQL语句中使用带有时区的时间戳字符串,例如:RFC3339格式的时间戳字符串,2013-04-12T15:52:01.123+08:00或者ISO-8601格式时间戳字符串2013-04-12T15:52:01.123+0800。上述两个字符串转化为Unix时间戳不受系统所在时区的影响。 + + 启动taos时,也可以从命令行指定一个taosd实例的end point,否则就从taos.cfg读取。 + +- maxBinaryDisplayWidth -启动taos时,也可以从命令行指定一个taosd实例的end point,否则就从taos.cfg读取。 + Shell中binary 和 nchar字段的显示宽度上限,超过此限制的部分将被隐藏。默认值:30。可在 shell 中通过命令 set max_binary_display_width nn 动态修改此选项。 + ## 用户管理 @@ -233,6 +252,12 @@ ALTER USER PASS <'password'>; 修改用户密码, 为避免被转换为小写,密码需要用单引号引用,单引号为英文半角 +``` +ALTER USER PRIVILEDGE ; +``` + +修改用户权限为:super/write/read,不需要添加单引号 + ``` SHOW USERS; ``` @@ -356,7 +381,7 @@ KILL STREAM ; ## 系统监控 -TDengine启动后,会自动创建一个监测数据库SYS,并自动将服务器的CPU、内存、硬盘空间、带宽、请求数、磁盘读写速度、慢查询等信息定时写入该数据库。TDengine还将重要的系统操作(比如登录、创建、删除数据库等)日志以及各种错误报警信息记录下来存放在SYS库里。系统管理员可以从CLI直接查看这个数据库,也可以在WEB通过图形化界面查看这些监测信息。 +TDengine启动后,会自动创建一个监测数据库log,并自动将服务器的CPU、内存、硬盘空间、带宽、请求数、磁盘读写速度、慢查询等信息定时写入该数据库。TDengine还将重要的系统操作(比如登录、创建、删除数据库等)日志以及各种错误报警信息记录下来存放在log库里。系统管理员可以从CLI直接查看这个数据库,也可以在WEB通过图形化界面查看这些监测信息。 这些监测信息的采集缺省是打开的,但可以修改配置文件里的选项enableMonitor将其关闭或打开。 @@ -387,4 +412,3 @@ TDengine的所有可执行文件默认存放在 _/usr/local/taos/bin_ 目录下 您可以通过修改系统配置文件taos.cfg来配置不同的数据目录和日志目录。 - diff --git a/documentation20/webdocs/markdowndocs/advanced features-ch.md b/documentation20/webdocs/markdowndocs/advanced features-ch.md index b1d050c8cc1fe1058631506586c43566b06b3c8a..ed02af25f2cd78372f20a2dc074bb0aa30b4e301 100644 --- a/documentation20/webdocs/markdowndocs/advanced features-ch.md +++ b/documentation20/webdocs/markdowndocs/advanced features-ch.md @@ -39,7 +39,7 @@ create table D1002 using meters tags ("Beijing.Haidian", 2); 我们已经知道,可以通过下面这条SQL语句以一分钟为时间窗口、30秒为前向增量统计这些电表的平均电压。 ```sql -select avg(voltage) from meters interval(1m) sliding(30s); +select avg(voltage) from meters interval(1m) sliding(30s); ``` 每次执行这条语句,都会重新计算所有数据。 @@ -47,14 +47,14 @@ select avg(voltage) from meters interval(1m) sliding(30s); 可以把上面的语句改进成下面的样子,每次使用不同的 `startTime` 并定期执行: ```sql -select avg(voltage) from meters where ts > {startTime} interval(1m) sliding(30s); +select avg(voltage) from meters where ts > {startTime} interval(1m) sliding(30s); ``` 这样做没有问题,但TDengine提供了更简单的方法, 只要在最初的查询语句前面加上 `create table {tableName} as ` 就可以了, 例如: ```sql -create table avg_vol as select avg(voltage) from meters interval(1m) sliding(30s); +create table avg_vol as select avg(voltage) from meters interval(1m) sliding(30s); ``` 会自动创建一个名为 `avg_vol` 的新表,然后每隔30秒,TDengine会增量执行 `as` 后面的 SQL 语句, @@ -80,7 +80,7 @@ taos> select * from avg_vol; 比如使用下面的SQL创建的连续查询将运行一小时,之后会自动停止。 ```sql -create table avg_vol as select avg(voltage) from meters where ts > now and ts <= now + 1h interval(1m) sliding(30s); +create table avg_vol as select avg(voltage) from meters where ts > now and ts <= now + 1h interval(1m) sliding(30s); ``` 需要说明的是,上面例子中的 `now` 是指创建连续查询的时间,而不是查询执行的时间,否则,查询就无法自动停止了。 @@ -396,7 +396,7 @@ ts: 1597465200000 current: 11.2 voltage: 220 phase: 1 location: Beijing.Haidian ```sql # taos -taos> use power; +taos> use power; taos> insert into d1001 values("2020-08-15 12:40:00.000", 12.4, 220, 1); ``` diff --git a/documentation20/webdocs/markdowndocs/architecture-ch.md b/documentation20/webdocs/markdowndocs/architecture-ch.md index a279875649503c64861f7b42b64741967f75aa69..d4705ccb05c092d8da38072368a167466bd78968 100644 --- a/documentation20/webdocs/markdowndocs/architecture-ch.md +++ b/documentation20/webdocs/markdowndocs/architecture-ch.md @@ -65,36 +65,36 @@ TDengine 的设计是基于单个硬件、软件系统不可靠,基于任何 TDengine 分布式架构的逻辑结构图如下:
    图 1 TDengine架构示意图
    -一个完整的 TDengine 系统是运行在一到多个物理节点上的,逻辑上,它包含数据节点(dnode)、TDengine客户端(taosc)以及应用(app)。系统中存在一到多个数据节点,这些数据节点组成一个集群(cluster)。应用通过taosc的API与TDengine集群进行互动。下面对每个逻辑单元进行简要介绍。 +一个完整的 TDengine 系统是运行在一到多个物理节点上的,逻辑上,它包含数据节点(dnode)、TDengine应用驱动(taosc)以及应用(app)。系统中存在一到多个数据节点,这些数据节点组成一个集群(cluster)。应用通过taosc的API与TDengine集群进行互动。下面对每个逻辑单元进行简要介绍。 -**物理节点(pnode):** pnode是一独立运行、拥有自己的计算、存储和网络能力的计算机,可以是安装有OS的物理机、虚拟机或容器。物理节点由其配置的 FQDN(Fully Qualified Domain Name)来标识。 +**物理节点(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)的组合。通过配置不同的端口,一个物理节点(一台物理机、虚拟机或容器)可以运行多个实例,或有多个数据节点。 -**虚拟节点(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 包含一定数量的表(数据采集点)。当创建一张新表时,系统会检查是否需要创建新的 vnode。一个数据节点上能创建的 vnode 的数量取决于该数据节点所在物理节点的硬件资源。一个 vnode 只属于一个DB,但一个DB可以有多个 vnode。一个 vnode 除存储的时序数据外,也保存有所包含的表的schema、标签值等。一个虚拟节点由所属的数据节点的EP,以及所属的VGroup ID在系统内唯一标识,由管理节点创建并管理。 **管理节点(mnode):** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中M)。同时,管理节点也负责元数据(包括用户、数据库、表、静态标签等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(最多不超过5个) mnode,它们自动构建成为一个虚拟管理节点组(图中M0, M1, M2)。mnode 间采用 master/slave 的机制进行管理,而且采取强一致方式进行数据同步, 任何数据更新操作只能在 Master 上进行。mnode 集群的创建由系统自动完成,无需人工干预。每个dnode上至多有一个mnode,由所属的数据节点的EP来唯一标识。每个dnode通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的EP。 **虚拟节点组(VGroup):** 不同数据节点上的 vnode 可以组成一个虚拟节点组(vnode group)来保证系统的高可靠。虚拟节点组内采取master/slave的方式进行管理。写操作只能在 master vnode 上进行,系统采用异步复制的方式将数据同步到 slave vnode,这样确保了一份数据在多个物理节点上有拷贝。一个 vgroup 里虚拟节点个数就是数据的副本数。如果一个DB的副本数为N,系统必须有至少N个数据节点。副本数在创建DB时通过参数 replica 可以指定,缺省为1。使用 TDengine 的多副本特性,可以不再需要昂贵的磁盘阵列等存储设备,就可以获得同样的数据高可靠性。虚拟节点组由管理节点创建、管理,并且由管理节点分配一个系统唯一的ID,VGroup ID。如果两个虚拟节点的vnode group ID相同,说明他们属于同一个组,数据互为备份。虚拟节点组里虚拟节点的个数是可以动态改变的,容许只有一个,也就是没有数据复制。VGroup ID是永远不变的,即使一个虚拟节点组被删除,它的ID也不会被收回重复利用。 -**TAOSC:** taosc是TDengine给应用提供的驱动程序(driver),负责处理应用与集群的接口交互,内嵌于JDBC、ODBC driver中,或者C、Python、Go语言连接库里。应用都是通过taosc而不是直接连接集群中的数据节点与整个集群进行交互的。这个模块负责获取并缓存元数据;将插入、查询等请求转发到正确的数据节点;在把结果返回给应用时,还需要负责最后一级的聚合、排序、过滤等操作。对于JDBC, ODBC, C/C++接口而言,这个模块是在应用所处的物理节点上运行,但消耗的资源很小。同时,为支持全分布式的RESTful接口,taosc在TDengine集群的每个dnode上都有一运行实例。 +**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上都有一运行实例。 ### 节点之间的通讯 -**通讯方式:**TDengine系统的各个节点之间的通讯是通过TCP/UDP进行的。因为考虑到物联网场景,数据写入的包一般不大,因此TDengine 除采用TCP做传输之外,还采用UDP方式,因为UDP 更加高效,而且不受连接数的限制。TDengine实现了自己的超时、重传、确认等机制,以确保UDP的可靠传输。对于数据量不到15K的数据包,采取UDP的方式进行传输,超过15K的,或者是查询类的操作,自动采取TCP的方式进行传输。同时,TDengine根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。对于数据节点之间的数据复制,只采用TCP方式进行数据传输。 +**通讯方式:**TDengine系统的各个数据节点之间,以及应用驱动与各数据节点之间的通讯是通过TCP/UDP进行的。因为考虑到物联网场景,数据写入的包一般不大,因此TDengine 除采用TCP做传输之外,还采用UDP方式,因为UDP 更加高效,而且不受连接数的限制。TDengine实现了自己的超时、重传、确认等机制,以确保UDP的可靠传输。对于数据量不到15K的数据包,采取UDP的方式进行传输,超过15K的,或者是查询类的操作,自动采取TCP的方式进行传输。同时,TDengine根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。对于数据节点之间的数据复制,只采用TCP方式进行数据传输。 -**FQDN配置**:一个数据节点有一个或多个FQDN,可以在系统配置文件taos.cfg通过参数“fqdn"进行指定,如果没有指定,系统将自动获取FQDN。如果节点没有配置FQDN,可以直接将该节点的配置参数fqdn设置为它的IP地址。但不建议使用IP,因为IP地址可变,一旦变化,将让集群无法正常工作。一个数据节点的EP(End Point)由FQDN + Port组成。采用FQDN,需要保证DNS服务正常工作,或者在节点以及应用所在的节点配置好hosts文件。 +**FQDN配置**:一个数据节点有一个或多个FQDN,可以在系统配置文件taos.cfg通过参数“fqdn"进行指定,如果没有指定,系统将自动获取计算机的hostname作为其FQDN。如果节点没有配置FQDN,可以直接将该节点的配置参数fqdn设置为它的IP地址。但不建议使用IP,因为IP地址可变,一旦变化,将让集群无法正常工作。一个数据节点的EP(End Point)由FQDN + Port组成。采用FQDN,需要保证DNS服务正常工作,或者在节点以及应用所在的节点配置好hosts文件。 -**端口配置:**一个数据节点对外的端口由TDengine的系统配置参数serverPort决定,对集群内部通讯的端口是serverPort+5。集群内数据节点之间的数据复制操作还占有一个TCP端口,是serverPort+10. 为支持多线程高效的处理UDP数据,每个对内和对外的UDP链接,都需要占用5个连续的端口。因此一个数据节点总的端口范围为serverPort到serverPort + 10,总共11个TCP/UDP端口。使用时,需要确保防火墙将这些端口打开。每个数据节点可以配置不同的serverPort。 +**端口配置:**一个数据节点对外的端口由TDengine的系统配置参数serverPort决定,对集群内部通讯的端口是serverPort+5。集群内数据节点之间的数据复制操作还占有一个TCP端口,是serverPort+10. 为支持多线程高效的处理UDP数据,每个对内和对外的UDP连接,都需要占用5个连续的端口。因此一个数据节点总的端口范围为serverPort到serverPort + 10,总共11个TCP/UDP端口。使用时,需要确保防火墙将这些端口打开。每个数据节点可以配置不同的serverPort。 -**集群对外链接:** TDengine集群可以容纳单个、多个甚至几千个数据节点。应用只需要向集群中任何一个数据节点发起连接即可,链接需要提供的网络参数是一数据节点的End Point(FQDN加配置的端口号)。通过命令行CLI启动应用taos时,可以通过选项-h来指定数据节点的FQDN, -P来指定其配置的端口号,如果端口不配置,将采用TDengine的系统配置参数serverPort。 +**集群对外连接:** TDengine集群可以容纳单个、多个甚至几千个数据节点。应用只需要向集群中任何一个数据节点发起连接即可,连接需要提供的网络参数是一数据节点的End Point(FQDN加配置的端口号)。通过命令行CLI启动应用taos时,可以通过选项-h来指定数据节点的FQDN, -P来指定其配置的端口号,如果端口不配置,将采用TDengine的系统配置参数serverPort。 -**集群内部通讯**: 各个数据节点之间通过TCP/UDP进行链接。一个数据节点启动时,将获取mnode所在的dnode的EP信息,然后与系统中的mnode建立起链接,交换信息。获取mnode的EP信息有三步,1:检查mnodeEpList文件是否存在,如果不存在或不能正常打开获得mnode EP信息,进入第二步;2:检查系统配置文件taos.cfg, 获取mnode EP配置参数first, second,如果不存在或者taos.cfg里没有这两个配置参数,或无效,进入第三步;3:将自己的EP设为mnode EP, 并独立运行起来。获取mnode EP列表后,数据节点发起链接,如果链接成功,则成功加入进工作的集群,如果不成功,则尝试mnode EP列表中的下一个。如果都尝试了,但链接都仍然失败,则休眠几秒后,再进行尝试。 +**集群内部通讯**: 各个数据节点之间通过TCP/UDP进行连接。一个数据节点启动时,将获取mnode所在的dnode的EP信息,然后与系统中的mnode建立起连接,交换信息。获取mnode的EP信息有三步,1:检查mnodeEpList文件是否存在,如果不存在或不能正常打开获得mnode EP信息,进入第二步;2:检查系统配置文件taos.cfg, 获取mnode EP配置参数first, second,如果不存在或者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自己根据资源做出的决定。 -**新数据节点的加入**:系统有了一个数据节点后,就已经成为一个工作的系统。添加新的节点进集群时,有两个步骤,第一步:使用TDengine CLI链接到现有工作的数据节点,然后用命令”create dnode"将新的数据节点的End Point添加进去; 第二步:在新的数据节点的系统配置参数文件taos.cfg里,将first, second参数设置为现有集群中任意两个数据节点的EP即可。具体添加的详细步骤请见详细的用户手册。这样就把集群一步一步的建立起来。 +**新数据节点的加入**:系统有了一个数据节点后,就已经成为一个工作的系统。添加新的节点进集群时,有两个步骤,第一步:使用TDengine CLI连接到现有工作的数据节点,然后用命令”create dnode"将新的数据节点的End Point添加进去; 第二步:在新的数据节点的系统配置参数文件taos.cfg里,将first, second参数设置为现有集群中任意两个数据节点的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。 ### 一个典型的消息流程 为解释vnode, mnode, taosc和应用之间的关系以及各自扮演的角色,下面对写入数据这个典型操作的流程进行剖析。 @@ -153,6 +153,7 @@ TDengine除vnode分片之外,还对时序数据按照时间段进行分区。 当新的数据节点被添加进集群,因为新的计算和存储被添加进来,系统也将自动启动负载均衡流程。 负载均衡过程无需任何人工干预,应用也无需重启,将自动连接新的节点,完全透明。 +**提示:负载均衡由参数balance控制,决定开启/关闭自动负载均衡。** ## 数据写入与复制流程 如果一个数据库有N个副本,那一个虚拟节点组就有N个虚拟节点,但是只有一个是Master,其他都是slave。当应用将新的记录写入系统时,只有Master vnode能接受写的请求。如果slave vnode收到写的请求,系统将通知taosc需要重新定向。 @@ -192,12 +193,13 @@ Master Vnode遵循下面的写入流程: 理论上,只要是异步复制,就无法保证100%不丢失。但是这个窗口极小,mater与slave要同时发生故障,而且发生在刚给应用确认写入成功之后。 -注:异地容灾、IDC无中断迁移,仅仅企业版支持 +注:异地容灾、IDC无中断迁移,仅仅企业版支持。 +**提示:该功能暂未提供** ### 主从选择 Vnode会保持一个数据版本号(Version),对内存数据进行持久化存储时,对该版本号也进行持久化存储。每个数据更新操作,无论是采集的时序数据还是元数据,这个版本号将增一。 -一个vnode启动时,角色(master、slave) 是不定的,数据是处于未同步状态,它需要与虚拟节点组内其他节点建立TCP链接,并互相交换status,其中包括version和自己的角色。通过status的交换,系统进入选主流程,规则如下: +一个vnode启动时,角色(master、slave) 是不定的,数据是处于未同步状态,它需要与虚拟节点组内其他节点建立TCP连接,并互相交换status,其中包括version和自己的角色。通过status的交换,系统进入选主流程,规则如下: 1. 如果只有一个副本,该副本永远就是master 2. 所有副本都在线时,版本最高的被选为master @@ -226,7 +228,7 @@ TDengine采用数据驱动的方式让缓存中的数据写入硬盘进行持久 为充分利用时序数据特点,TDengine将一个vnode保存在持久化存储的数据切分成多个文件,每个文件只保存固定天数的数据,这个天数由系统配置参数days决定。切分成多个文件后,给定查询的起止日期,无需任何索引,就可以立即定位需要打开哪些数据文件,大大加快读取速度。 -对于采集的数据,一般有保留时长,这个时长由系统配置参数keep决定。超过这个设置天数的数据文件,将被系统将自动删除,释放存储空间。 +对于采集的数据,一般有保留时长,这个时长由系统配置参数keep决定。超过这个设置天数的数据文件,将被系统自动删除,释放存储空间。 给定days与keep两个参数,一个vnode总的数据文件数为:keep/days。总的数据文件个数不宜过大,也不宜过小。10到100以内合适。基于这个原则,可以设置合理的days。 目前的版本,参数keep可以修改,但对于参数days,一但设置后,不可修改。 @@ -259,6 +261,7 @@ dataDir /mnt/disk6/taos 2 挂载的盘也可以是非本地的网络盘,只要系统能访问即可。 注:多级存储功能仅企业版支持 +**提示:该功能暂未提供** ## 数据查询 TDengine提供了多种多样针对表和超级表的查询处理功能,除了常规的聚合查询之外,还提供针对时序数据的窗口查询、统计聚合等功能。TDengine的查询处理需要客户端、vnode, mnode节点协同完成。 @@ -276,24 +279,31 @@ SQL语句的解析和校验工作在客户端完成。解析SQL语句并生成 在TDengine中引入关键词interval来进行时间轴上固定长度时间窗口的切分,并按照时间窗口对数据进行聚合,对窗口范围内的数据按需进行聚合。例如: ```mysql -select count(*) from d1001 interval(1h); +select count(*) from d1001 interval(1h); ``` 针对d1001设备采集的数据,按照1小时的时间窗口返回每小时存储的记录数量。 在需要连续获得查询结果的应用场景下,如果给定的时间区间存在数据缺失,会导致该区间数据结果也丢失。TDengine提供策略针对时间轴聚合计算的结果进行插值,通过使用关键词Fill就能够对时间轴聚合结果进行插值。例如: ```mysql -select count(*) from d1001 interval(1h) fill(prev); +select count(*) from d1001 interval(1h) fill(prev); ``` 针对d1001设备采集数据统计每小时记录数,如果某一个小时不存在数据,这返回之前一个小时的统计数据。TDengine提供前向插值(prev)、线性插值(linear)、NULL值填充(NULL)、特定值填充(value)。 ### 多表聚合查询 -多表聚合查询与单表查询的整体流程相同,但是存在如下的差异: - -- 由于多表可能分布在不同的节点(dnode),因此多表的聚合查询需要首先获得表所在的全部数据节点的信息,并且同时向相关的dnode发出查询请求。 -- 每个vnode的计算获得的中间结果(partial results)需要进行第二阶段的聚合才能形成最终结果,第二阶段的聚合过程在客户端完成。 -- 由于表标签信息存储在vnode中,因此针对标签信息的查询也需要vnode完成。客户端将标签的过滤表达式封装在查询请求结构体中发送给vnode,由vnode的查询执行线程从中抽取出标签查询条件,然后执行查询。标签查询与过滤是在针对表的查询之前完成。标签查询完成以后,将符合条件的表纳入到接下来的查询处理流程中。 +TDengine对每个数据采集点单独建表,但在实际应用中经常需要对不同的采集点数据进行聚合。为高效的进行聚合操作,TDengine引入超级表(STable)的概念。超级表用来代表一特定类型的数据采集点,它是包含多张表的表集合,集合里每张表的模式(schema)完全一致,但每张表都带有自己的静态标签,标签可以多个,可以随时增加、删除和修改。 应用可通过指定标签的过滤条件,对一个STable下的全部或部分表进行聚合或统计操作,这样大大简化应用的开发。其具体流程如下图所示: +
    + +
    图 5 多表聚合查询原理图
    +1:应用将一个查询条件发往系统; +2: taosc将超级表的名字发往 Meta Node(管理节点); +3:管理节点将超级表所拥有的 vnode 列表发回 taosc; +4:taosc将计算的请求连同标签过滤条件发往这些vnode对应的多个数据节点; +5:每个vnode先在内存里查找出自己节点里符合标签过滤条件的表的集合,然后扫描存储的时序数据,完成相应的聚合计算,将结果返回给taosc; +6:taosc将多个数据节点返回的结果做最后的聚合,将其返回给应用。 + +由于TDengine在vnode内将标签数据与时序数据分离存储,通过在内存里过滤标签数据,先找到需要参与聚合操作的表的集合,将需要扫描的数据集大幅减少,大幅提升聚合计算速度。同时,由于数据分布在多个vnode/dnode,聚合计算操作在多个vnode里并发进行,又进一步提升了聚合的速度。 对普通表的聚合函数以及绝大部分操作都适用于超级表,语法完全一样,细节请看 TAOS SQL。 ### 预计算 为有效提升查询处理的性能,针对物联网数据的不可更改的特点,在数据块头部记录该数据块中存储数据的统计信息:包括最大值、最小值、和。我们称之为预计算单元。如果查询处理涉及整个数据块的全部数据,直接使用预计算结果,完全不需要读取数据块的内容。由于预计算数据量远小于磁盘上存储的数据块数据的大小,对于磁盘IO为瓶颈的查询处理,使用预计算结果可以极大地减小读取IO压力,加速查询处理的流程。预计算机制与Postgre SQL的索引BRIN(block range index)有异曲同工之妙。 diff --git a/documentation20/webdocs/markdowndocs/cluster-ch.md b/documentation20/webdocs/markdowndocs/cluster-ch.md index 193de729ba9ccf9c1efba53520ac2d69f5f51d87..10c28c284c870d1a522a178beb5303901f079a5a 100644 --- a/documentation20/webdocs/markdowndocs/cluster-ch.md +++ b/documentation20/webdocs/markdowndocs/cluster-ch.md @@ -2,13 +2,13 @@ 多个TDengine服务器,也就是多个taosd的运行实例可以组成一个集群,以保证TDengine的高可靠运行,并提供水平扩展能力。要了解TDengine 2.0的集群管理,需要对集群的基本概念有所了解,请看TDengine 2.0整体架构一章。而且在安装集群之前,先请按照[《立即开始》](https://www.taosdata.com/cn/getting-started20/)一章安装并体验单节点功能。 -集群的每个数据节点是由End Point来唯一标识的,End Point是由FQDN(Fully Qualified Domain Name)外加Port组成,比如 h1.taosdata.com:6030。一般FQDN就是服务器的hostname,可通过Linux命令`hostname -f`获取,FQDN配置参考:[一篇文章说清楚TDengine的FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html)。端口是这个数据节点对外服务的端口号,缺省是6030,但可以通过taos.cfg里配置参数serverPort进行修改。一个物理节点可能配置了多个hostname, TDengine会自动获取第一个,但也可以通过taos.cfg里配置参数fqdn进行指定。如果习惯IP地址直接访问,可以将参数fqdn设置为本节点的IP地址。 +集群的每个数据节点是由End Point来唯一标识的,End Point是由FQDN(Fully Qualified Domain Name)外加Port组成,比如 h1.taosdata.com:6030。一般FQDN就是服务器的hostname,可通过Linux命令`hostname -f`获取(如何配置FQDN,请参考:[一篇文章说清楚TDengine的FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html))。端口是这个数据节点对外服务的端口号,缺省是6030,但可以通过taos.cfg里配置参数serverPort进行修改。一个物理节点可能配置了多个hostname, TDengine会自动获取第一个,但也可以通过taos.cfg里配置参数fqdn进行指定。如果习惯IP地址直接访问,可以将参数fqdn设置为本节点的IP地址。 TDengine的集群管理极其简单,除添加和删除节点需要人工干预之外,其他全部是自动完成,最大程度的降低了运维的工作量。本章对集群管理的操作做详细的描述。 ## 准备工作 -**第零步**:规划集群所有物理节点的FQDN,将规划好的FQDN分别添加到每个物理节点的/etc/hostname;修改每个物理节点的/etc/hosts,将所有集群物理节点的IP与FQDN的对应添加好【如部署了DNS,请联系网络管理员在DNS上做好相关配置】; +**第零步**:规划集群所有物理节点的FQDN,将规划好的FQDN分别添加到每个物理节点的/etc/hostname;修改每个物理节点的/etc/hosts,将所有集群物理节点的IP与FQDN的对应添加好。【如部署了DNS,请联系网络管理员在DNS上做好相关配置】 **第一步**:如果搭建集群的物理节点中,存有之前的测试数据、装过1.X的版本,或者装过其他版本的TDengine,请先将其删除,并清空所有数据,具体步骤请参考博客[《TDengine多种安装包的安装和卸载》](https://www.taosdata.com/blog/2019/08/09/566.html ) **注意1:**因为FQDN的信息会写进文件,如果之前没有配置或者更改FQDN,且启动了TDengine。请一定在确保数据无用或者备份的前提下,清理一下之前的数据(rm -rf /var/lib/taos/); @@ -16,13 +16,14 @@ TDengine的集群管理极其简单,除添加和删除节点需要人工干预 **第二步**:建议关闭所有物理节点的防火墙,至少保证端口:6030 - 6042的TCP和UDP端口都是开放的。**强烈建议**先关闭防火墙,集群搭建完毕之后,再来配置端口; -**第三步**:在所有节点安装TDengine,且版本必须是一致的,**但不要启动taosd**。安装时,提示输入是否要加入一个已经存在的TDengine集群时,第一个物理节点直接回车创建新集群,后续物理节点则输入该集群任何一个在线的物理节点的FQDN:端口号(默认6030); +**第三步**:在所有物理节点安装TDengine,且版本必须是一致的,**但不要启动taosd**。安装时,提示输入是否要加入一个已经存在的TDengine集群时,第一个物理节点直接回车创建新集群,后续物理节点则输入该集群任何一个在线的物理节点的FQDN:端口号(默认6030); -**第四步**:检查所有数据节点,以及应用所在物理节点的网络设置: +**第四步**:检查所有数据节点,以及应用程序所在物理节点的网络设置: 1. 每个物理节点上执行命令`hostname -f`,查看和确认所有节点的hostname是不相同的(应用驱动所在节点无需做此项检查); 2. 每个物理节点上执行`ping host`, 其中host是其他物理节点的hostname, 看能否ping通其它物理节点; 如果不能ping通,需要检查网络设置, 或/etc/hosts文件(Windows系统默认路径为C:\Windows\system32\drivers\etc\hosts),或DNS的配置。如果无法ping通,是无法组成集群的; -3. 每个数据节点的End Point就是输出的hostname外加端口号,比如h1.taosdata.com:6030 +3. 从应用运行的物理节点,ping taosd运行的数据节点,如果无法ping通,应用是无法连接taosd的,请检查应用所在物理节点的DNS设置或hosts文件; +4. 每个数据节点的End Point就是输出的hostname外加端口号,比如h1.taosdata.com:6030 **第五步**:修改TDengine的配置文件(所有节点的文件/etc/taos/taos.cfg都需要修改)。假设准备启动的第一个数据节点End Point为 h1.taosdata.com:6030, 其与集群配置相关参数如下: @@ -30,8 +31,8 @@ TDengine的集群管理极其简单,除添加和删除节点需要人工干预 // firstEp 是每个数据节点首次启动后连接的第一个数据节点 firstEp h1.taosdata.com:6030 -// 配置本数据节点的FQDN,如果本机只有一个hostname, 无需配置 -fqdn h1.taosdata.com +// 必须配置为本数据节点的FQDN,如果本机只有一个hostname, 可注释掉本配置 +fqdn h1.taosdata.com // 配置本数据节点的端口号,缺省是6030 serverPort 6030 @@ -40,7 +41,7 @@ serverPort 6030 arbitrator ha.taosdata.com:6042 ``` -一定要修改的参数是firstEp和fqdn, 其他参数可不做任何修改,除非你很清楚为什么要修改。 +一定要修改的参数是firstEp和fqdn。在每个数据节点,firstEp需全部配置成一样,**但fqdn一定要配置成其所在数据节点的值**。其他参数可不做任何修改,除非你很清楚为什么要修改。 **加入到集群中的数据节点dnode,涉及集群相关的下表11项参数必须完全相同,否则不能成功加入到集群中。** @@ -88,7 +89,7 @@ taos> 2. 在第一个数据节点,使用CLI程序taos, 登录进TDengine系统, 执行命令: ``` - CREATE DNODE "h2.taos.com:6030"; + CREATE DNODE "h2.taos.com:6030"; ``` 将新数据节点的End Point (准备工作中第四步获知的) 添加进集群的EP列表。**"fqdn:port"需要用双引号引起来**,否则出错。请注意将示例的“h2.taos.com:6030" 替换为这个新数据节点的End Point。 @@ -96,7 +97,7 @@ taos> 3. 然后执行命令 ``` - SHOW DNODES; + SHOW DNODES; ``` 查看新节点是否被成功加入。如果该被加入的数据节点处于离线状态,请做两个检查 @@ -114,12 +115,14 @@ taos> ## 数据节点管理 +上面已经介绍如何从零开始搭建集群。集群组建完后,还可以随时添加新的数据节点进行扩容,或删除数据节点,并检查集群当前状态。 + ### 添加数据节点 执行CLI程序taos, 使用root账号登录进系统, 执行: ``` -CREATE DNODE "fqdn:port"; +CREATE DNODE "fqdn:port"; ``` 将新数据节点的End Point添加进集群的EP列表。**"fqdn:port"需要用双引号引起来**,否则出错。一个数据节点对外服务的fqdn和port可以通过配置文件taos.cfg进行配置,缺省是自动获取。【强烈不建议用自动获取方式来配置FQDN,可能导致生成的数据节点的End Point不是所期望的】 @@ -210,6 +213,6 @@ SHOW MNODES; ## Arbitrator的使用 -如果副本数为偶数,当一个vnode group里一半或超过一半的vnode不工作时,是无法从中选出master的。同理,一半或超过一半的mnode不工作时,是无法选出mnode的master的,因为存在“split brain”问题。为解决这个问题,TDengine引入了arbitrator的概念。Arbitrator模拟一个vnode或mnode在工作,但只简单的负责网络连接,不处理任何数据插入或访问。只要包含arbitrator在内,超过半数的vnode或mnode工作,那么该vnode group或mnode组就可以正常的提供数据插入或查询服务。比如对于副本数为2的情形,如果一个节点A离线,但另外一个节点B正常,而且能连接到arbitrator, 那么节点B就能正常工作。 +如果副本数为偶数,当一个vnode group里一半vnode不工作时,是无法从中选出master的。同理,一半mnode不工作时,是无法选出mnode的master的,因为存在“split brain”问题。为解决这个问题,TDengine引入了arbitrator的概念。Arbitrator模拟一个vnode或mnode在工作,但只简单的负责网络连接,不处理任何数据插入或访问。只要包含arbitrator在内,超过半数的vnode或mnode工作,那么该vnode group或mnode组就可以正常的提供数据插入或查询服务。比如对于副本数为2的情形,如果一个节点A离线,但另外一个节点B正常,而且能连接到arbitrator, 那么节点B就能正常工作。 -TDengine安装包里带有一个执行程序tarbitrator, 找任何一台Linux服务器运行它即可。该程序对系统资源几乎没有要求,只需要保证有网络连接即可。该应用的命令行参数`-p`可以指定其对外服务的端口号,缺省是6042。配置每个taosd实例时,可以在配置文件taos.cfg里将参数arbitrator设置为arbitrator的End Point。如果该参数配置了,当副本数为偶数数,系统将自动连接配置的arbitrator。 +TDengine提供一个执行程序tarbitrator, 找任何一台Linux服务器运行它即可。请点击[安装包下载](https://www.taosdata.com/cn/all-downloads/),在TDengine Arbitrator Linux一节中,选择适合的版本下载并安装。该程序对系统资源几乎没有要求,只需要保证有网络连接即可。该应用的命令行参数`-p`可以指定其对外服务的端口号,缺省是6042。配置每个taosd实例时,可以在配置文件taos.cfg里将参数arbitrator设置为arbitrator的End Point。如果该参数配置了,当副本数为偶数数,系统将自动连接配置的arbitrator。如果副本数为奇数,即使配置了arbitrator, 系统也不会去建立连接。 diff --git a/documentation20/webdocs/markdowndocs/cluster.md b/documentation20/webdocs/markdowndocs/cluster.md index 43b35dbc66e94cb60c2973b16d71a2ad2531c6df..f5fa6af48c9bb0a4062c9de74ee3555561ac26ba 100644 --- a/documentation20/webdocs/markdowndocs/cluster.md +++ b/documentation20/webdocs/markdowndocs/cluster.md @@ -46,7 +46,7 @@ taos> 5. 在第一个节点,使用CLI程序taos, 登录进TDengine系统, 使用命令: ``` - CREATE DNODE "h2.taos.com:6030"; + CREATE DNODE "h2.taos.com:6030"; ``` 将新节点的End Point添加进集群的EP列表。**"fqdn:port"需要用双引号引起来**,否则出错。请注意将示例的“h2.taos.com:6030" 替换为你自己第一个节点的End Point @@ -54,7 +54,7 @@ taos> 6. 使用命令 ``` - SHOW DNODES; + SHOW DNODES; ``` 查看新节点是否被成功加入。 @@ -71,7 +71,7 @@ taos> ###添加节点 执行CLI程序taos, 使用root账号登录进系统, 执行: ``` -CREATE DNODE "fqdn:port"; +CREATE DNODE "fqdn:port"; ``` 将新节点的End Point添加进集群的EP列表。**"fqdn:port"需要用双引号引起来**,否则出错。一个节点对外服务的fqdn和port可以通过配置文件taos.cfg进行配置,缺省是自动获取。 diff --git a/documentation20/webdocs/markdowndocs/connector-ch.md b/documentation20/webdocs/markdowndocs/connector-ch.md index 7b6afb75a7ad75d6b94b519cc1e1b438ecbf3b6f..0e29b324871e61d184fde17710c863f06b60bdcc 100644 --- a/documentation20/webdocs/markdowndocs/connector-ch.md +++ b/documentation20/webdocs/markdowndocs/connector-ch.md @@ -142,7 +142,7 @@ C/C++的API类似于MySQL的C API。应用程序使用时,需要包含TDengine 获取最近一次API调用失败的原因,返回值为错误代码。 -**注意**:对于单个数据库连接,在同一时刻只能有一个线程使用该链接调用API,否则会有未定义的行为出现并可能导致客户端crash。客户端应用可以通过建立多个连接进行多线程的数据写入或查询处理。 +**注意**:对于单个数据库连接,在同一时刻只能有一个线程使用该连接调用API,否则会有未定义的行为出现并可能导致客户端crash。客户端应用可以通过建立多个连接进行多线程的数据写入或查询处理。 ### 异步查询API diff --git a/documentation20/webdocs/markdowndocs/connector-java-ch.md b/documentation20/webdocs/markdowndocs/connector-java-ch.md index f6da7ff4033c6da1679961404247bce9ab69ed86..e3743f4f9de727f396e343abac6234f10265cd78 100644 --- a/documentation20/webdocs/markdowndocs/connector-java-ch.md +++ b/documentation20/webdocs/markdowndocs/connector-java-ch.md @@ -72,38 +72,34 @@ maven 项目中使用如下 pom.xml 配置即可: ### 获取连接 -如下所示配置即可获取 TDengine Connection: +#### 通过JdbcUrl获取连接 + +通过指定的jdbcUrl获取连接,如下所示: ```java Class.forName("com.taosdata.jdbc.TSDBDriver"); -String jdbcUrl = "jdbc:TAOS://127.0.0.1:6030/log?user=root&password=taosdata"; +String jdbcUrl = "jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata"; Connection conn = DriverManager.getConnection(jdbcUrl); ``` -> 端口 6030 为默认连接端口,JDBC URL 中的 log 为系统本身的监控数据库。 +以上示例,建立了到hostname为taosdemo.com,端口为6030(TDengine的默认端口),数据库名为test的连接。这个url中指定用户名(user)为root,密码(password)为taosdata。 TDengine 的 JDBC URL 规范格式为: -`jdbc:TAOS://{host_ip}:{port}/[database_name]?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]` - -其中,`{}` 中的内容必须,`[]` 中为可选。配置参数说明如下: - +`jdbc:TAOS://[host_name]:[port]/[database_name]?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]` +url中的配置参数如下: * user:登录 TDengine 用户名,默认值 root。 * password:用户登录密码,默认值 taosdata。 -* charset:客户端使用的字符集,默认值为系统字符集。 * cfgdir:客户端配置文件目录路径,Linux OS 上默认值 /etc/taos ,Windows OS 上默认值 C:/TDengine/cfg。 +* charset:客户端使用的字符集,默认值为系统字符集。 * locale:客户端语言环境,默认值系统当前 locale。 * timezone:客户端使用的时区,默认值为系统当前时区。 -以上参数可以在 3 处配置,`优先级由高到低`分别如下: -1. JDBC URL 参数 - 如上所述,可以在 JDBC URL 的参数中指定。 -2. java.sql.DriverManager.getConnection(String jdbcUrl, Properties connProps) +#### 使用JdbcUrl和Properties获取连接 + +除了通过指定的jdbcUrl获取连接,还可以使用Properties指定建立连接时的参数,如下所示: ```java public Connection getConn() throws Exception{ Class.forName("com.taosdata.jdbc.TSDBDriver"); - String jdbcUrl = "jdbc:TAOS://127.0.0.1:0/log?user=root&password=taosdata"; + String jdbcUrl = "jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata"; Properties connProps = new Properties(); - connProps.setProperty(TSDBDriver.PROPERTY_KEY_USER, "root"); - connProps.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD, "taosdata"); - connProps.setProperty(TSDBDriver.PROPERTY_KEY_CONFIG_DIR, "/etc/taos"); connProps.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); @@ -111,16 +107,39 @@ public Connection getConn() throws Exception{ return conn; } ``` +以上示例,建立一个到hostname为taosdemo.com,端口为6030,数据库名为test的连接。这个连接在url中指定了用户名(user)为root,密码(password)为taosdata,并在connProps中指定了使用的字符集、语言环境、时区等信息。 + +properties中的配置参数如下: +* TSDBDriver.PROPERTY_KEY_USER:登录 TDengine 用户名,默认值 root。 +* TSDBDriver.PROPERTY_KEY_PASSWORD:用户登录密码,默认值 taosdata。 +* TSDBDriver.PROPERTY_KEY_CONFIG_DIR:客户端配置文件目录路径,Linux OS 上默认值 /etc/taos ,Windows OS 上默认值 C:/TDengine/cfg。 +* TSDBDriver.PROPERTY_KEY_CHARSET:客户端使用的字符集,默认值为系统字符集。 +* TSDBDriver.PROPERTY_KEY_LOCALE:客户端语言环境,默认值系统当前 locale。 +* TSDBDriver.PROPERTY_KEY_TIME_ZONE:客户端使用的时区,默认值为系统当前时区。 + +#### 使用客户端配置文件建立连接 +当使用JDBC连接TDengine集群时,可以使用客户端配置文件,在客户端配置文件中指定集群的firstEp、secondEp参数。 +如下所示: +1. 在java中不指定hostname和port +```java +public Connection getConn() throws Exception{ + Class.forName("com.taosdata.jdbc.TSDBDriver"); + String jdbcUrl = "jdbc:TAOS://:/test?user=root&password=taosdata"; + Properties connProps = new Properties(); + connProps.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); + connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); + connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); + Connection conn = DriverManager.getConnection(jdbcUrl, connProps); + return conn; +} +``` +2. 在配置文件中指定firstEp和secondEp +``` +# first fully qualified domain name (FQDN) for TDengine system +firstEp cluster_node1:6030 -3. 客户端配置文件 taos.cfg - - linux 系统默认配置文件为 /var/lib/taos/taos.cfg,windows 系统默认配置文件路径为 C:\TDengine\cfg\taos.cfg。 -```properties -# client default username -# defaultUser root - -# client default password -# defaultPass taosdata +# second fully qualified domain name (FQDN) for TDengine system, for cluster only +secondEp cluster_node2:6030 # default system charset # charset UTF-8 @@ -128,6 +147,19 @@ public Connection getConn() throws Exception{ # system locale # locale en_US.UTF-8 ``` + +以上示例,jdbc会使用客户端的配置文件,建立到hostname为cluster_node1,端口为6030,数据库名为test的连接。当集群中firstEp节点失效时,JDBC会尝试使用secondEp连接集群。 +TDengine中,只要保证firstEp和secondEp中一个节点有效,就可以正常建立到集群的连接。 + +> 注意:这里的配置文件指的是调用JDBC Connector的应用程序所在机器上的配置文件,Linux OS 上默认值 /etc/taos/taos.cfg ,Windows OS 上默认值 C://TDengine/cfg/taos.cfg。 + +#### 配置参数的优先级 +通过以上3种方式获取连接,如果配置参数在url、Properties、客户端配置文件中有重复,则参数的`优先级由高到低`分别如下: +1. JDBC URL 参数,如上所述,可以在 JDBC URL 的参数中指定。 +2. Properties connProps +3. 客户端配置文件 taos.cfg +例如:在url中指定了password为taosdata,在Properties中指定了password为taosdemo,那么,JDBC会使用url中的password建立连接。 + > 更多详细配置请参考[客户端配置][13] ### 创建数据库和表 diff --git a/documentation20/webdocs/markdowndocs/faq-ch.md b/documentation20/webdocs/markdowndocs/faq-ch.md index 7bbf7531c805eed1b3711cbe67a6dcfbc7fae3a1..80deb889ef0eee8e9b47f86b5e58a76c6c070d5b 100644 --- a/documentation20/webdocs/markdowndocs/faq-ch.md +++ b/documentation20/webdocs/markdowndocs/faq-ch.md @@ -21,7 +21,7 @@ ## 5. 遇到错误"Unable to establish connection", 我怎么办? -客户端遇到链接故障,请按照下面的步骤进行检查: +客户端遇到连接故障,请按照下面的步骤进行检查: 1. 检查网络环境 * 云服务器:检查云服务器的安全组是否打开TCP/UDP 端口6030-6042的访问权限 @@ -45,7 +45,7 @@ 9. 如果仍不能排除连接故障,请使用命令行工具nc来分别判断指定端口的TCP和UDP连接是否通畅 检查UDP端口连接是否工作:`nc -vuz {hostIP} {port} ` 检查服务器侧TCP端口连接是否工作:`nc -l {port}` - 检查客户端侧TCP端口链接是否工作:`nc {hostIP} {port}` + 检查客户端侧TCP端口连接是否工作:`nc {hostIP} {port}` 10. 也可以使用taos程序内嵌的网络连通检测功能,来验证服务器和客户端之间指定的端口连接是否通畅(包括TCP和UDP):[TDengine 内嵌网络检测工具使用指南](https://www.taosdata.com/blog/2020/09/08/1816.html)。 @@ -57,7 +57,7 @@ 1. 请检查连接的服务器的FQDN是否正确,FQDN配置参考:[一篇文章说清楚TDengine的FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html)。 2. 如果网络配置有DNS server, 请检查是否正常工作 3. 如果网络没有配置DNS server, 请检查客户端所在机器的hosts文件,查看该FQDN是否配置,并是否有正确的IP地址。 -4. 如果网络配置OK,从客户端所在机器,你需要能Ping该连接的FQDN,否则客户端是无法链接服务器的 +4. 如果网络配置OK,从客户端所在机器,你需要能Ping该连接的FQDN,否则客户端是无法连接服务器的 ## 7. 虽然语法正确,为什么我还是得到 "Invalid SQL" 错误 @@ -108,4 +108,8 @@ Connection = DriverManager.getConnection(url, properties); 附上必要的问题描述,以及发生该问题的执行操作,出现问题的表征及大概的时间,在 GitHub提交Issue。 -为了保证有足够的debug信息,如果问题能够重复,请修改/etc/taos/taos.cfg文件,最后面添加一行“debugFlag 135"(不带引号本身),然后重启taosd, 重复问题,然后再递交。但系统正常运行时,请一定将debugFlag设置为131,否则会产生大量的日志信息,降低系统效率。 +为了保证有足够的debug信息,如果问题能够重复,请修改/etc/taos/taos.cfg文件,最后面添加一行“debugFlag 135"(不带引号本身),然后重启taosd, 重复问题,然后再递交。也可以通过如下SQL语句,临时设置taosd的日志级别。 +``` + alter dnode debugFlag 135; +``` +但系统正常运行时,请一定将debugFlag设置为131,否则会产生大量的日志信息,降低系统效率。 diff --git a/documentation20/webdocs/markdowndocs/insert-ch.md b/documentation20/webdocs/markdowndocs/insert-ch.md index 5e4532dfd0ae16e03dc9d88f917029075bca2250..fa53cbd62b17169c0f54877a62da8c48ac21edcf 100644 --- a/documentation20/webdocs/markdowndocs/insert-ch.md +++ b/documentation20/webdocs/markdowndocs/insert-ch.md @@ -22,9 +22,10 @@ INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6, **Tips:** -- 要提高写入效率,需要批量写入。一批写入的记录条数越多,插入效率就越高。但一条记录不能超过16K,一条SQL语句总长度不能超过64K(可通过参数maxSQLLength配置,最大可配置为8M)。 +- 要提高写入效率,需要批量写入。一批写入的记录条数越多,插入效率就越高。但一条记录不能超过16K,一条SQL语句总长度不能超过64K(可通过参数maxSQLLength配置,最大可配置为1M)。 - TDengine支持多线程同时写入,要进一步提高写入速度,一个客户端需要打开20个以上的线程同时写。但线程数达到一定数量后,无法再提高,甚至还会下降,因为线程切频繁切换,带来额外开销。 - 对同一张表,如果新插入记录的时间戳已经存在,新记录将被直接抛弃,也就是说,在一张表里,时间戳必须是唯一的。如果应用自动生成记录,很有可能生成的时间戳是一样的,这样,成功插入的记录条数会小于应用插入的记录条数。 +- 写入的数据的时间戳必须大于当前时间减去配置参数keep的时间。如果keep配置为3650天,那么无法写入比3650天还老的数据。写入数据的时间戳也不能大于当前时间加配置参数days。如果days配置为2,那么无法写入比当前时间还晚2天的数据。 ## Prometheus直接写入 [Prometheus](https://www.prometheus.io/)作为Cloud Native Computing Fundation毕业的项目,在性能监控以及K8S性能监控领域有着非常广泛的应用。TDengine提供一个小工具[Bailongma](https://github.com/taosdata/Bailongma),只需在Prometheus做简单配置,无需任何代码,就可将Prometheus采集的数据直接写入TDengine,并按规则在TDengine自动创建库和相关表项。博文[用Docker容器快速搭建一个Devops监控Demo](https://www.taosdata.com/blog/2020/02/03/1189.html)即是采用bailongma将Prometheus和Telegraf的数据写入TDengine中的示例,可以参考。 diff --git a/documentation20/webdocs/markdowndocs/replica-ch.md b/documentation20/webdocs/markdowndocs/replica-ch.md index c32928b42d806c66b3e8bfe66943d4b199c34acc..1d80174455913a5de55678151811218e6f3d749c 100644 --- a/documentation20/webdocs/markdowndocs/replica-ch.md +++ b/documentation20/webdocs/markdowndocs/replica-ch.md @@ -66,21 +66,21 @@ TDengine采取的是Master-Slave模式进行同步,与流行的RAFT一致性 数据实时复制有三个主要流程:选主、数据转发、数据恢复。后续做详细讨论。 -## 虚拟节点之间的网络链接 +## 虚拟节点之间的网络连接 -虚拟节点之间通过TCP进行链接,节点之间的状态交换、数据包的转发都是通过这个TCP链接(peerFd)进行。为避免竞争,两个虚拟节点之间的TCP链接,总是由IP地址(UINT32)小的节点作为TCP客户端发起。一旦TCP链接被中断,虚拟节点能通过TCP socket自动检测到,将对方标为offline。如果监测到任何错误(比如数据恢复流程),虚拟节点将主动重置该链接。 +虚拟节点之间通过TCP进行连接,节点之间的状态交换、数据包的转发都是通过这个TCP连接(peerFd)进行。为避免竞争,两个虚拟节点之间的TCP连接,总是由IP地址(UINT32)小的节点作为TCP客户端发起。一旦TCP连接被中断,虚拟节点能通过TCP socket自动检测到,将对方标为offline。如果监测到任何错误(比如数据恢复流程),虚拟节点将主动重置该连接。 -一旦作为客户端的节点链接不成或中断,它将周期性的每隔一秒钟去试图去链接一次。因为TCP本身有心跳机制,虚拟节点之间不再另行提供心跳。 +一旦作为客户端的节点连接不成或中断,它将周期性的每隔一秒钟去试图去连接一次。因为TCP本身有心跳机制,虚拟节点之间不再另行提供心跳。 -如果一个unsynced节点要发起数据恢复流程,它与Master将建立起专有的TCP链接(syncFd)。数据恢复完成后,该链接会被关闭。而且为限制资源的使用,系统只容许一定数量(配置参数tsMaxSyncNum)的数据恢复的socket存在。如果超过这个数字,系统会将新的数据恢复请求延后处理。 +如果一个unsynced节点要发起数据恢复流程,它与Master将建立起专有的TCP连接(syncFd)。数据恢复完成后,该连接会被关闭。而且为限制资源的使用,系统只容许一定数量(配置参数tsMaxSyncNum)的数据恢复的socket存在。如果超过这个数字,系统会将新的数据恢复请求延后处理。 -任意一个节点,无论有多少虚拟节点,都会启动而且只会启动一个TCP server, 来接受来自其他虚拟节点的上述两类TCP的链接请求。当TCP socket建立起来,客户端侧发送的消息体里会带有vgId(全局唯一的vgroup ID), TCP 服务器侧会检查该vgId是否已经在该节点启动运行。如果已经启动运行,就接受其请求。如果不存在,就直接将链接请求关闭。在TDengine代码里,mnode group的vgId设置为1。 +任意一个节点,无论有多少虚拟节点,都会启动而且只会启动一个TCP server, 来接受来自其他虚拟节点的上述两类TCP的连接请求。当TCP socket建立起来,客户端侧发送的消息体里会带有vgId(全局唯一的vgroup ID), TCP 服务器侧会检查该vgId是否已经在该节点启动运行。如果已经启动运行,就接受其请求。如果不存在,就直接将连接请求关闭。在TDengine代码里,mnode group的vgId设置为1。 ## 选主流程 当同一组的两个虚拟节点之间(vnode A, vnode B)建立连接后,他们互换status消息。status消息里包含本地存储的同一虚拟节点组内所有虚拟节点的role和version。 -如果一个虚拟节点(vnode A)检测到与同一虚拟节点组内另外一虚拟节点(vnode B)的链接中断,vnode A将立即把vnode B的role设置为offline。无论是接收到另外一虚拟节点发来的status消息,还是检测与另外一虚拟节点的链接中断,该虚拟节点都将进入状态处理流程。状态处理流程的规则如下: +如果一个虚拟节点(vnode A)检测到与同一虚拟节点组内另外一虚拟节点(vnode B)的连接中断,vnode A将立即把vnode B的role设置为offline。无论是接收到另外一虚拟节点发来的status消息,还是检测与另外一虚拟节点的连接中断,该虚拟节点都将进入状态处理流程。状态处理流程的规则如下: 1. 如果检测到在线的节点数没有超过一半,则将自己的状态设置为unsynced. 2. 如果在线的虚拟节点数超过一半,会检查master节点是否存在,如果存在,则会决定是否将自己状态改为slave或启动数据恢复流程 @@ -118,7 +118,7 @@ TDengine采取的是Master-Slave模式进行同步,与流行的RAFT一致性 9. 如果quorum为1,上述6,7,8步不会发生。 10. 如果要等待slave的确认,master会启动2秒的定时器(可配置),如果超时,则认为失败。 -对于回复确认,sync模块提供的是异步回调函数,因此APP在调用syncForwardToPeer之后,无需等待,可以处理下一个操作。在Master与Slave的TCP链接管道里,可能有多个Forward消息,这些消息是严格按照应用提供的顺序排好的。对于Forward Response也是一样,TCP管道里存在多个,但都是排序好的。这个顺序,SYNC模块并没有做特别的事情,是由APP单线程顺序写来保证的(TDengine里每个vnode的写数据,都是单线程)。 +对于回复确认,sync模块提供的是异步回调函数,因此APP在调用syncForwardToPeer之后,无需等待,可以处理下一个操作。在Master与Slave的TCP连接管道里,可能有多个Forward消息,这些消息是严格按照应用提供的顺序排好的。对于Forward Response也是一样,TCP管道里存在多个,但都是排序好的。这个顺序,SYNC模块并没有做特别的事情,是由APP单线程顺序写来保证的(TDengine里每个vnode的写数据,都是单线程)。 ## 数据恢复流程 @@ -142,9 +142,9 @@ TDengine采取的是Master-Slave模式进行同步,与流行的RAFT一致性
    -1. 通过已经建立的TCP链接,发送sync req给master节点 -2. master收到sync req后,以client的身份,向vnode B主动建立一新的专用于同步的TCP链接(syncFd) -3. 新的TCP链接建立成功后,master将开始retrieve流程,对应的,vnode B将同步启动restore流程 +1. 通过已经建立的TCP连接,发送sync req给master节点 +2. master收到sync req后,以client的身份,向vnode B主动建立一新的专用于同步的TCP连接(syncFd) +3. 新的TCP连接建立成功后,master将开始retrieve流程,对应的,vnode B将同步启动restore流程 4. Retrieve/Restore流程里,先处理所有archived data (vnode里的data, head, last文件),后处理WAL data。 5. 对于archived data,master将通过回调函数getFileInfo获取数据文件的基本信息,包括文件名、magic以及文件大小。 6. master 将获得的文件名、magic以及文件大小发给vnode B @@ -157,7 +157,7 @@ TDengine采取的是Master-Slave模式进行同步,与流行的RAFT一致性 1. master节点调用回调函数getWalInfo,获取WAL的文件名。 2. 如果getWalInfo返回值大于0,表示该文件还不是最后一个WAL,因此master调用sendfile一下把该文件发送给vnode B 3. 如果getWalInfo返回时为0,表示该文件是最后一个WAL,因为文件可能还处于写的状态中,sync模块要根据WAL Head的定义逐条读出记录,然后发往vnode B。 -4. vnode A读取TCP链接传来的数据,按照WAL Head,逐条读取,如果版本号比现有的大,调用回调函数writeToCache,交给应用处理。如果小,直接扔掉。 +4. vnode A读取TCP连接传来的数据,按照WAL Head,逐条读取,如果版本号比现有的大,调用回调函数writeToCache,交给应用处理。如果小,直接扔掉。 5. 上述流程循环,直到所有WAL文件都被处理完。处理完后,master就会将新来的数据包通过Forward消息转发给slave。 从同步文件启动起,sync模块会通过inotify监控所有处理过的file以及wal。一旦发现被处理过的文件有更新变化,同步流程将中止,会重新启动。因为有可能落盘操作正在进行(比如历史数据导入,内存数据落盘),把已经处理过的文件进行了修改,需要重新同步才行。 @@ -194,15 +194,15 @@ sync模块通过inotify监控LastWal文件的更新和关闭操作。而且在 因为写入失败,客户端会重新写入数据。但对于TDengine而言,是OK的。因为时序数据都是有时间戳的,时间戳相同的数据更新操作,第一次会执行,但第二次会自动扔掉。对于Meta Data(增加、删除库、表等等)的操作,也是OK的。一张表、库已经被创建或删除,再创建或删除,不会被执行的。 -在TDengine的设计里,虚拟节点与虚拟节点之间,是一个TCP链接,是一个pipeline,数据块一个接一个按顺序在这个pipeline里等待处理。一旦某个数据块的处理失败,这个链接会被重置,后续的数据块的处理都会失败。因此不会存在Pipeline里一个数据块更新失败,但下一个数据块成功的可能。 +在TDengine的设计里,虚拟节点与虚拟节点之间,是一个TCP连接,是一个pipeline,数据块一个接一个按顺序在这个pipeline里等待处理。一旦某个数据块的处理失败,这个连接会被重置,后续的数据块的处理都会失败。因此不会存在Pipeline里一个数据块更新失败,但下一个数据块成功的可能。 ## Split Brain的问题 选举流程中,有个强制要求,那就是一定有超过半数的虚拟节点在线。但是如果replication正好是偶数,这个时候,完全可能存在splt brain问题。 -为解决这个问题,TDengine提供Arbitrator的解决方法。Arbitrator是一个节点,它的任务就是接受任何虚拟节点的链接请求,并保持它。 +为解决这个问题,TDengine提供Arbitrator的解决方法。Arbitrator是一个节点,它的任务就是接受任何虚拟节点的连接请求,并保持它。 -在启动复制模块实例时,在配置参数中,应用可以提供Arbitrator的IP地址。如果是奇数个副本,复制模块不会与这个arbitrator去建立链接,但如果是偶数个副本,就会主动去建立链接。 +在启动复制模块实例时,在配置参数中,应用可以提供Arbitrator的IP地址。如果是奇数个副本,复制模块不会与这个arbitrator去建立连接,但如果是偶数个副本,就会主动去建立连接。 Arbitrator的程序tarbitrator.c在复制模块的同一目录, 编译整个系统时,会在bin目录生成。命令行参数“-?”查看可以配置的参数,比如绑定的IP地址,监听的端口号。 diff --git a/documentation20/webdocs/markdowndocs/taosd-ch.md b/documentation20/webdocs/markdowndocs/taosd-ch.md index 8143137c795ece91eace923d8c4945bc36c27e9b..08be0c163e7076b58f03ff8ea3165e902a80fe64 100644 --- a/documentation20/webdocs/markdowndocs/taosd-ch.md +++ b/documentation20/webdocs/markdowndocs/taosd-ch.md @@ -13,7 +13,7 @@ taosd的启动入口是dnode模块,dnode然后启动其他模块,包括可 该模块负责taosd与taosc, 以及其他数据节点之间的通讯。TDengine没有采取标准的HTTP或gRPC等第三方工具,而是实现了自己的通讯模块RPC。 -考虑到物联网场景下,数据写入的包一般不大,因此除支持TCP链接之外,RPC还支持UDP链接。当数据包小于15K时,RPC将采用UDP方式进行链接,否则将采用TCP链接。对于查询类的消息,RPC不管包的大小,总是采取TCP链接。对于UDP链接,RPC实现了自己的超时、重传、顺序检查等机制,以保证数据可靠传输。 +考虑到物联网场景下,数据写入的包一般不大,因此除支持TCP连接之外,RPC还支持UDP连接。当数据包小于15K时,RPC将采用UDP方式进行连接,否则将采用TCP连接。对于查询类的消息,RPC不管包的大小,总是采取TCP连接。对于UDP连接,RPC实现了自己的超时、重传、顺序检查等机制,以保证数据可靠传输。 RPC模块还提供数据压缩功能,如果数据包的字节数超过系统配置参数compressMsgSize, RPC在传输中将自动压缩数据,以节省带宽。 @@ -25,7 +25,7 @@ RPC模块还提供数据压缩功能,如果数据包的字节数超过系统 - 系统的初始化,包括 - 从文件taos.cfg读取系统配置参数,从文件dnodeCfg.json读取数据节点的配置参数; - - 启动RPC模块,并建立起与taosc通讯的server链接,与其他数据节点通讯的server链接; + - 启动RPC模块,并建立起与taosc通讯的server连接,与其他数据节点通讯的server连接; - 启动并初始化dnode的内部管理, 该模块将扫描该数据节点已有的vnode,并打开它们; - 初始化可配置的模块,如mnode, http, monitor等。 - 数据节点的管理,包括 @@ -61,7 +61,7 @@ vnode与其子模块是通过API直接调用,而不是通过消息队列传递 mnode是整个系统的大脑,负责整个系统的资源调度,负责meta data的管理与存储。 -一个运行的系统里,只有一个mnode,但它有多个副本(由系统配置参数numOfMpeers控制)。这些副本分布在不同的dnode里,目的是保证系统的高可靠运行。副本之间的数据复制是采用同步而非异步的方式,以确保数据的一致性,确保数据不会丢失。这些副本会自动选举一个Master,其他副本是slave。所有数据更新类的操作,都只能在master上进行,而查询类的可以在slave节点上进行。代码实现上,同步模块与vnode共享,但mnode被分配一个特殊的vgroup ID: 1,而且quorum大于1。整个集群系统是由多个dnode组成的,运行的mnode的副本数不可能超过dnode的个数,但不会超过配置的副本数。如果某个mnode副本宕机一段时间,只要超过半数的mnode副本仍在运行,运行的mnode会自动根据整个系统的资源情况,在其他dnode里再启动一个mnode, 以保证运行的副本数。 +一个运行的系统里,只有一个mnode,但它有多个副本(由系统配置参数numOfMnodes控制)。这些副本分布在不同的dnode里,目的是保证系统的高可靠运行。副本之间的数据复制是采用同步而非异步的方式,以确保数据的一致性,确保数据不会丢失。这些副本会自动选举一个Master,其他副本是slave。所有数据更新类的操作,都只能在master上进行,而查询类的可以在slave节点上进行。代码实现上,同步模块与vnode共享,但mnode被分配一个特殊的vgroup ID: 1,而且quorum大于1。整个集群系统是由多个dnode组成的,运行的mnode的副本数不可能超过dnode的个数,但不会超过配置的副本数。如果某个mnode副本宕机一段时间,只要超过半数的mnode副本仍在运行,运行的mnode会自动根据整个系统的资源情况,在其他dnode里再启动一个mnode, 以保证运行的副本数。 各个dnode通过信息交换,保存有mnode各个副本的End Point列表,并向其中的master节点定时(间隔由系统配置参数statusInterval控制)发送status消息,消息体里包含该dnode的CPU、内存、剩余存储空间、vnode个数,以及各个vnode的状态(存储空间、原始数据大小、记录条数、角色等)。这样mnode就了解整个系统的资源情况,如果用户创建新的表,就可以决定需要在哪个dnode创建;如果增加或删除dnode, 或者监测到某dnode数据过热、或离线太长,就可以决定需要挪动那些vnode,以实现负载均衡。 diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg index fdb846670656b189d12368c519348367ec4d2974..974b2b05c12f9fd5a482ef0072a9dacc2d1f09dc 100644 --- a/packaging/cfg/taos.cfg +++ b/packaging/cfg/taos.cfg @@ -6,73 +6,76 @@ ######################################################## # first fully qualified domain name (FQDN) for TDengine system -# firstEp hostname1:6030 - -# second fully qualified domain name (FQDN) for TDengine system, for cluster only -# secondEp cluster_hostname2:6030 +# firstEp hostname:6030 # local fully qualified domain name (FQDN) -# fqdn hostname +# fqdn hostname # first port number for the connection (12 continuous UDP/TCP port number are used) -# serverPort 6030 +# serverPort 6030 # log file's directory -# logDir /var/log/taos +# logDir /var/log/taos # data file's directory -# dataDir /var/lib/taos +# dataDir /var/lib/taos # the arbitrator's fully qualified domain name (FQDN) for TDengine system, for cluster only -# arbitrator arbitrator_hostname:6042 +# arbitrator arbitrator_hostname:6042 # number of threads per CPU core -# numOfThreadsPerCore 1.0 +# numOfThreadsPerCore 1.0 + +# the proportion of total threads responsible for query +# ratioOfQueryThreads 0.5 # number of management nodes in the system -# numOfMnodes 3 +# numOfMnodes 3 # enable/disable backuping vnode directory when removing dnode -# vnodeBak 1 +# vnodeBak 1 + +# if report installation / use information +# telemetryReporting 1 # enable/disable load balancing -# balance 1 +# balance 1 # role for dnode. 0 - any, 1 - mnode, 2 - dnode -# role 0 +# role 0 # max timer control blocks -# maxTmrCtrl 512 +# maxTmrCtrl 512 # time interval of system monitor, seconds -# monitorInterval 30 +# monitorInterval 30 # number of seconds allowed for a dnode to be offline, for cluster only -# offlineThreshold 8640000 +# offlineThreshold 8640000 # RPC re-try timer, millisecond -# rpcTimer 300 +# rpcTimer 300 # RPC maximum time for ack, seconds. -# rpcMaxTime 600 +# rpcMaxTime 600 # time interval of dnode status reporting to mnode, seconds, for cluster only -# statusInterval 1 +# statusInterval 1 # time interval of heart beat from shell to dnode, seconds -# shellActivityTimer 3 +# shellActivityTimer 3 # time of keeping table meta data in cache, seconds -# tableMetaKeepTimer 7200 +# tableMetaKeepTimer 7200 # minimum sliding window time, milli-second -# minSlidingTime 10 +# minSlidingTime 10 # minimum time window, milli-second -# minIntervalTime 10 +# minIntervalTime 10 # maximum delay before launching a stream compution, milli-second -# maxStreamCompDelay 20000 +# maxStreamCompDelay 20000 # maximum delay before launching a stream computation for the first time, milli-second # maxFirstStreamCompDelay 10000 @@ -89,9 +92,6 @@ # max number of tables per vnode # maxTablesPerVnode 1000000 -# step size of increasing table number in a vnode -# tableIncStepPerVnode 1000 - # cache block size (Mbyte) # cache 16 @@ -110,6 +110,9 @@ # maximum rows of records in file block # maxRows 4096 +# the number of acknowledgments required for successful data writing +# quorum 1 + # enable/disable compression # comp 2 @@ -122,15 +125,6 @@ # number of replications, for cluster only # replica 1 -# mqtt hostname -# mqttHostName test.mosquitto.org - -# mqtt port -# mqttPort 1883 - -# mqtt topic -# mqttTopic /test - # the compressed rpc message, option: # -1 (no compression) # 0 (all message compressed), @@ -167,12 +161,12 @@ # stop writing data when the disk size of the log folder is less than this value # minimalDataDirGB 0.1 +# One mnode is equal to the number of vnode consumed +# mnodeEqualVnodeNum 4 + # enbale/disable http service # http 1 -# enable/disable muqq service -# mqtt 0 - # enable/disable system monitor # monitor 1 @@ -189,11 +183,12 @@ # max number of rows per log filters # numOfLogLines 10000000 +# enable/disable async log +# asyncLog 1 + # time of keeping log files, days # logKeepDays 0 -# enable/disable async log -# asyncLog 1 # The following parameters are used for debug purpose only. # debugFlag 8 bits mask: FILE-SCREEN-UNUSED-HeartBeat-DUMP-TRACE_WARN-ERROR @@ -231,18 +226,12 @@ # debug flag for JNI # jniDebugflag 131 -# debug flag for ODBC -# odbcDebugflag 131 - # debug flag for storage # uDebugflag 131 # debug flag for http server # httpDebugFlag 131 -# debug flag for mqtt -# mqttDebugFlag 131 - # debug flag for monitor # monitorDebugFlag 131 @@ -255,6 +244,9 @@ # debug flag for http server # tsdbDebugFlag 131 +# debug flag for continue query +# cqDebugFlag 131 + # enable/disable recording the SQL in taos client # tscEnableRecordSql 0 diff --git a/packaging/deb/makedeb.sh b/packaging/deb/makedeb.sh index f05d7f3414fbd787a97e13ca3084fddf878e98c9..450c6a8f551fe7dd8dff5e53f5dad639aec4656e 100755 --- a/packaging/deb/makedeb.sh +++ b/packaging/deb/makedeb.sh @@ -57,6 +57,7 @@ cp -r ${top_dir}/tests/examples/* ${pkg_dir}${install_home_pat cp -r ${top_dir}/src/connector/grafanaplugin ${pkg_dir}${install_home_path}/connector cp -r ${top_dir}/src/connector/python ${pkg_dir}${install_home_path}/connector cp -r ${top_dir}/src/connector/go ${pkg_dir}${install_home_path}/connector +cp -r ${top_dir}/src/connector/nodejs ${pkg_dir}${install_home_path}/connector cp ${compile_dir}/build/lib/taos-jdbcdriver*dist.* ${pkg_dir}${install_home_path}/connector cp -r ${compile_dir}/../packaging/deb/DEBIAN ${pkg_dir}/ diff --git a/packaging/docker/Dockerfile b/packaging/docker/Dockerfile index 668d5a49eb53aebe6185d1dc75a22afab4da3367..44ccafd04460c8beef0a4b2f5ae715033328f807 100644 --- a/packaging/docker/Dockerfile +++ b/packaging/docker/Dockerfile @@ -1,11 +1,13 @@ -FROM centos:7 +FROM ubuntu:20.04 WORKDIR /root +ARG version +RUN echo $version COPY tdengine.tar.gz /root/ RUN tar -zxf tdengine.tar.gz -WORKDIR /root/TDengine-server/ -RUN sh install.sh -e no +WORKDIR /root/TDengine-server-$version/ +RUN /bin/bash install.sh -e no ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib" diff --git a/packaging/docker/dockerbuild-aarch64.sh b/packaging/docker/dockerbuild-aarch64.sh new file mode 100755 index 0000000000000000000000000000000000000000..795eaed5491834cf5601e567440a314d6e1f9629 --- /dev/null +++ b/packaging/docker/dockerbuild-aarch64.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -x +docker build --rm -f "Dockerfile" -t tdengine/tdengine-aarch64:$1 "." --build-arg version=$1 +docker login -u tdengine -p $2 #replace the docker registry username and password +docker push tdengine/tdengine-aarch64:$1 diff --git a/packaging/docker/dockerbuild.sh b/packaging/docker/dockerbuild.sh index 7532832c07800d9f55a0043dd3564d5d58e81488..48e2f7ead63356e8210d03beff2add6796558f5b 100755 --- a/packaging/docker/dockerbuild.sh +++ b/packaging/docker/dockerbuild.sh @@ -1,5 +1,5 @@ #!/bin/bash set -x -docker build --rm -f "Dockerfile" -t tdengine/tdengine:$1 "." +docker build --rm -f "Dockerfile" -t tdengine/tdengine:$1 "." --build-arg version=$1 docker login -u tdengine -p $2 #replace the docker registry username and password docker push tdengine/tdengine:$1 diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec index a8303c594a1ec6b54218f89cda040c4db6927a22..4e40263dc4ebaf6b566d20890ecd97f64e160340 100644 --- a/packaging/rpm/tdengine.spec +++ b/packaging/rpm/tdengine.spec @@ -64,6 +64,7 @@ cp %{_compiledir}/../src/inc/taoserror.h %{buildroot}%{homepath}/incl cp -r %{_compiledir}/../src/connector/grafanaplugin %{buildroot}%{homepath}/connector cp -r %{_compiledir}/../src/connector/python %{buildroot}%{homepath}/connector cp -r %{_compiledir}/../src/connector/go %{buildroot}%{homepath}/connector +cp -r %{_compiledir}/../src/connector/nodejs %{buildroot}%{homepath}/connector cp %{_compiledir}/build/lib/taos-jdbcdriver*dist.* %{buildroot}%{homepath}/connector cp -r %{_compiledir}/../tests/examples/* %{buildroot}%{homepath}/examples diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 1cbb3ead9cee61c44f4b311f730f8f23458e72af..aedfb0a6834afbf3c0c8c822b056ea5705f8d2ff 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -272,6 +272,29 @@ function install_config() { break fi done + + # user email + #EMAIL_PATTERN='^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$' + #EMAIL_PATTERN='^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$' + #EMAIL_PATTERN="^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$" + echo + echo -e -n "${GREEN}Enter your email address for priority support or enter empty to skip${NC}: " + read emailAddr + while true; do + if [ ! -z "$emailAddr" ]; then + # check the format of the emailAddr + #if [[ "$emailAddr" =~ $EMAIL_PATTERN ]]; then + # Write the email address to temp file + email_file="${install_main_dir}/email" + ${csudo} bash -c "echo $emailAddr > ${email_file}" + break + #else + # read -p "Please enter the correct email address: " emailAddr + #fi + else + break + fi + done } diff --git a/packaging/tools/makearbi.sh b/packaging/tools/makearbi.sh index bc6179eff2de84086144ef20aae5b5dde00b6470..82808bcae962b2c90d1811d512e18c90419f7211 100755 --- a/packaging/tools/makearbi.sh +++ b/packaging/tools/makearbi.sh @@ -25,9 +25,9 @@ release_dir="${top_dir}/release" #package_name='linux' if [ "$verMode" == "cluster" ]; then - install_dir="${release_dir}/TDengine-enterprise-arbitrator" + install_dir="${release_dir}/TDengine-enterprise-arbitrator-${version}" else - install_dir="${release_dir}/TDengine-arbitrator" + install_dir="${release_dir}/TDengine-arbitrator-${version}" fi # Directories and files. @@ -48,9 +48,9 @@ mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir} cd ${release_dir} if [ "$verMode" == "cluster" ]; then - pkg_name=${install_dir}-${version}-${osType}-${cpuType} + pkg_name=${install_dir}-${osType}-${cpuType} elif [ "$verMode" == "edge" ]; then - pkg_name=${install_dir}-${version}-${osType}-${cpuType} + pkg_name=${install_dir}-${osType}-${cpuType} else echo "unknow verMode, nor cluster or edge" exit 1 diff --git a/packaging/tools/makearbi_power.sh b/packaging/tools/makearbi_power.sh index 5296cc8e3f334c0ed0f8e5ca30137e367b021929..fd50ecd43878de08e7bb94249da8cb64c3630e6e 100755 --- a/packaging/tools/makearbi_power.sh +++ b/packaging/tools/makearbi_power.sh @@ -25,9 +25,9 @@ release_dir="${top_dir}/release" #package_name='linux' if [ "$verMode" == "cluster" ]; then - install_dir="${release_dir}/PowerDB-enterprise-arbitrator" + install_dir="${release_dir}/PowerDB-enterprise-arbitrator-${version}" else - install_dir="${release_dir}/PowerDB-arbitrator" + install_dir="${release_dir}/PowerDB-arbitrator-${version}" fi # Directories and files. @@ -48,9 +48,9 @@ mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir} cd ${release_dir} if [ "$verMode" == "cluster" ]; then - pkg_name=${install_dir}-${version}-${osType}-${cpuType} + pkg_name=${install_dir}-${osType}-${cpuType} elif [ "$verMode" == "edge" ]; then - pkg_name=${install_dir}-${version}-${osType}-${cpuType} + pkg_name=${install_dir}-${osType}-${cpuType} else echo "unknow verMode, nor cluster or edge" exit 1 diff --git a/packaging/tools/makeclient.sh b/packaging/tools/makeclient.sh index 665fb2845c83a05153cf411f65a1a4323e8cc819..e17c678f263cb6b7a0ccbc32250265b9bc5cbd0e 100755 --- a/packaging/tools/makeclient.sh +++ b/packaging/tools/makeclient.sh @@ -32,9 +32,9 @@ release_dir="${top_dir}/release" #package_name='linux' if [ "$verMode" == "cluster" ]; then - install_dir="${release_dir}/TDengine-enterprise-client" + install_dir="${release_dir}/TDengine-enterprise-client-${version}" else - install_dir="${release_dir}/TDengine-client" + install_dir="${release_dir}/TDengine-client-${version}" fi # Directories and files. @@ -97,6 +97,8 @@ if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then cp -r ${examples_dir}/python ${install_dir}/examples cp -r ${examples_dir}/R ${install_dir}/examples cp -r ${examples_dir}/go ${install_dir}/examples + cp -r ${examples_dir}/nodejs ${install_dir}/examples + cp -r ${examples_dir}/C# ${install_dir}/examples fi # Copy driver mkdir -p ${install_dir}/driver @@ -111,8 +113,9 @@ if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then cp ${build_dir}/lib/*.jar ${install_dir}/connector fi cp -r ${connector_dir}/grafanaplugin ${install_dir}/connector/ - cp -r ${connector_dir}/python ${install_dir}/connector/ - cp -r ${connector_dir}/go ${install_dir}/connector + cp -r ${connector_dir}/python ${install_dir}/connector/ + cp -r ${connector_dir}/go ${install_dir}/connector + cp -r ${connector_dir}/nodejs ${install_dir}/connector fi # Copy release note # cp ${script_dir}/release_note ${install_dir} @@ -122,9 +125,9 @@ fi cd ${release_dir} if [ "$verMode" == "cluster" ]; then - pkg_name=${install_dir}-${version}-${osType}-${cpuType} + pkg_name=${install_dir}-${osType}-${cpuType} elif [ "$verMode" == "edge" ]; then - pkg_name=${install_dir}-${version}-${osType}-${cpuType} + pkg_name=${install_dir}-${osType}-${cpuType} else echo "unknow verMode, nor cluster or edge" exit 1 diff --git a/packaging/tools/makeclient_power.sh b/packaging/tools/makeclient_power.sh index d4be52f67911ee22f6d914cdc6bc6de9c7b0fb06..faa5a03f52b4c9b56981a6b1c0918e543262b3bb 100755 --- a/packaging/tools/makeclient_power.sh +++ b/packaging/tools/makeclient_power.sh @@ -32,9 +32,9 @@ release_dir="${top_dir}/release" #package_name='linux' if [ "$verMode" == "cluster" ]; then - install_dir="${release_dir}/PowerDB-enterprise-client" + install_dir="${release_dir}/PowerDB-enterprise-client-${version}" else - install_dir="${release_dir}/PowerDB-client" + install_dir="${release_dir}/PowerDB-client-${version}" fi # Directories and files. @@ -123,7 +123,7 @@ if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then cp -r ${examples_dir}/R ${install_dir}/examples sed -i '/password/ {s/taosdata/powerdb/g}' ${install_dir}/examples/R/command.txt cp -r ${examples_dir}/go ${install_dir}/examples - sed -i '/root/ {s/taosdata/powerdb/g}' ${install_dir}/examples/go/src/taosapp/taosapp.go + sed -i '/root/ {s/taosdata/powerdb/g}' ${install_dir}/examples/go/taosdemo.go fi # Copy driver mkdir -p ${install_dir}/driver @@ -164,9 +164,9 @@ fi cd ${release_dir} if [ "$verMode" == "cluster" ]; then - pkg_name=${install_dir}-${version}-${osType}-${cpuType} + pkg_name=${install_dir}-${osType}-${cpuType} elif [ "$verMode" == "edge" ]; then - pkg_name=${install_dir}-${version}-${osType}-${cpuType} + pkg_name=${install_dir}-${osType}-${cpuType} else echo "unknow verMode, nor cluster or edge" exit 1 diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 796f39ccc07de0498ba7aee905fe02422657245d..75b45b544e0a4abbf709cc4c5b3a3b55dc315f0f 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -25,9 +25,9 @@ release_dir="${top_dir}/release" #package_name='linux' if [ "$verMode" == "cluster" ]; then - install_dir="${release_dir}/TDengine-enterprise-server" + install_dir="${release_dir}/TDengine-enterprise-server-${version}" else - install_dir="${release_dir}/TDengine-server" + install_dir="${release_dir}/TDengine-server-${version}" fi # Directories and files. @@ -113,6 +113,8 @@ if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then cp -r ${examples_dir}/python ${install_dir}/examples cp -r ${examples_dir}/R ${install_dir}/examples cp -r ${examples_dir}/go ${install_dir}/examples + cp -r ${examples_dir}/nodejs ${install_dir}/examples + cp -r ${examples_dir}/C# ${install_dir}/examples fi # Copy driver mkdir -p ${install_dir}/driver @@ -122,10 +124,11 @@ cp ${lib_files} ${install_dir}/driver connector_dir="${code_dir}/connector" mkdir -p ${install_dir}/connector if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then - cp ${build_dir}/lib/*.jar ${install_dir}/connector + cp ${build_dir}/lib/*.jar ${install_dir}/connector cp -r ${connector_dir}/grafanaplugin ${install_dir}/connector/ - cp -r ${connector_dir}/python ${install_dir}/connector/ - cp -r ${connector_dir}/go ${install_dir}/connector + cp -r ${connector_dir}/python ${install_dir}/connector/ + cp -r ${connector_dir}/go ${install_dir}/connector + cp -r ${connector_dir}/nodejs ${install_dir}/connector fi # Copy release note # cp ${script_dir}/release_note ${install_dir} @@ -135,9 +138,9 @@ fi cd ${release_dir} if [ "$verMode" == "cluster" ]; then - pkg_name=${install_dir}-${version}-${osType}-${cpuType} + pkg_name=${install_dir}-${osType}-${cpuType} elif [ "$verMode" == "edge" ]; then - pkg_name=${install_dir}-${version}-${osType}-${cpuType} + pkg_name=${install_dir}-${osType}-${cpuType} else echo "unknow verMode, nor cluster or edge" exit 1 diff --git a/packaging/tools/makepkg_power.sh b/packaging/tools/makepkg_power.sh index 744f78e514611125bd0ecce1d53e5534656924c9..2c02b99787c6d5ad6234de2319bf78b0b09d7e8a 100755 --- a/packaging/tools/makepkg_power.sh +++ b/packaging/tools/makepkg_power.sh @@ -25,9 +25,9 @@ release_dir="${top_dir}/release" #package_name='linux' if [ "$verMode" == "cluster" ]; then - install_dir="${release_dir}/PowerDB-enterprise-server" + install_dir="${release_dir}/PowerDB-enterprise-server-${version}" else - install_dir="${release_dir}/PowerDB-server" + install_dir="${release_dir}/PowerDB-server-${version}" fi # Directories and files. @@ -146,7 +146,7 @@ if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then cp -r ${examples_dir}/R ${install_dir}/examples sed -i '/password/ {s/taosdata/powerdb/g}' ${install_dir}/examples/R/command.txt cp -r ${examples_dir}/go ${install_dir}/examples - sed -i '/root/ {s/taosdata/powerdb/g}' ${install_dir}/examples/go/src/taosapp/taosapp.go + sed -i '/root/ {s/taosdata/powerdb/g}' ${install_dir}/examples/go/taosdemo.go fi # Copy driver mkdir -p ${install_dir}/driver @@ -184,9 +184,9 @@ fi cd ${release_dir} if [ "$verMode" == "cluster" ]; then - pkg_name=${install_dir}-${version}-${osType}-${cpuType} + pkg_name=${install_dir}-${osType}-${cpuType} elif [ "$verMode" == "edge" ]; then - pkg_name=${install_dir}-${version}-${osType}-${cpuType} + pkg_name=${install_dir}-${osType}-${cpuType} else echo "unknow verMode, nor cluster or edge" exit 1 diff --git a/packaging/tools/post.sh b/packaging/tools/post.sh index 0feb64c795159b67920c8a39b53b0125dfb565bf..d91daaa5c44488e34dea7ec2ddec0863699446f2 100755 --- a/packaging/tools/post.sh +++ b/packaging/tools/post.sh @@ -10,6 +10,7 @@ data_dir="/var/lib/taos" log_dir="/var/log/taos" data_link_dir="/usr/local/taos/data" log_link_dir="/usr/local/taos/log" +install_main_dir="/usr/local/taos" # static directory cfg_dir="/usr/local/taos/cfg" @@ -134,6 +135,29 @@ function install_config() { else break fi + done + + # user email + #EMAIL_PATTERN='^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$' + #EMAIL_PATTERN='^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$' + #EMAIL_PATTERN="^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$" + echo + echo -e -n "${GREEN}Enter your email address for priority support or enter empty to skip${NC}: " + read emailAddr + while true; do + if [ ! -z "$emailAddr" ]; then + # check the format of the emailAddr + #if [[ "$emailAddr" =~ $EMAIL_PATTERN ]]; then + # Write the email address to temp file + email_file="${install_main_dir}/email" + ${csudo} bash -c "echo $emailAddr > ${email_file}" + break + #else + # read -p "Please enter the correct email address: " emailAddr + #fi + else + break + fi done } diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index d55be5b8c0e08bb5b0f6745b41328f07d37a7e90..b0d8d8983bab473b8711d19805cea0fef2f10ee7 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: tdengine base: core18 -version: 'RELEASE_VERSION' +version: '2.0.5.1' icon: snap/gui/t-dengine.svg summary: an open-source big data platform designed and optimized for IoT. description: | @@ -72,7 +72,7 @@ parts: - usr/bin/taosd - usr/bin/taos - usr/bin/taosdemo - - usr/lib/libtaos.so.RELEASE_VERSION + - usr/lib/libtaos.so.2.0.5.1 - usr/lib/libtaos.so.1 - usr/lib/libtaos.so diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 898b7cb032846cb85e4cc8767ed6090b35f41e1a..f619edd221c005a8d8e707afa5271072b032f74a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,4 +20,6 @@ ADD_SUBDIRECTORY(tsdb) ADD_SUBDIRECTORY(wal) ADD_SUBDIRECTORY(cq) ADD_SUBDIRECTORY(dnode) +ADD_SUBDIRECTORY(connector/odbc) ADD_SUBDIRECTORY(connector/jdbc) + diff --git a/src/balance/src/balance.c b/src/balance/src/balance.c index 2b1888042c0645a93ae08fe9438085f96e547b71..0e9bb85b25defd169fea8711d3e0b40304500de4 100644 --- a/src/balance/src/balance.c +++ b/src/balance/src/balance.c @@ -126,6 +126,8 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) { balanceAccquireDnodeList(); + mDebug("db:%s, try alloc %d vnodes to vgroup, dnodes total:%d, avail:%d", pVgroup->dbName, pVgroup->numOfVnodes, + mnodeGetDnodesNum(), tsBalanceDnodeListSize); for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) { for (; dnode < tsBalanceDnodeListSize; ++dnode) { SDnodeObj *pDnode = tsBalanceDnodeList[dnode]; @@ -135,17 +137,33 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) { pVnodeGid->pDnode = pDnode; dnode++; vnodes++; + mDebug("dnode:%d, is selected, vnodeIndex:%d", pDnode->dnodeId, i); break; + } else { + mDebug("dnode:%d, is not selected, status:%s vnodes:%d disk:%fGB role:%d", pDnode->dnodeId, + mnodeGetDnodeStatusStr(pDnode->status), pDnode->openVnodes, pDnode->diskAvailable, + pDnode->alternativeRole); } } } if (vnodes != pVgroup->numOfVnodes) { - mDebug("vgId:%d, db:%s need vnodes:%d, but alloc:%d, free them", pVgroup->vgId, pVgroup->dbName, - pVgroup->numOfVnodes, vnodes); balanceReleaseDnodeList(); balanceUnLock(); + mDebug("db:%s, need vnodes:%d, but alloc:%d", pVgroup->dbName, pVgroup->numOfVnodes, vnodes); + + void * pIter = NULL; + SDnodeObj *pDnode = NULL; + while (1) { + pIter = mnodeGetNextDnode(pIter, &pDnode); + if (pDnode == NULL) break; + mDebug("dnode:%d, status:%s vnodes:%d disk:%fGB role:%d", pDnode->dnodeId, mnodeGetDnodeStatusStr(pDnode->status), + pDnode->openVnodes, pDnode->diskAvailable, pDnode->alternativeRole); + mnodeDecDnodeRef(pDnode); + } + sdbFreeIter(pIter); + if (mnodeGetOnlineDnodesNum() == 0) { return TSDB_CODE_MND_NOT_READY; } else { @@ -198,8 +216,8 @@ static bool balanceCheckVgroupReady(SVgObj *pVgroup, SVnodeGid *pRmVnode) { SVnodeGid *pVnode = pVgroup->vnodeGid + i; if (pVnode == pRmVnode) continue; - mTrace("vgId:%d, change vgroup status, dnode:%d status:%d", pVgroup->vgId, pVnode->pDnode->dnodeId, - pVnode->pDnode->status); + mTrace("vgId:%d, check vgroup status, dnode:%d status:%d, vnode role:%s", pVgroup->vgId, pVnode->pDnode->dnodeId, + pVnode->pDnode->status, syncRole[pVnode->role]); if (pVnode->pDnode->status == TAOS_DN_STATUS_DROPPING) continue; if (pVnode->pDnode->status == TAOS_DN_STATUS_OFFLINE) continue; @@ -389,6 +407,7 @@ void balanceReset() { pDnode->lastAccess = 0; if (pDnode->status != TAOS_DN_STATUS_DROPPING) { pDnode->status = TAOS_DN_STATUS_OFFLINE; + pDnode->offlineReason = TAOS_DN_OFF_STATUS_NOT_RECEIVED; } mnodeDecDnodeRef(pDnode); @@ -551,7 +570,9 @@ static void balanceCheckDnodeAccess() { if (tsAccessSquence - pDnode->lastAccess > 3) { if (pDnode->status != TAOS_DN_STATUS_DROPPING && pDnode->status != TAOS_DN_STATUS_OFFLINE) { pDnode->status = TAOS_DN_STATUS_OFFLINE; - mInfo("dnode:%d, set to offline state", pDnode->dnodeId); + pDnode->offlineReason = TAOS_DN_OFF_STATUS_MSG_TIMEOUT; + mInfo("dnode:%d, set to offline state, access seq:%d, last seq:%d", pDnode->dnodeId, tsAccessSquence, + pDnode->lastAccess); balanceSetVgroupOffline(pDnode); } } @@ -935,6 +956,7 @@ static int32_t balanceRetrieveScores(SShowObj *pShow, char *data, int32_t rows, mnodeDecDnodeRef(pDnode); } + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); pShow->numOfReads += numOfRows; return numOfRows; } @@ -955,11 +977,16 @@ static void balanceMonitorDnodeModule() { continue; } - mLInfo("dnode:%d, numOfMnodes:%d expect:%d, add mnode in this dnode", pDnode->dnodeId, numOfMnodes, tsNumOfMnodes); - mnodeAddMnode(pDnode->dnodeId); - + mLInfo("dnode:%d, numOfMnodes:%d expect:%d, create mnode in this dnode", pDnode->dnodeId, numOfMnodes, tsNumOfMnodes); + mnodeCreateMnode(pDnode->dnodeId, pDnode->dnodeEp, true); + +#if 0 + // Only create one mnode each time + return; +#else numOfMnodes = mnodeGetMnodesNum(); if (numOfMnodes >= tsNumOfMnodes) return; +#endif } } diff --git a/src/client/inc/tscLocalMerge.h b/src/client/inc/tscLocalMerge.h index 4e579b0729431b0fc00d69431a304c4546f02fb0..5baa66a9e0229f35c431cea7a0d2dbb9e2ffb0e2 100644 --- a/src/client/inc/tscLocalMerge.h +++ b/src/client/inc/tscLocalMerge.h @@ -72,17 +72,10 @@ typedef struct SLocalReducer { bool orderPrjOnSTable; // projection query on stable } SLocalReducer; -typedef struct SSubqueryState { - int32_t numOfRemain; // the number of remain unfinished subquery - int32_t numOfTotal; // the number of total sub-queries - uint64_t numOfRetrievedRows; // total number of points in this query -} SSubqueryState; - typedef struct SRetrieveSupport { tExtMemBuffer ** pExtMemBuffer; // for build loser tree tOrderDescriptor *pOrderDescriptor; SColumnModel * pFinalColModel; // colModel for final result - SSubqueryState * pState; int32_t subqueryIndex; // index of current vnode in vnode list SSqlObj * pParentSql; tFilePage * localBuffer; // temp buffer, there is a buffer for each vnode to diff --git a/src/client/inc/tscSubquery.h b/src/client/inc/tscSubquery.h index 07e05803979c93f00312e17da0fbd6822b2a522b..bc01de110345e4c90cf5c15d3d7f6b010cb7308d 100644 --- a/src/client/inc/tscSubquery.h +++ b/src/client/inc/tscSubquery.h @@ -28,7 +28,7 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql); void tscSetupOutputColumnIndex(SSqlObj* pSql); void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code); -SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pState, int32_t index); +SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index); void tscHandleMasterJoinQuery(SSqlObj* pSql); @@ -39,7 +39,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql); int32_t tscHandleInsertRetry(SSqlObj* pSql); void tscBuildResFromSubqueries(SSqlObj *pSql); -void **doSetResultRowData(SSqlObj *pSql, bool finalResult); +TAOS_ROW doSetResultRowData(SSqlObj *pSql, bool finalResult); #ifdef __cplusplus } diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index c4fba06426bfed3c45b8ec93933afc8e9ff35438..d86e1aa0fb38f0c7d0da8035352ce51fc318b6b3 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -66,7 +66,6 @@ typedef struct STidTags { #pragma pack(pop) typedef struct SJoinSupporter { - SSubqueryState* pState; SSqlObj* pObj; // parent SqlObj int32_t subqueryIndex; // index of sub query SInterval interval; @@ -83,6 +82,7 @@ typedef struct SJoinSupporter { char* pIdTagList; // result of first stage tags int32_t totalLen; int32_t num; + SArray* pVgroupTables; } SJoinSupporter; typedef struct SVgroupTableInfo { @@ -110,7 +110,6 @@ SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint void* tscDestroyBlockArrayList(SArray* pDataBlockList); int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock); -void tscFreeUnusedDataBlocks(SArray* pDataBlockList); int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SArray* pDataList); int32_t tscGetDataBlockFromList(void* pHashList, SArray* pDataBlockList, int64_t id, int32_t size, int32_t startOffset, int32_t rowSize, const char* tableId, STableMeta* pTableMeta, @@ -151,14 +150,13 @@ int tscAllocPayload(SSqlCmd* pCmd, int size); TAOS_FIELD tscCreateField(int8_t type, const char* name, int16_t bytes); -SFieldSupInfo* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField); -SFieldSupInfo* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* field); +SInternalField* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField); +SInternalField* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* field); -SFieldSupInfo* tscFieldInfoGetSupp(SFieldInfo* pFieldInfo, int32_t index); +SInternalField* tscFieldInfoGetInternalField(SFieldInfo* pFieldInfo, int32_t index); TAOS_FIELD* tscFieldInfoGetField(SFieldInfo* pFieldInfo, int32_t index); void tscFieldInfoUpdateOffset(SQueryInfo* pQueryInfo); -void tscFieldInfoCopy(SFieldInfo* dst, const SFieldInfo* src); void tscFieldInfoUpdateOffsetForInterResult(SQueryInfo* pQueryInfo); int16_t tscFieldInfoGetOffset(SQueryInfo* pQueryInfo, int32_t index); @@ -191,6 +189,7 @@ SColumn* tscColumnListInsert(SArray* pColList, SColumnIndex* colIndex); SArray* tscColumnListClone(const SArray* src, int16_t tableIndex); void tscColumnListDestroy(SArray* pColList); +void tscDequoteAndTrimToken(SStrToken* pToken); int32_t tscValidateName(SStrToken* pToken); void tscIncStreamExecutionCount(void* pStream); @@ -206,8 +205,6 @@ void tscTagCondRelease(STagCond* pCond); void tscGetSrcColumnInfo(SSrcColumnInfo* pColInfo, SQueryInfo* pQueryInfo); -void tscSetFreeHeatBeat(STscObj* pObj); -bool tscShouldFreeHeartBeat(SSqlObj* pHb); bool tscShouldBeFreed(SSqlObj* pSql); STableMetaInfo* tscGetTableMetaInfoFromCmd(SSqlCmd *pCmd, int32_t subClauseIndex, int32_t tableIndex); @@ -219,7 +216,7 @@ SQueryInfo *tscGetQueryInfoDetailSafely(SSqlCmd *pCmd, int32_t subClauseIndex); void tscClearTableMetaInfo(STableMetaInfo* pTableMetaInfo, bool removeFromCache); STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, STableMeta* pTableMeta, - SVgroupsInfo* vgroupList, SArray* pTagCols); + SVgroupsInfo* vgroupList, SArray* pTagCols, SArray* pVgroupTables); STableMetaInfo* tscAddEmptyMetaInfo(SQueryInfo *pQueryInfo); int32_t tscAddSubqueryInfo(SSqlCmd *pCmd); @@ -228,16 +225,19 @@ void tscInitQueryInfo(SQueryInfo* pQueryInfo); void tscClearSubqueryInfo(SSqlCmd* pCmd); void tscFreeVgroupTableInfo(SArray* pVgroupTables); +SArray* tscCloneVgroupTableInfo(SArray* pVgroupTables); +void tscRemoveVgroupTableGroup(SArray* pVgroupTable, int32_t index); int tscGetSTableVgroupInfo(SSqlObj* pSql, int32_t clauseIndex); int tscGetTableMeta(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo); int tscGetMeterMetaEx(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo, bool createIfNotExists); void tscResetForNextRetrieve(SSqlRes* pRes); - -void tscAddTimestampColumn(SQueryInfo* pQueryInfo, int16_t functionId, int16_t tableIndex); void tscDoQuery(SSqlObj* pSql); +SVgroupsInfo* tscVgroupInfoClone(SVgroupsInfo *pInfo); +void* tscVgroupInfoClear(SVgroupsInfo *pInfo); +void tscSCMVgroupInfoCopy(SCMVgroupInfo* dst, const SCMVgroupInfo* src); /** * The create object function must be successful expect for the out of memory issue. * @@ -257,6 +257,8 @@ void tscDoQuery(SSqlObj* pSql); */ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cmd); +void registerSqlObj(SSqlObj* pSql); + SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void* param, int32_t cmd, SSqlObj* pPrevSql); void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClauseIndex, int32_t tableIndex); diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 27e2ee8c76b7a90ee9d11e6c132b17932b54da6a..fa215db2702f63aff4c704f8393255a94987d681 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -80,6 +80,8 @@ enum { DATA_FROM_DATA_FILE = 2, }; +typedef void (*__async_cb_func_t)(void *param, TAOS_RES *tres, int32_t numOfRows); + typedef struct STableComInfo { uint8_t numOfTags; uint8_t precision; @@ -88,10 +90,10 @@ typedef struct STableComInfo { } STableComInfo; typedef struct SCMCorVgroupInfo { - int32_t version; - int8_t inUse; - int8_t numOfEps; - SEpAddr epAddr[TSDB_MAX_REPLICA]; + int32_t version; + int8_t inUse; + int8_t numOfEps; + SEpAddr1 epAddr[TSDB_MAX_REPLICA]; } SCMCorVgroupInfo; typedef struct STableMeta { @@ -99,6 +101,7 @@ typedef struct STableMeta { uint8_t tableType; int16_t sversion; int16_t tversion; + char sTableId[TSDB_TABLE_FNAME_LEN]; SCMVgroupInfo vgroupInfo; SCMCorVgroupInfo corVgroupInfo; STableId id; @@ -106,7 +109,7 @@ typedef struct STableMeta { } STableMeta; typedef struct STableMetaInfo { - STableMeta * pTableMeta; // table meta, cached in client side and acquired by name + STableMeta *pTableMeta; // table meta, cached in client side and acquired by name SVgroupsInfo *vgroupList; SArray *pVgroupTables; // SArray @@ -139,16 +142,17 @@ typedef struct SColumnIndex { int16_t columnIndex; } SColumnIndex; -typedef struct SFieldSupInfo { +typedef struct SInternalField { + TAOS_FIELD field; bool visible; SExprInfo *pArithExprInfo; SSqlExpr *pSqlExpr; -} SFieldSupInfo; +} SInternalField; typedef struct SFieldInfo { - int16_t numOfOutput; // number of column in result - SArray *pFields; // SArray - SArray *pSupportInfo; // SArray + int16_t numOfOutput; // number of column in result + TAOS_FIELD* final; + SArray *internalField; // SArray } SFieldInfo; typedef struct SColumn { @@ -225,10 +229,9 @@ typedef struct STableDataBlocks { typedef struct SQueryInfo { int16_t command; // the command may be different for each subclause, so keep it seperately. uint32_t type; // query/insert type - // TODO refactor + STimeWindow window; // query time window SInterval interval; - int32_t tz; // query client timezone SSqlGroupbyExpr groupbyExpr; // group by tags info SArray * colList; // SArray @@ -260,7 +263,7 @@ typedef struct { }; int32_t insertType; - int32_t clauseIndex; // index of multiple subclause query + int32_t clauseIndex; // index of multiple subclause query char * curSql; // current sql, resume position of sql after parsing paused int8_t parseFinished; @@ -275,7 +278,8 @@ typedef struct { int32_t numOfParams; int8_t dataSourceType; // load data from file or not - int8_t submitSchema; // submit block is built with table schema + int8_t submitSchema; // submit block is built with table schema + STagData tagData; SHashObj *pTableList; // referred table involved in sql SArray *pDataBlocks; // SArray submit data blocks after parsing sql } SSqlCmd; @@ -305,7 +309,7 @@ typedef struct { int32_t numOfGroups; SResRec * pGroupRec; char * data; - void ** tsrow; + TAOS_ROW tsrow; int32_t* length; // length for each field for current row char ** buffer; // Buffer used to put multibytes encoded using unicode (wchar_t) SColumnIndex * pColumnIndex; @@ -333,6 +337,12 @@ typedef struct STscObj { T_REF_DECLARE() } STscObj; +typedef struct SSubqueryState { + int32_t numOfRemain; // the number of remain unfinished subquery + int32_t numOfSub; // the number of total sub-queries + uint64_t numOfRetrievedRows; // total number of points in this query +} SSubqueryState; + typedef struct SSqlObj { void *signature; pthread_t owner; // owner of sql object, by which it is executed @@ -354,10 +364,11 @@ typedef struct SSqlObj { tsem_t rspSem; SSqlCmd cmd; SSqlRes res; - uint16_t numOfSubs; + + SSubqueryState subState; struct SSqlObj **pSubs; - struct SSqlObj * prev, *next; + struct SSqlObj *prev, *next; struct SSqlObj **self; } SSqlObj; @@ -432,19 +443,20 @@ void tscPartiallyFreeSqlObj(SSqlObj *pSql); * @param pObj */ void tscFreeSqlObj(SSqlObj *pSql); - -void tscFreeSqlObjInCache(void *pSql); +void tscFreeRegisteredSqlObj(void *pSql); +void tscFreeTableMetaHelper(void *pTableMeta); void tscCloseTscObj(STscObj *pObj); +// todo move to taos? or create a new file: taos_internal.h TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int), - void *param, void **taos); -void waitForQueryRsp(void *param, TAOS_RES *tres, int code) ; + void *param, TAOS **taos); +TAOS_RES* taos_query_h(TAOS* taos, const char *sqlstr, TAOS_RES** res); +void waitForQueryRsp(void *param, TAOS_RES *tres, int code); -void doAsyncQuery(STscObj *pObj, SSqlObj *pSql, void (*fp)(), void *param, const char *sqlstr, size_t sqlLen); +void doAsyncQuery(STscObj *pObj, SSqlObj *pSql, __async_cb_func_t fp, void *param, const char *sqlstr, size_t sqlLen); void tscProcessMultiVnodesImportFromFile(SSqlObj *pSql); -void tscKillSTableQuery(SSqlObj *pSql); void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen); bool tscIsUpdateQuery(SSqlObj* pSql); bool tscHasReachLimitation(SQueryInfo *pQueryInfo, SSqlRes *pRes); @@ -457,7 +469,7 @@ int32_t tscSQLSyntaxErrMsg(char* msg, const char* additionalInfo, const char* s int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo); static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pFieldInfo, int32_t columnIndex) { - SFieldSupInfo* pInfo = (SFieldSupInfo*) TARRAY_GET_ELEM(pFieldInfo->pSupportInfo, columnIndex); + SInternalField* pInfo = (SInternalField*) TARRAY_GET_ELEM(pFieldInfo->internalField, columnIndex); assert(pInfo->pSqlExpr != NULL); int32_t type = pInfo->pSqlExpr->resType; @@ -470,11 +482,11 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField if (type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_BINARY) { pData = pInfo->pSqlExpr->param[1].pz; pRes->length[columnIndex] = pInfo->pSqlExpr->param[1].nLen; - pRes->tsrow[columnIndex] = (pInfo->pSqlExpr->param[1].nType == TSDB_DATA_TYPE_NULL) ? NULL : pData; + pRes->tsrow[columnIndex] = (pInfo->pSqlExpr->param[1].nType == TSDB_DATA_TYPE_NULL) ? NULL : (unsigned char*)pData; } else { assert(bytes == tDataTypeDesc[type].nSize); - pRes->tsrow[columnIndex] = isNull(pData, type) ? NULL : &pInfo->pSqlExpr->param[1].i64Key; + pRes->tsrow[columnIndex] = isNull(pData, type) ? NULL : (unsigned char*)&pInfo->pSqlExpr->param[1].i64Key; pRes->length[columnIndex] = bytes; } } else { @@ -482,7 +494,7 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField int32_t realLen = varDataLen(pData); assert(realLen <= bytes - VARSTR_HEADER_SIZE); - pRes->tsrow[columnIndex] = (isNull(pData, type)) ? NULL : ((tstr *)pData)->data; + pRes->tsrow[columnIndex] = (isNull(pData, type)) ? NULL : (unsigned char*)((tstr *)pData)->data; if (realLen < pInfo->pSqlExpr->resBytes - VARSTR_HEADER_SIZE) { // todo refactor *(pData + realLen + VARSTR_HEADER_SIZE) = 0; } @@ -491,7 +503,7 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField } else { assert(bytes == tDataTypeDesc[type].nSize); - pRes->tsrow[columnIndex] = isNull(pData, type) ? NULL : pData; + pRes->tsrow[columnIndex] = isNull(pData, type) ? NULL : (unsigned char*)pData; pRes->length[columnIndex] = bytes; } } @@ -509,8 +521,6 @@ extern SRpcCorEpSet tscMgmtEpSet; extern int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo); -typedef void (*__async_cb_func_t)(void *param, TAOS_RES *tres, int numOfRows); - int32_t tscCompareTidTags(const void* p1, const void* p2); void tscBuildVgroupTableInfo(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo, SArray* tables); diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index bd980b75a340dac3e76240e62743a8370b39404c..4e2272eb0566569754df5ef6201f3d190f2789c1 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -149,7 +149,7 @@ JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_initImp(JNIEnv *e JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setOptions(JNIEnv *env, jobject jobj, jint optionIndex, jstring optionValue) { if (optionValue == NULL) { - jniDebug("option index:%d value is null", optionIndex); + jniDebug("option index:%d value is null", (int32_t)optionIndex); return 0; } @@ -183,7 +183,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setOptions(JNIEnv } (*env)->ReleaseStringUTFChars(env, optionValue, tz1); } else { - jniError("option index:%d is not found", optionIndex); + jniError("option index:%d is not found", (int32_t)optionIndex); } return res; @@ -227,10 +227,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn ret = (jlong)taos_connect((char *)host, (char *)user, (char *)pass, (char *)dbname, (uint16_t)jport); if (ret == 0) { jniError("jobj:%p, conn:%p, connect to database failed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret, - (char *)host, (char *)user, (char *)dbname, jport); + (char *)host, (char *)user, (char *)dbname, (int32_t)jport); } else { jniDebug("jobj:%p, conn:%p, connect to database succeed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret, - (char *)host, (char *)user, (char *)dbname, jport); + (char *)host, (char *)user, (char *)dbname, (int32_t)jport); } if (host != NULL) (*env)->ReleaseStringUTFChars(env, jhost, host); @@ -385,7 +385,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getAffectedRowsIm } jint ret = taos_affected_rows((SSqlObj *)res); - jniDebug("jobj:%p, conn:%p, sql:%p, res: %p, affect rows:%d", jobj, tscon, (void *)con, (void *)res, ret); + jniDebug("jobj:%p, conn:%p, sql:%p, res: %p, affect rows:%d", jobj, tscon, (void *)con, (void *)res, (int32_t)ret); return ret; } @@ -490,13 +490,13 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn (*env)->CallVoidMethod(env, rowobj, g_rowdataSetBooleanFp, i, (jboolean)(*((char *)row[i]) == 1)); break; case TSDB_DATA_TYPE_TINYINT: - (*env)->CallVoidMethod(env, rowobj, g_rowdataSetByteFp, i, (jbyte) * ((char *)row[i])); + (*env)->CallVoidMethod(env, rowobj, g_rowdataSetByteFp, i, (jbyte) * ((int8_t *)row[i])); break; case TSDB_DATA_TYPE_SMALLINT: - (*env)->CallVoidMethod(env, rowobj, g_rowdataSetShortFp, i, (jshort) * ((short *)row[i])); + (*env)->CallVoidMethod(env, rowobj, g_rowdataSetShortFp, i, (jshort) * ((int16_t *)row[i])); break; case TSDB_DATA_TYPE_INT: - (*env)->CallVoidMethod(env, rowobj, g_rowdataSetIntFp, i, (jint) * (int *)row[i]); + (*env)->CallVoidMethod(env, rowobj, g_rowdataSetIntFp, i, (jint) * (int32_t *)row[i]); break; case TSDB_DATA_TYPE_BIGINT: (*env)->CallVoidMethod(env, rowobj, g_rowdataSetLongFp, i, (jlong) * ((int64_t *)row[i])); diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 09610575f619be3f02059b6e6ca1ba2c56edcb62..c996bb2a76ff505fca4e09cd8763b324e5c4cb8d 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -40,7 +40,7 @@ static void tscProcessAsyncRetrieveImpl(void *param, TAOS_RES *tres, int numOfRo static void tscAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOfRows); static void tscAsyncFetchSingleRowProxy(void *param, TAOS_RES *tres, int numOfRows); -void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const char* sqlstr, size_t sqlLen) { +void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, __async_cb_func_t fp, void* param, const char* sqlstr, size_t sqlLen) { SSqlCmd* pCmd = &pSql->cmd; pSql->signature = pSql; @@ -51,10 +51,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const pSql->fp = fp; pSql->fetchFp = fp; - uint64_t handle = (uint64_t) pSql; - pSql->self = taosCachePut(tscObjCache, &handle, sizeof(uint64_t), &pSql, sizeof(uint64_t), 2*3600*1000); - - T_REF_INC(pSql->pTscObj); + registerSqlObj(pSql); pSql->sqlstr = calloc(1, sqlLen + 1); if (pSql->sqlstr == NULL) { @@ -330,7 +327,7 @@ void tscAsyncFetchSingleRowProxy(void *param, TAOS_RES *tres, int numOfRows) { } for (int i = 0; i < pCmd->numOfCols; ++i){ - SFieldSupInfo* pSup = taosArrayGet(pQueryInfo->fieldsInfo.pSupportInfo, i); + SInternalField* pSup = taosArrayGet(pQueryInfo->fieldsInfo.internalField, i); if (pSup->pSqlExpr != NULL) { // pRes->tsrow[i] = TSC_GET_RESPTR_BASE(pRes, pQueryInfo, i) + pSup->pSqlExpr->resBytes * pRes->row; } else { @@ -351,7 +348,7 @@ void tscProcessFetchRow(SSchedMsg *pMsg) { SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); for (int i = 0; i < pCmd->numOfCols; ++i) { - SFieldSupInfo* pSup = taosArrayGet(pQueryInfo->fieldsInfo.pSupportInfo, i); + SInternalField* pSup = taosArrayGet(pQueryInfo->fieldsInfo.internalField, i); if (pSup->pSqlExpr != NULL) { tscGetResultColumnChr(pRes, &pQueryInfo->fieldsInfo, i); @@ -364,15 +361,6 @@ void tscProcessFetchRow(SSchedMsg *pMsg) { (*pSql->fetchFp)(pSql->param, pSql, pRes->tsrow); } -void tscProcessAsyncRes(SSchedMsg *pMsg) { - SSqlObj *pSql = (SSqlObj *)pMsg->ahandle; - SSqlRes *pRes = &pSql->res; - assert(pSql->fp != NULL && pSql->fetchFp != NULL); - - pSql->fp = pSql->fetchFp; - (*pSql->fp)(pSql->param, pSql, pRes->code); -} - // this function will be executed by queue task threads, so the terrno is not valid static void tscProcessAsyncError(SSchedMsg *pMsg) { void (*fp)() = pMsg->ahandle; @@ -396,22 +384,15 @@ void tscQueueAsyncRes(SSqlObj *pSql) { if (pSql == NULL || pSql->signature != pSql) { tscDebug("%p SqlObj is freed, not add into queue async res", pSql); return; - } else { - tscError("%p add into queued async res, code:%s", pSql, tstrerror(pSql->res.code)); } - SSchedMsg schedMsg = { 0 }; - schedMsg.fp = tscProcessAsyncRes; - schedMsg.ahandle = pSql; - schedMsg.thandle = (void *)1; - schedMsg.msg = NULL; - taosScheduleTask(tscQhandle, &schedMsg); -} + tscError("%p add into queued async res, code:%s", pSql, tstrerror(pSql->res.code)); -void tscProcessAsyncFree(SSchedMsg *pMsg) { - SSqlObj *pSql = (SSqlObj *)pMsg->ahandle; - tscDebug("%p sql is freed", pSql); - taos_free_result(pSql); + SSqlRes *pRes = &pSql->res; + assert(pSql->fp != NULL && pSql->fetchFp != NULL); + + pSql->fp = pSql->fetchFp; + (*pSql->fp)(pSql->param, pSql, pRes->code); } int tscSendMsgToServer(SSqlObj *pSql); @@ -424,11 +405,11 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { SSqlRes *pRes = &pSql->res; pRes->code = code; + const char* msg = (pCmd->command == TSDB_SQL_STABLEVGROUP)? "vgroup-list":"table-meta"; if (code != TSDB_CODE_SUCCESS) { - tscError("%p get tableMeta failed, code:%s", pSql, tstrerror(code)); + tscError("%p get %s failed, code:%s", pSql, msg, tstrerror(code)); goto _error; } else { - const char* msg = (pCmd->command == TSDB_SQL_STABLEVGROUP)? "vgroup-list":"table-meta"; tscDebug("%p get %s successfully", pSql, msg); } @@ -512,7 +493,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { goto _error; } - if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_STMT_INSERT)) { + if (pCmd->insertType == TSDB_QUERY_TYPE_STMT_INSERT) { STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); code = tscGetTableMeta(pSql, pTableMetaInfo); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index d8ac0d3109fc207278882e365724879a8114897a..7a668e85bf1ebb30362a45e3f96eabbeb0267f6d 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -326,7 +326,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI } else if (functionId == TSDB_FUNC_LAST_ROW) { *type = (int16_t)dataType; *bytes = (int16_t)dataBytes; - *interBytes = dataBytes + sizeof(SLastrowInfo); + *interBytes = dataBytes; } else { return TSDB_CODE_TSC_INVALID_SQL; } @@ -525,7 +525,7 @@ static void do_sum(SQLFunctionCtx *pCtx) { *retVal += pCtx->preAggVals.statis.sum; } else if (pCtx->inputType == TSDB_DATA_TYPE_DOUBLE || pCtx->inputType == TSDB_DATA_TYPE_FLOAT) { double *retVal = (double*) pCtx->aOutputBuf; - *retVal += GET_DOUBLE_VAL(&(pCtx->preAggVals.statis.sum)); + *retVal += GET_DOUBLE_VAL((const char*)&(pCtx->preAggVals.statis.sum)); } } else { // computing based on the true data block void *pData = GET_INPUT_CHAR(pCtx); @@ -768,7 +768,7 @@ static void avg_function(SQLFunctionCtx *pCtx) { if (pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_BIGINT) { *pVal += pCtx->preAggVals.statis.sum; } else if (pCtx->inputType == TSDB_DATA_TYPE_DOUBLE || pCtx->inputType == TSDB_DATA_TYPE_FLOAT) { - *pVal += GET_DOUBLE_VAL(&(pCtx->preAggVals.statis.sum)); + *pVal += GET_DOUBLE_VAL((const char *)&(pCtx->preAggVals.statis.sum)); } } else { void *pData = GET_INPUT_CHAR(pCtx); @@ -1843,8 +1843,10 @@ static void last_row_function(SQLFunctionCtx *pCtx) { pInfo1->hasResult = DATA_SET_FLAG; DO_UPDATE_TAG_COLUMNS(pCtx, pInfo1->ts); + } else { + DO_UPDATE_TAG_COLUMNS(pCtx, pCtx->ptsList[pCtx->size - 1]); } - + SET_VAL(pCtx, pCtx->size, 1); } @@ -2443,8 +2445,8 @@ static bool percentile_function_setup(SQLFunctionCtx *pCtx) { // in the first round, get the min-max value of all involved data SResultInfo *pResInfo = GET_RES_INFO(pCtx); SPercentileInfo *pInfo = pResInfo->interResultBuf; - pInfo->minval = DBL_MAX; - pInfo->maxval = -DBL_MAX; + SET_DOUBLE_VAL(&pInfo->minval, DBL_MAX); + SET_DOUBLE_VAL(&pInfo->maxval, -DBL_MAX); pInfo->numOfElems = 0; return true; @@ -2459,12 +2461,12 @@ static void percentile_function(SQLFunctionCtx *pCtx) { // the first stage, only acquire the min/max value if (pInfo->stage == 0) { if (pCtx->preAggVals.isSet) { - if (pInfo->minval > pCtx->preAggVals.statis.min) { - pInfo->minval = (double)pCtx->preAggVals.statis.min; + if (GET_DOUBLE_VAL(&pInfo->minval) > pCtx->preAggVals.statis.min) { + SET_DOUBLE_VAL(&pInfo->minval, (double)pCtx->preAggVals.statis.min); } - if (pInfo->maxval < pCtx->preAggVals.statis.max) { - pInfo->maxval = (double)pCtx->preAggVals.statis.max; + if (GET_DOUBLE_VAL(&pInfo->maxval) < pCtx->preAggVals.statis.max) { + SET_DOUBLE_VAL(&pInfo->maxval, (double)pCtx->preAggVals.statis.max); } pInfo->numOfElems += (pCtx->size - pCtx->preAggVals.statis.numOfNull); @@ -2498,12 +2500,12 @@ static void percentile_function(SQLFunctionCtx *pCtx) { break; } - if (v < pInfo->minval) { - pInfo->minval = v; + if (v < GET_DOUBLE_VAL(&pInfo->minval)) { + SET_DOUBLE_VAL(&pInfo->minval, v); } - if (v > pInfo->maxval) { - pInfo->maxval = v; + if (v > GET_DOUBLE_VAL(&pInfo->maxval)) { + SET_DOUBLE_VAL(&pInfo->maxval, v); } pInfo->numOfElems += 1; @@ -2562,12 +2564,12 @@ static void percentile_function_f(SQLFunctionCtx *pCtx, int32_t index) { break; } - if (v < pInfo->minval) { - pInfo->minval = v; + if (v < GET_DOUBLE_VAL(&pInfo->minval)) { + SET_DOUBLE_VAL(&pInfo->minval, v); } - if (v > pInfo->maxval) { - pInfo->maxval = v; + if (v > GET_DOUBLE_VAL(&pInfo->maxval)) { + SET_DOUBLE_VAL(&pInfo->maxval, v); } pInfo->numOfElems += 1; @@ -2607,7 +2609,7 @@ static void percentile_next_step(SQLFunctionCtx *pCtx) { } pInfo->stage += 1; - pInfo->pMemBucket = tMemBucketCreate(pCtx->inputBytes, pCtx->inputType, pInfo->minval, pInfo->maxval); + pInfo->pMemBucket = tMemBucketCreate(pCtx->inputBytes, pCtx->inputType, GET_DOUBLE_VAL(&pInfo->minval), GET_DOUBLE_VAL(&pInfo->maxval)); } else { pResInfo->complete = true; } @@ -3514,12 +3516,12 @@ static void spread_function(SQLFunctionCtx *pCtx) { pInfo->max = (double)pCtx->preAggVals.statis.max; } } else if (pCtx->inputType == TSDB_DATA_TYPE_DOUBLE || pCtx->inputType == TSDB_DATA_TYPE_FLOAT) { - if (pInfo->min > GET_DOUBLE_VAL(&(pCtx->preAggVals.statis.min))) { - pInfo->min = GET_DOUBLE_VAL(&(pCtx->preAggVals.statis.min)); + if (pInfo->min > GET_DOUBLE_VAL((const char *)&(pCtx->preAggVals.statis.min))) { + pInfo->min = GET_DOUBLE_VAL((const char *)&(pCtx->preAggVals.statis.min)); } - if (pInfo->max < GET_DOUBLE_VAL(&(pCtx->preAggVals.statis.max))) { - pInfo->max = GET_DOUBLE_VAL(&(pCtx->preAggVals.statis.max)); + if (pInfo->max < GET_DOUBLE_VAL((const char *)&(pCtx->preAggVals.statis.max))) { + pInfo->max = GET_DOUBLE_VAL((const char *)&(pCtx->preAggVals.statis.max)); } } @@ -4023,11 +4025,11 @@ static void ts_comp_function(SQLFunctionCtx *pCtx) { // primary ts must be existed, so no need to check its existance if (pCtx->order == TSDB_ORDER_ASC) { - tsBufAppend(pTSbuf, 0, &pCtx->tag, input, pCtx->size * TSDB_KEYSIZE); + tsBufAppend(pTSbuf, pCtx->param[0].i64Key, &pCtx->tag, input, pCtx->size * TSDB_KEYSIZE); } else { for (int32_t i = pCtx->size - 1; i >= 0; --i) { char *d = GET_INPUT_CHAR_INDEX(pCtx, i); - tsBufAppend(pTSbuf, 0, &pCtx->tag, d, TSDB_KEYSIZE); + tsBufAppend(pTSbuf, pCtx->param[0].i64Key, &pCtx->tag, d, TSDB_KEYSIZE); } } @@ -4046,7 +4048,7 @@ static void ts_comp_function_f(SQLFunctionCtx *pCtx, int32_t index) { STSBuf *pTSbuf = pInfo->pTSBuf; - tsBufAppend(pTSbuf, 0, &pCtx->tag, pData, TSDB_KEYSIZE); + tsBufAppend(pTSbuf, pCtx->param[0].i64Key, &pCtx->tag, pData, TSDB_KEYSIZE); SET_VAL(pCtx, pCtx->size, 1); pResInfo->hasResult = DATA_SET_FLAG; diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index 50f82ae662840a80b717cc99934640626a679d1f..b4c3f3549b1576b3ff83300d4f10d9e07778530d 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -23,7 +23,30 @@ #include "tscUtil.h" #include "tschemautil.h" #include "tsclient.h" - +#include "taos.h" +#include "tscSubquery.h" + +#define STR_NOCASE_EQUAL(str1, len1, str2, len2) ((len1 == len2) && 0 == strncasecmp(str1, str2, len1)) + +typedef enum BuildType { + SCREATE_BUILD_TABLE = 1, + SCREATE_BUILD_DB = 2, +} BuildType; + +typedef enum Stage { + SCREATE_CALLBACK_QUERY = 1, + SCREATE_CALLBACK_RETRIEVE = 2, +} Stage; + +// support 'show create table' +typedef struct SCreateBuilder { + char sTableName[TSDB_TABLE_FNAME_LEN]; + char buf[TSDB_TABLE_FNAME_LEN]; + SSqlObj *pParentSql; + SSqlObj *pInterSql; + int32_t (*fp)(void *para, char* result); + Stage callStage; +} SCreateBuilder; static void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnName, int16_t type, size_t valueLength); static int32_t getToStringLength(const char *pData, int32_t length, int32_t type) { @@ -216,7 +239,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols, TAOS_FIELD f = {.type = TSDB_DATA_TYPE_BINARY, .bytes = (TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE}; tstrncpy(f.name, "Field", sizeof(f.name)); - SFieldSupInfo* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); + SInternalField* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, (TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE, (TSDB_COL_NAME_LEN - 1), false); @@ -272,14 +295,511 @@ static int32_t tscProcessDescribeTable(SSqlObj *pSql) { tscFieldInfoUpdateOffset(pQueryInfo); return tscSetValueToResObj(pSql, rowLen); } +static int32_t tscGetNthFieldResult(TAOS_ROW row, TAOS_FIELD* fields, int *lengths, int idx, char *result) { + const char *val = (const char*)row[idx]; + if (val == NULL) { + sprintf(result, "%s", TSDB_DATA_NULL_STR); + return -1; + } + uint8_t type = fields[idx].type; + int32_t length = lengths[idx]; + + switch (type) { + case TSDB_DATA_TYPE_BOOL: + sprintf(result, "%s", ((((int32_t)(*((char *)val))) == 1) ? "true" : "false")); + break; + case TSDB_DATA_TYPE_TINYINT: + sprintf(result, "%d", *((int8_t *)val)); + break; + case TSDB_DATA_TYPE_SMALLINT: + sprintf(result, "%d", *((int16_t *)val)); + break; + case TSDB_DATA_TYPE_INT: + sprintf(result, "%d", *((int32_t *)val)); + break; + case TSDB_DATA_TYPE_BIGINT: + sprintf(result, "%"PRId64, *((int64_t *)val)); + break; + case TSDB_DATA_TYPE_FLOAT: + sprintf(result, "%f", GET_FLOAT_VAL(val)); + break; + case TSDB_DATA_TYPE_DOUBLE: + sprintf(result, "%f", GET_DOUBLE_VAL(val)); + break; + case TSDB_DATA_TYPE_NCHAR: + case TSDB_DATA_TYPE_BINARY: + memcpy(result, val, length); + break; + case TSDB_DATA_TYPE_TIMESTAMP: + ///formatTimestamp(buf, *(int64_t*)val, TSDB_TIME_PRECISION_MICRO); + //memcpy(result, val, strlen(buf)); + sprintf(result, "%"PRId64, *((int64_t *)val)); + break; + default: + break; + } + return 0; +} + +void tscSCreateCallBack(void *param, TAOS_RES *tres, int code) { + if (param == NULL || tres == NULL) { + return; + } + SCreateBuilder *builder = (SCreateBuilder *)(param); + SSqlObj *pParentSql = builder->pParentSql; + SSqlObj *pSql = (SSqlObj *)tres; + + SSqlRes *pRes = &pParentSql->res; + pRes->code = taos_errno(pSql); + if (pRes->code != TSDB_CODE_SUCCESS) { + taos_free_result(pSql); + free(builder); + tscQueueAsyncRes(pParentSql); + return; + } + + if (builder->callStage == SCREATE_CALLBACK_QUERY) { + taos_fetch_rows_a(tres, tscSCreateCallBack, param); + builder->callStage = SCREATE_CALLBACK_RETRIEVE; + } else { + char *result = calloc(1, TSDB_MAX_BINARY_LEN); + pRes->code = builder->fp(builder, result); + + taos_free_result(pSql); + free(builder); + free(result); + + if (pRes->code == TSDB_CODE_SUCCESS) { + (*pParentSql->fp)(pParentSql->param, pParentSql, code); + } else { + tscQueueAsyncRes(pParentSql); + } + } +} + +TAOS_ROW tscFetchRow(void *param) { + SCreateBuilder *builder = (SCreateBuilder *)param; + if (builder == NULL) { + return NULL; + } + SSqlObj *pSql = builder->pInterSql; + if (pSql == NULL || pSql->signature != pSql) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return NULL; + } + + SSqlCmd *pCmd = &pSql->cmd; + SSqlRes *pRes = &pSql->res; + + if (pRes->qhandle == 0 || + pCmd->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT || + pCmd->command == TSDB_SQL_INSERT) { + return NULL; + } + + // set the sql object owner + tscSetSqlOwner(pSql); + + // current data set are exhausted, fetch more data from node + if (pRes->row >= pRes->numOfRows && (pRes->completed != true || hasMoreVnodesToTry(pSql) || hasMoreClauseToTry(pSql)) && + (pCmd->command == TSDB_SQL_RETRIEVE || + pCmd->command == TSDB_SQL_RETRIEVE_LOCALMERGE || + pCmd->command == TSDB_SQL_TABLE_JOIN_RETRIEVE || + pCmd->command == TSDB_SQL_FETCH || + pCmd->command == TSDB_SQL_SHOW || + pCmd->command == TSDB_SQL_SHOW_CREATE_TABLE || + pCmd->command == TSDB_SQL_SHOW_CREATE_DATABASE || + pCmd->command == TSDB_SQL_SELECT || + pCmd->command == TSDB_SQL_DESCRIBE_TABLE || + pCmd->command == TSDB_SQL_SERV_STATUS || + pCmd->command == TSDB_SQL_CURRENT_DB || + pCmd->command == TSDB_SQL_SERV_VERSION || + pCmd->command == TSDB_SQL_CLI_VERSION || + pCmd->command == TSDB_SQL_CURRENT_USER )) { + taos_fetch_rows_a(pSql, tscSCreateCallBack, param); + return NULL; + } + + void* data = doSetResultRowData(pSql, true); + + tscClearSqlOwner(pSql); + return data; +} +static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) { + TAOS_ROW row = tscFetchRow(builder); + SSqlObj* pSql = builder->pInterSql; + + if (row == NULL) { + return TSDB_CODE_TSC_INVALID_TABLE_NAME; + } + + int32_t* lengths = taos_fetch_lengths(pSql); + int num_fields = taos_num_fields(pSql); + TAOS_FIELD *fields = taos_fetch_fields(pSql); + + char buf[TSDB_COL_NAME_LEN + 16]; + for (int i = 0; i < num_fields; i++) { + memset(buf, 0, sizeof(buf)); + int32_t ret = tscGetNthFieldResult(row, fields, lengths, i, buf); + + if (i == 0) { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s", "("); + } + if ((fields[i].type == TSDB_DATA_TYPE_NCHAR + || fields[i].type == TSDB_DATA_TYPE_BINARY + || fields[i].type == TSDB_DATA_TYPE_TIMESTAMP) && 0 == ret) { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "\"%s\",", buf); + } else { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s,", buf); + } + if (i == num_fields - 1) { + sprintf(result + strlen(result) - 1, "%s", ")"); + } + } + + if (0 == strlen(result)) { + return TSDB_CODE_TSC_INVALID_TABLE_NAME; + } + return TSDB_CODE_SUCCESS; +} + + +// build 'show create table/database' result fields +static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const char *ddl) { + int32_t rowLen = 0; + int16_t ddlLen = (int16_t)strlen(ddl); + SColumnIndex index = {0}; + pSql->cmd.numOfCols = 2; + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + pQueryInfo->order.order = TSDB_ORDER_ASC; + + TAOS_FIELD f; + if (type == SCREATE_BUILD_TABLE) { + f.type = TSDB_DATA_TYPE_BINARY; + f.bytes = (TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE; + tstrncpy(f.name, "Table", sizeof(f.name)); + } else { + f.type = TSDB_DATA_TYPE_BINARY; + f.bytes = (TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE; + tstrncpy(f.name, "Database", sizeof(f.name)); + } + + SInternalField* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); + pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, + f.bytes, f.bytes - VARSTR_HEADER_SIZE, false); + + rowLen += f.bytes; + + f.bytes = (int16_t)(ddlLen + VARSTR_HEADER_SIZE); + f.type = TSDB_DATA_TYPE_BINARY; + if (type == SCREATE_BUILD_TABLE) { + tstrncpy(f.name, "Create Table", sizeof(f.name)); + } else { + tstrncpy(f.name, "Create Database", sizeof(f.name)); + } + + pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); + pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, + (int16_t)(ddlLen + VARSTR_HEADER_SIZE), ddlLen, false); + + rowLen += ddlLen + VARSTR_HEADER_SIZE; + + return rowLen; +} +static int32_t tscSCreateSetValueToResObj(SSqlObj *pSql, int32_t rowLen, const char *tableName, const char *ddl) { + SSqlRes *pRes = &pSql->res; + + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + int32_t numOfRows = 1; + if (strlen(ddl) == 0) { + + } + tscInitResObjForLocalQuery(pSql, numOfRows, rowLen); + + TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 0); + char* dst = pRes->data + tscFieldInfoGetOffset(pQueryInfo, 0) * numOfRows; + STR_WITH_MAXSIZE_TO_VARSTR(dst, tableName, pField->bytes); + + pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 1); + dst = pRes->data + tscFieldInfoGetOffset(pQueryInfo, 1) * numOfRows; + STR_WITH_MAXSIZE_TO_VARSTR(dst, ddl, pField->bytes); + return 0; +} +static int32_t tscSCreateBuildResult(SSqlObj *pSql, BuildType type, const char *str, const char *result) { + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + int32_t rowLen = tscSCreateBuildResultFields(pSql, type, result); + + tscFieldInfoUpdateOffset(pQueryInfo); + return tscSCreateSetValueToResObj(pSql, rowLen, str, result); +} +int32_t tscRebuildCreateTableStatement(void *param,char *result) { + SCreateBuilder *builder = (SCreateBuilder *)param; + int32_t code = TSDB_CODE_SUCCESS; + + char *buf = calloc(1,TSDB_MAX_BINARY_LEN); + if (buf == NULL) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + code = tscGetTableTagValue(builder, buf); + if (code == TSDB_CODE_SUCCESS) { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "CREATE TABLE %s USING %s TAGS %s", builder->buf, builder->sTableName, buf); + code = tscSCreateBuildResult(builder->pParentSql, SCREATE_BUILD_TABLE, builder->buf, result); + } + free(buf); + return code; +} + +static int32_t tscGetDBInfo(SCreateBuilder *builder, char *result) { + TAOS_ROW row = tscFetchRow(builder); + if (row == NULL) { + return TSDB_CODE_TSC_DB_NOT_SELECTED; + } + const char *showColumns[] = {"REPLICA", "QUORUM", "DAYS", "KEEP", "BLOCKS", NULL}; + + SSqlObj *pSql = builder->pInterSql; + TAOS_FIELD *fields = taos_fetch_fields(pSql); + int num_fields = taos_num_fields(pSql); + + char buf[TSDB_DB_NAME_LEN + 64] = {0}; + do { + int32_t* lengths = taos_fetch_lengths(pSql); + int32_t ret = tscGetNthFieldResult(row, fields, lengths, 0, buf); + if (0 == ret && STR_NOCASE_EQUAL(buf, strlen(buf), builder->buf, strlen(builder->buf))) { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "CREATE DATABASE %s", buf); + for (int i = 1; i < num_fields; i++) { + for (int j = 0; showColumns[j] != NULL; j++) { + if (STR_NOCASE_EQUAL(fields[i].name, strlen(fields[i].name), showColumns[j], strlen(showColumns[j]))) { + memset(buf, 0, sizeof(buf)); + ret = tscGetNthFieldResult(row, fields, lengths, i, buf); + if (ret == 0) { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), " %s %s", showColumns[j], buf); + } + } + } + } + break; + } + + row = tscFetchRow(builder); + } while (row != NULL); + + if (0 == strlen(result)) { + return TSDB_CODE_TSC_DB_NOT_SELECTED; + } + + return TSDB_CODE_SUCCESS; +} +int32_t tscRebuildCreateDBStatement(void *param,char *result) { + SCreateBuilder *builder = (SCreateBuilder *)param; + int32_t code = TSDB_CODE_SUCCESS; + + char *buf = calloc(1, TSDB_MAX_BINARY_LEN); + if (buf == NULL) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + code = tscGetDBInfo(param, buf); + if (code == TSDB_CODE_SUCCESS) { + code = tscSCreateBuildResult(builder->pParentSql, SCREATE_BUILD_DB, builder->buf, buf); + } + free(buf); + return code; +} + +static int32_t tscGetTableTagColumnName(SSqlObj *pSql, char **result) { + char *buf = (char *)malloc(TSDB_MAX_BINARY_LEN); + if (buf == NULL) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + buf[0] = 0; + + STableMeta *pMeta = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0)->pTableMeta; + if (pMeta->tableType == TSDB_SUPER_TABLE || pMeta->tableType == TSDB_NORMAL_TABLE || + pMeta->tableType == TSDB_STREAM_TABLE) { + free(buf); + return TSDB_CODE_TSC_INVALID_VALUE; + } + + SSchema *pTagsSchema = tscGetTableTagSchema(pMeta); + int32_t numOfTags = tscGetNumOfTags(pMeta); + for (int32_t i = 0; i < numOfTags; i++) { + if (i != numOfTags - 1) { + snprintf(buf + strlen(buf), TSDB_MAX_BINARY_LEN - strlen(buf), "%s,", pTagsSchema[i].name); + } else { + snprintf(buf + strlen(buf), TSDB_MAX_BINARY_LEN - strlen(buf), "%s", pTagsSchema[i].name); + } + } + + *result = buf; + return TSDB_CODE_SUCCESS; +} +static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, char *ddl) { + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + + STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + STableMeta * pMeta = pTableMetaInfo->pTableMeta; + + SSqlObj *pInterSql = (SSqlObj *)calloc(1, sizeof(SSqlObj)); + if (pInterSql == NULL) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + SCreateBuilder *param = (SCreateBuilder *)malloc(sizeof(SCreateBuilder)); + if (param == NULL) { + free(pInterSql); + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + char fullName[TSDB_TABLE_FNAME_LEN] = {0}; + extractDBName(pTableMetaInfo->name, fullName); + extractTableName(pMeta->sTableId, param->sTableName); + snprintf(fullName + strlen(fullName), TSDB_TABLE_FNAME_LEN - strlen(fullName), ".%s", param->sTableName); + extractTableName(pTableMetaInfo->name, param->buf); + + param->pParentSql = pSql; + param->pInterSql = pInterSql; + param->fp = tscRebuildCreateTableStatement; + param->callStage = SCREATE_CALLBACK_QUERY; + + char *query = (char *)calloc(1, TSDB_MAX_BINARY_LEN); + if (query == NULL) { + free(param); + free(pInterSql); + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + char *columns = NULL; + int32_t code = tscGetTableTagColumnName(pSql, &columns) ; + if (code != TSDB_CODE_SUCCESS) { + free(param); + free(pInterSql); + free(query); + return code; + } + + snprintf(query + strlen(query), TSDB_MAX_BINARY_LEN - strlen(query), "SELECT %s FROM %s WHERE TBNAME IN(\'%s\')", columns, fullName, param->buf); + doAsyncQuery(pSql->pTscObj, pInterSql, tscSCreateCallBack, param, query, strlen(query)); + free(query); + free(columns); + + return TSDB_CODE_TSC_ACTION_IN_PROGRESS; +} +static int32_t tscRebuildDDLForNormalTable(SSqlObj *pSql, const char *tableName, char *ddl) { + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + STableMeta * pMeta = pTableMetaInfo->pTableMeta; + + int32_t numOfRows = tscGetNumOfColumns(pMeta); + SSchema *pSchema = tscGetTableSchema(pMeta); + + char *result = ddl; + sprintf(result, "create table %s (", tableName); + for (int32_t i = 0; i < numOfRows; ++i) { + uint8_t type = pSchema[i].type; + if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s(%d),", pSchema[i].name,tDataTypeDesc[pSchema[i].type].aName,pSchema->bytes); + } else { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s,", pSchema[i].name, tDataTypeDesc[pSchema[i].type].aName); + } + } + sprintf(result + strlen(result) - 1, "%s", ")"); + + return TSDB_CODE_SUCCESS; +} +static int32_t tscRebuildDDLForSuperTable(SSqlObj *pSql, const char *tableName, char *ddl) { + char *result = ddl; + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + STableMeta * pMeta = pTableMetaInfo->pTableMeta; + + int32_t numOfRows = tscGetNumOfColumns(pMeta); + int32_t totalRows = numOfRows + tscGetNumOfTags(pMeta); + SSchema *pSchema = tscGetTableSchema(pMeta); + + sprintf(result, "create table %s (", tableName); + for (int32_t i = 0; i < numOfRows; ++i) { + uint8_t type = pSchema[i].type; + if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result),"%s %s(%d),", pSchema[i].name,tDataTypeDesc[pSchema[i].type].aName,pSchema->bytes); + } else { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s,", pSchema[i].name, tDataTypeDesc[type].aName); + } + } + snprintf(result + strlen(result) - 1, TSDB_MAX_BINARY_LEN - strlen(result), "%s %s", ")", "TAGS ("); + + for (int32_t i = numOfRows; i < totalRows; i++) { + uint8_t type = pSchema[i].type; + if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s(%d),", pSchema[i].name,tDataTypeDesc[pSchema[i].type].aName,pSchema->bytes); + } else { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s,", pSchema[i].name, tDataTypeDesc[type].aName); + } + } + sprintf(result + strlen(result) - 1, "%s", ")"); + + return TSDB_CODE_SUCCESS; +} + +static int32_t tscProcessShowCreateTable(SSqlObj *pSql) { + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + assert(pTableMetaInfo->pTableMeta != NULL); + + char tableName[TSDB_TABLE_NAME_LEN] = {0}; + extractTableName(pTableMetaInfo->name, tableName); + + char *result = (char *)calloc(1, TSDB_MAX_BINARY_LEN); + int32_t code = TSDB_CODE_SUCCESS; + if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { + code = tscRebuildDDLForSuperTable(pSql, tableName, result); + } else if (UTIL_TABLE_IS_NORMAL_TABLE(pTableMetaInfo)) { + code = tscRebuildDDLForNormalTable(pSql, tableName, result); + } else if (UTIL_TABLE_IS_CHILD_TABLE(pTableMetaInfo)) { + code = tscRebuildDDLForSubTable(pSql, tableName, result); + } else { + code = TSDB_CODE_TSC_INVALID_VALUE; + } + + if (code == TSDB_CODE_SUCCESS) { + code = tscSCreateBuildResult(pSql, SCREATE_BUILD_TABLE, tableName, result); + } + free(result); + return code; +} + +static int32_t tscProcessShowCreateDatabase(SSqlObj *pSql) { + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + + STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + + SSqlObj *pInterSql = (SSqlObj *)calloc(1, sizeof(SSqlObj)); + if (pInterSql == NULL) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + SCreateBuilder *param = (SCreateBuilder *)malloc(sizeof(SCreateBuilder)); + if (param == NULL) { + free(pInterSql); + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + extractTableName(pTableMetaInfo->name, param->buf); + param->pParentSql = pSql; + param->pInterSql = pInterSql; + param->fp = tscRebuildCreateDBStatement; + param->callStage = SCREATE_CALLBACK_QUERY; + + const char *query = "show databases"; + doAsyncQuery(pSql->pTscObj, pInterSql, tscSCreateCallBack, param, query, strlen(query)); + return TSDB_CODE_TSC_ACTION_IN_PROGRESS; +} static int32_t tscProcessCurrentUser(SSqlObj *pSql) { SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); - + SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0); pExpr->resBytes = TSDB_USER_LEN + TSDB_DATA_TYPE_BINARY; pExpr->resType = TSDB_DATA_TYPE_BINARY; - + char* vx = calloc(1, pExpr->resBytes); if (vx == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; @@ -287,7 +807,7 @@ static int32_t tscProcessCurrentUser(SSqlObj *pSql) { size_t size = sizeof(pSql->pTscObj->user); STR_WITH_MAXSIZE_TO_VARSTR(vx, pSql->pTscObj->user, size); - + tscSetLocalQueryResult(pSql, vx, pExpr->aliasName, pExpr->resType, pExpr->resBytes); free(vx); @@ -297,15 +817,15 @@ static int32_t tscProcessCurrentUser(SSqlObj *pSql) { static int32_t tscProcessCurrentDB(SSqlObj *pSql) { char db[TSDB_DB_NAME_LEN] = {0}; extractDBName(pSql->pTscObj->db, db); - + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex); - + SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0); pExpr->resType = TSDB_DATA_TYPE_BINARY; - + size_t t = strlen(db); pExpr->resBytes = TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE; - + char* vx = calloc(1, pExpr->resBytes); if (vx == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; @@ -316,7 +836,7 @@ static int32_t tscProcessCurrentDB(SSqlObj *pSql) { } else { STR_WITH_SIZE_TO_VARSTR(vx, db, (VarDataLenT)t); } - + tscSetLocalQueryResult(pSql, vx, pExpr->aliasName, pExpr->resType, pExpr->resBytes); free(vx); @@ -326,49 +846,53 @@ static int32_t tscProcessCurrentDB(SSqlObj *pSql) { static int32_t tscProcessServerVer(SSqlObj *pSql) { const char* v = pSql->pTscObj->sversion; SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex); - + SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0); pExpr->resType = TSDB_DATA_TYPE_BINARY; - + size_t t = strlen(v); pExpr->resBytes = (int16_t)(t + VARSTR_HEADER_SIZE); - + char* vx = calloc(1, pExpr->resBytes); if (vx == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; + } STR_WITH_SIZE_TO_VARSTR(vx, v, (VarDataLenT)t); tscSetLocalQueryResult(pSql, vx, pExpr->aliasName, pExpr->resType, pExpr->resBytes); - + free(vx); return TSDB_CODE_SUCCESS; + } static int32_t tscProcessClientVer(SSqlObj *pSql) { SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); - + SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0); pExpr->resType = TSDB_DATA_TYPE_BINARY; - + size_t t = strlen(version); pExpr->resBytes = (int16_t)(t + VARSTR_HEADER_SIZE); - + char* v = calloc(1, pExpr->resBytes); if (v == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; + } STR_WITH_SIZE_TO_VARSTR(v, version, (VarDataLenT)t); tscSetLocalQueryResult(pSql, v, pExpr->aliasName, pExpr->resType, pExpr->resBytes); - + free(v); return TSDB_CODE_SUCCESS; + } static int32_t tscProcessServStatus(SSqlObj *pSql) { STscObj* pObj = pSql->pTscObj; - + if (pObj->pHb != NULL) { if (pObj->pHb->res.code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { pSql->res.code = TSDB_CODE_RPC_NETWORK_UNAVAIL; @@ -379,9 +903,9 @@ static int32_t tscProcessServStatus(SSqlObj *pSql) { return pSql->res.code; } } - + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); - + SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0); int32_t val = 1; tscSetLocalQueryResult(pSql, (char*) &val, pExpr->aliasName, TSDB_DATA_TYPE_INT, sizeof(int32_t)); @@ -393,24 +917,22 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa SSqlRes *pRes = &pSql->res; pCmd->numOfCols = 1; - + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); pQueryInfo->order.order = TSDB_ORDER_ASC; - + tscFieldInfoClear(&pQueryInfo->fieldsInfo); - pQueryInfo->fieldsInfo.pFields = taosArrayInit(1, sizeof(TAOS_FIELD)); - pQueryInfo->fieldsInfo.pSupportInfo = taosArrayInit(1, sizeof(SFieldSupInfo)); - + pQueryInfo->fieldsInfo.internalField = taosArrayInit(1, sizeof(SInternalField)); + TAOS_FIELD f = tscCreateField((int8_t)type, columnName, (int16_t)valueLength); tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); - + tscInitResObjForLocalQuery(pSql, 1, (int32_t)valueLength); - TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 0); - SFieldSupInfo* pInfo = tscFieldInfoGetSupp(&pQueryInfo->fieldsInfo, 0); + SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, 0); pInfo->pSqlExpr = taosArrayGetP(pQueryInfo->exprList, 0); - - memcpy(pRes->data, val, pField->bytes); + + memcpy(pRes->data, val, pInfo->field.bytes); } int tscProcessLocalCmd(SSqlObj *pSql) { @@ -428,6 +950,10 @@ int tscProcessLocalCmd(SSqlObj *pSql) { */ pRes->qhandle = 0x1; pRes->numOfRows = 0; + } else if (pCmd->command == TSDB_SQL_SHOW_CREATE_TABLE) { + pRes->code = tscProcessShowCreateTable(pSql); + } else if (pCmd->command == TSDB_SQL_SHOW_CREATE_DATABASE) { + pRes->code = tscProcessShowCreateDatabase(pSql); } else if (pCmd->command == TSDB_SQL_RESET_CACHE) { taosCacheEmpty(tscMetaCache); pRes->code = TSDB_CODE_SUCCESS; @@ -447,12 +973,13 @@ int tscProcessLocalCmd(SSqlObj *pSql) { } // keep the code in local variable in order to avoid invalid read in case of async query + int32_t code = pRes->code; if (code == TSDB_CODE_SUCCESS) { (*pSql->fp)(pSql->param, pSql, code); + } else if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS){ } else { tscQueueAsyncRes(pSql); } - return code; } diff --git a/src/client/src/tscLocalMerge.c b/src/client/src/tscLocalMerge.c index 19abbe32e5ce67b626dd94c3db9574d6a3afe6e8..18d72e2d1e23b63abde7ff7159eae2dad993b548 100644 --- a/src/client/src/tscLocalMerge.c +++ b/src/client/src/tscLocalMerge.c @@ -510,7 +510,8 @@ void tscDestroyLocalReducer(SSqlObj *pSql) { taosTFree(pLocalReducer->pResultBuf); if (pLocalReducer->pResInfo != NULL) { - for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { + size_t num = tscSqlExprNumOfExprs(pQueryInfo); + for (int32_t i = 0; i < num; ++i) { taosTFree(pLocalReducer->pResInfo[i].interResultBuf); } @@ -554,27 +555,48 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm numOfGroupByCols++; } - int32_t *orderIdx = (int32_t *)calloc(numOfGroupByCols, sizeof(int32_t)); - if (orderIdx == NULL) { + int32_t *orderColIndexList = (int32_t *)calloc(numOfGroupByCols, sizeof(int32_t)); + if (orderColIndexList == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } if (numOfGroupByCols > 0) { - int32_t startCols = pQueryInfo->fieldsInfo.numOfOutput - pQueryInfo->groupbyExpr.numOfGroupCols; - // tags value locate at the last columns - for (int32_t i = 0; i < pQueryInfo->groupbyExpr.numOfGroupCols; ++i) { - orderIdx[i] = startCols++; - } + if (pQueryInfo->groupbyExpr.numOfGroupCols > 0) { + int32_t startCols = pQueryInfo->fieldsInfo.numOfOutput - pQueryInfo->groupbyExpr.numOfGroupCols; + + // the last "pQueryInfo->groupbyExpr.numOfGroupCols" columns are order-by columns + for (int32_t i = 0; i < pQueryInfo->groupbyExpr.numOfGroupCols; ++i) { + orderColIndexList[i] = startCols++; + } + + if (pQueryInfo->interval.interval != 0) { + // the first column is the timestamp, handles queries like "interval(10m) group by tags" + orderColIndexList[numOfGroupByCols - 1] = PRIMARYKEY_TIMESTAMP_COL_INDEX; //TODO ??? + } + } else { + /* + * 1. the orderby ts asc/desc projection query for the super table + * 2. interval query without groupby clause + */ + if (pQueryInfo->interval.interval != 0) { + orderColIndexList[0] = PRIMARYKEY_TIMESTAMP_COL_INDEX; + } else { + size_t size = tscSqlExprNumOfExprs(pQueryInfo); + for (int32_t i = 0; i < size; ++i) { + SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i); + if (pExpr->functionId == TSDB_FUNC_PRJ && pExpr->colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX) { + orderColIndexList[0] = i; + } + } + } - if (pQueryInfo->interval.interval != 0) { - // the first column is the timestamp, handles queries like "interval(10m) group by tags" - orderIdx[numOfGroupByCols - 1] = PRIMARYKEY_TIMESTAMP_COL_INDEX; + assert(pQueryInfo->order.orderColId == PRIMARYKEY_TIMESTAMP_COL_INDEX); } } - *pOrderDesc = tOrderDesCreate(orderIdx, numOfGroupByCols, pModel, pQueryInfo->order.order); - taosTFree(orderIdx); + *pOrderDesc = tOrderDesCreate(orderColIndexList, numOfGroupByCols, pModel, pQueryInfo->order.order); + taosTFree(orderColIndexList); if (*pOrderDesc == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; @@ -588,7 +610,6 @@ bool isSameGroup(SSqlCmd *pCmd, SLocalReducer *pReducer, char *pPrev, tFilePage // disable merge procedure for column projection query int16_t functionId = pReducer->pCtx[0].functionId; - assert(functionId != TSDB_FUNC_ARITHM); if (pReducer->orderPrjOnSTable) { return true; } @@ -606,7 +627,7 @@ bool isSameGroup(SSqlCmd *pCmd, SLocalReducer *pReducer, char *pPrev, tFilePage return true; } - if (orderInfo->pData[numOfCols - 1] == PRIMARYKEY_TIMESTAMP_COL_INDEX) { + if (orderInfo->colIndex[numOfCols - 1] == PRIMARYKEY_TIMESTAMP_COL_INDEX) { /* * super table interval query * if the order columns is the primary timestamp, all result data belongs to one group @@ -620,7 +641,7 @@ bool isSameGroup(SSqlCmd *pCmd, SLocalReducer *pReducer, char *pPrev, tFilePage } // only one row exists - int32_t index = orderInfo->pData[0]; + int32_t index = orderInfo->colIndex[0]; int32_t offset = (pOrderDesc->pColumnModel)->pFields[index].offset; int32_t ret = memcmp(pPrev + offset, tmpBuffer->data + offset, pOrderDesc->pColumnModel->rowSize - offset); @@ -639,7 +660,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - (*pMemBuffer) = (tExtMemBuffer **)malloc(POINTER_BYTES * pSql->numOfSubs); + (*pMemBuffer) = (tExtMemBuffer **)malloc(POINTER_BYTES * pSql->subState.numOfSub); if (*pMemBuffer == NULL) { tscError("%p failed to allocate memory", pSql); pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; @@ -661,7 +682,6 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr pSchema[i].bytes = pExpr->resBytes; pSchema[i].type = (int8_t)pExpr->resType; - rlen += pExpr->resBytes; } @@ -678,7 +698,8 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr pg *= 2; } - size_t numOfSubs = pTableMetaInfo->vgroupList->numOfVgroups; + size_t numOfSubs = pSql->subState.numOfSub; + assert(numOfSubs <= pTableMetaInfo->vgroupList->numOfVgroups); for (int32_t i = 0; i < numOfSubs; ++i) { (*pMemBuffer)[i] = createExtMemBuffer(nBufferSizes, rlen, pg, pModel); (*pMemBuffer)[i]->flushModel = MULTIPLE_APPEND_MODEL; @@ -701,12 +722,8 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr int16_t type = -1; int16_t bytes = 0; - // if ((pExpr->functionId >= TSDB_FUNC_FIRST_DST && pExpr->functionId <= TSDB_FUNC_LAST_DST) || - // (pExpr->functionId >= TSDB_FUNC_SUM && pExpr->functionId <= TSDB_FUNC_MAX) || - // pExpr->functionId == TSDB_FUNC_LAST_ROW) { // the final result size and type in the same as query on single table. // so here, set the flag to be false; - int32_t functionId = pExpr->functionId; if (functionId >= TSDB_FUNC_TS && functionId <= TSDB_FUNC_DIFF) { type = pModel->pFields[i].field.type; @@ -742,6 +759,7 @@ void tscLocalReducerEnvDestroy(tExtMemBuffer **pMemBuffer, tOrderDescriptor *pDe int32_t numOfVnodes) { destroyColumnModel(pFinalModel); tOrderDescDestroy(pDesc); + for (int32_t i = 0; i < numOfVnodes; ++i) { pMemBuffer[i] = destoryExtMemBuffer(pMemBuffer[i]); } diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 327aac22d159875ba644890e4a0fd41e1998ecdf..ac34d26d2fe747773a550dd76ac7e967a592199e 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -406,7 +406,7 @@ static int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start return TSDB_CODE_SUCCESS; } -int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[], SParsedDataColInfo *spd, char *error, +int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[], SParsedDataColInfo *spd, SSqlCmd* pCmd, int16_t timePrec, int32_t *code, char *tmpTokenBuf) { int32_t index = 0; SStrToken sToken = {0}; @@ -426,12 +426,17 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[ *str += index; if (sToken.type == TK_QUESTION) { + if (pCmd->insertType != TSDB_QUERY_TYPE_STMT_INSERT) { + *code = tscSQLSyntaxErrMsg(pCmd->payload, "? only allowed in binding insertion", *str); + return -1; + } + uint32_t offset = (uint32_t)(start - pDataBlocks->pData); if (tscAddParamToDataBlock(pDataBlocks, pSchema->type, (uint8_t)timePrec, pSchema->bytes, offset) != NULL) { continue; } - strcpy(error, "client out of memory"); + strcpy(pCmd->payload, "client out of memory"); *code = TSDB_CODE_TSC_OUT_OF_MEMORY; return -1; } @@ -439,8 +444,7 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[ int16_t type = sToken.type; if ((type != TK_NOW && type != TK_INTEGER && type != TK_STRING && type != TK_FLOAT && type != TK_BOOL && type != TK_NULL && type != TK_HEX && type != TK_OCT && type != TK_BIN) || (sToken.n == 0) || (type == TK_RP)) { - tscSQLSyntaxErrMsg(error, "invalid data or symbol", sToken.z); - *code = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; + *code = tscSQLSyntaxErrMsg(pCmd->payload, "invalid data or symbol", sToken.z); return -1; } @@ -470,14 +474,14 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[ } bool isPrimaryKey = (colIndex == PRIMARYKEY_TIMESTAMP_COL_INDEX); - int32_t ret = tsParseOneColumnData(pSchema, &sToken, start, error, str, isPrimaryKey, timePrec); + int32_t ret = tsParseOneColumnData(pSchema, &sToken, start, pCmd->payload, str, isPrimaryKey, timePrec); if (ret != TSDB_CODE_SUCCESS) { *code = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; return -1; // NOTE: here 0 mean error! } if (isPrimaryKey && tsCheckTimestamp(pDataBlocks, start) != TSDB_CODE_SUCCESS) { - tscInvalidSQLErrMsg(error, "client time/server time can not be mixed up", sToken.z); + tscInvalidSQLErrMsg(pCmd->payload, "client time/server time can not be mixed up", sToken.z); *code = TSDB_CODE_TSC_INVALID_TIME_STAMP; return -1; } @@ -522,7 +526,7 @@ static int32_t rowDataCompar(const void *lhs, const void *rhs) { } int tsParseValues(char **str, STableDataBlocks *pDataBlock, STableMeta *pTableMeta, int maxRows, - SParsedDataColInfo *spd, char *error, int32_t *code, char *tmpTokenBuf) { + SParsedDataColInfo *spd, SSqlCmd* pCmd, int32_t *code, char *tmpTokenBuf) { int32_t index = 0; SStrToken sToken; @@ -534,8 +538,7 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, STableMeta *pTableMe int32_t precision = tinfo.precision; if (spd->hasVal[0] == false) { - strcpy(error, "primary timestamp column can not be null"); - *code = TSDB_CODE_TSC_INVALID_SQL; + *code = tscInvalidSQLErrMsg(pCmd->payload, "primary timestamp column can not be null", *str); return -1; } @@ -547,17 +550,17 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, STableMeta *pTableMe *str += index; if (numOfRows >= maxRows || pDataBlock->size + tinfo.rowSize >= pDataBlock->nAllocSize) { int32_t tSize; - int32_t retcode = tscAllocateMemIfNeed(pDataBlock, tinfo.rowSize, &tSize); - if (retcode != TSDB_CODE_SUCCESS) { //TODO pass the correct error code to client - strcpy(error, "client out of memory"); - *code = retcode; + *code = tscAllocateMemIfNeed(pDataBlock, tinfo.rowSize, &tSize); + if (*code != TSDB_CODE_SUCCESS) { //TODO pass the correct error code to client + strcpy(pCmd->payload, "client out of memory"); return -1; } + ASSERT(tSize > maxRows); maxRows = tSize; } - int32_t len = tsParseOneRowData(str, pDataBlock, pSchema, spd, error, precision, code, tmpTokenBuf); + int32_t len = tsParseOneRowData(str, pDataBlock, pSchema, spd, pCmd, precision, code, tmpTokenBuf); if (len <= 0) { // error message has been set in tsParseOneRowData return -1; } @@ -568,7 +571,7 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, STableMeta *pTableMe sToken = tStrGetToken(*str, &index, false, 0, NULL); *str += index; if (sToken.n == 0 || sToken.type != TK_RP) { - tscSQLSyntaxErrMsg(error, ") expected", *str); + tscSQLSyntaxErrMsg(pCmd->payload, ") expected", *str); *code = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; return -1; } @@ -577,7 +580,7 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, STableMeta *pTableMe } if (numOfRows <= 0) { - strcpy(error, "no any data points"); + strcpy(pCmd->payload, "no any data points"); *code = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; return -1; } else { @@ -704,7 +707,7 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableList, char **st return TSDB_CODE_TSC_OUT_OF_MEMORY; } - int32_t numOfRows = tsParseValues(str, dataBuf, pTableMeta, maxNumOfRows, spd, pCmd->payload, &code, tmpTokenBuf); + int32_t numOfRows = tsParseValues(str, dataBuf, pTableMeta, maxNumOfRows, spd, pCmd, &code, tmpTokenBuf); free(tmpTokenBuf); if (numOfRows <= 0) { return code; @@ -724,10 +727,6 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableList, char **st dataBuf->vgId = pTableMeta->vgroupInfo.vgId; dataBuf->numOfTables = 1; - /* - * the value of pRes->numOfRows does not affect the true result of AFFECTED ROWS, - * which is actually returned from server. - */ *totalNum += numOfRows; return TSDB_CODE_SUCCESS; } @@ -791,7 +790,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { sql += index; tscAllocPayload(pCmd, sizeof(STagData)); - STagData *pTag = (STagData *) pCmd->payload; + STagData *pTag = &pCmd->tagData; memset(pTag, 0, sizeof(STagData)); @@ -946,7 +945,6 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { return tscSQLSyntaxErrMsg(pCmd->payload, ") expected", sToken.z); } - pCmd->payloadLen = sizeof(pTag->name) + sizeof(pTag->dataLen) + pTag->dataLen; pTag->dataLen = htonl(pTag->dataLen); if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) { @@ -1192,8 +1190,7 @@ int tsParseInsertSql(SSqlObj *pSql) { str += index; if (TK_STRING == sToken.type) { - strdequote(sToken.z); - sToken.n = (uint32_t)strtrim(sToken.z); + tscDequoteAndTrimToken(&sToken); } if (sToken.type == TK_RP) { @@ -1460,8 +1457,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) { char *lineptr = line; strtolower(line, line); - int32_t len = - tsParseOneRowData(&lineptr, pTableDataBlock, pSchema, &spd, pCmd->payload, tinfo.precision, &code, tokenBuf); + int32_t len = tsParseOneRowData(&lineptr, pTableDataBlock, pSchema, &spd, pCmd, tinfo.precision, &code, tokenBuf); if (len <= 0 || pTableDataBlock->numOfParams > 0) { pSql->res.code = code; break; diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 620e8ea57a29c75f1060ee4de6f1661ae319f07d..1739e4348ca2d1e90e4cdc292a14c7dcc5dde2da 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -43,10 +43,6 @@ typedef struct SNormalStmt { tVariant* params; } SNormalStmt; -//typedef struct SInsertStmt { -// -//} SInsertStmt; - typedef struct STscStmt { bool isInsert; STscObj* taos; @@ -54,7 +50,6 @@ typedef struct STscStmt { SNormalStmt normal; } STscStmt; - static int normalStmtAddPart(SNormalStmt* stmt, bool isParam, char* str, uint32_t len) { uint16_t size = stmt->numParts + 1; if (size > stmt->sizeParts) { @@ -144,7 +139,7 @@ static int normalStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) { return TSDB_CODE_TSC_INVALID_VALUE; } } - + return TSDB_CODE_SUCCESS; } @@ -218,7 +213,7 @@ static char* normalStmtBuildSql(STscStmt* stmt) { case TSDB_DATA_TYPE_NULL: taosStringBuilderAppendNull(&sb); break; - + case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_SMALLINT: @@ -271,6 +266,388 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) { return TSDB_CODE_SUCCESS; } + if (1) { + // allow user bind param data with different type + short size = 0; + union { + int8_t v1; + int16_t v2; + int32_t v4; + int64_t v8; + float f4; + double f8; + unsigned char buf[32*1024]; + } u; + switch (param->type) { + case TSDB_DATA_TYPE_BOOL: { + switch (bind->buffer_type) { + case TSDB_DATA_TYPE_BOOL: { + u.v1 = *(int8_t*)bind->buffer; + if (u.v1==0 || u.v1==1) break; + } break; + case TSDB_DATA_TYPE_TINYINT: { + u.v1 = *(int8_t*)bind->buffer; + if (u.v1==0 || u.v1==1) break; + } break; + case TSDB_DATA_TYPE_SMALLINT: { + u.v1 = (int8_t)*(int16_t*)bind->buffer; + if (u.v1==0 || u.v1==1) break; + } break; + case TSDB_DATA_TYPE_INT: { + u.v1 = (int8_t)*(int32_t*)bind->buffer; + if (u.v1==0 || u.v1==1) break; + } break; + case TSDB_DATA_TYPE_BIGINT: { + u.v1 = (int8_t)*(int64_t*)bind->buffer; + if (u.v1==0 || u.v1==1) break; + } break; + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: { + // "0", "1" convertible + if (strncmp((const char*)bind->buffer, "0", *bind->length)==0) { + u.v1 = 0; + break; + } + if (strncmp((const char*)bind->buffer, "1", *bind->length)==0) { + u.v1 = 1; + break; + } + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_DOUBLE: + case TSDB_DATA_TYPE_TIMESTAMP: + default: { + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + } + memcpy(data + param->offset, &u.v1, sizeof(u.v1)); + return TSDB_CODE_SUCCESS; + } break; + case TSDB_DATA_TYPE_TINYINT: { + switch (bind->buffer_type) { + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_TINYINT: { + int8_t v = *(int8_t*)bind->buffer; + u.v1 = v; + if (v >= SCHAR_MIN && v <= SCHAR_MAX) break; + } break; + case TSDB_DATA_TYPE_SMALLINT: { + int16_t v = *(int16_t*)bind->buffer; + u.v1 = (int8_t)v; + if (v >= SCHAR_MIN && v <= SCHAR_MAX) break; + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + case TSDB_DATA_TYPE_INT: { + int32_t v = *(int32_t*)bind->buffer; + u.v1 = (int8_t)v; + if (v >= SCHAR_MIN && v <= SCHAR_MAX) break; + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + case TSDB_DATA_TYPE_BIGINT: { + int64_t v = *(int64_t*)bind->buffer; + u.v1 = (int8_t)v; + if (v >= SCHAR_MIN && v <= SCHAR_MAX) break; + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: { + int64_t v; + int n,r; + r = sscanf((const char*)bind->buffer, "%" PRId64 "%n", &v, &n); + if (r==1 && n==strlen((const char*)bind->buffer)) { + u.v1 = (int8_t)v; + if (v >= SCHAR_MIN && v <= SCHAR_MAX) break; + } + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_DOUBLE: + case TSDB_DATA_TYPE_TIMESTAMP: + default: { + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + } + memcpy(data + param->offset, &u.v1, sizeof(u.v1)); + return TSDB_CODE_SUCCESS; + } break; + case TSDB_DATA_TYPE_SMALLINT: { + switch (bind->buffer_type) { + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_SMALLINT: { + int v = *(int16_t*)bind->buffer; + u.v2 = (int16_t)v; + } break; + case TSDB_DATA_TYPE_INT: { + int32_t v = *(int32_t*)bind->buffer; + u.v2 = (int16_t)v; + if (v >= SHRT_MIN && v <= SHRT_MAX) break; + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + case TSDB_DATA_TYPE_BIGINT: { + int64_t v = *(int64_t*)bind->buffer; + u.v2 = (int16_t)v; + if (v >= SHRT_MIN && v <= SHRT_MAX) break; + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: { + int64_t v; + int n,r; + r = sscanf((const char*)bind->buffer, "%" PRId64 "%n", &v, &n); + if (r==1 && n==strlen((const char*)bind->buffer)) { + u.v2 = (int16_t)v; + if (v >= SHRT_MIN && v <= SHRT_MAX) break; + } + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_DOUBLE: + case TSDB_DATA_TYPE_TIMESTAMP: + default: { + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + } + memcpy(data + param->offset, &u.v2, sizeof(u.v2)); + return TSDB_CODE_SUCCESS; + } break; + case TSDB_DATA_TYPE_INT: { + switch (bind->buffer_type) { + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_INT: { + u.v4 = *(int32_t*)bind->buffer; + } break; + case TSDB_DATA_TYPE_BIGINT: { + int64_t v = *(int64_t*)bind->buffer; + u.v4 = (int32_t)v; + if (v >= INT_MIN && v <= INT_MAX) break; + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: { + int64_t v; + int n,r; + r = sscanf((const char*)bind->buffer, "%" PRId64 "%n", &v, &n); + if (r==1 && n==strlen((const char*)bind->buffer)) { + u.v4 = (int32_t)v; + if (v >= INT_MIN && v <= INT_MAX) break; + } + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_DOUBLE: + case TSDB_DATA_TYPE_TIMESTAMP: + default: { + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + } + memcpy(data + param->offset, &u.v2, sizeof(u.v2)); + return TSDB_CODE_SUCCESS; + } break; + case TSDB_DATA_TYPE_FLOAT: { + switch (bind->buffer_type) { + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_TINYINT: { + u.f4 = *(int8_t*)bind->buffer; + } break; + case TSDB_DATA_TYPE_SMALLINT: { + u.f4 = *(int16_t*)bind->buffer; + } break; + case TSDB_DATA_TYPE_INT: { + u.f4 = (float)*(int32_t*)bind->buffer; + // shall we check equality? + } break; + case TSDB_DATA_TYPE_BIGINT: { + u.f4 = (float)*(int64_t*)bind->buffer; + // shall we check equality? + } break; + case TSDB_DATA_TYPE_FLOAT: { + u.f4 = *(float*)bind->buffer; + } break; + case TSDB_DATA_TYPE_DOUBLE: { + u.f4 = *(float*)bind->buffer; + // shall we check equality? + } break; + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: { + float v; + int n,r; + r = sscanf((const char*)bind->buffer, "%f%n", &v, &n); + if (r==1 && n==strlen((const char*)bind->buffer)) { + u.f4 = v; + break; + } + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + case TSDB_DATA_TYPE_TIMESTAMP: + default: { + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + } + memcpy(data + param->offset, &u.f4, sizeof(u.f4)); + return TSDB_CODE_SUCCESS; + } break; + case TSDB_DATA_TYPE_BIGINT: { + switch (bind->buffer_type) { + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_TINYINT: { + u.v8 = *(int8_t*)bind->buffer; + } break; + case TSDB_DATA_TYPE_SMALLINT: { + u.v8 = *(int16_t*)bind->buffer; + } break; + case TSDB_DATA_TYPE_INT: { + u.v8 = *(int32_t*)bind->buffer; + } break; + case TSDB_DATA_TYPE_BIGINT: { + u.v8 = *(int64_t*)bind->buffer; + } break; + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: { + int64_t v; + int n,r; + r = sscanf((const char*)bind->buffer, "%" PRId64 "%n", &v, &n); + if (r==1 && n==strlen((const char*)bind->buffer)) { + u.v8 = v; + break; + } + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_DOUBLE: + case TSDB_DATA_TYPE_TIMESTAMP: + default: { + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + } + memcpy(data + param->offset, &u.v8, sizeof(u.v8)); + return TSDB_CODE_SUCCESS; + } break; + case TSDB_DATA_TYPE_DOUBLE: { + switch (bind->buffer_type) { + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_TINYINT: { + u.f8 = *(int8_t*)bind->buffer; + } break; + case TSDB_DATA_TYPE_SMALLINT: { + u.f8 = *(int16_t*)bind->buffer; + } break; + case TSDB_DATA_TYPE_INT: { + u.f8 = *(int32_t*)bind->buffer; + } break; + case TSDB_DATA_TYPE_BIGINT: { + u.f8 = (double)*(int64_t*)bind->buffer; + } break; + case TSDB_DATA_TYPE_FLOAT: { + u.f8 = *(float*)bind->buffer; + } break; + case TSDB_DATA_TYPE_DOUBLE: { + u.f8 = *(double*)bind->buffer; + } break; + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: { + double v; + int n,r; + r = sscanf((const char*)bind->buffer, "%lf%n", &v, &n); + if (r==1 && n==strlen((const char*)bind->buffer)) { + u.f8 = v; + break; + } + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + case TSDB_DATA_TYPE_TIMESTAMP: + default: { + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + } break; + memcpy(data + param->offset, &u.f8, sizeof(u.f8)); + return TSDB_CODE_SUCCESS; + } break; + case TSDB_DATA_TYPE_TIMESTAMP: { + switch (bind->buffer_type) { + case TSDB_DATA_TYPE_TIMESTAMP: { + u.v8 = *(int64_t*)bind->buffer; + } break; + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: { + // is this the correct way to call taosParseTime? + int32_t len = (int32_t)*bind->length; + if (taosParseTime(bind->buffer, &u.v8, len, 3, tsDaylight) == TSDB_CODE_SUCCESS) { + break; + } + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_DOUBLE: + default: { + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + } break; + memcpy(data + param->offset, &u.v8, sizeof(u.v8)); + return TSDB_CODE_SUCCESS; + } break; + case TSDB_DATA_TYPE_BINARY: { + switch (bind->buffer_type) { + case TSDB_DATA_TYPE_BINARY: { + if ((*bind->length) > (uintptr_t)param->bytes) { + return TSDB_CODE_TSC_INVALID_VALUE; + } + size = (short)*bind->length; + STR_WITH_SIZE_TO_VARSTR(data + param->offset, bind->buffer, size); + return TSDB_CODE_SUCCESS; + } break; + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_DOUBLE: + case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_NCHAR: + default: { + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + } + } break; + case TSDB_DATA_TYPE_NCHAR: { + switch (bind->buffer_type) { + case TSDB_DATA_TYPE_NCHAR: { + size_t output = 0; + if (!taosMbsToUcs4(bind->buffer, *bind->length, varDataVal(data + param->offset), param->bytes - VARSTR_HEADER_SIZE, &output)) { + return TSDB_CODE_TSC_INVALID_VALUE; + } + varDataSetLen(data + param->offset, output); + return TSDB_CODE_SUCCESS; + } break; + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_DOUBLE: + case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_BINARY: + default: { + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + } + } break; + default: { + return TSDB_CODE_TSC_INVALID_VALUE; + } break; + } + } + if (bind->buffer_type != param->type) { return TSDB_CODE_TSC_INVALID_VALUE; } @@ -304,12 +681,12 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) { size = (short)*bind->length; STR_WITH_SIZE_TO_VARSTR(data + param->offset, bind->buffer, size); return TSDB_CODE_SUCCESS; - + case TSDB_DATA_TYPE_NCHAR: { size_t output = 0; if (!taosMbsToUcs4(bind->buffer, *bind->length, varDataVal(data + param->offset), param->bytes - VARSTR_HEADER_SIZE, &output)) { return TSDB_CODE_TSC_INVALID_VALUE; - } + } varDataSetLen(data + param->offset, output); return TSDB_CODE_SUCCESS; } @@ -363,7 +740,7 @@ static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) { } // actual work of all data blocks is done, update block size and numOfRows. - // note we don't do this block by block during the binding process, because + // note we don't do this block by block during the binding process, because // we cannot recover if something goes wrong. pCmd->batchSize = binded * 2 + 1; @@ -410,7 +787,7 @@ static int insertStmtReset(STscStmt* pStmt) { } } pCmd->batchSize = 0; - + STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); pTableMetaInfo->vgroupIndex = 0; return TSDB_CODE_SUCCESS; @@ -452,7 +829,7 @@ static int insertStmtExecute(STscStmt* stmt) { pRes->numOfRows = 0; pRes->numOfTotal = 0; pRes->numOfClauseTotal = 0; - + pRes->qhandle = 0; pSql->cmd.insertType = 0; @@ -513,46 +890,47 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { SSqlObj* pSql = pStmt->pSql; size_t sqlLen = strlen(sql); - - //doAsyncQuery(pObj, pSql, waitForQueryRsp, taos, sqlstr, sqlLen); + SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; pSql->param = (void*) pSql; pSql->fp = waitForQueryRsp; pSql->cmd.insertType = TSDB_QUERY_TYPE_STMT_INSERT; - + if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE)) { tscError("%p failed to malloc payload buffer", pSql); return TSDB_CODE_TSC_OUT_OF_MEMORY; } - + pSql->sqlstr = realloc(pSql->sqlstr, sqlLen + 1); - + if (pSql->sqlstr == NULL) { tscError("%p failed to malloc sql string buffer", pSql); free(pCmd->payload); return TSDB_CODE_TSC_OUT_OF_MEMORY; } - + pRes->qhandle = 0; pRes->numOfRows = 1; - + strtolower(pSql->sqlstr, sql); tscDebugL("%p SQL: %s", pSql, pSql->sqlstr); - if (tscIsInsertData(pSql->sqlstr)) { + if (tscIsInsertData(pSql->sqlstr)) { pStmt->isInsert = true; - + pSql->cmd.numOfParams = 0; pSql->cmd.batchSize = 0; - + + registerSqlObj(pSql); + int32_t code = tsParseSql(pSql, true); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { // wait for the callback function to post the semaphore tsem_wait(&pSql->rspSem); return pSql->res.code; } - + return code; } @@ -574,7 +952,7 @@ int taos_stmt_close(TAOS_STMT* stmt) { free(normal->sql); } - tscFreeSqlObj(pStmt->pSql); + taos_free_result(pStmt->pSql); free(pStmt); return TSDB_CODE_SUCCESS; } @@ -641,3 +1019,80 @@ TAOS_RES *taos_stmt_use_result(TAOS_STMT* stmt) { pStmt->pSql = NULL; return result; } + +int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) { + STscStmt* pStmt = (STscStmt*)stmt; + + if (stmt == NULL || pStmt->taos == NULL || pStmt->pSql == NULL) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return TSDB_CODE_TSC_DISCONNECTED; + } + + if (insert) *insert = pStmt->isInsert; + + return TSDB_CODE_SUCCESS; +} + +int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) { + STscStmt* pStmt = (STscStmt*)stmt; + + if (stmt == NULL || pStmt->taos == NULL || pStmt->pSql == NULL) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return TSDB_CODE_TSC_DISCONNECTED; + } + + if (pStmt->isInsert) { + SSqlObj* pSql = pStmt->pSql; + SSqlCmd *pCmd = &pSql->cmd; + *nums = pCmd->numOfParams; + return TSDB_CODE_SUCCESS; + } else { + SNormalStmt* normal = &pStmt->normal; + *nums = normal->numParams; + return TSDB_CODE_SUCCESS; + } +} + +int taos_stmt_get_param(TAOS_STMT *stmt, int idx, int *type, int *bytes) { + STscStmt* pStmt = (STscStmt*)stmt; + + if (stmt == NULL || pStmt->taos == NULL || pStmt->pSql == NULL) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return TSDB_CODE_TSC_DISCONNECTED; + } + + if (pStmt->isInsert) { + SSqlObj* pSql = pStmt->pSql; + SSqlCmd *pCmd = &pSql->cmd; + STableDataBlocks* pBlock = taosArrayGetP(pCmd->pDataBlocks, 0); + + assert(pCmd->numOfParams == pBlock->numOfParams); + if (idx < 0 || idx >= pBlock->numOfParams) return -1; + + SParamInfo* param = pBlock->params + idx; + if (type) *type = param->type; + if (bytes) *bytes = param->bytes; + + return TSDB_CODE_SUCCESS; + } else { + return TSDB_CODE_TSC_APP_ERROR; + } +} + +const char *taos_data_type(int type) { + switch (type) { + case TSDB_DATA_TYPE_NULL: return "TSDB_DATA_TYPE_NULL"; + case TSDB_DATA_TYPE_BOOL: return "TSDB_DATA_TYPE_BOOL"; + case TSDB_DATA_TYPE_TINYINT: return "TSDB_DATA_TYPE_TINYINT"; + case TSDB_DATA_TYPE_SMALLINT: return "TSDB_DATA_TYPE_SMALLINT"; + case TSDB_DATA_TYPE_INT: return "TSDB_DATA_TYPE_INT"; + case TSDB_DATA_TYPE_BIGINT: return "TSDB_DATA_TYPE_BIGINT"; + case TSDB_DATA_TYPE_FLOAT: return "TSDB_DATA_TYPE_FLOAT"; + case TSDB_DATA_TYPE_DOUBLE: return "TSDB_DATA_TYPE_DOUBLE"; + case TSDB_DATA_TYPE_BINARY: return "TSDB_DATA_TYPE_BINARY"; + case TSDB_DATA_TYPE_TIMESTAMP: return "TSDB_DATA_TYPE_TIMESTAMP"; + case TSDB_DATA_TYPE_NCHAR: return "TSDB_DATA_TYPE_NCHAR"; + default: return "UNKNOWN"; + } +} + diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index f2f997a59494ab7ab4e8da31edb4b819730e30c4..eb6843b0e4fd844c9d13da7f55dca47008f62a79 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -20,8 +20,10 @@ #include "tutil.h" #include "taosmsg.h" +#include "taos.h" + void tscSaveSlowQueryFp(void *handle, void *tmrId); -void *tscSlowQueryConn = NULL; +TAOS *tscSlowQueryConn = NULL; bool tscSlowQueryConnInitialized = false; void tscInitConnCb(void *param, TAOS_RES *result, int code) { @@ -151,10 +153,12 @@ void tscKillQuery(STscObj *pObj, uint32_t killId) { pthread_mutex_unlock(&pObj->mutex); - if (pSql == NULL) return; - - tscDebug("%p query is killed, queryId:%d", pSql, killId); - taos_stop_query(pSql); + if (pSql == NULL) { + tscError("failed to kill query, id:%d, it may have completed/terminated", killId); + } else { + tscDebug("%p query is killed, queryId:%d", pSql, killId); + taos_stop_query(pSql); + } } void tscAddIntoStreamList(SSqlStream *pStream) { @@ -242,6 +246,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { pQdesc->stime = htobe64(pSql->stime); pQdesc->queryId = htonl(pSql->queryId); pQdesc->useconds = htobe64(pSql->res.useconds); + pQdesc->qHandle = htobe64(pSql->res.qhandle); pHeartbeat->numOfQueries++; pQdesc++; diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 33ad4f6b17d1a3d1bc9f2470c9d40e6ba06a021e..e2573f7e19303966e9f17a2731444bf9fca7ab87 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -122,7 +122,7 @@ static int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSql static int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo); static int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo); static int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index); -static int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pSqlExpr, SArray* pExprInfo, SQueryInfo* pQueryInfo, SArray* pCols); +static int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pSqlExpr, SQueryInfo* pQueryInfo, SArray* pCols, int64_t *uid); /* * Used during parsing query sql. Since the query sql usually small in length, error position @@ -190,7 +190,8 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { SSqlRes* pRes = &pSql->res; int32_t code = TSDB_CODE_SUCCESS; - if (!pInfo->valid) { + if (!pInfo->valid || terrno == TSDB_CODE_TSC_SQL_SYNTAX_ERROR) { + terrno = TSDB_CODE_SUCCESS; // clear the error number return tscSQLSyntaxErrMsg(tscGetErrorMsgPayload(pCmd), NULL, pInfo->pzErrMsg); } @@ -351,7 +352,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { case TSDB_SQL_DESCRIBE_TABLE: { SStrToken* pToken = &pInfo->pDCLInfo->a[0]; const char* msg1 = "invalid table name"; - const char* msg2 = "table name is too long"; + const char* msg2 = "table name too long"; if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); @@ -362,13 +363,46 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { } // additional msg has been attached already - if (tscSetTableFullName(pTableMetaInfo, pToken, pSql) != TSDB_CODE_SUCCESS) { - return TSDB_CODE_TSC_INVALID_SQL; + code = tscSetTableFullName(pTableMetaInfo, pToken, pSql); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + return tscGetTableMeta(pSql, pTableMetaInfo); + } + case TSDB_SQL_SHOW_CREATE_TABLE: { + SStrToken* pToken = &pInfo->pDCLInfo->a[0]; + const char* msg1 = "invalid table name"; + const char* msg2 = "table name is too long"; + + if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); + } + + if (!tscValidateTableNameLength(pToken->n)) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); + } + + code = tscSetTableFullName(pTableMetaInfo, pToken, pSql); + if (code != TSDB_CODE_SUCCESS) { + return code; } return tscGetTableMeta(pSql, pTableMetaInfo); } + case TSDB_SQL_SHOW_CREATE_DATABASE: { + const char* msg1 = "invalid database name"; + SStrToken* pToken = &pInfo->pDCLInfo->a[0]; + + if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); + } + if (pToken->n > TSDB_DB_NAME_LEN) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); + } + return tscSetTableFullName(pTableMetaInfo, pToken, pSql); + } case TSDB_SQL_CFG_DNODE: { const char* msg2 = "invalid configure options or values, such as resetlog / debugFlag 135 / balance 'vnode:2-dnode:2' / monitor 1 "; const char* msg3 = "invalid dnode ep"; @@ -410,7 +444,6 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { const char* msg3 = "name too long"; pCmd->command = pInfo->type; - // tDCLSQL* pDCL = pInfo->pDCLInfo; SUserInfo* pUser = &pInfo->pDCLInfo->user; SStrToken* pName = &pUser->user; @@ -594,6 +627,11 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQ return TSDB_CODE_SUCCESS; } + // orderby column not set yet, set it to be the primary timestamp column + if (pQueryInfo->order.orderColId == INT32_MIN) { + pQueryInfo->order.orderColId = PRIMARYKEY_TIMESTAMP_COL_INDEX; + } + // interval is not null SStrToken* t = &pQuerySql->interval; if (parseNatualDuration(t->z, t->n, &pQueryInfo->interval.interval, &pQueryInfo->interval.intervalUnit) != TSDB_CODE_SUCCESS) { @@ -773,55 +811,44 @@ int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pzTableName, SSqlObj* pSql) { const char* msg1 = "name too long"; - const char* msg2 = "current database name is invalid"; SSqlCmd* pCmd = &pSql->cmd; int32_t code = TSDB_CODE_SUCCESS; // backup the old name in pTableMetaInfo - size_t size = strlen(pTableMetaInfo->name); - char* oldName = NULL; - if (size > 0) { - oldName = strdup(pTableMetaInfo->name); - } + char oldName[TSDB_TABLE_FNAME_LEN] = {0}; + tstrncpy(oldName, pTableMetaInfo->name, tListLen(oldName)); - if (hasSpecifyDB(pzTableName)) { - // db has been specified in sql string so we ignore current db path + if (hasSpecifyDB(pzTableName)) { // db has been specified in sql string so we ignore current db path code = setObjFullName(pTableMetaInfo->name, getAccountId(pSql), NULL, pzTableName, NULL); if (code != 0) { invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } - } else { // get current DB name first, then set it into path + } else { // get current DB name first, and then set it into path SStrToken t = {0}; getCurrentDBName(pSql, &t); - if (t.n == 0) { - invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); - } - - code = setObjFullName(pTableMetaInfo->name, NULL, &t, pzTableName, NULL); - if (code != 0) { - invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); + if (t.n == 0) { // current database not available or not specified + code = TSDB_CODE_TSC_DB_NOT_SELECTED; + } else { + code = setObjFullName(pTableMetaInfo->name, NULL, &t, pzTableName, NULL); + if (code != 0) { + invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); + } } } if (code != TSDB_CODE_SUCCESS) { - taosTFree(oldName); return code; } /* - * the old name exists and is not equalled to the new name. Release the metermeta/metricmeta + * the old name exists and is not equalled to the new name. Release the table meta * that are corresponding to the old name for the new table name. */ - if (size > 0) { - if (strncasecmp(oldName, pTableMetaInfo->name, tListLen(pTableMetaInfo->name)) != 0) { - tscClearTableMetaInfo(pTableMetaInfo, false); - } - } else { - assert(pTableMetaInfo->pTableMeta == NULL); + if (strlen(oldName) > 0 && strncasecmp(oldName, pTableMetaInfo->name, tListLen(pTableMetaInfo->name)) != 0) { + tscClearTableMetaInfo(pTableMetaInfo, false); } - taosTFree(oldName); return TSDB_CODE_SUCCESS; } @@ -1179,6 +1206,10 @@ int32_t setObjFullName(char* fullName, const char* account, SStrToken* pDB, SStr return (totalLen < TSDB_TABLE_FNAME_LEN) ? TSDB_CODE_SUCCESS : TSDB_CODE_TSC_INVALID_SQL; } +static void tscInsertPrimaryTSSourceColumn(SQueryInfo* pQueryInfo, SColumnIndex* pIndex) { + SColumnIndex tsCol = {.tableIndex = pIndex->tableIndex, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX}; + tscColumnListInsert(pQueryInfo->colList, &tsCol); +} static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t exprIndex, tSQLExprItem* pItem) { const char* msg1 = "invalid column name, or illegal column type"; const char* msg2 = "invalid arithmetic expression in select clause"; @@ -1219,7 +1250,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t tExprNode* pNode = NULL; SArray* colList = taosArrayInit(10, sizeof(SColIndex)); - int32_t ret = exprTreeFromSqlExpr(pCmd, &pNode, pItem->pNode, pQueryInfo->exprList, pQueryInfo, colList); + int32_t ret = exprTreeFromSqlExpr(pCmd, &pNode, pItem->pNode, pQueryInfo, colList, NULL); if (ret != TSDB_CODE_SUCCESS) { taosArrayDestroy(colList); tExprTreeDestroy(&pNode, NULL); @@ -1254,6 +1285,8 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t addExprParams(pExpr, c, TSDB_DATA_TYPE_BINARY, (int32_t)len, index.tableIndex); insertResultField(pQueryInfo, exprIndex, &columnList, sizeof(double), TSDB_DATA_TYPE_DOUBLE, pExpr->aliasName, pExpr); + // add ts column + tscInsertPrimaryTSSourceColumn(pQueryInfo, &index); tbufCloseWriter(&bw); taosArrayDestroy(colList); @@ -1273,17 +1306,17 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t insertResultField(pQueryInfo, exprIndex, &columnList, sizeof(double), TSDB_DATA_TYPE_DOUBLE, aliasName, NULL); int32_t slot = tscNumOfFields(pQueryInfo) - 1; - SFieldSupInfo* pInfo = tscFieldInfoGetSupp(&pQueryInfo->fieldsInfo, slot); + SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, slot); if (pInfo->pSqlExpr == NULL) { SExprInfo* pArithExprInfo = calloc(1, sizeof(SExprInfo)); // arithmetic expression always return result in the format of double float - pArithExprInfo->bytes = sizeof(double); + pArithExprInfo->bytes = sizeof(double); pArithExprInfo->interBytes = sizeof(double); - pArithExprInfo->type = TSDB_DATA_TYPE_DOUBLE; + pArithExprInfo->type = TSDB_DATA_TYPE_DOUBLE; - int32_t ret = exprTreeFromSqlExpr(pCmd, &pArithExprInfo->pExpr, pItem->pNode, pQueryInfo->exprList, pQueryInfo, NULL); + int32_t ret = exprTreeFromSqlExpr(pCmd, &pArithExprInfo->pExpr, pItem->pNode, pQueryInfo, NULL, &pArithExprInfo->uid); if (ret != TSDB_CODE_SUCCESS) { tExprTreeDestroy(&pArithExprInfo->pExpr, NULL); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), "invalid expression in select clause"); @@ -1296,10 +1329,6 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t return TSDB_CODE_SUCCESS; } -static void tscInsertPrimaryTSSourceColumn(SQueryInfo* pQueryInfo, SColumnIndex* pIndex) { - SColumnIndex tsCol = {.tableIndex = pIndex->tableIndex, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX}; - tscColumnListInsert(pQueryInfo->colList, &tsCol); -} static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumnIndex* pIndex, tSQLExprItem* pItem) { SSqlExpr* pExpr = doAddProjectCol(pQueryInfo, startPos, pIndex->columnIndex, pIndex->tableIndex); @@ -1324,6 +1353,32 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn insertResultField(pQueryInfo, startPos, &ids, pExpr->resBytes, (int8_t)pExpr->resType, pExpr->aliasName, pExpr); } +static void addPrimaryTsColIntoResult(SQueryInfo* pQueryInfo) { + // primary timestamp column has been added already + size_t size = tscSqlExprNumOfExprs(pQueryInfo); + for (int32_t i = 0; i < size; ++i) { + SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); + if (pExpr->functionId == TSDB_FUNC_PRJ && pExpr->colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX) { + return; + } + } + + SColumnIndex index = {0}; + + // set the constant column value always attached to first table. + STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + SSchema* pSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, PRIMARYKEY_TIMESTAMP_COL_INDEX); + + // add the timestamp column into the output columns + int32_t numOfCols = (int32_t)tscSqlExprNumOfExprs(pQueryInfo); + tscAddSpecialColumnForSelect(pQueryInfo, numOfCols, TSDB_FUNC_PRJ, &index, pSchema, TSDB_COL_NORMAL); + + SInternalField* pSupInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, numOfCols); + pSupInfo->visible = false; + + pQueryInfo->type |= TSDB_QUERY_TYPE_PROJECTION_QUERY; +} + int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSelection, bool isSTable, bool joinQuery) { assert(pSelection != NULL && pCmd != NULL); @@ -1377,20 +1432,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel // there is only one user-defined column in the final result field, add the timestamp column. size_t numOfSrcCols = taosArrayGetSize(pQueryInfo->colList); if (numOfSrcCols <= 0 && !tscQueryTags(pQueryInfo)) { - SColumnIndex index = {0}; - - // set the constant column value always attached to first table. - STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, clauseIndex, 0); - SSchema* pSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, PRIMARYKEY_TIMESTAMP_COL_INDEX); - - // add the timestamp column into the output columns - int32_t numOfCols = (int32_t)tscSqlExprNumOfExprs(pQueryInfo); - tscAddSpecialColumnForSelect(pQueryInfo, numOfCols, TSDB_FUNC_PRJ, &index, pSchema, TSDB_COL_NORMAL); - - SFieldSupInfo* pSupInfo = tscFieldInfoGetSupp(&pQueryInfo->fieldsInfo, numOfCols); - pSupInfo->visible = false; - - pQueryInfo->type |= TSDB_QUERY_TYPE_PROJECTION_QUERY; + addPrimaryTsColIntoResult(pQueryInfo); } if (!functionCompatibleCheck(pQueryInfo, joinQuery)) { @@ -1428,7 +1470,7 @@ int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnLi } TAOS_FIELD f = tscCreateField(type, fieldName, bytes); - SFieldSupInfo* pInfo = tscFieldInfoInsert(&pQueryInfo->fieldsInfo, outputIndex, &f); + SInternalField* pInfo = tscFieldInfoInsert(&pQueryInfo->fieldsInfo, outputIndex, &f); pInfo->pSqlExpr = pSqlExpr; return TSDB_CODE_SUCCESS; @@ -1582,8 +1624,8 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t return TSDB_CODE_SUCCESS; } -static int32_t setExprInfoForFunctions(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSchema* pSchema, SConvertFunc cvtFunc, char* aliasName, - int32_t resColIdx, SColumnIndex* pColIndex) { +static int32_t setExprInfoForFunctions(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSchema* pSchema, SConvertFunc cvtFunc, + char* aliasName, int32_t resColIdx, SColumnIndex* pColIndex, bool finalResult) { const char* msg1 = "not support column types"; int16_t type = 0; @@ -1629,8 +1671,13 @@ static int32_t setExprInfoForFunctions(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS SColumnIndex index = {.tableIndex = pColIndex->tableIndex, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX}; tscColumnListInsert(pQueryInfo->colList, &index); + // if it is not in the final result, do not add it SColumnList ids = getColumnList(1, pColIndex->tableIndex, pColIndex->columnIndex); - insertResultField(pQueryInfo, resColIdx, &ids, bytes, (int8_t)type, columnName, pExpr); + if (finalResult) { + insertResultField(pQueryInfo, resColIdx, &ids, bytes, (int8_t)type, columnName, pExpr); + } else { + tscColumnListInsert(pQueryInfo->colList, &(ids.ids[0])); + } return TSDB_CODE_SUCCESS; } @@ -1667,7 +1714,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col if (pItem->pNode->pParam != NULL) { tSQLExprItem* pParamElem = &pItem->pNode->pParam->a[0]; SStrToken* pToken = &pParamElem->pNode->colInfo; - short sqlOptr = pParamElem->pNode->nSQLOptr; + int16_t sqlOptr = pParamElem->pNode->nSQLOptr; if ((pToken->z == NULL || pToken->n == 0) && (TK_INTEGER != sqlOptr)) /*select count(1) from table*/ { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); @@ -1905,7 +1952,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col for (int32_t j = 0; j < tscGetNumOfColumns(pTableMetaInfo->pTableMeta); ++j) { index.columnIndex = j; - if (setExprInfoForFunctions(pCmd, pQueryInfo, pSchema, cvtFunc, pItem->aliasName, colIndex++, &index) != 0) { + if (setExprInfoForFunctions(pCmd, pQueryInfo, pSchema, cvtFunc, pItem->aliasName, colIndex++, &index, finalResult) != 0) { return TSDB_CODE_TSC_INVALID_SQL; } } @@ -1922,7 +1969,8 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col if ((index.columnIndex >= tscGetNumOfColumns(pTableMetaInfo->pTableMeta)) || (index.columnIndex < 0)) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6); } - if (setExprInfoForFunctions(pCmd, pQueryInfo, pSchema, cvtFunc, pItem->aliasName, colIndex + i, &index) != 0) { + + if (setExprInfoForFunctions(pCmd, pQueryInfo, pSchema, cvtFunc, pItem->aliasName, colIndex + i, &index, finalResult) != 0) { return TSDB_CODE_TSC_INVALID_SQL; } @@ -1959,7 +2007,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col for (int32_t i = 0; i < tscGetNumOfColumns(pTableMetaInfo->pTableMeta); ++i) { SColumnIndex index = {.tableIndex = j, .columnIndex = i}; - if (setExprInfoForFunctions(pCmd, pQueryInfo, pSchema, cvtFunc, pItem->aliasName, colIndex, &index) != 0) { + if (setExprInfoForFunctions(pCmd, pQueryInfo, pSchema, cvtFunc, pItem->aliasName, colIndex, &index, finalResult) != 0) { return TSDB_CODE_TSC_INVALID_SQL; } @@ -3337,10 +3385,26 @@ static int32_t validateSQLExpr(SSqlCmd* pCmd, tSQLExpr* pExpr, SQueryInfo* pQuer tSQLExprItem item = {.pNode = pExpr, .aliasName = NULL}; - // sql function in selection clause, append sql function info in pSqlCmd structure sequentially + // sql function list in selection clause. + // Append the sqlExpr into exprList of pQueryInfo structure sequentially if (addExprAndResultField(pCmd, pQueryInfo, outputIndex, &item, false) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_SQL; } + + // It is invalid in case of more than one sqlExpr, such as first(ts, k) - last(ts, k) + int32_t inc = (int32_t) tscSqlExprNumOfExprs(pQueryInfo) - outputIndex; + if (inc > 1) { + return TSDB_CODE_TSC_INVALID_SQL; + } + + // Not supported data type in arithmetic expression + for(int32_t i = 0; i < inc; ++i) { + SSqlExpr* p1 = tscSqlExprGet(pQueryInfo, i + outputIndex); + int16_t t = p1->resType; + if (t == TSDB_DATA_TYPE_BINARY || t == TSDB_DATA_TYPE_NCHAR || t == TSDB_DATA_TYPE_BOOL || t == TSDB_DATA_TYPE_TIMESTAMP) { + return TSDB_CODE_TSC_INVALID_SQL; + } + } } return TSDB_CODE_SUCCESS; @@ -4015,7 +4079,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE tExprNode* p = NULL; SArray* colList = taosArrayInit(10, sizeof(SColIndex)); - ret = exprTreeFromSqlExpr(pCmd, &p, p1, NULL, pQueryInfo, colList); + ret = exprTreeFromSqlExpr(pCmd, &p, p1, pQueryInfo, colList, NULL); SBufferWriter bw = tbufInitWriter(NULL, false); TRY(0) { @@ -4342,14 +4406,13 @@ int32_t parseFillClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuery static void setDefaultOrderInfo(SQueryInfo* pQueryInfo) { /* set default timestamp order information for all queries */ - pQueryInfo->order.order = TSDB_ORDER_ASC; STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + pQueryInfo->order.order = TSDB_ORDER_ASC; if (isTopBottomQuery(pQueryInfo)) { - pQueryInfo->order.order = TSDB_ORDER_ASC; pQueryInfo->order.orderColId = PRIMARYKEY_TIMESTAMP_COL_INDEX; - } else { - pQueryInfo->order.orderColId = -1; + } else { // in case of select tbname from super_table, the defualt order column can not be the primary ts column + pQueryInfo->order.orderColId = INT32_MIN; } /* for super table query, set default ascending order for group output */ @@ -4453,6 +4516,11 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu } else { pQueryInfo->order.order = pSortorder->a[0].sortOrder; pQueryInfo->order.orderColId = PRIMARYKEY_TIMESTAMP_COL_INDEX; + + // orderby ts query on super table + if (tscOrderedProjectionQueryOnSTable(pQueryInfo, 0)) { + addPrimaryTsColIntoResult(pQueryInfo); + } } } @@ -4534,6 +4602,8 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { const char* msg18 = "primary timestamp column cannot be dropped"; const char* msg19 = "invalid new tag name"; + int32_t code = TSDB_CODE_SUCCESS; + SSqlCmd* pCmd = &pSql->cmd; SAlterTableSQL* pAlterSQL = pInfo->pAlterInfo; SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); @@ -4544,13 +4614,14 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } - if (tscSetTableFullName(pTableMetaInfo, &(pAlterSQL->name), pSql) != TSDB_CODE_SUCCESS) { - return TSDB_CODE_TSC_INVALID_SQL; + code = tscSetTableFullName(pTableMetaInfo, &(pAlterSQL->name), pSql); + if (code != TSDB_CODE_SUCCESS) { + return code; } - int32_t ret = tscGetTableMeta(pSql, pTableMetaInfo); - if (ret != TSDB_CODE_SUCCESS) { - return ret; + code = tscGetTableMeta(pSql, pTableMetaInfo); + if (code != TSDB_CODE_SUCCESS) { + return code; } STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; @@ -4679,7 +4750,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { // validate the length of binary if ((pTagsSchema->type == TSDB_DATA_TYPE_BINARY || pTagsSchema->type == TSDB_DATA_TYPE_NCHAR) && - (pVarList->a[1].pVar.nLen + VARSTR_HEADER_SIZE) > pTagsSchema->bytes) { + varDataTLen(pAlterSQL->tagData.data) > pTagsSchema->bytes) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg14); } @@ -4874,6 +4945,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) { {"cDebugFlag", 10}, {"httpDebugFlag", 13}, {"qDebugflag", 10}, {"sdbDebugFlag", 12}, {"uDebugFlag", 10}, {"tsdbDebugFlag", 13}, {"sDebugflag", 10}, {"rpcDebugFlag", 12}, {"dDebugFlag", 10}, {"mqttDebugFlag", 13}, {"wDebugFlag", 10}, {"tmrDebugFlag", 12}, + {"cqDebugFlag", 11}, }; SStrToken* pOptionToken = &pOptions->a[1]; @@ -5204,26 +5276,6 @@ int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDBInfo* pCreateDbSql) { return TSDB_CODE_SUCCESS; } -//void tscAddTimestampColumn(SQueryInfo* pQueryInfo, int16_t functionId, int16_t tableIndex) { -// // the first column not timestamp column, add it -// SSqlExpr* pExpr = NULL; -// if (tscSqlExprNumOfExprs(pQueryInfo) > 0) { -// pExpr = tscSqlExprGet(pQueryInfo, 0); -// } -// -// if (pExpr == NULL || pExpr->colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX || pExpr->functionId != functionId) { -// SColumnIndex index = {tableIndex, PRIMARYKEY_TIMESTAMP_COL_INDEX}; -// -// pExpr = tscSqlExprInsert(pQueryInfo, 0, functionId, &index, TSDB_DATA_TYPE_TIMESTAMP, TSDB_KEYSIZE, TSDB_KEYSIZE, false); -// pExpr->colInfo.flag = TSDB_COL_NORMAL; -// -// // NOTE: tag column does not add to source column list -// SColumnList ids = getColumnList(1, tableIndex, PRIMARYKEY_TIMESTAMP_COL_INDEX); -// -// insertResultField(pQueryInfo, 0, &ids, TSDB_KEYSIZE, TSDB_DATA_TYPE_TIMESTAMP, "ts", pExpr); -// } -//} - void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClauseIndex, int32_t tableIndex) { SQueryInfo* pParentQueryInfo = tscGetQueryInfoDetail(&pParentObj->cmd, subClauseIndex); @@ -5280,16 +5332,19 @@ void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex) { tscAddSpecialColumnForSelect(pQueryInfo, (int32_t)size, TSDB_FUNC_PRJ, &colIndex, pSchema, TSDB_COL_NORMAL); - SFieldSupInfo* pInfo = tscFieldInfoGetSupp(&pQueryInfo->fieldsInfo, (int32_t)size); + SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, (int32_t)size); doLimitOutputNormalColOfGroupby(pInfo->pSqlExpr); pInfo->visible = false; } static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) { int32_t tagLength = 0; - size_t size = taosArrayGetSize(pQueryInfo->exprList); - + +//todo is 0?? + STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + bool isSTable = UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo); + for (int32_t i = 0; i < size; ++i) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); if (pExpr->functionId == TSDB_FUNC_TAGPRJ || pExpr->functionId == TSDB_FUNC_TAG) { @@ -5301,8 +5356,7 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) { } } - STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta); + SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta); for (int32_t i = 0; i < size; ++i) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); @@ -5310,7 +5364,7 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) { !(pExpr->functionId == TSDB_FUNC_PRJ && TSDB_COL_IS_UD_COL(pExpr->colInfo.flag))) { SSchema* pColSchema = &pSchema[pExpr->colInfo.colIndex]; getResultDataInfo(pColSchema->type, pColSchema->bytes, pExpr->functionId, (int32_t)pExpr->param[0].i64Key, &pExpr->resType, - &pExpr->resBytes, &pExpr->interBytes, tagLength, true); + &pExpr->resBytes, &pExpr->interBytes, tagLength, isSTable); } } } @@ -5321,7 +5375,7 @@ static int32_t doUpdateSqlFunctionForColPrj(SQueryInfo* pQueryInfo) { for (int32_t i = 0; i < size; ++i) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); - if (pExpr->functionId == TSDB_FUNC_PRJ && (!TSDB_COL_IS_UD_COL(pExpr->colInfo.flag))) { + if (pExpr->functionId == TSDB_FUNC_PRJ && (!TSDB_COL_IS_UD_COL(pExpr->colInfo.flag) && (pExpr->colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX))) { bool qualifiedCol = false; for (int32_t j = 0; j < pQueryInfo->groupbyExpr.numOfGroupCols; ++j) { SColIndex* pColIndex = taosArrayGet(pQueryInfo->groupbyExpr.columnInfo, j); @@ -5419,13 +5473,6 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, SSqlCmd* pCmd) int16_t numOfSelectivity = 0; int16_t numOfAggregation = 0; - // todo is 0?? - STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - bool isSTable = UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo); - if (!isSTable) { - return TSDB_CODE_SUCCESS; - } - size_t numOfExprs = taosArrayGetSize(pQueryInfo->exprList); for (int32_t i = 0; i < numOfExprs; ++i) { SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, i); @@ -5727,7 +5774,7 @@ int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCMCreateDbMsg* pCreate) { char msg[512] = {0}; if (pCreate->walLevel != -1 && (pCreate->walLevel < TSDB_MIN_WAL_LEVEL || pCreate->walLevel > TSDB_MAX_WAL_LEVEL)) { - snprintf(msg, tListLen(msg), "invalid db option walLevel: %d, only 0-2 allowed", pCreate->walLevel); + snprintf(msg, tListLen(msg), "invalid db option walLevel: %d, only 1-2 allowed", pCreate->walLevel); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg); } @@ -5852,8 +5899,9 @@ int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* p return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } - if (tscSetTableFullName(pTableMetaInfo, pzTableName, pSql) != TSDB_CODE_SUCCESS) { - return TSDB_CODE_TSC_INVALID_SQL; + int32_t code = tscSetTableFullName(pTableMetaInfo, pzTableName, pSql); + if(code != TSDB_CODE_SUCCESS) { + return code; } if (!validateTableColumnInfo(pFieldList, pCmd) || @@ -5907,15 +5955,16 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } - if (tscSetTableFullName(pStableMeterMetaInfo, pToken, pSql) != TSDB_CODE_SUCCESS) { - return TSDB_CODE_TSC_INVALID_SQL; + int32_t code = tscSetTableFullName(pStableMeterMetaInfo, pToken, pSql); + if (code != TSDB_CODE_SUCCESS) { + return code; } // get meter meta from mnode tstrncpy(pCreateTable->usingInfo.tagdata.name, pStableMeterMetaInfo->name, sizeof(pCreateTable->usingInfo.tagdata.name)); tVariantList* pList = pInfo->pCreateTableInfo->usingInfo.pTagVals; - int32_t code = tscGetTableMeta(pSql, pStableMeterMetaInfo); + code = tscGetTableMeta(pSql, pStableMeterMetaInfo); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -5992,7 +6041,6 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { const char* msg1 = "invalid table name"; - const char* msg2 = "table name too long"; const char* msg3 = "fill only available for interval query"; const char* msg4 = "fill option not supported in stream computing"; const char* msg5 = "sql too long"; // todo ADD support @@ -6024,11 +6072,12 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } - if (tscSetTableFullName(pTableMetaInfo, &srcToken, pSql) != TSDB_CODE_SUCCESS) { - return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); + int32_t code = tscSetTableFullName(pTableMetaInfo, &srcToken, pSql); + if (code != TSDB_CODE_SUCCESS) { + return code; } - int32_t code = tscGetTableMeta(pSql, pTableMetaInfo); + code = tscGetTableMeta(pSql, pTableMetaInfo); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -6055,8 +6104,9 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { } // set the created table[stream] name - if (tscSetTableFullName(pTableMetaInfo, pzTableName, pSql) != TSDB_CODE_SUCCESS) { - return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); + code = tscSetTableFullName(pTableMetaInfo, pzTableName, pSql); + if (code != TSDB_CODE_SUCCESS) { + return code; } if (pQuerySql->selectToken.n > TSDB_MAX_SAVED_SQL_LEN) { @@ -6100,7 +6150,6 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) { assert(pQuerySql != NULL && (pQuerySql->from == NULL || pQuerySql->from->nExpr > 0)); const char* msg0 = "invalid table name"; - //const char* msg1 = "table name too long"; const char* msg2 = "point interpolation query needs timestamp"; const char* msg5 = "fill only available for interval query"; const char* msg6 = "start(end) time of query range required or time range too large"; @@ -6172,11 +6221,16 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) { STableMetaInfo* pTableMetaInfo1 = tscGetMetaInfo(pQueryInfo, i/2); SStrToken t = {.type = TSDB_DATA_TYPE_BINARY, .n = pTableItem->nLen, .z = pTableItem->pz}; - if (tscSetTableFullName(pTableMetaInfo1, &t, pSql) != TSDB_CODE_SUCCESS) { - return TSDB_CODE_TSC_INVALID_SQL; + code = tscSetTableFullName(pTableMetaInfo1, &t, pSql); + if (code != TSDB_CODE_SUCCESS) { + return code; } tVariant* pTableItem1 = &pQuerySql->from->a[i + 1].pVar; + if (pTableItem1->nType != TSDB_DATA_TYPE_BINARY) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg11); + } + SStrToken aliasName = {.z = pTableItem1->pz, .n = pTableItem1->nLen, .type = TK_STRING}; if (tscValidateName(&aliasName) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg11); @@ -6242,6 +6296,11 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) { return TSDB_CODE_TSC_INVALID_SQL; } + // set order by info + if (parseOrderbyClause(pCmd, pQueryInfo, pQuerySql, tscGetTableSchema(pTableMetaInfo->pTableMeta)) != TSDB_CODE_SUCCESS) { + return TSDB_CODE_TSC_INVALID_SQL; + } + // set interval value if (parseIntervalClause(pCmd, pQueryInfo, pQuerySql) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_SQL; @@ -6252,11 +6311,6 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) { } } - // set order by info - if (parseOrderbyClause(pCmd, pQueryInfo, pQuerySql, tscGetTableSchema(pTableMetaInfo->pTableMeta)) != TSDB_CODE_SUCCESS) { - return TSDB_CODE_TSC_INVALID_SQL; - } - // user does not specified the query time window, twa is not allowed in such case. if ((pQueryInfo->window.skey == INT64_MIN || pQueryInfo->window.ekey == INT64_MAX || (pQueryInfo->window.ekey == INT64_MAX / 1000 && tinfo.precision == TSDB_TIME_PRECISION_MILLI)) && tscIsTWAQuery(pQueryInfo)) { @@ -6323,19 +6377,19 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) { return TSDB_CODE_SUCCESS; // Does not build query message here } -int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pSqlExpr, SArray* pExprInfo, SQueryInfo* pQueryInfo, SArray* pCols) { +int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pSqlExpr, SQueryInfo* pQueryInfo, SArray* pCols, int64_t *uid) { tExprNode* pLeft = NULL; tExprNode* pRight= NULL; if (pSqlExpr->pLeft != NULL) { - int32_t ret = exprTreeFromSqlExpr(pCmd, &pLeft, pSqlExpr->pLeft, pExprInfo, pQueryInfo, pCols); + int32_t ret = exprTreeFromSqlExpr(pCmd, &pLeft, pSqlExpr->pLeft, pQueryInfo, pCols, uid); if (ret != TSDB_CODE_SUCCESS) { return ret; } } if (pSqlExpr->pRight != NULL) { - int32_t ret = exprTreeFromSqlExpr(pCmd, &pRight, pSqlExpr->pRight, pExprInfo, pQueryInfo, pCols); + int32_t ret = exprTreeFromSqlExpr(pCmd, &pRight, pSqlExpr->pRight, pQueryInfo, pCols, uid); if (ret != TSDB_CODE_SUCCESS) { return ret; } @@ -6362,14 +6416,19 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pS strncpy((*pExpr)->pSchema->name, pSqlExpr->operand.z, pSqlExpr->operand.n); // set the input column data byte and type. - size_t size = taosArrayGetSize(pExprInfo); + size_t size = taosArrayGetSize(pQueryInfo->exprList); for (int32_t i = 0; i < size; ++i) { - SSqlExpr* p1 = taosArrayGetP(pExprInfo, i); + SSqlExpr* p1 = taosArrayGetP(pQueryInfo->exprList, i); if (strcmp((*pExpr)->pSchema->name, p1->aliasName) == 0) { - (*pExpr)->pSchema->type = (uint8_t)p1->resType; + (*pExpr)->pSchema->type = (uint8_t)p1->resType; (*pExpr)->pSchema->bytes = p1->resBytes; + + if (uid != NULL) { + *uid = p1->uid; + } + break; } } diff --git a/src/client/src/tscSchemaUtil.c b/src/client/src/tscSchemaUtil.c index 244bb8116452fac495f2d140b8b3d8b3e8d96eeb..ac740555af649c8c20dc1fe51cc7ea48592e064c 100644 --- a/src/client/src/tscSchemaUtil.c +++ b/src/client/src/tscSchemaUtil.c @@ -145,10 +145,11 @@ static void tscInitCorVgroupInfo(SCMCorVgroupInfo *corVgroupInfo, SCMVgroupInfo corVgroupInfo->inUse = 0; corVgroupInfo->numOfEps = vgroupInfo->numOfEps; for (int32_t i = 0; i < corVgroupInfo->numOfEps; i++) { - strncpy(corVgroupInfo->epAddr[i].fqdn, vgroupInfo->epAddr[i].fqdn, TSDB_FQDN_LEN); + corVgroupInfo->epAddr[i].fqdn = strdup(vgroupInfo->epAddr[i].fqdn); corVgroupInfo->epAddr[i].port = vgroupInfo->epAddr[i].port; } } + STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size) { assert(pTableMetaMsg != NULL); @@ -162,14 +163,25 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size .numOfColumns = pTableMetaMsg->numOfColumns, }; - pTableMeta->id.tid = pTableMetaMsg->sid; + pTableMeta->id.tid = pTableMetaMsg->tid; pTableMeta->id.uid = pTableMetaMsg->uid; - pTableMeta->vgroupInfo = pTableMetaMsg->vgroup; - tscInitCorVgroupInfo(&pTableMeta->corVgroupInfo, &pTableMeta->vgroupInfo); + SCMVgroupInfo* pVgroupInfo = &pTableMeta->vgroupInfo; + pVgroupInfo->numOfEps = pTableMetaMsg->vgroup.numOfEps; + pVgroupInfo->vgId = pTableMetaMsg->vgroup.vgId; + + for(int32_t i = 0; i < pVgroupInfo->numOfEps; ++i) { + SEpAddrMsg* pEpMsg = &pTableMetaMsg->vgroup.epAddr[i]; + + pVgroupInfo->epAddr[i].fqdn = strndup(pEpMsg->fqdn, tListLen(pEpMsg->fqdn)); + pVgroupInfo->epAddr[i].port = pEpMsg->port; + } + + tscInitCorVgroupInfo(&pTableMeta->corVgroupInfo, pVgroupInfo); pTableMeta->sversion = pTableMetaMsg->sversion; pTableMeta->tversion = pTableMetaMsg->tversion; + tstrncpy(pTableMeta->sTableId, pTableMetaMsg->sTableId, TSDB_TABLE_FNAME_LEN); memcpy(pTableMeta->schema, pTableMetaMsg->schema, schemaSize); diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index c6e9cbafd751809e6bfdedb064f3b6c40480699b..581271f8455f655451a0e9291e131a7eb8ac2dec 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -24,7 +24,6 @@ #include "tschemautil.h" #include "tsclient.h" #include "ttimer.h" -#include "tutil.h" #include "tlockfree.h" SRpcCorEpSet tscMgmtEpSet; @@ -53,7 +52,10 @@ static void tscSetDnodeEpSet(SSqlObj* pSql, SCMVgroupInfo* pVgroupInfo) { assert(pSql != NULL && pVgroupInfo != NULL && pVgroupInfo->numOfEps > 0); SRpcEpSet* pEpSet = &pSql->epSet; - pEpSet->inUse = 0; + + // Issue the query to one of the vnode among a vgroup randomly. + // change the inUse property would not affect the isUse attribute of STableMeta + pEpSet->inUse = rand() % pVgroupInfo->numOfEps; // apply the FQDN string length check here bool hasFqdn = false; @@ -122,12 +124,15 @@ static void tscUpdateVgroupInfo(SSqlObj *pObj, SRpcEpSet *pEpSet) { pVgroupInfo->inUse = pEpSet->inUse; pVgroupInfo->numOfEps = pEpSet->numOfEps; for (int32_t i = 0; i < pVgroupInfo->numOfEps; i++) { - tstrncpy(pVgroupInfo->epAddr[i].fqdn, pEpSet->fqdn[i], TSDB_FQDN_LEN); + taosTFree(pVgroupInfo->epAddr[i].fqdn); + pVgroupInfo->epAddr[i].fqdn = strndup(pEpSet->fqdn[i], tListLen(pEpSet->fqdn[i])); pVgroupInfo->epAddr[i].port = pEpSet->port[i]; } + tscDebug("after: EndPoint in use: %d", pVgroupInfo->inUse); taosCorEndWrite(&pVgroupInfo->version); } + void tscPrintMgmtEp() { SRpcEpSet dump; tscDumpMgmtEpSet(&dump); @@ -143,12 +148,13 @@ void tscPrintMgmtEp() { void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) { STscObj *pObj = (STscObj *)param; if (pObj == NULL) return; + if (pObj != pObj->signature) { tscError("heart beat msg, pObj:%p, signature:%p invalid", pObj, pObj->signature); return; } - SSqlObj *pSql = pObj->pHb; + SSqlObj *pSql = tres; SSqlRes *pRes = &pSql->res; if (code == 0) { @@ -169,10 +175,17 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) { if (pRsp->streamId) tscKillStream(pObj, htonl(pRsp->streamId)); } } else { - tscDebug("heart beat failed, code:%s", tstrerror(code)); + tscDebug("heartbeat failed, code:%s", tstrerror(code)); } - taosTmrReset(tscProcessActivityTimer, tsShellActivityTimer * 500, pObj, tscTmr, &pObj->pTimer); + if (pObj->pHb != NULL) { + int32_t waitingDuring = tsShellActivityTimer * 500; + tscDebug("%p start heartbeat in %dms", pSql, waitingDuring); + + taosTmrReset(tscProcessActivityTimer, waitingDuring, pObj, tscTmr, &pObj->pTimer); + } else { + tscDebug("%p start to close tscObj:%p, not send heartbeat again", pSql, pObj); + } } void tscProcessActivityTimer(void *handle, void *tmrId) { @@ -186,15 +199,19 @@ void tscProcessActivityTimer(void *handle, void *tmrId) { return; } - if (tscShouldFreeHeartBeat(pHB)) { - tscDebug("%p free HB object and release connection", pHB); - tscFreeSqlObj(pHB); - tscCloseTscObj(pObj); - } else { - int32_t code = tscProcessSql(pHB); - if (code != TSDB_CODE_SUCCESS) { - tscError("%p failed to sent HB to server, reason:%s", pHB, tstrerror(code)); - } + void** p = taosCacheAcquireByKey(tscObjCache, &pHB, sizeof(TSDB_CACHE_PTR_TYPE)); + if (p == NULL) { + tscWarn("%p HB object has been released already", pHB); + return; + } + + assert(*pHB->self == pHB); + + int32_t code = tscProcessSql(pHB); + taosCacheRelease(tscObjCache, (void**) &p, false); + + if (code != TSDB_CODE_SUCCESS) { + tscError("%p failed to sent HB to server, reason:%s", pHB, tstrerror(code)); } } @@ -233,9 +250,8 @@ int tscSendMsgToServer(SSqlObj *pSql) { } void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { - uint64_t handle = (uint64_t) rpcMsg->ahandle; - - void** p = taosCacheAcquireByKey(tscObjCache, &handle, sizeof(uint64_t)); + TSDB_CACHE_PTR_TYPE handle = (TSDB_CACHE_PTR_TYPE) rpcMsg->ahandle; + void** p = taosCacheAcquireByKey(tscObjCache, &handle, sizeof(TSDB_CACHE_PTR_TYPE)); if (p == NULL) { rpcFreeCont(rpcMsg->pCont); return; @@ -249,6 +265,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { SSqlCmd *pCmd = &pSql->cmd; assert(*pSql->self == pSql); + pSql->pRpcCtx = NULL; if (pObj->signature != pObj) { tscDebug("%p DB connection is closed, cmd:%d pObj:%p signature:%p", pSql, pCmd->command, pObj, pObj->signature); @@ -258,8 +275,6 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { return; } - pSql->pRpcCtx = NULL; // clear the rpcCtx - SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); if (pQueryInfo != NULL && pQueryInfo->type == TSDB_QUERY_TYPE_FREE_RESOURCE) { tscDebug("%p sqlObj needs to be released or DB connection is closed, cmd:%d type:%d, pObj:%p signature:%p", @@ -454,34 +469,6 @@ int tscProcessSql(SSqlObj *pSql) { return doProcessSql(pSql); } -void tscKillSTableQuery(SSqlObj *pSql) { - SSqlCmd* pCmd = &pSql->cmd; - - SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); - if (!tscIsTwoStageSTableQuery(pQueryInfo, 0)) { - return; - } - - pSql->res.code = TSDB_CODE_TSC_QUERY_CANCELLED; - - for (int i = 0; i < pSql->numOfSubs; ++i) { - // NOTE: pSub may have been released already here - SSqlObj *pSub = pSql->pSubs[i]; - if (pSub == NULL) { - continue; - } - - pSub->res.code = TSDB_CODE_TSC_QUERY_CANCELLED; - if (pSub->pRpcCtx != NULL) { - rpcCancelRequest(pSub->pRpcCtx); - } - - tscQueueAsyncRes(pSub); // async res? not other functions? - } - - tscDebug("%p super table query cancelled", pSql); -} - int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SRetrieveTableMsg *pRetrieveMsg = (SRetrieveTableMsg *) pSql->cmd.payload; pRetrieveMsg->qhandle = htobe64(pSql->res.qhandle); @@ -494,14 +481,25 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) { if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { int32_t vgIndex = pTableMetaInfo->vgroupIndex; - - SVgroupsInfo* pVgroupInfo = pTableMetaInfo->vgroupList; - assert(pVgroupInfo->vgroups[vgIndex].vgId > 0 && vgIndex < pTableMetaInfo->vgroupList->numOfVgroups); + if (pTableMetaInfo->pVgroupTables == NULL) { + SVgroupsInfo *pVgroupInfo = pTableMetaInfo->vgroupList; + assert(pVgroupInfo->vgroups[vgIndex].vgId > 0 && vgIndex < pTableMetaInfo->vgroupList->numOfVgroups); + + pRetrieveMsg->header.vgId = htonl(pVgroupInfo->vgroups[vgIndex].vgId); + tscDebug("%p build fetch msg from vgId:%d, vgIndex:%d", pSql, pVgroupInfo->vgroups[vgIndex].vgId, vgIndex); + } else { + int32_t numOfVgroups = (int32_t)taosArrayGetSize(pTableMetaInfo->pVgroupTables); + assert(vgIndex >= 0 && vgIndex < numOfVgroups); + + SVgroupTableInfo* pTableIdList = taosArrayGet(pTableMetaInfo->pVgroupTables, vgIndex); - pRetrieveMsg->header.vgId = htonl(pVgroupInfo->vgroups[vgIndex].vgId); + pRetrieveMsg->header.vgId = htonl(pTableIdList->vgInfo.vgId); + tscDebug("%p build fetch msg from vgId:%d, vgIndex:%d", pSql, pTableIdList->vgInfo.vgId, vgIndex); + } } else { STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; pRetrieveMsg->header.vgId = htonl(pTableMeta->vgroupInfo.vgId); + tscDebug("%p build fetch msg from only one vgroup, vgId:%d", pSql, pTableMeta->vgroupInfo.vgId); } pSql->cmd.payloadLen = sizeof(SRetrieveTableMsg); @@ -641,14 +639,14 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { size_t numOfSrcCols = taosArrayGetSize(pQueryInfo->colList); if (numOfSrcCols <= 0 && !tscQueryTags(pQueryInfo)) { - tscError("%p illegal value of numOfCols in query msg: %"PRIu64", table cols:%d", pSql, numOfSrcCols, + tscError("%p illegal value of numOfCols in query msg: %" PRIu64 ", table cols:%d", pSql, (uint64_t)numOfSrcCols, tscGetNumOfColumns(pTableMeta)); return TSDB_CODE_TSC_INVALID_SQL; } if (pQueryInfo->interval.interval < 0) { - tscError("%p illegal value of aggregation time interval in query msg: %ld", pSql, pQueryInfo->interval.interval); + tscError("%p illegal value of aggregation time interval in query msg: %" PRId64, pSql, (int64_t)pQueryInfo->interval.interval); return TSDB_CODE_TSC_INVALID_SQL; } @@ -675,12 +673,12 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pQueryMsg->limit = htobe64(pQueryInfo->limit.limit); pQueryMsg->offset = htobe64(pQueryInfo->limit.offset); pQueryMsg->numOfCols = htons((int16_t)taosArrayGetSize(pQueryInfo->colList)); - pQueryMsg->interval.interval = htobe64(pQueryInfo->interval.interval); - pQueryMsg->interval.sliding = htobe64(pQueryInfo->interval.sliding); + pQueryMsg->interval.interval = htobe64(pQueryInfo->interval.interval); + pQueryMsg->interval.sliding = htobe64(pQueryInfo->interval.sliding); pQueryMsg->interval.offset = htobe64(pQueryInfo->interval.offset); pQueryMsg->interval.intervalUnit = pQueryInfo->interval.intervalUnit; - pQueryMsg->interval.slidingUnit = pQueryInfo->interval.slidingUnit; - pQueryMsg->interval.offsetUnit = pQueryInfo->interval.offsetUnit; + pQueryMsg->interval.slidingUnit = pQueryInfo->interval.slidingUnit; + pQueryMsg->interval.offsetUnit = pQueryInfo->interval.offsetUnit; pQueryMsg->numOfGroupCols = htons(pQueryInfo->groupbyExpr.numOfGroupCols); pQueryMsg->numOfTags = htonl(numOfTags); pQueryMsg->tagNameRelType = htons(pQueryInfo->tagCond.relType); @@ -745,7 +743,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i); if (!tscValidateColumnId(pTableMetaInfo, pExpr->colInfo.colId, pExpr->numOfParams)) { - /* column id is not valid according to the cached table meta, the table meta is expired */ tscError("%p table schema is not matched with parsed sql", pSql); return TSDB_CODE_TSC_INVALID_SQL; } @@ -864,7 +861,8 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int32_t numOfBlocks = 0; if (pQueryInfo->tsBuf != NULL) { - STSVnodeBlockInfo *pBlockInfo = tsBufGetVnodeBlockInfo(pQueryInfo->tsBuf, pTableMetaInfo->vgroupIndex); + int32_t vnodeId = htonl(pQueryMsg->head.vgId); + STSVnodeBlockInfo *pBlockInfo = tsBufGetVnodeBlockInfo(pQueryInfo->tsBuf, vnodeId); assert(QUERY_IS_JOIN_QUERY(pQueryInfo->type) && pBlockInfo != NULL); // this query should not be sent // todo refactor @@ -1382,7 +1380,7 @@ static int tscSetResultPointer(SQueryInfo *pQueryInfo, SSqlRes *pRes) { for (int i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { int16_t offset = tscFieldInfoGetOffset(pQueryInfo, i); - pRes->tsrow[i] = ((char*) pRes->data + offset * pRes->numOfRows); + pRes->tsrow[i] = (unsigned char*)((char*) pRes->data + offset * pRes->numOfRows); } return 0; @@ -1441,7 +1439,7 @@ int tscProcessLocalRetrieveRsp(SSqlObj *pSql) { int tscProcessRetrieveLocalMergeRsp(SSqlObj *pSql) { SSqlRes *pRes = &pSql->res; - SSqlCmd *pCmd = &pSql->cmd; + SSqlCmd* pCmd = &pSql->cmd; int32_t code = pRes->code; if (pRes->code != TSDB_CODE_SUCCESS) { @@ -1484,6 +1482,7 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SCMConnectMsg *pConnect = (SCMConnectMsg*)pCmd->payload; + // TODO refactor full_name char *db; // ugly code to move the space db = strstr(pObj->db, TS_PATH_DELIMITER); db = (db == NULL) ? pObj->db : db + 1; @@ -1491,47 +1490,36 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) { tstrncpy(pConnect->clientVersion, version, sizeof(pConnect->clientVersion)); tstrncpy(pConnect->msgVersion, "", sizeof(pConnect->msgVersion)); + pConnect->pid = htonl(taosGetPId()); + taosGetCurrentAPPName(pConnect->appName, NULL); + return TSDB_CODE_SUCCESS; } int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) { - SCMTableInfoMsg *pInfoMsg; - char * pMsg; - int msgLen = 0; - - char *tmpData = NULL; - uint32_t len = pSql->cmd.payloadLen; - if (len > 0) { - if ((tmpData = calloc(1, len)) == NULL) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; - } - - // STagData is in binary format, strncpy is not available - memcpy(tmpData, pSql->cmd.payload, len); - } - SSqlCmd * pCmd = &pSql->cmd; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - pInfoMsg = (SCMTableInfoMsg *)pCmd->payload; + SCMTableInfoMsg* pInfoMsg = (SCMTableInfoMsg *)pCmd->payload; strcpy(pInfoMsg->tableId, pTableMetaInfo->name); pInfoMsg->createFlag = htons(pSql->cmd.autoCreated ? 1 : 0); - pMsg = (char*)pInfoMsg + sizeof(SCMTableInfoMsg); + char* pMsg = (char*)pInfoMsg + sizeof(SCMTableInfoMsg); - if (pSql->cmd.autoCreated && len > 0) { - memcpy(pInfoMsg->tags, tmpData, len); - pMsg += len; + size_t len = htonl(pCmd->tagData.dataLen); + if (pSql->cmd.autoCreated) { + if (len > 0) { + len += sizeof(pCmd->tagData.name) + sizeof(pCmd->tagData.dataLen); + memcpy(pInfoMsg->tags, &pCmd->tagData, len); + pMsg += len; + } } pCmd->payloadLen = (int32_t)(pMsg - (char*)pInfoMsg); pCmd->msgType = TSDB_MSG_TYPE_CM_TABLE_META; - taosTFree(tmpData); - - assert(msgLen + minMsgSize() <= (int32_t)pCmd->allocSize); return TSDB_CODE_SUCCESS; } @@ -1657,6 +1645,10 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SCMHeartBeatMsg *pHeartbeat = (SCMHeartBeatMsg *)pCmd->payload; pHeartbeat->numOfQueries = numOfQueries; pHeartbeat->numOfStreams = numOfStreams; + + pHeartbeat->pid = htonl(taosGetPId()); + taosGetCurrentAPPName(pHeartbeat->appName, NULL); + int msgLen = tscBuildQueryStreamDesc(pHeartbeat, pObj); pthread_mutex_unlock(&pObj->mutex); @@ -1670,7 +1662,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int tscProcessTableMetaRsp(SSqlObj *pSql) { STableMetaMsg *pMetaMsg = (STableMetaMsg *)pSql->res.pRsp; - pMetaMsg->sid = htonl(pMetaMsg->sid); + pMetaMsg->tid = htonl(pMetaMsg->tid); pMetaMsg->sversion = htons(pMetaMsg->sversion); pMetaMsg->tversion = htons(pMetaMsg->tversion); pMetaMsg->vgroup.vgId = htonl(pMetaMsg->vgroup.vgId); @@ -1680,9 +1672,9 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) { pMetaMsg->numOfColumns = htons(pMetaMsg->numOfColumns); if ((pMetaMsg->tableType != TSDB_SUPER_TABLE) && - (pMetaMsg->sid <= 0 || pMetaMsg->vgroup.vgId < 2 || pMetaMsg->vgroup.numOfEps <= 0)) { + (pMetaMsg->tid <= 0 || pMetaMsg->vgroup.vgId < 2 || pMetaMsg->vgroup.numOfEps <= 0)) { tscError("invalid value in table numOfEps:%d, vgId:%d tid:%d, name:%s", pMetaMsg->vgroup.numOfEps, pMetaMsg->vgroup.vgId, - pMetaMsg->sid, pMetaMsg->tableId); + pMetaMsg->tid, pMetaMsg->tableId); return TSDB_CODE_TSC_INVALID_VALUE; } @@ -1861,22 +1853,30 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) { SSqlCmd* pCmd = &parent->cmd; for(int32_t i = 0; i < pStableVgroup->numOfTables; ++i) { STableMetaInfo *pInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, i); - SVgroupsInfo * pVgroupInfo = (SVgroupsInfo *)pMsg; - pVgroupInfo->numOfVgroups = htonl(pVgroupInfo->numOfVgroups); - size_t size = sizeof(SCMVgroupInfo) * pVgroupInfo->numOfVgroups + sizeof(SVgroupsInfo); - pInfo->vgroupList = calloc(1, size); + SVgroupsMsg * pVgroupMsg = (SVgroupsMsg *) pMsg; + pVgroupMsg->numOfVgroups = htonl(pVgroupMsg->numOfVgroups); + + size_t size = sizeof(SCMVgroupMsg) * pVgroupMsg->numOfVgroups + sizeof(SVgroupsMsg); + + size_t vgroupsz = sizeof(SCMVgroupInfo) * pVgroupMsg->numOfVgroups + sizeof(SVgroupsInfo); + pInfo->vgroupList = calloc(1, vgroupsz); assert(pInfo->vgroupList != NULL); - memcpy(pInfo->vgroupList, pVgroupInfo, size); + pInfo->vgroupList->numOfVgroups = pVgroupMsg->numOfVgroups; for (int32_t j = 0; j < pInfo->vgroupList->numOfVgroups; ++j) { //just init, no need to lock SCMVgroupInfo *pVgroups = &pInfo->vgroupList->vgroups[j]; - pVgroups->vgId = htonl(pVgroups->vgId); - assert(pVgroups->numOfEps >= 1); + + SCMVgroupMsg *vmsg = &pVgroupMsg->vgroups[j]; + pVgroups->vgId = htonl(vmsg->vgId); + pVgroups->numOfEps = vmsg->numOfEps; + + assert(pVgroups->numOfEps >= 1 && pVgroups->vgId >= 1); for (int32_t k = 0; k < pVgroups->numOfEps; ++k) { - pVgroups->epAddr[k].port = htons(pVgroups->epAddr[k].port); + pVgroups->epAddr[k].port = htons(vmsg->epAddr[k].port); + pVgroups->epAddr[k].fqdn = strndup(vmsg->epAddr[k].fqdn, tListLen(vmsg->epAddr[k].fqdn)); } } @@ -1912,7 +1912,7 @@ int tscProcessShowRsp(SSqlObj *pSql) { pMetaMsg->numOfColumns = ntohs(pMetaMsg->numOfColumns); pSchema = pMetaMsg->schema; - pMetaMsg->sid = ntohs(pMetaMsg->sid); + pMetaMsg->tid = ntohs(pMetaMsg->tid); for (int i = 0; i < pMetaMsg->numOfColumns; ++i) { pSchema->bytes = htons(pSchema->bytes); pSchema++; @@ -1946,7 +1946,7 @@ int tscProcessShowRsp(SSqlObj *pSql) { tscColumnListInsert(pQueryInfo->colList, &index); TAOS_FIELD f = tscCreateField(pSchema->type, pSchema->name, pSchema->bytes); - SFieldSupInfo* pInfo = tscFieldInfoAppend(pFieldInfo, &f); + SInternalField* pInfo = tscFieldInfoAppend(pFieldInfo, &f); pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, pTableSchema[i].type, pTableSchema[i].bytes, pTableSchema[i].bytes, false); @@ -1959,6 +1959,7 @@ int tscProcessShowRsp(SSqlObj *pSql) { return 0; } +// TODO multithread problem static void createHBObj(STscObj* pObj) { if (pObj->pHb != NULL) { return; @@ -1986,12 +1987,11 @@ static void createHBObj(STscObj* pObj) { pSql->param = pObj; pSql->pTscObj = pObj; pSql->signature = pSql; - pObj->pHb = pSql; - T_REF_INC(pObj); - tscAddSubqueryInfo(&pObj->pHb->cmd); + registerSqlObj(pSql); + tscDebug("%p HB is allocated, pObj:%p", pSql, pObj); - tscDebug("%p HB is allocated, pObj:%p", pObj->pHb, pObj); + pObj->pHb = pSql; } int tscProcessConnectRsp(SSqlObj *pSql) { @@ -2017,8 +2017,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) { pObj->connId = htonl(pConnect->connId); createHBObj(pObj); - -// taosTmrReset(tscProcessActivityTimer, tsShellActivityTimer * 500, pObj, tscTmr, &pObj->pTimer); + taosTmrReset(tscProcessActivityTimer, tsShellActivityTimer * 500, pObj, tscTmr, &pObj->pTimer); return 0; } @@ -2090,6 +2089,9 @@ int tscProcessAlterDbMsgRsp(SSqlObj *pSql) { UNUSED(pSql); return 0; } +int tscProcessShowCreateRsp(SSqlObj *pSql) { + return tscLocalResultCommonBuilder(pSql, 1); +} int tscProcessQueryRsp(SSqlObj *pSql) { SSqlRes *pRes = &pSql->res; @@ -2164,11 +2166,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf pNew->signature = pNew; pNew->cmd.command = TSDB_SQL_META; - T_REF_INC(pNew->pTscObj); - - // TODO add test case on x86 platform - uint64_t adr = (uint64_t) pNew; - pNew->self = taosCachePut(tscObjCache, &adr, sizeof(uint64_t), &pNew, sizeof(uint64_t), 2*60*1000); + registerSqlObj(pNew); tscAddSubqueryInfo(&pNew->cmd); @@ -2186,8 +2184,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf assert(pNew->cmd.numOfClause == 1 && pNewQueryInfo->numOfTables == 1); tstrncpy(pNewMeterMetaInfo->name, pTableMetaInfo->name, sizeof(pNewMeterMetaInfo->name)); - memcpy(pNew->cmd.payload, pSql->cmd.payload, pSql->cmd.payloadLen); // tag information if table does not exists. - pNew->cmd.payloadLen = pSql->cmd.payloadLen; + memcpy(&pNew->cmd.tagData, &pSql->cmd.tagData, sizeof(pSql->cmd.tagData)); tscDebug("%p new pSqlObj:%p to get tableMeta, auto create:%d", pSql, pNew, pNew->cmd.autoCreated); pNew->fp = tscTableMetaCallBack; @@ -2286,7 +2283,7 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) { for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) { STableMetaInfo *pMInfo = tscGetMetaInfo(pQueryInfo, i); STableMeta *pTableMeta = taosCacheAcquireByData(tscMetaCache, pMInfo->pTableMeta); - tscAddTableMetaInfo(pNewQueryInfo, pMInfo->name, pTableMeta, NULL, pMInfo->tagColList); + tscAddTableMetaInfo(pNewQueryInfo, pMInfo->name, pTableMeta, NULL, pMInfo->tagColList, pMInfo->pVgroupTables); } if ((code = tscAllocPayload(&pNew->cmd, TSDB_DEFAULT_PAYLOAD_SIZE)) != TSDB_CODE_SUCCESS) { @@ -2295,10 +2292,8 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) { } pNewQueryInfo->numOfTables = pQueryInfo->numOfTables; - T_REF_INC(pNew->pTscObj); + registerSqlObj(pNew); - uint64_t p = (uint64_t) pNew; - pNew->self = taosCachePut(tscObjCache, &p, sizeof(uint64_t), &pNew, sizeof(uint64_t), 2 * 600 * 1000); tscDebug("%p new sqlObj:%p to get vgroupInfo, numOfTables:%d", pSql, pNew, pNewQueryInfo->numOfTables); pNew->fp = tscTableMetaCallBack; @@ -2376,6 +2371,10 @@ void tscInitMsgsFp() { tscProcessMsgRsp[TSDB_SQL_ALTER_TABLE] = tscProcessAlterTableMsgRsp; tscProcessMsgRsp[TSDB_SQL_ALTER_DB] = tscProcessAlterDbMsgRsp; + tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_TABLE] = tscProcessShowCreateRsp; + tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp; + + tscKeepConn[TSDB_SQL_SHOW] = 1; tscKeepConn[TSDB_SQL_RETRIEVE] = 1; tscKeepConn[TSDB_SQL_SELECT] = 1; diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 69bc69cd4adfdb0413c330891a23cbd2c80351cb..8cac9b3398a0bc4569b52acc7858bbc1e50de542 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -26,7 +26,9 @@ #include "tsclient.h" #include "ttokendef.h" #include "tutil.h" +#include "ttimer.h" #include "tscProfile.h" +#include "ttimer.h" static bool validImpl(const char* str, size_t maxsize) { if (str == NULL) { @@ -49,8 +51,8 @@ static bool validPassword(const char* passwd) { return validImpl(passwd, TSDB_PASSWORD_LEN - 1); } -SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, const char *auth, const char *db, - uint16_t port, void (*fp)(void *, TAOS_RES *, int), void *param, void **taos) { +static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, const char *auth, const char *db, + uint16_t port, void (*fp)(void *, TAOS_RES *, int), void *param, TAOS **taos) { taos_init(); if (!validUserName(user)) { @@ -156,10 +158,7 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con *taos = pObj; } - T_REF_INC(pSql->pTscObj); - - uint64_t key = (uint64_t) pSql; - pSql->self = taosCachePut(tscObjCache, &key, sizeof(uint64_t), &pSql, sizeof(uint64_t), 2*3600*1000); + registerSqlObj(pSql); tsInsertHeadSize = sizeof(SMsgDesc) + sizeof(SSubmitMsg); return pSql; @@ -236,51 +235,57 @@ TAOS *taos_connect_c(const char *ip, uint8_t ipLen, const char *user, uint8_t us return taos_connect(ipBuf, userBuf, passBuf, dbBuf, port); } +static void asyncConnCallback(void *param, TAOS_RES *tres, int code) { + SSqlObj *pSql = (SSqlObj *) tres; + assert(pSql != NULL); + + pSql->fetchFp(pSql->param, tres, code); +} + TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int), - void *param, void **taos) { - SSqlObj* pSql = taosConnectImpl(ip, user, pass, NULL, db, port, fp, param, taos); + void *param, TAOS **taos) { + STscObj *pObj = NULL; + SSqlObj *pSql = taosConnectImpl(ip, user, pass, NULL, db, port, asyncConnCallback, param, (void **)&pObj); if (pSql == NULL) { return NULL; } - + + if (taos) *taos = pObj; + + pSql->fetchFp = fp; pSql->res.code = tscProcessSql(pSql); tscDebug("%p DB async connection is opening", taos); - return taos; + return pObj; } void taos_close(TAOS *taos) { STscObj *pObj = (STscObj *)taos; - if (pObj == NULL || pObj->signature != pObj) { + if (pObj == NULL) { + tscDebug("(null) try to free tscObj and close dnodeConn"); return; } - if (pObj->pHb != NULL) { - if (pObj->pHb->pRpcCtx != NULL) { // wait for rsp from dnode - rpcCancelRequest(pObj->pHb->pRpcCtx); + tscDebug("%p try to free tscObj and close dnodeConn:%p", pObj, pObj->pDnodeConn); + if (pObj->signature != pObj) { + tscDebug("%p already closed or invalid tscObj", pObj); + return; + } + + // make sure that the close connection can only be executed once. + pObj->signature = NULL; + taosTmrStopA(&(pObj->pTimer)); + + SSqlObj* pHb = pObj->pHb; + if (pHb != NULL && atomic_val_compare_exchange_ptr(&pObj->pHb, pHb, 0) == pHb) { + if (pHb->pRpcCtx != NULL) { // wait for rsp from dnode + rpcCancelRequest(pHb->pRpcCtx); + pHb->pRpcCtx = NULL; } - tscSetFreeHeatBeat(pObj); - tscFreeSqlObj(pObj->pHb); - } - - // free all sqlObjs created by using this connect before free the STscObj -// while(1) { -// pthread_mutex_lock(&pObj->mutex); -// void* p = pObj->sqlList; -// pthread_mutex_unlock(&pObj->mutex); -// -// if (p == NULL) { -// break; -// } -// -// tscDebug("%p waiting for sqlObj to be freed, %p", pObj, p); -// taosMsleep(100); -// -// // todo fix me!! two threads call taos_free_result will cause problem. -// tscDebug("%p free :%p", pObj, p); -// taos_free_result(p); -// } + tscDebug("%p HB is freed", pHb); + taos_free_result(pHb); + } int32_t ref = T_REF_DEC(pObj); assert(ref >= 0); @@ -306,7 +311,7 @@ static void waitForRetrieveRsp(void *param, TAOS_RES *tres, int numOfRows) { tsem_post(&pSql->rspSem); } -TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen) { +TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen, TAOS_RES** res) { STscObj *pObj = (STscObj *)taos; if (pObj == NULL || pObj->signature != pObj) { terrno = TSDB_CODE_TSC_DISCONNECTED; @@ -331,12 +336,20 @@ TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen) { tsem_init(&pSql->rspSem, 0, 0); doAsyncQuery(pObj, pSql, waitForQueryRsp, taos, sqlstr, sqlLen); + if (res != NULL) { + *res = pSql; + } + tsem_wait(&pSql->rspSem); return pSql; } TAOS_RES* taos_query(TAOS *taos, const char *sqlstr) { - return taos_query_c(taos, sqlstr, (uint32_t)strlen(sqlstr)); + return taos_query_c(taos, sqlstr, (uint32_t)strlen(sqlstr), NULL); +} + +TAOS_RES* taos_query_h(TAOS* taos, const char *sqlstr, TAOS_RES** res) { + return taos_query_c(taos, sqlstr, (uint32_t) strlen(sqlstr), res); } int taos_result_precision(TAOS_RES *res) { @@ -360,7 +373,7 @@ int taos_num_fields(TAOS_RES *res) { size_t numOfCols = tscNumOfFields(pQueryInfo); for(int32_t i = 0; i < numOfCols; ++i) { - SFieldSupInfo* pInfo = taosArrayGet(pQueryInfo->fieldsInfo.pSupportInfo, i); + SInternalField* pInfo = taosArrayGet(pQueryInfo->fieldsInfo.internalField, i); if (pInfo->visible) { num++; } @@ -396,8 +409,24 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) { if (numOfCols == 0) { return NULL; } - - return pQueryInfo->fieldsInfo.pFields->pData; + + SFieldInfo *pFieldInfo = &pQueryInfo->fieldsInfo; + + if (pFieldInfo->final == NULL) { + TAOS_FIELD* f = calloc(pFieldInfo->numOfOutput, sizeof(TAOS_FIELD)); + + int32_t j = 0; + for(int32_t i = 0; i < pFieldInfo->numOfOutput; ++i) { + SInternalField* pField = tscFieldInfoGetInternalField(pFieldInfo, i); + if (pField->visible) { + f[j++] = pField->field; + } + } + + pFieldInfo->final = f; + } + + return pFieldInfo->final; } int taos_retrieve(TAOS_RES *res) { @@ -470,6 +499,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) { SSqlRes *pRes = &pSql->res; if (pRes->qhandle == 0 || + pRes->code == TSDB_CODE_TSC_QUERY_CANCELLED || pCmd->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT || pCmd->command == TSDB_SQL_INSERT) { return NULL; @@ -485,6 +515,8 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) { pCmd->command == TSDB_SQL_TABLE_JOIN_RETRIEVE || pCmd->command == TSDB_SQL_FETCH || pCmd->command == TSDB_SQL_SHOW || + pCmd->command == TSDB_SQL_SHOW_CREATE_TABLE || + pCmd->command == TSDB_SQL_SHOW_CREATE_DATABASE || pCmd->command == TSDB_SQL_SELECT || pCmd->command == TSDB_SQL_DESCRIBE_TABLE || pCmd->command == TSDB_SQL_SERV_STATUS || @@ -531,7 +563,7 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) { pRes->numOfClauseTotal = 0; pRes->rspType = 0; - pSql->numOfSubs = 0; + pSql->subState.numOfSub = 0; taosTFree(pSql->pSubs); assert(pSql->fp == NULL); @@ -575,7 +607,8 @@ static UNUSED_FUNC bool tscKillQueryInDnode(SSqlObj* pSql) { return true; } - SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); + SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); + if ((pQueryInfo == NULL) || tscIsTwoStageSTableQuery(pQueryInfo, 0)) { return true; } @@ -685,6 +718,46 @@ int* taos_fetch_lengths(TAOS_RES *res) { char *taos_get_client_info() { return version; } +static void tscKillSTableQuery(SSqlObj *pSql) { + SSqlCmd* pCmd = &pSql->cmd; + + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); + + if (!tscIsTwoStageSTableQuery(pQueryInfo, 0)) { + return; + } + + // set the master sqlObj flag to cancel query + pSql->res.code = TSDB_CODE_TSC_QUERY_CANCELLED; + + for (int i = 0; i < pSql->subState.numOfSub; ++i) { + // NOTE: pSub may have been released already here + SSqlObj *pSub = pSql->pSubs[i]; + if (pSub == NULL) { + continue; + } + + void** p = taosCacheAcquireByKey(tscObjCache, &pSub, sizeof(TSDB_CACHE_PTR_TYPE)); + if (p == NULL) { + continue; + } + + SSqlObj* pSubObj = (SSqlObj*) (*p); + assert(pSubObj->self == (SSqlObj**) p); + + pSubObj->res.code = TSDB_CODE_TSC_QUERY_CANCELLED; + if (pSubObj->pRpcCtx != NULL) { + rpcCancelRequest(pSubObj->pRpcCtx); + pSubObj->pRpcCtx = NULL; + } + + tscQueueAsyncRes(pSubObj); + taosCacheRelease(tscObjCache, (void**) &p, false); + } + + tscDebug("%p super table query cancelled", pSql); +} + void taos_stop_query(TAOS_RES *res) { SSqlObj *pSql = (SSqlObj *)res; if (pSql == NULL || pSql->signature != pSql) { @@ -694,20 +767,27 @@ void taos_stop_query(TAOS_RES *res) { tscDebug("%p start to cancel query", res); SSqlCmd *pCmd = &pSql->cmd; - // TODO there are multi-thread problem. - // It may have been released by the other thread already. - // The ref count may fix this problem. - SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); - // set the error code for master pSqlObj firstly pSql->res.code = TSDB_CODE_TSC_QUERY_CANCELLED; + SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); + if (tscIsTwoStageSTableQuery(pQueryInfo, 0)) { assert(pSql->pRpcCtx == NULL); tscKillSTableQuery(pSql); } else { if (pSql->cmd.command < TSDB_SQL_LOCAL) { - rpcCancelRequest(pSql->pRpcCtx); + /* + * There is multi-thread problem here, since pSql->pRpcCtx may have been + * reset and freed in the processMsgFromServer function, and causes the invalid + * write problem for rpcCancelRequest. + */ + if (pSql->pRpcCtx != NULL) { + rpcCancelRequest(pSql->pRpcCtx); + pSql->pRpcCtx = NULL; + } + + tscQueueAsyncRes(pSql); } } @@ -728,15 +808,15 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) switch (fields[i].type) { case TSDB_DATA_TYPE_TINYINT: - len += sprintf(str + len, "%d", *((char *)row[i])); + len += sprintf(str + len, "%d", *((int8_t *)row[i])); break; case TSDB_DATA_TYPE_SMALLINT: - len += sprintf(str + len, "%d", *((short *)row[i])); + len += sprintf(str + len, "%d", *((int16_t *)row[i])); break; case TSDB_DATA_TYPE_INT: - len += sprintf(str + len, "%d", *((int *)row[i])); + len += sprintf(str + len, "%d", *((int32_t *)row[i])); break; case TSDB_DATA_TYPE_BIGINT: @@ -795,14 +875,17 @@ int taos_validate_sql(TAOS *taos, const char *sql) { } SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); + pSql->pTscObj = taos; pSql->signature = pSql; + SSqlRes *pRes = &pSql->res; SSqlCmd *pCmd = &pSql->cmd; pRes->numOfTotal = 0; pRes->numOfClauseTotal = 0; + tscDebug("%p Valid SQL: %s pObj:%p", pSql, sql, pObj); int32_t sqlLen = (int32_t)strlen(sql); @@ -817,7 +900,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) { if (pSql->sqlstr == NULL) { pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; tscError("%p failed to malloc sql string buffer", pSql); - tscDebug("%p Valid SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj); + tscDebug("%p Valid SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(pSql), pObj); taosTFree(pSql); return pRes->code; } @@ -833,16 +916,19 @@ int taos_validate_sql(TAOS *taos, const char *sql) { pSql->fp = asyncCallback; pSql->fetchFp = asyncCallback; pSql->param = pSql; + + registerSqlObj(pSql); int code = tsParseSql(pSql, true); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { tsem_wait(&pSql->rspSem); code = pSql->res.code; } + if (code != TSDB_CODE_SUCCESS) { - tscDebug("%p Valid SQL result:%d, %s pObj:%p", pSql, code, taos_errstr(taos), pObj); + tscDebug("%p Valid SQL result:%d, %s pObj:%p", pSql, code, taos_errstr(pSql), pObj); } - taos_free_result(pSql); + taos_free_result(pSql); return code; } @@ -941,34 +1027,32 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); pSql->pTscObj = taos; pSql->signature = pSql; + SSqlRes *pRes = &pSql->res; + pRes->code = 0; pRes->numOfTotal = 0; // the number of getting table meta from server pRes->numOfClauseTotal = 0; - pRes->code = 0; - assert(pSql->fp == NULL); tscDebug("%p tableNameList: %s pObj:%p", pSql, tableNameList, pObj); int32_t tblListLen = (int32_t)strlen(tableNameList); if (tblListLen > MAX_TABLE_NAME_LENGTH) { tscError("%p tableNameList too long, length:%d, maximum allowed:%d", pSql, tblListLen, MAX_TABLE_NAME_LENGTH); - pRes->code = TSDB_CODE_TSC_INVALID_SQL; - taosTFree(pSql); - return pRes->code; + tscFreeSqlObj(pSql); + return TSDB_CODE_TSC_INVALID_SQL; } char *str = calloc(1, tblListLen + 1); if (str == NULL) { - pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; tscError("%p failed to malloc sql string buffer", pSql); - taosTFree(pSql); - return pRes->code; + tscFreeSqlObj(pSql); + return TSDB_CODE_TSC_OUT_OF_MEMORY; } strtolower(str, tableNameList); - pRes->code = (uint8_t)tscParseTblNameList(pSql, str, tblListLen); + int32_t code = (uint8_t) tscParseTblNameList(pSql, str, tblListLen); /* * set the qhandle to 0 before return in order to erase the qhandle value assigned in the previous successful query. @@ -978,17 +1062,17 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { pRes->qhandle = 0; free(str); - if (pRes->code != TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS) { tscFreeSqlObj(pSql); - return pRes->code; + return code; } tscDoQuery(pSql); - tscDebug("%p load multi metermeta result:%d %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj); - if (pRes->code != TSDB_CODE_SUCCESS) { - tscPartiallyFreeSqlObj(pSql); + tscDebug("%p load multi table meta result:%d %s pObj:%p", pSql, pRes->code, taos_errstr(pSql), pObj); + if ((code = pRes->code) != TSDB_CODE_SUCCESS) { + tscFreeSqlObj(pSql); } - return pRes->code; + return code; } diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 4a1f4d9d87ff25450826cbf4715d3200685d1fe7..0f67911bbea992503979e5de019e4e10d3bf3c14 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -136,7 +136,6 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) { etime = pStream->stime + (etime - pStream->stime) / pStream->interval.interval * pStream->interval.interval; } else { etime = taosTimeTruncate(etime, &pStream->interval, pStream->precision); - //etime = taosGetIntervalStartTimestamp(etime, pStream->interval.sliding, pStream->interval.sliding, pStream->interval.slidingUnit, pStream->precision); } pQueryInfo->window.ekey = etime; if (pQueryInfo->window.skey >= pQueryInfo->window.ekey) { @@ -169,8 +168,8 @@ static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOf STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pStream->pSql->cmd, 0, 0); taosCacheRelease(tscMetaCache, (void**)&(pTableMetaInfo->pTableMeta), true); - taosTFree(pTableMetaInfo->vgroupList); - + pTableMetaInfo->vgroupList = tscVgroupInfoClear(pTableMetaInfo->vgroupList); + tscSetRetryTimer(pStream, pStream->pSql, retryDelay); return; } @@ -275,8 +274,8 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf taosCacheRelease(tscMetaCache, (void**)&(pTableMetaInfo->pTableMeta), false); tscFreeSqlResult(pSql); taosTFree(pSql->pSubs); - pSql->numOfSubs = 0; - taosTFree(pTableMetaInfo->vgroupList); + pSql->subState.numOfSub = 0; + pTableMetaInfo->vgroupList = tscVgroupInfoClear(pTableMetaInfo->vgroupList); tscSetNextLaunchTimer(pStream, pSql); } } @@ -399,8 +398,8 @@ static void tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) { SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); if (pQueryInfo->interval.intervalUnit != 'n' && pQueryInfo->interval.intervalUnit!= 'y' && pQueryInfo->interval.interval < minIntervalTime) { - tscWarn("%p stream:%p, original sample interval:%ld too small, reset to:%" PRId64, pSql, pStream, - pQueryInfo->interval.interval, minIntervalTime); + tscWarn("%p stream:%p, original sample interval:%" PRId64 " too small, reset to:%" PRId64, pSql, pStream, + (int64_t)pQueryInfo->interval.interval, minIntervalTime); pQueryInfo->interval.interval = minIntervalTime; } @@ -454,17 +453,11 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in } } else { // timewindow based aggregation stream if (stime == 0) { // no data in meter till now - stime = pQueryInfo->window.skey; - if (stime == INT64_MIN) { - stime = (int64_t)taosGetTimestamp(pStream->precision); - stime = taosTimeTruncate(stime, &pStream->interval, pStream->precision); - stime = taosTimeTruncate(stime - 1, &pStream->interval, pStream->precision); - //stime = taosGetIntervalStartTimestamp(stime, pStream->interval.interval, pStream->interval.interval, pStream->interval.intervalUnit, pStream->precision); - //stime = taosGetIntervalStartTimestamp(stime - 1, pStream->interval.interval, pStream->interval.interval, pStream->interval.intervalUnit, pStream->precision); - tscWarn("%p stream:%p, last timestamp:0, reset to:%" PRId64, pSql, pStream, stime); + if (pQueryInfo->window.skey != INT64_MIN) { + stime = pQueryInfo->window.skey; } + stime = taosTimeTruncate(stime, &pStream->interval, pStream->precision); } else { - //int64_t newStime = taosGetIntervalStartTimestamp(stime, pStream->interval.interval, pStream->interval.interval, pStream->interval.intervalUnit, pStream->precision); int64_t newStime = taosTimeTruncate(stime, &pStream->interval, pStream->precision); if (newStime != stime) { tscWarn("%p stream:%p, last timestamp:%" PRId64 ", reset to:%" PRId64, pSql, pStream, stime, newStime); @@ -477,8 +470,10 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in } static int64_t tscGetLaunchTimestamp(const SSqlStream *pStream) { - int64_t timer = pStream->stime - taosGetTimestamp(pStream->precision); - if (timer < 0) timer = 0; + int64_t timer = 0, now = taosGetTimestamp(pStream->precision); + if (pStream->stime > now) { + timer = pStream->stime - now; + } int64_t startDelay = (pStream->precision == TSDB_TIME_PRECISION_MICRO) ? tsStreamCompStartDelay * 1000L : tsStreamCompStartDelay; @@ -515,6 +510,8 @@ static void tscCreateStream(void *param, TAOS_RES *res, int code) { return; } + registerSqlObj(pSql); + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); @@ -568,6 +565,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p pStream->pSql = pSql; pSql->pStream = pStream; pSql->param = pStream; + pSql->maxRetry = TSDB_MAX_REPLICA; pSql->sqlstr = calloc(1, strlen(sqlstr) + 1); if (pSql->sqlstr == NULL) { @@ -575,6 +573,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p tscFreeSqlObj(pSql); return NULL; } + strtolower(pSql->sqlstr, sqlstr); tscDebugL("%p SQL: %s", pSql, pSql->sqlstr); @@ -615,10 +614,9 @@ void taos_close_stream(TAOS_STREAM *handle) { tscDebug("%p stream:%p is closed", pSql, pStream); // notify CQ to release the pStream object pStream->fp(pStream->param, NULL, NULL); - - tscFreeSqlObj(pSql); pStream->pSql = NULL; + taos_free_result(pSql); taosTFree(pStream); } } diff --git a/src/client/src/tscSub.c b/src/client/src/tscSub.c index 76bce19668433d8819d44c8f272ad62b1d6dd034..2c81bd7c7ce25535dfffe9c1fd6f8a0197fb900b 100644 --- a/src/client/src/tscSub.c +++ b/src/client/src/tscSub.c @@ -105,6 +105,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* code = TAOS_SYSTEM_ERROR(errno); goto fail; } + tstrncpy(pSub->topic, topic, sizeof(pSub->topic)); pSub->progress = taosArrayInit(32, sizeof(SSubscriptionProgress)); if (pSub->progress == NULL) { @@ -119,6 +120,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* code = TSDB_CODE_TSC_OUT_OF_MEMORY; goto fail; } + pSql->signature = pSql; pSql->pTscObj = pObj; pSql->pSubscription = pSub; @@ -142,6 +144,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* code = TSDB_CODE_TSC_OUT_OF_MEMORY; goto fail; } + strtolower(pSql->sqlstr, pSql->sqlstr); pRes->qhandle = 0; pRes->numOfRows = 1; @@ -152,11 +155,14 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* goto fail; } + registerSqlObj(pSql); + code = tsParseSql(pSql, false); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { tsem_wait(&pSub->sem); code = pSql->res.code; } + if (code != TSDB_CODE_SUCCESS) { line = __LINE__; goto fail; @@ -173,9 +179,15 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* fail: tscError("tscCreateSubscription failed at line %d, reason: %s", line, tstrerror(code)); if (pSql != NULL) { - tscFreeSqlObj(pSql); + if (pSql->self != NULL) { + taos_free_result(pSql); + } else { + tscFreeSqlObj(pSql); + } + pSql = NULL; } + if (pSub != NULL) { taosArrayDestroy(pSub->progress); tsem_destroy(&pSub->sem); @@ -494,6 +506,10 @@ void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) { } } + if (pSub->pSql != NULL) { + taos_free_result(pSub->pSql); + } + tscFreeSqlObj(pSub->pSql); taosArrayDestroy(pSub->progress); tsem_destroy(&pSub->sem); diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index f9bb18081017795d05f0f452b0a4c8bce3d02ece..cece5e4f5ca228df9b6650bc72bb17a83f617e8d 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -25,7 +25,6 @@ #include "tsclient.h" typedef struct SInsertSupporter { - SSubqueryState* pState; SSqlObj* pSql; int32_t index; } SInsertSupporter; @@ -59,6 +58,8 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ pSubQueryInfo1->tsBuf = output1; pSubQueryInfo2->tsBuf = output2; + TSKEY st = taosGetTimestampUs(); + // no result generated, return directly if (pSupporter1->pTSBuf == NULL || pSupporter2->pTSBuf == NULL) { tscDebug("%p at least one ts-comp is empty, 0 for secondary query after ts blocks intersecting", pSql); @@ -95,7 +96,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ tscInfo("%" PRId64 ", tags:%"PRId64" \t %" PRId64 ", tags:%"PRId64, elem1.ts, elem1.tag.i64Key, elem2.ts, elem2.tag.i64Key); #endif - int32_t res = tVariantCompare(&elem1.tag, &elem2.tag); + int32_t res = tVariantCompare(elem1.tag, elem2.tag); if (res == -1 || (res == 0 && tsCompare(order, elem1.ts, elem2.ts))) { if (!tsBufNextPos(pSupporter1->pTSBuf)) { break; @@ -122,8 +123,9 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ win->ekey = elem1.ts; } - tsBufAppend(output1, elem1.vnode, &elem1.tag, (const char*)&elem1.ts, sizeof(elem1.ts)); - tsBufAppend(output2, elem2.vnode, &elem2.tag, (const char*)&elem2.ts, sizeof(elem2.ts)); + tsBufAppend(output1, elem1.vnode, elem1.tag, (const char*)&elem1.ts, sizeof(elem1.ts)); + tsBufAppend(output2, elem2.vnode, elem2.tag, (const char*)&elem2.ts, sizeof(elem2.ts)); + } else { pLimit->offset -= 1; } @@ -158,22 +160,22 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ tsBufDestroy(pSupporter1->pTSBuf); tsBufDestroy(pSupporter2->pTSBuf); - tscDebug("%p input1:%" PRId64 ", input2:%" PRId64 ", final:%" PRId64 " for secondary query after ts blocks " - "intersecting, skey:%" PRId64 ", ekey:%" PRId64, pSql, numOfInput1, numOfInput2, output1->numOfTotal, - win->skey, win->ekey); + TSKEY et = taosGetTimestampUs(); + tscDebug("%p input1:%" PRId64 ", input2:%" PRId64 ", final:%" PRId64 " in %d vnodes for secondary query after ts blocks " + "intersecting, skey:%" PRId64 ", ekey:%" PRId64 ", numOfVnode:%d, elasped time:%"PRId64" us", pSql, numOfInput1, numOfInput2, output1->numOfTotal, + output1->numOfVnodes, win->skey, win->ekey, tsBufGetNumOfVnodes(output1), et - st); return output1->numOfTotal; } // todo handle failed to create sub query -SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pState, int32_t index) { +SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) { SJoinSupporter* pSupporter = calloc(1, sizeof(SJoinSupporter)); if (pSupporter == NULL) { return NULL; } pSupporter->pObj = pSql; - pSupporter->pState = pState; pSupporter->subqueryIndex = index; SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex); @@ -249,7 +251,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { SJoinSupporter* pSupporter = NULL; //If the columns are not involved in the final select clause, the corresponding query will not be issued. - for (int32_t i = 0; i < pSql->numOfSubs; ++i) { + for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { pSupporter = pSql->pSubs[i]->param; if (taosArrayGetSize(pSupporter->exprList) > 0) { ++numOfSub; @@ -259,16 +261,15 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { assert(numOfSub > 0); // scan all subquery, if one sub query has only ts, ignore it - tscDebug("%p start to launch secondary subqueries, total:%d, only:%d needs to query", pSql, pSql->numOfSubs, numOfSub); + tscDebug("%p start to launch secondary subqueries, %d out of %d needs to query", pSql, numOfSub, pSql->subState.numOfSub); //the subqueries that do not actually launch the secondary query to virtual node is set as completed. - SSubqueryState* pState = pSupporter->pState; - pState->numOfTotal = pSql->numOfSubs; + SSubqueryState* pState = &pSql->subState; pState->numOfRemain = numOfSub; - + bool success = true; - for (int32_t i = 0; i < pSql->numOfSubs; ++i) { + for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { SSqlObj *pPrevSub = pSql->pSubs[i]; pSql->pSubs[i] = NULL; @@ -278,7 +279,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { tscDebug("%p subIndex: %d, no need to launch query, ignore it", pSql, i); tscDestroyJoinSupporter(pSupporter); - tscFreeSqlObj(pPrevSub); + taos_free_result(pPrevSub); pSql->pSubs[i] = NULL; continue; @@ -307,7 +308,6 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { // set the second stage sub query for join process TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE); - memcpy(&pQueryInfo->interval, &pSupporter->interval, sizeof(pQueryInfo->interval)); tscTagCondCopy(&pQueryInfo->tagCond, &pSupporter->tagCond); @@ -321,12 +321,13 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { memset(&pSupporter->fieldsInfo, 0, sizeof(SFieldInfo)); SQueryInfo *pNewQueryInfo = tscGetQueryInfoDetail(&pNew->cmd, 0); - assert(pNew->numOfSubs == 0 && pNew->cmd.numOfClause == 1 && pNewQueryInfo->numOfTables == 1); + assert(pNew->subState.numOfSub == 0 && pNew->cmd.numOfClause == 1 && pNewQueryInfo->numOfTables == 1); tscFieldInfoUpdateOffset(pNewQueryInfo); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pNewQueryInfo, 0); - + pTableMetaInfo->pVgroupTables = pSupporter->pVgroupTables; + /* * When handling the projection query, the offset value will be modified for table-table join, which is changed * during the timestamp intersection. @@ -362,6 +363,54 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { pExpr->numOfParams = 1; } + int32_t num = 0; + int32_t *list = NULL; + tsBufGetVnodeIdList(pNewQueryInfo->tsBuf, &num, &list); + + if (pTableMetaInfo->pVgroupTables != NULL) { + for(int32_t k = 0; k < taosArrayGetSize(pTableMetaInfo->pVgroupTables);) { + SVgroupTableInfo* p = taosArrayGet(pTableMetaInfo->pVgroupTables, k); + + bool found = false; + for(int32_t f = 0; f < num; ++f) { + if (p->vgInfo.vgId == list[f]) { + found = true; + break; + } + } + + if (!found) { + tscRemoveVgroupTableGroup(pTableMetaInfo->pVgroupTables, k); + } else { + k++; + } + } + + assert(taosArrayGetSize(pTableMetaInfo->pVgroupTables) > 0); + TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_MULTITABLE_QUERY); + } else { // TODO remove unnecessarily accessed vnode +// pTableMetaInfo->vgroupList-> +// for(int32_t k = 0; k < taosArrayGetSize(pTableMetaInfo->pVgroupTables);) { +// SVgroupTableInfo* p = taosArrayGet(pTableMetaInfo->pVgroupTables, k); +// +// bool found = false; +// for(int32_t f = 0; f < num; ++f) { +// if (p->vgInfo.vgId == list[f]) { +// found = true; +// break; +// } +// } +// +// if (!found) { +// tscRemoveVgroupTableGroup(pTableMetaInfo->pVgroupTables, k); +// } else { +// k++; +// } +// } + } + + taosTFree(list); + size_t numOfCols = taosArrayGetSize(pNewQueryInfo->colList); tscDebug("%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, name:%s", pSql, pNew, 0, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, taosArrayGetSize(pNewQueryInfo->exprList), @@ -372,13 +421,13 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { if (!success) { pSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY; tscError("%p failed to prepare subqueries objs for secondary phase query, numOfSub:%d, code:%d", pSql, - pSql->numOfSubs, pSql->res.code); + pSql->subState.numOfSub, pSql->res.code); freeJoinSubqueryObj(pSql); return pSql->res.code; } - for(int32_t i = 0; i < pSql->numOfSubs; ++i) { + for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) { if (pSql->pSubs[i] == NULL) { continue; } @@ -390,17 +439,13 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { } void freeJoinSubqueryObj(SSqlObj* pSql) { - SSubqueryState* pState = NULL; - - for (int32_t i = 0; i < pSql->numOfSubs; ++i) { + for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { SSqlObj* pSub = pSql->pSubs[i]; if (pSub == NULL) { continue; } SJoinSupporter* p = pSub->param; - pState = p->pState; - tscDestroyJoinSupporter(p); if (pSub->res.code == TSDB_CODE_SUCCESS) { @@ -408,14 +453,13 @@ void freeJoinSubqueryObj(SSqlObj* pSql) { } } - taosTFree(pState); - pSql->numOfSubs = 0; + pSql->subState.numOfSub = 0; } static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSupporter* pSupporter) { - assert(pSupporter->pState->numOfRemain > 0); + assert(pSqlObj->subState.numOfRemain > 0); - if (atomic_sub_fetch_32(&pSupporter->pState->numOfRemain, 1) <= 0) { + if (atomic_sub_fetch_32(&pSqlObj->subState.numOfRemain, 1) <= 0) { tscError("%p all subquery return and query failed, global code:%d", pSqlObj, pSqlObj->res.code); freeJoinSubqueryObj(pSqlObj); } @@ -425,6 +469,8 @@ static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSupporter* pSupporter) { static void updateQueryTimeRange(SQueryInfo* pQueryInfo, STimeWindow* win) { assert(pQueryInfo->window.skey <= win->skey && pQueryInfo->window.ekey >= win->ekey); pQueryInfo->window = *win; + + } int32_t tscCompareTidTags(const void* p1, const void* p2) { @@ -456,7 +502,7 @@ void tscBuildVgroupTableInfo(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo, SArr SVgroupTableInfo info = {{0}}; for (int32_t m = 0; m < pvg->numOfVgroups; ++m) { if (tt->vgId == pvg->vgroups[m].vgId) { - info.vgInfo = pvg->vgroups[m]; + tscSCMVgroupInfoCopy(&info.vgInfo, &pvg->vgroups[m]); break; } } @@ -481,10 +527,11 @@ static void issueTSCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj* SSqlCmd* pCmd = &pSql->cmd; tscClearSubqueryInfo(pCmd); tscFreeSqlResult(pSql); - + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); + assert(pQueryInfo->numOfTables == 1); + STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - tscInitQueryInfo(pQueryInfo); TSDB_QUERY_CLEAR_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY); @@ -531,13 +578,7 @@ static void issueTSCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj* tscProcessSql(pSql); } -static bool checkForDuplicateTagVal(SQueryInfo* pQueryInfo, SJoinSupporter* p1, SSqlObj* pPSqlObj) { - STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - - SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);// todo: tags mismatch, tags not completed - SColumn *pCol = taosArrayGetP(pTableMetaInfo->tagColList, 0); - SSchema *pColSchema = &pSchema[pCol->colIndex.columnIndex]; - +static bool checkForDuplicateTagVal(SSchema* pColSchema, SJoinSupporter* p1, SSqlObj* pPSqlObj) { for(int32_t i = 1; i < p1->num; ++i) { STidTags* prev = (STidTags*) varDataVal(p1->pIdTagList + (i - 1) * p1->tagSize); STidTags* p = (STidTags*) varDataVal(p1->pIdTagList + i * p1->tagSize); @@ -571,7 +612,7 @@ static int32_t getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pPar *s1 = taosArrayInit(p1->num, p1->tagSize - sizeof(int16_t)); *s2 = taosArrayInit(p2->num, p2->tagSize - sizeof(int16_t)); - if (!(checkForDuplicateTagVal(pQueryInfo, p1, pParentSql) && checkForDuplicateTagVal(pQueryInfo, p2, pParentSql))) { + if (!(checkForDuplicateTagVal(pColSchema, p1, pParentSql) && checkForDuplicateTagVal(pColSchema, p2, pParentSql))) { return TSDB_CODE_QRY_DUP_JOIN_KEY; } @@ -679,7 +720,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow // no data exists in next vnode, mark the query completed // only when there is no subquery exits any more, proceeds to get the intersect of the tuple sets. - if (atomic_sub_fetch_32(&pSupporter->pState->numOfRemain, 1) > 0) { + if (atomic_sub_fetch_32(&pParentSql->subState.numOfRemain, 1) > 0) { return; } @@ -715,10 +756,16 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow STableMetaInfo* pTableMetaInfo2 = tscGetMetaInfo(pQueryInfo2, 0); tscBuildVgroupTableInfo(pParentSql, pTableMetaInfo2, s2); - pSupporter->pState->numOfTotal = 2; - pSupporter->pState->numOfRemain = pSupporter->pState->numOfTotal; + SSqlObj* psub1 = pParentSql->pSubs[0]; + ((SJoinSupporter*)psub1->param)->pVgroupTables = tscCloneVgroupTableInfo(pTableMetaInfo1->pVgroupTables); + + SSqlObj* psub2 = pParentSql->pSubs[1]; + ((SJoinSupporter*)psub2->param)->pVgroupTables = tscCloneVgroupTableInfo(pTableMetaInfo2->pVgroupTables); - for (int32_t m = 0; m < pParentSql->numOfSubs; ++m) { + pParentSql->subState.numOfSub = 2; + pParentSql->subState.numOfRemain = pParentSql->subState.numOfSub; + + for (int32_t m = 0; m < pParentSql->subState.numOfSub; ++m) { SSqlObj* sub = pParentSql->pSubs[m]; issueTSCompQuery(sub, sub->param, pParentSql); } @@ -773,9 +820,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow pSupporter->pTSBuf = pBuf; } else { assert(pQueryInfo->numOfTables == 1); // for subquery, only one - STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - - tsBufMerge(pSupporter->pTSBuf, pBuf, pTableMetaInfo->vgroupIndex); + tsBufMerge(pSupporter->pTSBuf, pBuf); tsBufDestroy(pBuf); } @@ -817,7 +862,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow return; } - if (atomic_sub_fetch_32(&pSupporter->pState->numOfRemain, 1) > 0) { + if (atomic_sub_fetch_32(&pParentSql->subState.numOfRemain, 1) > 0) { return; } @@ -842,6 +887,8 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow // launch the query the retrieve actual results from vnode along with the filtered timestamp SQueryInfo* pPQueryInfo = tscGetQueryInfoDetail(&pParentSql->cmd, pParentSql->cmd.clauseIndex); updateQueryTimeRange(pPQueryInfo, &win); + + //update the vgroup that involved in real data query tscLaunchRealSubqueries(pParentSql); } @@ -849,7 +896,6 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR SJoinSupporter* pSupporter = (SJoinSupporter*)param; SSqlObj* pParentSql = pSupporter->pObj; - SSubqueryState* pState = pSupporter->pState; SSqlObj* pSql = (SSqlObj*)tres; SSqlCmd* pCmd = &pSql->cmd; @@ -870,29 +916,37 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR pRes->numOfTotal += pRes->numOfRows; } + SSubqueryState* pState = &pParentSql->subState; if (tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0) && numOfRows == 0) { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); assert(pQueryInfo->numOfTables == 1); // for projection query, need to try next vnode if current vnode is exhausted - if ((++pTableMetaInfo->vgroupIndex) < pTableMetaInfo->vgroupList->numOfVgroups) { - pState->numOfRemain = 1; - pState->numOfTotal = 1; + int32_t numOfVgroups = 0; // TODO refactor + if (pTableMetaInfo->pVgroupTables != NULL) { + numOfVgroups = taosArrayGetSize(pTableMetaInfo->pVgroupTables); + } else { + numOfVgroups = pTableMetaInfo->vgroupList->numOfVgroups; + } + if ((++pTableMetaInfo->vgroupIndex) < numOfVgroups) { + tscDebug("%p no result in current vnode anymore, try next vnode, vgIndex:%d", pSql, pTableMetaInfo->vgroupIndex); pSql->cmd.command = TSDB_SQL_SELECT; pSql->fp = tscJoinQueryCallback; - tscProcessSql(pSql); + tscProcessSql(pSql); return; + } else { + tscDebug("%p no result in current subquery anymore", pSql); } } if (atomic_sub_fetch_32(&pState->numOfRemain, 1) > 0) { - tscDebug("%p sub:%p completed, remain:%d, total:%d", pParentSql, tres, pState->numOfRemain, pState->numOfTotal); + tscDebug("%p sub:%p completed, remain:%d, total:%d", pParentSql, tres, pState->numOfRemain, pState->numOfSub); return; } - tscDebug("%p all %d secondary subqueries retrieval completed, code:%d", tres, pState->numOfTotal, pParentSql->res.code); + tscDebug("%p all %d secondary subqueries retrieval completed, code:%d", tres, pState->numOfSub, pParentSql->res.code); if (pParentSql->res.code != TSDB_CODE_SUCCESS) { freeJoinSubqueryObj(pParentSql); @@ -900,68 +954,62 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR } // update the records for each subquery in parent sql object. - for (int32_t i = 0; i < pParentSql->numOfSubs; ++i) { + for (int32_t i = 0; i < pState->numOfSub; ++i) { if (pParentSql->pSubs[i] == NULL) { + tscDebug("%p %p sub:%d not retrieve data", pParentSql, NULL, i); continue; } SSqlRes* pRes1 = &pParentSql->pSubs[i]->res; - pRes1->numOfClauseTotal += pRes1->numOfRows; - } - - // data has retrieved to client, build the join results - tscBuildResFromSubqueries(pParentSql); -} -static SJoinSupporter* tscUpdateSubqueryStatus(SSqlObj* pSql, int32_t numOfFetch) { - int32_t notInvolved = 0; - SJoinSupporter* pSupporter = NULL; - SSubqueryState* pState = NULL; - - for(int32_t i = 0; i < pSql->numOfSubs; ++i) { - if (pSql->pSubs[i] == NULL) { - notInvolved++; + if (pRes1->row > 0 && pRes1->numOfRows > 0) { + tscDebug("%p sub:%p index:%d numOfRows:%"PRId64" total:%"PRId64 " (not retrieve)", pParentSql, pParentSql->pSubs[i], i, + pRes1->numOfRows, pRes1->numOfTotal); + assert(pRes1->row < pRes1->numOfRows); } else { - pSupporter = (SJoinSupporter*)pSql->pSubs[i]->param; - pState = pSupporter->pState; + pRes1->numOfClauseTotal += pRes1->numOfRows; + tscDebug("%p sub:%p index:%d numOfRows:%"PRId64" total:%"PRId64, pParentSql, pParentSql->pSubs[i], i, + pRes1->numOfRows, pRes1->numOfTotal); } } - - assert(pState != NULL); - if (pState != NULL) { - pState->numOfTotal = pSql->numOfSubs; - pState->numOfRemain = numOfFetch; - } - - return pSupporter; + + // data has retrieved to client, build the join results + tscBuildResFromSubqueries(pParentSql); } void tscFetchDatablockFromSubquery(SSqlObj* pSql) { - assert(pSql->numOfSubs >= 1); + assert(pSql->subState.numOfSub >= 1); int32_t numOfFetch = 0; - bool hasData = true; - for (int32_t i = 0; i < pSql->numOfSubs; ++i) { - // if the subquery is NULL, it does not involved in the final result generation + bool hasData = true; + bool reachLimit = false; + + // if the subquery is NULL, it does not involved in the final result generation + for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { SSqlObj* pSub = pSql->pSubs[i]; if (pSub == NULL) { continue; } - + SSqlRes *pRes = &pSub->res; + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSub->cmd, 0); if (!tscHasReachLimitation(pQueryInfo, pRes)) { if (pRes->row >= pRes->numOfRows) { + // no data left in current result buffer hasData = false; + // The current query is completed for the active vnode, try next vnode if exists + // If it is completed, no need to fetch anymore. if (!pRes->completed) { numOfFetch++; } } } else { // has reach the limitation, no data anymore if (pRes->row >= pRes->numOfRows) { - hasData = false; + reachLimit = true; + hasData = false; break; } } @@ -971,10 +1019,67 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) { if (hasData) { tscBuildResFromSubqueries(pSql); return; - } else if (numOfFetch <= 0) { + } + + // If at least one subquery is completed in current vnode, try the next vnode in case of multi-vnode + // super table projection query. + if (numOfFetch <= 0 && !reachLimit) { + bool tryNextVnode = false; + + SSqlObj* pp = pSql->pSubs[0]; + SQueryInfo* pi = tscGetQueryInfoDetail(&pp->cmd, 0); + + // get the number of subquery that need to retrieve the next vnode. + if (tscNonOrderedProjectionQueryOnSTable(pi, 0)) { + for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) { + SSqlObj* pSub = pSql->pSubs[i]; + if (pSub != NULL && pSub->res.row >= pSub->res.numOfRows && pSub->res.completed) { + pSql->subState.numOfRemain++; + } + } + } + + for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { + SSqlObj* pSub = pSql->pSubs[i]; + if (pSub == NULL) { + continue; + } + + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSub->cmd, 0); + + if (tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0) && pSub->res.row >= pSub->res.numOfRows && pSub->res.completed) { + STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + assert(pQueryInfo->numOfTables == 1); + + // for projection query, need to try next vnode if current vnode is exhausted + int32_t numOfVgroups = 0; // TODO refactor + if (pTableMetaInfo->pVgroupTables != NULL) { + numOfVgroups = taosArrayGetSize(pTableMetaInfo->pVgroupTables); + } else { + numOfVgroups = pTableMetaInfo->vgroupList->numOfVgroups; + } + + if ((++pTableMetaInfo->vgroupIndex) < numOfVgroups) { + tscDebug("%p no result in current vnode anymore, try next vnode, vgIndex:%d", pSub, + pTableMetaInfo->vgroupIndex); + pSub->cmd.command = TSDB_SQL_SELECT; + pSub->fp = tscJoinQueryCallback; + + tscProcessSql(pSub); + tryNextVnode = true; + } else { + tscDebug("%p no result in current subquery anymore", pSub); + } + } + } + + if (tryNextVnode) { + return; + } + pSql->res.completed = true; freeJoinSubqueryObj(pSql); - + if (pSql->res.code == TSDB_CODE_SUCCESS) { (*pSql->fp)(pSql->param, pSql, 0); } else { @@ -985,15 +1090,17 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) { } // TODO multi-vnode retrieve for projection query with limitation has bugs, since the global limiation is not handled + // retrieve data from current vnode. tscDebug("%p retrieve data from %d subqueries", pSql, numOfFetch); - SJoinSupporter* pSupporter = tscUpdateSubqueryStatus(pSql, numOfFetch); - - for (int32_t i = 0; i < pSql->numOfSubs; ++i) { + SJoinSupporter* pSupporter = NULL; + pSql->subState.numOfRemain = numOfFetch; + + for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { SSqlObj* pSql1 = pSql->pSubs[i]; if (pSql1 == NULL) { continue; } - + SSqlRes* pRes1 = &pSql1->res; SSqlCmd* pCmd1 = &pSql1->cmd; @@ -1123,7 +1230,7 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) { } // wait for the other subqueries response from vnode - if (atomic_sub_fetch_32(&pSupporter->pState->numOfRemain, 1) > 0) { + if (atomic_sub_fetch_32(&pParentSql->subState.numOfRemain, 1) > 0) { return; } @@ -1135,7 +1242,7 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) { * data instead of returning to its invoker */ if (pTableMetaInfo->vgroupIndex > 0 && tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0)) { - pSupporter->pState->numOfRemain = pSupporter->pState->numOfTotal; // reset the record value +// pParentSql->subState.numOfRemain = pParentSql->subState.numOfSub; // reset the record value pSql->fp = joinRetrieveFinalResCallback; // continue retrieve data pSql->cmd.command = TSDB_SQL_FETCH; @@ -1155,7 +1262,6 @@ static void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code); static SSqlObj *tscCreateSTableSubquery(SSqlObj *pSql, SRetrieveSupport *trsupport, SSqlObj *prevSqlObj); -// TODO int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter *pSupporter) { SSqlCmd * pCmd = &pSql->cmd; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); @@ -1164,7 +1270,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter assert(pSql->res.numOfRows == 0); if (pSql->pSubs == NULL) { - pSql->pSubs = calloc(pSupporter->pState->numOfTotal, POINTER_BYTES); + pSql->pSubs = calloc(pSql->subState.numOfSub, POINTER_BYTES); if (pSql->pSubs == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } @@ -1175,8 +1281,8 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter return TSDB_CODE_TSC_OUT_OF_MEMORY; } - pSql->pSubs[pSql->numOfSubs++] = pNew; - assert(pSql->numOfSubs <= pSupporter->pState->numOfTotal); + pSql->pSubs[pSql->subState.numOfRemain++] = pNew; + assert(pSql->subState.numOfRemain <= pSql->subState.numOfSub); if (QUERY_IS_JOIN_QUERY(pQueryInfo->type)) { addGroupInfoForSubquery(pSql, pNew, 0, tableIndex); @@ -1220,7 +1326,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pNewQueryInfo, 0); if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { // return the tableId & tag - SColumnIndex index = {0}; + SColumnIndex colIndex = {0}; STagCond* pTagCond = &pSupporter->tagCond; assert(pTagCond->joinInfo.hasJoin); @@ -1233,7 +1339,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta); for(int32_t i = 0; i < numOfTags; ++i) { if (pSchema[i].colId == tagColId) { - index.columnIndex = i; + colIndex.columnIndex = i; break; } } @@ -1250,18 +1356,18 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter // set get tags query type TSDB_QUERY_SET_TYPE(pNewQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY); - tscAddSpecialColumnForSelect(pNewQueryInfo, 0, TSDB_FUNC_TID_TAG, &index, &s1, TSDB_COL_TAG); + tscAddSpecialColumnForSelect(pNewQueryInfo, 0, TSDB_FUNC_TID_TAG, &colIndex, &s1, TSDB_COL_TAG); size_t numOfCols = taosArrayGetSize(pNewQueryInfo->colList); tscDebug( "%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, transfer to tid_tag query to retrieve (tableId, tags), " "exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, tagIndex:%d, name:%s", pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo), - numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, index.columnIndex, pNewQueryInfo->pTableMetaInfo[0]->name); + numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, colIndex.columnIndex, pNewQueryInfo->pTableMetaInfo[0]->name); } else { SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = 1}; - SColumnIndex index = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX}; - tscAddSpecialColumnForSelect(pNewQueryInfo, 0, TSDB_FUNC_TS_COMP, &index, &colSchema, TSDB_COL_NORMAL); + SColumnIndex colIndex = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX}; + tscAddSpecialColumnForSelect(pNewQueryInfo, 0, TSDB_FUNC_TS_COMP, &colIndex, &colSchema, TSDB_COL_NORMAL); // set the tags value for ts_comp function SSqlExpr *pExpr = tscSqlExprGet(pNewQueryInfo, 0); @@ -1311,22 +1417,13 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) { assert((pQueryInfo->type & TSDB_QUERY_TYPE_SUBQUERY) == 0); int32_t code = TSDB_CODE_SUCCESS; - - // todo add test - SSubqueryState *pState = calloc(1, sizeof(SSubqueryState)); - if (pState == NULL) { - code = TSDB_CODE_TSC_OUT_OF_MEMORY; - goto _error; - } - - pState->numOfTotal = pQueryInfo->numOfTables; - pState->numOfRemain = pState->numOfTotal; + pSql->subState.numOfSub = pQueryInfo->numOfTables; bool hasEmptySub = false; tscDebug("%p start subquery, total:%d", pSql, pQueryInfo->numOfTables); for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) { - SJoinSupporter *pSupporter = tscCreateJoinSupporter(pSql, pState, i); + SJoinSupporter *pSupporter = tscCreateJoinSupporter(pSql, i); if (pSupporter == NULL) { // failed to create support struct, abort current query tscError("%p tableIndex:%d, failed to allocate join support object, abort further query", pSql, i); @@ -1353,10 +1450,10 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) { pSql->cmd.command = TSDB_SQL_RETRIEVE_EMPTY_RESULT; (*pSql->fp)(pSql->param, pSql, 0); } else { - for (int32_t i = 0; i < pSql->numOfSubs; ++i) { + for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { SSqlObj* pSub = pSql->pSubs[i]; if ((code = tscProcessSql(pSub)) != TSDB_CODE_SUCCESS) { - pState->numOfRemain = i - 1; // the already sent reques will continue and do not go to the error process routine + pSql->subState.numOfRemain = i - 1; // the already sent request will continue and do not go to the error process routine break; } } @@ -1371,8 +1468,8 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) { tscQueueAsyncRes(pSql); } -static void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs, SSubqueryState* pState) { - assert(numOfSubs <= pSql->numOfSubs && numOfSubs >= 0 && pState != NULL); +static void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs) { + assert(numOfSubs <= pSql->subState.numOfSub && numOfSubs >= 0); for(int32_t i = 0; i < numOfSubs; ++i) { SSqlObj* pSub = pSql->pSubs[i]; @@ -1383,10 +1480,8 @@ static void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs, SSubqueryState taosTFree(pSupport->localBuffer); taosTFree(pSupport); - tscFreeSqlObj(pSub); + taos_free_result(pSub); } - - free(pState); } int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { @@ -1409,9 +1504,16 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - - pSql->numOfSubs = pTableMetaInfo->vgroupList->numOfVgroups; - assert(pSql->numOfSubs > 0); + SSubqueryState *pState = &pSql->subState; + + pState->numOfSub = 0; + if (pTableMetaInfo->pVgroupTables == NULL) { + pState->numOfSub = pTableMetaInfo->vgroupList->numOfVgroups; + } else { + pState->numOfSub = taosArrayGetSize(pTableMetaInfo->pVgroupTables); + } + + assert(pState->numOfSub > 0); int32_t ret = tscLocalReducerEnvCreate(pSql, &pMemoryBuf, &pDesc, &pModel, nBufferSize); if (ret != 0) { @@ -1421,28 +1523,24 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { return ret; } - pSql->pSubs = calloc(pSql->numOfSubs, POINTER_BYTES); + pSql->pSubs = calloc(pState->numOfSub, POINTER_BYTES); - tscDebug("%p retrieved query data from %d vnode(s)", pSql, pSql->numOfSubs); - SSubqueryState *pState = calloc(1, sizeof(SSubqueryState)); + tscDebug("%p retrieved query data from %d vnode(s)", pSql, pState->numOfSub); - if (pSql->pSubs == NULL || pState == NULL) { - taosTFree(pState); + if (pSql->pSubs == NULL) { taosTFree(pSql->pSubs); pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; - tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pModel, pSql->numOfSubs); + tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pModel, pState->numOfSub); tscQueueAsyncRes(pSql); return ret; } - pState->numOfTotal = pSql->numOfSubs; - pState->numOfRemain = pSql->numOfSubs; - + pState->numOfRemain = pState->numOfSub; pRes->code = TSDB_CODE_SUCCESS; int32_t i = 0; - for (; i < pSql->numOfSubs; ++i) { + for (; i < pState->numOfSub; ++i) { SRetrieveSupport *trs = (SRetrieveSupport *)calloc(1, sizeof(SRetrieveSupport)); if (trs == NULL) { tscError("%p failed to malloc buffer for SRetrieveSupport, orderOfSub:%d, reason:%s", pSql, i, strerror(errno)); @@ -1451,8 +1549,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { trs->pExtMemBuffer = pMemoryBuf; trs->pOrderDescriptor = pDesc; - trs->pState = pState; - + trs->localBuffer = (tFilePage *)calloc(1, nBufferSize + sizeof(tFilePage)); if (trs->localBuffer == NULL) { tscError("%p failed to malloc buffer for local buffer, orderOfSub:%d, reason:%s", pSql, i, strerror(errno)); @@ -1460,8 +1557,8 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { break; } - trs->subqueryIndex = i; - trs->pParentSql = pSql; + trs->subqueryIndex = i; + trs->pParentSql = pSql; trs->pFinalColModel = pModel; SSqlObj *pNew = tscCreateSTableSubquery(pSql, trs, NULL); @@ -1482,42 +1579,46 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { tscDebug("%p sub:%p create subquery success. orderOfSub:%d", pSql, pNew, trs->subqueryIndex); } - if (i < pSql->numOfSubs) { + if (i < pState->numOfSub) { tscError("%p failed to prepare subquery structure and launch subqueries", pSql); pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; - tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pModel, pSql->numOfSubs); - doCleanupSubqueries(pSql, i, pState); + tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pModel, pState->numOfSub); + doCleanupSubqueries(pSql, i); return pRes->code; // free all allocated resource } if (pRes->code == TSDB_CODE_TSC_QUERY_CANCELLED) { - tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pModel, pSql->numOfSubs); - doCleanupSubqueries(pSql, i, pState); + tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pModel, pState->numOfSub); + doCleanupSubqueries(pSql, i); return pRes->code; } - for(int32_t j = 0; j < pSql->numOfSubs; ++j) { + for(int32_t j = 0; j < pState->numOfSub; ++j) { SSqlObj* pSub = pSql->pSubs[j]; SRetrieveSupport* pSupport = pSub->param; tscDebug("%p sub:%p launch subquery, orderOfSub:%d.", pSql, pSub, pSupport->subqueryIndex); tscProcessSql(pSub); } - + return TSDB_CODE_SUCCESS; } -static void tscFreeSubSqlObj(SRetrieveSupport *trsupport, SSqlObj *pSql) { - tscDebug("%p start to free subquery obj", pSql); +static void tscFreeRetrieveSup(SSqlObj *pSql) { + SRetrieveSupport *trsupport = pSql->param; - int32_t index = trsupport->subqueryIndex; - SSqlObj *pParentSql = trsupport->pParentSql; + void* p = atomic_val_compare_exchange_ptr(&pSql->param, trsupport, 0); + if (p == NULL) { + tscDebug("%p retrieve supp already released", pSql); + return; + } - assert(pSql == pParentSql->pSubs[index]); -// pParentSql->pSubs[index] = NULL; -// -// taos_free_result(pSql); + tscDebug("%p start to free subquery supp obj:%p", pSql, trsupport); +// int32_t index = trsupport->subqueryIndex; +// SSqlObj *pParentSql = trsupport->pParentSql; + +// assert(pSql == pParentSql->pSubs[index]); taosTFree(trsupport->localBuffer); taosTFree(trsupport); } @@ -1576,13 +1677,19 @@ static int32_t tscReissueSubquery(SRetrieveSupport *trsupport, SSqlObj *pSql, in } void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numOfRows) { + // it has been freed already + if (pSql->param != trsupport || pSql->param == NULL) { + return; + } + SSqlObj *pParentSql = trsupport->pParentSql; int32_t subqueryIndex = trsupport->subqueryIndex; assert(pSql != NULL); - SSubqueryState* pState = trsupport->pState; - assert(pState->numOfRemain <= pState->numOfTotal && pState->numOfRemain >= 0 && pParentSql->numOfSubs == pState->numOfTotal); - + + SSubqueryState* pState = &pParentSql->subState; + assert(pState->numOfRemain <= pState->numOfSub && pState->numOfRemain >= 0); + // retrieved in subquery failed. OR query cancelled in retrieve phase. if (taos_errno(pSql) == TSDB_CODE_SUCCESS && pParentSql->res.code != TSDB_CODE_SUCCESS) { @@ -1615,22 +1722,21 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO int32_t remain = -1; if ((remain = atomic_sub_fetch_32(&pState->numOfRemain, 1)) > 0) { tscDebug("%p sub:%p orderOfSub:%d freed, finished subqueries:%d", pParentSql, pSql, trsupport->subqueryIndex, - pState->numOfTotal - remain); + pState->numOfSub - remain); - tscFreeSubSqlObj(trsupport, pSql); + tscFreeRetrieveSup(pSql); return; } // all subqueries are failed - tscError("%p retrieve from %d vnode(s) completed,code:%s.FAILED.", pParentSql, pState->numOfTotal, + tscError("%p retrieve from %d vnode(s) completed,code:%s.FAILED.", pParentSql, pState->numOfSub, tstrerror(pParentSql->res.code)); // release allocated resource tscLocalReducerEnvDestroy(trsupport->pExtMemBuffer, trsupport->pOrderDescriptor, trsupport->pFinalColModel, - pState->numOfTotal); + pState->numOfSub); - taosTFree(trsupport->pState); - tscFreeSubSqlObj(trsupport, pSql); + tscFreeRetrieveSup(pSql); // in case of second stage join subquery, invoke its callback function instead of regular QueueAsyncRes SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pParentSql->cmd, 0); @@ -1649,16 +1755,16 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p SSqlObj * pParentSql = trsupport->pParentSql; tOrderDescriptor *pDesc = trsupport->pOrderDescriptor; - SSubqueryState* pState = trsupport->pState; + SSubqueryState* pState = &pParentSql->subState; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); STableMetaInfo* pTableMetaInfo = pQueryInfo->pTableMetaInfo[0]; // data in from current vnode is stored in cache and disk uint32_t numOfRowsFromSubquery = (uint32_t)(trsupport->pExtMemBuffer[idx]->numOfTotalElems + trsupport->localBuffer->num); - tscDebug("%p sub:%p all data retrieved from ep:%s, vgId:%d, numOfRows:%d, orderOfSub:%d", pParentSql, pSql, - pTableMetaInfo->vgroupList->vgroups[0].epAddr[0].fqdn, pTableMetaInfo->vgroupList->vgroups[0].vgId, - numOfRowsFromSubquery, idx); + SVgroupsInfo* vgroupsInfo = pTableMetaInfo->vgroupList; + tscDebug("%p sub:%p all data retrieved from ep:%s, vgId:%d, numOfRows:%d, orderOfSub:%d", pParentSql, pSql, + vgroupsInfo->vgroups[0].epAddr[0].fqdn, vgroupsInfo->vgroups[0].vgId, numOfRowsFromSubquery, idx); tColModelCompact(pDesc->pColumnModel, trsupport->localBuffer, pDesc->pColumnModel->capacity); @@ -1686,11 +1792,11 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p } int32_t remain = -1; - if ((remain = atomic_sub_fetch_32(&pState->numOfRemain, 1)) > 0) { + if ((remain = atomic_sub_fetch_32(&pParentSql->subState.numOfRemain, 1)) > 0) { tscDebug("%p sub:%p orderOfSub:%d freed, finished subqueries:%d", pParentSql, pSql, trsupport->subqueryIndex, - pState->numOfTotal - remain); + pState->numOfSub - remain); - tscFreeSubSqlObj(trsupport, pSql); + tscFreeRetrieveSup(pSql); return; } @@ -1698,21 +1804,19 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p pDesc->pColumnModel->capacity = trsupport->pExtMemBuffer[idx]->numOfElemsPerPage; tscDebug("%p retrieve from %d vnodes completed.final NumOfRows:%" PRId64 ",start to build loser tree", pParentSql, - pState->numOfTotal, pState->numOfRetrievedRows); + pState->numOfSub, pState->numOfRetrievedRows); SQueryInfo *pPQueryInfo = tscGetQueryInfoDetail(&pParentSql->cmd, 0); tscClearInterpInfo(pPQueryInfo); - tscCreateLocalReducer(trsupport->pExtMemBuffer, pState->numOfTotal, pDesc, trsupport->pFinalColModel, pParentSql); + tscCreateLocalReducer(trsupport->pExtMemBuffer, pState->numOfSub, pDesc, trsupport->pFinalColModel, pParentSql); tscDebug("%p build loser tree completed", pParentSql); pParentSql->res.precision = pSql->res.precision; pParentSql->res.numOfRows = 0; pParentSql->res.row = 0; - // only free once - taosTFree(trsupport->pState); - tscFreeSubSqlObj(trsupport, pSql); + tscFreeRetrieveSup(pSql); // set the command flag must be after the semaphore been correctly set. pParentSql->cmd.command = TSDB_SQL_RETRIEVE_LOCALMERGE; @@ -1724,16 +1828,23 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p } static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfRows) { + SSqlObj *pSql = (SSqlObj *)tres; + assert(pSql != NULL); + + // this query has been freed already SRetrieveSupport *trsupport = (SRetrieveSupport *)param; + if (pSql->param == NULL || param == NULL) { + tscDebug("%p already freed in dnodecallback", pSql); + assert(pSql->res.code == TSDB_CODE_TSC_QUERY_CANCELLED); + return; + } + tOrderDescriptor *pDesc = trsupport->pOrderDescriptor; int32_t idx = trsupport->subqueryIndex; SSqlObj * pParentSql = trsupport->pParentSql; - assert(tres != NULL); - SSqlObj *pSql = (SSqlObj *)tres; - - SSubqueryState* pState = trsupport->pState; - assert(pState->numOfRemain <= pState->numOfTotal && pState->numOfRemain >= 0 && pParentSql->numOfSubs == pState->numOfTotal); + SSubqueryState* pState = &pParentSql->subState; + assert(pState->numOfRemain <= pState->numOfSub && pState->numOfRemain >= 0); STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0); SCMVgroupInfo *pVgroup = &pTableMetaInfo->vgroupList->vgroups[0]; @@ -1750,6 +1861,10 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR if (taos_errno(pSql) != TSDB_CODE_SUCCESS) { assert(numOfRows == taos_errno(pSql)); + if (numOfRows == TSDB_CODE_TSC_QUERY_CANCELLED) { + trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY; + } + if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY) { tscError("%p sub:%p failed code:%s, retry:%d", pParentSql, pSql, tstrerror(numOfRows), trsupport->numOfRetry); @@ -1821,7 +1936,7 @@ static SSqlObj *tscCreateSTableSubquery(SSqlObj *pSql, SRetrieveSupport *trsuppo SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pNew->cmd, 0); pQueryInfo->type |= TSDB_QUERY_TYPE_STABLE_SUBQUERY; - assert(pQueryInfo->numOfTables == 1 && pNew->cmd.numOfClause == 1 && trsupport->subqueryIndex < pSql->numOfSubs); + assert(pQueryInfo->numOfTables == 1 && pNew->cmd.numOfClause == 1 && trsupport->subqueryIndex < pSql->subState.numOfSub); // launch subquery for each vnode, so the subquery index equals to the vgroupIndex. STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, table_index); @@ -1892,7 +2007,6 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) { static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows) { SInsertSupporter *pSupporter = (SInsertSupporter *)param; SSqlObj* pParentObj = pSupporter->pSql; - SSubqueryState* pState = pSupporter->pState; // record the total inserted rows if (numOfRows > 0) { @@ -1907,15 +2021,13 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows) } taosTFree(pSupporter); - if (atomic_sub_fetch_32(&pState->numOfRemain, 1) > 0) { + + if (atomic_sub_fetch_32(&pParentObj->subState.numOfRemain, 1) > 0) { return; } tscDebug("%p Async insertion completed, total inserted:%" PRId64, pParentObj, pParentObj->res.numOfRows); - // release data block data - taosTFree(pState); - // restore user defined fp pParentObj->fp = pParentObj->fetchFp; @@ -1936,7 +2048,7 @@ int32_t tscHandleInsertRetry(SSqlObj* pSql) { SSqlRes* pRes = &pSql->res; SInsertSupporter* pSupporter = (SInsertSupporter*) pSql->param; - assert(pSupporter->index < pSupporter->pState->numOfTotal); + assert(pSupporter->index < pSupporter->pSql->subState.numOfSub); STableDataBlocks* pTableDataBlock = taosArrayGetP(pCmd->pDataBlocks, pSupporter->index); int32_t code = tscCopyDataBlockToPayload(pSql, pTableDataBlock); @@ -1953,33 +2065,29 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; - pSql->numOfSubs = (uint16_t)taosArrayGetSize(pCmd->pDataBlocks); - assert(pSql->numOfSubs > 0); + pSql->subState.numOfSub = (uint16_t)taosArrayGetSize(pCmd->pDataBlocks); + assert(pSql->subState.numOfSub > 0); pRes->code = TSDB_CODE_SUCCESS; // the number of already initialized subqueries int32_t numOfSub = 0; - SSubqueryState *pState = calloc(1, sizeof(SSubqueryState)); - pState->numOfTotal = pSql->numOfSubs; - pState->numOfRemain = pSql->numOfSubs; - - pSql->pSubs = calloc(pSql->numOfSubs, POINTER_BYTES); + pSql->subState.numOfRemain = pSql->subState.numOfSub; + pSql->pSubs = calloc(pSql->subState.numOfSub, POINTER_BYTES); if (pSql->pSubs == NULL) { goto _error; } - tscDebug("%p submit data to %d vnode(s)", pSql, pSql->numOfSubs); + tscDebug("%p submit data to %d vnode(s)", pSql, pSql->subState.numOfSub); - while(numOfSub < pSql->numOfSubs) { + while(numOfSub < pSql->subState.numOfSub) { SInsertSupporter* pSupporter = calloc(1, sizeof(SInsertSupporter)); if (pSupporter == NULL) { goto _error; } pSupporter->pSql = pSql; - pSupporter->pState = pState; pSupporter->index = numOfSub; SSqlObj *pNew = createSimpleSubObj(pSql, multiVnodeInsertFinalize, pSupporter, TSDB_SQL_INSERT); @@ -2002,12 +2110,12 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { numOfSub++; } else { tscDebug("%p prepare submit data block failed in async insertion, vnodeIdx:%d, total:%d, code:%s", pSql, numOfSub, - pSql->numOfSubs, tstrerror(pRes->code)); + pSql->subState.numOfSub, tstrerror(pRes->code)); goto _error; } } - if (numOfSub < pSql->numOfSubs) { + if (numOfSub < pSql->subState.numOfSub) { tscError("%p failed to prepare subObj structure and launch sub-insertion", pSql); pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; goto _error; @@ -2025,18 +2133,17 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { return TSDB_CODE_SUCCESS; _error: - taosTFree(pState); return TSDB_CODE_TSC_OUT_OF_MEMORY; } static char* getResultBlockPosition(SSqlCmd* pCmd, SSqlRes* pRes, int32_t columnIndex, int16_t* bytes) { SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); - SFieldSupInfo* pInfo = (SFieldSupInfo*) TARRAY_GET_ELEM(pQueryInfo->fieldsInfo.pSupportInfo, columnIndex); + SInternalField* pInfo = (SInternalField*) TARRAY_GET_ELEM(pQueryInfo->fieldsInfo.internalField, columnIndex); assert(pInfo->pSqlExpr != NULL); *bytes = pInfo->pSqlExpr->resBytes; - char* pData = pRes->data + pInfo->pSqlExpr->offset * pRes->numOfRows; + char* pData = pRes->data + pInfo->pSqlExpr->offset * pRes->numOfRows + pRes->row * (*bytes); return pData; } @@ -2047,12 +2154,14 @@ static void doBuildResFromSubqueries(SSqlObj* pSql) { SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex); int32_t numOfRes = INT32_MAX; - for (int32_t i = 0; i < pSql->numOfSubs; ++i) { - if (pSql->pSubs[i] == NULL) { + for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { + SSqlObj* pSub = pSql->pSubs[i]; + if (pSub == NULL) { continue; } - numOfRes = (int32_t)(MIN(numOfRes, pSql->pSubs[i]->res.numOfRows)); + int32_t remain = pSub->res.numOfRows - pSub->res.row; + numOfRes = (int32_t)(MIN(numOfRes, remain)); } if (numOfRes == 0) { @@ -2078,14 +2187,23 @@ static void doBuildResFromSubqueries(SSqlObj* pSql) { size_t numOfExprs = tscSqlExprNumOfExprs(pQueryInfo); for(int32_t i = 0; i < numOfExprs; ++i) { SColumnIndex* pIndex = &pRes->pColumnIndex[i]; - SSqlRes *pRes1 = &pSql->pSubs[pIndex->tableIndex]->res; - SSqlCmd *pCmd1 = &pSql->pSubs[pIndex->tableIndex]->cmd; + SSqlRes* pRes1 = &pSql->pSubs[pIndex->tableIndex]->res; + SSqlCmd* pCmd1 = &pSql->pSubs[pIndex->tableIndex]->cmd; char* pData = getResultBlockPosition(pCmd1, pRes1, pIndex->columnIndex, &bytes); memcpy(data, pData, bytes * numOfRes); data += bytes * numOfRes; - pRes1->row = numOfRes; + } + + for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) { + SSqlObj* pSub = pSql->pSubs[i]; + if (pSub == NULL) { + continue; + } + + pSub->res.row += numOfRes; + assert(pSub->res.row <= pSub->res.numOfRows); } pRes->numOfRows = numOfRes; @@ -2104,6 +2222,8 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) { SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex); size_t numOfExprs = tscSqlExprNumOfExprs(pQueryInfo); + pRes->numOfCols = numOfExprs; + pRes->tsrow = calloc(numOfExprs, POINTER_BYTES); pRes->buffer = calloc(numOfExprs, POINTER_BYTES); pRes->length = calloc(numOfExprs, sizeof(int32_t)); @@ -2140,7 +2260,7 @@ static void transferNcharData(SSqlObj *pSql, int32_t columnIndex, TAOS_FIELD *pF int32_t length = taosUcs4ToMbs(pRes->tsrow[columnIndex], pRes->length[columnIndex], pRes->buffer[columnIndex]); if ( length >= 0 ) { - pRes->tsrow[columnIndex] = pRes->buffer[columnIndex]; + pRes->tsrow[columnIndex] = (unsigned char*)pRes->buffer[columnIndex]; pRes->length[columnIndex] = length; } else { tscError("%p charset:%s to %s. val:%s convert failed.", pSql, DEFAULT_UNICODE_ENCODEC, tsCharset, (char*)pRes->tsrow[columnIndex]); @@ -2168,7 +2288,7 @@ static char *getArithemicInputSrc(void *param, const char *name, int32_t colId) return pSupport->data[index] + pSupport->offset * pExpr->resBytes; } -void **doSetResultRowData(SSqlObj *pSql, bool finalResult) { +TAOS_ROW doSetResultRowData(SSqlObj *pSql, bool finalResult) { SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; @@ -2182,7 +2302,7 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) { size_t size = tscNumOfFields(pQueryInfo); for (int i = 0; i < size; ++i) { - SFieldSupInfo* pSup = TARRAY_GET_ELEM(pQueryInfo->fieldsInfo.pSupportInfo, i); + SInternalField* pSup = TARRAY_GET_ELEM(pQueryInfo->fieldsInfo.internalField, i); if (pSup->pSqlExpr != NULL) { tscGetResultColumnChr(pRes, &pQueryInfo->fieldsInfo, i); } @@ -2192,7 +2312,7 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) { continue; } - TAOS_FIELD *pField = TARRAY_GET_ELEM(pQueryInfo->fieldsInfo.pFields, i); + TAOS_FIELD *pField = TARRAY_GET_ELEM(pQueryInfo->fieldsInfo.internalField, i); if (pRes->tsrow[i] != NULL && pField->type == TSDB_DATA_TYPE_NCHAR) { transferNcharData(pSql, i, pField); } @@ -2221,7 +2341,7 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) { tExprTreeCalcTraverse(pRes->pArithSup->pArithExpr->pExpr, 1, pRes->buffer[i], pRes->pArithSup, TSDB_ORDER_ASC, getArithemicInputSrc); - pRes->tsrow[i] = pRes->buffer[i]; + pRes->tsrow[i] = (unsigned char*)pRes->buffer[i]; } } @@ -2237,7 +2357,7 @@ static UNUSED_FUNC bool tscHasRemainDataInSubqueryResultSet(SSqlObj *pSql) { if (tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0)) { bool allSubqueryExhausted = true; - for (int32_t i = 0; i < pSql->numOfSubs; ++i) { + for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { if (pSql->pSubs[i] == NULL) { continue; } @@ -2263,7 +2383,7 @@ static UNUSED_FUNC bool tscHasRemainDataInSubqueryResultSet(SSqlObj *pSql) { hasData = !allSubqueryExhausted; } else { // otherwise, in case inner join, if any subquery exhausted, query completed. - for (int32_t i = 0; i < pSql->numOfSubs; ++i) { + for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { if (pSql->pSubs[i] == 0) { continue; } diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index 82ce1d36791e2a5e79177ea1405bf90145f2776d..47c2d35a75cba4787e00c645e2f242ae24788df7 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -77,6 +77,7 @@ int32_t tscInitRpc(const char *user, const char *secretEncrypt, void **pDnodeCon return 0; } + void taos_init_imp(void) { char temp[128]; @@ -122,14 +123,12 @@ void taos_init_imp(void) { tscInitMsgsFp(); int queueSize = tsMaxConnections*2; - if (tscEmbedded == 0) { - tscNumOfThreads = (int)(tsNumOfCores * tsNumOfThreadsPerCore / 2.0); - } else { - tscNumOfThreads = (int)(tsNumOfCores * tsNumOfThreadsPerCore / 4.0); + double factor = (tscEmbedded == 0)? 2.0:4.0; + tscNumOfThreads = (int)(tsNumOfCores * tsNumOfThreadsPerCore / factor); + if (tscNumOfThreads < 2) { + tscNumOfThreads = 2; } - if (tscNumOfThreads < 2) tscNumOfThreads = 2; - tscQhandle = taosInitScheduler(queueSize, tscNumOfThreads, "tsc"); if (NULL == tscQhandle) { tscError("failed to init scheduler"); @@ -140,14 +139,11 @@ void taos_init_imp(void) { if(0 == tscEmbedded){ taosTmrReset(tscCheckDiskUsage, 10, NULL, tscTmr, &tscCheckDiskUsageTmr); } - - int64_t refreshTime = tsTableMetaKeepTimer; - refreshTime = refreshTime > 10 ? 10 : refreshTime; - refreshTime = refreshTime < 10 ? 10 : refreshTime; + int64_t refreshTime = 10; // 10 seconds by default if (tscMetaCache == NULL) { - tscMetaCache = taosCacheInit(TSDB_DATA_TYPE_BINARY, refreshTime, false, NULL, "tableMeta"); - tscObjCache = taosCacheInit(TSDB_DATA_TYPE_BIGINT, refreshTime/2, false, tscFreeSqlObjInCache, "sqlObj"); + tscMetaCache = taosCacheInit(TSDB_DATA_TYPE_BINARY, refreshTime, false, tscFreeTableMetaHelper, "tableMeta"); + tscObjCache = taosCacheInit(TSDB_CACHE_PTR_KEY, refreshTime / 2, false, tscFreeRegisteredSqlObj, "sqlObj"); } tscDebug("client is initialized successfully"); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 38fb63f18ed6e5342006247264c3566697e02b8b..f99adfffeaf29353d2f5623c3d5648766d00c05e 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -114,9 +114,9 @@ bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) { } // for select query super table, the super table vgroup list can not be null in any cases. - if (pQueryInfo->command == TSDB_SQL_SELECT && UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { - assert(pTableMetaInfo->vgroupList != NULL); - } + // if (pQueryInfo->command == TSDB_SQL_SELECT && UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { + // assert(pTableMetaInfo->vgroupList != NULL); + // } if ((pQueryInfo->type & TSDB_QUERY_TYPE_FREE_RESOURCE) == TSDB_QUERY_TYPE_FREE_RESOURCE) { return false; @@ -360,26 +360,26 @@ void tscPartiallyFreeSqlObj(SSqlObj* pSql) { tscFreeSqlResult(pSql); taosTFree(pSql->pSubs); - pSql->numOfSubs = 0; + pSql->subState.numOfSub = 0; pSql->self = 0; tscResetSqlCmdObj(pCmd, false); } -static UNUSED_FUNC void tscFreeSubobj(SSqlObj* pSql) { - if (pSql->numOfSubs == 0) { +static void tscFreeSubobj(SSqlObj* pSql) { + if (pSql->subState.numOfSub == 0) { return; } - tscDebug("%p start to free sub SqlObj, numOfSub:%d", pSql, pSql->numOfSubs); + tscDebug("%p start to free sub SqlObj, numOfSub:%d", pSql, pSql->subState.numOfSub); - for(int32_t i = 0; i < pSql->numOfSubs; ++i) { + for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) { tscDebug("%p free sub SqlObj:%p, index:%d", pSql, pSql->pSubs[i], i); taos_free_result(pSql->pSubs[i]); pSql->pSubs[i] = NULL; } - pSql->numOfSubs = 0; + pSql->subState.numOfSub = 0; } /** @@ -389,12 +389,41 @@ static UNUSED_FUNC void tscFreeSubobj(SSqlObj* pSql) { * * @param pSql */ -void tscFreeSqlObjInCache(void *pSql) { +void tscFreeRegisteredSqlObj(void *pSql) { assert(pSql != NULL); + SSqlObj** p = (SSqlObj**)pSql; + STscObj* pTscObj = (*p)->pTscObj; assert((*p)->self != 0 && (*p)->self == (p)); tscFreeSqlObj(*p); + + int32_t ref = T_REF_DEC(pTscObj); + assert(ref >= 0); + + tscDebug("%p free sqlObj completed, tscObj:%p ref:%d", *p, pTscObj, ref); + if (ref == 0) { + tscDebug("%p all sqlObj freed, free tscObj:%p", *p, pTscObj); + tscCloseTscObj(pTscObj); + } +} + +void tscFreeTableMetaHelper(void *pTableMeta) { + STableMeta* p = (STableMeta*) pTableMeta; + + int32_t numOfEps = p->vgroupInfo.numOfEps; + assert(numOfEps >= 0 && numOfEps <= TSDB_MAX_REPLICA); + + for(int32_t i = 0; i < numOfEps; ++i) { + taosTFree(p->vgroupInfo.epAddr[i].fqdn); + } + + int32_t numOfEps1 = p->corVgroupInfo.numOfEps; + assert(numOfEps1 >= 0 && numOfEps1 <= TSDB_MAX_REPLICA); + + for(int32_t i = 0; i < numOfEps1; ++i) { + taosTFree(p->corVgroupInfo.epAddr[i].fqdn); + } } void tscFreeSqlObj(SSqlObj* pSql) { @@ -403,9 +432,10 @@ void tscFreeSqlObj(SSqlObj* pSql) { } tscDebug("%p start to free sqlObj", pSql); - STscObj* pTscObj = pSql->pTscObj; + pSql->res.code = TSDB_CODE_TSC_QUERY_CANCELLED; tscFreeSubobj(pSql); + tscPartiallyFreeSqlObj(pSql); pSql->signature = NULL; @@ -421,14 +451,6 @@ void tscFreeSqlObj(SSqlObj* pSql) { tsem_destroy(&pSql->rspSem); free(pSql); - tscDebug("%p free sqlObj completed", pSql); - - int32_t ref = T_REF_DEC(pTscObj); - assert(ref >= 0); - - if (ref == 0) { - tscCloseTscObj(pTscObj); - } } void tscDestroyDataBlock(STableDataBlocks* pDataBlock) { @@ -682,16 +704,14 @@ static int32_t getRowExpandSize(STableMeta* pTableMeta) { int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SArray* pTableDataBlockList) { SSqlCmd* pCmd = &pSql->cmd; - // the maximum expanded size in byte when a row-wise data is converted to SDataRow format - STableDataBlocks* pOneTableBlock = taosArrayGetP(pTableDataBlockList, 0); - int32_t expandSize = getRowExpandSize(pOneTableBlock->pTableMeta); - void* pVnodeDataBlockHashList = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false); SArray* pVnodeDataBlockList = taosArrayInit(8, POINTER_BYTES); size_t total = taosArrayGetSize(pTableDataBlockList); for (int32_t i = 0; i < total; ++i) { - pOneTableBlock = taosArrayGetP(pTableDataBlockList, i); + // the maximum expanded size in byte when a row-wise data is converted to SDataRow format + STableDataBlocks* pOneTableBlock = taosArrayGetP(pTableDataBlockList, i); + int32_t expandSize = getRowExpandSize(pOneTableBlock->pTableMeta); STableDataBlocks* dataBuf = NULL; int32_t ret = @@ -825,35 +845,30 @@ TAOS_FIELD tscCreateField(int8_t type, const char* name, int16_t bytes) { return f; } -SFieldSupInfo* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField) { +SInternalField* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField) { assert(pFieldInfo != NULL); - taosArrayPush(pFieldInfo->pFields, pField); pFieldInfo->numOfOutput++; - struct SFieldSupInfo info = { + struct SInternalField info = { .pSqlExpr = NULL, .pArithExprInfo = NULL, .visible = true, }; - - return taosArrayPush(pFieldInfo->pSupportInfo, &info); -} -SFieldSupInfo* tscFieldInfoGetSupp(SFieldInfo* pFieldInfo, int32_t index) { - return TARRAY_GET_ELEM(pFieldInfo->pSupportInfo, index); + info.field = *pField; + return taosArrayPush(pFieldInfo->internalField, &info); } -SFieldSupInfo* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* field) { - taosArrayInsert(pFieldInfo->pFields, index, field); +SInternalField* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* field) { pFieldInfo->numOfOutput++; - - struct SFieldSupInfo info = { + struct SInternalField info = { .pSqlExpr = NULL, .pArithExprInfo = NULL, .visible = true, }; - - return taosArrayInsert(pFieldInfo->pSupportInfo, index, &info); + + info.field = *field; + return taosArrayInsert(pFieldInfo->internalField, index, &info); } void tscFieldInfoUpdateOffset(SQueryInfo* pQueryInfo) { @@ -887,29 +902,18 @@ void tscFieldInfoUpdateOffsetForInterResult(SQueryInfo* pQueryInfo) { } } -void tscFieldInfoCopy(SFieldInfo* dst, const SFieldInfo* src) { - dst->numOfOutput = src->numOfOutput; - - if (dst->pFields == NULL) { - dst->pFields = taosArrayClone(src->pFields); - } else { - taosArrayCopy(dst->pFields, src->pFields); - } - - if (dst->pSupportInfo == NULL) { - dst->pSupportInfo = taosArrayClone(src->pSupportInfo); - } else { - taosArrayCopy(dst->pSupportInfo, src->pSupportInfo); - } +SInternalField* tscFieldInfoGetInternalField(SFieldInfo* pFieldInfo, int32_t index) { + assert(index < pFieldInfo->numOfOutput); + return TARRAY_GET_ELEM(pFieldInfo->internalField, index); } TAOS_FIELD* tscFieldInfoGetField(SFieldInfo* pFieldInfo, int32_t index) { assert(index < pFieldInfo->numOfOutput); - return TARRAY_GET_ELEM(pFieldInfo->pFields, index); + return &((SInternalField*)TARRAY_GET_ELEM(pFieldInfo->internalField, index))->field; } int16_t tscFieldInfoGetOffset(SQueryInfo* pQueryInfo, int32_t index) { - SFieldSupInfo* pInfo = tscFieldInfoGetSupp(&pQueryInfo->fieldsInfo, index); + SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, index); assert(pInfo != NULL && pInfo->pSqlExpr != NULL); return pInfo->pSqlExpr->offset; @@ -956,10 +960,8 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) { return; } - taosArrayDestroy(pFieldInfo->pFields); - for(int32_t i = 0; i < pFieldInfo->numOfOutput; ++i) { - SFieldSupInfo* pInfo = taosArrayGet(pFieldInfo->pSupportInfo, i); + SInternalField* pInfo = taosArrayGet(pFieldInfo->internalField, i); if (pInfo->pArithExprInfo != NULL) { tExprTreeDestroy(&pInfo->pArithExprInfo->pExpr, NULL); @@ -967,7 +969,9 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) { } } - taosArrayDestroy(pFieldInfo->pSupportInfo); + taosArrayDestroy(pFieldInfo->internalField); + taosTFree(pFieldInfo->final); + memset(pFieldInfo, 0, sizeof(SFieldInfo)); } @@ -1265,6 +1269,51 @@ static int32_t validateQuoteToken(SStrToken* pToken) { return TSDB_CODE_SUCCESS; } +void tscDequoteAndTrimToken(SStrToken* pToken) { + assert(pToken->type == TK_STRING); + + uint32_t first = 0, last = pToken->n; + + // trim leading spaces + while (first < last) { + char c = pToken->z[first]; + if (c != ' ' && c != '\t') { + break; + } + first++; + } + + // trim ending spaces + while (first < last) { + char c = pToken->z[last - 1]; + if (c != ' ' && c != '\t') { + break; + } + last--; + } + + // there are still at least two characters + if (first < last - 1) { + char c = pToken->z[first]; + // dequote + if ((c == '\'' || c == '"') && c == pToken->z[last - 1]) { + first++; + last--; + } + } + + // left shift the string and pad spaces + for (uint32_t i = 0; i + first < last; i++) { + pToken->z[i] = pToken->z[first + i]; + } + for (uint32_t i = last - first; i < pToken->n; i++) { + pToken->z[i] = ' '; + } + + // adjust token length + pToken->n = last - first; +} + int32_t tscValidateName(SStrToken* pToken) { if (pToken->type != TK_STRING && pToken->type != TK_ID) { return TSDB_CODE_TSC_INVALID_SQL; @@ -1469,13 +1518,6 @@ void tscSetFreeHeatBeat(STscObj* pObj) { pQueryInfo->type = TSDB_QUERY_TYPE_FREE_RESOURCE; } -bool tscShouldFreeHeartBeat(SSqlObj* pHb) { - assert(pHb == pHb->signature); - - SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pHb->cmd, 0); - return pQueryInfo->type == TSDB_QUERY_TYPE_FREE_RESOURCE; -} - /* * the following four kinds of SqlObj should not be freed * 1. SqlObj for stream computing @@ -1573,11 +1615,8 @@ STableMetaInfo* tscGetTableMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, i } void tscInitQueryInfo(SQueryInfo* pQueryInfo) { - assert(pQueryInfo->fieldsInfo.pFields == NULL); - pQueryInfo->fieldsInfo.pFields = taosArrayInit(4, sizeof(TAOS_FIELD)); - - assert(pQueryInfo->fieldsInfo.pSupportInfo == NULL); - pQueryInfo->fieldsInfo.pSupportInfo = taosArrayInit(4, sizeof(SFieldSupInfo)); + assert(pQueryInfo->fieldsInfo.internalField == NULL); + pQueryInfo->fieldsInfo.internalField = taosArrayInit(4, sizeof(SInternalField)); assert(pQueryInfo->exprList == NULL); pQueryInfo->exprList = taosArrayInit(4, POINTER_BYTES); @@ -1639,13 +1678,62 @@ void tscClearSubqueryInfo(SSqlCmd* pCmd) { } void tscFreeVgroupTableInfo(SArray* pVgroupTables) { - if (pVgroupTables != NULL) { - for (size_t i = 0; i < taosArrayGetSize(pVgroupTables); i++) { - SVgroupTableInfo* pInfo = taosArrayGet(pVgroupTables, i); - taosArrayDestroy(pInfo->itemList); + if (pVgroupTables == NULL) { + return; + } + + size_t num = taosArrayGetSize(pVgroupTables); + for (size_t i = 0; i < num; i++) { + SVgroupTableInfo* pInfo = taosArrayGet(pVgroupTables, i); + + for(int32_t j = 0; j < pInfo->vgInfo.numOfEps; ++j) { + taosTFree(pInfo->vgInfo.epAddr[j].fqdn); } - taosArrayDestroy(pVgroupTables); + + taosArrayDestroy(pInfo->itemList); } + + taosArrayDestroy(pVgroupTables); +} + +void tscRemoveVgroupTableGroup(SArray* pVgroupTable, int32_t index) { + assert(pVgroupTable != NULL && index >= 0); + + size_t size = taosArrayGetSize(pVgroupTable); + assert(size > index); + + SVgroupTableInfo* pInfo = taosArrayGet(pVgroupTable, index); + for(int32_t j = 0; j < pInfo->vgInfo.numOfEps; ++j) { + taosTFree(pInfo->vgInfo.epAddr[j].fqdn); + } + + taosArrayDestroy(pInfo->itemList); + taosArrayRemove(pVgroupTable, index); +} + +SArray* tscCloneVgroupTableInfo(SArray* pVgroupTables) { + if (pVgroupTables == NULL) { + return NULL; + } + + size_t num = taosArrayGetSize(pVgroupTables); + SArray* pa = taosArrayInit(num, sizeof(SVgroupTableInfo)); + + SVgroupTableInfo info; + for (size_t i = 0; i < num; i++) { + SVgroupTableInfo* pInfo = taosArrayGet(pVgroupTables, i); + memset(&info, 0, sizeof(SVgroupTableInfo)); + + info.vgInfo = pInfo->vgInfo; + for(int32_t j = 0; j < pInfo->vgInfo.numOfEps; ++j) { + info.vgInfo.epAddr[j].fqdn = strdup(pInfo->vgInfo.epAddr[j].fqdn); + } + + info.itemList = taosArrayClone(pInfo->itemList); + taosArrayPush(pa, &info); + } + + return pa; } void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool removeFromCache) { @@ -1653,6 +1741,7 @@ void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool rem for(int32_t i = 0; i < pQueryInfo->numOfTables; ++i) { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, i); + tscFreeVgroupTableInfo(pTableMetaInfo->pVgroupTables); tscClearTableMetaInfo(pTableMetaInfo, removeFromCache); free(pTableMetaInfo); @@ -1662,7 +1751,7 @@ void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool rem } STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, STableMeta* pTableMeta, - SVgroupsInfo* vgroupList, SArray* pTagCols) { + SVgroupsInfo* vgroupList, SArray* pTagCols, SArray* pVgroupTables) { void* pAlloc = realloc(pQueryInfo->pTableMetaInfo, (pQueryInfo->numOfTables + 1) * POINTER_BYTES); if (pAlloc == NULL) { terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; @@ -1685,13 +1774,7 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST pTableMetaInfo->pTableMeta = pTableMeta; if (vgroupList != NULL) { - size_t size = sizeof(SVgroupsInfo) + sizeof(SCMVgroupInfo) * vgroupList->numOfVgroups; - pTableMetaInfo->vgroupList = malloc(size); - if (pTableMetaInfo->vgroupList == NULL) { - return NULL; - } - - memcpy(pTableMetaInfo->vgroupList, vgroupList, size); + pTableMetaInfo->vgroupList = tscVgroupInfoClone(vgroupList); } pTableMetaInfo->tagColList = taosArrayInit(4, POINTER_BYTES); @@ -1702,13 +1785,15 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST if (pTagCols != NULL) { tscColumnListCopy(pTableMetaInfo->tagColList, pTagCols, -1); } + + pTableMetaInfo->pVgroupTables = tscCloneVgroupTableInfo(pVgroupTables); pQueryInfo->numOfTables += 1; return pTableMetaInfo; } STableMetaInfo* tscAddEmptyMetaInfo(SQueryInfo* pQueryInfo) { - return tscAddTableMetaInfo(pQueryInfo, NULL, NULL, NULL, NULL); + return tscAddTableMetaInfo(pQueryInfo, NULL, NULL, NULL, NULL, NULL); } void tscClearTableMetaInfo(STableMetaInfo* pTableMetaInfo, bool removeFromCache) { @@ -1720,8 +1805,7 @@ void tscClearTableMetaInfo(STableMetaInfo* pTableMetaInfo, bool removeFromCache) taosCacheRelease(tscMetaCache, (void**)&(pTableMetaInfo->pTableMeta), removeFromCache); } - taosTFree(pTableMetaInfo->vgroupList); - + pTableMetaInfo->vgroupList = tscVgroupInfoClear(pTableMetaInfo->vgroupList); tscColumnListDestroy(pTableMetaInfo->tagColList); pTableMetaInfo->tagColList = NULL; } @@ -1735,6 +1819,16 @@ void tscResetForNextRetrieve(SSqlRes* pRes) { pRes->numOfRows = 0; } +void registerSqlObj(SSqlObj* pSql) { + int32_t DEFAULT_LIFE_TIME = 2 * 600 * 1000; // 1200 sec + + int32_t ref = T_REF_INC(pSql->pTscObj); + tscDebug("%p add to tscObj:%p, ref:%d", pSql, pSql->pTscObj, ref); + + TSDB_CACHE_PTR_TYPE p = (TSDB_CACHE_PTR_TYPE) pSql; + pSql->self = taosCachePut(tscObjCache, &p, sizeof(TSDB_CACHE_PTR_TYPE), &p, sizeof(TSDB_CACHE_PTR_TYPE), DEFAULT_LIFE_TIME); +} + SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cmd) { SSqlObj* pNew = (SSqlObj*)calloc(1, sizeof(SSqlObj)); if (pNew == NULL) { @@ -1743,13 +1837,13 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm } pNew->pTscObj = pSql->pTscObj; - T_REF_INC(pNew->pTscObj); - pNew->signature = pNew; SSqlCmd* pCmd = &pNew->cmd; pCmd->command = cmd; pCmd->parseFinished = 1; + pCmd->autoCreated = pSql->cmd.autoCreated; + memcpy(&pCmd->tagData, &pSql->cmd.tagData, sizeof(pCmd->tagData)); if (tscAddSubqueryInfo(pCmd) != TSDB_CODE_SUCCESS) { tscFreeSqlObj(pNew); @@ -1764,8 +1858,7 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm pNew->sqlstr = strdup(pSql->sqlstr); if (pNew->sqlstr == NULL) { tscError("%p new subquery failed", pSql); - - free(pNew); + tscFreeSqlObj(pNew); return NULL; } @@ -1774,63 +1867,29 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm assert(pSql->cmd.clauseIndex == 0); STableMetaInfo* pMasterTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, pSql->cmd.clauseIndex, 0); - tscAddTableMetaInfo(pQueryInfo, pMasterTableMetaInfo->name, NULL, NULL, NULL); - - T_REF_INC(pNew->pTscObj); + tscAddTableMetaInfo(pQueryInfo, pMasterTableMetaInfo->name, NULL, NULL, NULL, NULL); - uint64_t p = (uint64_t) pNew; - pNew->self = taosCachePut(tscObjCache, &p, sizeof(uint64_t), &pNew, sizeof(uint64_t), 2 * 600 * 1000); + registerSqlObj(pNew); return pNew; } -// current sql function is not direct output result, so create a dummy output field -static void doSetNewFieldInfo(SQueryInfo* pNewQueryInfo, SSqlExpr* pExpr) { - TAOS_FIELD f = {.type = (uint8_t)pExpr->resType, .bytes = pExpr->resBytes}; - tstrncpy(f.name, pExpr->aliasName, sizeof(f.name)); - - SFieldSupInfo* pInfo1 = tscFieldInfoAppend(&pNewQueryInfo->fieldsInfo, &f); - - pInfo1->pSqlExpr = pExpr; - pInfo1->visible = false; -} - static void doSetSqlExprAndResultFieldInfo(SQueryInfo* pQueryInfo, SQueryInfo* pNewQueryInfo, int64_t uid) { int32_t numOfOutput = (int32_t)tscSqlExprNumOfExprs(pNewQueryInfo); if (numOfOutput == 0) { return; } - size_t numOfExprs = tscSqlExprNumOfExprs(pQueryInfo); - SFieldInfo* pFieldInfo = &pQueryInfo->fieldsInfo; - - // set the field info in pNewQueryInfo object + // set the field info in pNewQueryInfo object according to sqlExpr information + size_t numOfExprs = tscSqlExprNumOfExprs(pNewQueryInfo); for (int32_t i = 0; i < numOfExprs; ++i) { - SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); + SSqlExpr* pExpr = tscSqlExprGet(pNewQueryInfo, i); - if (pExpr->uid == uid) { - if (i < pFieldInfo->numOfOutput) { - SFieldSupInfo* pInfo = tscFieldInfoGetSupp(pFieldInfo, i); - - if (pInfo->pSqlExpr != NULL) { - TAOS_FIELD* p = tscFieldInfoGetField(pFieldInfo, i); - assert(strcmp(p->name, pExpr->aliasName) == 0); - - SFieldSupInfo* pInfo1 = tscFieldInfoAppend(&pNewQueryInfo->fieldsInfo, p); - *pInfo1 = *pInfo; - } else { - assert(pInfo->pArithExprInfo != NULL); - doSetNewFieldInfo(pNewQueryInfo, pExpr); - } - } else { // it is a arithmetic column, does not have actual field for sqlExpr, so build it - doSetNewFieldInfo(pNewQueryInfo, pExpr); - } - } + TAOS_FIELD f = tscCreateField((int8_t) pExpr->resType, pExpr->aliasName, pExpr->resBytes); + SInternalField* pInfo1 = tscFieldInfoAppend(&pNewQueryInfo->fieldsInfo, &f); + pInfo1->pSqlExpr = pExpr; } - // make sure the the sqlExpr for each fields is correct - numOfExprs = tscSqlExprNumOfExprs(pNewQueryInfo); - - // update the pSqlExpr pointer in SFieldSupInfo according the field name + // update the pSqlExpr pointer in SInternalField according the field name // make sure the pSqlExpr point to the correct SqlExpr in pNewQueryInfo, not SqlExpr in pQueryInfo for (int32_t f = 0; f < pNewQueryInfo->fieldsInfo.numOfOutput; ++f) { TAOS_FIELD* field = tscFieldInfoGetField(&pNewQueryInfo->fieldsInfo, f); @@ -1840,7 +1899,7 @@ static void doSetSqlExprAndResultFieldInfo(SQueryInfo* pQueryInfo, SQueryInfo* p SSqlExpr* pExpr1 = tscSqlExprGet(pNewQueryInfo, k1); if (strcmp(field->name, pExpr1->aliasName) == 0) { // establish link according to the result field name - SFieldSupInfo* pInfo = tscFieldInfoGetSupp(&pNewQueryInfo->fieldsInfo, f); + SInternalField* pInfo = tscFieldInfoGetInternalField(&pNewQueryInfo->fieldsInfo, f); pInfo->pSqlExpr = pExpr1; matched = true; @@ -1869,7 +1928,6 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void pNew->pTscObj = pSql->pTscObj; pNew->signature = pNew; - T_REF_INC(pNew->pTscObj); pNew->sqlstr = strdup(pSql->sqlstr); if (pNew->sqlstr == NULL) { @@ -1974,14 +2032,16 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void STableMeta* pTableMeta = taosCacheAcquireByData(tscMetaCache, pTableMetaInfo->pTableMeta); // get by name may failed due to the cache cleanup assert(pTableMeta != NULL); - pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, name, pTableMeta, pTableMetaInfo->vgroupList, pTableMetaInfo->tagColList); + pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, name, pTableMeta, pTableMetaInfo->vgroupList, + pTableMetaInfo->tagColList, pTableMetaInfo->pVgroupTables); } else { // transfer the ownership of pTableMeta to the newly create sql object. STableMetaInfo* pPrevInfo = tscGetTableMetaInfoFromCmd(&pPrevSql->cmd, pPrevSql->cmd.clauseIndex, 0); STableMeta* pPrevTableMeta = taosCacheTransfer(tscMetaCache, (void**)&pPrevInfo->pTableMeta); SVgroupsInfo* pVgroupsInfo = pPrevInfo->vgroupList; - pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, name, pPrevTableMeta, pVgroupsInfo, pTableMetaInfo->tagColList); + pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, name, pPrevTableMeta, pVgroupsInfo, pTableMetaInfo->tagColList, + pTableMetaInfo->pVgroupTables); } if (pFinalInfo->pTableMeta == NULL) { @@ -2018,10 +2078,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void tscDebug("%p new sub insertion: %p, vnodeIdx:%d", pSql, pNew, pTableMetaInfo->vgroupIndex); } - T_REF_INC(pNew->pTscObj); - - uint64_t p = (uint64_t) pNew; - pNew->self = taosCachePut(tscObjCache, &p, sizeof(uint64_t), &pNew, sizeof(uint64_t), 2 * 600 * 10); + registerSqlObj(pNew); return pNew; _error: @@ -2242,7 +2299,7 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) { * * For super table join with projection query, if anyone of the subquery is exhausted, the query completed. */ - pSql->numOfSubs = 0; + pSql->subState.numOfSub = 0; pCmd->command = TSDB_SQL_SELECT; tscResetForNextRetrieve(pRes); @@ -2274,7 +2331,7 @@ void tscTryQueryNextClause(SSqlObj* pSql, __async_cb_func_t fp) { pRes->numOfTotal = num; taosTFree(pSql->pSubs); - pSql->numOfSubs = 0; + pSql->subState.numOfSub = 0; pSql->fp = fp; tscDebug("%p try data in the next subclause:%d, total subclause:%d", pSql, pCmd->clauseIndex, pCmd->numOfClause); @@ -2359,3 +2416,58 @@ void tscClearSqlOwner(SSqlObj* pSql) { assert(taosCheckPthreadValid(pSql->owner)); atomic_store_64(&pSql->owner, 0); } + +SVgroupsInfo* tscVgroupInfoClone(SVgroupsInfo *vgroupList) { + if (vgroupList == NULL) { + return NULL; + } + + size_t size = sizeof(SVgroupsInfo) + sizeof(SCMVgroupInfo) * vgroupList->numOfVgroups; + SVgroupsInfo* pNew = calloc(1, size); + if (pNew == NULL) { + return NULL; + } + + pNew->numOfVgroups = vgroupList->numOfVgroups; + + for(int32_t i = 0; i < vgroupList->numOfVgroups; ++i) { + SCMVgroupInfo* pNewVInfo = &pNew->vgroups[i]; + + SCMVgroupInfo* pvInfo = &vgroupList->vgroups[i]; + pNewVInfo->vgId = pvInfo->vgId; + pNewVInfo->numOfEps = pvInfo->numOfEps; + + for(int32_t j = 0; j < pvInfo->numOfEps; ++j) { + pNewVInfo->epAddr[j].fqdn = strdup(pvInfo->epAddr[j].fqdn); + pNewVInfo->epAddr[j].port = pvInfo->epAddr[j].port; + } + } + + return pNew; +} + +void* tscVgroupInfoClear(SVgroupsInfo *vgroupList) { + if (vgroupList == NULL) { + return NULL; + } + + for(int32_t i = 0; i < vgroupList->numOfVgroups; ++i) { + SCMVgroupInfo* pVgroupInfo = &vgroupList->vgroups[i]; + + for(int32_t j = 0; j < pVgroupInfo->numOfEps; ++j) { + taosTFree(pVgroupInfo->epAddr[j].fqdn); + } + } + + taosTFree(vgroupList); + return NULL; +} + +void tscSCMVgroupInfoCopy(SCMVgroupInfo* dst, const SCMVgroupInfo* src) { + dst->vgId = src->vgId; + dst->numOfEps = src->numOfEps; + for(int32_t i = 0; i < dst->numOfEps; ++i) { + dst->epAddr[i].port = src->epAddr[i].port; + dst->epAddr[i].fqdn = strdup(src->epAddr[i].fqdn); + } +} diff --git a/src/common/inc/tcmdtype.h b/src/common/inc/tcmdtype.h index 90fb5bf47854313a67e395eea7b99a992a579889..69bbccd67e79eb77e3afd0523dec765e53a5cfa1 100644 --- a/src/common/inc/tcmdtype.h +++ b/src/common/inc/tcmdtype.h @@ -78,6 +78,9 @@ enum { TSDB_DEFINE_SQL_TYPE( TSDB_SQL_RETRIEVE_LOCALMERGE, "retrieve-localmerge" ) TSDB_DEFINE_SQL_TYPE( TSDB_SQL_TABLE_JOIN_RETRIEVE, "join-retrieve" ) + TSDB_DEFINE_SQL_TYPE( TSDB_SQL_SHOW_CREATE_TABLE, "show-create-table") + TSDB_DEFINE_SQL_TYPE( TSDB_SQL_SHOW_CREATE_DATABASE, "show-create-database") + /* * build empty result instead of accessing dnode to fetch result * reset the client cache diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 77e8b76456b04301a1f556c69a4bae98970c1f37..4636eaac08db4943e1837b5d6e8db40341ba6546 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -34,6 +34,7 @@ extern int32_t tsStatusInterval; extern int32_t tsNumOfMnodes; extern int32_t tsEnableVnodeBak; extern int32_t tsEnableTelemetryReporting; +extern char tsEmail[]; // common extern int tsRpcTimer; @@ -43,14 +44,17 @@ extern int32_t tsMaxShellConns; extern int32_t tsShellActivityTimer; extern uint32_t tsMaxTmrCtrl; extern float tsNumOfThreadsPerCore; -extern float tsRatioOfQueryThreads; +extern float tsRatioOfQueryThreads; // todo remove it extern int8_t tsDaylight; extern char tsTimezone[]; extern char tsLocale[]; -extern char tsCharset[]; // default encode string +extern char tsCharset[]; // default encode string extern int32_t tsEnableCoreFile; extern int32_t tsCompressMsgSize; +//query buffer management +extern int32_t tsQueryBufferSize; // maximum allowed usage buffer for each data node during query processing + // client extern int32_t tsTableMetaKeepTimer; extern int32_t tsMaxSQLStringLen; @@ -174,6 +178,7 @@ extern int32_t rpcDebugFlag; extern int32_t odbcDebugFlag; extern int32_t qDebugFlag; extern int32_t wDebugFlag; +extern int32_t cqDebugFlag; extern int32_t debugFlag; #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize) diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index e7f40442a0b18c07193a10db61452c820e603473..28289b051e4ef32e1b1e22847df584238857002b 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -313,13 +313,13 @@ void dataColSetOffset(SDataCol *pCol, int nEle) { SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows) { SDataCols *pCols = (SDataCols *)calloc(1, sizeof(SDataCols)); if (pCols == NULL) { - uDebug("malloc failure, size:%"PRId64" failed, reason:%s", sizeof(SDataCols), strerror(errno)); + uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCols), strerror(errno)); return NULL; } pCols->cols = (SDataCol *)calloc(maxCols, sizeof(SDataCol)); if (pCols->cols == NULL) { - uDebug("malloc failure, size:%"PRId64" failed, reason:%s", sizeof(SDataCol) * maxCols, strerror(errno)); + uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCol) * maxCols, strerror(errno)); tdFreeDataCols(pCols); return NULL; } @@ -331,7 +331,7 @@ SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows) { pCols->buf = malloc(pCols->bufSize); if (pCols->buf == NULL) { - uDebug("malloc failure, size:%"PRId64" failed, reason:%s", sizeof(SDataCol) * maxCols, strerror(errno)); + uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCol) * maxCols, strerror(errno)); tdFreeDataCols(pCols); return NULL; } @@ -566,7 +566,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) { SKVRow nrow = NULL; void * ptr = taosbsearch(&colId, kvRowColIdx(row), kvRowNCols(row), sizeof(SColIdx), comparTagId, TD_GE); - if (ptr == NULL || ((SColIdx *)ptr)->colId < colId) { // need to add a column value to the row + if (ptr == NULL || ((SColIdx *)ptr)->colId > colId) { // need to add a column value to the row int diff = IS_VAR_DATA_TYPE(type) ? varDataTLen(value) : TYPE_BYTES[type]; nrow = malloc(kvRowLen(row) + sizeof(SColIdx) + diff); if (nrow == NULL) return -1; @@ -716,4 +716,4 @@ SKVRow tdGetKVRowFromBuilder(SKVRowBuilder *pBuilder) { memcpy(kvRowValues(row), pBuilder->buf, pBuilder->size); return row; -} \ No newline at end of file +} diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 7e46f58a930bbdac64ea98758a3d4a997fd1a7ec..32569e39823416a25bc0f0bb88d1feb9faafcff1 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -42,16 +42,17 @@ int32_t tsStatusInterval = 1; // second int32_t tsNumOfMnodes = 3; int32_t tsEnableVnodeBak = 1; int32_t tsEnableTelemetryReporting = 1; +char tsEmail[TSDB_FQDN_LEN] = {0}; // common -int32_t tsRpcTimer = 1000; -int32_t tsRpcMaxTime = 600; // seconds; -int32_t tsMaxShellConns = 5000; +int32_t tsRpcTimer = 1000; +int32_t tsRpcMaxTime = 600; // seconds; +int32_t tsMaxShellConns = 5000; int32_t tsMaxConnections = 5000; -int32_t tsShellActivityTimer = 3; // second -float tsNumOfThreadsPerCore = 1.0; -float tsRatioOfQueryThreads = 0.5; -int8_t tsDaylight = 0; +int32_t tsShellActivityTimer = 3; // second +float tsNumOfThreadsPerCore = 1.0f; +float tsRatioOfQueryThreads = 0.5f; +int8_t tsDaylight = 0; char tsTimezone[TSDB_TIMEZONE_LEN] = {0}; char tsLocale[TSDB_LOCALE_LEN] = {0}; char tsCharset[TSDB_LOCALE_LEN] = {0}; // default encode string @@ -98,6 +99,12 @@ float tsStreamComputDelayRatio = 0.1f; int32_t tsProjectExecInterval = 10000; // every 10sec, the projection will be executed once 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 +// positive value (in MB) +int32_t tsQueryBufferSize = -1; + // db parameters int32_t tsCacheBlockSize = TSDB_DEFAULT_CACHE_BLOCK_SIZE; int32_t tsBlocksPerVnode = TSDB_DEFAULT_TOTAL_BLOCKS; @@ -131,7 +138,7 @@ uint16_t tsHttpPort = 6041; // only tcp, range tcp[6041] int32_t tsHttpCacheSessions = 1000; int32_t tsHttpSessionExpire = 36000; int32_t tsHttpMaxThreads = 2; -int32_t tsHttpEnableCompress = 0; +int32_t tsHttpEnableCompress = 1; int32_t tsHttpEnableRecordSql = 0; int32_t tsTelegrafUseFieldNum = 0; @@ -203,6 +210,7 @@ int32_t debugFlag = 0; int32_t sDebugFlag = 135; int32_t wDebugFlag = 135; int32_t tsdbDebugFlag = 131; +int32_t cqDebugFlag = 135; int32_t (*monitorStartSystemFp)() = NULL; void (*monitorStopSystemFp)() = NULL; @@ -222,12 +230,13 @@ void taosSetAllDebugFlag() { httpDebugFlag = debugFlag; mqttDebugFlag = debugFlag; monitorDebugFlag = debugFlag; + qDebugFlag = debugFlag; rpcDebugFlag = debugFlag; uDebugFlag = debugFlag; sDebugFlag = debugFlag; wDebugFlag = debugFlag; tsdbDebugFlag = debugFlag; - qDebugFlag = debugFlag; + cqDebugFlag = debugFlag; uInfo("all debug flag are set to %d", debugFlag); } } @@ -305,6 +314,8 @@ bool taosCfgDynamicOptions(char *msg) { static void doInitGlobalConfig(void) { osInit(); + srand(taosSafeRand()); + SGlobalCfg cfg = {0}; // ip address @@ -671,7 +682,7 @@ static void doInitGlobalConfig(void) { cfg.minValue = TSDB_MIN_CACHE_BLOCK_SIZE; cfg.maxValue = TSDB_MAX_CACHE_BLOCK_SIZE; cfg.ptrLength = 0; - cfg.unitType = TAOS_CFG_UTYPE_Mb; + cfg.unitType = TAOS_CFG_UTYPE_MB; taosInitConfigOption(cfg); cfg.option = "blocks"; @@ -834,6 +845,16 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "queryBufferSize"; + cfg.ptr = &tsQueryBufferSize; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = -1; + cfg.maxValue = 500000000000.0f; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_BYTE; + taosInitConfigOption(cfg); + // locale & charset cfg.option = "timezone"; cfg.ptr = tsTimezone; @@ -1012,7 +1033,7 @@ static void doInitGlobalConfig(void) { cfg.ptr = &tsLogKeepDays; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT; - cfg.minValue = 0; + cfg.minValue = -365000; cfg.maxValue = 365000; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_NONE; @@ -1209,6 +1230,16 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "cqDebugFlag"; + cfg.ptr = &cqDebugFlag; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG; + cfg.minValue = 0; + cfg.maxValue = 255; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + cfg.option = "tscEnableRecordSql"; cfg.ptr = &tsTscEnableRecordSql; cfg.valType = TAOS_CFG_VTYPE_INT32; diff --git a/src/common/src/ttypes.c b/src/common/src/ttypes.c index ff417b6cdef4c60dc8d563800a2b2d4c92c8d0c3..50554ce08e3fb659c1a5915c4c50b09f950324b4 100644 --- a/src/common/src/ttypes.c +++ b/src/common/src/ttypes.c @@ -219,7 +219,7 @@ static void getStatics_f(const TSKEY *primaryKey, const void *pData, int32_t num } float fv = 0; - fv = GET_FLOAT_VAL(&(data[i])); + fv = GET_FLOAT_VAL((const char*)&(data[i])); dsum += fv; if (fmin > fv) { fmin = fv; @@ -233,17 +233,12 @@ static void getStatics_f(const TSKEY *primaryKey, const void *pData, int32_t num } double csum = 0; - csum = GET_DOUBLE_VAL(sum); + csum = GET_DOUBLE_VAL((const char *)sum); csum += dsum; -#ifdef _TD_ARM_32_ - SET_DOUBLE_VAL_ALIGN(sum, &csum); - SET_DOUBLE_VAL_ALIGN(max, &fmax); - SET_DOUBLE_VAL_ALIGN(min, &fmin); -#else - *(double*)sum = csum; - *(double*)max = fmax; - *(double*)min = fmin; -#endif + + SET_DOUBLE_VAL(sum, csum); + SET_DOUBLE_VAL(max, fmax); + SET_DOUBLE_VAL(min, fmin); } static void getStatics_d(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, @@ -264,7 +259,7 @@ static void getStatics_d(const TSKEY *primaryKey, const void *pData, int32_t num } double dv = 0; - dv = GET_DOUBLE_VAL(&(data[i])); + dv = GET_DOUBLE_VAL((const char*)&(data[i])); dsum += dv; if (dmin > dv) { dmin = dv; @@ -278,19 +273,12 @@ static void getStatics_d(const TSKEY *primaryKey, const void *pData, int32_t num } double csum = 0; - csum = GET_DOUBLE_VAL(sum); + csum = GET_DOUBLE_VAL((const char *)sum); csum += dsum; - -#ifdef _TD_ARM_32_ - SET_DOUBLE_VAL_ALIGN(sum, &csum); - SET_DOUBLE_VAL_ALIGN(max, &dmax); - SET_DOUBLE_VAL_ALIGN(min, &dmin); -#else - *(double*) sum = csum; - *(double*) max = dmax; - *(double*) min = dmin; -#endif + SET_DOUBLE_PTR(sum, &csum); + SET_DOUBLE_PTR(max, &dmax); + SET_DOUBLE_PTR(min, &dmin); } static void getStatics_bin(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, @@ -493,46 +481,29 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) { *((int32_t *)val) = GET_INT32_VAL(src); break; } - case TSDB_DATA_TYPE_FLOAT: { -#ifdef _TD_ARM_32_ - float fv = GET_FLOAT_VAL(src); - SET_FLOAT_VAL_ALIGN(val, &fv); -#else - *((float *)val) = GET_FLOAT_VAL(src); -#endif + case TSDB_DATA_TYPE_FLOAT: + SET_FLOAT_VAL(val, GET_FLOAT_VAL(src)); break; - }; - case TSDB_DATA_TYPE_DOUBLE: { -#ifdef _TD_ARM_32_ - double dv = GET_DOUBLE_VAL(src); - SET_DOUBLE_VAL_ALIGN(val, &dv); -#else - *((double *)val) = GET_DOUBLE_VAL(src); -#endif + case TSDB_DATA_TYPE_DOUBLE: + SET_DOUBLE_VAL(val, GET_DOUBLE_VAL(src)); break; - }; case TSDB_DATA_TYPE_TIMESTAMP: - case TSDB_DATA_TYPE_BIGINT: { + case TSDB_DATA_TYPE_BIGINT: *((int64_t *)val) = GET_INT64_VAL(src); break; - }; - case TSDB_DATA_TYPE_SMALLINT: { + case TSDB_DATA_TYPE_SMALLINT: *((int16_t *)val) = GET_INT16_VAL(src); break; - }; case TSDB_DATA_TYPE_BOOL: - case TSDB_DATA_TYPE_TINYINT: { + case TSDB_DATA_TYPE_TINYINT: *((int8_t *)val) = GET_INT8_VAL(src); break; - }; - case TSDB_DATA_TYPE_BINARY: { + case TSDB_DATA_TYPE_BINARY: varDataCopy(val, src); break; - }; - case TSDB_DATA_TYPE_NCHAR: { + case TSDB_DATA_TYPE_NCHAR: varDataCopy(val, src); break; - }; default: { memcpy(val, src, len); break; @@ -579,4 +550,4 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf break; } } -} \ No newline at end of file +} diff --git a/src/common/src/tvariant.c b/src/common/src/tvariant.c index 069d8eb2517cbbd70477652140294fb3b3863906..9eb9924932c7757c3c999eb5afadd8c719dc16bc 100644 --- a/src/common/src/tvariant.c +++ b/src/common/src/tvariant.c @@ -144,21 +144,24 @@ void tVariantDestroy(tVariant *pVar) { void tVariantAssign(tVariant *pDst, const tVariant *pSrc) { if (pSrc == NULL || pDst == NULL) return; - *pDst = *pSrc; - + pDst->nType = pSrc->nType; if (pSrc->nType == TSDB_DATA_TYPE_BINARY || pSrc->nType == TSDB_DATA_TYPE_NCHAR) { - int32_t len = pSrc->nLen + 1; - if (pSrc->nType == TSDB_DATA_TYPE_NCHAR) { - len = len * TSDB_NCHAR_SIZE; - } - - pDst->pz = calloc(1, len); - memcpy(pDst->pz, pSrc->pz, len); + int32_t len = pSrc->nLen + TSDB_NCHAR_SIZE; + char* p = realloc(pDst->pz, len); + assert(p); + + memset(p, 0, len); + pDst->pz = p; + + memcpy(pDst->pz, pSrc->pz, pSrc->nLen); + pDst->nLen = pSrc->nLen; return; + } - // this is only for string array - if (pSrc->nType == TSDB_DATA_TYPE_ARRAY) { + if (pSrc->nType >= TSDB_DATA_TYPE_BOOL && pSrc->nType <= TSDB_DATA_TYPE_DOUBLE) { + pDst->i64Key = pSrc->i64Key; + } else if (pSrc->nType == TSDB_DATA_TYPE_ARRAY) { // this is only for string array size_t num = taosArrayGetSize(pSrc->arr); pDst->arr = taosArrayInit(num, sizeof(char*)); for(size_t i = 0; i < num; i++) { @@ -166,8 +169,6 @@ void tVariantAssign(tVariant *pDst, const tVariant *pSrc) { char* n = strdup(p); taosArrayPush(pDst->arr, &n); } - - return; } pDst->nLen = tDataTypeDesc[pDst->nType].nSize; @@ -709,46 +710,21 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu return -1; } -#ifdef _TD_ARM_32_ - //memcpy(&payload, &value, sizeof(float)); - float fv = (float)value; - SET_FLOAT_VAL_ALIGN(payload, &fv); -#else - *((float *)payload) = (float)value; -#endif + SET_FLOAT_VAL(payload, value); } } else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) { -#ifdef _TD_ARM_32_ - //memcpy(&payload, &pVariant->i64Key, sizeof(float)); - float fv = (float)pVariant->i64Key; - SET_FLOAT_VAL_ALIGN(payload, &fv); -#else - *((float *)payload) = (float)pVariant->i64Key; -#endif + SET_FLOAT_VAL(payload, pVariant->i64Key); } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { -#ifdef _TD_ARM_32_ - //memcpy(&payload, &pVariant->dKey, sizeof(float)); - float fv = (float)pVariant->dKey; - SET_FLOAT_VAL_ALIGN(payload, &fv); -#else - *((float *)payload) = (float)pVariant->dKey; -#endif + SET_FLOAT_VAL(payload, pVariant->dKey); } else if (pVariant->nType == TSDB_DATA_TYPE_NULL) { *((int32_t *)payload) = TSDB_DATA_FLOAT_NULL; return 0; } -#ifdef _TD_ARM_32_ float fv = GET_FLOAT_VAL(payload); if (isinf(fv) || isnan(fv) || fv > FLT_MAX || fv < -FLT_MAX) { return -1; } -#else - if (isinf(*((float *)payload)) || isnan(*((float *)payload)) || *((float *)payload) > FLT_MAX || - *((float *)payload) < -FLT_MAX) { - return -1; - } -#endif break; } case TSDB_DATA_TYPE_DOUBLE: { @@ -765,42 +741,21 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu return -1; } -#ifdef _TD_ARM_32_ - SET_DOUBLE_VAL_ALIGN(payload, &value); -#else - *((double *)payload) = value; -#endif + SET_DOUBLE_VAL(payload, value); } } else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) { -#ifdef _TD_ARM_32_ - double dv = (double)(pVariant->i64Key); - SET_DOUBLE_VAL_ALIGN(payload, &dv); -#else - *((double *)payload) = (double)pVariant->i64Key; -#endif + SET_DOUBLE_VAL(payload, pVariant->i64Key); } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { -#ifdef _TD_ARM_32_ - double dv = (double)(pVariant->dKey); - SET_DOUBLE_VAL_ALIGN(payload, &dv); -#else - *((double *)payload) = pVariant->dKey; -#endif + SET_DOUBLE_VAL(payload, pVariant->dKey); } else if (pVariant->nType == TSDB_DATA_TYPE_NULL) { *((int64_t *)payload) = TSDB_DATA_DOUBLE_NULL; return 0; } -#ifdef _TD_ARM_32_ double dv = GET_DOUBLE_VAL(payload); if (isinf(dv) || isnan(dv) || dv > DBL_MAX || dv < -DBL_MAX) { return -1; } -#else - if (isinf(*((double *)payload)) || isnan(*((double *)payload)) || *((double *)payload) > DBL_MAX || - *((double *)payload) < -DBL_MAX) { - return -1; - } -#endif break; } diff --git a/src/connector/go b/src/connector/go index 8c58c512b6acda8bcdfa48fdc7140227b5221766..8d7bf743852897110cbdcc7c4322cd7a74d4167b 160000 --- a/src/connector/go +++ b/src/connector/go @@ -1 +1 @@ -Subproject commit 8c58c512b6acda8bcdfa48fdc7140227b5221766 +Subproject commit 8d7bf743852897110cbdcc7c4322cd7a74d4167b diff --git a/src/connector/jdbc/CMakeLists.txt b/src/connector/jdbc/CMakeLists.txt index 7f823b97b266dae11ce1ba384cc812a1a9d6b691..c565853ab0fd3fa961643725bbf3d17ff1dc349a 100644 --- a/src/connector/jdbc/CMakeLists.txt +++ b/src/connector/jdbc/CMakeLists.txt @@ -8,7 +8,7 @@ IF (TD_MVN_INSTALLED) ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME} POST_BUILD COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.0-dist.jar ${LIBRARY_OUTPUT_PATH} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.8-dist.jar ${LIBRARY_OUTPUT_PATH} COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml COMMENT "build jdbc driver") ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME}) diff --git a/src/connector/jdbc/deploy-pom.xml b/src/connector/jdbc/deploy-pom.xml index 766a58f9babe3e4eec8b482b937378be6b8f0943..3f6ebeff03f538e4963540e015c7fd4b310acc42 100755 --- a/src/connector/jdbc/deploy-pom.xml +++ b/src/connector/jdbc/deploy-pom.xml @@ -5,10 +5,9 @@ com.taosdata.jdbc taos-jdbcdriver - 2.0.0-SNAPSHOT + 2.0.6 jar - JDBCDriver https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc TDengine JDBC Driver diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml index 36e2fa426b7647b4b2a3543ffa8470c310dc82b2..3b62f66d2ec88002d2f749166fb00bff670617ee 100755 --- a/src/connector/jdbc/pom.xml +++ b/src/connector/jdbc/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.taosdata.jdbc taos-jdbcdriver - 2.0.0 + 2.0.8 jar JDBCDriver https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc @@ -55,6 +55,7 @@ 4.13 test + diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/DatabaseMetaDataResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/DatabaseMetaDataResultSet.java index 86938031f6e4a6001bca2c8f2911e6a8f0284cc4..f82c064e751c195eb6327580c285a815346c917b 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/DatabaseMetaDataResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/DatabaseMetaDataResultSet.java @@ -67,14 +67,23 @@ public class DatabaseMetaDataResultSet implements ResultSet { @Override public boolean next() throws SQLException { +// boolean ret = false; +// if (rowDataList.size() > 0) { +// ret = rowDataList.iterator().hasNext(); +// if (ret) { +// rowCursor = rowDataList.iterator().next(); +// cursorRowNumber++; +// } +// } +// return ret; + + /**** add by zyyang 2020-09-29 ****************/ boolean ret = false; - if (rowDataList.size() > 0) { - ret = rowDataList.iterator().hasNext(); - if (ret) { - rowCursor = rowDataList.iterator().next(); - cursorRowNumber++; - } + if (!rowDataList.isEmpty() && cursorRowNumber < rowDataList.size()) { + rowCursor = rowDataList.get(cursorRowNumber++); + ret = true; } + return ret; } @@ -91,7 +100,8 @@ public class DatabaseMetaDataResultSet implements ResultSet { @Override public String getString(int columnIndex) throws SQLException { columnIndex--; - return rowCursor.getString(columnIndex, columnMetaDataList.get(columnIndex).getColType()); + int colType = columnMetaDataList.get(columnIndex).getColType(); + return rowCursor.getString(columnIndex, colType); } @Override diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java index 15f66fa2029e7c1bf8a3ecf8ec68b53a8455c648..c1d9d2af8e5a5c24dcfed6039e3ce06530b95276 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java @@ -20,519 +20,519 @@ import java.util.List; public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { - private String dbProductName = null; - private String url = null; - private String userName = null; - private Connection conn = null; - - public TSDBDatabaseMetaData(String dbProductName, String url, String userName) { - this.dbProductName = dbProductName; - this.url = url; - this.userName = userName; - } + private String dbProductName = null; + private String url = null; + private String userName = null; + private Connection conn = null; + + public TSDBDatabaseMetaData(String dbProductName, String url, String userName) { + this.dbProductName = dbProductName; + this.url = url; + this.userName = userName; + } - public void setConnection(Connection conn) { - this.conn = conn; - } + public void setConnection(Connection conn) { + this.conn = conn; + } - public T unwrap(Class iface) throws SQLException { - return null; - } + public T unwrap(Class iface) throws SQLException { + return null; + } - public boolean isWrapperFor(Class iface) throws SQLException { - return false; - } + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } - public boolean allProceduresAreCallable() throws SQLException { - return false; - } + public boolean allProceduresAreCallable() throws SQLException { + return false; + } - public boolean allTablesAreSelectable() throws SQLException { - return false; - } + public boolean allTablesAreSelectable() throws SQLException { + return false; + } - public String getURL() throws SQLException { - return this.url; - } + public String getURL() throws SQLException { + return this.url; + } - public String getUserName() throws SQLException { - return this.userName; - } + public String getUserName() throws SQLException { + return this.userName; + } - public boolean isReadOnly() throws SQLException { - return false; - } + public boolean isReadOnly() throws SQLException { + return false; + } - public boolean nullsAreSortedHigh() throws SQLException { - return false; - } + public boolean nullsAreSortedHigh() throws SQLException { + return false; + } - public boolean nullsAreSortedLow() throws SQLException { - return !nullsAreSortedHigh(); - } + public boolean nullsAreSortedLow() throws SQLException { + return !nullsAreSortedHigh(); + } - public boolean nullsAreSortedAtStart() throws SQLException { - return true; - } + public boolean nullsAreSortedAtStart() throws SQLException { + return true; + } - public boolean nullsAreSortedAtEnd() throws SQLException { - return !nullsAreSortedAtStart(); - } + public boolean nullsAreSortedAtEnd() throws SQLException { + return !nullsAreSortedAtStart(); + } - public String getDatabaseProductName() throws SQLException { - return this.dbProductName; - } + public String getDatabaseProductName() throws SQLException { + return this.dbProductName; + } - public String getDatabaseProductVersion() throws SQLException { - return "1.5.1"; - } + public String getDatabaseProductVersion() throws SQLException { + return "1.5.1"; + } - public String getDriverName() throws SQLException { - return TSDBDriver.class.getName(); - } + public String getDriverName() throws SQLException { + return TSDBDriver.class.getName(); + } - public String getDriverVersion() throws SQLException { - return "1.0.0"; - } + public String getDriverVersion() throws SQLException { + return "1.0.0"; + } - public int getDriverMajorVersion() { - return 0; - } + public int getDriverMajorVersion() { + return 0; + } - public int getDriverMinorVersion() { - return 0; - } + public int getDriverMinorVersion() { + return 0; + } - public boolean usesLocalFiles() throws SQLException { - return false; - } + public boolean usesLocalFiles() throws SQLException { + return false; + } - public boolean usesLocalFilePerTable() throws SQLException { - return false; - } + public boolean usesLocalFilePerTable() throws SQLException { + return false; + } - public boolean supportsMixedCaseIdentifiers() throws SQLException { - return false; - } + public boolean supportsMixedCaseIdentifiers() throws SQLException { + return false; + } - public boolean storesUpperCaseIdentifiers() throws SQLException { - return false; - } + public boolean storesUpperCaseIdentifiers() throws SQLException { + return false; + } - public boolean storesLowerCaseIdentifiers() throws SQLException { - return false; - } + public boolean storesLowerCaseIdentifiers() throws SQLException { + return false; + } - public boolean storesMixedCaseIdentifiers() throws SQLException { - return false; - } + public boolean storesMixedCaseIdentifiers() throws SQLException { + return false; + } - public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { - return false; - } + public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { + return false; + } - public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { - return false; - } + public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { + return false; + } - public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { - return false; - } + public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { + return false; + } - public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { - return false; - } + public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { + return false; + } - public String getIdentifierQuoteString() throws SQLException { - return " "; - } + public String getIdentifierQuoteString() throws SQLException { + return " "; + } - public String getSQLKeywords() throws SQLException { - return null; - } + public String getSQLKeywords() throws SQLException { + return null; + } - public String getNumericFunctions() throws SQLException { - return null; - } + public String getNumericFunctions() throws SQLException { + return null; + } - public String getStringFunctions() throws SQLException { - return null; - } + public String getStringFunctions() throws SQLException { + return null; + } - public String getSystemFunctions() throws SQLException { - return null; - } + public String getSystemFunctions() throws SQLException { + return null; + } - public String getTimeDateFunctions() throws SQLException { - return null; - } + public String getTimeDateFunctions() throws SQLException { + return null; + } - public String getSearchStringEscape() throws SQLException { - return null; - } + public String getSearchStringEscape() throws SQLException { + return null; + } - public String getExtraNameCharacters() throws SQLException { - return null; - } + public String getExtraNameCharacters() throws SQLException { + return null; + } - public boolean supportsAlterTableWithAddColumn() throws SQLException { - return true; - } + public boolean supportsAlterTableWithAddColumn() throws SQLException { + return true; + } - public boolean supportsAlterTableWithDropColumn() throws SQLException { - return true; - } + public boolean supportsAlterTableWithDropColumn() throws SQLException { + return true; + } - public boolean supportsColumnAliasing() throws SQLException { - return true; - } + public boolean supportsColumnAliasing() throws SQLException { + return true; + } - public boolean nullPlusNonNullIsNull() throws SQLException { - return false; - } + public boolean nullPlusNonNullIsNull() throws SQLException { + return false; + } - public boolean supportsConvert() throws SQLException { - return false; - } + public boolean supportsConvert() throws SQLException { + return false; + } - public boolean supportsConvert(int fromType, int toType) throws SQLException { - return false; - } + public boolean supportsConvert(int fromType, int toType) throws SQLException { + return false; + } - public boolean supportsTableCorrelationNames() throws SQLException { - return false; - } + public boolean supportsTableCorrelationNames() throws SQLException { + return false; + } - public boolean supportsDifferentTableCorrelationNames() throws SQLException { - return false; - } + public boolean supportsDifferentTableCorrelationNames() throws SQLException { + return false; + } - public boolean supportsExpressionsInOrderBy() throws SQLException { - return false; - } + public boolean supportsExpressionsInOrderBy() throws SQLException { + return false; + } - public boolean supportsOrderByUnrelated() throws SQLException { - return false; - } + public boolean supportsOrderByUnrelated() throws SQLException { + return false; + } - public boolean supportsGroupBy() throws SQLException { - return false; - } + public boolean supportsGroupBy() throws SQLException { + return false; + } - public boolean supportsGroupByUnrelated() throws SQLException { - return false; - } + public boolean supportsGroupByUnrelated() throws SQLException { + return false; + } - public boolean supportsGroupByBeyondSelect() throws SQLException { - return false; - } + public boolean supportsGroupByBeyondSelect() throws SQLException { + return false; + } - public boolean supportsLikeEscapeClause() throws SQLException { - return false; - } + public boolean supportsLikeEscapeClause() throws SQLException { + return false; + } - public boolean supportsMultipleResultSets() throws SQLException { - return false; - } + public boolean supportsMultipleResultSets() throws SQLException { + return false; + } - public boolean supportsMultipleTransactions() throws SQLException { - return false; - } + public boolean supportsMultipleTransactions() throws SQLException { + return false; + } - public boolean supportsNonNullableColumns() throws SQLException { - return false; - } + public boolean supportsNonNullableColumns() throws SQLException { + return false; + } - public boolean supportsMinimumSQLGrammar() throws SQLException { - return false; - } + public boolean supportsMinimumSQLGrammar() throws SQLException { + return false; + } - public boolean supportsCoreSQLGrammar() throws SQLException { - return false; - } + public boolean supportsCoreSQLGrammar() throws SQLException { + return false; + } - public boolean supportsExtendedSQLGrammar() throws SQLException { - return false; - } + public boolean supportsExtendedSQLGrammar() throws SQLException { + return false; + } - public boolean supportsANSI92EntryLevelSQL() throws SQLException { - return false; - } + public boolean supportsANSI92EntryLevelSQL() throws SQLException { + return false; + } - public boolean supportsANSI92IntermediateSQL() throws SQLException { - return false; - } + public boolean supportsANSI92IntermediateSQL() throws SQLException { + return false; + } - public boolean supportsANSI92FullSQL() throws SQLException { - return false; - } + public boolean supportsANSI92FullSQL() throws SQLException { + return false; + } - public boolean supportsIntegrityEnhancementFacility() throws SQLException { - return false; - } + public boolean supportsIntegrityEnhancementFacility() throws SQLException { + return false; + } - public boolean supportsOuterJoins() throws SQLException { - return false; - } + public boolean supportsOuterJoins() throws SQLException { + return false; + } - public boolean supportsFullOuterJoins() throws SQLException { - return false; - } + public boolean supportsFullOuterJoins() throws SQLException { + return false; + } - public boolean supportsLimitedOuterJoins() throws SQLException { - return false; - } + public boolean supportsLimitedOuterJoins() throws SQLException { + return false; + } - public String getSchemaTerm() throws SQLException { - return null; - } + public String getSchemaTerm() throws SQLException { + return null; + } - public String getProcedureTerm() throws SQLException { - return null; - } + public String getProcedureTerm() throws SQLException { + return null; + } - public String getCatalogTerm() throws SQLException { - return "database"; - } + public String getCatalogTerm() throws SQLException { + return "database"; + } - public boolean isCatalogAtStart() throws SQLException { - return true; - } + public boolean isCatalogAtStart() throws SQLException { + return true; + } - public String getCatalogSeparator() throws SQLException { - return "."; - } + public String getCatalogSeparator() throws SQLException { + return "."; + } - public boolean supportsSchemasInDataManipulation() throws SQLException { - return false; - } + public boolean supportsSchemasInDataManipulation() throws SQLException { + return false; + } - public boolean supportsSchemasInProcedureCalls() throws SQLException { - return false; - } + public boolean supportsSchemasInProcedureCalls() throws SQLException { + return false; + } - public boolean supportsSchemasInTableDefinitions() throws SQLException { - return false; - } + public boolean supportsSchemasInTableDefinitions() throws SQLException { + return false; + } - public boolean supportsSchemasInIndexDefinitions() throws SQLException { - return false; - } + public boolean supportsSchemasInIndexDefinitions() throws SQLException { + return false; + } - public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException { - return false; - } + public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException { + return false; + } - public boolean supportsCatalogsInDataManipulation() throws SQLException { - return true; - } + public boolean supportsCatalogsInDataManipulation() throws SQLException { + return true; + } - public boolean supportsCatalogsInProcedureCalls() throws SQLException { - return false; - } + public boolean supportsCatalogsInProcedureCalls() throws SQLException { + return false; + } - public boolean supportsCatalogsInTableDefinitions() throws SQLException { - return false; - } + public boolean supportsCatalogsInTableDefinitions() throws SQLException { + return false; + } - public boolean supportsCatalogsInIndexDefinitions() throws SQLException { - return false; - } + public boolean supportsCatalogsInIndexDefinitions() throws SQLException { + return false; + } - public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException { - return false; - } + public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException { + return false; + } - public boolean supportsPositionedDelete() throws SQLException { - return false; - } + public boolean supportsPositionedDelete() throws SQLException { + return false; + } - public boolean supportsPositionedUpdate() throws SQLException { - return false; - } + public boolean supportsPositionedUpdate() throws SQLException { + return false; + } - public boolean supportsSelectForUpdate() throws SQLException { - return false; - } + public boolean supportsSelectForUpdate() throws SQLException { + return false; + } - public boolean supportsStoredProcedures() throws SQLException { - return false; - } + public boolean supportsStoredProcedures() throws SQLException { + return false; + } - public boolean supportsSubqueriesInComparisons() throws SQLException { - return false; - } + public boolean supportsSubqueriesInComparisons() throws SQLException { + return false; + } - public boolean supportsSubqueriesInExists() throws SQLException { - return false; - } + public boolean supportsSubqueriesInExists() throws SQLException { + return false; + } - public boolean supportsSubqueriesInIns() throws SQLException { - return false; - } + public boolean supportsSubqueriesInIns() throws SQLException { + return false; + } - public boolean supportsSubqueriesInQuantifieds() throws SQLException { - return false; - } + public boolean supportsSubqueriesInQuantifieds() throws SQLException { + return false; + } - public boolean supportsCorrelatedSubqueries() throws SQLException { - return false; - } + public boolean supportsCorrelatedSubqueries() throws SQLException { + return false; + } - public boolean supportsUnion() throws SQLException { - return false; - } + public boolean supportsUnion() throws SQLException { + return false; + } - public boolean supportsUnionAll() throws SQLException { - return false; - } + public boolean supportsUnionAll() throws SQLException { + return false; + } - public boolean supportsOpenCursorsAcrossCommit() throws SQLException { - return false; - } + public boolean supportsOpenCursorsAcrossCommit() throws SQLException { + return false; + } - public boolean supportsOpenCursorsAcrossRollback() throws SQLException { - return false; - } + public boolean supportsOpenCursorsAcrossRollback() throws SQLException { + return false; + } - public boolean supportsOpenStatementsAcrossCommit() throws SQLException { - return false; - } + public boolean supportsOpenStatementsAcrossCommit() throws SQLException { + return false; + } - public boolean supportsOpenStatementsAcrossRollback() throws SQLException { - return false; - } + public boolean supportsOpenStatementsAcrossRollback() throws SQLException { + return false; + } - public int getMaxBinaryLiteralLength() throws SQLException { - return 0; - } + public int getMaxBinaryLiteralLength() throws SQLException { + return 0; + } - public int getMaxCharLiteralLength() throws SQLException { - return 0; - } + public int getMaxCharLiteralLength() throws SQLException { + return 0; + } - public int getMaxColumnNameLength() throws SQLException { - return 0; - } + public int getMaxColumnNameLength() throws SQLException { + return 0; + } - public int getMaxColumnsInGroupBy() throws SQLException { - return 0; - } + public int getMaxColumnsInGroupBy() throws SQLException { + return 0; + } - public int getMaxColumnsInIndex() throws SQLException { - return 0; - } + public int getMaxColumnsInIndex() throws SQLException { + return 0; + } - public int getMaxColumnsInOrderBy() throws SQLException { - return 0; - } + public int getMaxColumnsInOrderBy() throws SQLException { + return 0; + } - public int getMaxColumnsInSelect() throws SQLException { - return 0; - } - - public int getMaxColumnsInTable() throws SQLException { - return 0; - } - - public int getMaxConnections() throws SQLException { - return 0; - } - - public int getMaxCursorNameLength() throws SQLException { - return 0; - } - - public int getMaxIndexLength() throws SQLException { - return 0; - } - - public int getMaxSchemaNameLength() throws SQLException { - return 0; - } - - public int getMaxProcedureNameLength() throws SQLException { - return 0; - } - - public int getMaxCatalogNameLength() throws SQLException { - return 0; - } - - public int getMaxRowSize() throws SQLException { - return 0; - } - - public boolean doesMaxRowSizeIncludeBlobs() throws SQLException { - return false; - } - - public int getMaxStatementLength() throws SQLException { - return 0; - } - - public int getMaxStatements() throws SQLException { - return 0; - } - - public int getMaxTableNameLength() throws SQLException { - return 0; - } - - public int getMaxTablesInSelect() throws SQLException { - return 0; - } - - public int getMaxUserNameLength() throws SQLException { - return 0; - } - - public int getDefaultTransactionIsolation() throws SQLException { - return 0; - } - - public boolean supportsTransactions() throws SQLException { - return false; - } - - public boolean supportsTransactionIsolationLevel(int level) throws SQLException { - return false; - } - - public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException { - return false; - } - - public boolean supportsDataManipulationTransactionsOnly() throws SQLException { - return false; - } - - public boolean dataDefinitionCausesTransactionCommit() throws SQLException { - return false; - } - - public boolean dataDefinitionIgnoredInTransactions() throws SQLException { - return false; - } - - public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) - throws SQLException { - throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); - } - - public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, - String columnNamePattern) throws SQLException { - throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); - } - - public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) - throws SQLException { - Statement stmt = null; - if (null != conn && !conn.isClosed()) { - stmt = conn.createStatement(); - if (catalog == null || catalog.length() < 1) { - catalog = conn.getCatalog(); - } + public int getMaxColumnsInSelect() throws SQLException { + return 0; + } + + public int getMaxColumnsInTable() throws SQLException { + return 0; + } + + public int getMaxConnections() throws SQLException { + return 0; + } + + public int getMaxCursorNameLength() throws SQLException { + return 0; + } + + public int getMaxIndexLength() throws SQLException { + return 0; + } + + public int getMaxSchemaNameLength() throws SQLException { + return 0; + } + + public int getMaxProcedureNameLength() throws SQLException { + return 0; + } + + public int getMaxCatalogNameLength() throws SQLException { + return 0; + } + + public int getMaxRowSize() throws SQLException { + return 0; + } + + public boolean doesMaxRowSizeIncludeBlobs() throws SQLException { + return false; + } + + public int getMaxStatementLength() throws SQLException { + return 0; + } + + public int getMaxStatements() throws SQLException { + return 0; + } + + public int getMaxTableNameLength() throws SQLException { + return 0; + } + + public int getMaxTablesInSelect() throws SQLException { + return 0; + } + + public int getMaxUserNameLength() throws SQLException { + return 0; + } + + public int getDefaultTransactionIsolation() throws SQLException { + return 0; + } + + public boolean supportsTransactions() throws SQLException { + return false; + } + + public boolean supportsTransactionIsolationLevel(int level) throws SQLException { + return false; + } + + public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException { + return false; + } + + public boolean supportsDataManipulationTransactionsOnly() throws SQLException { + return false; + } + + public boolean dataDefinitionCausesTransactionCommit() throws SQLException { + return false; + } + + public boolean dataDefinitionIgnoredInTransactions() throws SQLException { + return false; + } + + public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) + throws SQLException { + throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); + } + + public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, + String columnNamePattern) throws SQLException { + throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); + } + + public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) + throws SQLException { + Statement stmt = null; + if (null != conn && !conn.isClosed()) { + stmt = conn.createStatement(); + if (catalog == null || catalog.length() < 1) { + catalog = conn.getCatalog(); + } stmt.executeUpdate("use " + catalog); ResultSet resultSet0 = stmt.executeQuery("show tables"); GetTablesResultSet getTablesResultSet = new GetTablesResultSet(resultSet0, catalog, schemaPattern, tableNamePattern, types); @@ -540,29 +540,29 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { } else { throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); } - } + } - public ResultSet getSchemas() throws SQLException { - return getEmptyResultSet(); - } + public ResultSet getSchemas() throws SQLException { + return getEmptyResultSet(); + } - public ResultSet getCatalogs() throws SQLException { + public ResultSet getCatalogs() throws SQLException { - if (conn != null && !conn.isClosed()) { - Statement stmt = conn.createStatement(); - ResultSet resultSet0 = stmt.executeQuery("show databases"); - CatalogResultSet resultSet = new CatalogResultSet(resultSet0); - return resultSet; - } else { - return getEmptyResultSet(); + if (conn != null && !conn.isClosed()) { + Statement stmt = conn.createStatement(); + ResultSet resultSet0 = stmt.executeQuery("show databases"); + CatalogResultSet resultSet = new CatalogResultSet(resultSet0); + return resultSet; + } else { + return getEmptyResultSet(); } - } + } - public ResultSet getTableTypes() throws SQLException { - DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); + public ResultSet getTableTypes() throws SQLException { + DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); - // set up ColumnMetaDataList - List columnMetaDataList = new ArrayList(1); + // set up ColumnMetaDataList + List columnMetaDataList = new ArrayList(1); ColumnMetaData colMetaData = new ColumnMetaData(); colMetaData.setColIndex(0); colMetaData.setColName("TABLE_TYPE"); @@ -582,220 +582,383 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { resultSet.setColumnMetaDataList(columnMetaDataList); resultSet.setRowDataList(rowDataList); return resultSet; - } - - public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) - throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) - throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) - throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) - throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, - String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getTypeInfo() throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) - throws SQLException { - return getEmptyResultSet(); - } - - public boolean supportsResultSetType(int type) throws SQLException { - return false; - } - - public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException { - return false; - } - - public boolean ownUpdatesAreVisible(int type) throws SQLException { - return false; - } - - public boolean ownDeletesAreVisible(int type) throws SQLException { - return false; - } - - public boolean ownInsertsAreVisible(int type) throws SQLException { - return false; - } - - public boolean othersUpdatesAreVisible(int type) throws SQLException { - return false; - } - - public boolean othersDeletesAreVisible(int type) throws SQLException { - return false; - } - - public boolean othersInsertsAreVisible(int type) throws SQLException { - return false; - } - - public boolean updatesAreDetected(int type) throws SQLException { - return false; - } - - public boolean deletesAreDetected(int type) throws SQLException { - return false; - } - - public boolean insertsAreDetected(int type) throws SQLException { - return false; - } - - public boolean supportsBatchUpdates() throws SQLException { - return false; - } - - public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) - throws SQLException { - return getEmptyResultSet(); - } - - public Connection getConnection() throws SQLException { - return null; - } - - public boolean supportsSavepoints() throws SQLException { - return false; - } - - public boolean supportsNamedParameters() throws SQLException { - return false; - } - - public boolean supportsMultipleOpenResults() throws SQLException { - return false; - } - - public boolean supportsGetGeneratedKeys() throws SQLException { - return false; - } - - public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, - String attributeNamePattern) throws SQLException { - return getEmptyResultSet(); - } - - public boolean supportsResultSetHoldability(int holdability) throws SQLException { - return false; - } - - public int getResultSetHoldability() throws SQLException { - return 0; - } - - public int getDatabaseMajorVersion() throws SQLException { - return 0; - } - - public int getDatabaseMinorVersion() throws SQLException { - return 0; - } - - public int getJDBCMajorVersion() throws SQLException { - return 0; - } - - public int getJDBCMinorVersion() throws SQLException { - return 0; - } - - public int getSQLStateType() throws SQLException { - return 0; - } - - public boolean locatorsUpdateCopy() throws SQLException { - return false; - } - - public boolean supportsStatementPooling() throws SQLException { - return false; - } - - public RowIdLifetime getRowIdLifetime() throws SQLException { - return null; - } - - public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException { - return null; - } - - public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException { - return false; - } - - public boolean autoCommitFailureClosesAllResultSets() throws SQLException { - return false; - } - - public ResultSet getClientInfoProperties() throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) - throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, - String columnNamePattern) throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, - String columnNamePattern) throws SQLException { - return getEmptyResultSet(); - } - - public boolean generatedKeyAlwaysReturned() throws SQLException { - return false; - } - - private ResultSet getEmptyResultSet() { - return new EmptyResultSet(); - } + } + + public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) + throws SQLException { + + /** add by zyyang **********/ + Statement stmt = null; + if (null != conn && !conn.isClosed()) { + stmt = conn.createStatement(); + if (catalog == null || catalog.length() < 1) { + catalog = conn.getCatalog(); + } + stmt.executeUpdate("use " + catalog); + + DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); + // set up ColumnMetaDataList + List columnMetaDataList = new ArrayList<>(24); + columnMetaDataList.add(null); + columnMetaDataList.add(null); + // add TABLE_NAME + ColumnMetaData colMetaData = new ColumnMetaData(); + colMetaData.setColIndex(3); + colMetaData.setColName("TABLE_NAME"); + colMetaData.setColSize(193); + colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_BINARY); + columnMetaDataList.add(colMetaData); + // add COLUMN_NAME + colMetaData = new ColumnMetaData(); + colMetaData.setColIndex(4); + colMetaData.setColName("COLUMN_NAME"); + colMetaData.setColSize(65); + colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_BINARY); + columnMetaDataList.add(colMetaData); + // add DATA_TYPE + colMetaData = new ColumnMetaData(); + colMetaData.setColIndex(5); + colMetaData.setColName("DATA_TYPE"); + colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(colMetaData); + // add TYPE_NAME + colMetaData = new ColumnMetaData(); + colMetaData.setColIndex(6); + colMetaData.setColName("TYPE_NAME"); + colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_BINARY); + columnMetaDataList.add(colMetaData); + // add COLUMN_SIZE + colMetaData = new ColumnMetaData(); + colMetaData.setColIndex(7); + colMetaData.setColName("COLUMN_SIZE"); + colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(colMetaData); + // add BUFFER_LENGTH ,not used + columnMetaDataList.add(null); + // add DECIMAL_DIGITS + colMetaData = new ColumnMetaData(); + colMetaData.setColIndex(9); + colMetaData.setColName("DECIMAL_DIGITS"); + colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(colMetaData); + // add NUM_PREC_RADIX + colMetaData = new ColumnMetaData(); + colMetaData.setColIndex(10); + colMetaData.setColName("NUM_PREC_RADIX"); + colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(colMetaData); + // add NULLABLE + colMetaData = new ColumnMetaData(); + colMetaData.setColIndex(11); + colMetaData.setColName("NULLABLE"); + colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(colMetaData); + + resultSet.setColumnMetaDataList(columnMetaDataList); + + // set up rowDataList + ResultSet resultSet0 = stmt.executeQuery("describe " + tableNamePattern); + List rowDataList = new ArrayList<>(); + int index = 0; + while (resultSet0.next()) { + TSDBResultSetRowData rowData = new TSDBResultSetRowData(24); + // set TABLE_NAME + rowData.setString(2, tableNamePattern); + // set COLUMN_NAME + rowData.setString(3, resultSet0.getString(1)); + // set DATA_TYPE + String typeName = resultSet0.getString(2); + rowData.setInt(4, getDataType(typeName)); + // set TYPE_NAME + rowData.setString(5, typeName); + // set COLUMN_SIZE + int length = resultSet0.getInt(3); + rowData.setInt(6, getColumnSize(typeName, length)); + // set DECIMAL_DIGITS + rowData.setInt(8, getDecimalDigits(typeName)); + // set NUM_PREC_RADIX + rowData.setInt(9, 10); + // set NULLABLE + rowData.setInt(10, getNullable(index, typeName)); + rowDataList.add(rowData); + index++; + } + resultSet.setRowDataList(rowDataList); + +// GetColumnsResultSet getColumnsResultSet = new GetColumnsResultSet(resultSet0, catalog, schemaPattern, tableNamePattern, columnNamePattern); +// return getColumnsResultSet; +// DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); + return resultSet; + } else { + throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); + } + + /*************************/ + +// return getEmptyResultSet(); + } + + private int getNullable(int index, String typeName) { + if (index == 0 && "TIMESTAMP".equals(typeName)) + return DatabaseMetaData.columnNoNulls; + return DatabaseMetaData.columnNullable; + } + + private int getColumnSize(String typeName, int length) { + switch (typeName) { + case "TIMESTAMP": + return 23; + + default: + return 0; + } + } + + private int getDecimalDigits(String typeName) { + switch (typeName) { + case "FLOAT": + return 5; + case "DOUBLE": + return 9; + default: + return 0; + } + } + + private int getDataType(String typeName) { + switch (typeName) { + case "TIMESTAMP": + return Types.TIMESTAMP; + case "INT": + return Types.INTEGER; + case "BIGINT": + return Types.BIGINT; + case "FLOAT": + return Types.FLOAT; + case "DOUBLE": + return Types.DOUBLE; + case "BINARY": + return Types.BINARY; + case "SMALLINT": + return Types.SMALLINT; + case "TINYINT": + return Types.TINYINT; + case "BOOL": + return Types.BOOLEAN; + case "NCHAR": + return Types.NCHAR; + default: + return Types.NULL; + } + } + + public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) + throws SQLException { + return getEmptyResultSet(); + } + + public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) + throws SQLException { + return getEmptyResultSet(); + } + + public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) + throws SQLException { + return getEmptyResultSet(); + } + + public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException { + return getEmptyResultSet(); + } + + public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException { + return getEmptyResultSet(); + } + + public ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException { + return getEmptyResultSet(); + } + + public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException { + return getEmptyResultSet(); + } + + public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, + String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException { + return getEmptyResultSet(); + } + + public ResultSet getTypeInfo() throws SQLException { + return getEmptyResultSet(); + } + + public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) + throws SQLException { + return getEmptyResultSet(); + } + + public boolean supportsResultSetType(int type) throws SQLException { + return false; + } + + public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException { + return false; + } + + public boolean ownUpdatesAreVisible(int type) throws SQLException { + return false; + } + + public boolean ownDeletesAreVisible(int type) throws SQLException { + return false; + } + + public boolean ownInsertsAreVisible(int type) throws SQLException { + return false; + } + + public boolean othersUpdatesAreVisible(int type) throws SQLException { + return false; + } + + public boolean othersDeletesAreVisible(int type) throws SQLException { + return false; + } + + public boolean othersInsertsAreVisible(int type) throws SQLException { + return false; + } + + public boolean updatesAreDetected(int type) throws SQLException { + return false; + } + + public boolean deletesAreDetected(int type) throws SQLException { + return false; + } + + public boolean insertsAreDetected(int type) throws SQLException { + return false; + } + + public boolean supportsBatchUpdates() throws SQLException { + return false; + } + + public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) + throws SQLException { + return getEmptyResultSet(); + } + + public Connection getConnection() throws SQLException { + return null; + } + + public boolean supportsSavepoints() throws SQLException { + return false; + } + + public boolean supportsNamedParameters() throws SQLException { + return false; + } + + public boolean supportsMultipleOpenResults() throws SQLException { + return false; + } + + public boolean supportsGetGeneratedKeys() throws SQLException { + return false; + } + + public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException { + return getEmptyResultSet(); + } + + public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException { + return getEmptyResultSet(); + } + + public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, + String attributeNamePattern) throws SQLException { + return getEmptyResultSet(); + } + + public boolean supportsResultSetHoldability(int holdability) throws SQLException { + return false; + } + + public int getResultSetHoldability() throws SQLException { + return 0; + } + + public int getDatabaseMajorVersion() throws SQLException { + return 0; + } + + public int getDatabaseMinorVersion() throws SQLException { + return 0; + } + + public int getJDBCMajorVersion() throws SQLException { + return 0; + } + + public int getJDBCMinorVersion() throws SQLException { + return 0; + } + + public int getSQLStateType() throws SQLException { + return 0; + } + + public boolean locatorsUpdateCopy() throws SQLException { + return false; + } + + public boolean supportsStatementPooling() throws SQLException { + return false; + } + + public RowIdLifetime getRowIdLifetime() throws SQLException { + return null; + } + + public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException { + return null; + } + + public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException { + return false; + } + + public boolean autoCommitFailureClosesAllResultSets() throws SQLException { + return false; + } + + public ResultSet getClientInfoProperties() throws SQLException { + return getEmptyResultSet(); + } + + public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) + throws SQLException { + return getEmptyResultSet(); + } + + public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, + String columnNamePattern) throws SQLException { + return getEmptyResultSet(); + } + + public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, + String columnNamePattern) throws SQLException { + return getEmptyResultSet(); + } + + public boolean generatedKeyAlwaysReturned() throws SQLException { + return false; + } + + private ResultSet getEmptyResultSet() { + return new EmptyResultSet(); + } } \ No newline at end of file diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java index bc649a31e1e4c56289284885a73469695ae4eae2..97d93fb0a18fa887465583bce1492c8305faaec5 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java @@ -179,7 +179,7 @@ public class TSDBDriver implements java.sql.Driver { } //load taos.cfg start - if (info.getProperty(TSDBDriver.PROPERTY_KEY_HOST) == null && info.getProperty(TSDBDriver.PROPERTY_KEY_PORT) == null){ + if (info.getProperty(TSDBDriver.PROPERTY_KEY_HOST) == null && info.getProperty(TSDBDriver.PROPERTY_KEY_PORT) == null) { File cfgDir = loadConfigDir(info.getProperty(TSDBDriver.PROPERTY_KEY_CONFIG_DIR)); File cfgFile = cfgDir.listFiles((dir, name) -> "taos.cfg".equalsIgnoreCase(name))[0]; List endpoints = loadConfigEndpoints(cfgFile); @@ -244,7 +244,7 @@ public class TSDBDriver implements java.sql.Driver { } public boolean acceptsURL(String url) throws SQLException { - return (url != null && url.length() > 0 && url.trim().length() > 0) && url.toLowerCase().startsWith(URL_PREFIX); + return (url != null && url.length() > 0 && url.trim().length() > 0) && url.startsWith(URL_PREFIX); } public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { @@ -291,8 +291,7 @@ public class TSDBDriver implements java.sql.Driver { return null; } - String lowerUrl = url.toLowerCase(); - if (!lowerUrl.startsWith(URL_PREFIX) && !lowerUrl.startsWith(URL_PREFIX1)) { + if (!url.startsWith(URL_PREFIX) && !url.startsWith(URL_PREFIX1)) { return null; } diff --git a/src/connector/odbc/CMakeLists.txt b/src/connector/odbc/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..58e7b6acf1f8424c8b8f72578a9ece027d1a9447 --- /dev/null +++ b/src/connector/odbc/CMakeLists.txt @@ -0,0 +1,33 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +PROJECT(TDengine) + +IF (TD_LINUX_64) + find_program(HAVE_ODBCINST NAMES odbcinst) + + IF (HAVE_ODBCINST) + include(CheckSymbolExists) + # shall we revert CMAKE_REQUIRED_LIBRARIES and how? + set(CMAKE_REQUIRED_LIBRARIES odbc) + check_symbol_exists(SQLExecute "sql.h" HAVE_ODBC_DEV) + if(NOT (HAVE_ODBC_DEV)) + unset(HAVE_ODBC_DEV CACHE) + message(WARNING "unixodbc-dev is not installed yet, you may install it under ubuntu by typing: sudo apt install unixodbc-dev") + else () + message(STATUS "unixodbc/unixodbc-dev are installed, and odbc connector will be built") + AUX_SOURCE_DIRECTORY(src SRC) + + # generate dynamic library (*.so) + ADD_LIBRARY(todbc SHARED ${SRC}) + SET_TARGET_PROPERTIES(todbc PROPERTIES CLEAN_DIRECT_OUTPUT 1) + SET_TARGET_PROPERTIES(todbc PROPERTIES VERSION ${TD_VER_NUMBER} SOVERSION 1) + TARGET_LINK_LIBRARIES(todbc taos) + + install(CODE "execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/src/install.sh ${CMAKE_BINARY_DIR})") + + ADD_SUBDIRECTORY(tests) + endif() + ELSE () + message(WARNING "unixodbc is not installed yet, you may install it under ubuntu by typing: sudo apt install unixodbc") + ENDIF () +ENDIF () + diff --git a/src/connector/odbc/src/install.sh b/src/connector/odbc/src/install.sh new file mode 100755 index 0000000000000000000000000000000000000000..b8c04677c7199384f7bc0b66515eb04d0fe560fc --- /dev/null +++ b/src/connector/odbc/src/install.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -u + +BLD_DIR="$1" + +rm -f "${BLD_DIR}/template.ini" +rm -f "${BLD_DIR}/template.dsn" + +cat > "${BLD_DIR}/template.ini" < "${BLD_DIR}/template.dsn" < + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +// #define _BSD_SOURCE +#define _XOPEN_SOURCE +#define _DEFAULT_SOURCE + +#include "taos.h" + +#include "os.h" +#include "taoserror.h" +#include "todbc_util.h" + +#include +#include + +#include + + +#define GET_REF(obj) atomic_load_64(&obj->refcount) +#define INC_REF(obj) atomic_add_fetch_64(&obj->refcount, 1) +#define DEC_REF(obj) atomic_sub_fetch_64(&obj->refcount, 1) + +#define LOCK(obj) pthread_mutex_lock(&obj->lock); +#define UNLOCK(obj) pthread_mutex_unlock(&obj->lock); + +#define SET_ERROR(obj, sqlstate, eno, err_fmt, ...) \ +do { \ + obj->err.err_no = eno; \ + const char* estr = tstrerror(eno); \ + if (!estr) estr = "Unknown error"; \ + int n = snprintf(NULL, 0, "%s: @[%d][TSDB:%x]" err_fmt "", estr, __LINE__, eno, ##__VA_ARGS__); \ + if (n<0) break; \ + char *err_str = (char*)realloc(obj->err.err_str, n+1); \ + if (!err_str) break; \ + obj->err.err_str = err_str; \ + snprintf(obj->err.err_str, n+1, "%s: @[%d][TSDB:%x]" err_fmt "", estr, __LINE__, eno, ##__VA_ARGS__); \ + snprintf((char*)obj->err.sql_state, sizeof(obj->err.sql_state), "%s", sqlstate); \ +} while (0) + +#define CLR_ERROR(obj) \ +do { \ + obj->err.err_no = TSDB_CODE_SUCCESS; \ + if (obj->err.err_str) obj->err.err_str[0] = '\0'; \ + obj->err.sql_state[0] = '\0'; \ +} while (0) + +#define FILL_ERROR(obj) \ +do { \ + size_t n = sizeof(obj->err.sql_state); \ + if (Sqlstate) strncpy((char*)Sqlstate, (char*)obj->err.sql_state, n); \ + if (NativeError) *NativeError = obj->err.err_no; \ + snprintf((char*)MessageText, BufferLength, "%s", obj->err.err_str); \ + if (TextLength && obj->err.err_str) *TextLength = strlen(obj->err.err_str); \ + if (TextLength && obj->err.err_str) *TextLength = utf8_chars(obj->err.err_str); \ +} while (0) + +#define FREE_ERROR(obj) \ +do { \ + obj->err.err_no = TSDB_CODE_SUCCESS; \ + if (obj->err.err_str) { \ + free(obj->err.err_str); \ + obj->err.err_str = NULL; \ + } \ + obj->err.sql_state[0] = '\0'; \ +} while (0) + +#define SET_UNSUPPORT_ERROR(obj, sqlstate, err_fmt, ...) \ +do { \ + SET_ERROR(obj, sqlstate, TSDB_CODE_ODBC_NOT_SUPPORT, err_fmt, ##__VA_ARGS__); \ +} while (0) \ + +#define SET_HANDLE_INVALID(obj, sqlstate, err_fmt, ...) \ +do { \ + SET_ERROR(obj, sqlstate, TSDB_CODE_QRY_INVALID_QHANDLE, err_fmt, ##__VA_ARGS__); \ +} while (0); + +#define SDUP(s,n) (s ? (s[n] ? (const char*)strndup((const char*)s,n) : (const char*)s) : strdup("")) +#define SFRE(x,s,n) \ +do { \ + if (x==(const char*)s) break; \ + if (x) { \ + free((char*)x); \ + x = NULL; \ + } \ +} while (0) + +#define CHK_CONN(obj) \ +do { \ + if (!obj->conn) { \ + SET_ERROR(obj, "HY000", TSDB_CODE_ODBC_INVALID_HANDLE, "connection closed or not ready"); \ + return SQL_ERROR; \ + } \ +} while (0); + +#define CHK_CONN_TAOS(obj) \ +do { \ + if (!obj->conn->taos) { \ + SET_ERROR(obj, "HY000", TSDB_CODE_ODBC_INVALID_HANDLE, "connection to data source closed or not ready"); \ + return SQL_ERROR; \ + } \ +} while (0); + +#define CHK_RS(r_091c, sql_091c, fmt_091c, ...) \ +do { \ + r_091c = SQL_ERROR; \ + int e = sql_091c->rs ? taos_errno(sql_091c->rs) : terrno; \ + if (e != TSDB_CODE_SUCCESS) { \ + SET_ERROR(sql_091c, "HY000", e, fmt_091c, ##__VA_ARGS__); \ + break; \ + } \ + r_091c = SQL_SUCCESS; \ +} while (0) + +#define PROFILING 0 + +#define PROFILE(statement) \ +do { \ + if (!PROFILING) { \ + statement; \ + break; \ + } \ + struct timeval tv0, tv1; \ + gettimeofday(&tv0, NULL); \ + statement; \ + gettimeofday(&tv1, NULL); \ + double delta = difftime(tv1.tv_sec, tv0.tv_sec); \ + delta *= 1000000; \ + delta += (tv1.tv_usec-tv0.tv_usec); \ + delta /= 1000000; \ + D("%s: elapsed: [%.6f]s", #statement, delta); \ +} while (0) + + +#define CHK_CONV(statement) \ +do { \ + const char *sqlstate = statement; \ + if (sqlstate) { \ + SET_ERROR(sql, sqlstate, TSDB_CODE_ODBC_OUT_OF_RANGE, \ + "no convertion from [%s[%d/0x%x]] to [%s[%d/0x%x]] for parameter [%d]", \ + sql_c_type(valueType), valueType, valueType, \ + taos_data_type(type), type, type, idx+1); \ + return SQL_ERROR; \ + } \ +} while (0) + +typedef struct env_s env_t; +typedef struct conn_s conn_t; +typedef struct sql_s sql_t; +typedef struct taos_error_s taos_error_t; +typedef struct param_bind_s param_bind_t; + +struct param_bind_s { + SQLUSMALLINT ParameterNumber; + SQLSMALLINT ValueType; + SQLSMALLINT ParameterType; + SQLULEN LengthPrecision; + SQLSMALLINT ParameterScale; + SQLPOINTER ParameterValue; + SQLLEN *StrLen_or_Ind; + + unsigned int valid; +}; + +struct taos_error_s { + char *err_str; + int err_no; + + SQLCHAR sql_state[6]; +}; + +struct env_s { + uint64_t refcount; + unsigned int destroying:1; + + taos_error_t err; +}; + +struct conn_s { + uint64_t refcount; + env_t *env; + + TAOS *taos; + + taos_error_t err; +}; + +struct sql_s { + uint64_t refcount; + conn_t *conn; + + TAOS_STMT *stmt; + param_bind_t *params; + int n_params; + size_t rowlen; + size_t n_rows; + size_t ptr_offset; + + TAOS_RES *rs; + TAOS_ROW row; + + taos_error_t err; + unsigned int is_prepared:1; + unsigned int is_insert:1; + unsigned int is_executed:1; +}; + +typedef struct c_target_s c_target_t; +struct c_target_s { + SQLUSMALLINT col; + SQLSMALLINT ct; // c type: SQL_C_XXX + char *ptr; + SQLLEN len; + SQLLEN *soi; +}; + +static pthread_once_t init_once = PTHREAD_ONCE_INIT; +static void init_routine(void); + +// conversions + +const char* tsdb_int64_to_bit(int64_t src, int8_t *dst); +const char* tsdb_int64_to_tinyint(int64_t src, int8_t *dst); +const char* tsdb_int64_to_smallint(int64_t src, int16_t *dst); +const char* tsdb_int64_to_int(int64_t src, int32_t *dst); +const char* tsdb_int64_to_bigint(int64_t src, int64_t *dst); +const char* tsdb_int64_to_ts(int64_t src, int64_t *dst); +const char* tsdb_int64_to_float(int64_t src, float *dst); +const char* tsdb_int64_to_double(int64_t src, double *dst); +const char* tsdb_int64_to_char(int64_t src, char *dst, size_t dlen); + +const char* tsdb_double_to_bit(double src, int precision, int8_t *dst); +const char* tsdb_double_to_tinyint(double src, int precision, int8_t *dst); +const char* tsdb_double_to_smallint(double src, int precision, int16_t *dst); +const char* tsdb_double_to_int(double src, int precision, int32_t *dst); +const char* tsdb_double_to_bigint(double src, int precision, int64_t *dst); +const char* tsdb_double_to_ts(double src, int precision, int64_t *dst); +const char* tsdb_double_to_float(double src, int precision, float *dst); +const char* tsdb_double_to_double(double src, int precision, double *dst); +const char* tsdb_double_to_char(double src, int precision, char *dst, size_t dlen); + +const char* tsdb_chars_to_bit(const char *src, int8_t *dst); +const char* tsdb_chars_to_tinyint(const char *src, int8_t *dst); +const char* tsdb_chars_to_smallint(const char *src, int16_t *dst); +const char* tsdb_chars_to_int(const char *src, int32_t *dst); +const char* tsdb_chars_to_bigint(const char *src, int64_t *dst); +const char* tsdb_chars_to_ts(const char *src, int64_t *dst); +const char* tsdb_chars_to_float(const char *src, float *dst); +const char* tsdb_chars_to_double(const char *src, double *dst); +const char* tsdb_chars_to_char(const char *src, char *dst, size_t dlen); + + +static int do_field_display_size(TAOS_FIELD *field); + +static SQLRETURN doSQLAllocEnv(SQLHENV *EnvironmentHandle) +{ + pthread_once(&init_once, init_routine); + + env_t *env = (env_t*)calloc(1, sizeof(*env)); + if (!env) return SQL_ERROR; + + DASSERT(INC_REF(env)>0); + + *EnvironmentHandle = env; + + CLR_ERROR(env); + return SQL_SUCCESS; +} + +SQLRETURN SQL_API SQLAllocEnv(SQLHENV *EnvironmentHandle) +{ + SQLRETURN r; + r = doSQLAllocEnv(EnvironmentHandle); + return r; +} + +static SQLRETURN doSQLFreeEnv(SQLHENV EnvironmentHandle) +{ + env_t *env = (env_t*)EnvironmentHandle; + if (!env) return SQL_ERROR; + + DASSERT(GET_REF(env)==1); + + DASSERT(!env->destroying); + + env->destroying = 1; + DASSERT(env->destroying == 1); + + DASSERT(DEC_REF(env)==0); + + FREE_ERROR(env); + free(env); + + return SQL_SUCCESS; +} + +SQLRETURN SQL_API SQLFreeEnv(SQLHENV EnvironmentHandle) +{ + SQLRETURN r; + r = doSQLFreeEnv(EnvironmentHandle); + return r; +} + +static SQLRETURN doSQLAllocConnect(SQLHENV EnvironmentHandle, + SQLHDBC *ConnectionHandle) +{ + env_t *env = (env_t*)EnvironmentHandle; + if (!env) return SQL_ERROR; + + DASSERT(INC_REF(env)>1); + + conn_t *conn = NULL; + do { + conn = (conn_t*)calloc(1, sizeof(*conn)); + if (!conn) { + SET_ERROR(env, "HY001", TSDB_CODE_ODBC_OOM, ""); + break; + } + + conn->env = env; + *ConnectionHandle = conn; + + DASSERT(INC_REF(conn)>0); + + return SQL_SUCCESS; + } while (0); + + DASSERT(DEC_REF(env)>0); + + return SQL_ERROR; +} + +SQLRETURN SQL_API SQLAllocConnect(SQLHENV EnvironmentHandle, + SQLHDBC *ConnectionHandle) +{ + SQLRETURN r; + r = doSQLAllocConnect(EnvironmentHandle, ConnectionHandle); + return r; +} + +static SQLRETURN doSQLFreeConnect(SQLHDBC ConnectionHandle) +{ + conn_t *conn = (conn_t*)ConnectionHandle; + if (!conn) return SQL_ERROR; + + DASSERT(GET_REF(conn)==1); + + DASSERT(conn->env); + + do { + if (conn->taos) { + taos_close(conn->taos); + conn->taos = NULL; + } + + DASSERT(DEC_REF(conn->env)>0); + DASSERT(DEC_REF(conn)==0); + + conn->env = NULL; + FREE_ERROR(conn); + free(conn); + } while (0); + + return SQL_SUCCESS; +} + +SQLRETURN SQL_API SQLFreeConnect(SQLHDBC ConnectionHandle) +{ + SQLRETURN r; + r = doSQLFreeConnect(ConnectionHandle); + return r; +} + +static SQLRETURN doSQLConnect(SQLHDBC ConnectionHandle, + SQLCHAR *ServerName, SQLSMALLINT NameLength1, + SQLCHAR *UserName, SQLSMALLINT NameLength2, + SQLCHAR *Authentication, SQLSMALLINT NameLength3) +{ + conn_t *conn = (conn_t*)ConnectionHandle; + if (!conn) return SQL_ERROR; + + if (conn->taos) { + SET_ERROR(conn, "08002", TSDB_CODE_ODBC_CONNECTION_BUSY, "connection still in use"); + return SQL_ERROR; + } + + const char *serverName = SDUP(ServerName, NameLength1); + const char *userName = SDUP(UserName, NameLength2); + const char *auth = SDUP(Authentication, NameLength3); + + do { + if ((ServerName && !serverName) || (UserName && !userName) || (Authentication && !auth)) { + SET_ERROR(conn, "HY001", TSDB_CODE_ODBC_OOM, ""); + break; + } + + // TODO: data-race + // TODO: shall receive ip/port from odbc.ini + conn->taos = taos_connect("localhost", userName, auth, NULL, 0); + if (!conn->taos) { + SET_ERROR(conn, "08001", terrno, "failed to connect to data source"); + break; + } + } while (0); + + SFRE(serverName, ServerName, NameLength1); + SFRE(userName, UserName, NameLength2); + SFRE(auth, Authentication, NameLength3); + + return conn->taos ? SQL_SUCCESS : SQL_ERROR; +} + +SQLRETURN SQL_API SQLConnect(SQLHDBC ConnectionHandle, + SQLCHAR *ServerName, SQLSMALLINT NameLength1, + SQLCHAR *UserName, SQLSMALLINT NameLength2, + SQLCHAR *Authentication, SQLSMALLINT NameLength3) +{ + SQLRETURN r; + r = doSQLConnect(ConnectionHandle, ServerName, NameLength1, + UserName, NameLength2, + Authentication, NameLength3); + return r; +} + +static SQLRETURN doSQLDisconnect(SQLHDBC ConnectionHandle) +{ + conn_t *conn = (conn_t*)ConnectionHandle; + if (!conn) return SQL_ERROR; + + if (conn->taos) { + taos_close(conn->taos); + conn->taos = NULL; + } + + return SQL_SUCCESS; +} + +SQLRETURN SQL_API SQLDisconnect(SQLHDBC ConnectionHandle) +{ + SQLRETURN r; + r = doSQLDisconnect(ConnectionHandle); + return r; +} + +static SQLRETURN doSQLAllocStmt(SQLHDBC ConnectionHandle, + SQLHSTMT *StatementHandle) +{ + conn_t *conn = (conn_t*)ConnectionHandle; + if (!conn) return SQL_ERROR; + + DASSERT(INC_REF(conn)>1); + + do { + sql_t *sql = (sql_t*)calloc(1, sizeof(*sql)); + if (!sql) { + SET_ERROR(conn, "HY001", TSDB_CODE_ODBC_OOM, ""); + break; + } + + sql->conn = conn; + DASSERT(INC_REF(sql)>0); + + *StatementHandle = sql; + + return SQL_SUCCESS; + } while (0); + + DASSERT(DEC_REF(conn)>0); + + return SQL_ERROR; +} + +SQLRETURN SQL_API SQLAllocStmt(SQLHDBC ConnectionHandle, + SQLHSTMT *StatementHandle) +{ + SQLRETURN r; + r = doSQLAllocStmt(ConnectionHandle, StatementHandle); + return r; +} + +static SQLRETURN doSQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE *OutputHandle) +{ + switch (HandleType) { + case SQL_HANDLE_ENV: { + SQLHENV env = {0}; + SQLRETURN r = doSQLAllocEnv(&env); + if (r==SQL_SUCCESS && OutputHandle) *OutputHandle = env; + return r; + } break; + case SQL_HANDLE_DBC: { + SQLHDBC dbc = {0}; + SQLRETURN r = doSQLAllocConnect(InputHandle, &dbc); + if (r==SQL_SUCCESS && OutputHandle) *OutputHandle = dbc; + return r; + } break; + case SQL_HANDLE_STMT: { + SQLHSTMT stmt = {0}; + SQLRETURN r = doSQLAllocStmt(InputHandle, &stmt); + if (r==SQL_SUCCESS && OutputHandle) *OutputHandle = stmt; + return r; + } break; + default: { + return SQL_ERROR; + } break; + } +} + +SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE *OutputHandle) +{ + SQLRETURN r; + r = doSQLAllocHandle(HandleType, InputHandle, OutputHandle); + return r; +} + +static SQLRETURN doSQLFreeStmt(SQLHSTMT StatementHandle, + SQLUSMALLINT Option) +{ + sql_t *sql = (sql_t*)StatementHandle; + if (!sql) return SQL_ERROR; + + if (Option == SQL_CLOSE) return SQL_SUCCESS; + if (Option != SQL_DROP) { + SET_ERROR(sql, "HY000", TSDB_CODE_ODBC_NOT_SUPPORT, "free statement with Option[%x] not supported yet", Option); + return SQL_ERROR; + } + + DASSERT(GET_REF(sql)==1); + + if (sql->rs) { + taos_free_result(sql->rs); + sql->rs = NULL; + } + + if (sql->stmt) { + taos_stmt_close(sql->stmt); + sql->stmt = NULL; + } + + if (sql->params) { + free(sql->params); + sql->params = NULL; + } + sql->n_params = 0; + + DASSERT(DEC_REF(sql->conn)>0); + DASSERT(DEC_REF(sql)==0); + + sql->conn = NULL; + + FREE_ERROR(sql); + free(sql); + + return SQL_SUCCESS; +} + +SQLRETURN SQL_API SQLFreeStmt(SQLHSTMT StatementHandle, + SQLUSMALLINT Option) +{ + SQLRETURN r; + r = doSQLFreeStmt(StatementHandle, Option); + return r; +} + +static SQLRETURN doSQLExecDirect(SQLHSTMT StatementHandle, + SQLCHAR *StatementText, SQLINTEGER TextLength) +{ + sql_t *sql = (sql_t*)StatementHandle; + if (!sql) return SQL_ERROR; + + CHK_CONN(sql); + CHK_CONN_TAOS(sql); + + if (sql->rs) { + taos_free_result(sql->rs); + sql->rs = NULL; + sql->row = NULL; + } + + if (sql->stmt) { + taos_stmt_close(sql->stmt); + sql->stmt = NULL; + } + + if (sql->params) { + free(sql->params); + sql->params = NULL; + } + sql->n_params = 0; + + const char *stxt = SDUP(StatementText, TextLength); + + SQLRETURN r = SQL_ERROR; + do { + if (!stxt) { + SET_ERROR(sql, "HY001", TSDB_CODE_ODBC_OOM, ""); + break; + } + sql->rs = taos_query(sql->conn->taos, stxt); + CHK_RS(r, sql, "failed to execute"); + } while (0); + + SFRE(stxt, StatementText, TextLength); + + return r; +} + +SQLRETURN SQL_API SQLExecDirect(SQLHSTMT StatementHandle, + SQLCHAR *StatementText, SQLINTEGER TextLength) +{ + SQLRETURN r; + r = doSQLExecDirect(StatementHandle, StatementText, TextLength); + return r; +} + +SQLRETURN SQL_API SQLExecDirectW(SQLHSTMT hstmt, SQLWCHAR *szSqlStr, SQLINTEGER cbSqlStr) +{ + size_t bytes = 0; + SQLCHAR *utf8 = wchars_to_chars(szSqlStr, cbSqlStr, &bytes); + return SQLExecDirect(hstmt, utf8, bytes); +} + +static SQLRETURN doSQLNumResultCols(SQLHSTMT StatementHandle, + SQLSMALLINT *ColumnCount) +{ + sql_t *sql = (sql_t*)StatementHandle; + if (!sql) return SQL_ERROR; + + CHK_CONN(sql); + CHK_CONN_TAOS(sql); + + if (sql->is_insert) { + if (ColumnCount) { + *ColumnCount = 0; + } + return SQL_SUCCESS; + } + + if (!sql->rs) { + SET_ERROR(sql, "HY000", TSDB_CODE_ODBC_NO_RESULT, ""); + return SQL_ERROR; + } + + int fields = taos_field_count(sql->rs); + if (ColumnCount) { + *ColumnCount = fields; + } + + return SQL_SUCCESS; +} + +SQLRETURN SQL_API SQLNumResultCols(SQLHSTMT StatementHandle, + SQLSMALLINT *ColumnCount) +{ + SQLRETURN r; + r = doSQLNumResultCols(StatementHandle, ColumnCount); + return r; +} + +static SQLRETURN doSQLRowCount(SQLHSTMT StatementHandle, + SQLLEN *RowCount) +{ + sql_t *sql = (sql_t*)StatementHandle; + if (!sql) return SQL_ERROR; + + CHK_CONN(sql); + CHK_CONN_TAOS(sql); + + if (sql->is_insert) { + if (RowCount) *RowCount = 0; + return SQL_SUCCESS; + } + + if (!sql->rs) { + SET_ERROR(sql, "HY000", TSDB_CODE_ODBC_NO_RESULT, ""); + return SQL_ERROR; + } + + int rows = taos_affected_rows(sql->rs); + if (RowCount) { + *RowCount = rows; + } + return SQL_SUCCESS; +} + +SQLRETURN SQL_API SQLRowCount(SQLHSTMT StatementHandle, + SQLLEN *RowCount) +{ + SQLRETURN r; + r = doSQLRowCount(StatementHandle, RowCount); + return r; +} + +static SQLRETURN doSQLColAttribute(SQLHSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, + SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength, + SQLSMALLINT *StringLength, SQLLEN *NumericAttribute ) +{ + sql_t *sql = (sql_t*)StatementHandle; + if (!sql) return SQL_ERROR; + + CHK_CONN(sql); + CHK_CONN_TAOS(sql); + + if (!sql->rs) { + SET_ERROR(sql, "HY000", TSDB_CODE_ODBC_NO_RESULT, ""); + return SQL_ERROR; + } + + int nfields = taos_field_count(sql->rs); + TAOS_FIELD *fields = taos_fetch_fields(sql->rs); + + if (nfields==0 || fields==NULL) { + SET_ERROR(sql, "07005", TSDB_CODE_ODBC_NO_FIELDS, ""); + return SQL_ERROR; + } + + if (ColumnNumber<=0 || ColumnNumber>nfields) { + SET_ERROR(sql, "07009", TSDB_CODE_ODBC_OUT_OF_RANGE, "invalid column number [%d]", ColumnNumber); + return SQL_ERROR; + } + + TAOS_FIELD *field = fields + ColumnNumber-1; + + switch (FieldIdentifier) { + case SQL_COLUMN_DISPLAY_SIZE: { + *NumericAttribute = do_field_display_size(field); + } break; + case SQL_COLUMN_LABEL: { + size_t n = sizeof(field->name); + strncpy(CharacterAttribute, field->name, (n>BufferLength ? BufferLength : n)); + } break; + case SQL_COLUMN_UNSIGNED: { + *NumericAttribute = SQL_FALSE; + } break; + default: { + SET_ERROR(sql, "HY091", TSDB_CODE_ODBC_OUT_OF_RANGE, + "FieldIdentifier[%d/0x%x] for Column [%d] not supported yet", + FieldIdentifier, FieldIdentifier, ColumnNumber); + return SQL_ERROR; + } break; + } + return SQL_SUCCESS; +} + +SQLRETURN SQL_API SQLColAttribute(SQLHSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, + SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength, + SQLSMALLINT *StringLength, SQLLEN *NumericAttribute ) +{ + SQLRETURN r; + r = doSQLColAttribute(StatementHandle, ColumnNumber, FieldIdentifier, + CharacterAttribute, BufferLength, + StringLength, NumericAttribute); + return r; +} + +static SQLRETURN conv_tsdb_bool_to_c_bit(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b); +static SQLRETURN conv_tsdb_bool_to_c_tinyint(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b); +static SQLRETURN conv_tsdb_bool_to_c_short(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b); +static SQLRETURN conv_tsdb_bool_to_c_long(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b); +static SQLRETURN conv_tsdb_bool_to_c_sbigint(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b); +static SQLRETURN conv_tsdb_bool_to_c_float(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b); +static SQLRETURN conv_tsdb_bool_to_c_double(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b); +static SQLRETURN conv_tsdb_bool_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b); +static SQLRETURN conv_tsdb_bool_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b); +static SQLRETURN conv_tsdb_v1_to_c_tinyint(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1); +static SQLRETURN conv_tsdb_v1_to_c_short(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1); +static SQLRETURN conv_tsdb_v1_to_c_long(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1); +static SQLRETURN conv_tsdb_v1_to_c_sbigint(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1); +static SQLRETURN conv_tsdb_v1_to_c_float(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1); +static SQLRETURN conv_tsdb_v1_to_c_double(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1); +static SQLRETURN conv_tsdb_v1_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1); +static SQLRETURN conv_tsdb_v1_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1); +static SQLRETURN conv_tsdb_v2_to_c_short(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int16_t v2); +static SQLRETURN conv_tsdb_v2_to_c_long(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int16_t v2); +static SQLRETURN conv_tsdb_v2_to_c_sbigint(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int16_t v2); +static SQLRETURN conv_tsdb_v2_to_c_float(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int16_t v2); +static SQLRETURN conv_tsdb_v2_to_c_double(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int16_t v2); +static SQLRETURN conv_tsdb_v2_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int16_t v2); +static SQLRETURN conv_tsdb_v2_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int16_t v2); +static SQLRETURN conv_tsdb_v4_to_c_long(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int32_t v4); +static SQLRETURN conv_tsdb_v4_to_c_sbigint(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int32_t v4); +static SQLRETURN conv_tsdb_v4_to_c_float(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int32_t v4); +static SQLRETURN conv_tsdb_v4_to_c_double(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int32_t v4); +static SQLRETURN conv_tsdb_v4_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int32_t v4); +static SQLRETURN conv_tsdb_v4_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int32_t v4); +static SQLRETURN conv_tsdb_v8_to_c_sbigint(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int64_t v8); +static SQLRETURN conv_tsdb_v8_to_c_float(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int64_t v8); +static SQLRETURN conv_tsdb_v8_to_c_double(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int64_t v8); +static SQLRETURN conv_tsdb_v8_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int64_t v8); +static SQLRETURN conv_tsdb_v8_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int64_t v8); +static SQLRETURN conv_tsdb_f4_to_c_float(sql_t *sql, c_target_t *target, TAOS_FIELD *field, float f4); +static SQLRETURN conv_tsdb_f4_to_c_double(sql_t *sql, c_target_t *target, TAOS_FIELD *field, float f4); +static SQLRETURN conv_tsdb_f4_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, float f4); +static SQLRETURN conv_tsdb_f4_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, float f4); +static SQLRETURN conv_tsdb_f8_to_c_double(sql_t *sql, c_target_t *target, TAOS_FIELD *field, double f8); +static SQLRETURN conv_tsdb_f8_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, double f8); +static SQLRETURN conv_tsdb_f8_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, double f8); +static SQLRETURN conv_tsdb_ts_to_c_v8(sql_t *sql, c_target_t *target, TAOS_FIELD *field, SQL_TIMESTAMP_STRUCT *ts); +static SQLRETURN conv_tsdb_ts_to_c_str(sql_t *sql, c_target_t *target, TAOS_FIELD *field, SQL_TIMESTAMP_STRUCT *ts); +static SQLRETURN conv_tsdb_ts_to_c_bin(sql_t *sql, c_target_t *target, TAOS_FIELD *field, SQL_TIMESTAMP_STRUCT *ts); +static SQLRETURN conv_tsdb_ts_to_c_ts(sql_t *sql, c_target_t *target, TAOS_FIELD *field, SQL_TIMESTAMP_STRUCT *ts); +static SQLRETURN conv_tsdb_bin_to_c_str(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const unsigned char *bin); +static SQLRETURN conv_tsdb_bin_to_c_bin(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const unsigned char *bin); +static SQLRETURN conv_tsdb_str_to_c_bit(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str); +static SQLRETURN conv_tsdb_str_to_c_v1(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str); +static SQLRETURN conv_tsdb_str_to_c_v2(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str); +static SQLRETURN conv_tsdb_str_to_c_v4(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str); +static SQLRETURN conv_tsdb_str_to_c_v8(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str); +static SQLRETURN conv_tsdb_str_to_c_f4(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str); +static SQLRETURN conv_tsdb_str_to_c_f8(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str); +static SQLRETURN conv_tsdb_str_to_c_str(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str); +static SQLRETURN conv_tsdb_str_to_c_bin(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str); + +static SQLRETURN doSQLGetData(SQLHSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, + SQLPOINTER TargetValue, SQLLEN BufferLength, + SQLLEN *StrLen_or_Ind) +{ + sql_t *sql = (sql_t*)StatementHandle; + if (!sql) return SQL_ERROR; + + CHK_CONN(sql); + CHK_CONN_TAOS(sql); + + if (!sql->rs) { + SET_ERROR(sql, "HY000", TSDB_CODE_ODBC_NO_RESULT, ""); + return SQL_ERROR; + } + + if (!sql->row) { + SET_ERROR(sql, "24000", TSDB_CODE_ODBC_INVALID_CURSOR, ""); + return SQL_ERROR; + } + + DASSERT(TargetValue); + + int nfields = taos_field_count(sql->rs); + TAOS_FIELD *fields = taos_fetch_fields(sql->rs); + + if (ColumnNumber<=0 || ColumnNumber>nfields) { + SET_ERROR(sql, "07009", TSDB_CODE_ODBC_OUT_OF_RANGE, "invalid column number [%d]", ColumnNumber); + return SQL_ERROR; + } + + if (TargetValue == NULL) { + SET_ERROR(sql, "HY009", TSDB_CODE_ODBC_BAD_ARG, "NULL TargetValue not allowed for col [%d]", ColumnNumber); + return SQL_ERROR; + } + + TAOS_FIELD *field = fields + ColumnNumber-1; + void *row = sql->row[ColumnNumber-1]; + + if (!row) { + if (StrLen_or_Ind) { + *StrLen_or_Ind = SQL_NULL_DATA; + } + return SQL_SUCCESS; + } + + c_target_t target = {0}; + target.col = ColumnNumber; + target.ct = TargetType; + target.ptr = TargetValue; + target.len = BufferLength; + target.soi = StrLen_or_Ind; + + switch (field->type) { + case TSDB_DATA_TYPE_BOOL: { + int8_t v = *(int8_t*)row; + if (v) v = 1; + switch (target.ct) { + case SQL_C_BIT: return conv_tsdb_bool_to_c_bit(sql, &target, field, v); + case SQL_C_TINYINT: return conv_tsdb_bool_to_c_tinyint(sql, &target, field, v); + case SQL_C_SHORT: return conv_tsdb_bool_to_c_short(sql, &target, field, v); + case SQL_C_LONG: return conv_tsdb_bool_to_c_long(sql, &target, field, v); + case SQL_C_SBIGINT: return conv_tsdb_bool_to_c_sbigint(sql, &target, field, v); + case SQL_C_FLOAT: return conv_tsdb_bool_to_c_float(sql, &target, field, v); + case SQL_C_DOUBLE: return conv_tsdb_bool_to_c_double(sql, &target, field, v); + case SQL_C_CHAR: return conv_tsdb_bool_to_c_char(sql, &target, field, v); + case SQL_C_BINARY: return conv_tsdb_bool_to_c_binary(sql, &target, field, v); + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, + "no convertion from [%s] to [%s[%d][0x%x]] for col [%d]", + taos_data_type(field->type), sql_c_type(target.ct), target.ct, target.ct, ColumnNumber); + return SQL_ERROR; + } + } + } break; + case TSDB_DATA_TYPE_TINYINT: { + int8_t v = *(int8_t*)row; + switch (target.ct) { + case SQL_C_TINYINT: return conv_tsdb_v1_to_c_tinyint(sql, &target, field, v); + case SQL_C_SHORT: return conv_tsdb_v1_to_c_short(sql, &target, field, v); + case SQL_C_LONG: return conv_tsdb_v1_to_c_long(sql, &target, field, v); + case SQL_C_SBIGINT: return conv_tsdb_v1_to_c_sbigint(sql, &target, field, v); + case SQL_C_FLOAT: return conv_tsdb_v1_to_c_float(sql, &target, field, v); + case SQL_C_DOUBLE: return conv_tsdb_v1_to_c_double(sql, &target, field, v); + case SQL_C_CHAR: return conv_tsdb_v1_to_c_char(sql, &target, field, v); + case SQL_C_BINARY: return conv_tsdb_v1_to_c_binary(sql, &target, field, v); + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, + "no convertion from [%s] to [%s[%d][0x%x]] for col [%d]", + taos_data_type(field->type), sql_c_type(target.ct), target.ct, target.ct, ColumnNumber); + return SQL_ERROR; + } + } + } break; + case TSDB_DATA_TYPE_SMALLINT: { + int16_t v = *(int16_t*)row; + switch (target.ct) { + case SQL_C_SHORT: return conv_tsdb_v2_to_c_short(sql, &target, field, v); + case SQL_C_LONG: return conv_tsdb_v2_to_c_long(sql, &target, field, v); + case SQL_C_SBIGINT: return conv_tsdb_v2_to_c_sbigint(sql, &target, field, v); + case SQL_C_FLOAT: return conv_tsdb_v2_to_c_float(sql, &target, field, v); + case SQL_C_DOUBLE: return conv_tsdb_v2_to_c_double(sql, &target, field, v); + case SQL_C_CHAR: return conv_tsdb_v2_to_c_char(sql, &target, field, v); + case SQL_C_BINARY: return conv_tsdb_v2_to_c_binary(sql, &target, field, v); + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, + "no convertion from [%s] to [%s[%d][0x%x]] for col [%d]", + taos_data_type(field->type), sql_c_type(target.ct), target.ct, target.ct, ColumnNumber); + return SQL_ERROR; + } + } + } break; + case TSDB_DATA_TYPE_INT: { + int32_t v = *(int32_t*)row; + switch (target.ct) { + case SQL_C_LONG: return conv_tsdb_v4_to_c_long(sql, &target, field, v); + case SQL_C_SBIGINT: return conv_tsdb_v4_to_c_sbigint(sql, &target, field, v); + case SQL_C_FLOAT: return conv_tsdb_v4_to_c_float(sql, &target, field, v); + case SQL_C_DOUBLE: return conv_tsdb_v4_to_c_double(sql, &target, field, v); + case SQL_C_CHAR: return conv_tsdb_v4_to_c_char(sql, &target, field, v); + case SQL_C_BINARY: return conv_tsdb_v4_to_c_binary(sql, &target, field, v); + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, + "no convertion from [%s] to [%s[%d][0x%x]] for col [%d]", + taos_data_type(field->type), sql_c_type(target.ct), target.ct, target.ct, ColumnNumber); + return SQL_ERROR; + } + } + } break; + case TSDB_DATA_TYPE_BIGINT: { + int64_t v = *(int64_t*)row; + switch (target.ct) { + case SQL_C_SBIGINT: return conv_tsdb_v8_to_c_sbigint(sql, &target, field, v); + case SQL_C_FLOAT: return conv_tsdb_v8_to_c_float(sql, &target, field, v); + case SQL_C_DOUBLE: return conv_tsdb_v8_to_c_double(sql, &target, field, v); + case SQL_C_CHAR: return conv_tsdb_v8_to_c_char(sql, &target, field, v); + case SQL_C_BINARY: return conv_tsdb_v8_to_c_binary(sql, &target, field, v); + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, + "no convertion from [%s] to [%s[%d][0x%x]] for col [%d]", + taos_data_type(field->type), sql_c_type(target.ct), target.ct, target.ct, ColumnNumber); + return SQL_ERROR; + } + } + } break; + case TSDB_DATA_TYPE_FLOAT: { + float v = *(float*)row; + switch (target.ct) { + case SQL_C_FLOAT: return conv_tsdb_f4_to_c_float(sql, &target, field, v); + case SQL_C_DOUBLE: return conv_tsdb_f4_to_c_double(sql, &target, field, v); + case SQL_C_CHAR: return conv_tsdb_f4_to_c_char(sql, &target, field, v); + case SQL_C_BINARY: return conv_tsdb_f4_to_c_binary(sql, &target, field, v); + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, + "no convertion from [%s] to [%s[%d][0x%x]] for col [%d]", + taos_data_type(field->type), sql_c_type(target.ct), target.ct, target.ct, ColumnNumber); + return SQL_ERROR; + } + } + } break; + case TSDB_DATA_TYPE_DOUBLE: { + double v = *(double*)row; + switch (target.ct) { + case SQL_C_DOUBLE: return conv_tsdb_f8_to_c_double(sql, &target, field, v); + case SQL_C_CHAR: return conv_tsdb_f8_to_c_char(sql, &target, field, v); + case SQL_C_BINARY: return conv_tsdb_f8_to_c_binary(sql, &target, field, v); + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, + "no convertion from [%s] to [%s[%d][0x%x]] for col [%d]", + taos_data_type(field->type), sql_c_type(target.ct), target.ct, target.ct, ColumnNumber); + return SQL_ERROR; + } + } + } break; + case TSDB_DATA_TYPE_TIMESTAMP: { + SQL_TIMESTAMP_STRUCT ts = {0}; + int64_t v = *(int64_t*)row; + time_t t = v/1000; + struct tm tm = {0}; + localtime_r(&t, &tm); + ts.year = tm.tm_year + 1900; + ts.month = tm.tm_mon + 1; + ts.day = tm.tm_mday; + ts.hour = tm.tm_hour; + ts.minute = tm.tm_min; + ts.second = tm.tm_sec; + ts.fraction = v%1000 * 1000000; + switch (target.ct) { + case SQL_C_SBIGINT: return conv_tsdb_ts_to_c_v8(sql, &target, field, &ts); + case SQL_C_CHAR: return conv_tsdb_ts_to_c_str(sql, &target, field, &ts); + case SQL_C_BINARY: return conv_tsdb_ts_to_c_bin(sql, &target, field, &ts); + case SQL_C_TYPE_TIMESTAMP: + case SQL_C_TIMESTAMP: return conv_tsdb_ts_to_c_ts(sql, &target, field, &ts); + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, + "no convertion from [%s] to [%s[%d][0x%x]] for col [%d]", + taos_data_type(field->type), sql_c_type(target.ct), target.ct, target.ct, ColumnNumber); + return SQL_ERROR; + } + } + } break; + case TSDB_DATA_TYPE_BINARY: { + const unsigned char *bin = (const unsigned char *)row; + switch (target.ct) { + case SQL_C_CHAR: return conv_tsdb_bin_to_c_str(sql, &target, field, bin); + case SQL_C_BINARY: return conv_tsdb_bin_to_c_bin(sql, &target, field, bin); + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, + "no convertion from [%s] to [%s[%d][0x%x]] for col [%d]", + taos_data_type(field->type), sql_c_type(target.ct), target.ct, target.ct, ColumnNumber); + return SQL_ERROR; + } + } + } break; + case TSDB_DATA_TYPE_NCHAR: { + const char *str = (const char *)row; + switch (target.ct) { + case SQL_C_BIT: return conv_tsdb_str_to_c_bit(sql, &target, field, str); + case SQL_C_TINYINT: return conv_tsdb_str_to_c_v1(sql, &target, field, str); + case SQL_C_SHORT: return conv_tsdb_str_to_c_v2(sql, &target, field, str); + case SQL_C_LONG: return conv_tsdb_str_to_c_v4(sql, &target, field, str); + case SQL_C_SBIGINT: return conv_tsdb_str_to_c_v8(sql, &target, field, str); + case SQL_C_FLOAT: return conv_tsdb_str_to_c_f4(sql, &target, field, str); + case SQL_C_DOUBLE: return conv_tsdb_str_to_c_f8(sql, &target, field, str); + case SQL_C_CHAR: return conv_tsdb_str_to_c_str(sql, &target, field, str); + case SQL_C_BINARY: return conv_tsdb_str_to_c_bin(sql, &target, field, str); + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, + "no convertion from [%s] to [%s[%d][0x%x]] for col [%d]", + taos_data_type(field->type), sql_c_type(target.ct), target.ct, target.ct, ColumnNumber); + return SQL_ERROR; + } + } + } break; + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_OUT_OF_RANGE, + "no convertion from [%s[%d/0x%x]] to [%s[%d/0x%x]] for col [%d]", + taos_data_type(field->type), field->type, field->type, + sql_c_type(target.ct), target.ct, target.ct, ColumnNumber); + return SQL_ERROR; + } break; + } +} + +SQLRETURN SQL_API SQLGetData(SQLHSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, + SQLPOINTER TargetValue, SQLLEN BufferLength, + SQLLEN *StrLen_or_Ind) +{ + SQLRETURN r; + r = doSQLGetData(StatementHandle, ColumnNumber, TargetType, + TargetValue, BufferLength, + StrLen_or_Ind); + return r; +} + +static SQLRETURN doSQLFetch(SQLHSTMT StatementHandle) +{ + sql_t *sql = (sql_t*)StatementHandle; + if (!sql) return SQL_ERROR; + + CHK_CONN(sql); + CHK_CONN_TAOS(sql); + + if (!sql->rs) { + SET_ERROR(sql, "HY000", TSDB_CODE_ODBC_NO_RESULT, ""); + return SQL_ERROR; + } + + sql->row = taos_fetch_row(sql->rs); + return sql->row ? SQL_SUCCESS : SQL_NO_DATA; +} + +SQLRETURN SQL_API SQLFetch(SQLHSTMT StatementHandle) +{ + SQLRETURN r; + r = doSQLFetch(StatementHandle); + return r; +} + +static SQLRETURN doSQLPrepare(SQLHSTMT StatementHandle, + SQLCHAR *StatementText, SQLINTEGER TextLength) +{ + sql_t *sql = (sql_t*)StatementHandle; + if (!sql) return SQL_ERROR; + + CHK_CONN(sql); + CHK_CONN_TAOS(sql); + + if (sql->rs) { + taos_free_result(sql->rs); + sql->rs = NULL; + sql->row = NULL; + } + + if (sql->stmt) { + taos_stmt_close(sql->stmt); + sql->stmt = NULL; + } + + if (sql->params) { + free(sql->params); + sql->params = NULL; + } + sql->n_params = 0; + sql->is_insert = 0; + + do { + sql->stmt = taos_stmt_init(sql->conn->taos); + if (!sql->stmt) { + SET_ERROR(sql, "HY001", terrno, "failed to initialize TAOS statement internally"); + break; + } + + int ok = 0; + do { + int r = taos_stmt_prepare(sql->stmt, (const char *)StatementText, TextLength); + if (r) { + SET_ERROR(sql, "HY000", r, "failed to prepare a TAOS statement"); + break; + } + sql->is_prepared = 1; + + int is_insert = 0; + r = taos_stmt_is_insert(sql->stmt, &is_insert); + if (r) { + SET_ERROR(sql, "HY000", r, "failed to determine if a prepared-statement is of insert"); + break; + } + sql->is_insert = is_insert ? 1 : 0; + + int params = 0; + r = taos_stmt_num_params(sql->stmt, ¶ms); + if (r) { + SET_ERROR(sql, "HY000", terrno, "fetch num of statement params failed"); + break; + } + DASSERT(params>=0); + + if (params>0) { + param_bind_t *ar = (param_bind_t*)calloc(1, params * sizeof(*ar)); + if (!ar) { + SET_ERROR(sql, "HY001", TSDB_CODE_ODBC_OOM, ""); + break; + } + sql->params = ar; + } + + sql->n_params = params; + + ok = 1; + } while (0); + + if (!ok) { + taos_stmt_close(sql->stmt); + sql->stmt = NULL; + sql->is_prepared = 0; + sql->is_insert = 0; + sql->is_executed = 0; + } + } while (0); + + return sql->stmt ? SQL_SUCCESS : SQL_ERROR; +} + +SQLRETURN SQL_API SQLPrepare(SQLHSTMT StatementHandle, + SQLCHAR *StatementText, SQLINTEGER TextLength) +{ + SQLRETURN r; + r = doSQLPrepare(StatementHandle, StatementText, TextLength); + return r; +} + +static const int yes = 1; +static const int no = 0; + +static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bind_t *param, TAOS_BIND *bind) +{ + if (!param->valid) { + SET_ERROR(sql, "HY000", TSDB_CODE_ODBC_NOT_SUPPORT, "parameter [@%d] not bound yet", idx+1); + return SQL_ERROR; + } + + SQLPOINTER paramValue = param->ParameterValue; + SQLSMALLINT valueType = param->ValueType; + SQLLEN *soi = param->StrLen_or_Ind; + + size_t offset = idx_row * sql->rowlen + sql->ptr_offset; + + if (paramValue) paramValue += offset; + if (soi) soi = (SQLLEN*)((char*)soi + offset); + + + if (soi && *soi == SQL_NULL_DATA) { + bind->is_null = (int*)&yes; + return SQL_SUCCESS; + } + bind->is_null = (int*)&no; + int type = 0; + int bytes = 0; + if (sql->is_insert) { + int r = taos_stmt_get_param(sql->stmt, idx, &type, &bytes); + if (r) { + SET_ERROR(sql, "HY000", TSDB_CODE_ODBC_OUT_OF_RANGE, "parameter [@%d] not valid", idx+1); + return SQL_ERROR; + } + } else { + switch (valueType) { + case SQL_C_LONG: { + type = TSDB_DATA_TYPE_INT; + } break; + case SQL_C_WCHAR: { + type = TSDB_DATA_TYPE_NCHAR; + bytes = SQL_NTS; + } break; + case SQL_C_CHAR: + case SQL_C_SHORT: + case SQL_C_SSHORT: + case SQL_C_USHORT: + case SQL_C_SLONG: + case SQL_C_ULONG: + case SQL_C_FLOAT: + case SQL_C_DOUBLE: + case SQL_C_BIT: + case SQL_C_TINYINT: + case SQL_C_STINYINT: + case SQL_C_UTINYINT: + case SQL_C_SBIGINT: + case SQL_C_UBIGINT: + case SQL_C_BINARY: + case SQL_C_DATE: + case SQL_C_TIME: + case SQL_C_TIMESTAMP: + case SQL_C_TYPE_DATE: + case SQL_C_TYPE_TIME: + case SQL_C_TYPE_TIMESTAMP: + case SQL_C_NUMERIC: + case SQL_C_GUID: + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_OUT_OF_RANGE, + "no convertion from [%s[%d/0x%x]] for parameter [%d]", + sql_c_type(valueType), valueType, valueType, + idx+1); + return SQL_ERROR; + } break; + } + } + + // ref: https://docs.microsoft.com/en-us/sql/odbc/reference/appendixes/converting-data-from-c-to-sql-data-types?view=sql-server-ver15 + switch (type) { + case TSDB_DATA_TYPE_BOOL: { + bind->buffer_type = type; + bind->buffer_length = sizeof(bind->u.b); + bind->buffer = &bind->u.b; + bind->length = &bind->buffer_length; + switch (valueType) { + case SQL_C_LONG: { + CHK_CONV(tsdb_int64_to_bit(*(int32_t*)paramValue, &bind->u.b)); + } break; + case SQL_C_BIT: { + CHK_CONV(tsdb_int64_to_bit(*(int8_t*)paramValue, &bind->u.b)); + } break; + case SQL_C_CHAR: + case SQL_C_WCHAR: + case SQL_C_SHORT: + case SQL_C_SSHORT: + case SQL_C_USHORT: + case SQL_C_SLONG: + case SQL_C_ULONG: + case SQL_C_FLOAT: + case SQL_C_DOUBLE: + case SQL_C_TINYINT: + case SQL_C_STINYINT: + case SQL_C_UTINYINT: + case SQL_C_SBIGINT: + case SQL_C_UBIGINT: + case SQL_C_BINARY: + case SQL_C_DATE: + case SQL_C_TIME: + case SQL_C_TIMESTAMP: + case SQL_C_TYPE_DATE: + case SQL_C_TYPE_TIME: + case SQL_C_TYPE_TIMESTAMP: + case SQL_C_NUMERIC: + case SQL_C_GUID: + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_OUT_OF_RANGE, + "no convertion from [%s[%d/0x%x]] to [%s[%d/0x%x]] for parameter [%d]", + sql_c_type(valueType), valueType, valueType, + taos_data_type(type), type, type, idx+1); + return SQL_ERROR; + } break; + } + } break; + case TSDB_DATA_TYPE_TINYINT: { + bind->buffer_type = type; + bind->buffer_length = sizeof(bind->u.v1); + bind->buffer = &bind->u.v1; + bind->length = &bind->buffer_length; + switch (valueType) { + case SQL_C_TINYINT: { + CHK_CONV(tsdb_int64_to_tinyint(*(int8_t*)paramValue, &bind->u.v1)); + } break; + case SQL_C_SHORT: { + CHK_CONV(tsdb_int64_to_tinyint(*(int16_t*)paramValue, &bind->u.v1)); + } break; + case SQL_C_LONG: { + CHK_CONV(tsdb_int64_to_tinyint(*(int32_t*)paramValue, &bind->u.v1)); + } break; + case SQL_C_SBIGINT: { + CHK_CONV(tsdb_int64_to_tinyint(*(int64_t*)paramValue, &bind->u.v1)); + } break; + case SQL_C_CHAR: + case SQL_C_WCHAR: + case SQL_C_SSHORT: + case SQL_C_USHORT: + case SQL_C_SLONG: + case SQL_C_ULONG: + case SQL_C_FLOAT: + case SQL_C_DOUBLE: + case SQL_C_BIT: + case SQL_C_STINYINT: + case SQL_C_UTINYINT: + case SQL_C_UBIGINT: + case SQL_C_BINARY: + case SQL_C_DATE: + case SQL_C_TIME: + case SQL_C_TIMESTAMP: + case SQL_C_TYPE_DATE: + case SQL_C_TYPE_TIME: + case SQL_C_TYPE_TIMESTAMP: + case SQL_C_NUMERIC: + case SQL_C_GUID: + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_OUT_OF_RANGE, + "no convertion from [%s[%d/0x%x]] to [%s[%d/0x%x]] for parameter [%d]", + sql_c_type(valueType), valueType, valueType, + taos_data_type(type), type, type, idx+1); + return SQL_ERROR; + } break; + } + } break; + case TSDB_DATA_TYPE_SMALLINT: { + bind->buffer_type = type; + bind->buffer_length = sizeof(bind->u.v2); + bind->buffer = &bind->u.v2; + bind->length = &bind->buffer_length; + switch (valueType) { + case SQL_C_LONG: { + CHK_CONV(tsdb_int64_to_smallint(*(int32_t*)paramValue, &bind->u.v2)); + } break; + case SQL_C_SHORT: { + CHK_CONV(tsdb_int64_to_smallint(*(int16_t*)paramValue, &bind->u.v2)); + } break; + case SQL_C_CHAR: + case SQL_C_WCHAR: + case SQL_C_SSHORT: + case SQL_C_USHORT: + case SQL_C_SLONG: + case SQL_C_ULONG: + case SQL_C_FLOAT: + case SQL_C_DOUBLE: + case SQL_C_BIT: + case SQL_C_TINYINT: + case SQL_C_STINYINT: + case SQL_C_UTINYINT: + case SQL_C_SBIGINT: + case SQL_C_UBIGINT: + case SQL_C_BINARY: + case SQL_C_DATE: + case SQL_C_TIME: + case SQL_C_TIMESTAMP: + case SQL_C_TYPE_DATE: + case SQL_C_TYPE_TIME: + case SQL_C_TYPE_TIMESTAMP: + case SQL_C_NUMERIC: + case SQL_C_GUID: + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_OUT_OF_RANGE, + "no convertion from [%s[%d/0x%x]] to [%s[%d/0x%x]] for parameter [%d]", + sql_c_type(valueType), valueType, valueType, + taos_data_type(type), type, type, idx+1); + return SQL_ERROR; + } break; + } + } break; + case TSDB_DATA_TYPE_INT: { + bind->buffer_type = type; + bind->buffer_length = sizeof(bind->u.v4); + bind->buffer = &bind->u.v4; + bind->length = &bind->buffer_length; + switch (valueType) { + case SQL_C_LONG: { + CHK_CONV(tsdb_int64_to_int(*(int32_t*)paramValue, &bind->u.v4)); + } break; + case SQL_C_CHAR: + case SQL_C_WCHAR: + case SQL_C_SHORT: + case SQL_C_SSHORT: + case SQL_C_USHORT: + case SQL_C_SLONG: + case SQL_C_ULONG: + case SQL_C_FLOAT: + case SQL_C_DOUBLE: + case SQL_C_BIT: + case SQL_C_TINYINT: + case SQL_C_STINYINT: + case SQL_C_UTINYINT: + case SQL_C_SBIGINT: + case SQL_C_UBIGINT: + case SQL_C_BINARY: + case SQL_C_DATE: + case SQL_C_TIME: + case SQL_C_TIMESTAMP: + case SQL_C_TYPE_DATE: + case SQL_C_TYPE_TIME: + case SQL_C_TYPE_TIMESTAMP: + case SQL_C_NUMERIC: + case SQL_C_GUID: + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_OUT_OF_RANGE, + "no convertion from [%s[%d/0x%x]] to [%s[%d/0x%x]] for parameter [%d]", + sql_c_type(valueType), valueType, valueType, + taos_data_type(type), type, type, idx+1); + return SQL_ERROR; + } break; + } + } break; + case TSDB_DATA_TYPE_BIGINT: { + bind->buffer_type = type; + bind->buffer_length = sizeof(bind->u.v8); + bind->buffer = &bind->u.v8; + bind->length = &bind->buffer_length; + switch (valueType) { + case SQL_C_SBIGINT: { + bind->u.v8 = *(int64_t*)paramValue; + } break; + case SQL_C_LONG: { + bind->u.v8 = *(int32_t*)paramValue; + } break; + case SQL_C_CHAR: + case SQL_C_WCHAR: + case SQL_C_SHORT: + case SQL_C_SSHORT: + case SQL_C_USHORT: + case SQL_C_SLONG: + case SQL_C_ULONG: + case SQL_C_FLOAT: + case SQL_C_DOUBLE: + case SQL_C_BIT: + case SQL_C_TINYINT: + case SQL_C_STINYINT: + case SQL_C_UTINYINT: + case SQL_C_UBIGINT: + case SQL_C_BINARY: + case SQL_C_DATE: + case SQL_C_TIME: + case SQL_C_TIMESTAMP: + case SQL_C_TYPE_DATE: + case SQL_C_TYPE_TIME: + case SQL_C_TYPE_TIMESTAMP: + case SQL_C_NUMERIC: + case SQL_C_GUID: + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_OUT_OF_RANGE, + "no convertion from [%s[%d/0x%x]] to [%s[%d/0x%x]] for parameter [%d]", + sql_c_type(valueType), valueType, valueType, + taos_data_type(type), type, type, idx+1); + return SQL_ERROR; + } break; + } + } break; + case TSDB_DATA_TYPE_FLOAT: { + bind->buffer_type = type; + bind->buffer_length = sizeof(bind->u.f4); + bind->buffer = &bind->u.f4; + bind->length = &bind->buffer_length; + switch (valueType) { + case SQL_C_DOUBLE: { + bind->u.f4 = *(double*)paramValue; + } break; + case SQL_C_FLOAT: { + bind->u.f4 = *(float*)paramValue; + } break; + case SQL_C_CHAR: + case SQL_C_WCHAR: + case SQL_C_SHORT: + case SQL_C_SSHORT: + case SQL_C_USHORT: + case SQL_C_LONG: + case SQL_C_SLONG: + case SQL_C_ULONG: + case SQL_C_BIT: + case SQL_C_TINYINT: + case SQL_C_STINYINT: + case SQL_C_UTINYINT: + case SQL_C_SBIGINT: + case SQL_C_UBIGINT: + case SQL_C_BINARY: + case SQL_C_DATE: + case SQL_C_TIME: + case SQL_C_TIMESTAMP: + case SQL_C_TYPE_DATE: + case SQL_C_TYPE_TIME: + case SQL_C_TYPE_TIMESTAMP: + case SQL_C_NUMERIC: + case SQL_C_GUID: + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_OUT_OF_RANGE, + "no convertion from [%s[%d/0x%x]] to [%s[%d/0x%x]] for parameter [%d]", + sql_c_type(valueType), valueType, valueType, + taos_data_type(type), type, type, idx+1); + return SQL_ERROR; + } break; + } + } break; + case TSDB_DATA_TYPE_DOUBLE: { + bind->buffer_type = type; + bind->buffer_length = sizeof(bind->u.f8); + bind->buffer = &bind->u.f8; + bind->length = &bind->buffer_length; + switch (valueType) { + case SQL_C_DOUBLE: { + bind->u.f8 = *(double*)paramValue; + } break; + case SQL_C_CHAR: + case SQL_C_WCHAR: + case SQL_C_SHORT: + case SQL_C_SSHORT: + case SQL_C_USHORT: + case SQL_C_LONG: + case SQL_C_SLONG: + case SQL_C_ULONG: + case SQL_C_FLOAT: + case SQL_C_BIT: + case SQL_C_TINYINT: + case SQL_C_STINYINT: + case SQL_C_UTINYINT: + case SQL_C_SBIGINT: + case SQL_C_UBIGINT: + case SQL_C_BINARY: + case SQL_C_DATE: + case SQL_C_TIME: + case SQL_C_TIMESTAMP: + case SQL_C_TYPE_DATE: + case SQL_C_TYPE_TIME: + case SQL_C_TYPE_TIMESTAMP: + case SQL_C_NUMERIC: + case SQL_C_GUID: + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_OUT_OF_RANGE, + "no convertion from [%s[%d/0x%x]] to [%s[%d/0x%x]] for parameter [%d]", + sql_c_type(valueType), valueType, valueType, + taos_data_type(type), type, type, idx+1); + return SQL_ERROR; + } break; + } + } break; + case TSDB_DATA_TYPE_BINARY: { + bind->buffer_type = type; + bind->length = &bind->buffer_length; + switch (valueType) { + case SQL_C_WCHAR: { + DASSERT(soi); + DASSERT(*soi != SQL_NTS); + size_t bytes = 0; + SQLCHAR *utf8 = wchars_to_chars(paramValue, *soi/2, &bytes); + bind->allocated = 1; + bind->u.bin = utf8; + bind->buffer_length = bytes; + bind->buffer = bind->u.bin; + } break; + case SQL_C_BINARY: { + bind->u.bin = (unsigned char*)paramValue; + if (*soi == SQL_NTS) { + bind->buffer_length = strlen((const char*)paramValue); + } else { + bind->buffer_length = *soi; + } + bind->buffer = bind->u.bin; + } break; + case SQL_C_CHAR: + case SQL_C_SHORT: + case SQL_C_SSHORT: + case SQL_C_USHORT: + case SQL_C_LONG: + case SQL_C_SLONG: + case SQL_C_ULONG: + case SQL_C_FLOAT: + case SQL_C_DOUBLE: + case SQL_C_BIT: + case SQL_C_TINYINT: + case SQL_C_STINYINT: + case SQL_C_UTINYINT: + case SQL_C_SBIGINT: + case SQL_C_UBIGINT: + case SQL_C_DATE: + case SQL_C_TIME: + case SQL_C_TIMESTAMP: + case SQL_C_TYPE_DATE: + case SQL_C_TYPE_TIME: + case SQL_C_TYPE_TIMESTAMP: + case SQL_C_NUMERIC: + case SQL_C_GUID: + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_OUT_OF_RANGE, + "no convertion from [%s[%d/0x%x]] to [%s[%d/0x%x]] for parameter [%d]", + sql_c_type(valueType), valueType, valueType, + taos_data_type(type), type, type, idx+1); + return SQL_ERROR; + } break; + } + } break; + case TSDB_DATA_TYPE_TIMESTAMP: { + bind->buffer_type = type; + bind->buffer_length = sizeof(bind->u.v8); + bind->buffer = &bind->u.v8; + bind->length = &bind->buffer_length; + switch (valueType) { + case SQL_C_WCHAR: { + DASSERT(soi); + DASSERT(*soi != SQL_NTS); + size_t bytes = 0; + int r = 0; + int64_t t = 0; + SQLCHAR *utf8 = wchars_to_chars(paramValue, *soi/2, &bytes); + // why cast utf8 to 'char*' ? + r = taosParseTime((char*)utf8, &t, strlen((const char*)utf8), TSDB_TIME_PRECISION_MILLI, 0); + bind->u.v8 = t; + free(utf8); + if (r) { + SET_ERROR(sql, "22007", TSDB_CODE_ODBC_OUT_OF_RANGE, + "convertion from [%s[%d/0x%x]] to [%s[%d/0x%x]] for parameter [%d] failed", + sql_c_type(valueType), valueType, valueType, + taos_data_type(type), type, type, idx+1); + return SQL_ERROR; + } + } break; + case SQL_C_SBIGINT: { + int64_t t = *(int64_t*)paramValue; + bind->u.v8 = t; + } break; + case SQL_C_SHORT: + case SQL_C_SSHORT: + case SQL_C_USHORT: + case SQL_C_LONG: + case SQL_C_SLONG: + case SQL_C_ULONG: + case SQL_C_FLOAT: + case SQL_C_DOUBLE: + case SQL_C_BIT: + case SQL_C_TINYINT: + case SQL_C_STINYINT: + case SQL_C_UTINYINT: + case SQL_C_UBIGINT: + case SQL_C_BINARY: + case SQL_C_DATE: + case SQL_C_TIME: + case SQL_C_TIMESTAMP: + case SQL_C_TYPE_DATE: + case SQL_C_TYPE_TIME: + case SQL_C_TYPE_TIMESTAMP: + case SQL_C_NUMERIC: + case SQL_C_GUID: + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_OUT_OF_RANGE, + "no convertion from [%s[%d/0x%x]] to [%s[%d/0x%x]] for parameter [%d]", + sql_c_type(valueType), valueType, valueType, + taos_data_type(type), type, type, idx+1); + return SQL_ERROR; + } break; + } + } break; + case TSDB_DATA_TYPE_NCHAR: { + bind->buffer_type = type; + bind->length = &bind->buffer_length; + switch (valueType) { + case SQL_C_WCHAR: { + DASSERT(soi); + DASSERT(*soi != SQL_NTS); + size_t bytes = 0; + SQLCHAR *utf8 = wchars_to_chars(paramValue, *soi/2, &bytes); + bind->allocated = 1; + bind->u.nchar = (char*)utf8; + bind->buffer_length = bytes; + bind->buffer = bind->u.nchar; + } break; + case SQL_C_CHAR: { + bind->u.nchar = (char*)paramValue; + if (*soi == SQL_NTS) { + bind->buffer_length = strlen((const char*)paramValue); + } else { + bind->buffer_length = *soi; + } + bind->buffer = bind->u.nchar; + } break; + case SQL_C_SHORT: + case SQL_C_SSHORT: + case SQL_C_USHORT: + case SQL_C_LONG: + case SQL_C_SLONG: + case SQL_C_ULONG: + case SQL_C_FLOAT: + case SQL_C_DOUBLE: + case SQL_C_BIT: + case SQL_C_TINYINT: + case SQL_C_STINYINT: + case SQL_C_UTINYINT: + case SQL_C_SBIGINT: + case SQL_C_UBIGINT: + case SQL_C_BINARY: + case SQL_C_DATE: + case SQL_C_TIME: + case SQL_C_TIMESTAMP: + case SQL_C_TYPE_DATE: + case SQL_C_TYPE_TIME: + case SQL_C_TYPE_TIMESTAMP: + case SQL_C_NUMERIC: + case SQL_C_GUID: + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_OUT_OF_RANGE, + "no convertion from [%s[%d/0x%x]] to [%s[%d/0x%x]] for parameter [%d]", + sql_c_type(valueType), valueType, valueType, + taos_data_type(type), type, type, idx+1); + return SQL_ERROR; + } break; + } + } break; + default: { + SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_OUT_OF_RANGE, + "no convertion from [%s[%d/0x%x]] to [%s[%d/0x%x]] for parameter [%d]", + sql_c_type(valueType), valueType, valueType, + taos_data_type(type), type, type, idx+1); + return SQL_ERROR; + } break; + } + return SQL_SUCCESS; +} + +static SQLRETURN do_bind_batch(sql_t *sql, int idx_row, TAOS_BIND *binds) +{ + for (int j=0; jn_params; ++j) { + SQLRETURN r = do_bind_param_value(sql, idx_row, j, sql->params+j, binds+j); + if (r==SQL_SUCCESS) continue; + return r; + } + if (sql->n_params > 0) { + int tr = 0; + PROFILE(tr = taos_stmt_bind_param(sql->stmt, binds)); + if (tr) { + SET_ERROR(sql, "HY000", tr, "failed to bind parameters[%d in total]", sql->n_params); + return SQL_ERROR; + } + + if (sql->is_insert) { + int r = 0; + PROFILE(r = taos_stmt_add_batch(sql->stmt)); + if (r) { + SET_ERROR(sql, "HY000", r, "failed to add batch"); + return SQL_ERROR; + } + } + } + return SQL_SUCCESS; +} + +static SQLRETURN do_execute(sql_t *sql) +{ + int tr = TSDB_CODE_SUCCESS; + if (sql->n_rows==0) sql->n_rows = 1; + for (int i=0; in_rows; ++i) { + TAOS_BIND *binds = NULL; + if (sql->n_params>0) { + binds = (TAOS_BIND*)calloc(sql->n_params, sizeof(*binds)); + if (!binds) { + SET_ERROR(sql, "HY001", TSDB_CODE_ODBC_OOM, ""); + return SQL_ERROR; + } + } + + SQLRETURN r = do_bind_batch(sql, i, binds); + + if (binds) { + for (int i = 0; in_params; ++i) { + TAOS_BIND *bind = binds + i; + if (bind->allocated) { + free(bind->u.nchar); + bind->u.nchar = NULL; + } + } + free(binds); + } + + if (r) return r; + } + + PROFILE(tr = taos_stmt_execute(sql->stmt)); + if (tr) { + SET_ERROR(sql, "HY000", tr, "failed to execute statement"); + return SQL_ERROR; + } + + sql->is_executed = 1; + if (sql->is_insert) return SQL_SUCCESS; + + SQLRETURN r = SQL_SUCCESS; + PROFILE(sql->rs = taos_stmt_use_result(sql->stmt)); + CHK_RS(r, sql, "failed to use result"); + + return r; +} + +static SQLRETURN doSQLExecute(SQLHSTMT StatementHandle) +{ + sql_t *sql = (sql_t*)StatementHandle; + if (!sql) return SQL_ERROR; + + CHK_CONN(sql); + CHK_CONN_TAOS(sql); + + if (!sql->stmt) { + SET_ERROR(sql, "HY010", TSDB_CODE_ODBC_STATEMENT_NOT_READY, ""); + return SQL_ERROR; + } + + if (sql->rs) { + taos_free_result(sql->rs); + sql->rs = NULL; + sql->row = NULL; + } + + SQLRETURN r = do_execute(sql); + + return r; +} + +SQLRETURN SQL_API SQLExecute(SQLHSTMT StatementHandle) +{ + SQLRETURN r; + PROFILE(r = doSQLExecute(StatementHandle)); + return r; +} + +static SQLRETURN doSQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, + SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier, + SQLPOINTER DiagInfo, SQLSMALLINT BufferLength, + SQLSMALLINT *StringLength) +{ + // if this function is not exported, isql will never call SQLGetDiagRec + return SQL_ERROR; +} + +SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, + SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier, + SQLPOINTER DiagInfo, SQLSMALLINT BufferLength, + SQLSMALLINT *StringLength) +{ + SQLRETURN r; + r = doSQLGetDiagField(HandleType, Handle, + RecNumber, DiagIdentifier, + DiagInfo, BufferLength, + StringLength); + return r; +} + +static SQLRETURN doSQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, + SQLSMALLINT RecNumber, SQLCHAR *Sqlstate, + SQLINTEGER *NativeError, SQLCHAR *MessageText, + SQLSMALLINT BufferLength, SQLSMALLINT *TextLength) +{ + if (RecNumber>1) return SQL_NO_DATA; + + switch (HandleType) { + case SQL_HANDLE_ENV: { + env_t *env = (env_t*)Handle; + if (!env) break; + FILL_ERROR(env); + return SQL_SUCCESS; + } break; + case SQL_HANDLE_DBC: { + conn_t *conn = (conn_t*)Handle; + if (!conn) break; + FILL_ERROR(conn); + return SQL_SUCCESS; + } break; + case SQL_HANDLE_STMT: { + sql_t *sql = (sql_t*)Handle; + if (!sql) break; + FILL_ERROR(sql); + return SQL_SUCCESS; + } break; + default: { + } break; + } + + // how to return error? + return SQL_ERROR; +} + +SQLRETURN SQL_API SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, + SQLSMALLINT RecNumber, SQLCHAR *Sqlstate, + SQLINTEGER *NativeError, SQLCHAR *MessageText, + SQLSMALLINT BufferLength, SQLSMALLINT *TextLength) +{ + SQLRETURN r; + r = doSQLGetDiagRec(HandleType, Handle, + RecNumber, Sqlstate, + NativeError, MessageText, + BufferLength, TextLength); + return r; +} + +static SQLRETURN doSQLBindParameter( + SQLHSTMT StatementHandle, + SQLUSMALLINT ParameterNumber, + SQLSMALLINT fParamType, + SQLSMALLINT ValueType, + SQLSMALLINT ParameterType, + SQLULEN LengthPrecision, + SQLSMALLINT ParameterScale, + SQLPOINTER ParameterValue, + SQLLEN cbValueMax, // ignore for now, since only SQL_PARAM_INPUT is supported now + SQLLEN *StrLen_or_Ind) +{ + sql_t *sql = (sql_t*)StatementHandle; + if (!sql) return SQL_ERROR; + + CHK_CONN(sql); + CHK_CONN_TAOS(sql); + + if (!sql->stmt) { + SET_ERROR(sql, "HY010", TSDB_CODE_ODBC_STATEMENT_NOT_READY, ""); + return SQL_ERROR; + } + + if (ParameterNumber<=0 || ParameterNumber>sql->n_params) { + SET_ERROR(sql, "07009", TSDB_CODE_ODBC_BAD_ARG, + "parameter [@%d] invalid", ParameterNumber); + return SQL_ERROR; + } + + if (fParamType != SQL_PARAM_INPUT) { + SET_ERROR(sql, "HY105", TSDB_CODE_ODBC_NOT_SUPPORT, "non-input parameter [@%d] not supported yet", ParameterNumber); + return SQL_ERROR; + } + + if (ValueType == SQL_C_DEFAULT) { + SET_ERROR(sql, "HY003", TSDB_CODE_ODBC_NOT_SUPPORT, "default value for parameter [@%d] not supported yet", ParameterNumber); + return SQL_ERROR; + } + + if (!is_valid_sql_c_type(ValueType)) { + SET_ERROR(sql, "HY003", TSDB_CODE_ODBC_NOT_SUPPORT, + "SQL_C_TYPE [%s/%d/0x%x] for parameter [@%d] unknown", + sql_c_type(ValueType), ValueType, ValueType, ParameterNumber); + return SQL_ERROR; + } + + if (!is_valid_sql_sql_type(ParameterType)) { + SET_ERROR(sql, "HY004", TSDB_CODE_ODBC_NOT_SUPPORT, + "SQL_TYPE [%s/%d/0x%x] for parameter [@%d] unknown", + sql_c_type(ParameterType), ParameterType, ParameterType, ParameterNumber); + return SQL_ERROR; + } + + param_bind_t *pb = sql->params + ParameterNumber - 1; + + pb->ParameterNumber = ParameterNumber; + pb->ValueType = ValueType; + pb->ParameterType = ParameterType; + pb->LengthPrecision = LengthPrecision; + pb->ParameterScale = ParameterScale; + pb->ParameterValue = ParameterValue; + pb->StrLen_or_Ind = StrLen_or_Ind; + + pb->valid = 1; + return SQL_SUCCESS; +} + +SQLRETURN SQL_API SQLBindParameter( + SQLHSTMT StatementHandle, + SQLUSMALLINT ParameterNumber, + SQLSMALLINT fParamType, + SQLSMALLINT ValueType, + SQLSMALLINT ParameterType, + SQLULEN LengthPrecision, + SQLSMALLINT ParameterScale, + SQLPOINTER ParameterValue, + SQLLEN cbValueMax, // ignore for now, since only SQL_PARAM_INPUT is supported now + SQLLEN *StrLen_or_Ind) +{ + SQLRETURN r; + r = doSQLBindParameter(StatementHandle, ParameterNumber, fParamType, ValueType, ParameterType, + LengthPrecision, ParameterScale, ParameterValue, cbValueMax, StrLen_or_Ind); + return r; +} + +static SQLRETURN doSQLDriverConnect( + SQLHDBC hdbc, + SQLHWND hwnd, + SQLCHAR *szConnStrIn, + SQLSMALLINT cbConnStrIn, + SQLCHAR *szConnStrOut, + SQLSMALLINT cbConnStrOutMax, + SQLSMALLINT *pcbConnStrOut, + SQLUSMALLINT fDriverCompletion) +{ + conn_t *conn = (conn_t*)hdbc; + if (!conn) return SQL_ERROR; + + if (fDriverCompletion!=SQL_DRIVER_NOPROMPT) { + SET_ERROR(conn, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, "option[%d] other than SQL_DRIVER_NOPROMPT not supported yet", fDriverCompletion); + return SQL_ERROR; + } + + if (conn->taos) { + SET_ERROR(conn, "08002", TSDB_CODE_ODBC_CONNECTION_BUSY, "connection still in use"); + return SQL_ERROR; + } + + // DSN=; UID=; PWD= + + const char *connStr = SDUP(szConnStrIn, cbConnStrIn); + + char *serverName = NULL; + char *userName = NULL; + char *auth = NULL; + int bytes = 0; + + do { + if (szConnStrIn && !connStr) { + SET_ERROR(conn, "HY001", TSDB_CODE_ODBC_OOM, ""); + break; + } + + int n = sscanf((const char*)connStr, "DSN=%m[^;]; UID=%m[^;]; PWD=%m[^;] %n", &serverName, &userName, &auth, &bytes); + if (n<1) { + SET_ERROR(conn, "HY000", TSDB_CODE_ODBC_BAD_CONNSTR, "unrecognized connection string: [%s]", (const char*)szConnStrIn); + break; + } + + // TODO: data-race + // TODO: shall receive ip/port from odbc.ini + conn->taos = taos_connect("localhost", userName, auth, NULL, 0); + if (!conn->taos) { + SET_ERROR(conn, "HY000", terrno, "failed to connect to data source"); + break; + } + + if (szConnStrOut) { + snprintf((char*)szConnStrOut, cbConnStrOutMax, "%s", connStr); + } + if (pcbConnStrOut) { + *pcbConnStrOut = cbConnStrIn; + } + + } while (0); + + if (serverName) free(serverName); + if (userName) free(userName); + if (auth) free(auth); + + SFRE(connStr, szConnStrIn, cbConnStrIn); + + return conn->taos ? SQL_SUCCESS : SQL_ERROR; +} + +SQLRETURN SQL_API SQLDriverConnect( + SQLHDBC hdbc, + SQLHWND hwnd, + SQLCHAR *szConnStrIn, + SQLSMALLINT cbConnStrIn, + SQLCHAR *szConnStrOut, + SQLSMALLINT cbConnStrOutMax, + SQLSMALLINT *pcbConnStrOut, + SQLUSMALLINT fDriverCompletion) +{ + SQLRETURN r; + r = doSQLDriverConnect(hdbc, hwnd, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut, fDriverCompletion); + return r; +} + +static SQLRETURN doSQLSetConnectAttr(SQLHDBC ConnectionHandle, + SQLINTEGER Attribute, SQLPOINTER Value, + SQLINTEGER StringLength) +{ + conn_t *conn = (conn_t*)ConnectionHandle; + if (!conn) return SQL_ERROR; + + if (Attribute != SQL_ATTR_AUTOCOMMIT) { + SET_ERROR(conn, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, "Attribute other than SQL_ATTR_AUTOCOMMIT not supported yet"); + return SQL_ERROR; + } + if (Value != (SQLPOINTER)SQL_AUTOCOMMIT_ON) { + SET_ERROR(conn, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, "Attribute Value other than SQL_AUTOCOMMIT_ON not supported yet[%p]", Value); + return SQL_ERROR; + } + + return SQL_SUCCESS; +} + +SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC ConnectionHandle, + SQLINTEGER Attribute, SQLPOINTER Value, + SQLINTEGER StringLength) +{ + SQLRETURN r; + r = doSQLSetConnectAttr(ConnectionHandle, Attribute, Value, StringLength); + return r; +} + +static SQLRETURN doSQLDescribeCol(SQLHSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName, + SQLSMALLINT BufferLength, SQLSMALLINT *NameLength, + SQLSMALLINT *DataType, SQLULEN *ColumnSize, + SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable) +{ + sql_t *sql = (sql_t*)StatementHandle; + if (!sql) return SQL_ERROR; + + CHK_CONN(sql); + CHK_CONN_TAOS(sql); + + if (!sql->rs) { + SET_ERROR(sql, "HY000", TSDB_CODE_ODBC_NO_RESULT, ""); + return SQL_ERROR; + } + + int nfields = taos_field_count(sql->rs); + TAOS_FIELD *fields = taos_fetch_fields(sql->rs); + + if (ColumnNumber<=0 || ColumnNumber>nfields) { + SET_ERROR(sql, "07009", TSDB_CODE_ODBC_OUT_OF_RANGE, "invalid column number [%d]", ColumnNumber); + return SQL_ERROR; + } + + TAOS_FIELD *field = fields + ColumnNumber - 1; + if (ColumnName) { + size_t n = sizeof(field->name); + if (n>BufferLength) n = BufferLength; + strncpy((char*)ColumnName, field->name, n); + } + if (NameLength) { + *NameLength = strnlen(field->name, sizeof(field->name)); + } + if (ColumnSize) { + *ColumnSize = field->bytes; + } + if (DecimalDigits) *DecimalDigits = 0; + + if (DataType) { + switch (field->type) { + case TSDB_DATA_TYPE_BOOL: { + *DataType = SQL_TINYINT; + } break; + + case TSDB_DATA_TYPE_TINYINT: { + *DataType = SQL_TINYINT; + } break; + + case TSDB_DATA_TYPE_SMALLINT: { + *DataType = SQL_SMALLINT; + } break; + + case TSDB_DATA_TYPE_INT: { + *DataType = SQL_INTEGER; + } break; + + case TSDB_DATA_TYPE_BIGINT: { + *DataType = SQL_BIGINT; + } break; + + case TSDB_DATA_TYPE_FLOAT: { + *DataType = SQL_FLOAT; + } break; + + case TSDB_DATA_TYPE_DOUBLE: { + *DataType = SQL_DOUBLE; + } break; + + case TSDB_DATA_TYPE_TIMESTAMP: { + // *DataType = SQL_TIMESTAMP; + // *ColumnSize = 30; + // *DecimalDigits = 3; + *DataType = SQL_TIMESTAMP; + *ColumnSize = sizeof(SQL_TIMESTAMP_STRUCT); + *DecimalDigits = 0; + } break; + + case TSDB_DATA_TYPE_NCHAR: { + *DataType = SQL_CHAR; // unicode ? + if (ColumnSize) *ColumnSize -= VARSTR_HEADER_SIZE; + } break; + + case TSDB_DATA_TYPE_BINARY: { + *DataType = SQL_BINARY; + if (ColumnSize) *ColumnSize -= VARSTR_HEADER_SIZE; + } break; + + default: + SET_ERROR(sql, "HY000", TSDB_CODE_ODBC_NOT_SUPPORT, + "unknown [%s[%d/0x%x]]", taos_data_type(field->type), field->type, field->type); + return SQL_ERROR; + break; + } + } + if (Nullable) { + *Nullable = SQL_NULLABLE_UNKNOWN; + } + + return SQL_SUCCESS; +} + +SQLRETURN SQL_API SQLDescribeCol(SQLHSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName, + SQLSMALLINT BufferLength, SQLSMALLINT *NameLength, + SQLSMALLINT *DataType, SQLULEN *ColumnSize, + SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable) +{ + SQLRETURN r; + r = doSQLDescribeCol(StatementHandle, ColumnNumber, ColumnName, + BufferLength, NameLength, + DataType, ColumnSize, + DecimalDigits, Nullable); + return r; +} + +static SQLRETURN doSQLNumParams(SQLHSTMT hstmt, SQLSMALLINT *pcpar) +{ + sql_t *sql = (sql_t*)hstmt; + if (!sql) return SQL_ERROR; + + CHK_CONN(sql); + CHK_CONN_TAOS(sql); + + if (!sql->stmt) { + SET_ERROR(sql, "HY010", TSDB_CODE_ODBC_STATEMENT_NOT_READY, ""); + return SQL_ERROR; + } + + int insert = 0; + int r = taos_stmt_is_insert(sql->stmt, &insert); + if (r) { + SET_ERROR(sql, "HY000", terrno, ""); + return SQL_ERROR; + } + // if (!insert) { + // SET_ERROR(sql, "HY000", terrno, "taos does not provide count of parameters for statement other than insert"); + // return SQL_ERROR; + // } + + int params = 0; + r = taos_stmt_num_params(sql->stmt, ¶ms); + if (r) { + SET_ERROR(sql, "HY000", terrno, "fetch num of statement params failed"); + return SQL_ERROR; + } + + if (pcpar) *pcpar = params; + + return SQL_SUCCESS; +} + +SQLRETURN SQL_API SQLNumParams(SQLHSTMT hstmt, SQLSMALLINT *pcpar) +{ + SQLRETURN r; + r = doSQLNumParams(hstmt, pcpar); + return r; +} + +static SQLRETURN doSQLSetStmtAttr(SQLHSTMT StatementHandle, + SQLINTEGER Attribute, SQLPOINTER Value, + SQLINTEGER StringLength) +{ + sql_t *sql = (sql_t*)StatementHandle; + if (!sql) return SQL_ERROR; + + CHK_CONN(sql); + CHK_CONN_TAOS(sql); + + if (!sql->stmt) { + SET_ERROR(sql, "HY010", TSDB_CODE_ODBC_STATEMENT_NOT_READY, ""); + return SQL_ERROR; + } + + if (sql->is_executed) { + SET_ERROR(sql, "HY000", TSDB_CODE_ODBC_NOT_SUPPORT, "change attr after executing statement not supported yet"); + return SQL_ERROR; + } + + switch (Attribute) { + case SQL_ATTR_PARAM_BIND_TYPE: { + SQLULEN val = (SQLULEN)Value; + if (val==SQL_BIND_BY_COLUMN) { + sql->rowlen = 0; + SET_ERROR(sql, "HY000", TSDB_CODE_ODBC_NOT_SUPPORT, "SQL_ATTR_PARAM_BIND_TYPE/SQL_BIND_BY_COLUMN"); + return SQL_ERROR; + } + sql->rowlen = val; + return SQL_SUCCESS; + } break; + case SQL_ATTR_PARAMSET_SIZE: { + SQLULEN val = (SQLULEN)Value; + DASSERT(val>0); + sql->n_rows = val; + return SQL_SUCCESS; + } break; + case SQL_ATTR_PARAM_BIND_OFFSET_PTR: { + if (Value) { + SQLULEN val = *(SQLULEN*)Value; + sql->ptr_offset = val; + } else { + sql->ptr_offset = 0; + } + return SQL_SUCCESS; + } break; + default: { + SET_ERROR(sql, "HY000", TSDB_CODE_ODBC_NOT_SUPPORT, "Attribute:%d", Attribute); + } break; + } + return SQL_ERROR; +} + +SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT StatementHandle, + SQLINTEGER Attribute, SQLPOINTER Value, + SQLINTEGER StringLength) +{ + SQLRETURN r; + r = doSQLSetStmtAttr(StatementHandle, Attribute, Value, StringLength); + return r; +} + + + + +static void init_routine(void) { + if (0) { + string_conv(NULL, NULL, NULL, 0, NULL, 0, NULL, NULL); + utf8_to_ucs4le(NULL, NULL); + ucs4le_to_utf8(NULL, 0, NULL); + } + taos_init(); +} + +static int do_field_display_size(TAOS_FIELD *field) { + switch (field->type) { + case TSDB_DATA_TYPE_TINYINT: + return 5; + break; + + case TSDB_DATA_TYPE_SMALLINT: + return 7; + break; + + case TSDB_DATA_TYPE_INT: + return 12; + break; + + case TSDB_DATA_TYPE_BIGINT: + return 22; + break; + + case TSDB_DATA_TYPE_FLOAT: { + return 12; + } break; + + case TSDB_DATA_TYPE_DOUBLE: { + return 20; + } break; + + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: { + return 3*(field->bytes - VARSTR_HEADER_SIZE) + 2; + } break; + + case TSDB_DATA_TYPE_TIMESTAMP: + return 26; + break; + + case TSDB_DATA_TYPE_BOOL: + return 7; + default: + break; + } + + return 10; +} + +// convertion from TSDB_DATA_TYPE_XXX to SQL_C_XXX +static SQLRETURN conv_tsdb_bool_to_c_bit(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b) +{ + int8_t v = b; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_bool_to_c_tinyint(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b) +{ + int8_t v = b; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_bool_to_c_short(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b) +{ + int16_t v = b; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_bool_to_c_long(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b) +{ + int32_t v = b; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_bool_to_c_sbigint(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b) +{ + int64_t v = b; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_bool_to_c_float(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b) +{ + float v = b; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_bool_to_c_double(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b) +{ + double v = b; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_bool_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b) +{ + DASSERT(target->len>0); + *target->soi = 1; + target->ptr[0] = '0' + b; + if (target->len>1) { + target->ptr[1] = '\0'; + } + + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_bool_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t b) +{ + DASSERT(target->len>0); + *target->soi = 1; + target->ptr[0] = '0' + b; + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v1_to_c_tinyint(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1) +{ + int8_t v = v1; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v1_to_c_short(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1) +{ + int16_t v = v1; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v1_to_c_long(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1) +{ + int32_t v = v1; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v1_to_c_sbigint(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1) +{ + int64_t v = v1; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v1_to_c_float(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1) +{ + float v = v1; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v1_to_c_double(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1) +{ + double v = v1; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v1_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1) +{ + char buf[64]; + int n = snprintf(buf, sizeof(buf), "%d", v1); + DASSERT(nsoi = n; + strncpy(target->ptr, buf, (n>=target->len ? target->len : n+1)); + if (n<=target->len) return SQL_SUCCESS; + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_TINYINT -> SQL_C_BIT"); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_v1_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int8_t v1) +{ + char buf[64]; + int n = snprintf(buf, sizeof(buf), "%d", v1); + DASSERT(nsoi = n; + strncpy(target->ptr, buf, (n>target->len ? target->len : n)); + if (n<=target->len) return SQL_SUCCESS; + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_TINYINT -> SQL_C_BIT"); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_v2_to_c_short(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int16_t v2) +{ + int16_t v = v2; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v2_to_c_long(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int16_t v2) +{ + int32_t v = v2; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v2_to_c_sbigint(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int16_t v2) +{ + int64_t v = v2; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v2_to_c_float(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int16_t v2) +{ + float v = v2; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v2_to_c_double(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int16_t v2) +{ + double v = v2; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v2_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int16_t v2) +{ + char buf[64]; + int n = snprintf(buf, sizeof(buf), "%d", v2); + DASSERT(nsoi = n; + strncpy(target->ptr, buf, (n>=target->len ? target->len : n+1)); + if (n<=target->len) return SQL_SUCCESS; + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_SMALLINT -> SQL_C_CHAR"); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_v2_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int16_t v2) +{ + char buf[64]; + int n = snprintf(buf, sizeof(buf), "%d", v2); + DASSERT(nsoi = n; + strncpy(target->ptr, buf, (n>target->len ? target->len : n)); + if (n<=target->len) return SQL_SUCCESS; + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_SMALLINT -> SQL_C_CHAR"); + return SQL_SUCCESS_WITH_INFO; +} + + +static SQLRETURN conv_tsdb_v4_to_c_long(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int32_t v4) +{ + int32_t v = v4; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v4_to_c_sbigint(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int32_t v4) +{ + int64_t v = v4; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v4_to_c_float(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int32_t v4) +{ + float v = v4; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v4_to_c_double(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int32_t v4) +{ + double v = v4; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v4_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int32_t v4) +{ + char buf[64]; + int n = snprintf(buf, sizeof(buf), "%d", v4); + DASSERT(nsoi = n; + strncpy(target->ptr, buf, (n>=target->len ? target->len : n+1)); + if (n<=target->len) return SQL_SUCCESS; + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_INTEGER -> SQL_C_CHAR"); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_v4_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int32_t v4) +{ + char buf[64]; + int n = snprintf(buf, sizeof(buf), "%d", v4); + DASSERT(nsoi = n; + strncpy(target->ptr, buf, (n>target->len ? target->len : n)); + if (n<=target->len) return SQL_SUCCESS; + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_INTEGER -> SQL_C_BINARY"); + return SQL_SUCCESS_WITH_INFO; +} + + +static SQLRETURN conv_tsdb_v8_to_c_sbigint(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int64_t v8) +{ + int64_t v = v8; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v8_to_c_float(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int64_t v8) +{ + float v = v8; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v8_to_c_double(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int64_t v8) +{ + double v = v8; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_v8_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int64_t v8) +{ + char buf[64]; + int n = snprintf(buf, sizeof(buf), "%" PRId64 "", v8); + DASSERT(nsoi = n; + strncpy(target->ptr, buf, (n>=target->len ? target->len : n+1)); + if (n<=target->len) return SQL_SUCCESS; + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_BIGINT -> SQL_C_CHAR"); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_v8_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int64_t v8) +{ + char buf[64]; + int n = snprintf(buf, sizeof(buf), "%" PRId64 "", v8); + DASSERT(nsoi = n; + strncpy(target->ptr, buf, (n>target->len ? target->len : n)); + if (n<=target->len) return SQL_SUCCESS; + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_BIGINT -> SQL_C_BINARY"); + return SQL_SUCCESS_WITH_INFO; +} + + +static SQLRETURN conv_tsdb_f4_to_c_float(sql_t *sql, c_target_t *target, TAOS_FIELD *field, float f4) +{ + float v = f4; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_f4_to_c_double(sql_t *sql, c_target_t *target, TAOS_FIELD *field, float f4) +{ + double v = f4; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_f4_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, float f4) +{ + char buf[64]; + int n = snprintf(buf, sizeof(buf), "%g", f4); + DASSERT(nsoi = n; + strncpy(target->ptr, buf, (n>=target->len ? target->len : n+1)); + if (n<=target->len) return SQL_SUCCESS; + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_FLOAT -> SQL_C_CHAR"); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_f4_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, float f4) +{ + char buf[64]; + int n = snprintf(buf, sizeof(buf), "%g", f4); + DASSERT(nsoi = n; + strncpy(target->ptr, buf, (n>target->len ? target->len : n)); + if (n<=target->len) return SQL_SUCCESS; + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_FLOAT -> SQL_C_BINARY"); + return SQL_SUCCESS_WITH_INFO; +} + + +static SQLRETURN conv_tsdb_f8_to_c_double(sql_t *sql, c_target_t *target, TAOS_FIELD *field, double f8) +{ + double v = f8; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_f8_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, double f8) +{ + char buf[64]; + int n = snprintf(buf, sizeof(buf), "%.6f", f8); + DASSERT(nsoi = n; + strncpy(target->ptr, buf, (n>=target->len ? target->len : n+1)); + if (n<=target->len) return SQL_SUCCESS; + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_DOUBLE -> SQL_C_CHAR"); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_f8_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, double f8) +{ + char buf[64]; + int n = snprintf(buf, sizeof(buf), "%g", f8); + DASSERT(nsoi = n; + strncpy(target->ptr, buf, (n>target->len ? target->len : n)); + if (n<=target->len) return SQL_SUCCESS; + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_DOUBLE -> SQL_C_BINARY"); + return SQL_SUCCESS_WITH_INFO; +} + + +static SQLRETURN conv_tsdb_ts_to_c_v8(sql_t *sql, c_target_t *target, TAOS_FIELD *field, SQL_TIMESTAMP_STRUCT *ts) +{ + struct tm tm = {0}; + tm.tm_sec = ts->second; + tm.tm_min = ts->minute; + tm.tm_hour = ts->hour; + tm.tm_mday = ts->day; + tm.tm_mon = ts->month - 1; + tm.tm_year = ts->year - 1900; + time_t t = mktime(&tm); + DASSERT(sizeof(t) == sizeof(int64_t)); + int64_t v = (int64_t)t; + v *= 1000; + v += ts->fraction / 1000000; + memcpy(target->ptr, &v, sizeof(v)); + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_ts_to_c_str(sql_t *sql, c_target_t *target, TAOS_FIELD *field, SQL_TIMESTAMP_STRUCT *ts) +{ + struct tm tm = {0}; + tm.tm_sec = ts->second; + tm.tm_min = ts->minute; + tm.tm_hour = ts->hour; + tm.tm_mday = ts->day; + tm.tm_mon = ts->month - 1; + tm.tm_year = ts->year - 1900; + + char buf[64]; + int n = strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tm); + DASSERT(n < sizeof(buf)); + + *target->soi = n; + + unsigned int fraction = ts->fraction; + fraction /= 1000000; + snprintf(target->ptr, target->len, "%s.%03d", buf, fraction); + if (target->soi) *target->soi = strlen((const char*)target->ptr); + + if (n <= target->len) { + return SQL_SUCCESS; + } + + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_TIMESTAMP -> SQL_C_CHAR"); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_ts_to_c_bin(sql_t *sql, c_target_t *target, TAOS_FIELD *field, SQL_TIMESTAMP_STRUCT *ts) +{ + struct tm tm = {0}; + tm.tm_sec = ts->second; + tm.tm_min = ts->minute; + tm.tm_hour = ts->hour; + tm.tm_mday = ts->day; + tm.tm_mon = ts->month - 1; + tm.tm_year = ts->year - 1900; + + char buf[64]; + int n = strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tm); + DASSERT(n < sizeof(buf)); + + unsigned int fraction = ts->fraction; + fraction /= 1000000; + snprintf(target->ptr, target->len, "%s.%03d", buf, fraction); + if (target->soi) *target->soi = strlen((const char*)target->ptr); + + if (n <= target->len) { + return SQL_SUCCESS; + } + + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_TIMESTAMP -> SQL_C_BINARY"); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_ts_to_c_ts(sql_t *sql, c_target_t *target, TAOS_FIELD *field, SQL_TIMESTAMP_STRUCT *ts) +{ + DASSERT(target->len == sizeof(*ts)); + memcpy(target->ptr, ts, sizeof(*ts)); + *target->soi = target->len; + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_bin_to_c_str(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const unsigned char *bin) +{ + if (target->len<1) { + SET_ERROR(sql, "HY090", TSDB_CODE_ODBC_BAD_ARG, ""); + return SQL_ERROR; + } + size_t field_bytes = field->bytes - VARSTR_HEADER_SIZE; + size_t n = strnlen((const char*)bin, field_bytes); + + if (n < target->len) { + memcpy(target->ptr, bin, n); + target->ptr[n] = '\0'; + *target->soi = n; + return SQL_SUCCESS; + } + n = target->len - 1; + *target->soi = n; + if (n > 0) { + memcpy(target->ptr, bin, n-1); + target->ptr[n-1] = '\0'; + } + SET_ERROR(sql, "01004", TSDB_CODE_ODBC_CONV_TRUNC, ""); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_bin_to_c_bin(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const unsigned char *bin) +{ + if (target->len<1) { + SET_ERROR(sql, "HY090", TSDB_CODE_ODBC_BAD_ARG, ""); + return SQL_ERROR; + } + size_t field_bytes = field->bytes - VARSTR_HEADER_SIZE; + size_t n = strnlen((const char*)bin, field_bytes); + + if (n <= target->len) { + memcpy(target->ptr, bin, n); + if (nlen) target->ptr[n] = '\0'; + *target->soi = n; + return SQL_SUCCESS; + } + + n = target->len; + memcpy(target->ptr, bin, n); + *target->soi = n; + SET_ERROR(sql, "01004", TSDB_CODE_ODBC_CONV_TRUNC, ""); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_str_to_c_bit(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str) +{ + int bytes = 0; + double f8 = 0; + int n = sscanf(str, "%lf%n", &f8, &bytes); + + int8_t v = f8; + memcpy(target->ptr, &v, sizeof(v)); + + *target->soi = 1; + + if (n!=1 || bytes!=strlen(str)) { + SET_ERROR(sql, "22018", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_NCHAR -> SQL_C_BIT"); + return SQL_SUCCESS_WITH_INFO; + } + + char buf[64]; + snprintf(buf, sizeof(buf), "%d", v); + + if (strcmp(buf, str)==0) { + if (v==0 || v==1) return SQL_SUCCESS; + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_NCHAR -> SQL_C_BIT"); + return SQL_SUCCESS_WITH_INFO; + } + + if (f8>0 || f8<2) { + SET_ERROR(sql, "01S07", TSDB_CODE_ODBC_CONV_TRUNC, "TSDB_DATA_TYPE_NCHAR -> SQL_C_BIT"); + return SQL_SUCCESS_WITH_INFO; + } + + if (f8<0 || f8>2) { + SET_ERROR(sql, "22003", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_NCHAR -> SQL_C_BIT"); + return SQL_SUCCESS_WITH_INFO; + } + + SET_ERROR(sql, "01S07", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_NCHAR -> SQL_C_BIT"); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_str_to_c_v1(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str) +{ + int bytes = 0; + double f8 = 0; + int n = sscanf(str, "%lf%n", &f8, &bytes); + + int8_t v = f8; + memcpy(target->ptr, &v, sizeof(v)); + + *target->soi = 1; + + if (n!=1 || bytes!=strlen(str)) { + SET_ERROR(sql, "22018", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_NCHAR -> SQL_C_TINYINT"); + return SQL_SUCCESS_WITH_INFO; + } + + char buf[64]; + snprintf(buf, sizeof(buf), "%d", v); + + if (strcmp(buf, str)==0) return SQL_SUCCESS; + + if (f8>INT8_MAX || f8 SQL_C_TINYINT"); + return SQL_SUCCESS_WITH_INFO; + } + + SET_ERROR(sql, "01S07", TSDB_CODE_ODBC_CONV_TRUNC, "TSDB_DATA_TYPE_NCHAR -> SQL_C_TINYINT"); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_str_to_c_v2(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str) +{ + int bytes = 0; + double f8 = 0; + int n = sscanf(str, "%lf%n", &f8, &bytes); + + int16_t v = f8; + memcpy(target->ptr, &v, sizeof(v)); + + *target->soi = 2; + + if (n!=1 || bytes!=strlen(str)) { + SET_ERROR(sql, "22018", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_NCHAR -> SQL_C_SHORT"); + return SQL_SUCCESS_WITH_INFO; + } + + char buf[64]; + snprintf(buf, sizeof(buf), "%d", v); + + if (strcmp(buf, str)==0) return SQL_SUCCESS; + + if (f8>INT16_MAX || f8 SQL_C_SHORT"); + return SQL_SUCCESS_WITH_INFO; + } + + SET_ERROR(sql, "01S07", TSDB_CODE_ODBC_CONV_TRUNC, "TSDB_DATA_TYPE_NCHAR -> SQL_C_SHORT"); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_str_to_c_v4(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str) +{ + int bytes = 0; + double f8 = 0; + int n = sscanf(str, "%lf%n", &f8, &bytes); + + int32_t v = f8; + memcpy(target->ptr, &v, sizeof(v)); + + *target->soi = 4; + + if (n!=1 || bytes!=strlen(str)) { + SET_ERROR(sql, "22018", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_NCHAR -> SQL_C_LONG"); + return SQL_SUCCESS_WITH_INFO; + } + + char buf[64]; + snprintf(buf, sizeof(buf), "%d", v); + + if (strcmp(buf, str)==0) return SQL_SUCCESS; + + if (f8>INT32_MAX || f8 SQL_C_LONG"); + return SQL_SUCCESS_WITH_INFO; + } + + SET_ERROR(sql, "01S07", TSDB_CODE_ODBC_CONV_TRUNC, "TSDB_DATA_TYPE_NCHAR -> SQL_C_LONG"); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_str_to_c_v8(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str) +{ + int bytes = 0; + double f8 = 0; + int n = sscanf(str, "%lf%n", &f8, &bytes); + + int64_t v = f8; + memcpy(target->ptr, &v, sizeof(v)); + + *target->soi = 8; + + if (n!=1 || bytes!=strlen(str)) { + SET_ERROR(sql, "22018", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_NCHAR -> SQL_C_SBIGINT"); + return SQL_SUCCESS_WITH_INFO; + } + + char buf[64]; + snprintf(buf, sizeof(buf), "%" PRId64 "", v); + + if (strcmp(buf, str)==0) return SQL_SUCCESS; + + if (f8>INT64_MAX || f8 SQL_C_SBIGINT"); + return SQL_SUCCESS_WITH_INFO; + } + + SET_ERROR(sql, "01S07", TSDB_CODE_ODBC_CONV_TRUNC, "TSDB_DATA_TYPE_NCHAR -> SQL_C_SBIGINT"); + return SQL_SUCCESS_WITH_INFO; +} + +static SQLRETURN conv_tsdb_str_to_c_f4(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str) +{ + int bytes = 0; + double f8 = 0; + int n = sscanf(str, "%lf%n", &f8, &bytes); + + float v = f8; + memcpy(target->ptr, &v, sizeof(v)); + + *target->soi = 4; + + if (n!=1 || bytes!=strlen(str)) { + SET_ERROR(sql, "22018", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_NCHAR -> SQL_C_FLOAT"); + return SQL_SUCCESS_WITH_INFO; + } + + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_str_to_c_f8(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str) +{ + int bytes = 0; + double f8 = 0; + int n = sscanf(str, "%lf%n", &f8, &bytes); + + float v = f8; + memcpy(target->ptr, &v, sizeof(v)); + + *target->soi = 8; + + if (n!=1 || bytes!=strlen(str)) { + SET_ERROR(sql, "22018", TSDB_CODE_ODBC_CONV_UNDEF, "TSDB_DATA_TYPE_NCHAR -> SQL_C_DOUBLE"); + return SQL_SUCCESS_WITH_INFO; + } + + return SQL_SUCCESS; +} + +static SQLRETURN conv_tsdb_str_to_c_str(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str) +{ + return conv_tsdb_bin_to_c_str(sql, target, field, (const unsigned char*)str); +} + +static SQLRETURN conv_tsdb_str_to_c_bin(sql_t *sql, c_target_t *target, TAOS_FIELD *field, const char *str) +{ + return conv_tsdb_bin_to_c_bin(sql, target, field, (const unsigned char*)str); +} + + + + +const char* tsdb_int64_to_bit(int64_t src, int8_t *dst) +{ + *dst = src; + if (src==0 || src==1) return NULL; + return "22003"; +} + +const char* tsdb_int64_to_tinyint(int64_t src, int8_t *dst) +{ + *dst = src; + if (src>=SCHAR_MIN && src<=SCHAR_MAX) return NULL; + return "22003"; +} + +const char* tsdb_int64_to_smallint(int64_t src, int16_t *dst) +{ + *dst = src; + if (src>=SHRT_MIN && src<=SHRT_MAX) return NULL; + return "22003"; +} + +const char* tsdb_int64_to_int(int64_t src, int32_t *dst) +{ + *dst = src; + if (src>=LONG_MIN && src<=LONG_MAX) return NULL; + return "22003"; +} + +const char* tsdb_int64_to_bigint(int64_t src, int64_t *dst) +{ + *dst = src; + return NULL; +} + +const char* tsdb_int64_to_ts(int64_t src, int64_t *dst) +{ + *dst = src; + + char buf[4096]; + int n = snprintf(buf, sizeof(buf), "%" PRId64 "", src); + DASSERT(n>=0); + DASSERT(n=2) return "22003"; + + char buf[4096]; + int n = snprintf(buf, sizeof(buf), "%.*g", precision, src); + DASSERT(n>=0); + DASSERT(nSCHAR_MAX) return "22003"; + + char buf[4096]; + int n = snprintf(buf, sizeof(buf), "%.*g", precision, src); + DASSERT(n>=0); + DASSERT(nSHRT_MAX) return "22003"; + + char buf[4096]; + int n = snprintf(buf, sizeof(buf), "%.*g", precision, src); + DASSERT(n>=0); + DASSERT(nLONG_MAX) return "22003"; + + char buf[4096]; + int n = snprintf(buf, sizeof(buf), "%.*g", precision, src); + DASSERT(n>=0); + DASSERT(nLLONG_MAX) return "22003"; + + char buf[4096]; + int n = snprintf(buf, sizeof(buf), "%.*g", precision, src); + DASSERT(n>=0); + DASSERT(n=0); + DASSERT(n=0); + DASSERT(n2>=0); + DASSERT(n1=0); + if (n>=dlen) return "22001"; + + return NULL; +} + +const char* tsdb_chars_to_bit(const char *src, int8_t *dst) +{ + int bytes = 0; + int64_t v = 0; + int n = sscanf(src, "%" PRId64 "%n", &v, &bytes); + if (n!=1) return "22018"; + + if (bytes!=strlen(src)) { + if (src[bytes-1]=='.') { + if (v==0 || v==1) return "22001"; + + return "22003"; + } + return "22018"; + } + + if (v==0 || v==1) return NULL; + + return "22003"; +} + +const char* tsdb_chars_to_tinyint(const char *src, int8_t *dst) +{ + int bytes = 0; + int64_t v = 0; + int n = sscanf(src, "%" PRId64 "%n", &v, &bytes); + if (n!=1) return "22018"; + + + if (bytes!=strlen(src)) { + if (src[bytes-1]=='.') { + if (vSCHAR_MAX) return "22001"; + + return "22003"; + } + return "22018"; + } + + if (vSCHAR_MAX) return "22001"; + + return NULL; +} + +const char* tsdb_chars_to_smallint(const char *src, int16_t *dst) +{ + int bytes = 0; + int64_t v = 0; + int n = sscanf(src, "%" PRId64 "%n", &v, &bytes); + if (n!=1) return "22018"; + + + if (bytes!=strlen(src)) { + if (src[bytes-1]=='.') { + if (vSHRT_MAX) return "22001"; + + return "22003"; + } + return "22018"; + } + + if (vSHRT_MAX) return "22001"; + + return NULL; +} + +const char* tsdb_chars_to_int(const char *src, int32_t *dst) +{ + int bytes = 0; + int64_t v = 0; + int n = sscanf(src, "%" PRId64 "%n", &v, &bytes); + if (n!=1) return "22018"; + + + if (bytes!=strlen(src)) { + if (src[bytes-1]=='.') { + if (vLONG_MAX) return "22001"; + + return "22003"; + } + return "22018"; + } + + if (vLONG_MAX) return "22001"; + + return NULL; +} + +const char* tsdb_chars_to_bigint(const char *src, int64_t *dst) +{ + int bytes = 0; + int64_t v = 0; + int n = sscanf(src, "%" PRId64 "%n", &v, &bytes); + if (n!=1) return "22018"; + + + if (bytes!=strlen(src)) { + if (src[bytes-1]=='.') { + if (vLLONG_MAX) return "22001"; + + return "22003"; + } + return "22018"; + } + + if (vLLONG_MAX) return "22001"; + + return NULL; +} + +const char* tsdb_chars_to_ts(const char *src, int64_t *dst) +{ + int bytes = 0; + int64_t v = 0; + int n = sscanf(src, "%" PRId64 "%n", &v, &bytes); + if (n!=1) return "22018"; + + + if (bytes!=strlen(src)) { + if (src[bytes-1]=='.') { + if (vLLONG_MAX) return "22001"; + + return "22003"; + } + return "22018"; + } + + if (vLLONG_MAX) return "22001"; + + return NULL; +} + +const char* tsdb_chars_to_float(const char *src, float *dst) +{ + int bytes = 0; + int n = sscanf(src, "%f%n", dst, &bytes); + if (n!=1) return "22018"; + + if (bytes!=strlen(src)) return "22018"; + + return NULL; +} + +const char* tsdb_chars_to_double(const char *src, double *dst) +{ + int bytes = 0; + int n = sscanf(src, "%lf%n", dst, &bytes); + if (n!=1) return "22018"; + + if (bytes!=strlen(src)) return "22018"; + + return NULL; +} + +const char* tsdb_chars_to_char(const char *src, char *dst, size_t dlen) +{ + int n = snprintf(dst, dlen, "%s", src); + if (n>=dlen) return "22001"; + + return NULL; +} + diff --git a/src/connector/odbc/src/todbc_util.c b/src/connector/odbc/src/todbc_util.c new file mode 100644 index 0000000000000000000000000000000000000000..b6b45d8120d28da31dcc1d323893984f9b93519b --- /dev/null +++ b/src/connector/odbc/src/todbc_util.c @@ -0,0 +1,238 @@ +/* + * 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 "todbc_util.h" + +#include "iconv.h" + +#include +#include +#include +#include +#include + +const char* sql_sql_type(int type) { + switch (type) { + case SQL_BIT: return "SQL_BIT"; + case SQL_TINYINT: return "SQL_TINYINT"; + case SQL_SMALLINT: return "SQL_SMALLINT"; + case SQL_INTEGER: return "SQL_INTEGER"; + case SQL_BIGINT: return "SQL_BIGINT"; + case SQL_FLOAT: return "SQL_FLOAT"; + case SQL_DOUBLE: return "SQL_DOUBLE"; + case SQL_DECIMAL: return "SQL_DECIMAL"; + case SQL_NUMERIC: return "SQL_NUMERIC"; + case SQL_REAL: return "SQL_REAL"; + case SQL_CHAR: return "SQL_CHAR"; + case SQL_VARCHAR: return "SQL_VARCHAR"; + case SQL_LONGVARCHAR: return "SQL_LONGVARCHAR"; + case SQL_WCHAR: return "SQL_WCHAR"; + case SQL_WVARCHAR: return "SQL_WVARCHAR"; + case SQL_WLONGVARCHAR: return "SQL_WLONGVARCHAR"; + case SQL_BINARY: return "SQL_BINARY"; + case SQL_VARBINARY: return "SQL_VARBINARY"; + case SQL_LONGVARBINARY: return "SQL_LONGVARBINARY"; + case SQL_DATE: return "SQL_DATE"; + case SQL_TIME: return "SQL_TIME"; + case SQL_TIMESTAMP: return "SQL_TIMESTAMP"; + case SQL_TYPE_DATE: return "SQL_TYPE_DATE"; + case SQL_TYPE_TIME: return "SQL_TYPE_TIME"; + case SQL_TYPE_TIMESTAMP: return "SQL_TYPE_TIMESTAMP"; + case SQL_INTERVAL_MONTH: return "SQL_INTERVAL_MONTH"; + case SQL_INTERVAL_YEAR: return "SQL_INTERVAL_YEAR"; + case SQL_INTERVAL_YEAR_TO_MONTH: return "SQL_INTERVAL_YEAR_TO_MONTH"; + case SQL_INTERVAL_DAY: return "SQL_INTERVAL_DAY"; + case SQL_INTERVAL_HOUR: return "SQL_INTERVAL_HOUR"; + case SQL_INTERVAL_MINUTE: return "SQL_INTERVAL_MINUTE"; + case SQL_INTERVAL_SECOND: return "SQL_INTERVAL_SECOND"; + case SQL_INTERVAL_DAY_TO_HOUR: return "SQL_INTERVAL_DAY_TO_HOUR"; + case SQL_INTERVAL_DAY_TO_MINUTE: return "SQL_INTERVAL_DAY_TO_MINUTE"; + case SQL_INTERVAL_DAY_TO_SECOND: return "SQL_INTERVAL_DAY_TO_SECOND"; + case SQL_INTERVAL_HOUR_TO_MINUTE: return "SQL_INTERVAL_HOUR_TO_MINUTE"; + case SQL_INTERVAL_HOUR_TO_SECOND: return "SQL_INTERVAL_HOUR_TO_SECOND"; + case SQL_INTERVAL_MINUTE_TO_SECOND: return "SQL_INTERVAL_MINUTE_TO_SECOND"; + case SQL_GUID: return "SQL_GUID"; + default: return "UNKNOWN"; + } +} + +const char* sql_c_type(int type) { + switch (type) { + case SQL_C_CHAR: return "SQL_C_CHAR"; + case SQL_C_WCHAR: return "SQL_C_WCHAR"; + case SQL_C_SHORT: return "SQL_C_SHORT"; + case SQL_C_SSHORT: return "SQL_C_SSHORT"; + case SQL_C_USHORT: return "SQL_C_USHORT"; + case SQL_C_LONG: return "SQL_C_LONG"; + case SQL_C_SLONG: return "SQL_C_SLONG"; + case SQL_C_ULONG: return "SQL_C_ULONG"; + case SQL_C_FLOAT: return "SQL_C_FLOAT"; + case SQL_C_DOUBLE: return "SQL_C_DOUBLE"; + case SQL_C_BIT: return "SQL_C_BIT"; + case SQL_C_TINYINT: return "SQL_C_TINYINT"; + case SQL_C_STINYINT: return "SQL_C_STINYINT"; + case SQL_C_UTINYINT: return "SQL_C_UTINYINT"; + case SQL_C_SBIGINT: return "SQL_C_SBIGINT"; + case SQL_C_UBIGINT: return "SQL_C_UBIGINT"; + case SQL_C_BINARY: return "SQL_C_BINARY"; + case SQL_C_DATE: return "SQL_C_DATE"; + case SQL_C_TIME: return "SQL_C_TIME"; + case SQL_C_TIMESTAMP: return "SQL_C_TIMESTAMP"; + case SQL_C_TYPE_DATE: return "SQL_C_TYPE_DATE"; + case SQL_C_TYPE_TIME: return "SQL_C_TYPE_TIME"; + case SQL_C_TYPE_TIMESTAMP: return "SQL_C_TYPE_TIMESTAMP"; + case SQL_C_NUMERIC: return "SQL_C_NUMERIC"; + case SQL_C_GUID: return "SQL_C_GUID"; + default: return "UNKNOWN"; + } +} + +int is_valid_sql_c_type(int type) { + const char *ctype = sql_c_type(type); + if (strcmp(ctype, "UNKNOWN")==0) return 0; + return 1; +} + +int is_valid_sql_sql_type(int type) { + const char *sqltype = sql_sql_type(type); + if (strcmp(sqltype, "UNKNOWN")==0) return 0; + return 1; +} + +int string_conv(const char *fromcode, const char *tocode, + const unsigned char *src, size_t sbytes, + unsigned char *dst, size_t dbytes, + size_t *consumed, size_t *generated) +{ + if (consumed) *consumed = 0; + if (generated) *generated = 0; + + if (dbytes <= 0) return -1; + dst[0] = '\0'; + + iconv_t conv = iconv_open(tocode, fromcode); + if (!conv) return -1; + + int r = 0; + do { + char *s = (char*)src; + char *d = (char*)dst; + size_t sl = sbytes; + size_t dl = dbytes; + + r = iconv(conv, &s, &sl, &d, &dl); + *d = '\0'; + + if (consumed) *consumed = sbytes - sl; + if (generated) *generated = dbytes - dl; + + } while (0); + + iconv_close(conv); + return r; +} + +int utf8_chars(const char *src) +{ + const char *fromcode = "UTF-8"; + const char *tocode = "UCS-2LE"; + iconv_t conv = iconv_open(tocode, fromcode); + if (!conv) return -1; + + size_t slen = strlen(src); + char buf[4096]; + size_t dlen = sizeof(buf); + char *ps = (char*)src; + char *pd = buf; + iconv(conv, &ps, &slen, &pd, &dlen); + DASSERT(slen==0); + + size_t chars = (sizeof(buf) - dlen) / 2; + iconv_close(conv); + return chars; +} + +unsigned char* utf8_to_ucs4le(const char *utf8, size_t *chars) +{ + const char *tocode = "UCS-4LE"; + const char *fromcode = "UTF-8"; + + iconv_t conv = iconv_open(tocode, fromcode); + if (!conv) return NULL; + + unsigned char *ucs4le = NULL; + + do { + size_t slen = strlen(utf8); + size_t dlen = slen * 4; + + ucs4le = (unsigned char*)malloc(dlen+1); + if (!ucs4le) break; + + char *src = (char*)utf8; + char *dst = (char*)ucs4le; + size_t s = slen; + size_t d = dlen; + iconv(conv, &src, &s, &dst, &d); + dst[0] = '\0'; + + if (chars) *chars = (dlen - d) / 4; + } while (0); + + iconv_close(conv); + return ucs4le; +} + +char* ucs4le_to_utf8(const unsigned char *ucs4le, size_t slen, size_t *chars) +{ + const char *fromcode = "UCS-4LE"; + const char *tocode = "UTF-8"; + + iconv_t conv = iconv_open(tocode, fromcode); + if (!conv) return NULL; + + char *utf8 = NULL; + + do { + size_t dlen = slen; + + utf8 = (char*)malloc(dlen+1); + if (!utf8) break; + + char *dst = utf8; + char *src = (char*)ucs4le; + size_t s = slen; + size_t d = dlen; + iconv(conv, &src, &s, &dst, &d); + dst[0] = '\0'; + + if (chars) *chars = (slen - s) / 4; + } while (0); + + iconv_close(conv); + return utf8; +} + +SQLCHAR* wchars_to_chars(const SQLWCHAR *wchars, size_t chs, size_t *bytes) +{ + size_t dlen = chs * 4; + SQLCHAR *dst = (SQLCHAR*)malloc(dlen + 1); + if (!dst) return NULL; + + string_conv("UCS-2LE", "UTF-8", (const unsigned char*)wchars, chs * sizeof(*wchars), dst, dlen + 1, NULL, bytes); + + return dst; +} + diff --git a/src/connector/odbc/src/todbc_util.h b/src/connector/odbc/src/todbc_util.h new file mode 100644 index 0000000000000000000000000000000000000000..43264975b4e618bd495691e59fb9df59f6664e03 --- /dev/null +++ b/src/connector/odbc/src/todbc_util.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TODBC_UTIL_H_ +#define _TODBC_UTIL_H_ + +#include +#include +#include +#include +#include + +#define D(fmt, ...) \ + fprintf(stderr, \ + "%s[%d]:%s() " fmt "\n", \ + basename((char*)__FILE__), __LINE__, __func__, \ + ##__VA_ARGS__) + +#define DASSERT(statement) \ +do { \ + if (statement) break; \ + D("Assertion failure: %s", #statement); \ + abort(); \ +} while (0) + +#define DASSERTX(statement, fmt, ...) \ +do { \ + if (statement) break; \ + D("Assertion failure: %s, " fmt "", #statement, ##__VA_ARGS__); \ + abort(); \ +} while (0) + + + +const char* sql_sql_type(int type); +const char* sql_c_type(int type); + +int is_valid_sql_c_type(int type); +int is_valid_sql_sql_type(int type); + +int string_conv(const char *fromcode, const char *tocode, + const unsigned char *src, size_t sbytes, + unsigned char *dst, size_t dbytes, + size_t *consumed, size_t *generated); +int utf8_chars(const char *src); + +unsigned char* utf8_to_ucs4le(const char *utf8, size_t *chars); +char* ucs4le_to_utf8(const unsigned char *ucs4le, size_t slen, size_t *chars); +SQLCHAR* wchars_to_chars(const SQLWCHAR *wchars, size_t chs, size_t *bytes); + +#endif // _TODBC_UTIL_H_ diff --git a/src/connector/odbc/tests/CMakeLists.txt b/src/connector/odbc/tests/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ac57a5647fce8bd036e133936284f3f4c847d8c8 --- /dev/null +++ b/src/connector/odbc/tests/CMakeLists.txt @@ -0,0 +1,7 @@ +PROJECT(TDengine) + +IF (TD_LINUX) + AUX_SOURCE_DIRECTORY(. SRC) + ADD_EXECUTABLE(tcodbc main.c) + TARGET_LINK_LIBRARIES(tcodbc odbc) +ENDIF () diff --git a/src/connector/odbc/tests/main.c b/src/connector/odbc/tests/main.c new file mode 100644 index 0000000000000000000000000000000000000000..1ac9b71369e8a526b051008b9379fdda4b6a5e77 --- /dev/null +++ b/src/connector/odbc/tests/main.c @@ -0,0 +1,231 @@ +#include +#include + +#include +#include + +#include "os.h" + +// static const char *dsn = "TAOS_DSN"; +// static const char *uid = "root"; +// static const char *pwd = "taosdata"; + +typedef struct data_s data_t; +struct data_s { + int64_t ts; + int8_t b; + int8_t v1; + int16_t v2; + int32_t v4; + int64_t v8; + float f4; + double f8; + char bin[40+1]; + char blob[40+1]; // why 80? ref: tests/examples/c/apitest.c +}; + +static const char *pre_stmts[] = { + "create database db", + "use db", + "create table t (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), blob nchar(10))" +}; + +static const char *pro_stmts[] = { + // "insert into t values ('2019-07-15 00:00:00', 1)", + // "insert into t values ('2019-07-15 01:00:00', 2)", + "select * from t" + // "drop database db" +}; + +#define CHK_RESULT(r, ht, h) \ +do { \ + if (r==0) break; \ + SQLCHAR ss[10]; \ + SQLINTEGER ne = 0; \ + SQLCHAR es[4096]; \ + SQLSMALLINT n = 0; \ + ss[0] = '\0'; \ + es[0] = '\0'; \ + SQLRETURN ret = SQLGetDiagRec(ht, h, 1, ss, &ne, es, sizeof(es), &n); \ + if (ret) break; \ + fprintf(stderr, "%s%s\n", ss, es); \ +} while (0) + +static int do_statement(SQLHSTMT stmt, const char *statement) { + SQLRETURN r = 0; + do { + fprintf(stderr, "prepare [%s]\n", statement); + r = SQLPrepare(stmt, (SQLCHAR*)statement, strlen(statement)); + CHK_RESULT(r, SQL_HANDLE_STMT, stmt); + if (r) break; + fprintf(stderr, "execute [%s]\n", statement); + r = SQLExecute(stmt); + CHK_RESULT(r, SQL_HANDLE_STMT, stmt); + if (r) break; + fprintf(stderr, "done\n"); + } while (0); + fprintf(stderr, "r: [%x][%d]\n", r, r); + return r; +} + +static int do_insert(SQLHSTMT stmt, data_t data) { + SQLRETURN r = 0; + SQLLEN lbin; + SQLLEN lblob; + + const char *statement = "insert into t values (?, ?, ?, ?, ?, ?, ?, ?, ?,?)"; + int ignored = 0; + + do { + fprintf(stderr, "prepare [%s]\n", statement); + r = SQLPrepare(stmt, (SQLCHAR*)statement, strlen(statement)); + CHK_RESULT(r, SQL_HANDLE_STMT, stmt); + if (r) break; + + fprintf(stderr, "bind 1 [%s]\n", statement); + r = SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_SBIGINT, SQL_TIMESTAMP, ignored, ignored, &data.ts, ignored, NULL); + CHK_RESULT(r, SQL_HANDLE_STMT, stmt); + if (r) break; + + fprintf(stderr, "bind 2 [%s]\n", statement); + r = SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_BIT, SQL_BIT, ignored, ignored, &data.b, ignored, NULL); + CHK_RESULT(r, SQL_HANDLE_STMT, stmt); + if (r) break; + + fprintf(stderr, "bind 3 [%s]\n", statement); + r = SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_TINYINT, SQL_TINYINT, ignored, ignored, &data.v1, ignored, NULL); + CHK_RESULT(r, SQL_HANDLE_STMT, stmt); + if (r) break; + + fprintf(stderr, "bind 4 [%s]\n", statement); + r = SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_SHORT, SQL_SMALLINT, ignored, ignored, &data.v2, ignored, NULL); + CHK_RESULT(r, SQL_HANDLE_STMT, stmt); + if (r) break; + + fprintf(stderr, "bind 5 [%s]\n", statement); + r = SQLBindParameter(stmt, 5, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, ignored, ignored, &data.v4, ignored, NULL); + CHK_RESULT(r, SQL_HANDLE_STMT, stmt); + if (r) break; + + fprintf(stderr, "bind 6 [%s]\n", statement); + r = SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_SBIGINT, SQL_BIGINT, ignored, ignored, &data.v8, ignored, NULL); + CHK_RESULT(r, SQL_HANDLE_STMT, stmt); + if (r) break; + + fprintf(stderr, "bind 7 [%s]\n", statement); + r = SQLBindParameter(stmt, 7, SQL_PARAM_INPUT, SQL_C_FLOAT, SQL_FLOAT, ignored, ignored, &data.f4, ignored, NULL); + CHK_RESULT(r, SQL_HANDLE_STMT, stmt); + if (r) break; + + fprintf(stderr, "bind 8 [%s]\n", statement); + r = SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_DOUBLE, ignored, ignored, &data.f8, ignored, NULL); + CHK_RESULT(r, SQL_HANDLE_STMT, stmt); + if (r) break; + + fprintf(stderr, "bind 9 [%s]\n", statement); + lbin = SQL_NTS; + r = SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_VARBINARY, sizeof(data.bin)-1, ignored, &data.bin, ignored, &lbin); + CHK_RESULT(r, SQL_HANDLE_STMT, stmt); + if (r) break; + + fprintf(stderr, "bind 10 [%s]\n", statement); + lblob = SQL_NTS; + r = SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(data.blob)-1, ignored, &data.blob, ignored, &lblob); + CHK_RESULT(r, SQL_HANDLE_STMT, stmt); + if (r) break; + + fprintf(stderr, "execute [%s]\n", statement); + r = SQLExecute(stmt); + CHK_RESULT(r, SQL_HANDLE_STMT, stmt); + if (r) break; + + // ts += 1; + // v = 2; + // fprintf(stderr, "execute [%s]\n", statement); + // r = SQLExecute(stmt); + // if (r) break; + + fprintf(stderr, "done\n"); + } while (0); + fprintf(stderr, "r: [%x][%d]\n", r, r); + return r; +} + +int main(int argc, char *argv[]) { + if (argc < 4) return 1; + const char *dsn = argv[1]; + const char *uid = argv[2]; + const char *pwd = argv[3]; + SQLRETURN r; + SQLHENV env = {0}; + SQLHDBC conn = {0}; + r = SQLAllocEnv(&env); + if (r!=SQL_SUCCESS) return 1; + do { + r = SQLAllocConnect(env, &conn); + CHK_RESULT(r, SQL_HANDLE_ENV, env); + if (r!=SQL_SUCCESS) break; + do { + r = SQLConnect(conn, (SQLCHAR*)dsn, strlen(dsn), + (SQLCHAR*)uid, strlen(uid), + (SQLCHAR*)pwd, strlen(pwd)); + CHK_RESULT(r, SQL_HANDLE_DBC, conn); + if (r!=SQL_SUCCESS) break; + do { + SQLHSTMT stmt = {0}; + r = SQLAllocHandle(SQL_HANDLE_STMT, conn, &stmt); + if (r!=SQL_SUCCESS) break; + do { + do_statement(stmt, "drop database db"); + for (size_t i=0; i ?", 4) +row = cursor.fetchone() +while row: + print(row) + row = cursor.fetchone() +cursor.close() + +cursor = cnxn.cursor() +cursor.execute("SELECT * from db.v where v1 > ?", '5') +row = cursor.fetchone() +while row: + print(row) + row = cursor.fetchone() +cursor.close() + diff --git a/src/connector/python/linux/python2/taos/cinterface.py b/src/connector/python/linux/python2/taos/cinterface.py index c26e5c0967918bd45f362b3df6267561e80dfd66..32859f6b340b4393b523d475bce1ac89cef1a040 100644 --- a/src/connector/python/linux/python2/taos/cinterface.py +++ b/src/connector/python/linux/python2/taos/cinterface.py @@ -225,6 +225,7 @@ class CTaosInterface(object): if connection.value == None: print('connect to TDengine failed') + raise ConnectionError("connect to TDengine failed") # sys.exit(1) else: print('connect to TDengine success') diff --git a/src/connector/python/linux/python2/taos/cursor.py b/src/connector/python/linux/python2/taos/cursor.py index 8c268d8afba2b971709fba6f157abfebdc8dfd1a..37c02d330e856717b5ed0bdac76723cf64d3860b 100644 --- a/src/connector/python/linux/python2/taos/cursor.py +++ b/src/connector/python/linux/python2/taos/cursor.py @@ -192,8 +192,10 @@ class TDengineCursor(object): buffer = [[] for i in range(len(self._fields))] self._rowcount = 0 while True: - block, num_of_fields = CTaosInterface.fetchBlock( - self._result, self._fields) + block, num_of_fields = CTaosInterface.fetchBlock(self._result, self._fields) + errno = CTaosInterface.libtaos.taos_errno(self._result) + if errno != 0: + raise ProgrammingError(CTaosInterface.errStr(self._result), errno) if num_of_fields == 0: break self._rowcount += num_of_fields diff --git a/src/connector/python/linux/python3/taos/cinterface.py b/src/connector/python/linux/python3/taos/cinterface.py index c9d0551af5faedc0b9726fa9be28337f26bba079..609154a3a4b38cfd1cf7976fb755e4aef7be3354 100644 --- a/src/connector/python/linux/python3/taos/cinterface.py +++ b/src/connector/python/linux/python3/taos/cinterface.py @@ -225,6 +225,7 @@ class CTaosInterface(object): if connection.value == None: print('connect to TDengine failed') + raise ConnectionError("connect to TDengine failed") # sys.exit(1) #else: # print('connect to TDengine success') @@ -414,4 +415,4 @@ if __name__ == '__main__': print(data) cinter.freeResult(result) - cinter.close(conn) \ No newline at end of file + cinter.close(conn) diff --git a/src/connector/python/linux/python3/taos/cursor.py b/src/connector/python/linux/python3/taos/cursor.py index 3f0f315d3388fcac1c752c847b7fa1c412b06749..ec7a85ee1a3f8cb0cd49aca8c2a4242dca89021e 100644 --- a/src/connector/python/linux/python3/taos/cursor.py +++ b/src/connector/python/linux/python3/taos/cursor.py @@ -207,8 +207,10 @@ class TDengineCursor(object): buffer = [[] for i in range(len(self._fields))] self._rowcount = 0 while True: - block, num_of_fields = CTaosInterface.fetchBlock( - self._result, self._fields) + block, num_of_fields = CTaosInterface.fetchBlock(self._result, self._fields) + errno = CTaosInterface.libtaos.taos_errno(self._result) + if errno != 0: + raise ProgrammingError(CTaosInterface.errStr(self._result), errno) if num_of_fields == 0: break self._rowcount += num_of_fields diff --git a/src/connector/python/windows/python2/taos/cursor.py b/src/connector/python/windows/python2/taos/cursor.py index 7eee3bfc8f8559454f53aa967f5ad0294a1cb2bf..8714fe77cb739f23f79247a41d72aa127b6d6d25 100644 --- a/src/connector/python/windows/python2/taos/cursor.py +++ b/src/connector/python/windows/python2/taos/cursor.py @@ -142,6 +142,9 @@ class TDengineCursor(object): self._rowcount = 0 while True: block, num_of_fields = CTaosInterface.fetchBlock(self._result, self._fields) + errno = CTaosInterface.libtaos.taos_errno(self._result) + if errno != 0: + raise ProgrammingError(CTaosInterface.errStr(self._result), errno) if num_of_fields == 0: break self._rowcount += num_of_fields for i in range(len(self._fields)): diff --git a/src/connector/python/windows/python3/taos/cursor.py b/src/connector/python/windows/python3/taos/cursor.py index 5f5aa4e1d7d9b454132f533a9e84cca2859db735..c2c442b06ee71ae90ec63662886c709e38d4d2ad 100644 --- a/src/connector/python/windows/python3/taos/cursor.py +++ b/src/connector/python/windows/python3/taos/cursor.py @@ -142,6 +142,9 @@ class TDengineCursor(object): self._rowcount = 0 while True: block, num_of_fields = CTaosInterface.fetchBlock(self._result, self._fields) + errno = CTaosInterface.libtaos.taos_errno(self._result) + if errno != 0: + raise ProgrammingError(CTaosInterface.errStr(self._result), errno) if num_of_fields == 0: break self._rowcount += num_of_fields for i in range(len(self._fields)): diff --git a/src/cq/CMakeLists.txt b/src/cq/CMakeLists.txt index db366639ef8e3a0a702f5dae64d8d048df1e15fe..e6313973484467e4b67be88ffc21225923739b71 100644 --- a/src/cq/CMakeLists.txt +++ b/src/cq/CMakeLists.txt @@ -2,6 +2,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SRC) IF (TD_LINUX) diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index 758d620e571b387bbbe91101c89da3900019b6e3..1a99a84b8ebfe8ed503213299646da39b5b1d27a 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -21,6 +21,7 @@ #include #include "taos.h" +#include "tsclient.h" #include "taosdef.h" #include "taosmsg.h" #include "ttimer.h" @@ -30,10 +31,12 @@ #include "tlog.h" #include "twal.h" -#define cError(...) { if (cqDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR CQ ", cqDebugFlag, __VA_ARGS__); }} -#define cWarn(...) { if (cqDebugFlag & DEBUG_WARN) { taosPrintLog("WARN CQ ", cqDebugFlag, __VA_ARGS__); }} +#define cFatal(...) { if (cqDebugFlag & DEBUG_FATAL) { taosPrintLog("CQ FATAL ", 255, __VA_ARGS__); }} +#define cError(...) { if (cqDebugFlag & DEBUG_ERROR) { taosPrintLog("CQ ERROR ", 255, __VA_ARGS__); }} +#define cWarn(...) { if (cqDebugFlag & DEBUG_WARN) { taosPrintLog("CQ WARN ", 255, __VA_ARGS__); }} +#define cInfo(...) { if (cqDebugFlag & DEBUG_INFO) { taosPrintLog("CQ ", 255, __VA_ARGS__); }} +#define cDebug(...) { if (cqDebugFlag & DEBUG_DEBUG) { taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__); }} #define cTrace(...) { if (cqDebugFlag & DEBUG_TRACE) { taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__); }} -#define cPrint(...) { taosPrintLog("CQ ", 255, __VA_ARGS__); } typedef struct { int vgId; @@ -63,8 +66,6 @@ typedef struct SCqObj { SCqContext * pContext; } SCqObj; -int cqDebugFlag = 135; - static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row); static void cqCreateStream(SCqContext *pContext, SCqObj *pObj); @@ -94,7 +95,7 @@ void *cqOpen(void *ahandle, const SCqCfg *pCfg) { pthread_mutex_init(&pContext->mutex, NULL); - cTrace("vgId:%d, CQ is opened", pContext->vgId); + cInfo("vgId:%d, CQ is opened", pContext->vgId); return pContext; } @@ -125,7 +126,7 @@ void cqClose(void *handle) { taosTmrCleanUp(pContext->tmrCtrl); pContext->tmrCtrl = NULL; - cTrace("vgId:%d, CQ is closed", pContext->vgId); + cInfo("vgId:%d, CQ is closed", pContext->vgId); free(pContext); } @@ -133,7 +134,7 @@ void cqStart(void *handle) { SCqContext *pContext = handle; if (pContext->dbConn || pContext->master) return; - cTrace("vgId:%d, start all CQs", pContext->vgId); + cInfo("vgId:%d, start all CQs", pContext->vgId); pthread_mutex_lock(&pContext->mutex); pContext->master = 1; @@ -149,7 +150,7 @@ void cqStart(void *handle) { void cqStop(void *handle) { SCqContext *pContext = handle; - cTrace("vgId:%d, stop all CQs", pContext->vgId); + cInfo("vgId:%d, stop all CQs", pContext->vgId); if (pContext->dbConn == NULL || pContext->master == 0) return; pthread_mutex_lock(&pContext->mutex); @@ -160,7 +161,7 @@ void cqStop(void *handle) { if (pObj->pStream) { taos_close_stream(pObj->pStream); pObj->pStream = NULL; - cTrace("vgId:%d, id:%d CQ:%s is closed", pContext->vgId, pObj->tid, pObj->sqlStr); + cInfo("vgId:%d, id:%d CQ:%s is closed", pContext->vgId, pObj->tid, pObj->sqlStr); } else { taosTmrStop(pObj->tmrId); pObj->tmrId = 0; @@ -188,7 +189,7 @@ void *cqCreate(void *handle, uint64_t uid, int tid, char *sqlStr, STSchema *pSch pObj->pSchema = tdDupSchema(pSchema); pObj->rowSize = schemaTLen(pSchema); - cTrace("vgId:%d, id:%d CQ:%s is created", pContext->vgId, pObj->tid, pObj->sqlStr); + cInfo("vgId:%d, id:%d CQ:%s is created", pContext->vgId, pObj->tid, pObj->sqlStr); pthread_mutex_lock(&pContext->mutex); @@ -228,7 +229,7 @@ void cqDrop(void *handle) { pObj->tmrId = 0; } - cTrace("vgId:%d, id:%d CQ:%s is dropped", pContext->vgId, pObj->tid, pObj->sqlStr); + cInfo("vgId:%d, id:%d CQ:%s is dropped", pContext->vgId, pObj->tid, pObj->sqlStr); tdFreeSchema(pObj->pSchema); free(pObj->sqlStr); free(pObj); @@ -236,24 +237,31 @@ void cqDrop(void *handle) { pthread_mutex_unlock(&pContext->mutex); } +static void doCreateStream(void *param, TAOS_RES *result, int code) { + SCqObj* pObj = (SCqObj*)param; + SCqContext* pContext = pObj->pContext; + SSqlObj* pSql = (SSqlObj*)result; + pContext->dbConn = pSql->pTscObj; + cqCreateStream(pContext, pObj); +} + static void cqProcessCreateTimer(void *param, void *tmrId) { SCqObj* pObj = (SCqObj*)param; SCqContext* pContext = pObj->pContext; if (pContext->dbConn == NULL) { - pContext->dbConn = taos_connect("localhost", pContext->user, pContext->pass, pContext->db, 0); - if (pContext->dbConn == NULL) { - cError("vgId:%d, failed to connect to TDengine(%s)", pContext->vgId, tstrerror(terrno)); - } + cDebug("vgId:%d, try connect to TDengine", pContext->vgId); + taos_connect_a(NULL, pContext->user, pContext->pass, pContext->db, 0, doCreateStream, param, NULL); + } else { + cqCreateStream(pContext, pObj); } - - cqCreateStream(pContext, pObj); } static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) { pObj->pContext = pContext; if (pContext->dbConn == NULL) { + cDebug("vgId:%d, create dbConn after 1000 ms", pContext->vgId); pObj->tmrId = taosTmrStart(cqProcessCreateTimer, 1000, pObj, pContext->tmrCtrl); return; } @@ -262,7 +270,7 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) { pObj->pStream = taos_open_stream(pContext->dbConn, pObj->sqlStr, cqProcessStreamRes, 0, pObj, NULL); if (pObj->pStream) { pContext->num++; - cTrace("vgId:%d, id:%d CQ:%s is openned", pContext->vgId, pObj->tid, pObj->sqlStr); + cInfo("vgId:%d, id:%d CQ:%s is openned", pContext->vgId, pObj->tid, pObj->sqlStr); } else { cError("vgId:%d, id:%d CQ:%s, failed to open", pContext->vgId, pObj->tid, pObj->sqlStr); } @@ -278,7 +286,7 @@ static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) { STSchema *pSchema = pObj->pSchema; if (pObj->pStream == NULL) return; - cTrace("vgId:%d, id:%d CQ:%s stream result is ready", pContext->vgId, pObj->tid, pObj->sqlStr); + cDebug("vgId:%d, id:%d CQ:%s stream result is ready", pContext->vgId, pObj->tid, pObj->sqlStr); int size = sizeof(SWalHead) + sizeof(SSubmitMsg) + sizeof(SSubmitBlk) + TD_DATA_ROW_HEAD_SIZE + pObj->rowSize; char *buffer = calloc(size, 1); diff --git a/src/dnode/CMakeLists.txt b/src/dnode/CMakeLists.txt index dea90811ad83206b05e29b0e2468b8057ac8d7a8..5608cfd6d16826e399f9ea41dc026d2ab2459610 100644 --- a/src/dnode/CMakeLists.txt +++ b/src/dnode/CMakeLists.txt @@ -4,6 +4,7 @@ PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/mnode/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/tsdb/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/sync/inc) INCLUDE_DIRECTORIES(${TD_ENTERPRISE_DIR}/src/inc) INCLUDE_DIRECTORIES(inc) diff --git a/src/dnode/src/dnodeMPeer.c b/src/dnode/src/dnodeMPeer.c index 82ed7dd1793882c15929aa0899e04357a99359bb..8414d79a9815287dfdfae3af5cc123304745c56d 100644 --- a/src/dnode/src/dnodeMPeer.c +++ b/src/dnode/src/dnodeMPeer.c @@ -33,7 +33,8 @@ typedef struct { } SMPeerWorker; typedef struct { - int32_t num; + int32_t curNum; + int32_t maxNum; SMPeerWorker *peerWorker; } SMPeerWorkerPool; @@ -46,37 +47,44 @@ static void *dnodeProcessMnodePeerQueue(void *param); int32_t dnodeInitMnodePeer() { tsMPeerQset = taosOpenQset(); - tsMPeerPool.num = 1; - tsMPeerPool.peerWorker = (SMPeerWorker *)calloc(sizeof(SMPeerWorker), tsMPeerPool.num); + tsMPeerPool.maxNum = 1; + tsMPeerPool.curNum = 0; + tsMPeerPool.peerWorker = (SMPeerWorker *)calloc(sizeof(SMPeerWorker), tsMPeerPool.maxNum); if (tsMPeerPool.peerWorker == NULL) return -1; - for (int32_t i = 0; i < tsMPeerPool.num; ++i) { + for (int32_t i = 0; i < tsMPeerPool.maxNum; ++i) { SMPeerWorker *pWorker = tsMPeerPool.peerWorker + i; pWorker->workerId = i; + dDebug("dnode mpeer worker:%d is created", i); } - dInfo("dnode mpeer is opened"); + dDebug("dnode mpeer is opened, workers:%d qset:%p", tsMPeerPool.maxNum, tsMPeerQset); return 0; } void dnodeCleanupMnodePeer() { - for (int32_t i = 0; i < tsMPeerPool.num; ++i) { + for (int32_t i = 0; i < tsMPeerPool.maxNum; ++i) { SMPeerWorker *pWorker = tsMPeerPool.peerWorker + i; if (pWorker->thread) { taosQsetThreadResume(tsMPeerQset); } + dDebug("dnode mpeer worker:%d is closed", i); } - for (int32_t i = 0; i < tsMPeerPool.num; ++i) { + for (int32_t i = 0; i < tsMPeerPool.maxNum; ++i) { SMPeerWorker *pWorker = tsMPeerPool.peerWorker + i; + dDebug("dnode mpeer worker:%d start to join", i); if (pWorker->thread) { pthread_join(pWorker->thread, NULL); } + dDebug("dnode mpeer worker:%d join success", i); } + dDebug("dnode mpeer is closed, qset:%p", tsMPeerQset); + taosCloseQset(tsMPeerQset); + tsMPeerQset = NULL; taosTFree(tsMPeerPool.peerWorker); - dInfo("dnode mpeer is closed"); } int32_t dnodeAllocateMnodePqueue() { @@ -85,7 +93,7 @@ int32_t dnodeAllocateMnodePqueue() { taosAddIntoQset(tsMPeerQset, tsMPeerQueue, NULL); - for (int32_t i = 0; i < tsMPeerPool.num; ++i) { + for (int32_t i = tsMPeerPool.curNum; i < tsMPeerPool.maxNum; ++i) { SMPeerWorker *pWorker = tsMPeerPool.peerWorker + i; pWorker->workerId = i; @@ -98,7 +106,9 @@ int32_t dnodeAllocateMnodePqueue() { } pthread_attr_destroy(&thAttr); - dDebug("dnode mpeer worker:%d is launched, total:%d", pWorker->workerId, tsMPeerPool.num); + + tsMPeerPool.curNum = i + 1; + dDebug("dnode mpeer worker:%d is launched, total:%d", pWorker->workerId, tsMPeerPool.maxNum); } dDebug("dnode mpeer queue:%p is allocated", tsMPeerQueue); @@ -106,6 +116,7 @@ int32_t dnodeAllocateMnodePqueue() { } void dnodeFreeMnodePqueue() { + dDebug("dnode mpeer queue:%p is freed", tsMPeerQueue); taosCloseQueue(tsMPeerQueue); tsMPeerQueue = NULL; } @@ -148,7 +159,7 @@ static void *dnodeProcessMnodePeerQueue(void *param) { while (1) { if (taosReadQitemFromQset(tsMPeerQset, &type, (void **)&pPeerMsg, &unUsed) == 0) { - dDebug("dnodeProcessMnodePeerQueue: got no message from qset, exiting..."); + dDebug("qset:%p, mnode peer got no message from qset, exiting", tsMPeerQset); break; } diff --git a/src/dnode/src/dnodeMRead.c b/src/dnode/src/dnodeMRead.c index 6e610d8498ad4776d0eb02098129d6b87992ec0a..fdcbb5889f766ddebdb3f1e56ccffa0b5b129552 100644 --- a/src/dnode/src/dnodeMRead.c +++ b/src/dnode/src/dnodeMRead.c @@ -33,7 +33,8 @@ typedef struct { } SMReadWorker; typedef struct { - int32_t num; + int32_t curNum; + int32_t maxNum; SMReadWorker *readWorker; } SMReadWorkerPool; @@ -46,40 +47,46 @@ static void *dnodeProcessMnodeReadQueue(void *param); int32_t dnodeInitMnodeRead() { tsMReadQset = taosOpenQset(); - tsMReadPool.num = tsNumOfCores * tsNumOfThreadsPerCore / 2; - tsMReadPool.num = MAX(2, tsMReadPool.num); - tsMReadPool.num = MIN(4, tsMReadPool.num); - tsMReadPool.readWorker = (SMReadWorker *)calloc(sizeof(SMReadWorker), tsMReadPool.num); + tsMReadPool.maxNum = tsNumOfCores * tsNumOfThreadsPerCore / 2; + tsMReadPool.maxNum = MAX(2, tsMReadPool.maxNum); + tsMReadPool.maxNum = MIN(4, tsMReadPool.maxNum); + tsMReadPool.curNum = 0; + tsMReadPool.readWorker = (SMReadWorker *)calloc(sizeof(SMReadWorker), tsMReadPool.maxNum); if (tsMReadPool.readWorker == NULL) return -1; - for (int32_t i = 0; i < tsMReadPool.num; ++i) { + for (int32_t i = 0; i < tsMReadPool.maxNum; ++i) { SMReadWorker *pWorker = tsMReadPool.readWorker + i; pWorker->workerId = i; + dDebug("dnode mread worker:%d is created", i); } - dInfo("dnode mread is opened"); + dDebug("dnode mread is opened, workers:%d qset:%p", tsMReadPool.maxNum, tsMReadQset); return 0; } void dnodeCleanupMnodeRead() { - for (int32_t i = 0; i < tsMReadPool.num; ++i) { + for (int32_t i = 0; i < tsMReadPool.maxNum; ++i) { SMReadWorker *pWorker = tsMReadPool.readWorker + i; if (pWorker->thread) { taosQsetThreadResume(tsMReadQset); } + dDebug("dnode mread worker:%d is closed", i); } - for (int32_t i = 0; i < tsMReadPool.num; ++i) { + for (int32_t i = 0; i < tsMReadPool.maxNum; ++i) { SMReadWorker *pWorker = tsMReadPool.readWorker + i; + dDebug("dnode mread worker:%d start to join", i); if (pWorker->thread) { pthread_join(pWorker->thread, NULL); } + dDebug("dnode mread worker:%d start to join", i); } + dDebug("dnode mread is closed, qset:%p", tsMReadQset); + taosCloseQset(tsMReadQset); + tsMReadQset = NULL; free(tsMReadPool.readWorker); - - dInfo("dnode mread is closed"); } int32_t dnodeAllocateMnodeRqueue() { @@ -88,7 +95,7 @@ int32_t dnodeAllocateMnodeRqueue() { taosAddIntoQset(tsMReadQset, tsMReadQueue, NULL); - for (int32_t i = 0; i < tsMReadPool.num; ++i) { + for (int32_t i = tsMReadPool.curNum; i < tsMReadPool.maxNum; ++i) { SMReadWorker *pWorker = tsMReadPool.readWorker + i; pWorker->workerId = i; @@ -101,7 +108,8 @@ int32_t dnodeAllocateMnodeRqueue() { } pthread_attr_destroy(&thAttr); - dDebug("dnode mread worker:%d is launched, total:%d", pWorker->workerId, tsMReadPool.num); + tsMReadPool.curNum = i + 1; + dDebug("dnode mread worker:%d is launched, total:%d", pWorker->workerId, tsMReadPool.maxNum); } dDebug("dnode mread queue:%p is allocated", tsMReadQueue); @@ -109,6 +117,7 @@ int32_t dnodeAllocateMnodeRqueue() { } void dnodeFreeMnodeRqueue() { + dDebug("dnode mread queue:%p is freed", tsMReadQueue); taosCloseQueue(tsMReadQueue); tsMReadQueue = NULL; } @@ -156,7 +165,7 @@ static void *dnodeProcessMnodeReadQueue(void *param) { while (1) { if (taosReadQitemFromQset(tsMReadQset, &type, (void **)&pReadMsg, &unUsed) == 0) { - dDebug("dnodeProcessMnodeReadQueue: got no message from qset, exiting..."); + dDebug("qset:%p, mnode read got no message from qset, exiting", tsMReadQset); break; } diff --git a/src/dnode/src/dnodeMWrite.c b/src/dnode/src/dnodeMWrite.c index 0a305b5598161447bd1e94f0d8c7202389a2f724..384a0fae75088197d7fb01dd67c6e1b9d38739cd 100644 --- a/src/dnode/src/dnodeMWrite.c +++ b/src/dnode/src/dnodeMWrite.c @@ -34,7 +34,8 @@ typedef struct { } SMWriteWorker; typedef struct { - int32_t num; + int32_t curNum; + int32_t maxNum; SMWriteWorker *writeWorker; } SMWriteWorkerPool; @@ -47,38 +48,45 @@ static void *dnodeProcessMnodeWriteQueue(void *param); int32_t dnodeInitMnodeWrite() { tsMWriteQset = taosOpenQset(); - - tsMWritePool.num = 1; - tsMWritePool.writeWorker = (SMWriteWorker *)calloc(sizeof(SMWriteWorker), tsMWritePool.num); + + tsMWritePool.maxNum = 1; + tsMWritePool.curNum = 0; + tsMWritePool.writeWorker = (SMWriteWorker *)calloc(sizeof(SMWriteWorker), tsMWritePool.maxNum); if (tsMWritePool.writeWorker == NULL) return -1; - for (int32_t i = 0; i < tsMWritePool.num; ++i) { + for (int32_t i = 0; i < tsMWritePool.maxNum; ++i) { SMWriteWorker *pWorker = tsMWritePool.writeWorker + i; pWorker->workerId = i; + dDebug("dnode mwrite worker:%d is created", i); } - dInfo("dnode mwrite is opened"); + dDebug("dnode mwrite is opened, workers:%d qset:%p", tsMWritePool.maxNum, tsMWriteQset); return 0; } void dnodeCleanupMnodeWrite() { - for (int32_t i = 0; i < tsMWritePool.num; ++i) { + for (int32_t i = 0; i < tsMWritePool.maxNum; ++i) { SMWriteWorker *pWorker = tsMWritePool.writeWorker + i; if (pWorker->thread) { taosQsetThreadResume(tsMWriteQset); } + dDebug("dnode mwrite worker:%d is closed", i); } - for (int32_t i = 0; i < tsMWritePool.num; ++i) { + for (int32_t i = 0; i < tsMWritePool.maxNum; ++i) { SMWriteWorker *pWorker = tsMWritePool.writeWorker + i; + dDebug("dnode mwrite worker:%d start to join", i); if (pWorker->thread) { pthread_join(pWorker->thread, NULL); } + dDebug("dnode mwrite worker:%d join success", i); } + dDebug("dnode mwrite is closed, qset:%p", tsMWriteQset); + taosCloseQset(tsMWriteQset); + tsMWriteQset = NULL; taosTFree(tsMWritePool.writeWorker); - dInfo("dnode mwrite is closed"); } int32_t dnodeAllocateMnodeWqueue() { @@ -87,7 +95,7 @@ int32_t dnodeAllocateMnodeWqueue() { taosAddIntoQset(tsMWriteQset, tsMWriteQueue, NULL); - for (int32_t i = 0; i < tsMWritePool.num; ++i) { + for (int32_t i = tsMWritePool.curNum; i < tsMWritePool.maxNum; ++i) { SMWriteWorker *pWorker = tsMWritePool.writeWorker + i; pWorker->workerId = i; @@ -100,7 +108,8 @@ int32_t dnodeAllocateMnodeWqueue() { } pthread_attr_destroy(&thAttr); - dDebug("dnode mwrite worker:%d is launched, total:%d", pWorker->workerId, tsMWritePool.num); + tsMWritePool.curNum = i + 1; + dDebug("dnode mwrite worker:%d is launched, total:%d", pWorker->workerId, tsMWritePool.maxNum); } dDebug("dnode mwrite queue:%p is allocated", tsMWriteQueue); @@ -108,6 +117,7 @@ int32_t dnodeAllocateMnodeWqueue() { } void dnodeFreeMnodeWqueue() { + dDebug("dnode mwrite queue:%p is freed", tsMWriteQueue); taosCloseQueue(tsMWriteQueue); tsMWriteQueue = NULL; } @@ -122,11 +132,15 @@ void dnodeDispatchToMnodeWriteQueue(SRpcMsg *pMsg) { SMnodeMsg *pWrite = (SMnodeMsg *)taosAllocateQitem(sizeof(SMnodeMsg)); mnodeCreateMsg(pWrite, pMsg); - dDebug("app:%p:%p, msg:%s is put into mwrite queue", pWrite->rpcMsg.ahandle, pWrite, taosMsg[pWrite->rpcMsg.msgType]); + dDebug("app:%p:%p, msg:%s is put into mwrite queue:%p", pWrite->rpcMsg.ahandle, pWrite, + taosMsg[pWrite->rpcMsg.msgType], tsMWriteQueue); taosWriteQitem(tsMWriteQueue, TAOS_QTYPE_RPC, pWrite); } static void dnodeFreeMnodeWriteMsg(SMnodeMsg *pWrite) { + dDebug("app:%p:%p, msg:%s is freed from mwrite queue:%p", pWrite->rpcMsg.ahandle, pWrite, + taosMsg[pWrite->rpcMsg.msgType], tsMWriteQueue); + mnodeCleanupMsg(pWrite); taosFreeQitem(pWrite); } @@ -158,7 +172,7 @@ static void *dnodeProcessMnodeWriteQueue(void *param) { while (1) { if (taosReadQitemFromQset(tsMWriteQset, &type, (void **)&pWrite, &unUsed) == 0) { - dDebug("dnodeProcessMnodeWriteQueue: got no message from qset, exiting..."); + dDebug("qset:%p, mnode write got no message from qset, exiting", tsMWriteQset); break; } @@ -182,8 +196,8 @@ void dnodeReprocessMnodeWriteMsg(void *pMsg) { dnodeSendRedirectMsg(pMsg, true); dnodeFreeMnodeWriteMsg(pWrite); } else { - dDebug("app:%p:%p, msg:%s is reput into mwrite queue, retry times:%d", pWrite->rpcMsg.ahandle, pWrite, - taosMsg[pWrite->rpcMsg.msgType], pWrite->retry); + dDebug("app:%p:%p, msg:%s is reput into mwrite queue:%p, retry times:%d", pWrite->rpcMsg.ahandle, pWrite, + taosMsg[pWrite->rpcMsg.msgType], tsMWriteQueue, pWrite->retry); taosWriteQitem(tsMWriteQueue, TAOS_QTYPE_RPC, pWrite); } diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index c968246a68e0f8db8c55f8964a9332b17a30fdcc..968a8d9759e5618753996476b40efc3be77f7925 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -74,14 +74,16 @@ static int32_t dnodeProcessAlterVnodeMsg(SRpcMsg *pMsg); static int32_t dnodeProcessDropVnodeMsg(SRpcMsg *pMsg); static int32_t dnodeProcessAlterStreamMsg(SRpcMsg *pMsg); static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg); +static int32_t dnodeProcessCreateMnodeMsg(SRpcMsg *pMsg); static int32_t (*dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *pMsg); int32_t dnodeInitMgmt() { dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_CREATE_VNODE] = dnodeProcessCreateVnodeMsg; - dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_ALTER_VNODE] = dnodeProcessAlterVnodeMsg; + dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_ALTER_VNODE] = dnodeProcessAlterVnodeMsg; dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_DROP_VNODE] = dnodeProcessDropVnodeMsg; dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_ALTER_STREAM] = dnodeProcessAlterStreamMsg; dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeProcessConfigDnodeMsg; + dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_CREATE_MNODE] = dnodeProcessCreateMnodeMsg; dnodeAddClientRspHandle(TSDB_MSG_TYPE_DM_STATUS_RSP, dnodeProcessStatusRsp); dnodeReadDnodeCfg(); @@ -226,7 +228,7 @@ static void *dnodeProcessMgmtQueue(void *param) { while (1) { if (taosReadQitemFromQset(tsMgmtQset, &type, (void **) &pMsg, &handle) == 0) { - dDebug("dnode mgmt got no message from qset, exit ..."); + dDebug("qset:%p, dnode mgmt got no message from qset, exit", tsMgmtQset); break; } @@ -451,10 +453,34 @@ static int32_t dnodeProcessAlterStreamMsg(SRpcMsg *pMsg) { } static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) { - SMDCfgDnodeMsg *pCfg = (SMDCfgDnodeMsg *)pMsg->pCont; + SMDCfgDnodeMsg *pCfg = pMsg->pCont; return taosCfgDynamicOptions(pCfg->config); } +static int32_t dnodeProcessCreateMnodeMsg(SRpcMsg *pMsg) { + SMDCreateMnodeMsg *pCfg = pMsg->pCont; + pCfg->dnodeId = htonl(pCfg->dnodeId); + if (pCfg->dnodeId != dnodeGetDnodeId()) { + dError("dnodeId:%d, in create mnode msg is not equal with saved dnodeId:%d", pCfg->dnodeId, dnodeGetDnodeId()); + return TSDB_CODE_MND_DNODE_ID_NOT_CONFIGURED; + } + + if (strcmp(pCfg->dnodeEp, tsLocalEp) != 0) { + dError("dnodeEp:%s, in create mnode msg is not equal with saved dnodeEp:%s", pCfg->dnodeEp, tsLocalEp); + return TSDB_CODE_MND_DNODE_EP_NOT_CONFIGURED; + } + + dDebug("dnodeId:%d, create mnode msg is received from mnodes, numOfMnodes:%d", pCfg->dnodeId, pCfg->mnodes.nodeNum); + for (int i = 0; i < pCfg->mnodes.nodeNum; ++i) { + pCfg->mnodes.nodeInfos[i].nodeId = htonl(pCfg->mnodes.nodeInfos[i].nodeId); + dDebug("mnode index:%d, mnode:%d:%s", i, pCfg->mnodes.nodeInfos[i].nodeId, pCfg->mnodes.nodeInfos[i].nodeEp); + } + + dnodeStartMnode(&pCfg->mnodes); + + return TSDB_CODE_SUCCESS; +} + void dnodeUpdateMnodeEpSetForPeer(SRpcEpSet *pEpSet) { if (pEpSet->numOfEps <= 0) { dError("mnode EP list for peer is changed, but content is invalid, discard it"); @@ -464,7 +490,7 @@ void dnodeUpdateMnodeEpSetForPeer(SRpcEpSet *pEpSet) { dInfo("mnode EP list for peer is changed, numOfEps:%d inUse:%d", pEpSet->numOfEps, pEpSet->inUse); for (int i = 0; i < pEpSet->numOfEps; ++i) { pEpSet->port[i] -= TSDB_PORT_DNODEDNODE; - dInfo("mnode index:%d %s:%u", i, pEpSet->fqdn[i], pEpSet->port[i]) + dInfo("mnode index:%d %s:%u", i, pEpSet->fqdn[i], pEpSet->port[i]); } tsDMnodeEpSet = *pEpSet; @@ -509,7 +535,9 @@ static void dnodeProcessStatusRsp(SRpcMsg *pMsg) { } vnodeSetAccess(pStatusRsp->vgAccess, pCfg->numOfVnodes); - dnodeProcessModuleStatus(pCfg->moduleStatus); + + // will not set mnode in status msg + // dnodeProcessModuleStatus(pCfg->moduleStatus); dnodeUpdateDnodeCfg(pCfg); dnodeUpdateMnodeInfos(pMnodes); @@ -553,7 +581,7 @@ static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes) { } dnodeSaveMnodeInfos(); - sdbUpdateSync(); + sdbUpdateAsync(); } static bool dnodeReadMnodeInfos() { diff --git a/src/dnode/src/dnodeModule.c b/src/dnode/src/dnodeModule.c index 0a5b9b550cab09a4bdd5abb25c28aa5c202d8f90..46376159c6782efde7adbd19c75af83aa4cde397 100644 --- a/src/dnode/src/dnodeModule.c +++ b/src/dnode/src/dnodeModule.c @@ -97,7 +97,7 @@ void dnodeCleanupModules() { } } - if (tsModule[TSDB_MOD_MNODE].enable && tsModule[TSDB_MOD_MNODE].cleanUpFp) { + if (tsModule[TSDB_MOD_MNODE].cleanUpFp) { (*tsModule[TSDB_MOD_MNODE].cleanUpFp)(); } } @@ -146,19 +146,19 @@ void dnodeProcessModuleStatus(uint32_t moduleStatus) { } } -bool dnodeCheckMnodeStarting() { - if (tsModuleStatus & TSDB_MOD_MNODE) return false; - - SDMMnodeInfos *mnodes = dnodeGetMnodeInfos(); - for (int32_t i = 0; i < mnodes->nodeNum; ++i) { - SDMMnodeInfo *node = &mnodes->nodeInfos[i]; - if (node->nodeId == dnodeGetDnodeId()) { - uint32_t moduleStatus = tsModuleStatus | (1 << TSDB_MOD_MNODE);; - dInfo("start mnode module, module status:%d, new status:%d", tsModuleStatus, moduleStatus); - dnodeProcessModuleStatus(moduleStatus); - return true; - } +bool dnodeStartMnode(void *pMnodes) { + SDMMnodeInfos *mnodes = pMnodes; + + if (tsModuleStatus & (1 << TSDB_MOD_MNODE)) { + dDebug("mnode module is already started, module status:%d", tsModuleStatus); + return false; } - return false; + uint32_t moduleStatus = tsModuleStatus | (1 << TSDB_MOD_MNODE); + dInfo("start mnode module, module status:%d, new status:%d", tsModuleStatus, moduleStatus); + dnodeProcessModuleStatus(moduleStatus); + + sdbUpdateSync(mnodes); + + return true; } diff --git a/src/dnode/src/dnodePeer.c b/src/dnode/src/dnodePeer.c index c09d7422396b4525945ae0bb1f32d77d82ac9903..3bc2f7b48b319f3c9e6215a05463ebedc74035fa 100644 --- a/src/dnode/src/dnodePeer.c +++ b/src/dnode/src/dnodePeer.c @@ -48,6 +48,7 @@ int32_t dnodeInitServer() { dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_VNODE] = dnodeDispatchToMgmtQueue; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_ALTER_STREAM] = dnodeDispatchToMgmtQueue; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeDispatchToMgmtQueue; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_MNODE] = dnodeDispatchToMgmtQueue; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_TABLE] = dnodeDispatchToMnodePeerQueue; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = dnodeDispatchToMnodePeerQueue; @@ -170,8 +171,12 @@ void dnodeSendMsgToDnode(SRpcEpSet *epSet, SRpcMsg *rpcMsg) { rpcSendRequest(tsDnodeClientRpc, epSet, rpcMsg); } -void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp) { +void dnodeSendMsgToMnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp) { SRpcEpSet epSet = {0}; dnodeGetMnodeEpSetForPeer(&epSet); rpcSendRecv(tsDnodeClientRpc, &epSet, rpcMsg, rpcRsp); } + +void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp, SRpcEpSet *epSet) { + rpcSendRecv(tsDnodeClientRpc, epSet, rpcMsg, rpcRsp); +} \ No newline at end of file diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index 4a1d337824e3a7879c651b8db3a3465e526c9299..4c6c2100e048e9aaf23f4155d3c54604104a8f9b 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -156,7 +156,7 @@ static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char dDebug("user:%s, send auth msg to mnodes", user); SRpcMsg rpcRsp = {0}; - dnodeSendMsgToDnodeRecv(&rpcMsg, &rpcRsp); + dnodeSendMsgToMnodeRecv(&rpcMsg, &rpcRsp); if (rpcRsp.code != 0) { dError("user:%s, auth msg received from mnodes, error:%s", user, tstrerror(rpcRsp.code)); @@ -173,15 +173,15 @@ static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char return rpcRsp.code; } -void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t sid) { - dDebug("vgId:%d, sid:%d send config table msg to mnode", vgId, sid); +void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t tid) { + dDebug("vgId:%d, tid:%d send config table msg to mnode", vgId, tid); int32_t contLen = sizeof(SDMConfigTableMsg); SDMConfigTableMsg *pMsg = rpcMallocCont(contLen); pMsg->dnodeId = htonl(dnodeGetDnodeId()); pMsg->vgId = htonl(vgId); - pMsg->sid = htonl(sid); + pMsg->tid = htonl(tid); SRpcMsg rpcMsg = {0}; rpcMsg.pCont = pMsg; @@ -189,23 +189,23 @@ void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t sid) { rpcMsg.msgType = TSDB_MSG_TYPE_DM_CONFIG_TABLE; SRpcMsg rpcRsp = {0}; - dnodeSendMsgToDnodeRecv(&rpcMsg, &rpcRsp); + dnodeSendMsgToMnodeRecv(&rpcMsg, &rpcRsp); terrno = rpcRsp.code; if (rpcRsp.code != 0) { rpcFreeCont(rpcRsp.pCont); - dError("vgId:%d, sid:%d failed to config table from mnode", vgId, sid); + dError("vgId:%d, tid:%d failed to config table from mnode", vgId, tid); return NULL; } else { - dInfo("vgId:%d, sid:%d config table msg is received", vgId, sid); + dInfo("vgId:%d, tid:%d config table msg is received", vgId, tid); // delete this after debug finished SMDCreateTableMsg *pTable = rpcRsp.pCont; int16_t numOfColumns = htons(pTable->numOfColumns); int16_t numOfTags = htons(pTable->numOfTags); - int32_t sid = htonl(pTable->sid); + int32_t tableId = htonl(pTable->tid); uint64_t uid = htobe64(pTable->uid); - dInfo("table:%s, numOfColumns:%d numOfTags:%d sid:%d uid:%" PRIu64, pTable->tableId, numOfColumns, numOfTags, sid, uid); + dInfo("table:%s, numOfColumns:%d numOfTags:%d tid:%d uid:%" PRIu64, pTable->tableId, numOfColumns, numOfTags, tableId, uid); return rpcRsp.pCont; } diff --git a/src/dnode/src/dnodeTelemetry.c b/src/dnode/src/dnodeTelemetry.c index 8ed4a9518b6c8a80bf79e0c7f326da54fa7d9e83..4fdc0b8a73b58efa801f33ea99ffb7d123a72dcf 100644 --- a/src/dnode/src/dnodeTelemetry.c +++ b/src/dnode/src/dnodeTelemetry.c @@ -177,7 +177,8 @@ static void addMemoryInfo(SBufferWriter* bw) { static void addVersionInfo(SBufferWriter* bw) { addStringField(bw, "version", version); addStringField(bw, "buildInfo", buildinfo); - addStringField(bw, "gitInfo", gitinfo); + addStringField(bw, "gitInfo", gitinfo); + addStringField(bw, "email", tsEmail); } static void addRuntimeInfo(SBufferWriter* bw) { @@ -261,11 +262,27 @@ static void* telemetryThread(void* param) { return NULL; } +static void dnodeGetEmail(char* filepath) { + int fd = open(filepath, O_RDONLY); + if (fd < 0) { + return; + } + + if (taosTRead(fd, (void *)tsEmail, TSDB_FQDN_LEN) < 0) { + dError("failed to read %d bytes from file %s since %s", TSDB_FQDN_LEN, filepath, strerror(errno)); + } + + close(fd); +} + + int32_t dnodeInitTelemetry() { if (!tsEnableTelemetryReporting) { return 0; } + dnodeGetEmail("/usr/local/taos/email"); + if (tsem_init(&tsExitSem, 0, 0) == -1) { // just log the error, it is ok for telemetry to fail dTrace("failed to create semaphore for telemetry, reason:%s", strerror(errno)); diff --git a/src/dnode/src/dnodeVRead.c b/src/dnode/src/dnodeVRead.c index d66ebf9772bcf702490b5c780de3223cd1b6a833..e61158ef30dddd6037af36c61be1fd522f8af10b 100644 --- a/src/dnode/src/dnodeVRead.c +++ b/src/dnode/src/dnodeVRead.c @@ -187,8 +187,8 @@ void dnodeSendRpcReadRsp(void *pVnode, SReadMsg *pRead, int32_t code) { } void dnodeDispatchNonRspMsg(void *pVnode, SReadMsg *pRead, int32_t code) { + rpcFreeCont(pRead->rpcMsg.pCont); vnodeRelease(pVnode); - return; } static void *dnodeProcessReadQueue(void *param) { @@ -198,7 +198,7 @@ static void *dnodeProcessReadQueue(void *param) { while (1) { if (taosReadQitemFromQset(readQset, &type, (void **)&pReadMsg, &pVnode) == 0) { - dDebug("dnodeProcessReadQueee: got no message from qset, exiting..."); + dDebug("qset:%p dnode read got no message from qset, exiting", readQset); break; } @@ -212,7 +212,8 @@ static void *dnodeProcessReadQueue(void *param) { } else { if (code == TSDB_CODE_QRY_HAS_RSP) { dnodeSendRpcReadRsp(pVnode, pReadMsg, pReadMsg->rpcMsg.code); - } else { // code == TSDB_CODE_NOT_READY, do not return msg to client + } else { // code == TSDB_CODE_QRY_NOT_READY, do not return msg to client + assert(pReadMsg->rpcMsg.handle == NULL || (pReadMsg->rpcMsg.handle != NULL && pReadMsg->rpcMsg.msgType == 5)); dnodeDispatchNonRspMsg(pVnode, pReadMsg, code); } } diff --git a/src/dnode/src/dnodeVWrite.c b/src/dnode/src/dnodeVWrite.c index 51bc8890fcd98b6f5dee4c88d2858990e68bc2a3..f2740bf6b810197283926a602db4fc423067e231 100644 --- a/src/dnode/src/dnodeVWrite.c +++ b/src/dnode/src/dnodeVWrite.c @@ -24,8 +24,10 @@ #include "twal.h" #include "tdataformat.h" #include "tglobal.h" +#include "tsync.h" #include "vnode.h" #include "dnodeInt.h" +#include "syncInt.h" #include "dnodeVWrite.h" #include "dnodeMgmt.h" @@ -188,6 +190,7 @@ void dnodeFreeVnodeWqueue(void *wqueue) { void dnodeSendRpcVnodeWriteRsp(void *pVnode, void *param, int32_t code) { SWriteMsg *pWrite = (SWriteMsg *)param; + if (pWrite == NULL) return; if (code < 0) pWrite->code = code; int32_t count = atomic_add_fetch_32(&pWrite->processedCount, 1); @@ -210,19 +213,19 @@ void dnodeSendRpcVnodeWriteRsp(void *pVnode, void *param, int32_t code) { static void *dnodeProcessWriteQueue(void *param) { SWriteWorker *pWorker = (SWriteWorker *)param; - SWriteMsg *pWrite; - SWalHead *pHead; + SWriteMsg * pWrite; + SWalHead * pHead; int32_t numOfMsgs; int type; - void *pVnode, *item; - SRspRet *pRspRet; + void * pVnode, *item; + SRspRet * pRspRet; dDebug("write worker:%d is running", pWorker->workerId); while (1) { numOfMsgs = taosReadAllQitemsFromQset(pWorker->qset, pWorker->qall, &pVnode); if (numOfMsgs == 0) { - dDebug("dnodeProcessWriteQueee: got no message from qset, exiting..."); + dDebug("qset:%p, dnode write got no message from qset, exiting", pWorker->qset); break; } @@ -237,16 +240,25 @@ static void *dnodeProcessWriteQueue(void *param) { pHead->msgType = pWrite->rpcMsg.msgType; pHead->version = 0; pHead->len = pWrite->contLen; - dDebug("%p, rpc msg:%s will be processed in vwrite queue", pWrite->rpcMsg.ahandle, taosMsg[pWrite->rpcMsg.msgType]); + dDebug("%p, rpc msg:%s will be processed in vwrite queue", pWrite->rpcMsg.ahandle, + taosMsg[pWrite->rpcMsg.msgType]); + } else if (type == TAOS_QTYPE_CQ) { + pHead = (SWalHead *)((char*)item + sizeof(SSyncHead)); + dTrace("%p, CQ wal msg:%s will be processed in vwrite queue, version:%" PRIu64, pHead, taosMsg[pHead->msgType], + pHead->version); } else { pHead = (SWalHead *)item; - dTrace("%p, wal msg:%s will be processed in vwrite queue, version:%" PRIu64, pHead, taosMsg[pHead->msgType], pHead->version); + dTrace("%p, wal msg:%s will be processed in vwrite queue, version:%" PRIu64, pHead, taosMsg[pHead->msgType], + pHead->version); } int32_t code = vnodeProcessWrite(pVnode, type, pHead, pRspRet); - if (pWrite) { + dTrace("%p, msg:%s is processed in vwrite queue, version:%" PRIu64 ", result:%s", pHead, taosMsg[pHead->msgType], + pHead->version, tstrerror(code)); + + if (pWrite) { pWrite->rpcMsg.code = code; - if (code <= 0) pWrite->processedCount = 1; + if (code <= 0) pWrite->processedCount = 1; } } @@ -258,7 +270,7 @@ static void *dnodeProcessWriteQueue(void *param) { taosGetQitem(pWorker->qall, &type, &item); if (type == TAOS_QTYPE_RPC) { pWrite = (SWriteMsg *)item; - dnodeSendRpcVnodeWriteRsp(pVnode, item, pWrite->rpcMsg.code); + dnodeSendRpcVnodeWriteRsp(pVnode, item, pWrite->rpcMsg.code); } else if (type == TAOS_QTYPE_FWD) { pHead = (SWalHead *)item; vnodeConfirmForward(pVnode, pHead->version, 0); @@ -279,13 +291,13 @@ static void dnodeHandleIdleWorker(SWriteWorker *pWorker) { int32_t num = taosGetQueueNumber(pWorker->qset); if (num > 0) { - usleep(30000); - sched_yield(); + usleep(30000); + sched_yield(); } else { - taosFreeQall(pWorker->qall); - taosCloseQset(pWorker->qset); - pWorker->qset = NULL; - dDebug("write worker:%d is released", pWorker->workerId); - pthread_exit(NULL); + taosFreeQall(pWorker->qall); + taosCloseQset(pWorker->qset); + pWorker->qset = NULL; + dDebug("write worker:%d is released", pWorker->workerId); + pthread_exit(NULL); } } diff --git a/src/inc/dnode.h b/src/inc/dnode.h index fda9c1c1ddd928ccf02bd6fd8a1480b30769bb6b..e84545be1753f3fedb4ee78acf397c91d824ad8b 100644 --- a/src/inc/dnode.h +++ b/src/inc/dnode.h @@ -43,12 +43,13 @@ void dnodeGetMnodeEpSetForPeer(void *epSet); void dnodeGetMnodeEpSetForShell(void *epSet); void * dnodeGetMnodeInfos(); int32_t dnodeGetDnodeId(); -bool dnodeCheckMnodeStarting(); +bool dnodeStartMnode(void *pModes); void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); void dnodeSendMsgToDnode(SRpcEpSet *epSet, SRpcMsg *rpcMsg); -void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp); -void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t sid); +void dnodeSendMsgToMnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp); +void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp, SRpcEpSet *epSet); +void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t tid); void *dnodeAllocateVnodeWqueue(void *pVnode); void dnodeFreeVnodeWqueue(void *queue); diff --git a/src/inc/mnode.h b/src/inc/mnode.h index 03a25e0f92b881b6b1b9bcfcf6605257b776ae1b..5bef7402e30a0cc9f1964cc2430e0b1f5141590c 100644 --- a/src/inc/mnode.h +++ b/src/inc/mnode.h @@ -60,7 +60,8 @@ int32_t mnodeInitSystem(); int32_t mnodeStartSystem(); void mnodeCleanupSystem(); void mnodeStopSystem(); -void sdbUpdateSync(); +void sdbUpdateAsync(); +void sdbUpdateSync(void *pMnodes); bool mnodeIsRunning(); int32_t mnodeProcessRead(SMnodeMsg *pMsg); int32_t mnodeProcessWrite(SMnodeMsg *pMsg); diff --git a/src/inc/query.h b/src/inc/query.h index 0c18f85dc31bae5e77bae7228d5390a8d32df07a..5e1de77889cc469566cc94b729c55622e5462bd6 100644 --- a/src/inc/query.h +++ b/src/inc/query.h @@ -78,7 +78,6 @@ int32_t qKillQuery(qinfo_t qinfo); int32_t qQueryCompleted(qinfo_t qinfo); - /** * destroy query info structure * @param qHandle diff --git a/src/inc/taos.h b/src/inc/taos.h index 7e8f174b7c3737463f7e66dfdc6d5cd906791ee3..315313734753de73bf477b1f67783a45c38c87c9 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -22,12 +22,12 @@ extern "C" { #endif -typedef void TAOS; -typedef void** TAOS_ROW; -typedef void TAOS_RES; -typedef void TAOS_SUB; -typedef void TAOS_STREAM; -typedef void TAOS_STMT; +typedef void TAOS; +typedef void TAOS_STMT; +typedef void TAOS_RES; +typedef void TAOS_STREAM; +typedef void TAOS_SUB; +typedef void **TAOS_ROW; // Data type definition #define TSDB_DATA_TYPE_NULL 0 // 1 bytes @@ -69,6 +69,8 @@ DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...); DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port); DLL_EXPORT void taos_close(TAOS *taos); +const char *taos_data_type(int type); + typedef struct TAOS_BIND { int buffer_type; void * buffer; @@ -77,10 +79,26 @@ typedef struct TAOS_BIND { int * is_null; int is_unsigned; // unused int * error; // unused + union { + int64_t ts; + int8_t b; + int8_t v1; + int16_t v2; + int32_t v4; + int64_t v8; + float f4; + double f8; + unsigned char *bin; + char *nchar; + } u; + unsigned int allocated; } TAOS_BIND; TAOS_STMT *taos_stmt_init(TAOS *taos); int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length); +int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert); +int taos_stmt_num_params(TAOS_STMT *stmt, int *nums); +int taos_stmt_get_param(TAOS_STMT *stmt, int idx, int *type, int *bytes); int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind); int taos_stmt_add_batch(TAOS_STMT *stmt); int taos_stmt_execute(TAOS_STMT *stmt); diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 9a411d8f858b9f6f90651e8f4d40d6f3c46a02f5..aee60da20147c674979540aa73da5ac101fae7f0 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -64,7 +64,7 @@ extern const int32_t TYPE_BYTES[11]; // TODO: replace and remove code below #define CHAR_BYTES sizeof(char) #define SHORT_BYTES sizeof(int16_t) -#define INT_BYTES sizeof(int) +#define INT_BYTES sizeof(int32_t) #define LONG_BYTES sizeof(int64_t) #define FLOAT_BYTES sizeof(float) #define DOUBLE_BYTES sizeof(double) @@ -73,7 +73,7 @@ extern const int32_t TYPE_BYTES[11]; #define TSDB_DATA_BOOL_NULL 0x02 #define TSDB_DATA_TINYINT_NULL 0x80 #define TSDB_DATA_SMALLINT_NULL 0x8000 -#define TSDB_DATA_INT_NULL 0x80000000 +#define TSDB_DATA_INT_NULL 0x80000000L #define TSDB_DATA_BIGINT_NULL 0x8000000000000000L #define TSDB_DATA_FLOAT_NULL 0x7FF00000 // it is an NAN @@ -131,22 +131,31 @@ do { \ #define GET_INT16_VAL(x) (*(int16_t *)(x)) #define GET_INT32_VAL(x) (*(int32_t *)(x)) #define GET_INT64_VAL(x) (*(int64_t *)(x)) -#ifdef _TD_ARM_32_ - #define GET_FLOAT_VAL(x) taos_align_get_float(x) - #define GET_DOUBLE_VAL(x) taos_align_get_double(x) - - float taos_align_get_float(const char* pBuf); - double taos_align_get_double(const char* pBuf); +#ifdef _TD_ARM_32 //#define __float_align_declear() float __underlyFloat = 0.0; //#define __float_align_declear() //#define GET_FLOAT_VAL_ALIGN(x) (*(int32_t*)&(__underlyFloat) = *(int32_t*)(x); __underlyFloat); // notes: src must be float or double type variable !!! - #define SET_FLOAT_VAL_ALIGN(dst, src) (*(int32_t*) dst = *(int32_t*)src); - #define SET_DOUBLE_VAL_ALIGN(dst, src) (*(int64_t*) dst = *(int64_t*)src); + //#define SET_FLOAT_VAL_ALIGN(dst, src) (*(int32_t*) dst = *(int32_t*)src); + //#define SET_DOUBLE_VAL_ALIGN(dst, src) (*(int64_t*) dst = *(int64_t*)src); + + float taos_align_get_float(const char* pBuf); + double taos_align_get_double(const char* pBuf); + + #define GET_FLOAT_VAL(x) taos_align_get_float(x) + #define GET_DOUBLE_VAL(x) taos_align_get_double(x) + #define SET_FLOAT_VAL(x, y) { float z = (float)(y); (*(int32_t*) x = *(int32_t*)(&z)); } + #define SET_DOUBLE_VAL(x, y) { double z = (double)(y); (*(int64_t*) x = *(int64_t*)(&z)); } + #define SET_FLOAT_PTR(x, y) { (*(int32_t*) x = *(int32_t*)y); } + #define SET_DOUBLE_PTR(x, y) { (*(int64_t*) x = *(int64_t*)y); } #else - #define GET_FLOAT_VAL(x) (*(float *)(x)) - #define GET_DOUBLE_VAL(x) (*(double *)(x)) + #define GET_FLOAT_VAL(x) (*(float *)(x)) + #define GET_DOUBLE_VAL(x) (*(double *)(x)) + #define SET_FLOAT_VAL(x, y) { (*(float *)(x)) = (float)(y); } + #define SET_DOUBLE_VAL(x, y) { (*(double *)(x)) = (double)(y); } + #define SET_FLOAT_PTR(x, y) { (*(float *)(x)) = (*(float *)(y)); } + #define SET_DOUBLE_PTR(x, y) { (*(double *)(x)) = (*(double *)(y)); } #endif typedef struct tDataTypeDescriptor { @@ -185,9 +194,9 @@ static FORCE_INLINE bool isNull(const char *val, int32_t type) { case TSDB_DATA_TYPE_DOUBLE: return *(uint64_t *)val == TSDB_DATA_DOUBLE_NULL; case TSDB_DATA_TYPE_NCHAR: - return *(uint32_t*) varDataVal(val) == TSDB_DATA_NCHAR_NULL; + return varDataLen(val) == sizeof(int32_t) && *(uint32_t*) varDataVal(val) == TSDB_DATA_NCHAR_NULL; case TSDB_DATA_TYPE_BINARY: - return *(uint8_t *) varDataVal(val) == TSDB_DATA_BINARY_NULL; + return varDataLen(val) == sizeof(int8_t) && *(uint8_t *) varDataVal(val) == TSDB_DATA_BINARY_NULL; default: return false; }; @@ -244,9 +253,11 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf #define TSDB_COL_NAME_LEN 65 #define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64 #define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE -#define TSDB_MAX_SQL_SHOW_LEN 256 +#define TSDB_MAX_SQL_SHOW_LEN 512 #define TSDB_MAX_ALLOWED_SQL_LEN (8*1024*1024U) // sql length should be less than 8mb +#define TSDB_APPNAME_LEN TSDB_UNI_LEN + #define TSDB_MAX_BYTES_PER_ROW 16384 #define TSDB_MAX_TAGS_LEN 16384 #define TSDB_MAX_TAGS 128 @@ -273,7 +284,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf #define TSDB_SHELL_VNODE_BITS 24 #define TSDB_SHELL_SID_MASK 0xFF #define TSDB_HTTP_TOKEN_LEN 20 -#define TSDB_SHOW_SQL_LEN 64 +#define TSDB_SHOW_SQL_LEN 512 #define TSDB_SLOW_QUERY_SQL_LEN 512 #define TSDB_MQTT_HOSTNAME_LEN 64 @@ -294,6 +305,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf #define TSDB_CQ_SQL_SIZE 1024 #define TSDB_MIN_VNODES 64 #define TSDB_MAX_VNODES 2048 +#define TSDB_MIN_VNODES_PER_DB 2 +#define TSDB_MAX_VNODES_PER_DB 64 #define TSDB_DNODE_ROLE_ANY 0 #define TSDB_DNODE_ROLE_MGMT 1 diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 67e2d43c98c11a24e348b5102377367024fa0286..e64b7974507a7cf9c9606639dfbf4f42a4b44bc1 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -28,7 +28,7 @@ extern "C" { #else #define TAOS_DEFINE_ERROR(name, mod, code, msg) static const int32_t name = (0x80000000 | ((mod)<<16) | (code)); #endif - + #define TAOS_SYSTEM_ERROR(code) (0x80ff0000 | (code)) #define TAOS_SUCCEEDED(err) ((err) >= 0) #define TAOS_FAILED(err) ((err) < 0) @@ -37,7 +37,7 @@ const char* tstrerror(int32_t err); int32_t* taosGetErrno(); #define terrno (*taosGetErrno()) - + #define TSDB_CODE_SUCCESS 0 #ifdef TAOS_ERROR_C @@ -98,7 +98,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_ACTION_IN_PROGRESS, 0, 0x0212, "Action in TAOS_DEFINE_ERROR(TSDB_CODE_TSC_DISCONNECTED, 0, 0x0213, "Disconnected from service") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_WRITE_AUTH, 0, 0x0214, "No write permission") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_CONN_KILLED, 0, 0x0215, "Connection killed") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_SQL_SYNTAX_ERROR, 0, 0x0216, "Syntax errr in SQL") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_SQL_SYNTAX_ERROR, 0, 0x0216, "Syntax error in SQL") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_DB_NOT_SELECTED, 0, 0x0217, "Database not specified or available") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_TABLE_NAME, 0, 0x0218, "Table does not exist") // mnode TAOS_DEFINE_ERROR(TSDB_CODE_MND_MSG_NOT_PROCESSED, 0, 0x0300, "Message not processed") @@ -137,6 +139,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE, 0, 0x0339, "Vgroup alr TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_NOT_FREE, 0, 0x033A, "Dnode not avaliable") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CLUSTER_ID, 0, 0x033B, "Cluster id not match") TAOS_DEFINE_ERROR(TSDB_CODE_MND_NOT_READY, 0, 0x033C, "Cluster not ready") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_ID_NOT_CONFIGURED, 0, 0x033D, "Dnode Id not configured") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_EP_NOT_CONFIGURED, 0, 0x033E, "Dnode Ep not configured") TAOS_DEFINE_ERROR(TSDB_CODE_MND_ACCT_ALREADY_EXIST, 0, 0x0340, "Account already exists") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_ACCT, 0, 0x0341, "Invalid account") @@ -178,7 +182,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_DND_OUT_OF_MEMORY, 0, 0x0401, "Dnode out TAOS_DEFINE_ERROR(TSDB_CODE_DND_NO_WRITE_ACCESS, 0, 0x0402, "No permission for disk files in dnode") TAOS_DEFINE_ERROR(TSDB_CODE_DND_INVALID_MSG_LEN, 0, 0x0403, "Invalid message length") -// vnode +// vnode TAOS_DEFINE_ERROR(TSDB_CODE_VND_ACTION_IN_PROGRESS, 0, 0x0500, "Action in progress") TAOS_DEFINE_ERROR(TSDB_CODE_VND_MSG_NOT_PROCESSED, 0, 0x0501, "Message not processed") TAOS_DEFINE_ERROR(TSDB_CODE_VND_ACTION_NEED_REPROCESSED, 0, 0x0502, "Action need to be reprocessed") @@ -189,6 +193,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_DISK_PERMISSIONS, 0, 0x0506, "No write p TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR, 0, 0x0507, "Missing data file") TAOS_DEFINE_ERROR(TSDB_CODE_VND_OUT_OF_MEMORY, 0, 0x0508, "Out of memory") TAOS_DEFINE_ERROR(TSDB_CODE_VND_APP_ERROR, 0, 0x0509, "Unexpected generic error in vnode") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_VRESION_FILE, 0, 0x050A, "Invalid version file") TAOS_DEFINE_ERROR(TSDB_CODE_VND_NOT_SYNCED, 0, 0x0511, "Database suspended") TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_WRITE_AUTH, 0, 0x0512, "Write operation denied") @@ -225,6 +230,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_NOT_READY, 0, 0x0707, "Query not TAOS_DEFINE_ERROR(TSDB_CODE_QRY_HAS_RSP, 0, 0x0708, "Query should response") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_IN_EXEC, 0, 0x0709, "Multiple retrieval of this query") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW, 0, 0x070A, "Too many time window in query") +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_NOT_ENOUGH_BUFFER, 0, 0x070B, "Query buffer limit has reached") // grant TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, 0, 0x0800, "License expired") @@ -243,9 +249,11 @@ TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CPU_LIMITED, 0, 0x080B, "CPU cores // sync TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_CONFIG, 0, 0x0900, "Invalid Sync Configuration") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_ENABLED, 0, 0x0901, "Sync module not enabled") +TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_VERSION, 0, 0x0902, "Invalid Sync version") // wal TAOS_DEFINE_ERROR(TSDB_CODE_WAL_APP_ERROR, 0, 0x1000, "Unexpected generic error in wal") +TAOS_DEFINE_ERROR(TSDB_CODE_WAL_FILE_CORRUPTED, 0, 0x1001, "WAL file is corrupted") // http TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_SERVER_OFFLINE, 0, 0x1100, "http server is not onlin") @@ -347,6 +355,23 @@ TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_OP_TAG_VALUE_TOO_LONG, 0, 0x11A4, "tag value TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_OP_VALUE_NULL, 0, 0x11A5, "value not find") TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_OP_VALUE_TYPE, 0, 0x11A6, "value type should be boolean, number or string") + +TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_OOM, 0, 0x2101, "out of memory") +TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_CONV_UNDEF, 0, 0x2102, "convertion undefined") +TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_CONV_TRUNC, 0, 0x2103, "convertion truncated") +TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_CONV_NOT_SUPPORT, 0, 0x2104, "convertion not supported") +TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_OUT_OF_RANGE, 0, 0x2105, "out of range") +TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_NOT_SUPPORT, 0, 0x2106, "not supported yet") +TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_INVALID_HANDLE, 0, 0x2107, "invalid handle") +TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_NO_RESULT, 0, 0x2108, "no result set") +TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_NO_FIELDS, 0, 0x2109, "no fields returned") +TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_INVALID_CURSOR, 0, 0x2110, "invalid cursor") +TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_STATEMENT_NOT_READY, 0, 0x2111, "statement not ready") +TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_CONNECTION_BUSY, 0, 0x2112, "connection still busy") +TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_BAD_CONNSTR, 0, 0x2113, "bad connection string") +TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_BAD_ARG, 0, 0x2114, "bad argument") + + #ifdef TAOS_ERROR_C }; #endif diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index e49e2caca1faed014a79281da4812f791f898e82..600347c44fdb2a89e03bf24413f22240bb2815f2 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -59,7 +59,7 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_DROP_STABLE, "drop-stable" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_ALTER_STREAM, "alter-stream" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_CONFIG_DNODE, "config-dnode" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_ALTER_VNODE, "alter-vnode" ) -TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY5, "dummy5" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_CREATE_MNODE, "create-mnode" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY6, "dummy6" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY7, "dummy7" ) @@ -182,10 +182,16 @@ extern char *taosMsg[]; #pragma pack(push, 1) +// null-terminated string instead of char array to avoid too many memory consumption in case of more than 1M tableMeta typedef struct { char fqdn[TSDB_FQDN_LEN]; uint16_t port; -} SEpAddr; +} SEpAddrMsg; + +typedef struct { + char* fqdn; + uint16_t port; +} SEpAddr1; typedef struct { int32_t numOfVnodes; @@ -245,7 +251,7 @@ typedef struct { int8_t tableType; int16_t numOfColumns; int16_t numOfTags; - int32_t sid; + int32_t tid; int32_t sversion; int32_t tversion; int32_t tagDataLen; @@ -305,6 +311,8 @@ typedef struct { char clientVersion[TSDB_VERSION_LEN]; char msgVersion[TSDB_VERSION_LEN]; char db[TSDB_TABLE_FNAME_LEN]; + char appName[TSDB_APPNAME_LEN]; + int32_t pid; } SCMConnectMsg; typedef struct { @@ -352,7 +360,7 @@ typedef struct { typedef struct { int32_t contLen; int32_t vgId; - int32_t sid; + int32_t tid; uint64_t uid; char tableId[TSDB_TABLE_FNAME_LEN]; } SMDDropTableMsg; @@ -399,6 +407,7 @@ typedef struct SExprInfo { int16_t bytes; int16_t type; int32_t interBytes; + int64_t uid; } SExprInfo; typedef struct SColumnFilterInfo { @@ -660,28 +669,40 @@ typedef struct SCMSTableVgroupMsg { } SCMSTableVgroupMsg, SCMSTableVgroupRspMsg; typedef struct { - int32_t vgId; - int8_t numOfEps; - SEpAddr epAddr[TSDB_MAX_REPLICA]; + int32_t vgId; + int8_t numOfEps; + SEpAddr1 epAddr[TSDB_MAX_REPLICA]; } SCMVgroupInfo; +typedef struct { + int32_t vgId; + int8_t numOfEps; + SEpAddrMsg epAddr[TSDB_MAX_REPLICA]; +} SCMVgroupMsg; + typedef struct { int32_t numOfVgroups; SCMVgroupInfo vgroups[]; } SVgroupsInfo; +typedef struct { + int32_t numOfVgroups; + SCMVgroupMsg vgroups[]; +} SVgroupsMsg; + typedef struct STableMetaMsg { int32_t contLen; char tableId[TSDB_TABLE_FNAME_LEN]; // table id + char sTableId[TSDB_TABLE_FNAME_LEN]; uint8_t numOfTags; uint8_t precision; uint8_t tableType; int16_t numOfColumns; int16_t sversion; int16_t tversion; - int32_t sid; + int32_t tid; uint64_t uid; - SCMVgroupInfo vgroup; + SCMVgroupMsg vgroup; SSchema schema[]; } STableMetaMsg; @@ -718,10 +739,16 @@ typedef struct { char ep[TSDB_EP_LEN]; // end point, hostname:port } SCMCreateDnodeMsg, SCMDropDnodeMsg; +typedef struct { + int32_t dnodeId; + char dnodeEp[TSDB_EP_LEN]; // end point, hostname:port + SDMMnodeInfos mnodes; +} SMDCreateMnodeMsg; + typedef struct { int32_t dnodeId; int32_t vgId; - int32_t sid; + int32_t tid; } SDMConfigTableMsg; typedef struct { @@ -739,6 +766,7 @@ typedef struct { uint32_t queryId; int64_t useconds; int64_t stime; + uint64_t qHandle; } SQueryDesc; typedef struct { @@ -754,8 +782,10 @@ typedef struct { typedef struct { uint32_t connId; + int32_t pid; int32_t numOfQueries; int32_t numOfStreams; + char appName[TSDB_APPNAME_LEN]; char pData[]; } SCMHeartBeatMsg; diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index c5831a9b8a708c8913bcb374e0c88baa947160e7..a94cdaad15a5c2abe35b7a02502ff8ae95102cd9 100644 --- a/src/inc/ttokendef.h +++ b/src/inc/ttokendef.h @@ -16,6 +16,7 @@ #ifndef TDENGINE_TTOKENDEF_H #define TDENGINE_TTOKENDEF_H + #define TK_ID 1 #define TK_BOOL 2 #define TK_TINYINT 3 @@ -75,24 +76,24 @@ #define TK_VNODES 57 #define TK_IPTOKEN 58 #define TK_DOT 59 -#define TK_TABLES 60 -#define TK_STABLES 61 -#define TK_VGROUPS 62 -#define TK_DROP 63 -#define TK_TABLE 64 -#define TK_DATABASE 65 -#define TK_DNODE 66 -#define TK_USER 67 -#define TK_ACCOUNT 68 -#define TK_USE 69 -#define TK_DESCRIBE 70 -#define TK_ALTER 71 -#define TK_PASS 72 -#define TK_PRIVILEGE 73 -#define TK_LOCAL 74 -#define TK_IF 75 -#define TK_EXISTS 76 -#define TK_CREATE 77 +#define TK_CREATE 60 +#define TK_TABLE 61 +#define TK_DATABASE 62 +#define TK_TABLES 63 +#define TK_STABLES 64 +#define TK_VGROUPS 65 +#define TK_DROP 66 +#define TK_DNODE 67 +#define TK_USER 68 +#define TK_ACCOUNT 69 +#define TK_USE 70 +#define TK_DESCRIBE 71 +#define TK_ALTER 72 +#define TK_PASS 73 +#define TK_PRIVILEGE 74 +#define TK_LOCAL 75 +#define TK_IF 76 +#define TK_EXISTS 77 #define TK_PPS 78 #define TK_TSERIES 79 #define TK_DBS 80 @@ -222,7 +223,6 @@ #define TK_INTO 204 #define TK_VALUES 205 - #define TK_SPACE 300 #define TK_COMMENT 301 #define TK_ILLEGAL 302 diff --git a/src/inc/twal.h b/src/inc/twal.h index 4fdb7aa275d539ae63129e038c4ae50f59552e1f..92204abd7d34a9ee2eebf1b74c2e8d58b9599f17 100644 --- a/src/inc/twal.h +++ b/src/inc/twal.h @@ -44,12 +44,14 @@ typedef void* twalh; // WAL HANDLE typedef int (*FWalWrite)(void *ahandle, void *pHead, int type); twalh walOpen(const char *path, const SWalCfg *pCfg); +int walAlter(twalh pWal, const SWalCfg *pCfg); void walClose(twalh); int walRenew(twalh); int walWrite(twalh, SWalHead *); void walFsync(twalh); int walRestore(twalh, void *pVnode, FWalWrite writeFp); int walGetWalFile(twalh, char *name, uint32_t *index); +int64_t walGetVersion(twalh); extern int wDebugFlag; diff --git a/src/inc/vnode.h b/src/inc/vnode.h index 15ddb6afee7c3ac2914df8133df24f6ef80a0a8a..fdce4d62794075bd2e7027b125780fbd7a2deaed 100644 --- a/src/inc/vnode.h +++ b/src/inc/vnode.h @@ -41,6 +41,8 @@ typedef struct { SRpcMsg rpcMsg; } SReadMsg; +extern char *vnodeStatus[]; + int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg); int32_t vnodeDrop(int32_t vgId); int32_t vnodeOpen(int32_t vgId, char *rootDir); @@ -54,6 +56,7 @@ void vnodeRelease(void *pVnode); // dec refCount void* vnodeGetWal(void *pVnode); int32_t vnodeProcessWrite(void *pVnode, int qtype, void *pHead, void *item); +int32_t vnodeCheckWrite(void *pVnode); int32_t vnodeGetVnodeList(int32_t vnodeList[], int32_t *numOfVnodes); void vnodeBuildStatusMsg(void *param); void vnodeConfirmForward(void *param, uint64_t version, int32_t code); @@ -63,6 +66,7 @@ int32_t vnodeInitResources(); void vnodeCleanupResources(); int32_t vnodeProcessRead(void *pVnode, SReadMsg *pReadMsg); +int32_t vnodeCheckRead(void *pVnode); #ifdef __cplusplus } diff --git a/src/kit/shell/inc/shell.h b/src/kit/shell/inc/shell.h index dd62df170a7c87f127eb7c52c1f580b7f460b445..f508d186083c84482080f2f8fe251173733f1366 100644 --- a/src/kit/shell/inc/shell.h +++ b/src/kit/shell/inc/shell.h @@ -20,6 +20,7 @@ #include "taos.h" #include "taosdef.h" #include "stdbool.h" +#include "tsclient.h" #define MAX_USERNAME_SIZE 64 #define MAX_DBNAME_SIZE 64 @@ -59,7 +60,7 @@ typedef struct SShellArguments { extern void shellParseArgument(int argc, char* argv[], SShellArguments* arguments); extern TAOS* shellInit(SShellArguments* args); extern void* shellLoopQuery(void* arg); -extern void taos_error(TAOS* con); +extern void taos_error(TAOS_RES* tres); extern int regex_match(const char* s, const char* reg, int cflags); void shellReadCommand(TAOS* con, char command[]); int32_t shellRunCommand(TAOS* con, char* command); @@ -71,7 +72,7 @@ void source_dir(TAOS* con, SShellArguments* args); void get_history_path(char* history); void cleanup_handler(void* arg); void exitShell(); -int shellDumpResult(TAOS* con, char* fname, int* error_no, bool printMode); +int shellDumpResult(TAOS_RES* con, char* fname, int* error_no, bool printMode); void shellGetGrantInfo(void *con); int isCommentLine(char *line); diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index 1d1ca1c42bbb921adef67b63511d4c70be8ccf2e..748b7e792982352de611227d82a844448d251ee2 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -294,9 +294,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) { st = taosGetTimestampUs(); - TAOS_RES* pSql = taos_query(con, command); - atomic_store_ptr(&result, pSql); // set the global TAOS_RES pointer - + TAOS_RES* pSql = taos_query_h(con, command, &result); if (taos_errno(pSql)) { taos_error(pSql); return; @@ -419,16 +417,16 @@ static void dumpFieldToFile(FILE* fp, const char* val, TAOS_FIELD* field, int32_ char buf[TSDB_MAX_BYTES_PER_ROW]; switch (field->type) { case TSDB_DATA_TYPE_BOOL: - fprintf(fp, "%d", ((((int)(*((char *)val))) == 1) ? 1 : 0)); + fprintf(fp, "%d", ((((int32_t)(*((char *)val))) == 1) ? 1 : 0)); break; case TSDB_DATA_TYPE_TINYINT: - fprintf(fp, "%d", (int)(*((char *)val))); + fprintf(fp, "%d", *((int8_t *)val)); break; case TSDB_DATA_TYPE_SMALLINT: - fprintf(fp, "%d", (int)(*((short *)val))); + fprintf(fp, "%d", *((int16_t *)val)); break; case TSDB_DATA_TYPE_INT: - fprintf(fp, "%d", *((int *)val)); + fprintf(fp, "%d", *((int32_t *)val)); break; case TSDB_DATA_TYPE_BIGINT: fprintf(fp, "%" PRId64, *((int64_t *)val)); @@ -495,7 +493,7 @@ static int dumpResultToFile(const char* fname, TAOS_RES* tres) { if (i > 0) { fputc(',', fp); } - dumpFieldToFile(fp, row[i], fields +i, length[i], precision); + dumpFieldToFile(fp, (const char*)row[i], fields +i, length[i], precision); } fputc('\n', fp); @@ -559,16 +557,16 @@ static void printField(const char* val, TAOS_FIELD* field, int width, int32_t le char buf[TSDB_MAX_BYTES_PER_ROW]; switch (field->type) { case TSDB_DATA_TYPE_BOOL: - printf("%*s", width, ((((int)(*((char *)val))) == 1) ? "true" : "false")); + printf("%*s", width, ((((int32_t)(*((char *)val))) == 1) ? "true" : "false")); break; case TSDB_DATA_TYPE_TINYINT: - printf("%*d", width, (int)(*((char *)val))); + printf("%*d", width, *((int8_t *)val)); break; case TSDB_DATA_TYPE_SMALLINT: - printf("%*d", width, (int)(*((short *)val))); + printf("%*d", width, *((int16_t *)val)); break; case TSDB_DATA_TYPE_INT: - printf("%*d", width, *((int *)val)); + printf("%*d", width, *((int32_t *)val)); break; case TSDB_DATA_TYPE_BIGINT: printf("%*" PRId64, width, *((int64_t *)val)); @@ -621,7 +619,7 @@ static int verticalPrintResult(TAOS_RES* tres) { int padding = (int)(maxColNameLen - strlen(field->name)); printf("%*.s%s: ", padding, " ", field->name); - printField(row[i], field, 0, length[i], precision); + printField((const char*)row[i], field, 0, length[i], precision); putchar('\n'); } @@ -722,7 +720,7 @@ static int horizontalPrintResult(TAOS_RES* tres) { int32_t* length = taos_fetch_lengths(tres); for (int i = 0; i < num_fields; i++) { putchar(' '); - printField(row[i], fields + i, width[i], length[i], precision); + printField((const char*)row[i], fields + i, width[i], length[i], precision); putchar(' '); putchar('|'); } diff --git a/src/kit/shell/src/shellImport.c b/src/kit/shell/src/shellImport.c index ee0a90757bb51a98dd2bf535319afc215dbc04a8..af61995c618bc80389b8abf6d8c6f6c929327925 100644 --- a/src/kit/shell/src/shellImport.c +++ b/src/kit/shell/src/shellImport.c @@ -204,7 +204,7 @@ static void shellSourceFile(TAOS *con, char *fptr) { int32_t code = taos_errno(pSql); if (code != 0) { - fprintf(stderr, "DB error: %s: %s (%d)\n", taos_errstr(con), fname, lineNo); + fprintf(stderr, "DB error: %s: %s (%d)\n", taos_errstr(pSql), fname, lineNo); } /* free local resouce: allocated memory/metric-meta refcnt */ @@ -243,7 +243,7 @@ static void shellRunImportThreads(SShellArguments* args) pThread->totalThreads = args->threadNum; pThread->taos = taos_connect(args->host, args->user, args->password, args->database, tsDnodeShellPort); if (pThread->taos == NULL) { - fprintf(stderr, "ERROR: thread:%d failed connect to TDengine, error:%s\n", pThread->threadIndex, taos_errstr(pThread->taos)); + fprintf(stderr, "ERROR: thread:%d failed connect to TDengine, error:%s\n", pThread->threadIndex, "null taos"/*taos_errstr(pThread->taos)*/); exit(0); } diff --git a/src/kit/shell/src/shellWindows.c b/src/kit/shell/src/shellWindows.c index 67174827d4ce005ad579fbb9ab3c72f1828ad095..ce986813918249ebe501e92d3af307a67c296907 100644 --- a/src/kit/shell/src/shellWindows.c +++ b/src/kit/shell/src/shellWindows.c @@ -90,11 +90,12 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) { } } else if (strcmp(argv[i], "-c") == 0) { if (i < argc - 1) { - if (strlen(argv[++i]) >= TSDB_FILENAME_LEN) { - fprintf(stderr, "config file path: %s overflow max len %d\n", argv[i], TSDB_FILENAME_LEN - 1); + char *tmp = argv[++i]; + if (strlen(tmp) >= TSDB_FILENAME_LEN) { + fprintf(stderr, "config file path: %s overflow max len %d\n", tmp, TSDB_FILENAME_LEN - 1); exit(EXIT_FAILURE); } - strcpy(configDir, argv[++i]); + strcpy(configDir, tmp); } else { fprintf(stderr, "Option -c requires an argument\n"); exit(EXIT_FAILURE); diff --git a/src/mnode/inc/mnodeDef.h b/src/mnode/inc/mnodeDef.h index 682986b29f8e7e2d22f96b60e3ecb309ea9c4fdc..4bc840f026d41dc4fe4e8d61c84d53140501bff6 100644 --- a/src/mnode/inc/mnodeDef.h +++ b/src/mnode/inc/mnodeDef.h @@ -69,7 +69,8 @@ typedef struct SDnodeObj { int16_t cpuAvgUsage; // calc from sys.cpu int16_t memoryAvgUsage; // calc from sys.mem int16_t bandwidthUsage; // calc from sys.band - int8_t reserved2[2]; + int8_t offlineReason; + int8_t reserved2[1]; } SDnodeObj; typedef struct SMnodeObj { @@ -114,7 +115,7 @@ typedef struct { uint64_t suid; int64_t createdTime; int32_t numOfColumns; //used by normal table - int32_t sid; + int32_t tid; int32_t vgId; int32_t sqlLen; int8_t updateEnd[4]; diff --git a/src/mnode/inc/mnodeDnode.h b/src/mnode/inc/mnodeDnode.h index 13b6ec44111cd9526522c8d213a767c66ad834c1..b6ddb7a9bf27252bb9dc97d8c6645245354a6428 100644 --- a/src/mnode/inc/mnodeDnode.h +++ b/src/mnode/inc/mnodeDnode.h @@ -33,6 +33,28 @@ typedef enum { TAOS_DN_ALTERNATIVE_ROLE_VNODE } EDnodeAlternativeRole; +typedef enum EDnodeOfflineReason { + TAOS_DN_OFF_ONLINE = 0, + TAOS_DN_OFF_STATUS_MSG_TIMEOUT, + TAOS_DN_OFF_STATUS_NOT_RECEIVED, + TAOS_DN_OFF_RESET_BY_MNODE, + TAOS_DN_OFF_VERSION_NOT_MATCH, + TAOS_DN_OFF_DNODE_ID_NOT_MATCH, + TAOS_DN_OFF_CLUSTER_ID_NOT_MATCH, + TAOS_DN_OFF_NUM_OF_MNODES_NOT_MATCH, + TAOS_DN_OFF_ENABLE_BALANCE_NOT_MATCH, + TAOS_DN_OFF_MN_EQUAL_VN_NOT_MATCH, + TAOS_DN_OFF_OFFLINE_THRESHOLD_NOT_MATCH, + TAOS_DN_OFF_STATUS_INTERVAL_NOT_MATCH, + TAOS_DN_OFF_MAX_TAB_PER_VN_NOT_MATCH, + TAOS_DN_OFF_MAX_VG_PER_DB_NOT_MATCH, + TAOS_DN_OFF_ARBITRATOR_NOT_MATCH, + TAOS_DN_OFF_TIME_ZONE_NOT_MATCH, + TAOS_DN_OFF_LOCALE_NOT_MATCH, + TAOS_DN_OFF_CHARSET_NOT_MATCH, + TAOS_DN_OFF_OTHERS +} EDnodeOfflineReason; + int32_t mnodeInitDnodes(); void mnodeCleanupDnodes(); diff --git a/src/mnode/inc/mnodeMnode.h b/src/mnode/inc/mnodeMnode.h index 0976ea8acd74e511a6cda374dc6ad5501b503482..a28a03ea4028a243a27e79688de54627aaeb7064 100644 --- a/src/mnode/inc/mnodeMnode.h +++ b/src/mnode/inc/mnodeMnode.h @@ -31,7 +31,7 @@ typedef enum { int32_t mnodeInitMnodes(); void mnodeCleanupMnodes(); -int32_t mnodeAddMnode(int32_t dnodeId); +void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm); int32_t mnodeDropMnode(int32_t dnodeId); void mnodeDropMnodeLocal(int32_t dnodeId); diff --git a/src/mnode/inc/mnodeProfile.h b/src/mnode/inc/mnodeProfile.h index e39496ec9cacf431e2fefd737018d54a56e27f88..1e5b1c0f9c7c1c220a88339f00d46538c78cf938 100644 --- a/src/mnode/inc/mnodeProfile.h +++ b/src/mnode/inc/mnodeProfile.h @@ -23,6 +23,8 @@ extern "C" { typedef struct { char user[TSDB_USER_LEN]; + char appName[TSDB_APPNAME_LEN]; // app name that invokes taosc + uint32_t pid; // pid of app that invokes taosc int8_t killed; uint16_t port; uint32_t ip; @@ -40,7 +42,7 @@ typedef struct { int32_t mnodeInitProfile(); void mnodeCleanupProfile(); -SConnObj *mnodeCreateConn(char *user, uint32_t ip, uint16_t port); +SConnObj *mnodeCreateConn(char *user, uint32_t ip, uint16_t port, int32_t pid, const char* app); SConnObj *mnodeAccquireConn(int32_t connId, char *user, uint32_t ip, uint16_t port); void mnodeReleaseConn(SConnObj *pConn); int32_t mnodeSaveQueryStreamList(SConnObj *pConn, SCMHeartBeatMsg *pHBMsg); diff --git a/src/mnode/src/mnodeCluster.c b/src/mnode/src/mnodeCluster.c index 69614f77d6876f86c44e42fbfa12ce95e93c452a..35b6a67ab24d5ee50a4f4da7bb902ab0d7232b7e 100644 --- a/src/mnode/src/mnodeCluster.c +++ b/src/mnode/src/mnodeCluster.c @@ -225,6 +225,7 @@ static int32_t mnodeRetrieveClusters(SShowObj *pShow, char *data, int32_t rows, numOfRows++; } + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); pShow->numOfReads += numOfRows; return numOfRows; } diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 54c049d242c504eee095120f800e023095b8eda6..8d7c267ab7cb328bb187518a88be3d344b0d53e2 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -648,8 +648,12 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void while (numOfRows < rows) { pShow->pIter = mnodeGetNextDb(pShow->pIter, &pDb); + if (pDb == NULL) break; - if (pDb->pAcct != pUser->pAcct) continue; + if (pDb->pAcct != pUser->pAcct) { + mnodeDecDbRef(pDb); + continue; + } cols = 0; @@ -760,6 +764,8 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void } pShow->numOfReads += numOfRows; + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); + mnodeDecUserRef(pUser); return numOfRows; } @@ -910,13 +916,13 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) { } if (walLevel > 0 && walLevel != pDb->cfg.walLevel) { - mError("db:%s, can't alter walLevel option", pDb->name); - terrno = TSDB_CODE_MND_INVALID_DB_OPTION; + mDebug("db:%s, walLevel:%d change to %d", pDb->name, pDb->cfg.walLevel, walLevel); + newCfg.walLevel = walLevel; } if (fsyncPeriod >= 0 && fsyncPeriod != pDb->cfg.fsyncPeriod) { - mError("db:%s, can't alter fsyncPeriod option", pDb->name); - terrno = TSDB_CODE_MND_INVALID_DB_OPTION; + mDebug("db:%s, fsyncPeriod:%d change to %d", pDb->name, pDb->cfg.fsyncPeriod, fsyncPeriod); + newCfg.fsyncPeriod = fsyncPeriod; } if (replications > 0 && replications != pDb->cfg.replications) { diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index ac8730b0ccb308b04be0519e56e91714e09f07b5..1cd861e22303d5f6f0dcb75c7ef83cf66696578f 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -60,6 +60,28 @@ static int32_t mnodeGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn); static char* mnodeGetDnodeAlternativeRoleStr(int32_t alternativeRole); +static char* offlineReason[] = { + "", + "status msg timeout", + "status not received", + "status reset by mnode", + "version not match", + "dnodeId not match", + "clusterId not match", + "numOfMnodes not match", + "balance not match", + "mnEqualVn not match", + "offThreshold not match", + "interval not match", + "maxTabPerVn not match", + "maxVgPerDb not match", + "arbitrator not match", + "timezone not match", + "locale not match", + "charset not match", + "unknown", +}; + static int32_t mnodeDnodeActionDestroy(SSdbOper *pOper) { taosTFree(pOper->pObj); return TSDB_CODE_SUCCESS; @@ -70,6 +92,7 @@ static int32_t mnodeDnodeActionInsert(SSdbOper *pOper) { if (pDnode->status != TAOS_DN_STATUS_DROPPING) { pDnode->status = TAOS_DN_STATUS_OFFLINE; pDnode->lastAccess = tsAccessSquence; + pDnode->offlineReason = TAOS_DN_OFF_STATUS_NOT_RECEIVED; } mInfo("dnode:%d, fqdn:%s ep:%s port:%d, do insert action", pDnode->dnodeId, pDnode->dnodeFqdn, pDnode->dnodeEp, pDnode->dnodePort); @@ -124,7 +147,7 @@ static int32_t mnodeDnodeActionRestored() { mnodeCreateDnode(tsLocalEp, NULL); SDnodeObj *pDnode = mnodeGetDnodeByEp(tsLocalEp); if (pDnode != NULL) { - mnodeAddMnode(pDnode->dnodeId); + mnodeCreateMnode(pDnode->dnodeId, pDnode->dnodeEp, false); mnodeDecDnodeRef(pDnode); } } @@ -334,74 +357,85 @@ static void mnodeProcessCfgDnodeMsgRsp(SRpcMsg *rpcMsg) { mInfo("cfg dnode rsp is received"); } -static bool mnodeCheckClusterCfgPara(const SClusterCfg *clusterCfg) { +static int32_t mnodeCheckClusterCfgPara(const SClusterCfg *clusterCfg) { if (clusterCfg->numOfMnodes != htonl(tsNumOfMnodes)) { mError("\"numOfMnodes\"[%d - %d] cfg parameters inconsistent", clusterCfg->numOfMnodes, htonl(tsNumOfMnodes)); - return false; - } - if (clusterCfg->enableBalance != htonl(tsEnableBalance)) { + return TAOS_DN_OFF_NUM_OF_MNODES_NOT_MATCH; + } + if (clusterCfg->enableBalance != htonl(tsEnableBalance)) { mError("\"balance\"[%d - %d] cfg parameters inconsistent", clusterCfg->enableBalance, htonl(tsEnableBalance)); - return false; + return TAOS_DN_OFF_ENABLE_BALANCE_NOT_MATCH; } if (clusterCfg->mnodeEqualVnodeNum != htonl(tsMnodeEqualVnodeNum)) { - mError("\"mnodeEqualVnodeNum\"[%d - %d] cfg parameters inconsistent", clusterCfg->mnodeEqualVnodeNum, htonl(tsMnodeEqualVnodeNum)); - return false; + mError("\"mnodeEqualVnodeNum\"[%d - %d] cfg parameters inconsistent", clusterCfg->mnodeEqualVnodeNum, + htonl(tsMnodeEqualVnodeNum)); + return TAOS_DN_OFF_MN_EQUAL_VN_NOT_MATCH; } - if (clusterCfg->offlineThreshold != htonl(tsOfflineThreshold)) { - mError("\"offlineThreshold\"[%d - %d] cfg parameters inconsistent", clusterCfg->offlineThreshold, htonl(tsOfflineThreshold)); - return false; + if (clusterCfg->offlineThreshold != htonl(tsOfflineThreshold)) { + mError("\"offlineThreshold\"[%d - %d] cfg parameters inconsistent", clusterCfg->offlineThreshold, + htonl(tsOfflineThreshold)); + return TAOS_DN_OFF_OFFLINE_THRESHOLD_NOT_MATCH; } - if (clusterCfg->statusInterval != htonl(tsStatusInterval)) { - mError("\"statusInterval\"[%d - %d] cfg parameters inconsistent", clusterCfg->statusInterval, htonl(tsStatusInterval)); - return false; + if (clusterCfg->statusInterval != htonl(tsStatusInterval)) { + mError("\"statusInterval\"[%d - %d] cfg parameters inconsistent", clusterCfg->statusInterval, + htonl(tsStatusInterval)); + return TAOS_DN_OFF_STATUS_INTERVAL_NOT_MATCH; } - if (clusterCfg->maxtablesPerVnode != htonl(tsMaxTablePerVnode)) { - mError("\"maxTablesPerVnode\"[%d - %d] cfg parameters inconsistent", clusterCfg->maxtablesPerVnode, htonl(tsMaxTablePerVnode)); - return false; + if (clusterCfg->maxtablesPerVnode != htonl(tsMaxTablePerVnode)) { + mError("\"maxTablesPerVnode\"[%d - %d] cfg parameters inconsistent", clusterCfg->maxtablesPerVnode, + htonl(tsMaxTablePerVnode)); + return TAOS_DN_OFF_MAX_TAB_PER_VN_NOT_MATCH; } - if (clusterCfg->maxVgroupsPerDb != htonl(tsMaxVgroupsPerDb)) { - mError("\"maxVgroupsPerDb\"[%d - %d] cfg parameters inconsistent", clusterCfg->maxVgroupsPerDb, htonl(tsMaxVgroupsPerDb)); - return false; + if (clusterCfg->maxVgroupsPerDb != htonl(tsMaxVgroupsPerDb)) { + mError("\"maxVgroupsPerDb\"[%d - %d] cfg parameters inconsistent", clusterCfg->maxVgroupsPerDb, + htonl(tsMaxVgroupsPerDb)); + return TAOS_DN_OFF_MAX_VG_PER_DB_NOT_MATCH; } if (0 != strncasecmp(clusterCfg->arbitrator, tsArbitrator, strlen(tsArbitrator))) { mError("\"arbitrator\"[%s - %s] cfg parameters inconsistent", clusterCfg->arbitrator, tsArbitrator); - return false; + return TAOS_DN_OFF_ARBITRATOR_NOT_MATCH; } int64_t checkTime = 0; - char timestr[32] = "1970-01-01 00:00:00.00"; + char timestr[32] = "1970-01-01 00:00:00.00"; (void)taosParseTime(timestr, &checkTime, strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0); - if ((0 != strncasecmp(clusterCfg->timezone, tsTimezone, strlen(tsTimezone))) && (checkTime != clusterCfg->checkTime)) { - mError("\"timezone\"[%s - %s] [%" PRId64 " - %" PRId64"] cfg parameters inconsistent", clusterCfg->timezone, tsTimezone, clusterCfg->checkTime, checkTime); - return false; + if ((0 != strncasecmp(clusterCfg->timezone, tsTimezone, strlen(tsTimezone))) && + (checkTime != clusterCfg->checkTime)) { + mError("\"timezone\"[%s - %s] [%" PRId64 " - %" PRId64 "] cfg parameters inconsistent", clusterCfg->timezone, + tsTimezone, clusterCfg->checkTime, checkTime); + return TAOS_DN_OFF_TIME_ZONE_NOT_MATCH; } if (0 != strncasecmp(clusterCfg->locale, tsLocale, strlen(tsLocale))) { mError("\"locale\"[%s - %s] cfg parameters inconsistent", clusterCfg->locale, tsLocale); - return false; + return TAOS_DN_OFF_LOCALE_NOT_MATCH; } if (0 != strncasecmp(clusterCfg->charset, tsCharset, strlen(tsCharset))) { mError("\"charset\"[%s - %s] cfg parameters inconsistent.", clusterCfg->charset, tsCharset); - return false; + return TAOS_DN_OFF_CHARSET_NOT_MATCH; } - - return true; + + return 0; } static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { + SDnodeObj *pDnode = NULL; SDMStatusMsg *pStatus = pMsg->rpcMsg.pCont; pStatus->dnodeId = htonl(pStatus->dnodeId); pStatus->moduleStatus = htonl(pStatus->moduleStatus); pStatus->lastReboot = htonl(pStatus->lastReboot); pStatus->numOfCores = htons(pStatus->numOfCores); - + uint32_t version = htonl(pStatus->version); if (version != tsVersion) { - mError("status msg version:%d not equal with mnode:%d", version, tsVersion); + pDnode = mnodeGetDnodeByEp(pStatus->dnodeEp); + if (pDnode != NULL && pDnode->status != TAOS_DN_STATUS_READY) { + pDnode->offlineReason = TAOS_DN_OFF_VERSION_NOT_MATCH; + } + mError("dnode:%d, status msg version:%d not equal with cluster:%d", pStatus->dnodeId, version, tsVersion); return TSDB_CODE_MND_INVALID_MSG_VERSION; } - SDnodeObj *pDnode = NULL; if (pStatus->dnodeId == 0) { pDnode = mnodeGetDnodeByEp(pStatus->dnodeEp); if (pDnode == NULL) { @@ -411,7 +445,11 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { } else { pDnode = mnodeGetDnode(pStatus->dnodeId); if (pDnode == NULL) { - mError("dnode id:%d, %s not exist", pStatus->dnodeId, pStatus->dnodeEp); + pDnode = mnodeGetDnodeByEp(pStatus->dnodeEp); + if (pDnode != NULL && pDnode->status != TAOS_DN_STATUS_READY) { + pDnode->offlineReason = TAOS_DN_OFF_DNODE_ID_NOT_MATCH; + } + mError("dnode:%d, %s not exist", pStatus->dnodeId, pStatus->dnodeEp); return TSDB_CODE_MND_DNODE_NOT_EXIST; } } @@ -426,11 +464,15 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { mDebug("dnode:%d %s, first access, set clusterId %s", pDnode->dnodeId, pDnode->dnodeEp, mnodeGetClusterId()); } else { if (strncmp(pStatus->clusterId, mnodeGetClusterId(), TSDB_CLUSTER_ID_LEN - 1) != 0) { + if (pDnode != NULL && pDnode->status != TAOS_DN_STATUS_READY) { + pDnode->offlineReason = TAOS_DN_OFF_CLUSTER_ID_NOT_MATCH; + } mError("dnode:%d, input clusterId %s not match with exist %s", pDnode->dnodeId, pStatus->clusterId, mnodeGetClusterId()); return TSDB_CODE_MND_INVALID_CLUSTER_ID; } else { - mTrace("dnode:%d, status received, access times %d", pDnode->dnodeId, pDnode->lastAccess); + mTrace("dnode:%d, status received, access times %d openVnodes:%d:%d", pDnode->dnodeId, pDnode->lastAccess, + htons(pStatus->openVnodes), pDnode->openVnodes); } } @@ -469,16 +511,19 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { if (pDnode->status == TAOS_DN_STATUS_OFFLINE) { // Verify whether the cluster parameters are consistent when status change from offline to ready - bool ret = mnodeCheckClusterCfgPara(&(pStatus->clusterCfg)); - if (false == ret) { + int32_t ret = mnodeCheckClusterCfgPara(&(pStatus->clusterCfg)); + if (0 != ret) { + pDnode->offlineReason = ret; mnodeDecDnodeRef(pDnode); rpcFreeCont(pRsp); - mError("dnode:%d, %s cluster cfg parameters inconsistent", pDnode->dnodeId, pStatus->dnodeEp); + mError("dnode:%d, %s cluster cfg parameters inconsistent, reason:%s", pDnode->dnodeId, pStatus->dnodeEp, + offlineReason[ret]); return TSDB_CODE_MND_CLUSTER_CFG_INCONSISTENT; } - + mDebug("dnode:%d, from offline to online", pDnode->dnodeId); pDnode->status = TAOS_DN_STATUS_READY; + pDnode->offlineReason = TAOS_DN_OFF_ONLINE; balanceSyncNotify(); balanceAsyncNotify(); } @@ -529,6 +574,7 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) { pDnode = (SDnodeObj *) calloc(1, sizeof(SDnodeObj)); pDnode->createdTime = taosGetTimestampMs(); pDnode->status = TAOS_DN_STATUS_OFFLINE; + pDnode->offlineReason = TAOS_DN_OFF_STATUS_NOT_RECEIVED; tstrncpy(pDnode->dnodeEp, ep, TSDB_EP_LEN); taosGetFqdnPortFromEp(ep, pDnode->dnodeFqdn, &pDnode->dnodePort); @@ -654,13 +700,13 @@ static int32_t mnodeGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pShow->bytes[cols] = 12 + VARSTR_HEADER_SIZE; + pShow->bytes[cols] = 10 + VARSTR_HEADER_SIZE; pSchema[cols].type = TSDB_DATA_TYPE_BINARY; strcpy(pSchema[cols].name, "status"); pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pShow->bytes[cols] = 6 + VARSTR_HEADER_SIZE; + pShow->bytes[cols] = 5 + VARSTR_HEADER_SIZE; pSchema[cols].type = TSDB_DATA_TYPE_BINARY; strcpy(pSchema[cols].name, "role"); pSchema[cols].bytes = htons(pShow->bytes[cols]); @@ -672,6 +718,12 @@ static int32_t mnodeGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; + pShow->bytes[cols] = 24 + VARSTR_HEADER_SIZE; + pSchema[cols].type = TSDB_DATA_TYPE_BINARY; + strcpy(pSchema[cols].name, "offline reason"); + pSchema[cols].bytes = htons(pShow->bytes[cols]); + cols++; + pMeta->numOfColumns = htons(cols); pShow->numOfColumns = cols; @@ -731,11 +783,15 @@ static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, vo *(int64_t *)pWrite = pDnode->createdTime; cols++; - - numOfRows++; + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + STR_TO_VARSTR(pWrite, offlineReason[pDnode->offlineReason]); + cols++; + + numOfRows++; mnodeDecDnodeRef(pDnode); } + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); pShow->numOfReads += numOfRows; return numOfRows; } @@ -803,6 +859,7 @@ int32_t mnodeRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pC char* pWrite; char* moduleName[5] = { "MNODE", "HTTP", "MONITOR", "MQTT", "UNKNOWN" }; + int32_t cols; while (numOfRows < rows) { SDnodeObj *pDnode = NULL; @@ -810,7 +867,7 @@ int32_t mnodeRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pC if (pDnode == NULL) break; for (int32_t moduleType = 0; moduleType < TSDB_MOD_MAX; ++moduleType) { - int32_t cols = 0; + cols = 0; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; *(int16_t *)pWrite = pDnode->dnodeId; @@ -837,6 +894,7 @@ int32_t mnodeRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pC mnodeDecDnodeRef(pDnode); } + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); pShow->numOfReads += numOfRows; return numOfRows; } @@ -936,6 +994,7 @@ static int32_t mnodeRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, v } } + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); pShow->numOfReads += numOfRows; return numOfRows; } @@ -1028,6 +1087,7 @@ static int32_t mnodeRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, vo numOfRows = 0; } + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); pShow->numOfReads += numOfRows; return numOfRows; } diff --git a/src/mnode/src/mnodeInt.c b/src/mnode/src/mnodeInt.c index 91c8dcb6e52e86ef009c18e69b00252c66346b1b..fb1b8741a9f8895c579ad0e549dc8f3c15f7618c 100644 --- a/src/mnode/src/mnodeInt.c +++ b/src/mnode/src/mnodeInt.c @@ -39,6 +39,11 @@ void mnodeCreateMsg(SMnodeMsg *pMsg, SRpcMsg *rpcMsg) { } int32_t mnodeInitMsg(SMnodeMsg *pMsg) { + if (pMsg->pUser != NULL) { + mDebug("app:%p:%p, user info already inited", pMsg->rpcMsg.ahandle, pMsg); + return TSDB_CODE_SUCCESS; + } + pMsg->pUser = mnodeGetUserFromConn(pMsg->rpcMsg.handle); if (pMsg->pUser == NULL) { return TSDB_CODE_MND_INVALID_USER; diff --git a/src/mnode/src/mnodeMain.c b/src/mnode/src/mnodeMain.c index d63a5758686f5db46926e1b3c1bc97becd53d8ae..2bb8a810566a676a4ae991bc79e5eb78234747c7 100644 --- a/src/mnode/src/mnodeMain.c +++ b/src/mnode/src/mnodeMain.c @@ -109,7 +109,7 @@ int32_t mnodeStartSystem() { mInfo("mnode is initialized successfully"); - sdbUpdateSync(); + sdbUpdateSync(NULL); return 0; } @@ -123,16 +123,18 @@ int32_t mnodeInitSystem() { } void mnodeCleanupSystem() { - mInfo("starting to clean up mnode"); - tsMgmtIsRunning = false; - - dnodeFreeMnodeWqueue(); - dnodeFreeMnodeRqueue(); - dnodeFreeMnodePqueue(); - mnodeCleanupTimer(); - mnodeCleanupComponents(sizeof(tsMnodeComponents) / sizeof(tsMnodeComponents[0]) - 1); - - mInfo("mnode is cleaned up"); + if (tsMgmtIsRunning) { + mInfo("starting to clean up mnode"); + tsMgmtIsRunning = false; + + dnodeFreeMnodeWqueue(); + dnodeFreeMnodeRqueue(); + dnodeFreeMnodePqueue(); + mnodeCleanupTimer(); + mnodeCleanupComponents(sizeof(tsMnodeComponents) / sizeof(tsMnodeComponents[0]) - 1); + + mInfo("mnode is cleaned up"); + } } void mnodeStopSystem() { diff --git a/src/mnode/src/mnodeMnode.c b/src/mnode/src/mnodeMnode.c index bff84d8041cd1bb4ededbd48704a888763453059..89b2f50b731c90c1261957da93623ba16cebf2ab 100644 --- a/src/mnode/src/mnodeMnode.c +++ b/src/mnode/src/mnodeMnode.c @@ -23,6 +23,8 @@ #include "tutil.h" #include "tsocket.h" #include "tdataformat.h" +#include "dnode.h" +#include "mnode.h" #include "mnodeDef.h" #include "mnodeInt.h" #include "mnodeMnode.h" @@ -30,6 +32,7 @@ #include "mnodeSdb.h" #include "mnodeShow.h" #include "mnodeUser.h" +#include "mnodeVgroup.h" static void * tsMnodeSdb = NULL; static int32_t tsMnodeUpdateSize = 0; @@ -266,25 +269,87 @@ void mnodeGetMnodeInfos(void *mnodeInfos) { mnodeMnodeUnLock(); } -int32_t mnodeAddMnode(int32_t dnodeId) { +static int32_t mnodeSendCreateMnodeMsg(int32_t dnodeId, char *dnodeEp) { + mDebug("dnode:%d, send create mnode msg to dnode %s", dnodeId, dnodeEp); + + SMDCreateMnodeMsg *pCreate = rpcMallocCont(sizeof(SMDCreateMnodeMsg)); + if (pCreate == NULL) { + return TSDB_CODE_MND_OUT_OF_MEMORY; + } else { + pCreate->dnodeId = htonl(dnodeId); + tstrncpy(pCreate->dnodeEp, dnodeEp, sizeof(pCreate->dnodeEp)); + pCreate->mnodes = tsMnodeInfos; + bool found = false; + for (int i = 0; i < pCreate->mnodes.nodeNum; ++i) { + if (pCreate->mnodes.nodeInfos[i].nodeId == htonl(dnodeId)) { + found = true; + } + } + if (!found) { + pCreate->mnodes.nodeInfos[pCreate->mnodes.nodeNum].nodeId = htonl(dnodeId); + tstrncpy(pCreate->mnodes.nodeInfos[pCreate->mnodes.nodeNum].nodeEp, dnodeEp, sizeof(pCreate->dnodeEp)); + pCreate->mnodes.nodeNum++; + } + } + + SRpcMsg rpcMsg = {0}; + rpcMsg.pCont = pCreate; + rpcMsg.contLen = sizeof(SMDCreateMnodeMsg); + rpcMsg.msgType = TSDB_MSG_TYPE_MD_CREATE_MNODE; + + SRpcMsg rpcRsp = {0}; + SRpcEpSet epSet = mnodeGetEpSetFromIp(pCreate->dnodeEp); + dnodeSendMsgToDnodeRecv(&rpcMsg, &rpcRsp, &epSet); + + if (rpcRsp.code != TSDB_CODE_SUCCESS) { + mError("dnode:%d, failed to send create mnode msg, ep:%s reason:%s", dnodeId, dnodeEp, tstrerror(rpcRsp.code)); + } else { + mDebug("dnode:%d, create mnode msg is disposed, mnode is created in dnode", dnodeId); + } + + rpcFreeCont(rpcRsp.pCont); + return rpcRsp.code; +} + +static int32_t mnodeCreateMnodeCb(SMnodeMsg *pMsg, int32_t code) { + if (code != TSDB_CODE_SUCCESS) { + mError("failed to create mnode, reason:%s", tstrerror(code)); + } else { + mDebug("mnode is created successfully"); + mnodeUpdateMnodeEpSet(); + sdbUpdateAsync(); + } + + return code; +} + +void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) { SMnodeObj *pMnode = calloc(1, sizeof(SMnodeObj)); pMnode->mnodeId = dnodeId; pMnode->createdTime = taosGetTimestampMs(); SSdbOper oper = { - .type = SDB_OPER_GLOBAL, + .type = SDB_OPER_GLOBAL, .table = tsMnodeSdb, - .pObj = pMnode, + .pObj = pMnode, + .writeCb = mnodeCreateMnodeCb }; - int32_t code = sdbInsertRow(&oper); - if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { - taosTFree(pMnode); + int32_t code = TSDB_CODE_SUCCESS; + if (needConfirm) { + code = mnodeSendCreateMnodeMsg(dnodeId, dnodeEp); } - mnodeUpdateMnodeEpSet(); + if (code != TSDB_CODE_SUCCESS) { + taosTFree(pMnode); + return; + } - return code; + code = sdbInsertRow(&oper); + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { + mError("dnode:%d, failed to create mnode, ep:%s reason:%s", dnodeId, dnodeEp, tstrerror(code)); + taosTFree(pMnode); + } } void mnodeDropMnodeLocal(int32_t dnodeId) { @@ -296,6 +361,7 @@ void mnodeDropMnodeLocal(int32_t dnodeId) { } mnodeUpdateMnodeEpSet(); + sdbUpdateAsync(); } int32_t mnodeDropMnode(int32_t dnodeId) { @@ -315,6 +381,7 @@ int32_t mnodeDropMnode(int32_t dnodeId) { sdbDecRef(tsMnodeSdb, pMnode); mnodeUpdateMnodeEpSet(); + sdbUpdateAsync(); return code; } @@ -414,6 +481,7 @@ static int32_t mnodeRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, vo mnodeDecMnodeRef(pMnode); } + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); pShow->numOfReads += numOfRows; return numOfRows; diff --git a/src/mnode/src/mnodePeer.c b/src/mnode/src/mnodePeer.c index 8b368a33f4c7336178fcd949b729ca81fa660b4a..2a04f541c51483ccba93369a65061507f83ead23 100644 --- a/src/mnode/src/mnodePeer.c +++ b/src/mnode/src/mnodePeer.c @@ -58,10 +58,15 @@ int32_t mnodeProcessPeerReq(SMnodeMsg *pMsg) { rpcRsp->rsp = epSet; rpcRsp->len = sizeof(SRpcEpSet); - mDebug("%p, msg:%s in mpeer queue, will be redireced, numOfEps:%d inUse:%d", pMsg->rpcMsg.ahandle, + mDebug("%p, msg:%s in mpeer queue will be redirected, numOfEps:%d inUse:%d", pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType], epSet->numOfEps, epSet->inUse); for (int32_t i = 0; i < epSet->numOfEps; ++i) { - mDebug("mnode index:%d ep:%s:%d", i, epSet->fqdn[i], htons(epSet->port[i])); + if (strcmp(epSet->fqdn[i], tsLocalFqdn) == 0 && htons(epSet->port[i]) == tsServerPort + TSDB_PORT_DNODEDNODE) { + epSet->inUse = (i + 1) % epSet->numOfEps; + mDebug("mnode index:%d ep:%s:%u, set inUse to %d", i, epSet->fqdn[i], htons(epSet->port[i]), epSet->inUse); + } else { + mDebug("mnode index:%d ep:%s:%u", i, epSet->fqdn[i], htons(epSet->port[i])); + } } return TSDB_CODE_RPC_REDIRECT; diff --git a/src/mnode/src/mnodeProfile.c b/src/mnode/src/mnodeProfile.c index 26f38dde034788fb440a785ce6c90e8aedf8ddca..f8f99e22c6f437b1eece0d704c8c4551bc434110 100644 --- a/src/mnode/src/mnodeProfile.c +++ b/src/mnode/src/mnodeProfile.c @@ -24,15 +24,9 @@ #include "mnode.h" #include "mnodeDef.h" #include "mnodeInt.h" -#include "mnodeAcct.h" -#include "mnodeDnode.h" -#include "mnodeDb.h" -#include "mnodeMnode.h" #include "mnodeProfile.h" #include "mnodeShow.h" -#include "mnodeTable.h" #include "mnodeUser.h" -#include "mnodeVgroup.h" #include "mnodeWrite.h" #define CONN_KEEP_TIME (tsShellActivityTimer * 3) @@ -78,7 +72,7 @@ void mnodeCleanupProfile() { } } -SConnObj *mnodeCreateConn(char *user, uint32_t ip, uint16_t port) { +SConnObj *mnodeCreateConn(char *user, uint32_t ip, uint16_t port, int32_t pid, const char* app) { #if 0 int32_t connSize = taosHashGetSize(tsMnodeConnCache->pHashTable); if (connSize > tsMaxShellConns) { @@ -96,10 +90,13 @@ SConnObj *mnodeCreateConn(char *user, uint32_t ip, uint16_t port) { .ip = ip, .port = port, .connId = connId, - .stime = taosGetTimestampMs() + .stime = taosGetTimestampMs(), + .pid = pid, }; - tstrncpy(connObj.user, user, sizeof(connObj.user)); + tstrncpy(connObj.user, user, tListLen(connObj.user)); + tstrncpy(connObj.appName, app, tListLen(connObj.appName)); + connObj.lastAccess = connObj.stime; SConnObj *pConn = taosCachePut(tsMnodeConnCache, &connId, sizeof(int32_t), &connObj, sizeof(connObj), CONN_KEEP_TIME * 1000); @@ -114,7 +111,6 @@ void mnodeReleaseConn(SConnObj *pConn) { } SConnObj *mnodeAccquireConn(int32_t connId, char *user, uint32_t ip, uint16_t port) { - uint64_t expireTime = CONN_KEEP_TIME * 1000 + (uint64_t)taosGetTimestampMs(); SConnObj *pConn = taosCacheAcquireByKey(tsMnodeConnCache, &connId, sizeof(int32_t)); if (pConn == NULL) { mDebug("connId:%d, is already destroyed, user:%s ip:%s:%u", connId, user, taosIpStr(ip), port); @@ -129,7 +125,7 @@ SConnObj *mnodeAccquireConn(int32_t connId, char *user, uint32_t ip, uint16_t po } // mDebug("connId:%d, is incoming, user:%s ip:%s:%u", connId, pConn->user, taosIpStr(pConn->ip), pConn->port); - pConn->lastAccess = expireTime; + pConn->lastAccess = CONN_KEEP_TIME * 1000 + (uint64_t)taosGetTimestampMs(); return pConn; } @@ -183,6 +179,20 @@ static int32_t mnodeGetConnsMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; + // app name + pShow->bytes[cols] = TSDB_APPNAME_LEN + VARSTR_HEADER_SIZE; + pSchema[cols].type = TSDB_DATA_TYPE_BINARY; + strcpy(pSchema[cols].name, "app_name"); + pSchema[cols].bytes = htons(pShow->bytes[cols]); + cols++; + + // app pid + pShow->bytes[cols] = 4; + pSchema[cols].type = TSDB_DATA_TYPE_INT; + strcpy(pSchema[cols].name, "pid"); + pSchema[cols].bytes = htons(pShow->bytes[cols]); + cols++; + pShow->bytes[cols] = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE; pSchema[cols].type = TSDB_DATA_TYPE_BINARY; strcpy(pSchema[cols].name, "ip:port"); @@ -191,13 +201,13 @@ static int32_t mnodeGetConnsMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC pShow->bytes[cols] = 8; pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(pSchema[cols].name, "login time"); + strcpy(pSchema[cols].name, "login_time"); pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; pShow->bytes[cols] = 8; pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(pSchema[cols].name, "last access"); + strcpy(pSchema[cols].name, "last_access"); pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; @@ -236,6 +246,16 @@ static int32_t mnodeRetrieveConns(SShowObj *pShow, char *data, int32_t rows, voi STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->user, pShow->bytes[cols]); cols++; + // app name + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConnObj->appName, pShow->bytes[cols]); + cols++; + + // app pid + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int32_t*)pWrite = pConnObj->pid; + cols++; + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; snprintf(ipStr, sizeof(ipStr), "%s:%u", taosIpStr(pConnObj->ip), pConnObj->port); STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, pShow->bytes[cols]); @@ -254,8 +274,7 @@ static int32_t mnodeRetrieveConns(SShowObj *pShow, char *data, int32_t rows, voi } pShow->numOfReads += numOfRows; - const int32_t NUM_OF_COLUMNS = 5; - mnodeVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow); + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); return numOfRows; } @@ -299,7 +318,7 @@ static int32_t mnodeGetQueryMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC pShow->bytes[cols] = QUERY_ID_SIZE + VARSTR_HEADER_SIZE; pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "queryId"); + strcpy(pSchema[cols].name, "query_id"); pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; @@ -315,9 +334,15 @@ static int32_t mnodeGetQueryMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; + pShow->bytes[cols] = 24; + pSchema[cols].type = TSDB_DATA_TYPE_BINARY; + strcpy(pSchema[cols].name, "qhandle"); + pSchema[cols].bytes = htons(pShow->bytes[cols]); + cols++; + pShow->bytes[cols] = 8; pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(pSchema[cols].name, "created time"); + strcpy(pSchema[cols].name, "created_time"); pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; @@ -352,7 +377,7 @@ static int32_t mnodeRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, v SConnObj *pConnObj = NULL; int32_t cols = 0; char * pWrite; - char ipStr[TSDB_IPv4ADDR_LEN + 6]; + char str[TSDB_IPv4ADDR_LEN + 6] = {0}; while (numOfRows < rows) { pShow->pIter = mnodeGetNextConn(pShow->pIter, &pConnObj); @@ -362,9 +387,9 @@ static int32_t mnodeRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, v SQueryDesc *pDesc = pConnObj->pQueries + i; cols = 0; - snprintf(ipStr, QUERY_ID_SIZE + 1, "%u:%u", pConnObj->connId, htonl(pDesc->queryId)); + snprintf(str, QUERY_ID_SIZE + 1, "%u:%u", pConnObj->connId, htonl(pDesc->queryId)); pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, pShow->bytes[cols]); + STR_WITH_MAXSIZE_TO_VARSTR(pWrite, str, pShow->bytes[cols]); cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; @@ -372,8 +397,15 @@ static int32_t mnodeRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, v cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - snprintf(ipStr, sizeof(ipStr), "%s:%u", taosIpStr(pConnObj->ip), pConnObj->port); - STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, pShow->bytes[cols]); + snprintf(str, tListLen(str), "%s:%u", taosIpStr(pConnObj->ip), pConnObj->port); + STR_WITH_MAXSIZE_TO_VARSTR(pWrite, str, pShow->bytes[cols]); + cols++; + + char handleBuf[24] = {0}; + snprintf(handleBuf, tListLen(handleBuf), "%p", (void*)htobe64(pDesc->qHandle)); + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + + STR_WITH_MAXSIZE_TO_VARSTR(pWrite, handleBuf, pShow->bytes[cols]); cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; @@ -393,8 +425,7 @@ static int32_t mnodeRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, v } pShow->numOfReads += numOfRows; - const int32_t NUM_OF_COLUMNS = 6; - mnodeVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow); + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); return numOfRows; } @@ -522,8 +553,7 @@ static int32_t mnodeRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, v } pShow->numOfReads += numOfRows; - const int32_t NUM_OF_COLUMNS = 8; - mnodeVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow); + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); return numOfRows; } @@ -595,7 +625,7 @@ static int32_t mnodeProcessKillConnectionMsg(SMnodeMsg *pMsg) { SCMKillConnMsg *pKill = pMsg->rpcMsg.pCont; int32_t connId = atoi(pKill->queryId); - SConnObj * pConn = taosCacheAcquireByKey(tsMnodeConnCache, &connId, sizeof(int32_t)); + SConnObj *pConn = taosCacheAcquireByKey(tsMnodeConnCache, &connId, sizeof(int32_t)); if (pConn == NULL) { mError("connId:%s, failed to kill, conn not exist", pKill->queryId); return TSDB_CODE_MND_INVALID_CONN_ID; diff --git a/src/mnode/src/mnodeRead.c b/src/mnode/src/mnodeRead.c index af2fed3408ab726b5a819f6717fab497fcba1136..93b944febb42d3c7e7bac113b5447ddd1488369c 100644 --- a/src/mnode/src/mnodeRead.c +++ b/src/mnode/src/mnodeRead.c @@ -51,14 +51,21 @@ int32_t mnodeProcessRead(SMnodeMsg *pMsg) { SMnodeRsp *rpcRsp = &pMsg->rpcRsp; SRpcEpSet *epSet = rpcMallocCont(sizeof(SRpcEpSet)); mnodeGetMnodeEpSetForShell(epSet); - rpcRsp->rsp = epSet; - rpcRsp->len = sizeof(SRpcEpSet); - mDebug("%p, msg:%s in mread queue, will be redireced, inUse:%d", pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType], epSet->inUse); + mDebug("%p, msg:%s in mread queue will be redirected, numOfEps:%d inUse:%d", pMsg->rpcMsg.ahandle, + taosMsg[pMsg->rpcMsg.msgType], epSet->numOfEps, epSet->inUse); for (int32_t i = 0; i < epSet->numOfEps; ++i) { - mDebug("mnode index:%d ep:%s:%d", i, epSet->fqdn[i], htons(epSet->port[i])); + if (strcmp(epSet->fqdn[i], tsLocalFqdn) == 0 && htons(epSet->port[i]) == tsServerPort) { + epSet->inUse = (i + 1) % epSet->numOfEps; + mDebug("mnode index:%d ep:%s:%u, set inUse to %d", i, epSet->fqdn[i], htons(epSet->port[i]), epSet->inUse); + } else { + mDebug("mnode index:%d ep:%s:%u", i, epSet->fqdn[i], htons(epSet->port[i])); + } } + rpcRsp->rsp = epSet; + rpcRsp->len = sizeof(SRpcEpSet); + return TSDB_CODE_RPC_REDIRECT; } diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index 646c17b2b8b64344afb7c5117f2bd83b3da89dab..14558485aa743a42bee016226dfc2e16a4f81d0c 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -185,7 +185,11 @@ static int32_t sdbInitWal() { } sdbInfo("open sdb wal for restore"); - walRestore(tsSdbObj.wal, NULL, sdbWrite); + int code = walRestore(tsSdbObj.wal, NULL, sdbWrite); + if (code != TSDB_CODE_SUCCESS) { + sdbError("failed to open wal for restore, reason:%s", tstrerror(code)); + return -1; + } return 0; } @@ -294,31 +298,25 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) { taosFreeQitem(pOper); } -static void sdbUpdateSyncTmrFp(void *param, void *tmrId) { sdbUpdateSync(); } +static void sdbUpdateSyncTmrFp(void *param, void *tmrId) { sdbUpdateSync(NULL); } + +void sdbUpdateAsync() { + taosTmrReset(sdbUpdateSyncTmrFp, 200, NULL, tsMnodeTmr, &tsUpdateSyncTmr); +} -void sdbUpdateSync() { +void sdbUpdateSync(void *pMnodes) { + SDMMnodeInfos *mnodes = pMnodes; if (!mnodeIsRunning()) { - mDebug("mnode not start yet, update sync info later"); - if (dnodeCheckMnodeStarting()) { - taosTmrReset(sdbUpdateSyncTmrFp, 1000, NULL, tsMnodeTmr, &tsUpdateSyncTmr); - } + mDebug("mnode not start yet, update sync config later"); return; } - mDebug("update sync info in sdb"); + + mDebug("update sync config in sync module, mnodes:%p", pMnodes); SSyncCfg syncCfg = {0}; int32_t index = 0; - SDMMnodeInfos *mnodes = dnodeGetMnodeInfos(); - for (int32_t i = 0; i < mnodes->nodeNum; ++i) { - SDMMnodeInfo *node = &mnodes->nodeInfos[i]; - syncCfg.nodeInfo[i].nodeId = node->nodeId; - taosGetFqdnPortFromEp(node->nodeEp, syncCfg.nodeInfo[i].nodeFqdn, &syncCfg.nodeInfo[i].nodePort); - syncCfg.nodeInfo[i].nodePort += TSDB_PORT_SYNC; - index++; - } - - if (index == 0) { + if (mnodes == NULL) { void *pIter = NULL; while (1) { SMnodeObj *pMnode = NULL; @@ -338,9 +336,19 @@ void sdbUpdateSync() { mnodeDecMnodeRef(pMnode); } sdbFreeIter(pIter); + syncCfg.replica = index; + mDebug("mnodes info not input, use infos in sdb, numOfMnodes:%d", syncCfg.replica); + } else { + for (index = 0; index < mnodes->nodeNum; ++index) { + SDMMnodeInfo *node = &mnodes->nodeInfos[index]; + syncCfg.nodeInfo[index].nodeId = node->nodeId; + taosGetFqdnPortFromEp(node->nodeEp, syncCfg.nodeInfo[index].nodeFqdn, &syncCfg.nodeInfo[index].nodePort); + syncCfg.nodeInfo[index].nodePort += TSDB_PORT_SYNC; + } + syncCfg.replica = index; + mDebug("mnodes info input, numOfMnodes:%d", syncCfg.replica); } - syncCfg.replica = index; syncCfg.quorum = (syncCfg.replica == 1) ? 1 : 2; bool hasThisDnode = false; @@ -351,8 +359,15 @@ void sdbUpdateSync() { } } - if (!hasThisDnode) return; - if (memcmp(&syncCfg, &tsSdbObj.cfg, sizeof(SSyncCfg)) == 0) return; + if (!hasThisDnode) { + sdbDebug("update sync config, this dnode not exist"); + return; + } + + if (memcmp(&syncCfg, &tsSdbObj.cfg, sizeof(SSyncCfg)) == 0) { + sdbDebug("update sync config, info not changed"); + return; + } sdbInfo("work as mnode, replica:%d", syncCfg.replica); for (int32_t i = 0; i < syncCfg.replica; ++i) { @@ -579,7 +594,7 @@ static int sdbWrite(void *param, void *data, int type) { pthread_mutex_unlock(&tsSdbObj.mutex); sdbError("table:%s, failed to restore %s record:%s from source(%d), ver:%" PRId64 " too large, sdb ver:%" PRId64, pTable->tableName, sdbGetActionStr(action), sdbGetKeyStr(pTable, pHead->cont), type, pHead->version, tsSdbObj.version); - return TSDB_CODE_MND_APP_ERROR; + return TSDB_CODE_SYN_INVALID_VERSION; } else { tsSdbObj.version = pHead->version; } @@ -1039,7 +1054,7 @@ static void *sdbWorkerFp(void *param) { while (1) { numOfMsgs = taosReadAllQitemsFromQset(tsSdbWriteQset, tsSdbWriteQall, &unUsed); if (numOfMsgs == 0) { - sdbDebug("sdbWorkerFp: got no message from qset, exiting..."); + sdbDebug("qset:%p, sdb got no message from qset, exiting", tsSdbWriteQset); break; } diff --git a/src/mnode/src/mnodeShow.c b/src/mnode/src/mnodeShow.c index f66ef6b7a36ac785459b9093f54b8e33ba6cc622..80909e99aec6d752d35042ca2d761a6e8b923441 100644 --- a/src/mnode/src/mnodeShow.c +++ b/src/mnode/src/mnodeShow.c @@ -65,7 +65,7 @@ int32_t mnodeInitShow() { mnodeAddReadMsgHandle(TSDB_MSG_TYPE_CM_CONNECT, mnodeProcessConnectMsg); mnodeAddReadMsgHandle(TSDB_MSG_TYPE_CM_USE_DB, mnodeProcessUseMsg); - tsMnodeShowCache = taosCacheInit(TSDB_DATA_TYPE_BIGINT, 5, false, mnodeFreeShowObj, "show"); + tsMnodeShowCache = taosCacheInit(TSDB_CACHE_PTR_KEY, 5, true, mnodeFreeShowObj, "show"); return 0; } @@ -186,7 +186,7 @@ static int32_t mnodeProcessRetrieveMsg(SMnodeMsg *pMsg) { rowsToRead = pShow->numOfRows - pShow->numOfReads; } - /* return no more than 100 meters in one round trip */ + /* return no more than 100 tables in one round trip */ if (rowsToRead > 100) rowsToRead = 100; /* @@ -244,7 +244,8 @@ static int32_t mnodeProcessHeartBeatMsg(SMnodeMsg *pMsg) { int32_t connId = htonl(pHBMsg->connId); SConnObj *pConn = mnodeAccquireConn(connId, connInfo.user, connInfo.clientIp, connInfo.clientPort); if (pConn == NULL) { - pConn = mnodeCreateConn(connInfo.user, connInfo.clientIp, connInfo.clientPort); + pHBMsg->pid = htonl(pHBMsg->pid); + pConn = mnodeCreateConn(connInfo.user, connInfo.clientIp, connInfo.clientPort, pHBMsg->pid, pHBMsg->appName); } if (pConn == NULL) { @@ -325,7 +326,8 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) { goto connect_over; } - SConnObj *pConn = mnodeCreateConn(connInfo.user, connInfo.clientIp, connInfo.clientPort); + pConnectMsg->pid = htonl(pConnectMsg->pid); + SConnObj *pConn = mnodeCreateConn(connInfo.user, connInfo.clientIp, connInfo.clientPort, pConnectMsg->pid, pConnectMsg->appName); if (pConn == NULL) { code = terrno; } else { @@ -378,8 +380,8 @@ static bool mnodeCheckShowFinished(SShowObj *pShow) { } static bool mnodeAccquireShowObj(SShowObj *pShow) { - uint64_t handleVal = (uint64_t)pShow; - SShowObj **ppShow = taosCacheAcquireByKey(tsMnodeShowCache, &handleVal, sizeof(int64_t)); + TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE)pShow; + SShowObj **ppShow = taosCacheAcquireByKey(tsMnodeShowCache, &handleVal, sizeof(TSDB_CACHE_PTR_TYPE)); if (ppShow) { mDebug("%p, show is accquired from cache, data:%p, index:%d", pShow, ppShow, pShow->index); return true; @@ -389,10 +391,12 @@ static bool mnodeAccquireShowObj(SShowObj *pShow) { } static void* mnodePutShowObj(SShowObj *pShow) { + const int32_t DEFAULT_SHOWHANDLE_LIFE_SPAN = tsShellActivityTimer * 6 * 1000; + if (tsMnodeShowCache != NULL) { pShow->index = atomic_add_fetch_32(&tsShowObjIndex, 1); - uint64_t handleVal = (uint64_t)pShow; - SShowObj **ppShow = taosCachePut(tsMnodeShowCache, &handleVal, sizeof(int64_t), &pShow, sizeof(int64_t), 6000); + TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE)pShow; + SShowObj **ppShow = taosCachePut(tsMnodeShowCache, &handleVal, sizeof(TSDB_CACHE_PTR_TYPE), &pShow, sizeof(TSDB_CACHE_PTR_TYPE), DEFAULT_SHOWHANDLE_LIFE_SPAN); pShow->ppShow = (void**)ppShow; mDebug("%p, show is put into cache, data:%p index:%d", pShow, ppShow, pShow->index); return pShow; diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 4400927e9b02ba30196e0b04d485f894d23c8cf6..82a062169a591d26d665437273183a4c5e1f27b4 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -63,27 +63,27 @@ static int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t static int32_t mnodeGetStreamTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn); static int32_t mnodeRetrieveStreamTables(SShowObj *pShow, char *data, int32_t rows, void *pConn); -static int32_t mnodeProcessCreateTableMsg(SMnodeMsg *mnodeMsg); +static int32_t mnodeProcessCreateTableMsg(SMnodeMsg *pMsg); static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg); static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg); static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg); -static int32_t mnodeProcessDropTableMsg(SMnodeMsg *mnodeMsg); +static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg); static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg); static void mnodeProcessDropSuperTableRsp(SRpcMsg *rpcMsg); static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg); static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg); -static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *mnodeMsg); -static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *mnodeMsg); -static int32_t mnodeProcessTableCfgMsg(SMnodeMsg *mnodeMsg); +static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg); +static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *pMsg); +static int32_t mnodeProcessTableCfgMsg(SMnodeMsg *pMsg); -static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *mnodeMsg); +static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *pMsg); static int32_t mnodeGetSuperTableMeta(SMnodeMsg *pMsg); static int32_t mnodeGetChildTableMeta(SMnodeMsg *pMsg); static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg); -static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *mnodeMsg); +static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg); static void mnodeProcessAlterTableRsp(SRpcMsg *rpcMsg); static int32_t mnodeFindSuperTableColumnIndex(SSuperTableObj *pStable, char *colName); @@ -131,6 +131,8 @@ static int32_t mnodeChildTableActionInsert(SSdbOper *pOper) { mnodeAddTableIntoStable(pTable->superTable, pTable); grantAdd(TSDB_GRANT_TIMESERIES, pTable->superTable->numOfColumns - 1); if (pAcct) pAcct->acctInfo.numOfTimeSeries += (pTable->superTable->numOfColumns - 1); + } else { + mError("table:%s:%p, correspond stable not found suid:%" PRIu64, pTable->info.tableId, pTable, pTable->suid); } } else { grantAdd(TSDB_GRANT_TIMESERIES, pTable->numOfColumns - 1); @@ -301,7 +303,7 @@ static int32_t mnodeChildTableActionRestored() { SVgObj *pVgroup = mnodeGetVgroup(pTable->vgId); if (pVgroup == NULL) { - mError("ctable:%s, failed to get vgId:%d sid:%d, discard it", pTable->info.tableId, pTable->vgId, pTable->sid); + mError("ctable:%s, failed to get vgId:%d tid:%d, discard it", pTable->info.tableId, pTable->vgId, pTable->tid); pTable->vgId = 0; SSdbOper desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .table = tsChildTableSdb}; sdbDeleteRow(&desc); @@ -312,7 +314,7 @@ static int32_t mnodeChildTableActionRestored() { if (strcmp(pVgroup->dbName, pDb->name) != 0) { mError("ctable:%s, db:%s not match with vgId:%d db:%s sid:%d, discard it", - pTable->info.tableId, pDb->name, pTable->vgId, pVgroup->dbName, pTable->sid); + pTable->info.tableId, pDb->name, pTable->vgId, pVgroup->dbName, pTable->tid); pTable->vgId = 0; SSdbOper desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .table = tsChildTableSdb}; sdbDeleteRow(&desc); @@ -460,12 +462,14 @@ static int32_t mnodeSuperTableActionUpdate(SSdbOper *pOper) { void *oldSchema = pTable->schema; void *oldVgHash = pTable->vgHash; int32_t oldRefCount = pTable->refCount; + int32_t oldNumOfTables = pTable->numOfTables; memcpy(pTable, pNew, sizeof(SSuperTableObj)); pTable->vgHash = oldVgHash; pTable->refCount = oldRefCount; pTable->schema = pNew->schema; + pTable->numOfTables = oldNumOfTables; free(pNew); free(oldTableId); free(oldSchema); @@ -767,8 +771,8 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) { return mnodeProcessDropSuperTableMsg(pMsg); } else { SChildTableObj *pCTable = (SChildTableObj *)pMsg->pTable; - mInfo("app:%p:%p, table:%s, start to drop ctable, vgId:%d sid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg, - pDrop->tableId, pCTable->vgId, pCTable->sid, pCTable->uid); + mInfo("app:%p:%p, table:%s, start to drop ctable, vgId:%d tid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg, + pDrop->tableId, pCTable->vgId, pCTable->tid, pCTable->uid); return mnodeProcessDropChildTableMsg(pMsg); } } @@ -837,10 +841,11 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) { return TSDB_CODE_MND_OUT_OF_MEMORY; } + int64_t us = taosGetTimestampUs(); pStable->info.tableId = strdup(pCreate->tableId); pStable->info.type = TSDB_SUPER_TABLE; pStable->createdTime = taosGetTimestampMs(); - pStable->uid = (((uint64_t) pStable->createdTime) << 16) + (sdbGetVersion() & ((1ul << 16) - 1ul)); + pStable->uid = (us << 24) + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul)); pStable->sversion = 0; pStable->tversion = 0; pStable->numOfColumns = htons(pCreate->numOfColumns); @@ -1384,6 +1389,8 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows, } pShow->numOfReads += numOfRows; + + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); mnodeDecDbRef(pDb); return numOfRows; @@ -1392,16 +1399,20 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows, void mnodeDropAllSuperTables(SDbObj *pDropDb) { void * pIter= NULL; int32_t numOfTables = 0; - int32_t dbNameLen = strlen(pDropDb->name); SSuperTableObj *pTable = NULL; + char prefix[64] = {0}; + tstrncpy(prefix, pDropDb->name, 64); + strcat(prefix, TS_PATH_DELIMITER); + int32_t prefixLen = strlen(prefix); + mInfo("db:%s, all super tables will be dropped from sdb", pDropDb->name); while (1) { pIter = mnodeGetNextSuperTable(pIter, &pTable); if (pTable == NULL) break; - if (strncmp(pDropDb->name, pTable->info.tableId, dbNameLen) == 0) { + if (strncmp(prefix, pTable->info.tableId, prefixLen) == 0) { SSdbOper oper = { .type = SDB_OPER_LOCAL, .table = tsSuperTableSdb, @@ -1465,13 +1476,14 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) { int32_t numOfTable = htonl(pInfo->numOfTables); // reserve space - int32_t contLen = sizeof(SCMSTableVgroupRspMsg) + 32 * sizeof(SCMVgroupInfo) + sizeof(SVgroupsInfo); + int32_t contLen = sizeof(SCMSTableVgroupRspMsg) + 32 * sizeof(SCMVgroupMsg) + sizeof(SVgroupsMsg); for (int32_t i = 0; i < numOfTable; ++i) { char *stableName = (char*)pInfo + sizeof(SCMSTableVgroupMsg) + (TSDB_TABLE_FNAME_LEN) * i; SSuperTableObj *pTable = mnodeGetSuperTable(stableName); if (pTable != NULL && pTable->vgHash != NULL) { - contLen += (taosHashGetSize(pTable->vgHash) * sizeof(SCMVgroupInfo) + sizeof(SVgroupsInfo)); + contLen += (taosHashGetSize(pTable->vgHash) * sizeof(SCMVgroupMsg) + sizeof(SVgroupsMsg)); } + mnodeDecTableRef(pTable); } @@ -1492,19 +1504,19 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) { continue; } if (pTable->vgHash == NULL) { - mError("app:%p:%p, stable:%s, no vgroup exist while get stable vgroup info", pMsg->rpcMsg.ahandle, pMsg, + mDebug("app:%p:%p, stable:%s, no vgroup exist while get stable vgroup info", pMsg->rpcMsg.ahandle, pMsg, stableName); mnodeDecTableRef(pTable); // even this super table has no corresponding table, still return pRsp->numOfTables++; - SVgroupsInfo *pVgroupInfo = (SVgroupsInfo *)msg; - pVgroupInfo->numOfVgroups = 0; + SVgroupsMsg *pVgroupMsg = (SVgroupsMsg *)msg; + pVgroupMsg->numOfVgroups = 0; - msg += sizeof(SVgroupsInfo); + msg += sizeof(SVgroupsMsg); } else { - SVgroupsInfo *pVgroupInfo = (SVgroupsInfo *)msg; + SVgroupsMsg *pVgroupMsg = (SVgroupsMsg *)msg; SHashMutableIterator *pIter = taosHashCreateIter(pTable->vgHash); int32_t vgSize = 0; @@ -1513,15 +1525,17 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) { SVgObj * pVgroup = mnodeGetVgroup(*pVgId); if (pVgroup == NULL) continue; - pVgroupInfo->vgroups[vgSize].vgId = htonl(pVgroup->vgId); + pVgroupMsg->vgroups[vgSize].vgId = htonl(pVgroup->vgId); + pVgroupMsg->vgroups[vgSize].numOfEps = 0; + for (int32_t vn = 0; vn < pVgroup->numOfVnodes; ++vn) { SDnodeObj *pDnode = pVgroup->vnodeGid[vn].pDnode; if (pDnode == NULL) break; - tstrncpy(pVgroupInfo->vgroups[vgSize].epAddr[vn].fqdn, pDnode->dnodeFqdn, TSDB_FQDN_LEN); - pVgroupInfo->vgroups[vgSize].epAddr[vn].port = htons(pDnode->dnodePort); + tstrncpy(pVgroupMsg->vgroups[vgSize].epAddr[vn].fqdn, pDnode->dnodeFqdn, TSDB_FQDN_LEN); + pVgroupMsg->vgroups[vgSize].epAddr[vn].port = htons(pDnode->dnodePort); - pVgroupInfo->vgroups[vgSize].numOfEps++; + pVgroupMsg->vgroups[vgSize].numOfEps++; } vgSize++; @@ -1531,10 +1545,10 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) { taosHashDestroyIter(pIter); mnodeDecTableRef(pTable); - pVgroupInfo->numOfVgroups = htonl(vgSize); + pVgroupMsg->numOfVgroups = htonl(vgSize); // one table is done, try the next table - msg += sizeof(SVgroupsInfo) + vgSize * sizeof(SCMVgroupInfo); + msg += sizeof(SVgroupsMsg) + vgSize * sizeof(SCMVgroupMsg); pRsp->numOfTables++; } } @@ -1584,7 +1598,7 @@ static void *mnodeBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableO pCreate->vgId = htonl(pTable->vgId); pCreate->tableType = pTable->info.type; pCreate->createdTime = htobe64(pTable->createdTime); - pCreate->sid = htonl(pTable->sid); + pCreate->tid = htonl(pTable->tid); pCreate->sqlDataLen = htonl(pTable->sqlLen); pCreate->uid = htobe64(pTable->uid); @@ -1633,7 +1647,7 @@ static int32_t mnodeDoCreateChildTableFp(SMnodeMsg *pMsg) { assert(pTable); mDebug("app:%p:%p, table:%s, created in mnode, vgId:%d sid:%d, uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg, - pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid); + pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid); SCMCreateTableMsg *pCreate = pMsg->rpcMsg.pCont; SMDCreateTableMsg *pMDCreate = mnodeBuildCreateChildTableMsg(pCreate, pTable); @@ -1675,7 +1689,7 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) { return TSDB_CODE_MND_ACTION_IN_PROGRESS; } else { mError("app:%p:%p, table:%s, failed to create table sid:%d, uid:%" PRIu64 ", reason:%s", pMsg->rpcMsg.ahandle, pMsg, - pTable->info.tableId, pTable->sid, pTable->uid, tstrerror(code)); + pTable->info.tableId, pTable->tid, pTable->uid, tstrerror(code)); SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pTable, .table = tsChildTableSdb}; sdbDeleteRow(&desc); return code; @@ -1699,11 +1713,11 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) { pTable->info.tableId = strdup(pCreate->tableId); pTable->createdTime = taosGetTimestampMs(); - pTable->sid = tid; + pTable->tid = tid; pTable->vgId = pVgroup->vgId; - + if (pTable->info.type == TSDB_CHILD_TABLE) { - STagData *pTagData = (STagData *) pCreate->schema; // it is a tag key + STagData *pTagData = (STagData *)pCreate->schema; // it is a tag key if (pMsg->pSTable == NULL) pMsg->pSTable = mnodeGetSuperTable(pTagData->name); if (pMsg->pSTable == NULL) { mError("app:%p:%p, table:%s, corresponding super table:%s does not exist", pMsg->rpcMsg.ahandle, pMsg, @@ -1713,7 +1727,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) { } pTable->suid = pMsg->pSTable->uid; - pTable->uid = (((uint64_t)pTable->vgId) << 48) + ((((uint64_t)pTable->sid) & ((1ul << 24) - 1ul)) << 24) + + pTable->uid = (((uint64_t)pTable->vgId) << 48) + ((((uint64_t)pTable->tid) & ((1ul << 24) - 1ul)) << 24) + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul)); pTable->superTable = pMsg->pSTable; } else { @@ -1721,7 +1735,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) { int64_t us = taosGetTimestampUs(); pTable->uid = (us << 24) + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul)); } else { - pTable->uid = (((uint64_t)pTable->vgId) << 48) + ((((uint64_t)pTable->sid) & ((1ul << 24) - 1ul)) << 24) + + pTable->uid = (((uint64_t)pTable->vgId) << 48) + ((((uint64_t)pTable->tid) & ((1ul << 24) - 1ul)) << 24) + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul)); } @@ -1778,7 +1792,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) { tstrerror(code)); } else { mDebug("app:%p:%p, table:%s, allocated in vgroup, vgId:%d sid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg, - pTable->info.tableId, pVgroup->vgId, pTable->sid, pTable->uid); + pTable->info.tableId, pVgroup->vgId, pTable->tid, pTable->uid); } return code; @@ -1796,8 +1810,8 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) { if (pMsg->retry == 0) { if (pMsg->pTable == NULL) { SVgObj *pVgroup = NULL; - int32_t sid = 0; - code = mnodeGetAvailableVgroup(pMsg, &pVgroup, &sid); + int32_t tid = 0; + code = mnodeGetAvailableVgroup(pMsg, &pVgroup, &tid); if (code != TSDB_CODE_SUCCESS) { mDebug("app:%p:%p, table:%s, failed to get available vgroup, reason:%s", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId, tstrerror(code)); @@ -1811,7 +1825,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) { pMsg->pVgroup = pVgroup; mnodeIncVgroupRef(pVgroup); - return mnodeDoCreateChildTable(pMsg, sid); + return mnodeDoCreateChildTable(pMsg, tid); } } else { if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pCreate->tableId); @@ -1841,13 +1855,13 @@ static int32_t mnodeSendDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) { tstrncpy(pDrop->tableId, pTable->info.tableId, TSDB_TABLE_FNAME_LEN); pDrop->vgId = htonl(pTable->vgId); pDrop->contLen = htonl(sizeof(SMDDropTableMsg)); - pDrop->sid = htonl(pTable->sid); + pDrop->tid = htonl(pTable->tid); pDrop->uid = htobe64(pTable->uid); SRpcEpSet epSet = mnodeGetEpSetFromVgroup(pMsg->pVgroup); mInfo("app:%p:%p, ctable:%s, send drop ctable msg, vgId:%d sid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg, - pDrop->tableId, pTable->vgId, pTable->sid, pTable->uid); + pDrop->tableId, pTable->vgId, pTable->tid, pTable->uid); SRpcMsg rpcMsg = { .ahandle = pMsg, @@ -2086,12 +2100,15 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) { SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable; pMeta->uid = htobe64(pTable->uid); - pMeta->sid = htonl(pTable->sid); + pMeta->tid = htonl(pTable->tid); pMeta->precision = pDb->cfg.precision; pMeta->tableType = pTable->info.type; tstrncpy(pMeta->tableId, pTable->info.tableId, TSDB_TABLE_FNAME_LEN); + if (pTable->superTable != NULL) { + tstrncpy(pMeta->sTableId, pTable->superTable->info.tableId, TSDB_TABLE_FNAME_LEN); + } - if (pTable->info.type == TSDB_CHILD_TABLE) { + if (pTable->info.type == TSDB_CHILD_TABLE && pTable->superTable != NULL) { pMeta->sversion = htons(pTable->superTable->sversion); pMeta->tversion = htons(pTable->superTable->tversion); pMeta->numOfTags = (int8_t)pTable->superTable->numOfTags; @@ -2122,8 +2139,8 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) { } pMeta->vgroup.vgId = htonl(pMsg->pVgroup->vgId); - mDebug("app:%p:%p, table:%s, uid:%" PRIu64 " table meta is retrieved", pMsg->rpcMsg.ahandle, pMsg, - pTable->info.tableId, pTable->uid); + mDebug("app:%p:%p, table:%s, uid:%" PRIu64 " table meta is retrieved, vgId:%d sid:%d", pMsg->rpcMsg.ahandle, pMsg, + pTable->info.tableId, pTable->uid, pTable->vgId, pTable->tid); return TSDB_CODE_SUCCESS; } @@ -2214,16 +2231,20 @@ void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup) { void mnodeDropAllChildTables(SDbObj *pDropDb) { void * pIter = NULL; int32_t numOfTables = 0; - int32_t dbNameLen = strlen(pDropDb->name); SChildTableObj *pTable = NULL; + char prefix[64] = {0}; + tstrncpy(prefix, pDropDb->name, 64); + strcat(prefix, TS_PATH_DELIMITER); + int32_t prefixLen = strlen(prefix); + mInfo("db:%s, all child tables will be dropped from sdb", pDropDb->name); while (1) { pIter = mnodeGetNextChildTable(pIter, &pTable); if (pTable == NULL) break; - if (strncmp(pDropDb->name, pTable->info.tableId, dbNameLen) == 0) { + if (strncmp(prefix, pTable->info.tableId, prefixLen) == 0) { SSdbOper oper = { .type = SDB_OPER_LOCAL, .table = tsChildTableSdb, @@ -2245,7 +2266,8 @@ static void mnodeDropAllChildTablesInStable(SSuperTableObj *pStable) { int32_t numOfTables = 0; SChildTableObj *pTable = NULL; - mInfo("stable:%s, all child tables:%d will dropped from sdb", pStable->info.tableId, pStable->numOfTables); + mInfo("stable:%s uid:%" PRIu64 ", all child tables:%d will be dropped from sdb", pStable->info.tableId, pStable->uid, + pStable->numOfTables); while (1) { pIter = mnodeGetNextChildTable(pIter, &pTable); @@ -2270,11 +2292,11 @@ static void mnodeDropAllChildTablesInStable(SSuperTableObj *pStable) { } #if 0 -static SChildTableObj* mnodeGetTableByPos(int32_t vnode, int32_t sid) { +static SChildTableObj* mnodeGetTableByPos(int32_t vnode, int32_t tid) { SVgObj *pVgroup = mnodeGetVgroup(vnode); if (pVgroup == NULL) return NULL; - SChildTableObj *pTable = pVgroup->tableList[sid - 1]; + SChildTableObj *pTable = pVgroup->tableList[tid - 1]; mnodeIncTableRef((STableObj *)pTable); mnodeDecVgroupRef(pVgroup); @@ -2322,12 +2344,12 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) { assert(pTable); mInfo("app:%p:%p, table:%s, drop table rsp received, vgId:%d sid:%d uid:%" PRIu64 ", thandle:%p result:%s", - mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid, + mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid, mnodeMsg->rpcMsg.handle, tstrerror(rpcMsg->code)); if (rpcMsg->code != TSDB_CODE_SUCCESS) { mError("app:%p:%p, table:%s, failed to drop in dnode, vgId:%d sid:%d uid:%" PRIu64 ", reason:%s", - mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid, + mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid, tstrerror(rpcMsg->code)); dnodeSendRpcMnodeWriteRsp(mnodeMsg, rpcMsg->code); return; @@ -2365,7 +2387,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) { // If the table is deleted by another thread during creation, stop creating and send drop msg to vnode if (sdbCheckRowDeleted(tsChildTableSdb, pTable)) { mDebug("app:%p:%p, table:%s, create table rsp received, but a deleting opertion incoming, vgId:%d sid:%d uid:%" PRIu64, - mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid); + mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid); // if the vgroup is already dropped from hash, it can't be accquired by pTable->vgId // so the refCount of vgroup can not be decreased @@ -2398,14 +2420,16 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) { } } else { if (mnodeMsg->retry++ < 10) { - mDebug("app:%p:%p, table:%s, create table rsp received, need retry, times:%d result:%s thandle:%p", - mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, mnodeMsg->retry, tstrerror(rpcMsg->code), - mnodeMsg->rpcMsg.handle); + mDebug("app:%p:%p, table:%s, create table rsp received, need retry, times:%d vgId:%d sid:%d uid:%" PRIu64 + " result:%s thandle:%p", + mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, mnodeMsg->retry, pTable->vgId, pTable->tid, + pTable->uid, tstrerror(rpcMsg->code), mnodeMsg->rpcMsg.handle); dnodeDelayReprocessMnodeWriteMsg(mnodeMsg); } else { - mError("app:%p:%p, table:%s, failed to create in dnode, result:%s thandle:%p", mnodeMsg->rpcMsg.ahandle, mnodeMsg, - pTable->info.tableId, tstrerror(rpcMsg->code), mnodeMsg->rpcMsg.handle); + mError("app:%p:%p, table:%s, failed to create in dnode, vgId:%d sid:%d uid:%" PRIu64 ", result:%s thandle:%p", + mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid, + tstrerror(rpcMsg->code), mnodeMsg->rpcMsg.handle); SSdbOper oper = {.type = SDB_OPER_GLOBAL, .table = tsChildTableSdb, .pObj = pTable}; sdbDeleteRow(&oper); @@ -2537,6 +2561,25 @@ static int32_t mnodeGetShowTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, void pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; + pShow->bytes[cols] = 8; // table uid + pSchema[cols].type = TSDB_DATA_TYPE_BIGINT; + strcpy(pSchema[cols].name, "uid"); + pSchema[cols].bytes = htons(pShow->bytes[cols]); + cols++; + + pShow->bytes[cols] = 4; + pSchema[cols].type = TSDB_DATA_TYPE_INT; + strcpy(pSchema[cols].name, "tid"); + pSchema[cols].bytes = htons(pShow->bytes[cols]); + cols++; + + pShow->bytes[cols] = 4; + pSchema[cols].type = TSDB_DATA_TYPE_INT; + strcpy(pSchema[cols].name, "vgId"); + pSchema[cols].bytes = htons(pShow->bytes[cols]); + cols++; + + pMeta->numOfColumns = htons(cols); pShow->numOfColumns = cols; @@ -2562,6 +2605,7 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows return 0; } + int32_t cols = 0; int32_t numOfRows = 0; SChildTableObj *pTable = NULL; SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; @@ -2602,8 +2646,7 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows continue; } - int32_t cols = 0; - + cols = 0; char *pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; STR_WITH_MAXSIZE_TO_VARSTR(pWrite, tableName, pShow->bytes[cols]); @@ -2632,14 +2675,29 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows cols++; + // uid + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int64_t*) pWrite = pTable->uid; + cols++; + + + // tid + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int32_t*) pWrite = pTable->tid; + cols++; + + //vgid + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int32_t*) pWrite = pTable->vgId; + cols++; + numOfRows++; mnodeDecTableRef(pTable); } pShow->numOfReads += numOfRows; - const int32_t NUM_OF_COLUMNS = 4; - mnodeVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow); + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); mnodeDecDbRef(pDb); free(pattern); @@ -2837,9 +2895,8 @@ static int32_t mnodeRetrieveStreamTables(SShowObj *pShow, char *data, int32_t ro } pShow->numOfReads += numOfRows; - const int32_t NUM_OF_COLUMNS = 4; - mnodeVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow); + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); mnodeDecDbRef(pDb); return numOfRows; diff --git a/src/mnode/src/mnodeUser.c b/src/mnode/src/mnodeUser.c index c03ff688d2282f931706e80331a884439d78ee04..779e25254897ff37f1ca884e83469233d7197b8c 100644 --- a/src/mnode/src/mnodeUser.c +++ b/src/mnode/src/mnodeUser.c @@ -386,6 +386,7 @@ static int32_t mnodeRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, voi mnodeDecUserRef(pUser); } + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); pShow->numOfReads += numOfRows; return numOfRows; } diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index aa6631ff837010e9fffb3663b5b50a57c61b557c..5084f1276ae883289939bd74c50a0502f6b3c71d 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -270,31 +270,34 @@ void mnodeUpdateVgroup(SVgObj *pVgroup) { Traverse all vgroups on mnode, if there no such vgId on a dnode, so send msg to this dnode for re-creating this vgId/vnode */ void mnodeCheckUnCreatedVgroup(SDnodeObj *pDnode, SVnodeLoad *pVloads, int32_t openVnodes) { - SVnodeLoad *pNextV = NULL; - void *pIter = NULL; while (1) { SVgObj *pVgroup; pIter = mnodeGetNextVgroup(pIter, &pVgroup); if (pVgroup == NULL) break; - pNextV = pVloads; - int32_t i; - for (i = 0; i < openVnodes; ++i) { - if ((pVgroup->vnodeGid[i].pDnode == pDnode) && (pVgroup->vgId == pNextV->vgId)) { - break; - } - pNextV++; - } - - if (i == openVnodes) { - if (pVgroup->status == TAOS_VG_STATUS_CREATING || pVgroup->status == TAOS_VG_STATUS_DROPPING) { - mDebug("vgId:%d, not exist in dnode:%d and status is %s, do nothing", pVgroup->vgId, pDnode->dnodeId, - vgroupStatus[pVgroup->status]); - } else { - mDebug("vgId:%d, not exist in dnode:%d and status is %s, send create msg", pVgroup->vgId, pDnode->dnodeId, - vgroupStatus[pVgroup->status]); - mnodeSendCreateVgroupMsg(pVgroup, NULL); + for (int v = 0; v < pVgroup->numOfVnodes; ++v) { + if (pVgroup->vnodeGid[v].dnodeId == pDnode->dnodeId) { + // vgroup should have a vnode on this dnode + bool have = false; + for (int32_t i = 0; i < openVnodes; ++i) { + SVnodeLoad *pVload = pVloads + i; + if (pVgroup->vgId == pVload->vgId) { + have = true; + break; + } + } + + if (have) continue; + + if (pVgroup->status == TAOS_VG_STATUS_CREATING || pVgroup->status == TAOS_VG_STATUS_DROPPING) { + mDebug("vgId:%d, not exist in dnode:%d and status is %s, do nothing", pVgroup->vgId, pDnode->dnodeId, + vgroupStatus[pVgroup->status]); + } else { + mDebug("vgId:%d, not exist in dnode:%d and status is %s, send create msg", pVgroup->vgId, pDnode->dnodeId, + vgroupStatus[pVgroup->status]); + mnodeSendCreateVgroupMsg(pVgroup, NULL); + } } } @@ -302,7 +305,6 @@ void mnodeCheckUnCreatedVgroup(SDnodeObj *pDnode, SVnodeLoad *pVloads, int32_t o } sdbFreeIter(pIter); - return; } void mnodeUpdateVgroupStatus(SVgObj *pVgroup, SDnodeObj *pDnode, SVnodeLoad *pVload) { @@ -310,7 +312,7 @@ void mnodeUpdateVgroupStatus(SVgObj *pVgroup, SDnodeObj *pDnode, SVnodeLoad *pVl for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) { SVnodeGid *pVgid = &pVgroup->vnodeGid[i]; if (pVgid->pDnode == pDnode) { - mTrace("dnode:%d, receive status from dnode, vgId:%d status is %d", pDnode->dnodeId, pVgroup->vgId, pVgid->role); + mTrace("dnode:%d, receive status from dnode, vgId:%d status is %d:%s", pDnode->dnodeId, pVgroup->vgId, pVgid->role, syncRole[pVgid->role]); pVgid->role = pVload->role; if (pVload->role == TAOS_SYNC_ROLE_MASTER) { pVgroup->inUse = i; @@ -434,7 +436,8 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi int maxVgroupsPerDb = tsMaxVgroupsPerDb; if (maxVgroupsPerDb <= 0) { maxVgroupsPerDb = mnodeGetOnlinDnodesCpuCoreNum(); - maxVgroupsPerDb = MAX(maxVgroupsPerDb, 2); + maxVgroupsPerDb = MAX(maxVgroupsPerDb, TSDB_MIN_VNODES_PER_DB); + maxVgroupsPerDb = MIN(maxVgroupsPerDb, TSDB_MAX_VNODES_PER_DB); } int32_t code = TSDB_CODE_MND_NO_ENOUGH_DNODES; @@ -660,13 +663,13 @@ static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p for (int32_t i = 0; i < pShow->maxReplica; ++i) { pShow->bytes[cols] = 2; pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT; - strcpy(pSchema[cols].name, "dnode"); + snprintf(pSchema[cols].name, TSDB_COL_NAME_LEN, "dnode%d", i + 1); pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; pShow->bytes[cols] = 9 + VARSTR_HEADER_SIZE; pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "vstatus"); + snprintf(pSchema[cols].name, TSDB_COL_NAME_LEN, "v%dstatus", i + 1); pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; } @@ -722,8 +725,16 @@ static int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, v while (numOfRows < rows) { pShow->pIter = mnodeGetNextVgroup(pShow->pIter, &pVgroup); if (pVgroup == NULL) break; - if (pVgroup->pDb != pDb) continue; - if (!mnodeFilterVgroups(pVgroup, pTable)) continue; + + if (pVgroup->pDb != pDb) { + mnodeDecVgroupRef(pVgroup); + continue; + } + + if (!mnodeFilterVgroups(pVgroup, pTable)) { + mnodeDecVgroupRef(pVgroup); + continue; + } cols = 0; @@ -771,6 +782,8 @@ static int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, v numOfRows++; } + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); + pShow->numOfReads += numOfRows; mnodeDecTableRef(pTable); mnodeDecDbRef(pDb); @@ -780,12 +793,12 @@ static int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, v void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable) { int32_t idPoolSize = taosIdPoolMaxSize(pVgroup->idPool); - if (pTable->sid > idPoolSize) { + if (pTable->tid > idPoolSize) { mnodeAllocVgroupIdPool(pVgroup); } - if (pTable->sid >= 1) { - taosIdPoolMarkStatus(pVgroup->idPool, pTable->sid); + if (pTable->tid >= 1) { + taosIdPoolMarkStatus(pVgroup->idPool, pTable->tid); pVgroup->numOfTables++; // The create vgroup message may be received later than the create table message // and the writing order in sdb is therefore uncertain @@ -795,8 +808,8 @@ void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable) { } void mnodeRemoveTableFromVgroup(SVgObj *pVgroup, SChildTableObj *pTable) { - if (pTable->sid >= 1) { - taosFreeId(pVgroup->idPool, pTable->sid); + if (pTable->tid >= 1) { + taosFreeId(pVgroup->idPool, pTable->tid); pVgroup->numOfTables--; // The create vgroup message may be received later than the create table message // and the writing order in sdb is therefore uncertain diff --git a/src/mnode/src/mnodeWrite.c b/src/mnode/src/mnodeWrite.c index ab3cfa2dad179628a9ee74d578ff0d4d06ead127..d021745d2b754c21e422f87438d18539a15fd908 100644 --- a/src/mnode/src/mnodeWrite.c +++ b/src/mnode/src/mnodeWrite.c @@ -54,11 +54,17 @@ int32_t mnodeProcessWrite(SMnodeMsg *pMsg) { rpcRsp->rsp = epSet; rpcRsp->len = sizeof(SRpcEpSet); - mDebug("app:%p:%p, msg:%s will be redireced inUse:%d", pMsg->rpcMsg.ahandle, pMsg, taosMsg[pMsg->rpcMsg.msgType], - epSet->inUse); + mDebug("app:%p:%p, msg:%s in write queue, will be redirected, numOfEps:%d inUse:%d", pMsg->rpcMsg.ahandle, pMsg, + taosMsg[pMsg->rpcMsg.msgType], epSet->numOfEps, epSet->inUse); for (int32_t i = 0; i < epSet->numOfEps; ++i) { - mDebug("app:%p:%p, mnode index:%d ep:%s:%d", pMsg->rpcMsg.ahandle, pMsg, i, epSet->fqdn[i], - htons(epSet->port[i])); + if (strcmp(epSet->fqdn[i], tsLocalFqdn) == 0 && htons(epSet->port[i]) == tsServerPort) { + epSet->inUse = (i + 1) % epSet->numOfEps; + mDebug("app:%p:%p, mnode index:%d ep:%s:%d, set inUse to %d", pMsg->rpcMsg.ahandle, pMsg, i, epSet->fqdn[i], + htons(epSet->port[i]), epSet->inUse); + } else { + mDebug("app:%p:%p, mnode index:%d ep:%s:%d", pMsg->rpcMsg.ahandle, pMsg, i, epSet->fqdn[i], + htons(epSet->port[i])); + } } return TSDB_CODE_RPC_REDIRECT; diff --git a/src/os/inc/os.h b/src/os/inc/os.h index d4b71173a07fe2c36ee1479bc94bbf274b8dd6b6..86e16db8b1446308060945d3a7db2531287c62ec 100644 --- a/src/os/inc/os.h +++ b/src/os/inc/os.h @@ -24,10 +24,14 @@ extern "C" { #include "osDarwin.h" #endif -#ifdef _TD_ARM_64_ +#ifdef _TD_ARM_64 #include "osArm64.h" #endif +#ifdef _TD_ARM_32 +#include "osArm32.h" +#endif + #ifdef _TD_LINUX_64 #include "osLinux64.h" #endif @@ -40,7 +44,7 @@ extern "C" { #include "osAlpine.h" #endif -#ifdef _TD_NINGSI_60_ +#ifdef _TD_NINGSI_60 #include "osNingsi.h" #endif diff --git a/src/os/inc/osArm32.h b/src/os/inc/osArm32.h new file mode 100644 index 0000000000000000000000000000000000000000..17b4d2dbd53fbc516900bf9aa2db69e7f44dace0 --- /dev/null +++ b/src/os/inc/osArm32.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_OS_ARM32_H +#define TDENGINE_OS_ARM32_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TAOS_OS_FUNC_LZ4 + #define BUILDIN_CLZL(val) __builtin_clzll(val) + #define BUILDIN_CTZL(val) __builtin_ctzll(val) + #define BUILDIN_CLZ(val) __builtin_clz(val) + #define BUILDIN_CTZ(val) __builtin_ctz(val) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/os/inc/osDef.h b/src/os/inc/osDef.h index 81c70a58fdf01e405d2e665b5a017a4696d76e91..d718bef6da42f59c5ee4ea7bfaad098b47062984 100644 --- a/src/os/inc/osDef.h +++ b/src/os/inc/osDef.h @@ -27,7 +27,7 @@ extern "C" { #define FD_VALID(x) ((x) > STDERR_FILENO) #define FD_INITIALIZER ((int32_t)-1) -#define WCHAR wchar_t +// #define WCHAR wchar_t #define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b))) #define POINTER_DISTANCE(p1, p2) ((char *)(p1) - (char *)(p2)) diff --git a/src/os/inc/osDir.h b/src/os/inc/osDir.h index 17683743e3ee7ed11350c02e504cce9f379b73d9..67cfdb3b530a7db17b834a1443d681e1cd5361a7 100644 --- a/src/os/inc/osDir.h +++ b/src/os/inc/osDir.h @@ -20,11 +20,14 @@ extern "C" { #endif +#include + // TAOS_OS_FUNC_DIR void taosRemoveDir(char *rootDir); int taosMkDir(const char *pathname, mode_t mode); void taosRename(char* oldName, char *newName); void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays); +int32_t taosCompressFile(char *srcFileName, char *destFileName); #ifdef __cplusplus } diff --git a/src/os/inc/osNingsi.h b/src/os/inc/osNingsi.h index da7f796b595cf9303d6e178da46368f552030edd..d88d2797455e5c3357bee81cdf9414146a38cd08 100644 --- a/src/os/inc/osNingsi.h +++ b/src/os/inc/osNingsi.h @@ -129,8 +129,6 @@ void* atomic_exchange_ptr_impl( void **ptr, void *val ); #define atomic_fetch_xor_64(ptr, val) __sync_fetch_and_xor((ptr), (val)) #define atomic_fetch_xor_ptr(ptr, val) __sync_fetch_and_xor((ptr), (val)) - - #ifdef __cplusplus } #endif diff --git a/src/os/inc/osSemphone.h b/src/os/inc/osSemphone.h index 4280b458a65b23b3aa680c6ed46f61beb5c48948..a71e74e97f4d9910414a5e801b89a1968d1df050 100644 --- a/src/os/inc/osSemphone.h +++ b/src/os/inc/osSemphone.h @@ -33,6 +33,8 @@ bool taosCheckPthreadValid(pthread_t thread); int64_t taosGetPthreadId(); void taosResetPthread(pthread_t *thread); bool taosComparePthread(pthread_t first, pthread_t second); +int32_t taosGetPId(); +int32_t taosGetCurrentAPPName(char *name, int32_t* len); #ifdef __cplusplus } diff --git a/src/os/inc/osTime.h b/src/os/inc/osTime.h index 99f7586f721acbc64b1c9e3e70bf2e33a6092fc8..6b209219c6c736ed95c69659a78d14037987be00 100644 --- a/src/os/inc/osTime.h +++ b/src/os/inc/osTime.h @@ -63,9 +63,10 @@ static FORCE_INLINE int64_t taosGetTimestamp(int32_t precision) { typedef struct SInterval { - char intervalUnit; - char slidingUnit; - char offsetUnit; + int32_t tz; // query client timezone + char intervalUnit; + char slidingUnit; + char offsetUnit; int64_t interval; int64_t sliding; int64_t offset; diff --git a/src/os/inc/osWindows.h b/src/os/inc/osWindows.h index d4f3d6d2afd94bcfd2527af9927bf188ba4bf0de..dc1da35037dc06c258856a1a143146492eeed0e5 100644 --- a/src/os/inc/osWindows.h +++ b/src/os/inc/osWindows.h @@ -51,8 +51,6 @@ extern "C" { #endif -#define TAOS_OS_FUNC_ATOMIC - #define TAOS_OS_FUNC_LZ4 int32_t BUILDIN_CLZL(uint64_t val); int32_t BUILDIN_CLZ(uint32_t val); @@ -351,4 +349,4 @@ void wordfree(wordexp_t *pwordexp); #ifdef __cplusplus } #endif -#endif \ No newline at end of file +#endif diff --git a/src/os/src/detail/CMakeLists.txt b/src/os/src/detail/CMakeLists.txt index 9f710e3ddffbe9342857cc3e92348f70c586f86e..0d5c130d6eddce07b967e3fe15762f01d6e1e97b 100644 --- a/src/os/src/detail/CMakeLists.txt +++ b/src/os/src/detail/CMakeLists.txt @@ -2,9 +2,14 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) INCLUDE_DIRECTORIES(.) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/zlib-1.2.11/inc) AUX_SOURCE_DIRECTORY(. SRC) SET_SOURCE_FILES_PROPERTIES(osSysinfo.c PROPERTIES COMPILE_FLAGS -w) SET_SOURCE_FILES_PROPERTIES(osCoredump.c PROPERTIES COMPILE_FLAGS -w) ADD_LIBRARY(osdetail ${SRC}) TARGET_LINK_LIBRARIES(osdetail os) + +IF (TD_ARM_32 OR TD_LINUX_32) + TARGET_LINK_LIBRARIES(osdetail atomic) +ENDIF () diff --git a/src/os/src/detail/osDir.c b/src/os/src/detail/osDir.c index 93651c78ef98cfbcb8bbdbb575b3fb952acab229..d3f0fda1a5c8535226eedbac6d5d88a1352e3c6e 100644 --- a/src/os/src/detail/osDir.c +++ b/src/os/src/detail/osDir.c @@ -17,6 +17,9 @@ #include "os.h" #include "tglobal.h" #include "tulog.h" +#include "zlib.h" + +#define COMPRESS_STEP_SIZE 163840 void taosRemoveDir(char *rootDir) { DIR *dir = opendir(rootDir); @@ -73,11 +76,11 @@ void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays) { if (de->d_type & DT_DIR) { continue; } else { - // struct stat fState; - // if (stat(fname, &fState) < 0) { - // continue; - // } int32_t len = (int32_t)strlen(filename); + if (len > 3 && strcmp(filename + len - 3, ".gz") == 0) { + len -= 3; + } + int64_t fileSec = 0; for (int i = len - 1; i >= 0; i--) { if (filename[i] == '.') { @@ -100,3 +103,46 @@ void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays) { closedir(dir); rmdir(rootDir); } + +int32_t taosCompressFile(char *srcFileName, char *destFileName) { + int32_t ret = 0; + int32_t len = 0; + char * data = malloc(COMPRESS_STEP_SIZE); + FILE * srcFp = NULL; + gzFile dstFp = NULL; + + srcFp = fopen(srcFileName, "r"); + if (srcFp == NULL) { + ret = -1; + goto cmp_end; + } + + int32_t fd = open(destFileName, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO); + if (fd < 0) { + ret = -2; + goto cmp_end; + } + + dstFp = gzdopen(fd, "wb6f"); + if (dstFp == NULL) { + ret = -3; + close(fd); + goto cmp_end; + } + + while (!feof(srcFp)) { + len = (int32_t)fread(data, 1, COMPRESS_STEP_SIZE, srcFp); + (void)gzwrite(dstFp, data, len); + } + +cmp_end: + if (srcFp) { + fclose(srcFp); + } + if (dstFp) { + gzclose(dstFp); + } + free(data); + + return ret; +} diff --git a/src/os/src/detail/osSemphone.c b/src/os/src/detail/osSemphone.c index b91888845edd9e98315994eaada9eca245aacb24..9eb8c18a40a11fac9ada037163011cdcf92201fb 100644 --- a/src/os/src/detail/osSemphone.c +++ b/src/os/src/detail/osSemphone.c @@ -34,5 +34,31 @@ bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; } int64_t taosGetPthreadId() { return (int64_t)pthread_self(); } void taosResetPthread(pthread_t *thread) { *thread = 0; } bool taosComparePthread(pthread_t first, pthread_t second) { return first == second; } +int32_t taosGetPId() { return getpid(); } + +int32_t taosGetCurrentAPPName(char *name, int32_t* len) { + const char* self = "/proc/self/exe"; + char path[PATH_MAX] = {0}; + + if (readlink(self, path, PATH_MAX) <= 0) { + return -1; + } + + path[PATH_MAX - 1] = 0; + char* end = strrchr(path, '/'); + if (end == NULL) { + return -1; + } + + ++end; + + strcpy(name, end); + + if (len != NULL) { + *len = strlen(name); + } + + return 0; +} #endif \ No newline at end of file diff --git a/src/os/src/detail/osSysinfo.c b/src/os/src/detail/osSysinfo.c index 83ecd8580946db628e7a785b5becca87db23118c..8df671f9c8974ecf77e5bf0943950772e3f9d192 100644 --- a/src/os/src/detail/osSysinfo.c +++ b/src/os/src/detail/osSysinfo.c @@ -203,7 +203,7 @@ static void taosGetSystemTimezone() { snprintf(tsTimezone, TSDB_TIMEZONE_LEN, "%s (%s, %s%02d00)", buf, tzname[daylight], tz >= 0 ? "+" : "-", abs(tz)); // cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT; - uInfo("timezone not configured, set to system default:%s", tsTimezone); + uWarn("timezone not configured, set to system default:%s", tsTimezone); } /* @@ -235,7 +235,7 @@ static void taosGetSystemLocale() { // get and set default locale strcpy(tsLocale, "en_US.UTF-8"); } else { tstrncpy(tsLocale, locale, TSDB_LOCALE_LEN); - uError("locale not configured, set to system default:%s", tsLocale); + uWarn("locale not configured, set to system default:%s", tsLocale); } } @@ -569,7 +569,6 @@ int taosSystem(const char *cmd) { } } -int _sysctl(struct __sysctl_args *args ); void taosSetCoreDump() { if (0 == tsEnableCoreFile) { return; diff --git a/src/os/src/detail/osTime.c b/src/os/src/detail/osTime.c index bd4dc24554b26d0b4aae2cf8e82c02ee3fbba4b9..b78627f46f2124912338f3b029b5a0fd341e729c 100644 --- a/src/os/src/detail/osTime.c +++ b/src/os/src/detail/osTime.c @@ -481,7 +481,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio start = (int64_t)(mktime(&tm) * TSDB_TICK_PER_SECOND(precision)); } else { int64_t delta = t - pInterval->interval; - int32_t factor = delta > 0 ? 1 : -1; + int32_t factor = (delta >= 0) ? 1 : -1; start = (delta / pInterval->sliding + factor) * pInterval->sliding; diff --git a/src/os/src/linux/CMakeLists.txt b/src/os/src/linux/CMakeLists.txt index 752326cc1de74550afac386ad5ac84f6d2f48990..b1a7ebf54e58bbbdeea6d5cc219904916cc2ba03 100644 --- a/src/os/src/linux/CMakeLists.txt +++ b/src/os/src/linux/CMakeLists.txt @@ -4,4 +4,4 @@ PROJECT(TDengine) AUX_SOURCE_DIRECTORY(. SRC) ADD_LIBRARY(os ${SRC}) -TARGET_LINK_LIBRARIES(os m rt) +TARGET_LINK_LIBRARIES(os m rt z) diff --git a/src/os/src/linux/ningsi.c b/src/os/src/linux/ningsi.c index 793ccac84adc05988c9fbb0b6b1d13170752c76a..2514c38ece835630c8bfbf7714868701c193d116 100644 --- a/src/os/src/linux/ningsi.c +++ b/src/os/src/linux/ningsi.c @@ -16,7 +16,7 @@ #define _DEFAULT_SOURCE #include "os.h" -#ifdef _TD_NINGSI_60_ +#ifdef _TD_NINGSI_60 void* atomic_exchange_ptr_impl(void** ptr, void* val ) { void *old; do { diff --git a/src/os/src/windows/wSemphone.c b/src/os/src/windows/wSemphone.c index ded7e418430be2674b82761771579c7b84a65007..1f723540f695e4a4609a9ec74e773a1559e7f30a 100644 --- a/src/os/src/windows/wSemphone.c +++ b/src/os/src/windows/wSemphone.c @@ -36,3 +36,21 @@ int64_t taosGetPthreadId() { bool taosComparePthread(pthread_t first, pthread_t second) { return first.p == second.p; } + +int32_t taosGetPId() { + return GetCurrentProcessId(); +} + +int32_t taosGetCurrentAPPName(char *name, int32_t* len) { + char filepath[1024] = {0}; + + GetModuleFileName(NULL, filepath, MAX_PATH); + *strrchr(filepath,'.') = '\0'; + strcpy(name, filepath); + + if (len != NULL) { + *len = (int32_t) strlen(filepath); + } + + return 0; +} \ No newline at end of file diff --git a/src/plugins/http/inc/httpInt.h b/src/plugins/http/inc/httpInt.h index 36a022159f4e8b58ca4179e9ae73d5ad7dd793d2..affc0e838ea97f25dcb2e53947ecbb7b025dffb1 100644 --- a/src/plugins/http/inc/httpInt.h +++ b/src/plugins/http/inc/httpInt.h @@ -122,9 +122,9 @@ typedef struct { } HttpDecodeMethod; typedef struct { - void (*startJsonFp)(struct HttpContext *pContext, HttpSqlCmd *cmd, void *result); + void (*startJsonFp)(struct HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result); void (*stopJsonFp)(struct HttpContext *pContext, HttpSqlCmd *cmd); - bool (*buildQueryJsonFp)(struct HttpContext *pContext, HttpSqlCmd *cmd, void *result, int numOfRows); + bool (*buildQueryJsonFp)(struct HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, int numOfRows); void (*buildAffectRowJsonFp)(struct HttpContext *pContext, HttpSqlCmd *cmd, int affectRows); void (*initJsonFp)(struct HttpContext *pContext); void (*cleanJsonFp)(struct HttpContext *pContext); @@ -148,7 +148,7 @@ typedef struct HttpContext { char ipstr[22]; char user[TSDB_USER_LEN]; // parsed from auth token or login message char pass[TSDB_PASSWORD_LEN]; - void * taos; + TAOS * taos; void * ppContext; HttpSession *session; z_stream gzipStream; diff --git a/src/plugins/http/inc/httpJson.h b/src/plugins/http/inc/httpJson.h index ac0a632137256af96de8503775e5a34fc81b1f1c..fcb74253b99c0cd8921d981e3ba7a4a027bf2b31 100644 --- a/src/plugins/http/inc/httpJson.h +++ b/src/plugins/http/inc/httpJson.h @@ -19,7 +19,7 @@ #include #include -#define JSON_BUFFER_SIZE 10240 +#define JSON_BUFFER_SIZE 16384 struct HttpContext; enum { JsonNumber, JsonString, JsonBoolean, JsonArray, JsonObject, JsonNull }; diff --git a/src/plugins/http/src/httpContext.c b/src/plugins/http/src/httpContext.c index 92388693753986b0241e03580c3d5e0518421469..ec60b984b2b0fcc72367295cef9d956165e678d5 100644 --- a/src/plugins/http/src/httpContext.c +++ b/src/plugins/http/src/httpContext.c @@ -67,7 +67,7 @@ static void httpDestroyContext(void *data) { } bool httpInitContexts() { - tsHttpServer.contextCache = taosCacheInit(TSDB_DATA_TYPE_BIGINT, 2, true, httpDestroyContext, "restc"); + tsHttpServer.contextCache = taosCacheInit(TSDB_CACHE_PTR_KEY, 2, true, httpDestroyContext, "restc"); if (tsHttpServer.contextCache == NULL) { httpError("failed to init context cache"); return false; @@ -117,8 +117,9 @@ HttpContext *httpCreateContext(int32_t fd) { pContext->state = HTTP_CONTEXT_STATE_READY; pContext->parser = httpCreateParser(pContext); - uint64_t handleVal = (uint64_t)pContext; - HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &handleVal, sizeof(int64_t), &pContext, sizeof(int64_t), 3000); + TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE)pContext; + HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &handleVal, sizeof(TSDB_CACHE_PTR_TYPE), &pContext, + sizeof(TSDB_CACHE_PTR_TYPE), 3000); pContext->ppContext = ppContext; httpDebug("context:%p, fd:%d, is created, data:%p", pContext, fd, ppContext); @@ -129,8 +130,8 @@ HttpContext *httpCreateContext(int32_t fd) { } HttpContext *httpGetContext(void *ptr) { - uint64_t handleVal = (uint64_t)ptr; - HttpContext **ppContext = taosCacheAcquireByKey(tsHttpServer.contextCache, &handleVal, sizeof(HttpContext *)); + TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE)ptr; + HttpContext **ppContext = taosCacheAcquireByKey(tsHttpServer.contextCache, &handleVal, sizeof(TSDB_CACHE_PTR_TYPE)); if (ppContext) { HttpContext *pContext = *ppContext; @@ -230,4 +231,5 @@ void httpCloseContextByServer(HttpContext *pContext) { pContext->parsed = false; httpRemoveContextFromEpoll(pContext); + httpReleaseContext(pContext, true); } diff --git a/src/plugins/http/src/httpGcJson.c b/src/plugins/http/src/httpGcJson.c index a291641dc376c6d581a137403a1ac623ce9dd5ec..2c9eca11deb51acc8cc25965b83cc686ac04c6e5 100644 --- a/src/plugins/http/src/httpGcJson.c +++ b/src/plugins/http/src/httpGcJson.c @@ -145,13 +145,13 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%d,", fields[i].name, *((int32_t *)row[i])); break; case TSDB_DATA_TYPE_BIGINT: - len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%ld", fields[i].name, *((int64_t *)row[i])); + len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%" PRId64, fields[i].name, *((int64_t *)row[i])); break; case TSDB_DATA_TYPE_FLOAT: - len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%.5f", fields[i].name, *((float *)row[i])); + len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%.5f", fields[i].name, GET_FLOAT_VAL(row[i])); break; case TSDB_DATA_TYPE_DOUBLE: - len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%.9f", fields[i].name, *((double *)row[i])); + len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%.9f", fields[i].name, GET_DOUBLE_VAL(row[i])); break; case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: @@ -210,14 +210,14 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, httpJsonInt64(jsonBuf, *((int64_t *)row[i])); break; case TSDB_DATA_TYPE_FLOAT: - httpJsonFloat(jsonBuf, *((float *)row[i])); + httpJsonFloat(jsonBuf, GET_FLOAT_VAL(row[i])); break; case TSDB_DATA_TYPE_DOUBLE: - httpJsonDouble(jsonBuf, *((double *)row[i])); + httpJsonDouble(jsonBuf, GET_DOUBLE_VAL(row[i])); break; case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: - httpJsonStringForTransMean(jsonBuf, row[i], fields[i].bytes); + httpJsonStringForTransMean(jsonBuf, (char*)row[i], fields[i].bytes); break; case TSDB_DATA_TYPE_TIMESTAMP: if (precision == TSDB_TIME_PRECISION_MILLI) { //ms diff --git a/src/plugins/http/src/httpJson.c b/src/plugins/http/src/httpJson.c index e9a8947df2650a590bc7c7cd0f12c5d6c8a4dd20..1aa6cfac4bf9414e6aa8004ca1bb120b2d40feba 100644 --- a/src/plugins/http/src/httpJson.c +++ b/src/plugins/http/src/httpJson.c @@ -52,12 +52,12 @@ int32_t httpWriteBufByFd(struct HttpContext* pContext, const char* buf, int32_t } if (len < 0) { - httpDebug("context:%p, fd:%d, socket write errno:%d, times:%d", pContext, pContext->fd, errno, countWait); + httpDebug("context:%p, fd:%d, socket write errno:%d:%s, times:%d", pContext, pContext->fd, errno, strerror(errno), countWait); if (++countWait > HTTP_WRITE_RETRY_TIMES) break; taosMsleep(HTTP_WRITE_WAIT_TIME_MS); continue; } else if (len == 0) { - httpDebug("context:%p, fd:%d, socket write errno:%d, connect already closed", pContext, pContext->fd, errno); + httpDebug("context:%p, fd:%d, socket write errno:%d:%s, connect already closed", pContext, pContext->fd, errno, strerror(errno)); break; } else { countWait = 0; @@ -113,7 +113,7 @@ int32_t httpWriteJsonBufBody(JsonBuf* buf, bool isTheLast) { httpTrace("context:%p, fd:%d, no data need dump", buf->pContext, buf->pContext->fd); return 0; // there is no data to dump. } else { - int32_t len = sprintf(sLen, "%lx\r\n", srcLen); + int32_t len = sprintf(sLen, "%" PRIx64 "\r\n", srcLen); httpTrace("context:%p, fd:%d, write body, chunkSize:%" PRIu64 ", response:\n%s", buf->pContext, buf->pContext->fd, srcLen, buf->buf); httpWriteBufNoTrace(buf->pContext, sLen, len); @@ -131,14 +131,14 @@ int32_t httpWriteJsonBufBody(JsonBuf* buf, bool isTheLast) { httpWriteBufNoTrace(buf->pContext, sLen, len); remain = httpWriteBufNoTrace(buf->pContext, (const char*)compressBuf, compressBufLen); } else { - httpTrace("context:%p, fd:%d, last:%d, compress already dumped, response:\n%s", buf->pContext, + httpDebug("context:%p, fd:%d, last:%d, compress already dumped, response:\n%s", buf->pContext, buf->pContext->fd, isTheLast, buf->buf); - return 0; // there is no data to dump. + remain = 0; // there is no data to dump. } } else { httpError("context:%p, fd:%d, failed to compress data, chunkSize:%" PRIu64 ", last:%d, error:%d, response:\n%s", buf->pContext, buf->pContext->fd, srcLen, isTheLast, ret, buf->buf); - return 0; + remain = 0; } } @@ -267,9 +267,9 @@ void httpJsonTimestamp(JsonBuf* buf, int64_t t, bool us) { ptm = localtime(&tt); int32_t length = (int32_t) strftime(ts, 35, "%Y-%m-%d %H:%M:%S", ptm); if (us) { - length += snprintf(ts + length, 8, ".%06ld", t % precision); + length += snprintf(ts + length, 8, ".%06" PRId64, t % precision); } else { - length += snprintf(ts + length, 5, ".%03ld", t % precision); + length += snprintf(ts + length, 5, ".%03" PRId64, t % precision); } httpJsonString(buf, ts, length); @@ -287,9 +287,9 @@ void httpJsonUtcTimestamp(JsonBuf* buf, int64_t t, bool us) { ptm = localtime(&tt); int32_t length = (int32_t)strftime(ts, 40, "%Y-%m-%dT%H:%M:%S", ptm); if (us) { - length += snprintf(ts + length, 8, ".%06ld", t % precision); + length += snprintf(ts + length, 8, ".%06" PRId64, t % precision); } else { - length += snprintf(ts + length, 5, ".%03ld", t % precision); + length += snprintf(ts + length, 5, ".%03" PRId64, t % precision); } length += (int32_t)strftime(ts + length, 40 - length, "%z", ptm); diff --git a/src/plugins/http/src/httpParser.c b/src/plugins/http/src/httpParser.c index 0c3204687a3fa92fb71d8da2551bb4c10a7a4097..b84483453736aac7693c9ec671ec5a27c4178072 100644 --- a/src/plugins/http/src/httpParser.c +++ b/src/plugins/http/src/httpParser.c @@ -153,10 +153,10 @@ static int32_t httpOnRequestLine(HttpParser *pParser, char *method, char *target for (int32_t i = 0; i < HTTP_MAX_URL; i++) { char *pSeek = strchr(pStart, '/'); if (pSeek == NULL) { - httpAppendString(pParser->path + i, pStart, strlen(pStart)); + (void)httpAppendString(pParser->path + i, pStart, strlen(pStart)); break; } else { - httpAppendString(pParser->path + i, pStart, (int32_t)(pSeek - pStart)); + (void)httpAppendString(pParser->path + i, pStart, (int32_t)(pSeek - pStart)); } pStart = pSeek + 1; } @@ -485,11 +485,11 @@ void httpClearParser(HttpParser *parser) { } void httpDestroyParser(HttpParser *parser) { + if (!parser) return; + HttpContext *pContext = parser->pContext; httpTrace("context:%p, fd:%d, destroy parser", pContext, pContext->fd); - if (!parser) return; - free(parser->method); parser->method = NULL; free(parser->target); parser->target = NULL; free(parser->version); parser->version = NULL; @@ -684,23 +684,28 @@ static int32_t httpParserOnVersion(HttpParser *parser, HTTP_PARSER_STATE state, break; } - if (c!='0' && c!='1') { + if (c != '0' && c != '1' && c != '2') { httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c); ok = -1; httpOnError(parser, 400, TSDB_CODE_HTTP_PARSE_VERSION_FAILED); break; } + if (httpAppendString(&parser->str, &c, 1)) { httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); ok = -1; httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_VERSION_FAILED); break; } - - if (c == '0') parser->httpVersion = HTTP_VERSION_10; - else if (c == '1') parser->httpVersion = HTTP_VERSION_11; - else if (c == '2') parser->httpVersion = HTTP_VERSION_12; - else parser->httpVersion = HTTP_INVALID_VERSION; + + if (c == '0') + parser->httpVersion = HTTP_VERSION_10; + else if (c == '1') + parser->httpVersion = HTTP_VERSION_11; + else if (c == '2') + parser->httpVersion = HTTP_VERSION_12; + else { + } parser->version = strdup(parser->str.str); if (!parser->version) { diff --git a/src/plugins/http/src/httpQueue.c b/src/plugins/http/src/httpQueue.c index 86a97a6abe251e1fa99219b9fb63a525ba89f7d4..43a8ddbd1a0d207addf0576951b2af9b2be16555 100644 --- a/src/plugins/http/src/httpQueue.c +++ b/src/plugins/http/src/httpQueue.c @@ -67,7 +67,7 @@ static void *httpProcessResultQueue(void *param) { while (1) { if (taosReadQitemFromQset(tsHttpQset, &type, (void **)&pMsg, &unUsed) == 0) { - httpDebug("httpResultQueue: got no message from qset, exiting..."); + httpDebug("qset:%p, http queue got no message from qset, exiting", tsHttpQset); break; } diff --git a/src/plugins/http/src/httpRestJson.c b/src/plugins/http/src/httpRestJson.c index f8912331a367d2f5fe0e5b659bd6b4a4ad1f43ae..a5b156bffc23ea3cdb042f456a327895fc0bdaa6 100644 --- a/src/plugins/http/src/httpRestJson.c +++ b/src/plugins/http/src/httpRestJson.c @@ -124,14 +124,14 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, httpJsonInt64(jsonBuf, *((int64_t *)row[i])); break; case TSDB_DATA_TYPE_FLOAT: - httpJsonFloat(jsonBuf, *((float *)row[i])); + httpJsonFloat(jsonBuf, GET_FLOAT_VAL(row[i])); break; case TSDB_DATA_TYPE_DOUBLE: - httpJsonDouble(jsonBuf, *((double *)row[i])); + httpJsonDouble(jsonBuf, GET_DOUBLE_VAL(row[i])); break; case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: - httpJsonStringForTransMean(jsonBuf, row[i], length[i]); + httpJsonStringForTransMean(jsonBuf, (char*)row[i], length[i]); break; case TSDB_DATA_TYPE_TIMESTAMP: if (timestampFormat == REST_TIMESTAMP_FMT_LOCAL_STRING) { @@ -195,4 +195,4 @@ void restStopSqlJson(HttpContext *pContext, HttpSqlCmd *cmd) { httpJsonToken(jsonBuf, JsonObjEnd); httpWriteJsonBufEnd(jsonBuf); -} \ No newline at end of file +} diff --git a/src/plugins/http/src/httpSql.c b/src/plugins/http/src/httpSql.c index 881fa55fb7b1b37901930775d9d67012e3debe18..70d644146cf5ebe15a42c8f00a2e6e4bd603d081 100644 --- a/src/plugins/http/src/httpSql.c +++ b/src/plugins/http/src/httpSql.c @@ -27,8 +27,6 @@ #include "httpSession.h" #include "httpQueue.h" -void *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int), - void *param, void **taos); void httpProcessMultiSql(HttpContext *pContext); void httpProcessMultiSqlRetrieveCallBack(void *param, TAOS_RES *result, int numOfRows); @@ -257,20 +255,20 @@ void httpProcessSingleSqlCallBackImp(void *param, TAOS_RES *result, int unUsedCo HttpEncodeMethod *encode = pContext->encodeMethod; if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { - httpError("context:%p, fd:%d, user:%s, query error, taos:%p, code:%s:inprogress, sqlObj:%p", pContext, pContext->fd, - pContext->user, pContext->session->taos, tstrerror(code), (SSqlObj *)result); + httpError("context:%p, fd:%d, user:%s, query error, code:%s:inprogress, sqlObj:%p", pContext, pContext->fd, + pContext->user, tstrerror(code), (SSqlObj *)result); return; } if (code < 0) { SSqlObj *pObj = (SSqlObj *)result; if (code == TSDB_CODE_TSC_INVALID_SQL) { - httpError("context:%p, fd:%d, user:%s, query error, taos:%p, code:%s, sqlObj:%p, error:%s", pContext, - pContext->fd, pContext->user, pContext->session->taos, tstrerror(code), pObj, pObj->cmd.payload); + httpError("context:%p, fd:%d, user:%s, query error, code:%s, sqlObj:%p, error:%s", pContext, + pContext->fd, pContext->user, tstrerror(code), pObj, pObj->cmd.payload); httpSendTaosdInvalidSqlErrorResp(pContext, pObj->cmd.payload); } else { - httpError("context:%p, fd:%d, user:%s, query error, taos:%p, code:%s, sqlObj:%p", pContext, pContext->fd, - pContext->user, pContext->session->taos, tstrerror(code), pObj); + httpError("context:%p, fd:%d, user:%s, query error, code:%s, sqlObj:%p", pContext, pContext->fd, + pContext->user, tstrerror(code), pObj); httpSendErrorResp(pContext, code); } taos_free_result(result); diff --git a/src/plugins/http/src/httpUtil.c b/src/plugins/http/src/httpUtil.c index 2c8879f8804828fdd9de268ab1b6348df3a6b77c..39168ee96dc0ef83dc329614f63543d2c6c7fdfa 100644 --- a/src/plugins/http/src/httpUtil.c +++ b/src/plugins/http/src/httpUtil.c @@ -406,15 +406,21 @@ int32_t httpGzipCompressInit(HttpContext *pContext) { int32_t httpGzipCompress(HttpContext *pContext, char *srcData, int32_t nSrcData, char *destData, int32_t *nDestData, bool isTheLast) { int32_t err = 0; + int32_t lastTotalLen = (int32_t) (pContext->gzipStream.total_out); pContext->gzipStream.next_in = (Bytef *) srcData; pContext->gzipStream.avail_in = (uLong) nSrcData; pContext->gzipStream.next_out = (Bytef *) destData; pContext->gzipStream.avail_out = (uLong) (*nDestData); - while (pContext->gzipStream.avail_in != 0 && pContext->gzipStream.total_out < (uLong) (*nDestData)) { + while (pContext->gzipStream.avail_in != 0) { if (deflate(&pContext->gzipStream, Z_FULL_FLUSH) != Z_OK) { return -1; } + + int32_t cacheLen = pContext->gzipStream.total_out - lastTotalLen; + if (cacheLen >= *nDestData) { + return -2; + } } if (pContext->gzipStream.avail_in != 0) { @@ -427,16 +433,16 @@ int32_t httpGzipCompress(HttpContext *pContext, char *srcData, int32_t nSrcData, break; } if (err != Z_OK) { - return -2; + return -3; } } if (deflateEnd(&pContext->gzipStream) != Z_OK) { - return -3; + return -4; } } - *nDestData = (int32_t) (pContext->gzipStream.total_out); + *nDestData = (int32_t) (pContext->gzipStream.total_out) - lastTotalLen; return 0; } diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index 5d570821cb6608fb382398e146766eb1f8aff284..f392644e6736f528fa75f21ee2857c570c0c22c9 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -185,11 +185,18 @@ enum { QUERY_RESULT_READY = 2, }; +typedef struct SMemRef { + int32_t ref; + void *mem; + void *imem; +} SMemRef; + typedef struct SQInfo { void* signature; int32_t code; // error code to returned to client int64_t owner; // if it is in execution void* tsdb; + SMemRef memRef; int32_t vgId; STableGroupInfo tableGroupInfo; // table list SArray STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray structure @@ -206,6 +213,7 @@ typedef struct SQInfo { void* pBuf; // allocated buffer for STableQueryInfo, sizeof(STableQueryInfo)*numOfTables; pthread_mutex_t lock; // used to synchronize the rsp/query threads + tsem_t ready; int32_t dataReady; // denote if query result is ready or not void* rspContext; // response context } SQInfo; diff --git a/src/query/inc/qExtbuffer.h b/src/query/inc/qExtbuffer.h index 0bdcf5c45ef6d9ce283d36ccd9d7b6296fc67472..df6e64ddd85c4ec6be693f262ea561ee23f3bf0b 100644 --- a/src/query/inc/qExtbuffer.h +++ b/src/query/inc/qExtbuffer.h @@ -89,7 +89,7 @@ typedef struct SColumnModel { typedef struct SColumnOrderInfo { int32_t numOfCols; - int16_t pData[]; + int16_t colIndex[]; } SColumnOrderInfo; typedef struct tOrderDescriptor { diff --git a/src/query/inc/qResultbuf.h b/src/query/inc/qResultbuf.h index 5303251d981f9e12bb92088b65cf6231d6e45f88..704df9f3f29cc0653c353ed194e02e72cb4c5fb2 100644 --- a/src/query/inc/qResultbuf.h +++ b/src/query/inc/qResultbuf.h @@ -73,12 +73,11 @@ typedef struct SDiskbasedResultBuf { bool comp; // compressed before flushed to disk int32_t nextPos; // next page flush position - const void* handle; // for debug purpose + const void* handle; // for debug purpose SResultBufStatis statis; } SDiskbasedResultBuf; -#define DEFAULT_INTERN_BUF_PAGE_SIZE (4096L) -#define DEFAULT_INMEM_BUF_PAGES 10 +#define DEFAULT_INTERN_BUF_PAGE_SIZE (256L) // in bytes #define PAGE_INFO_INITIALIZER (SPageDiskInfo){-1, -1} /** diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h index d6664577a377bb619db2f0bab04471642aa10e20..bc8f9a5e23df72f82bcb3bb5140bec42fe426268 100644 --- a/src/query/inc/qSqlparser.h +++ b/src/query/inc/qSqlparser.h @@ -276,8 +276,6 @@ tSQLExpr *tSQLExprNodeClone(tSQLExpr *pExpr); SAlterTableSQL *tAlterTableSQLElems(SStrToken *pMeterName, tFieldList *pCols, tVariantList *pVals, int32_t type); -tSQLExprListList *tSQLListListAppend(tSQLExprListList *pList, tSQLExprList *pExprList); - void destroyAllSelectClause(SSubclauseInfo *pSql); void doDestroyQuerySql(SQuerySQL *pSql); diff --git a/src/query/inc/qTsbuf.h b/src/query/inc/qTsbuf.h index 46e6f79014f32c9b3052824bdb702556f5c4f060..6c2a955f47577a0da19f6520b2addc44e66b73ba 100644 --- a/src/query/inc/qTsbuf.h +++ b/src/query/inc/qTsbuf.h @@ -35,16 +35,9 @@ typedef struct STSList { int32_t len; } STSList; -typedef struct STSRawBlock { - int32_t vnode; - int64_t tag; - TSKEY* ts; - int32_t len; -} STSRawBlock; - typedef struct STSElem { TSKEY ts; - tVariant tag; + tVariant* tag; int32_t vnode; } STSElem; @@ -84,6 +77,7 @@ typedef struct STSBuf { char path[PATH_MAX]; uint32_t fileSize; + // todo use array STSVnodeBlockInfoEx* pData; uint32_t numOfAlloc; uint32_t numOfVnodes; @@ -106,12 +100,12 @@ typedef struct STSBufFileHeader { STSBuf* tsBufCreate(bool autoDelete, int32_t order); STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete); -STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_t len, int32_t tsOrder); +STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_t len, int32_t tsOrder, int32_t vnodeId); void* tsBufDestroy(STSBuf* pTSBuf); void tsBufAppend(STSBuf* pTSBuf, int32_t vnodeId, tVariant* tag, const char* pData, int32_t len); -int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf, int32_t vnodeIdx); +int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf); STSBuf* tsBufClone(STSBuf* pTSBuf); @@ -121,6 +115,7 @@ void tsBufFlush(STSBuf* pTSBuf); void tsBufResetPos(STSBuf* pTSBuf); STSElem tsBufGetElem(STSBuf* pTSBuf); + bool tsBufNextPos(STSBuf* pTSBuf); STSElem tsBufGetElemStartPos(STSBuf* pTSBuf, int32_t vnodeId, tVariant* tag); @@ -136,6 +131,10 @@ void tsBufSetCursor(STSBuf* pTSBuf, STSCursor* pCur); */ void tsBufDisplay(STSBuf* pTSBuf); +int32_t tsBufGetNumOfVnodes(STSBuf* pTSBuf); + +void tsBufGetVnodeIdList(STSBuf* pTSBuf, int32_t* num, int32_t** vnodeId); + #ifdef __cplusplus } #endif diff --git a/src/query/inc/qUtil.h b/src/query/inc/qUtil.h index 314159484d0de1d161cdf183534a0bc1820fa90e..5320e5622e70a93c06edb4a1e5a3fe568498ef21 100644 --- a/src/query/inc/qUtil.h +++ b/src/query/inc/qUtil.h @@ -39,7 +39,6 @@ static FORCE_INLINE SWindowResult *getWindowResult(SWindowResInfo *pWindowResInf } #define curTimeWindowIndex(_winres) ((_winres)->curIndex) -#define GET_TIMEWINDOW(_winresInfo, _win) (STimeWindow) {(_win)->skey, ((_win)->skey + (_winresInfo)->interval - 1)} #define GET_ROW_PARAM_FOR_MULTIOUTPUT(_q, tbq, sq) (((tbq) && (!sq))? (_q)->pSelectExpr[1].base.arg->argValue.i64:1) bool isWindowResClosed(SWindowResInfo *pWindowResInfo, int32_t slot); diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 8a5b9d61e2e06768622eedc45b7bd02d3cb14c70..e5d1185330a47b79fec1becd74a01ed779db8c80 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -80,6 +80,7 @@ cmd ::= SHOW GRANTS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_GRANTS, 0, 0); cmd ::= SHOW VNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, 0, 0); } cmd ::= SHOW VNODES IPTOKEN(X). { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, &X, 0); } + %type dbPrefix {SStrToken} dbPrefix(A) ::=. {A.n = 0; A.type = 0;} dbPrefix(A) ::= ids(X) DOT. {A = X; } @@ -88,6 +89,15 @@ dbPrefix(A) ::= ids(X) DOT. {A = X; } cpxName(A) ::= . {A.n = 0; } cpxName(A) ::= DOT ids(Y). {A = Y; A.n += 1; } +cmd ::= SHOW CREATE TABLE ids(X) cpxName(Y). { + X.n += Y.n; + setDCLSQLElems(pInfo, TSDB_SQL_SHOW_CREATE_TABLE, 1, &X); +} + +cmd ::= SHOW CREATE DATABASE ids(X). { + setDCLSQLElems(pInfo, TSDB_SQL_SHOW_CREATE_DATABASE, 1, &X); +} + cmd ::= SHOW dbPrefix(X) TABLES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_TABLE, &X, 0); } diff --git a/src/query/src/qAst.c b/src/query/src/qAst.c index 63411aaf3f9085d3912b923ac419cd1552239583..893105e44ac4eb82843514cda20928d3e0dcdaf9 100644 --- a/src/query/src/qAst.c +++ b/src/query/src/qAst.c @@ -646,9 +646,7 @@ static bool filterItem(tExprNode *pExpr, const void *pItem, SExprTraverseSupp *p } // handle the leaf node - assert(pLeft->nodeType == TSQL_NODE_COL && pRight->nodeType == TSQL_NODE_VALUE); param->setupInfoFn(pExpr, param->pExtInfo); - return param->nodeFilterFn(pItem, pExpr->_node.info); } @@ -769,6 +767,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S assert(taosArrayGetSize(result) == 0); tSQLBinaryTraverseOnSkipList(pExpr, result, pSkipList, param); } + return; } diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index a12833eb3d10b0c28742efe35e3eedde0ccae14f..3df319a5c26840a38628632248da7aef33f61956 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -184,16 +184,18 @@ static void resetMergeResultBuf(SQuery *pQuery, SQLFunctionCtx *pCtx, SResultInf static bool functionNeedToExecute(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx *pCtx, int32_t functionId); static void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, TSKEY *tsCol, SDataBlockInfo* pBlockInfo, - SDataStatis *pStatis, void *param, int32_t colIndex); + SDataStatis *pStatis, void *param, int32_t colIndex, int32_t vgId); static void initCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv); -static void destroyTableQueryInfo(STableQueryInfo *pTableQueryInfo); +static void destroyTableQueryInfoImpl(STableQueryInfo *pTableQueryInfo); static void resetCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv); static bool hasMainOutput(SQuery *pQuery); static void buildTagQueryResult(SQInfo *pQInfo); static int32_t setAdditionalInfo(SQInfo *pQInfo, void *pTable, STableQueryInfo *pTableQueryInfo); static int32_t flushFromResultBuf(SQueryRuntimeEnv* pRuntimeEnv, SGroupResInfo* pGroupResInfo); +static int32_t checkForQueryBuf(size_t numOfTables); +static void releaseQueryBuf(size_t numOfTables); bool doFilterData(SQuery *pQuery, int32_t elemPos) { for (int32_t k = 0; k < pQuery->numOfFilterCols; ++k) { @@ -1005,9 +1007,10 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis * longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } + SQInfo* pQInfo = GET_QINFO_ADDR(pRuntimeEnv); for (int32_t k = 0; k < pQuery->numOfOutput; ++k) { char *dataBlock = getDataBlock(pRuntimeEnv, &sasArray[k], k, pDataBlockInfo->rows, pDataBlock); - setExecParams(pQuery, &pCtx[k], dataBlock, tsCols, pDataBlockInfo, pStatis, &sasArray[k], k); + setExecParams(pQuery, &pCtx[k], dataBlock, tsCols, pDataBlockInfo, pStatis, &sasArray[k], k, pQInfo->vgId); } int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); @@ -1200,7 +1203,7 @@ static int32_t doTSJoinFilter(SQueryRuntimeEnv *pRuntimeEnv, int32_t offset) { SQLFunctionCtx *pCtx = pRuntimeEnv->pCtx; // compare tag first - if (tVariantCompare(&pCtx[0].tag, &elem.tag) != 0) { + if (tVariantCompare(&pCtx[0].tag, elem.tag) != 0) { return TS_JOIN_TAG_NOT_EQUALS; } @@ -1286,9 +1289,10 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS groupbyColumnData = getGroupbyColumnData(pQuery, &type, &bytes, pDataBlock); } + SQInfo* pQInfo = GET_QINFO_ADDR(pRuntimeEnv); for (int32_t k = 0; k < pQuery->numOfOutput; ++k) { char *dataBlock = getDataBlock(pRuntimeEnv, &sasArray[k], k, pDataBlockInfo->rows, pDataBlock); - setExecParams(pQuery, &pCtx[k], dataBlock, tsCols, pDataBlockInfo, pStatis, &sasArray[k], k); + setExecParams(pQuery, &pCtx[k], dataBlock, tsCols, pDataBlockInfo, pStatis, &sasArray[k], k, pQInfo->vgId); } // set the input column data @@ -1303,7 +1307,6 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS // from top to bottom in desc // from bottom to top in asc order if (pRuntimeEnv->pTSBuf != NULL) { - SQInfo *pQInfo = (SQInfo *)GET_QINFO_ADDR(pRuntimeEnv); qDebug("QInfo:%p process data rows, numOfRows:%d, query order:%d, ts comp order:%d", pQInfo, pDataBlockInfo->rows, pQuery->order.order, pRuntimeEnv->pTSBuf->cur.order); } @@ -1409,6 +1412,10 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS item->lastKey = (QUERY_IS_ASC_QUERY(pQuery)? pDataBlockInfo->window.ekey:pDataBlockInfo->window.skey) + step; } + if (pRuntimeEnv->pTSBuf != NULL) { + item->cur = tsBufGetCursor(pRuntimeEnv->pTSBuf); + } + // todo refactor: extract method for(int32_t i = 0; i < pQuery->numOfOutput; ++i) { if (pQuery->pSelectExpr[i].base.functionId != TSDB_FUNC_ARITHM) { @@ -1469,7 +1476,7 @@ static int32_t tableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBl } void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, TSKEY *tsCol, SDataBlockInfo* pBlockInfo, - SDataStatis *pStatis, void *param, int32_t colIndex) { + SDataStatis *pStatis, void *param, int32_t colIndex, int32_t vgId) { int32_t functionId = pQuery->pSelectExpr[colIndex].base.functionId; int32_t colId = pQuery->pSelectExpr[colIndex].base.colInfo.colId; @@ -1537,9 +1544,14 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, TSKEY if (isNull((const char*) &pQuery->fillVal[colIndex], pCtx->inputType)) { pCtx->param[1].nType = TSDB_DATA_TYPE_NULL; } else { // todo refactor, tVariantCreateFromBinary should handle the NULL value - tVariantCreateFromBinary(&pCtx->param[1], (char*) &pQuery->fillVal[colIndex], pCtx->inputBytes, pCtx->inputType); + if (pCtx->inputType != TSDB_DATA_TYPE_BINARY && pCtx->inputType != TSDB_DATA_TYPE_NCHAR) { + tVariantCreateFromBinary(&pCtx->param[1], (char*) &pQuery->fillVal[colIndex], pCtx->inputBytes, pCtx->inputType); + } } } + } else if (functionId == TSDB_FUNC_TS_COMP) { + pCtx->param[0].i64Key = vgId; + pCtx->param[0].nType = TSDB_DATA_TYPE_BIGINT; } #if defined(_DEBUG_VIEW) @@ -1983,8 +1995,7 @@ static void changeExecuteScanOrder(SQInfo *pQInfo, SQueryTableMsg* pQueryMsg, bo // todo handle the case the the order irrelevant query type mixed up with order critical query type // descending order query for last_row query if (isFirstLastRowQuery(pQuery)) { - qDebug("QInfo:%p scan order changed for last_row query, old:%d, new:%d", GET_QINFO_ADDR(pQuery), - pQuery->order.order, TSDB_ORDER_ASC); + qDebug("QInfo:%p scan order changed for last_row query, old:%d, new:%d", pQInfo, pQuery->order.order, TSDB_ORDER_ASC); pQuery->order.order = TSDB_ORDER_ASC; if (pQuery->window.skey > pQuery->window.ekey) { @@ -2086,13 +2097,14 @@ static int32_t getInitialPageNum(SQInfo *pQInfo) { static void getIntermediateBufInfo(SQueryRuntimeEnv* pRuntimeEnv, int32_t* ps, int32_t* rowsize) { SQuery* pQuery = pRuntimeEnv->pQuery; + int32_t MIN_ROWS_PER_PAGE = 4; *rowsize = (int32_t)(pQuery->rowSize * GET_ROW_PARAM_FOR_MULTIOUTPUT(pQuery, pRuntimeEnv->topBotQuery, pRuntimeEnv->stableQuery)); int32_t overhead = sizeof(tFilePage); // one page contains at least two rows *ps = DEFAULT_INTERN_BUF_PAGE_SIZE; - while(((*rowsize) * 2) > (*ps) - overhead) { + while(((*rowsize) * MIN_ROWS_PER_PAGE) > (*ps) - overhead) { *ps = (*ps << 1u); } @@ -2120,7 +2132,7 @@ static bool needToLoadDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis *pDat } } - // no statistics data + // no statistics data, load the true data block if (index == -1) { return true; } @@ -2130,8 +2142,17 @@ static bool needToLoadDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis *pDat return true; } - // all points in current column are NULL, no need to check its boundary value + // all data in current column are NULL, no need to check its boundary value if (pDataStatis[index].numOfNull == numOfRows) { + + // if isNULL query exists, load the null data column + for (int32_t j = 0; j < pFilterInfo->numOfFilters; ++j) { + SColumnFilterElem *pFilterElem = &pFilterInfo->pFilters[j]; + if (pFilterElem->fp == isNull_filter) { + return true; + } + } + continue; } @@ -2216,10 +2237,11 @@ static bool overlapWithTimeWindow(SQuery* pQuery, SDataBlockInfo* pBlockInfo) { return false; } -int32_t loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, void* pQueryHandle, SDataBlockInfo* pBlockInfo, SDataStatis **pStatis, SArray** pDataBlock, uint32_t* status) { +int32_t loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, SWindowResInfo * pWindowResInfo, void* pQueryHandle, SDataBlockInfo* pBlockInfo, SDataStatis **pStatis, SArray** pDataBlock, uint32_t* status) { SQuery *pQuery = pRuntimeEnv->pQuery; - *status = 0; + *status = BLK_DATA_NO_NEEDED; + if (pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf > 0) { *status = BLK_DATA_ALL_NEEDED; } else { // check if this data block is required to load @@ -2231,12 +2253,26 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, void* pQueryHandle, } if ((*status) != BLK_DATA_ALL_NEEDED) { + // the pCtx[i] result is belonged to previous time window since the outputBuf has not been set yet, + // the filter result may be incorrect. So in case of interval query, we need to set the correct time output buffer + if (QUERY_IS_INTERVAL_QUERY(pQuery)) { + bool hasTimeWindow = false; + bool masterScan = IS_MASTER_SCAN(pRuntimeEnv); + + TSKEY k = QUERY_IS_ASC_QUERY(pQuery)? pBlockInfo->window.skey:pBlockInfo->window.ekey; + + STimeWindow win = getActiveTimeWindow(pWindowResInfo, k, pQuery); + if (setWindowOutputBufByKey(pRuntimeEnv, pWindowResInfo, pBlockInfo->tid, &win, masterScan, &hasTimeWindow) != + TSDB_CODE_SUCCESS) { + // todo handle error in set result for timewindow + } + } + for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { SSqlFuncMsg* pSqlFunc = &pQuery->pSelectExpr[i].base; int32_t functionId = pSqlFunc->functionId; int32_t colId = pSqlFunc->colInfo.colId; - (*status) |= aAggs[functionId].dataReqFunc(&pRuntimeEnv->pCtx[i], pBlockInfo->window.skey, pBlockInfo->window.ekey, colId); if (((*status) & BLK_DATA_ALL_NEEDED) == BLK_DATA_ALL_NEEDED) { break; @@ -2467,7 +2503,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { SArray * pDataBlock = NULL; uint32_t status = 0; - int32_t ret = loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis, &pDataBlock, &status); + int32_t ret = loadDataBlockOnDemand(pRuntimeEnv, &pRuntimeEnv->windowResInfo, pQueryHandle, &blockInfo, &pStatis, &pDataBlock, &status); if (ret != TSDB_CODE_SUCCESS) { break; } @@ -2599,8 +2635,13 @@ void setTagVal(SQueryRuntimeEnv *pRuntimeEnv, void *pTable, void *tsdb) { SColumnInfo* pColInfo = doGetTagColumnInfoById(pQuery->tagColList, pQuery->numOfTags, tagColId); doSetTagValueInParam(tsdb, pTable, tagColId, &pRuntimeEnv->pCtx[0].tag, pColInfo->type, pColInfo->bytes); + + if (pRuntimeEnv->pCtx[0].tag.nType == TSDB_DATA_TYPE_BINARY || pRuntimeEnv->pCtx[0].tag.nType == TSDB_DATA_TYPE_NCHAR) {} + qDebug("QInfo:%p set tag value for join comparison, colId:%" PRId64 ", val:%s", pQInfo, pExprInfo->base.arg->argValue.i64, + pRuntimeEnv->pCtx[0].tag.pz); + } else { qDebug("QInfo:%p set tag value for join comparison, colId:%" PRId64 ", val:%"PRId64, pQInfo, pExprInfo->base.arg->argValue.i64, - pRuntimeEnv->pCtx[0].tag.i64Key) + pRuntimeEnv->pCtx[0].tag.i64Key); } } } @@ -2957,11 +2998,10 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) { STableQueryInfo *item = taosArrayGetP(pGroup, i); SIDList list = getDataBufPagesIdList(pRuntimeEnv->pResultBuf, TSDB_TABLEID(item->pTable)->tid); - pageList = list; - tid = TSDB_TABLEID(item->pTable)->tid; - if (taosArrayGetSize(list) > 0 && item->windowResInfo.size > 0) { pTableList[numOfTables++] = item; + tid = TSDB_TABLEID(item->pTable)->tid; + pageList = list; } } @@ -3715,7 +3755,7 @@ static STableQueryInfo *createTableQueryInfo(SQueryRuntimeEnv *pRuntimeEnv, void return pTableQueryInfo; } -void destroyTableQueryInfo(STableQueryInfo *pTableQueryInfo) { +void destroyTableQueryInfoImpl(STableQueryInfo *pTableQueryInfo) { if (pTableQueryInfo == NULL) { return; } @@ -3835,14 +3875,40 @@ int32_t setAdditionalInfo(SQInfo *pQInfo, void* pTable, STableQueryInfo *pTableQ // both the master and supplement scan needs to set the correct ts comp start position if (pRuntimeEnv->pTSBuf != NULL) { + tVariant* pTag = &pRuntimeEnv->pCtx[0].tag; + if (pTableQueryInfo->cur.vgroupIndex == -1) { - tVariantAssign(&pTableQueryInfo->tag, &pRuntimeEnv->pCtx[0].tag); - tsBufGetElemStartPos(pRuntimeEnv->pTSBuf, 0, &pTableQueryInfo->tag); + tVariantAssign(&pTableQueryInfo->tag, pTag); + + STSElem elem = tsBufGetElemStartPos(pRuntimeEnv->pTSBuf, pQInfo->vgId, &pTableQueryInfo->tag); + + // failed to find data with the specified tag value and vnodeId + if (elem.vnode < 0) { + if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { + qError("QInfo:%p failed to find tag:%s in ts_comp", pQInfo, pTag->pz); + } else { + qError("QInfo:%p failed to find tag:%" PRId64 " in ts_comp", pQInfo, pTag->i64Key); + } + + return false; + } // keep the cursor info of current meter - pTableQueryInfo->cur = pRuntimeEnv->pTSBuf->cur; + pTableQueryInfo->cur = tsBufGetCursor(pRuntimeEnv->pTSBuf); + if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { + qDebug("QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); + } else { + qDebug("QInfo:%p find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64Key, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); + } + } else { tsBufSetCursor(pRuntimeEnv->pTSBuf, &pTableQueryInfo->cur); + + if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { + qDebug("QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); + } else { + qDebug("QInfo:%p find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64Key, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); + } } } @@ -4391,6 +4457,8 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) { return true; } +static void doDestroyTableQueryInfo(STableGroupInfo* pTableqinfoGroupInfo); + static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery) { SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; SQuery *pQuery = pQInfo->runtimeEnv.pQuery; @@ -4430,16 +4498,20 @@ static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery) // update the query time window pQuery->window = cond.twindow; - size_t numOfGroups = GET_NUM_OF_TABLEGROUP(pQInfo); - for(int32_t i = 0; i < numOfGroups; ++i) { - SArray *group = GET_TABLEGROUP(pQInfo, i); + if (pQInfo->tableGroupInfo.numOfTables == 0) { + pQInfo->tableqinfoGroupInfo.numOfTables = 0; + } else { + size_t numOfGroups = GET_NUM_OF_TABLEGROUP(pQInfo); + for(int32_t i = 0; i < numOfGroups; ++i) { + SArray *group = GET_TABLEGROUP(pQInfo, i); - size_t t = taosArrayGetSize(group); - for (int32_t j = 0; j < t; ++j) { - STableQueryInfo *pCheckInfo = taosArrayGetP(group, j); + size_t t = taosArrayGetSize(group); + for (int32_t j = 0; j < t; ++j) { + STableQueryInfo *pCheckInfo = taosArrayGetP(group, j); - pCheckInfo->win = pQuery->window; - pCheckInfo->lastKey = pCheckInfo->win.skey; + pCheckInfo->win = pQuery->window; + pCheckInfo->lastKey = pCheckInfo->win.skey; + } } } } else if (isPointInterpoQuery(pQuery)) { @@ -4482,7 +4554,6 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo int32_t code = TSDB_CODE_SUCCESS; SQuery *pQuery = pQInfo->runtimeEnv.pQuery; - pQuery->precision = tsdbGetCfg(tsdb)->precision; pRuntimeEnv->topBotQuery = isTopBottomQuery(pQuery); pRuntimeEnv->hasTagResults = hasTagValOutput(pQuery); @@ -4653,18 +4724,17 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) { setEnvForEachBlock(pQInfo, *pTableQueryInfo, &blockInfo); } - SDataStatis *pStatis = NULL; - SArray * pDataBlock = NULL; uint32_t status = 0; + SDataStatis *pStatis = NULL; + SArray *pDataBlock = NULL; - int32_t ret = loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis, &pDataBlock, &status); + int32_t ret = loadDataBlockOnDemand(pRuntimeEnv, &pQuery->current->windowResInfo, pQueryHandle, &blockInfo, &pStatis, &pDataBlock, &status); if (ret != TSDB_CODE_SUCCESS) { break; } if (status == BLK_DATA_DISCARD) { - pQuery->current->lastKey = - QUERY_IS_ASC_QUERY(pQuery) ? blockInfo.window.ekey + step : blockInfo.window.skey + step; + pQuery->current->lastKey = QUERY_IS_ASC_QUERY(pQuery)? blockInfo.window.ekey + step : blockInfo.window.skey + step; continue; } @@ -4734,15 +4804,62 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) { } if (pRuntimeEnv->pTSBuf != NULL) { - if (pRuntimeEnv->cur.vgroupIndex == -1) { - STSElem elem = tsBufGetElemStartPos(pRuntimeEnv->pTSBuf, 0, &pRuntimeEnv->pCtx[0].tag); + tVariant* pTag = &pRuntimeEnv->pCtx[0].tag; - // failed to find data with the specified tag value + if (pRuntimeEnv->cur.vgroupIndex == -1) { + STSElem elem = tsBufGetElemStartPos(pRuntimeEnv->pTSBuf, pQInfo->vgId, pTag); + // failed to find data with the specified tag value and vnodeId if (elem.vnode < 0) { + if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { + qError("QInfo:%p failed to find tag:%s in ts_comp", pQInfo, pTag->pz); + } else { + qError("QInfo:%p failed to find tag:%"PRId64" in ts_comp", pQInfo, pTag->i64Key); + } + return false; + } else { + STSCursor cur = tsBufGetCursor(pRuntimeEnv->pTSBuf); + + if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { + qDebug("QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz, + cur.blockIndex, cur.tsIndex); + } else { + qDebug("QInfo:%p find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64Key, + cur.blockIndex, cur.tsIndex); + } } } else { - tsBufSetCursor(pRuntimeEnv->pTSBuf, &pRuntimeEnv->cur); + STSElem elem = tsBufGetElem(pRuntimeEnv->pTSBuf); + if (tVariantCompare(elem.tag, &pRuntimeEnv->pCtx[0].tag) != 0) { + + STSElem elem1 = tsBufGetElemStartPos(pRuntimeEnv->pTSBuf, pQInfo->vgId, pTag); + // failed to find data with the specified tag value and vnodeId + if (elem1.vnode < 0) { + if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { + qError("QInfo:%p failed to find tag:%s in ts_comp", pQInfo, pTag->pz); + } else { + qError("QInfo:%p failed to find tag:%"PRId64" in ts_comp", pQInfo, pTag->i64Key); + } + + return false; + } else { + STSCursor cur = tsBufGetCursor(pRuntimeEnv->pTSBuf); + if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { + qDebug("QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz, cur.blockIndex, cur.tsIndex); + } else { + qDebug("QInfo:%p find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64Key, cur.blockIndex, cur.tsIndex); + } + } + + } else { + tsBufSetCursor(pRuntimeEnv->pTSBuf, &pRuntimeEnv->cur); + STSCursor cur = tsBufGetCursor(pRuntimeEnv->pTSBuf); + if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { + qDebug("QInfo:%p continue scan ts_comp file, tag:%s blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz, cur.blockIndex, cur.tsIndex); + } else { + qDebug("QInfo:%p continue scan ts_comp file, tag:%"PRId64" blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64Key, cur.blockIndex, cur.tsIndex); + } + } } } @@ -4998,6 +5115,10 @@ static void sequentialTableProcess(SQInfo *pQInfo) { break; } + if (pRuntimeEnv->pTSBuf != NULL) { + pRuntimeEnv->cur = pRuntimeEnv->pTSBuf->cur; + } + } else { // all data in the result buffer are skipped due to the offset, continue to retrieve data from current meter if (pQuery->rec.rows == 0) { @@ -5036,8 +5157,8 @@ static void sequentialTableProcess(SQInfo *pQInfo) { } qDebug( - "QInfo %p numOfTables:%"PRIu64", index:%d, numOfGroups:%" PRIzu ", %"PRId64" points returned, total:%"PRId64", offset:%" PRId64, - pQInfo, pQInfo->tableqinfoGroupInfo.numOfTables, pQInfo->tableIndex, numOfGroups, pQuery->rec.rows, pQuery->rec.total, + "QInfo %p numOfTables:%" PRIu64 ", index:%d, numOfGroups:%" PRIzu ", %" PRId64 " points returned, total:%" PRId64 ", offset:%" PRId64, + pQInfo, (uint64_t)pQInfo->tableqinfoGroupInfo.numOfTables, pQInfo->tableIndex, numOfGroups, pQuery->rec.rows, pQuery->rec.total, pQuery->limit.offset); } @@ -6198,7 +6319,9 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou // NOTE: pTableCheckInfo need to update the query time range and the lastKey info pQInfo->arrTableIdInfo = taosArrayInit(tableIndex, sizeof(STableIdInfo)); pQInfo->dataReady = QUERY_RESULT_NOT_READY; + pQInfo->rspContext = NULL; pthread_mutex_init(&pQInfo->lock, NULL); + tsem_init(&pQInfo->ready, 0, 0); pQuery->pos = -1; pQuery->window = pQueryMsg->window; @@ -6289,12 +6412,14 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ STSBuf *pTSBuf = NULL; if (pQueryMsg->tsLen > 0) { // open new file to save the result char *tsBlock = (char *) pQueryMsg + pQueryMsg->tsOffset; - pTSBuf = tsBufCreateFromCompBlocks(tsBlock, pQueryMsg->tsNumOfBlocks, pQueryMsg->tsLen, pQueryMsg->tsOrder); + pTSBuf = tsBufCreateFromCompBlocks(tsBlock, pQueryMsg->tsNumOfBlocks, pQueryMsg->tsLen, pQueryMsg->tsOrder, vgId); tsBufResetPos(pTSBuf); bool ret = tsBufNextPos(pTSBuf); UNUSED(ret); } + + pQuery->precision = tsdbGetCfg(tsdb)->precision; if ((QUERY_IS_ASC_QUERY(pQuery) && (pQuery->window.skey > pQuery->window.ekey)) || (!QUERY_IS_ASC_QUERY(pQuery) && (pQuery->window.ekey > pQuery->window.skey))) { @@ -6325,17 +6450,43 @@ _error: } static void freeColumnFilterInfo(SColumnFilterInfo* pFilter, int32_t numOfFilters) { - if (pFilter == NULL) { + if (pFilter == NULL || numOfFilters == 0) { return; } + for (int32_t i = 0; i < numOfFilters; i++) { if (pFilter[i].filterstr) { free((void*)(pFilter[i].pz)); } } + free(pFilter); } +static void doDestroyTableQueryInfo(STableGroupInfo* pTableqinfoGroupInfo) { + if (pTableqinfoGroupInfo->pGroupList != NULL) { + int32_t numOfGroups = (int32_t) taosArrayGetSize(pTableqinfoGroupInfo->pGroupList); + for (int32_t i = 0; i < numOfGroups; ++i) { + SArray *p = taosArrayGetP(pTableqinfoGroupInfo->pGroupList, i); + + size_t num = taosArrayGetSize(p); + for(int32_t j = 0; j < num; ++j) { + STableQueryInfo* item = taosArrayGetP(p, j); + destroyTableQueryInfoImpl(item); + } + + taosArrayDestroy(p); + } + } + + taosArrayDestroy(pTableqinfoGroupInfo->pGroupList); + taosHashCleanup(pTableqinfoGroupInfo->map); + + pTableqinfoGroupInfo->pGroupList = NULL; + pTableqinfoGroupInfo->map = NULL; + pTableqinfoGroupInfo->numOfTables = 0; +} + static void freeQInfo(SQInfo *pQInfo) { if (!isValidQInfo(pQInfo)) { return; @@ -6343,6 +6494,8 @@ static void freeQInfo(SQInfo *pQInfo) { qDebug("QInfo:%p start to free QInfo", pQInfo); + releaseQueryBuf(pQInfo->tableqinfoGroupInfo.numOfTables); + teardownQueryRuntimeEnv(&pQInfo->runtimeEnv); SQuery *pQuery = pQInfo->runtimeEnv.pQuery; @@ -6396,25 +6549,9 @@ static void freeQInfo(SQInfo *pQInfo) { taosTFree(pQuery); } - // todo refactor, extract method to destroytableDataInfo - if (pQInfo->tableqinfoGroupInfo.pGroupList != NULL) { - int32_t numOfGroups = (int32_t)(GET_NUM_OF_TABLEGROUP(pQInfo)); - for (int32_t i = 0; i < numOfGroups; ++i) { - SArray *p = GET_TABLEGROUP(pQInfo, i); - - size_t num = taosArrayGetSize(p); - for(int32_t j = 0; j < num; ++j) { - STableQueryInfo* item = taosArrayGetP(p, j); - destroyTableQueryInfo(item); - } - - taosArrayDestroy(p); - } - } + doDestroyTableQueryInfo(&pQInfo->tableqinfoGroupInfo); taosTFree(pQInfo->pBuf); - taosArrayDestroy(pQInfo->tableqinfoGroupInfo.pGroupList); - taosHashCleanup(pQInfo->tableqinfoGroupInfo.map); tsdbDestroyTableGroup(&pQInfo->tableGroupInfo); taosArrayDestroy(pQInfo->arrTableIdInfo); @@ -6593,6 +6730,11 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi assert(0); } + code = checkForQueryBuf(tableGroupInfo.numOfTables); + if (code != TSDB_CODE_SUCCESS) { // not enough query buffer, abort + goto _over; + } + (*pQInfo) = createQInfoImpl(pQueryMsg, pGroupbyExpr, pExprs, &tableGroupInfo, pTagColumnInfo, isSTableQuery); pExprs = NULL; pGroupbyExpr = NULL; @@ -6651,12 +6793,14 @@ static bool doBuildResCheck(SQInfo* pQInfo) { pQInfo->dataReady = QUERY_RESULT_READY; buildRes = (pQInfo->rspContext != NULL); - pthread_mutex_unlock(&pQInfo->lock); - - // clear qhandle owner + // clear qhandle owner, it must be in the secure area. other thread may run ahead before current, after it is + // put into task to be executed. assert(pQInfo->owner == taosGetPthreadId()); pQInfo->owner = 0; + pthread_mutex_unlock(&pQInfo->lock); + + tsem_post(&pQInfo->ready); return buildRes; } @@ -6720,18 +6864,24 @@ int32_t qRetrieveQueryResultInfo(qinfo_t qinfo, bool* buildRes, void* pRspContex SQInfo *pQInfo = (SQInfo *)qinfo; if (pQInfo == NULL || !isValidQInfo(pQInfo)) { + qError("QInfo:%p invalid qhandle", pQInfo); return TSDB_CODE_QRY_INVALID_QHANDLE; } *buildRes = false; - SQuery *pQuery = pQInfo->runtimeEnv.pQuery; if (IS_QUERY_KILLED(pQInfo)) { - qDebug("QInfo:%p query is killed, code:%d", pQInfo, pQInfo->code); + qDebug("QInfo:%p query is killed, code:0x%08x", pQInfo, pQInfo->code); return pQInfo->code; } int32_t code = TSDB_CODE_SUCCESS; + +#if 0 + SQuery *pQuery = pQInfo->runtimeEnv.pQuery; + pthread_mutex_lock(&pQInfo->lock); + assert(pQInfo->rspContext == NULL); + if (pQInfo->dataReady == QUERY_RESULT_READY) { *buildRes = true; qDebug("QInfo:%p retrieve result info, rowsize:%d, rows:%"PRId64", code:%d", pQInfo, pQuery->rowSize, pQuery->rec.rows, @@ -6740,10 +6890,17 @@ int32_t qRetrieveQueryResultInfo(qinfo_t qinfo, bool* buildRes, void* pRspContex *buildRes = false; qDebug("QInfo:%p retrieve req set query return result after paused", pQInfo); pQInfo->rspContext = pRspContext; + assert(pQInfo->rspContext != NULL); } code = pQInfo->code; pthread_mutex_unlock(&pQInfo->lock); +#else + tsem_wait(&pQInfo->ready); + *buildRes = true; + code = pQInfo->code; +#endif + return code; } @@ -6979,6 +7136,48 @@ static void buildTagQueryResult(SQInfo* pQInfo) { setQueryStatus(pQuery, QUERY_COMPLETED); } +static int64_t getQuerySupportBufSize(size_t numOfTables) { + size_t s1 = sizeof(STableQueryInfo); + size_t s2 = sizeof(SHashNode); + +// size_t s3 = sizeof(STableCheckInfo); buffer consumption in tsdb + return (int64_t)((s1 + s2) * 1.5 * numOfTables); +} + +int32_t checkForQueryBuf(size_t numOfTables) { + int64_t t = getQuerySupportBufSize(numOfTables); + if (tsQueryBufferSize < 0) { + return TSDB_CODE_SUCCESS; + } else if (tsQueryBufferSize > 0) { + + while(1) { + int64_t s = tsQueryBufferSize; + int64_t remain = s - t; + if (remain >= 0) { + if (atomic_val_compare_exchange_64(&tsQueryBufferSize, s, remain) == s) { + return TSDB_CODE_SUCCESS; + } + } else { + return TSDB_CODE_QRY_NOT_ENOUGH_BUFFER; + } + } + } + + // disable query processing if the value of tsQueryBufferSize is zero. + return TSDB_CODE_QRY_NOT_ENOUGH_BUFFER; +} + +void releaseQueryBuf(size_t numOfTables) { + if (tsQueryBufferSize <= 0) { + return; + } + + int64_t t = getQuerySupportBufSize(numOfTables); + + // restore value is not enough buffer available + atomic_add_fetch_64(&tsQueryBufferSize, t); +} + void* qGetResultRetrieveMsg(qinfo_t qinfo) { SQInfo* pQInfo = (SQInfo*) qinfo; assert(pQInfo != NULL); @@ -7008,7 +7207,7 @@ void* qOpenQueryMgmt(int32_t vgId) { return NULL; } - pQueryMgmt->qinfoPool = taosCacheInit(TSDB_DATA_TYPE_BIGINT, REFRESH_HANDLE_INTERVAL, true, freeqinfoFn, cacheName); + pQueryMgmt->qinfoPool = taosCacheInit(TSDB_CACHE_PTR_KEY, REFRESH_HANDLE_INTERVAL, true, freeqinfoFn, cacheName); pQueryMgmt->closed = false; pQueryMgmt->vgId = vgId; @@ -7060,6 +7259,7 @@ void qCleanupQueryMgmt(void* pQMgmt) { void** qRegisterQInfo(void* pMgmt, uint64_t qInfo) { if (pMgmt == NULL) { + terrno = TSDB_CODE_VND_INVALID_VGROUP_ID; return NULL; } @@ -7068,6 +7268,7 @@ void** qRegisterQInfo(void* pMgmt, uint64_t qInfo) { SQueryMgmt *pQueryMgmt = pMgmt; if (pQueryMgmt->qinfoPool == NULL) { qError("QInfo:%p failed to add qhandle into qMgmt, since qMgmt is closed", (void *)qInfo); + terrno = TSDB_CODE_VND_INVALID_VGROUP_ID; return NULL; } @@ -7075,26 +7276,34 @@ void** qRegisterQInfo(void* pMgmt, uint64_t qInfo) { if (pQueryMgmt->closed) { // pthread_mutex_unlock(&pQueryMgmt->lock); qError("QInfo:%p failed to add qhandle into cache, since qMgmt is colsing", (void *)qInfo); + terrno = TSDB_CODE_VND_INVALID_VGROUP_ID; return NULL; } else { - uint64_t handleVal = (uint64_t) qInfo; - - void** handle = taosCachePut(pQueryMgmt->qinfoPool, &handleVal, sizeof(int64_t), &qInfo, POINTER_BYTES, DEFAULT_QHANDLE_LIFE_SPAN); + TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE) qInfo; + void** handle = taosCachePut(pQueryMgmt->qinfoPool, &handleVal, sizeof(TSDB_CACHE_PTR_TYPE), &qInfo, sizeof(TSDB_CACHE_PTR_TYPE), DEFAULT_QHANDLE_LIFE_SPAN); // pthread_mutex_unlock(&pQueryMgmt->lock); return handle; } } -void** qAcquireQInfo(void* pMgmt, uint64_t key) { +void** qAcquireQInfo(void* pMgmt, uint64_t _key) { SQueryMgmt *pQueryMgmt = pMgmt; - if (pQueryMgmt->qinfoPool == NULL || pQueryMgmt->closed) { + if (pQueryMgmt->closed) { + terrno = TSDB_CODE_VND_INVALID_VGROUP_ID; + return NULL; + } + + if (pQueryMgmt->qinfoPool == NULL) { + terrno = TSDB_CODE_QRY_INVALID_QHANDLE; return NULL; } - void** handle = taosCacheAcquireByKey(pQueryMgmt->qinfoPool, &key, sizeof(uint64_t)); + TSDB_CACHE_PTR_TYPE key = (TSDB_CACHE_PTR_TYPE)_key; + void** handle = taosCacheAcquireByKey(pQueryMgmt->qinfoPool, &key, sizeof(TSDB_CACHE_PTR_TYPE)); if (handle == NULL || *handle == NULL) { + terrno = TSDB_CODE_QRY_INVALID_QHANDLE; return NULL; } else { return handle; diff --git a/src/query/src/qExtbuffer.c b/src/query/src/qExtbuffer.c index 1d3120ead47852da3e3ec6bdcc6f92de9c52cb60..17be294531e51982924d84700fc21653ad231224 100644 --- a/src/query/src/qExtbuffer.c +++ b/src/query/src/qExtbuffer.c @@ -343,8 +343,8 @@ static FORCE_INLINE int32_t primaryKeyComparator(int64_t f1, int64_t f2, int32_t if (f1 == f2) { return 0; } - - if (colIdx == 0 && tsOrder == TSDB_ORDER_DESC) { // primary column desc order + + if (tsOrder == TSDB_ORDER_DESC) { // primary column desc order return (f1 < f2) ? 1 : -1; } else { // asc return (f1 < f2) ? -1 : 1; @@ -435,7 +435,7 @@ int32_t compare_a(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1, int32_t cmpCnt = pDescriptor->orderInfo.numOfCols; for (int32_t i = 0; i < cmpCnt; ++i) { - int32_t colIdx = pDescriptor->orderInfo.pData[i]; + int32_t colIdx = pDescriptor->orderInfo.colIndex[i]; char *f1 = COLMODEL_GET_VAL(data1, pDescriptor->pColumnModel, numOfRows1, s1, colIdx); char *f2 = COLMODEL_GET_VAL(data2, pDescriptor->pColumnModel, numOfRows2, s2, colIdx); @@ -467,7 +467,7 @@ int32_t compare_d(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1, int32_t cmpCnt = pDescriptor->orderInfo.numOfCols; for (int32_t i = 0; i < cmpCnt; ++i) { - int32_t colIdx = pDescriptor->orderInfo.pData[i]; + int32_t colIdx = pDescriptor->orderInfo.colIndex[i]; char *f1 = COLMODEL_GET_VAL(data1, pDescriptor->pColumnModel, numOfRows1, s1, colIdx); char *f2 = COLMODEL_GET_VAL(data2, pDescriptor->pColumnModel, numOfRows2, s2, colIdx); @@ -557,13 +557,13 @@ static void median(tOrderDescriptor *pDescriptor, int32_t numOfRows, int32_t sta int32_t midIdx = ((end - start) >> 1) + start; #if defined(_DEBUG_VIEW) - int32_t f = pDescriptor->orderInfo.pData[0]; + int32_t f = pDescriptor->orderInfo.colIndex[0]; char *midx = COLMODEL_GET_VAL(data, pDescriptor->pColumnModel, numOfRows, midIdx, f); char *startx = COLMODEL_GET_VAL(data, pDescriptor->pColumnModel, numOfRows, start, f); char *endx = COLMODEL_GET_VAL(data, pDescriptor->pColumnModel, numOfRows, end, f); - int32_t colIdx = pDescriptor->orderInfo.pData[0]; + int32_t colIdx = pDescriptor->orderInfo.colIndex[0]; tSortDataPrint(pDescriptor->pColumnModel->pFields[colIdx].field.type, "before", startx, midx, endx); #endif @@ -591,7 +591,7 @@ static void median(tOrderDescriptor *pDescriptor, int32_t numOfRows, int32_t sta } static UNUSED_FUNC void tRowModelDisplay(tOrderDescriptor *pDescriptor, int32_t numOfRows, char *d, int32_t len) { - int32_t colIdx = pDescriptor->orderInfo.pData[0]; + int32_t colIdx = pDescriptor->orderInfo.colIndex[0]; for (int32_t i = 0; i < len; ++i) { char *startx = COLMODEL_GET_VAL(d, pDescriptor->pColumnModel, numOfRows, i, colIdx); @@ -1075,7 +1075,7 @@ tOrderDescriptor *tOrderDesCreate(const int32_t *orderColIdx, int32_t numOfOrder desc->orderInfo.numOfCols = numOfOrderCols; for (int32_t i = 0; i < numOfOrderCols; ++i) { - desc->orderInfo.pData[i] = orderColIdx[i]; + desc->orderInfo.colIndex[i] = orderColIdx[i]; } return desc; diff --git a/src/query/src/qFill.c b/src/query/src/qFill.c index 8660d9f4fe59b72aa88a058c922369d313e49b48..f186726c0120f2e2e34580fec0da00c2083e5da9 100644 --- a/src/query/src/qFill.c +++ b/src/query/src/qFill.c @@ -38,6 +38,9 @@ SFillInfo* taosInitFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_ pFillInfo->numOfTags = numOfTags; pFillInfo->numOfCols = numOfCols; pFillInfo->precision = precision; + + pFillInfo->interval.interval = slidingTime; + pFillInfo->interval.intervalUnit = slidingUnit; pFillInfo->interval.sliding = slidingTime; pFillInfo->interval.slidingUnit = slidingUnit; diff --git a/src/query/src/qParserImpl.c b/src/query/src/qParserImpl.c index 33237a58c2096f7c87b890863723318fe487ff32..7e8128f200658af282bab89bd73dc2c27ddb25c1 100644 --- a/src/query/src/qParserImpl.c +++ b/src/query/src/qParserImpl.c @@ -130,13 +130,15 @@ tSQLExpr *tSQLExprIdValueCreate(SStrToken *pToken, int32_t optrType) { tVariantCreate(&pSQLExpr->val, pToken); pSQLExpr->nSQLOptr = optrType; } else if (optrType == TK_NOW) { - // default use microsecond + // use microsecond by default pSQLExpr->val.i64Key = taosGetTimestamp(TSDB_TIME_PRECISION_MICRO); pSQLExpr->val.nType = TSDB_DATA_TYPE_BIGINT; pSQLExpr->nSQLOptr = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond } else if (optrType == TK_VARIABLE) { int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSQLExpr->val.i64Key); - UNUSED(ret); + if (ret != TSDB_CODE_SUCCESS) { + terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; + } pSQLExpr->val.nType = TSDB_DATA_TYPE_BIGINT; pSQLExpr->nSQLOptr = TK_TIMESTAMP; @@ -148,6 +150,7 @@ tSQLExpr *tSQLExprIdValueCreate(SStrToken *pToken, int32_t optrType) { pSQLExpr->nSQLOptr = optrType; } + return pSQLExpr; } @@ -532,26 +535,6 @@ SQuerySQL *tSetQuerySQLElems(SStrToken *pSelectToken, tSQLExprList *pSelection, return pQuery; } -tSQLExprListList *tSQLListListAppend(tSQLExprListList *pList, tSQLExprList *pExprList) { - if (pList == NULL) pList = calloc(1, sizeof(tSQLExprListList)); - - if (pList->nAlloc <= pList->nList) { // - pList->nAlloc = (pList->nAlloc << 1) + 4; - pList->a = realloc(pList->a, pList->nAlloc * sizeof(pList->a[0])); - if (pList->a == 0) { - pList->nList = pList->nAlloc = 0; - return pList; - } - } - assert(pList->a != 0); - - if (pExprList) { - pList->a[pList->nList++] = pExprList; - } - - return pList; -} - void doDestroyQuerySql(SQuerySQL *pQuerySql) { if (pQuerySql == NULL) { return; diff --git a/src/query/src/qPercentile.c b/src/query/src/qPercentile.c index 3a8be781d5c9e7cfcb524e10b2d937a73ecb74ca..ab9ffb7bcb458129b7f170e7020cee904d2dfda6 100644 --- a/src/query/src/qPercentile.c +++ b/src/query/src/qPercentile.c @@ -365,7 +365,7 @@ void tMemBucketDestroy(tMemBucket *pBucket) { taosTFree(pBucket); } -void tMemBucketUpdateBoundingBox(MinMaxEntry *r, char *data, int32_t dataType) { +void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataType) { switch (dataType) { case TSDB_DATA_TYPE_INT: { int32_t val = *(int32_t *)data; diff --git a/src/query/src/qSyntaxtreefunction.c b/src/query/src/qSyntaxtreefunction.c index 2104edfd910bba1a1701800387545c4f58dfb625..7f7fca2c1e0ca6ce85f0df1c1b6e6dce82d8c000 100644 --- a/src/query/src/qSyntaxtreefunction.c +++ b/src/query/src/qSyntaxtreefunction.c @@ -1247,7 +1247,10 @@ _bi_consumer_fn_t tGetBiConsumerFn(int32_t leftType, int32_t rightType, int32_t case TSDB_BINARY_OP_REMAINDER: return rem_function_arraylist[leftType][rightType]; default: + assert(0); return NULL; } + + assert(0); return NULL; } diff --git a/src/query/src/qTsbuf.c b/src/query/src/qTsbuf.c index b264f6cdc9d815a12cc5a3ab0e5c09c0d670bcdb..ad29cef5c290f4a6bcd45f8a79828b0c14727dc0 100644 --- a/src/query/src/qTsbuf.c +++ b/src/query/src/qTsbuf.c @@ -403,7 +403,7 @@ void tsBufAppend(STSBuf* pTSBuf, int32_t vnodeId, tVariant* tag, const char* pDa } else { expandBuffer(ptsData, len); } - + tVariantAssign(&pTSBuf->block.tag, tag); memcpy(ptsData->rawBuf + ptsData->len, pData, (size_t)len); @@ -561,6 +561,19 @@ static void tsBufGetBlock(STSBuf* pTSBuf, int32_t vnodeIndex, int32_t blockIndex pCur->tsIndex = (pCur->order == TSDB_ORDER_ASC) ? 0 : pBlock->numOfElem - 1; } +static int32_t doUpdateVnodeInfo(STSBuf* pTSBuf, int64_t offset, STSVnodeBlockInfo* pVInfo) { + if (offset < 0 || offset >= getDataStartOffset()) { + return -1; + } + + if (fseek(pTSBuf->f, (int32_t)offset, SEEK_SET) != 0) { + return -1; + } + + fwrite(pVInfo, sizeof(STSVnodeBlockInfo), 1, pTSBuf->f); + return 0; +} + STSVnodeBlockInfo* tsBufGetVnodeBlockInfo(STSBuf* pTSBuf, int32_t vnodeId) { int32_t j = tsBufFindVnodeIndexFromId(pTSBuf->pData, pTSBuf->numOfVnodes, vnodeId); if (j == -1) { @@ -649,7 +662,7 @@ bool tsBufNextPos(STSBuf* pTSBuf) { return false; } - int32_t blockIndex = pCur->order == TSDB_ORDER_ASC ? 0 : pBlockInfo->numOfBlocks - 1; + int32_t blockIndex = (pCur->order == TSDB_ORDER_ASC) ? 0 : (pBlockInfo->numOfBlocks - 1); tsBufGetBlock(pTSBuf, pCur->vgroupIndex + step, blockIndex); break; @@ -675,8 +688,7 @@ void tsBufResetPos(STSBuf* pTSBuf) { } STSElem tsBufGetElem(STSBuf* pTSBuf) { - STSElem elem1 = {.vnode = -1}; - + STSElem elem1 = {.vnode = -1}; if (pTSBuf == NULL) { return elem1; } @@ -690,7 +702,7 @@ STSElem tsBufGetElem(STSBuf* pTSBuf) { elem1.vnode = pTSBuf->pData[pCur->vgroupIndex].info.vnode; elem1.ts = *(TSKEY*)(pTSBuf->tsData.rawBuf + pCur->tsIndex * TSDB_KEYSIZE); - tVariantAssign(&elem1.tag, &pBlock->tag); + elem1.tag = &pBlock->tag; return elem1; } @@ -702,7 +714,7 @@ STSElem tsBufGetElem(STSBuf* pTSBuf) { * @param vnodeId * @return */ -int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf, int32_t vnodeId) { +int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) { if (pDestBuf == NULL || pSrcBuf == NULL || pSrcBuf->numOfVnodes <= 0) { return 0; } @@ -712,14 +724,13 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf, int32_t vnodeId) { } // src can only have one vnode index - if (pSrcBuf->numOfVnodes > 1) { - return -1; - } - + assert(pSrcBuf->numOfVnodes == 1); + // there are data in buffer, flush to disk first tsBufFlush(pDestBuf); // compared with the last vnode id + int32_t vnodeId = tsBufGetLastVnodeInfo((STSBuf*) pSrcBuf)->info.vnode; if (vnodeId != tsBufGetLastVnodeInfo(pDestBuf)->info.vnode) { int32_t oldSize = pDestBuf->numOfVnodes; int32_t newSize = oldSize + pSrcBuf->numOfVnodes; @@ -791,14 +802,14 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf, int32_t vnodeId) { return 0; } -STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_t len, int32_t order) { +STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_t len, int32_t order, int32_t vnodeId) { STSBuf* pTSBuf = tsBufCreate(true, order); STSVnodeBlockInfo* pBlockInfo = &(addOneVnodeInfo(pTSBuf, 0)->info); pBlockInfo->numOfBlocks = numOfBlocks; pBlockInfo->compLen = len; pBlockInfo->offset = getDataStartOffset(); - pBlockInfo->vnode = 0; + pBlockInfo->vnode = vnodeId; // update prev vnode length info in file TSBufUpdateVnodeInfo(pTSBuf, pTSBuf->numOfVnodes - 1, pBlockInfo); @@ -902,8 +913,8 @@ void tsBufDisplay(STSBuf* pTSBuf) { while (tsBufNextPos(pTSBuf)) { STSElem elem = tsBufGetElem(pTSBuf); - if (elem.tag.nType == TSDB_DATA_TYPE_BIGINT) { - printf("%d-%" PRId64 "-%" PRId64 "\n", elem.vnode, elem.tag.i64Key, elem.ts); + if (elem.tag->nType == TSDB_DATA_TYPE_BIGINT) { + printf("%d-%" PRId64 "-%" PRId64 "\n", elem.vnode, elem.tag->i64Key, elem.ts); } } @@ -915,19 +926,6 @@ static int32_t getDataStartOffset() { return sizeof(STSBufFileHeader) + TS_COMP_FILE_VNODE_MAX * sizeof(STSVnodeBlockInfo); } -static int32_t doUpdateVnodeInfo(STSBuf* pTSBuf, int64_t offset, STSVnodeBlockInfo* pVInfo) { - if (offset < 0 || offset >= getDataStartOffset()) { - return -1; - } - - if (fseek(pTSBuf->f, (int32_t)offset, SEEK_SET) != 0) { - return -1; - } - - fwrite(pVInfo, sizeof(STSVnodeBlockInfo), 1, pTSBuf->f); - return 0; -} - // update prev vnode length info in file static void TSBufUpdateVnodeInfo(STSBuf* pTSBuf, int32_t index, STSVnodeBlockInfo* pBlockInfo) { int32_t offset = sizeof(STSBufFileHeader) + index * sizeof(STSVnodeBlockInfo); @@ -969,3 +967,29 @@ static STSBuf* allocResForTSBuf(STSBuf* pTSBuf) { pTSBuf->fileSize += getDataStartOffset(); return pTSBuf; } + +int32_t tsBufGetNumOfVnodes(STSBuf* pTSBuf) { + if (pTSBuf == NULL) { + return 0; + } + + return pTSBuf->numOfVnodes; +} + +void tsBufGetVnodeIdList(STSBuf* pTSBuf, int32_t* num, int32_t** vnodeId) { + int32_t size = tsBufGetNumOfVnodes(pTSBuf); + if (num != NULL) { + *num = size; + } + + *vnodeId = NULL; + if (size == 0) { + return; + } + + (*vnodeId) = malloc(tsBufGetNumOfVnodes(pTSBuf) * sizeof(int32_t)); + + for(int32_t i = 0; i < size; ++i) { + (*vnodeId)[i] = pTSBuf->pData[i].info.vnode; + } +} \ No newline at end of file diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 3145f39a5e1ca11af517882cb5e7e23b6d1efb26..a18efdeb744ba039c685d5fc1067c95e3ca15d86 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -23,7 +23,6 @@ ** input grammar file: */ #include -#include /************ Begin %include sections from the grammar ************************/ #include @@ -77,10 +76,8 @@ ** zero the stack is dynamically sized using realloc() ** ParseARG_SDECL A static variable declaration for the %extra_argument ** ParseARG_PDECL A parameter declaration for the %extra_argument -** ParseARG_PARAM Code to pass %extra_argument as a subroutine parameter ** ParseARG_STORE Code to store %extra_argument into yypParser ** ParseARG_FETCH Code to extract %extra_argument from yypParser -** ParseCTX_* As ParseARG_ except for %extra_context ** YYERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. ** YYNSTATE the combined number of states. @@ -100,56 +97,48 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 270 +#define YYNOCODE 272 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SStrToken typedef union { int yyinit; ParseTOKENTYPE yy0; - int yy112; - SCreateDBInfo yy118; - tVariantList* yy156; - tSQLExprList* yy158; - tSQLExpr* yy190; - SSubclauseInfo* yy333; - SIntervalVal yy340; - TAOS_FIELD yy343; - int64_t yy369; - SCreateTableSQL* yy398; - SLimitVal yy414; - SQuerySQL* yy444; - SCreateAcctSQL yy479; - tVariant yy506; - tFieldList* yy511; + SSubclauseInfo* yy25; + tSQLExpr* yy66; + SCreateAcctSQL yy73; + int yy82; + SQuerySQL* yy150; + SCreateDBInfo yy158; + TAOS_FIELD yy181; + SLimitVal yy188; + tSQLExprList* yy224; + int64_t yy271; + tVariant yy312; + SIntervalVal yy314; + SCreateTableSQL* yy374; + tFieldList* yy449; + tVariantList* yy494; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 #endif #define ParseARG_SDECL SSqlInfo* pInfo; #define ParseARG_PDECL ,SSqlInfo* pInfo -#define ParseARG_PARAM ,pInfo -#define ParseARG_FETCH SSqlInfo* pInfo=yypParser->pInfo; -#define ParseARG_STORE yypParser->pInfo=pInfo; -#define ParseCTX_SDECL -#define ParseCTX_PDECL -#define ParseCTX_PARAM -#define ParseCTX_FETCH -#define ParseCTX_STORE +#define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo +#define ParseARG_STORE yypParser->pInfo = pInfo #define YYFALLBACK 1 -#define YYNSTATE 248 -#define YYNRULE 228 -#define YYNRULE_WITH_ACTION 228 +#define YYNSTATE 252 +#define YYNRULE 230 #define YYNTOKEN 206 -#define YY_MAX_SHIFT 247 -#define YY_MIN_SHIFTREDUCE 410 -#define YY_MAX_SHIFTREDUCE 637 -#define YY_ERROR_ACTION 638 -#define YY_ACCEPT_ACTION 639 -#define YY_NO_ACTION 640 -#define YY_MIN_REDUCE 641 -#define YY_MAX_REDUCE 868 +#define YY_MAX_SHIFT 251 +#define YY_MIN_SHIFTREDUCE 416 +#define YY_MAX_SHIFTREDUCE 645 +#define YY_ERROR_ACTION 646 +#define YY_ACCEPT_ACTION 647 +#define YY_NO_ACTION 648 +#define YY_MIN_REDUCE 649 +#define YY_MAX_REDUCE 878 /************* End control #defines *******************************************/ -#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) /* Define the yytestcase() macro to be a no-op if is not already defined ** otherwise. @@ -214,219 +203,223 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (560) +#define YY_ACTTAB_COUNT (566) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 741, 451, 11, 739, 740, 639, 247, 451, 742, 452, - /* 10 */ 744, 745, 743, 35, 36, 452, 37, 38, 156, 245, - /* 20 */ 167, 29, 138, 137, 202, 41, 39, 43, 40, 106, - /* 30 */ 517, 162, 856, 34, 33, 782, 138, 32, 31, 30, - /* 40 */ 35, 36, 771, 37, 38, 161, 856, 167, 29, 771, - /* 50 */ 106, 202, 41, 39, 43, 40, 187, 159, 223, 222, - /* 60 */ 34, 33, 138, 157, 32, 31, 30, 35, 36, 451, - /* 70 */ 37, 38, 855, 142, 167, 29, 760, 452, 202, 41, - /* 80 */ 39, 43, 40, 199, 78, 60, 779, 34, 33, 234, - /* 90 */ 234, 32, 31, 30, 21, 41, 39, 43, 40, 32, - /* 100 */ 31, 30, 56, 34, 33, 852, 808, 32, 31, 30, - /* 110 */ 21, 21, 106, 411, 412, 413, 414, 415, 416, 417, - /* 120 */ 418, 419, 420, 421, 422, 246, 591, 171, 36, 757, - /* 130 */ 37, 38, 225, 50, 167, 29, 21, 62, 202, 41, - /* 140 */ 39, 43, 40, 172, 221, 757, 757, 34, 33, 27, - /* 150 */ 51, 32, 31, 30, 8, 37, 38, 63, 116, 167, - /* 160 */ 29, 101, 758, 202, 41, 39, 43, 40, 809, 226, - /* 170 */ 197, 757, 34, 33, 170, 851, 32, 31, 30, 16, - /* 180 */ 214, 240, 239, 213, 212, 211, 238, 210, 237, 236, - /* 190 */ 235, 209, 737, 760, 725, 726, 727, 728, 729, 730, - /* 200 */ 731, 732, 733, 734, 735, 736, 166, 604, 12, 241, - /* 210 */ 595, 17, 598, 190, 601, 559, 166, 604, 26, 103, - /* 220 */ 595, 597, 598, 600, 601, 34, 33, 151, 760, 32, - /* 230 */ 31, 30, 21, 90, 89, 145, 572, 573, 163, 164, - /* 240 */ 173, 150, 201, 76, 80, 85, 88, 79, 163, 164, - /* 250 */ 166, 604, 549, 82, 595, 106, 598, 100, 601, 244, - /* 260 */ 243, 97, 17, 16, 26, 240, 239, 756, 680, 26, - /* 270 */ 238, 129, 237, 236, 235, 119, 120, 70, 66, 69, - /* 280 */ 203, 165, 163, 164, 689, 533, 180, 129, 530, 186, - /* 290 */ 531, 850, 532, 184, 183, 596, 153, 599, 133, 131, - /* 300 */ 93, 92, 91, 42, 174, 546, 681, 220, 219, 129, - /* 310 */ 18, 61, 541, 42, 603, 593, 175, 176, 563, 189, - /* 320 */ 3, 47, 46, 537, 603, 538, 564, 623, 605, 602, - /* 330 */ 14, 13, 13, 154, 523, 75, 74, 522, 46, 602, - /* 340 */ 48, 22, 207, 535, 155, 536, 22, 42, 10, 9, - /* 350 */ 140, 594, 87, 86, 141, 143, 144, 148, 603, 149, - /* 360 */ 147, 136, 146, 139, 865, 759, 819, 818, 168, 607, - /* 370 */ 815, 814, 169, 602, 751, 224, 781, 773, 786, 788, - /* 380 */ 102, 801, 117, 800, 115, 118, 26, 534, 188, 691, - /* 390 */ 208, 134, 24, 217, 688, 218, 864, 72, 863, 861, - /* 400 */ 121, 95, 709, 25, 23, 135, 678, 81, 558, 676, - /* 410 */ 83, 191, 84, 674, 158, 673, 195, 177, 130, 671, - /* 420 */ 52, 670, 770, 669, 49, 44, 668, 107, 108, 200, - /* 430 */ 667, 194, 659, 132, 665, 663, 198, 196, 192, 661, - /* 440 */ 28, 57, 58, 802, 216, 77, 227, 228, 229, 230, - /* 450 */ 231, 232, 205, 233, 242, 53, 637, 178, 179, 636, - /* 460 */ 152, 64, 67, 182, 181, 672, 635, 628, 94, 96, - /* 470 */ 185, 666, 124, 55, 123, 710, 122, 125, 126, 128, - /* 480 */ 127, 1, 2, 189, 755, 543, 59, 560, 111, 109, - /* 490 */ 112, 110, 104, 113, 114, 160, 19, 193, 5, 565, - /* 500 */ 105, 6, 606, 4, 20, 15, 204, 7, 608, 65, - /* 510 */ 206, 492, 488, 486, 485, 484, 481, 455, 215, 68, - /* 520 */ 45, 71, 22, 519, 73, 518, 516, 54, 476, 474, - /* 530 */ 466, 472, 468, 470, 464, 462, 491, 490, 489, 487, - /* 540 */ 483, 482, 46, 453, 426, 424, 641, 640, 640, 640, - /* 550 */ 640, 640, 640, 640, 640, 640, 640, 640, 98, 99, + /* 0 */ 751, 459, 11, 749, 750, 647, 251, 459, 752, 460, + /* 10 */ 754, 755, 753, 35, 36, 460, 37, 38, 159, 249, + /* 20 */ 170, 29, 141, 459, 206, 41, 39, 43, 40, 140, + /* 30 */ 145, 460, 865, 34, 33, 862, 141, 32, 31, 30, + /* 40 */ 35, 36, 781, 37, 38, 165, 866, 170, 29, 141, + /* 50 */ 62, 206, 41, 39, 43, 40, 191, 525, 164, 866, + /* 60 */ 34, 33, 27, 21, 32, 31, 30, 417, 418, 419, + /* 70 */ 420, 421, 422, 423, 424, 425, 426, 427, 428, 250, + /* 80 */ 35, 36, 181, 37, 38, 227, 226, 170, 29, 781, + /* 90 */ 176, 206, 41, 39, 43, 40, 174, 162, 767, 792, + /* 100 */ 34, 33, 56, 160, 32, 31, 30, 21, 36, 8, + /* 110 */ 37, 38, 63, 118, 170, 29, 770, 108, 206, 41, + /* 120 */ 39, 43, 40, 32, 31, 30, 599, 34, 33, 78, + /* 130 */ 875, 32, 31, 30, 238, 37, 38, 108, 238, 170, + /* 140 */ 29, 184, 766, 206, 41, 39, 43, 40, 188, 187, + /* 150 */ 789, 177, 34, 33, 224, 223, 32, 31, 30, 16, + /* 160 */ 218, 244, 243, 217, 216, 215, 242, 214, 241, 240, + /* 170 */ 239, 213, 747, 818, 735, 736, 737, 738, 739, 740, + /* 180 */ 741, 742, 743, 744, 745, 746, 169, 612, 103, 12, + /* 190 */ 603, 17, 606, 819, 609, 201, 169, 612, 26, 108, + /* 200 */ 603, 108, 606, 861, 609, 153, 169, 612, 173, 567, + /* 210 */ 603, 154, 606, 105, 609, 90, 89, 148, 166, 167, + /* 220 */ 34, 33, 205, 102, 32, 31, 30, 770, 166, 167, + /* 230 */ 26, 21, 557, 41, 39, 43, 40, 549, 166, 167, + /* 240 */ 194, 34, 33, 17, 193, 32, 31, 30, 860, 16, + /* 250 */ 26, 244, 243, 203, 21, 60, 242, 61, 241, 240, + /* 260 */ 239, 248, 247, 96, 175, 229, 767, 76, 80, 245, + /* 270 */ 190, 554, 21, 85, 88, 79, 18, 156, 121, 122, + /* 280 */ 605, 82, 608, 42, 70, 66, 69, 225, 770, 767, + /* 290 */ 135, 133, 601, 42, 611, 768, 93, 92, 91, 690, + /* 300 */ 168, 207, 131, 42, 611, 230, 545, 767, 546, 610, + /* 310 */ 699, 157, 691, 131, 611, 131, 604, 541, 607, 610, + /* 320 */ 538, 571, 539, 47, 540, 46, 580, 581, 602, 610, + /* 330 */ 572, 631, 613, 50, 14, 13, 13, 531, 543, 3, + /* 340 */ 544, 46, 48, 530, 75, 74, 811, 22, 178, 179, + /* 350 */ 51, 211, 10, 9, 829, 22, 87, 86, 101, 99, + /* 360 */ 158, 143, 144, 146, 147, 151, 152, 150, 139, 149, + /* 370 */ 769, 142, 828, 171, 825, 824, 172, 791, 761, 796, + /* 380 */ 228, 783, 798, 104, 810, 119, 120, 701, 117, 212, + /* 390 */ 615, 137, 24, 221, 698, 26, 222, 192, 874, 72, + /* 400 */ 873, 871, 123, 719, 25, 100, 23, 138, 566, 688, + /* 410 */ 81, 686, 83, 84, 684, 195, 780, 683, 161, 542, + /* 420 */ 180, 199, 132, 681, 680, 679, 52, 49, 678, 677, + /* 430 */ 109, 134, 44, 675, 204, 673, 671, 669, 667, 202, + /* 440 */ 200, 198, 196, 28, 136, 220, 57, 58, 812, 77, + /* 450 */ 231, 232, 233, 234, 235, 236, 237, 246, 209, 645, + /* 460 */ 53, 182, 183, 644, 110, 64, 67, 155, 186, 185, + /* 470 */ 682, 643, 94, 636, 676, 189, 126, 125, 720, 124, + /* 480 */ 127, 128, 130, 129, 95, 668, 1, 551, 193, 765, + /* 490 */ 2, 55, 113, 111, 114, 112, 115, 116, 59, 568, + /* 500 */ 163, 106, 197, 5, 573, 107, 6, 65, 614, 19, + /* 510 */ 4, 20, 15, 208, 616, 7, 210, 500, 496, 494, + /* 520 */ 493, 492, 489, 463, 219, 68, 45, 71, 73, 22, + /* 530 */ 527, 526, 524, 54, 484, 482, 474, 480, 476, 478, + /* 540 */ 472, 470, 499, 498, 497, 495, 491, 490, 46, 461, + /* 550 */ 432, 430, 649, 648, 648, 648, 648, 648, 648, 648, + /* 560 */ 648, 648, 648, 648, 97, 98, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 225, 1, 259, 228, 229, 206, 207, 1, 233, 9, - /* 10 */ 235, 236, 237, 13, 14, 9, 16, 17, 208, 209, - /* 20 */ 20, 21, 259, 259, 24, 25, 26, 27, 28, 209, - /* 30 */ 5, 268, 269, 33, 34, 209, 259, 37, 38, 39, - /* 40 */ 13, 14, 243, 16, 17, 268, 269, 20, 21, 243, - /* 50 */ 209, 24, 25, 26, 27, 28, 257, 226, 33, 34, - /* 60 */ 33, 34, 259, 257, 37, 38, 39, 13, 14, 1, - /* 70 */ 16, 17, 269, 259, 20, 21, 245, 9, 24, 25, - /* 80 */ 26, 27, 28, 263, 72, 265, 260, 33, 34, 78, - /* 90 */ 78, 37, 38, 39, 209, 25, 26, 27, 28, 37, - /* 100 */ 38, 39, 102, 33, 34, 259, 265, 37, 38, 39, - /* 110 */ 209, 209, 209, 45, 46, 47, 48, 49, 50, 51, - /* 120 */ 52, 53, 54, 55, 56, 57, 99, 242, 14, 244, - /* 130 */ 16, 17, 209, 103, 20, 21, 209, 246, 24, 25, - /* 140 */ 26, 27, 28, 242, 242, 244, 244, 33, 34, 258, - /* 150 */ 120, 37, 38, 39, 98, 16, 17, 101, 102, 20, - /* 160 */ 21, 209, 239, 24, 25, 26, 27, 28, 265, 242, - /* 170 */ 267, 244, 33, 34, 226, 259, 37, 38, 39, 85, - /* 180 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, - /* 190 */ 96, 97, 225, 245, 227, 228, 229, 230, 231, 232, - /* 200 */ 233, 234, 235, 236, 237, 238, 1, 2, 44, 226, - /* 210 */ 5, 98, 7, 261, 9, 99, 1, 2, 105, 103, - /* 220 */ 5, 5, 7, 7, 9, 33, 34, 63, 245, 37, - /* 230 */ 38, 39, 209, 69, 70, 71, 115, 116, 33, 34, - /* 240 */ 63, 77, 37, 64, 65, 66, 67, 68, 33, 34, - /* 250 */ 1, 2, 37, 74, 5, 209, 7, 98, 9, 60, - /* 260 */ 61, 62, 98, 85, 105, 87, 88, 244, 213, 105, - /* 270 */ 92, 216, 94, 95, 96, 64, 65, 66, 67, 68, - /* 280 */ 15, 59, 33, 34, 213, 2, 126, 216, 5, 125, - /* 290 */ 7, 259, 9, 133, 134, 5, 132, 7, 64, 65, - /* 300 */ 66, 67, 68, 98, 127, 103, 213, 130, 131, 216, - /* 310 */ 108, 265, 99, 98, 109, 1, 33, 34, 99, 106, - /* 320 */ 98, 103, 103, 5, 109, 7, 99, 99, 99, 124, - /* 330 */ 103, 103, 103, 259, 99, 128, 129, 99, 103, 124, - /* 340 */ 122, 103, 99, 5, 259, 7, 103, 98, 128, 129, - /* 350 */ 259, 37, 72, 73, 259, 259, 259, 259, 109, 259, - /* 360 */ 259, 259, 259, 259, 245, 245, 240, 240, 240, 104, - /* 370 */ 240, 240, 240, 124, 241, 240, 209, 243, 209, 209, - /* 380 */ 209, 266, 209, 266, 247, 209, 105, 104, 243, 209, - /* 390 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 400 */ 209, 59, 209, 209, 209, 209, 209, 209, 109, 209, - /* 410 */ 209, 262, 209, 209, 262, 209, 262, 209, 209, 209, - /* 420 */ 119, 209, 256, 209, 121, 118, 209, 255, 254, 113, - /* 430 */ 209, 111, 209, 209, 209, 209, 117, 112, 110, 209, - /* 440 */ 123, 210, 210, 210, 75, 84, 83, 49, 80, 82, - /* 450 */ 53, 81, 210, 79, 75, 210, 5, 135, 5, 5, - /* 460 */ 210, 214, 214, 5, 135, 210, 5, 86, 211, 211, - /* 470 */ 126, 210, 218, 107, 222, 224, 223, 221, 219, 217, - /* 480 */ 220, 215, 212, 106, 243, 99, 103, 99, 251, 253, - /* 490 */ 250, 252, 98, 249, 248, 1, 103, 98, 114, 99, - /* 500 */ 98, 114, 99, 98, 103, 98, 100, 98, 104, 72, - /* 510 */ 100, 9, 5, 5, 5, 5, 5, 76, 15, 72, - /* 520 */ 16, 129, 103, 5, 129, 5, 99, 98, 5, 5, - /* 530 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* 540 */ 5, 5, 103, 76, 59, 58, 0, 270, 270, 270, - /* 550 */ 270, 270, 270, 270, 270, 270, 270, 270, 21, 21, - /* 560 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 570 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 580 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 590 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 600 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 610 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 620 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 630 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 640 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 650 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 660 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 670 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 680 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 690 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 700 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 710 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 720 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 730 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 740 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 750 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 760 */ 270, 270, 270, 270, 270, 270, + /* 0 */ 226, 1, 260, 229, 230, 207, 208, 1, 234, 9, + /* 10 */ 236, 237, 238, 13, 14, 9, 16, 17, 209, 210, + /* 20 */ 20, 21, 260, 1, 24, 25, 26, 27, 28, 260, + /* 30 */ 260, 9, 270, 33, 34, 260, 260, 37, 38, 39, + /* 40 */ 13, 14, 244, 16, 17, 269, 270, 20, 21, 260, + /* 50 */ 247, 24, 25, 26, 27, 28, 258, 5, 269, 270, + /* 60 */ 33, 34, 259, 210, 37, 38, 39, 45, 46, 47, + /* 70 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + /* 80 */ 13, 14, 60, 16, 17, 33, 34, 20, 21, 244, + /* 90 */ 66, 24, 25, 26, 27, 28, 243, 227, 245, 210, + /* 100 */ 33, 34, 102, 258, 37, 38, 39, 210, 14, 98, + /* 110 */ 16, 17, 101, 102, 20, 21, 246, 210, 24, 25, + /* 120 */ 26, 27, 28, 37, 38, 39, 99, 33, 34, 73, + /* 130 */ 246, 37, 38, 39, 78, 16, 17, 210, 78, 20, + /* 140 */ 21, 126, 245, 24, 25, 26, 27, 28, 133, 134, + /* 150 */ 261, 127, 33, 34, 130, 131, 37, 38, 39, 85, + /* 160 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, + /* 170 */ 96, 97, 226, 266, 228, 229, 230, 231, 232, 233, + /* 180 */ 234, 235, 236, 237, 238, 239, 1, 2, 210, 44, + /* 190 */ 5, 98, 7, 266, 9, 268, 1, 2, 105, 210, + /* 200 */ 5, 210, 7, 260, 9, 60, 1, 2, 227, 99, + /* 210 */ 5, 66, 7, 103, 9, 70, 71, 72, 33, 34, + /* 220 */ 33, 34, 37, 98, 37, 38, 39, 246, 33, 34, + /* 230 */ 105, 210, 37, 25, 26, 27, 28, 99, 33, 34, + /* 240 */ 262, 33, 34, 98, 106, 37, 38, 39, 260, 85, + /* 250 */ 105, 87, 88, 264, 210, 266, 92, 266, 94, 95, + /* 260 */ 96, 63, 64, 65, 243, 210, 245, 61, 62, 227, + /* 270 */ 125, 103, 210, 67, 68, 69, 108, 132, 61, 62, + /* 280 */ 5, 75, 7, 98, 67, 68, 69, 243, 246, 245, + /* 290 */ 61, 62, 1, 98, 109, 240, 67, 68, 69, 214, + /* 300 */ 59, 15, 217, 98, 109, 243, 5, 245, 7, 124, + /* 310 */ 214, 260, 214, 217, 109, 217, 5, 2, 7, 124, + /* 320 */ 5, 99, 7, 103, 9, 103, 115, 116, 37, 124, + /* 330 */ 99, 99, 99, 103, 103, 103, 103, 99, 5, 98, + /* 340 */ 7, 103, 122, 99, 128, 129, 267, 103, 33, 34, + /* 350 */ 120, 99, 128, 129, 241, 103, 73, 74, 61, 62, + /* 360 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, + /* 370 */ 246, 260, 241, 241, 241, 241, 241, 210, 242, 210, + /* 380 */ 241, 244, 210, 210, 267, 210, 210, 210, 248, 210, + /* 390 */ 104, 210, 210, 210, 210, 105, 210, 244, 210, 210, + /* 400 */ 210, 210, 210, 210, 210, 59, 210, 210, 109, 210, + /* 410 */ 210, 210, 210, 210, 210, 263, 257, 210, 263, 104, + /* 420 */ 210, 263, 210, 210, 210, 210, 119, 121, 210, 210, + /* 430 */ 256, 210, 118, 210, 113, 210, 210, 210, 210, 117, + /* 440 */ 112, 111, 110, 123, 210, 76, 211, 211, 211, 84, + /* 450 */ 83, 49, 80, 82, 53, 81, 79, 76, 211, 5, + /* 460 */ 211, 135, 5, 5, 255, 215, 215, 211, 5, 135, + /* 470 */ 211, 5, 212, 86, 211, 126, 219, 223, 225, 224, + /* 480 */ 222, 220, 218, 221, 212, 211, 216, 99, 106, 244, + /* 490 */ 213, 107, 252, 254, 251, 253, 250, 249, 103, 99, + /* 500 */ 1, 98, 98, 114, 99, 98, 114, 73, 99, 103, + /* 510 */ 98, 103, 98, 100, 104, 98, 100, 9, 5, 5, + /* 520 */ 5, 5, 5, 77, 15, 73, 16, 129, 129, 103, + /* 530 */ 5, 5, 99, 98, 5, 5, 5, 5, 5, 5, + /* 540 */ 5, 5, 5, 5, 5, 5, 5, 5, 103, 77, + /* 550 */ 59, 58, 0, 271, 271, 271, 271, 271, 271, 271, + /* 560 */ 271, 271, 271, 271, 21, 21, 271, 271, 271, 271, + /* 570 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 580 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 590 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 600 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 610 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 620 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 630 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 640 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 650 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 660 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 670 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 680 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 690 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 700 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 710 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 720 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 730 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 740 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 750 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 760 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 770 */ 271, 271, }; -#define YY_SHIFT_COUNT (247) +#define YY_SHIFT_COUNT (251) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (546) +#define YY_SHIFT_MAX (552) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 164, 94, 178, 205, 249, 6, 6, 6, 6, 6, - /* 10 */ 6, 0, 68, 249, 283, 283, 283, 113, 6, 6, - /* 20 */ 6, 6, 6, 12, 11, 11, 560, 215, 249, 249, - /* 30 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, - /* 40 */ 249, 249, 249, 249, 249, 283, 283, 25, 25, 25, - /* 50 */ 25, 25, 25, 56, 25, 159, 6, 6, 6, 6, - /* 60 */ 121, 121, 202, 6, 6, 6, 6, 6, 6, 6, + /* 0 */ 145, 74, 164, 185, 205, 6, 6, 6, 6, 6, + /* 10 */ 6, 0, 22, 205, 315, 315, 315, 93, 6, 6, + /* 20 */ 6, 6, 6, 56, 60, 60, 566, 195, 205, 205, + /* 30 */ 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, + /* 40 */ 205, 205, 205, 205, 205, 315, 315, 52, 52, 52, + /* 50 */ 52, 52, 52, 11, 52, 125, 6, 6, 6, 6, + /* 60 */ 211, 211, 168, 6, 6, 6, 6, 6, 6, 6, /* 70 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, /* 80 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, /* 90 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - /* 100 */ 281, 342, 342, 299, 299, 299, 342, 301, 303, 307, - /* 110 */ 316, 319, 325, 320, 328, 317, 281, 342, 342, 369, - /* 120 */ 369, 342, 361, 363, 398, 368, 367, 397, 370, 374, - /* 130 */ 342, 379, 342, 379, 560, 560, 27, 54, 54, 54, - /* 140 */ 114, 139, 70, 70, 70, 179, 192, 192, 192, 192, - /* 150 */ 211, 234, 177, 160, 62, 62, 199, 213, 116, 219, - /* 160 */ 227, 228, 229, 216, 290, 314, 222, 265, 218, 30, - /* 170 */ 235, 238, 243, 207, 220, 318, 338, 280, 451, 322, - /* 180 */ 453, 454, 329, 458, 461, 381, 344, 377, 386, 366, - /* 190 */ 383, 388, 394, 494, 399, 400, 402, 393, 384, 401, - /* 200 */ 387, 403, 405, 404, 407, 406, 409, 410, 437, 502, - /* 210 */ 507, 508, 509, 510, 511, 441, 503, 447, 504, 392, - /* 220 */ 395, 419, 518, 520, 427, 429, 419, 523, 524, 525, - /* 230 */ 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, - /* 240 */ 536, 439, 467, 537, 538, 485, 487, 546, + /* 100 */ 6, 6, 290, 346, 346, 299, 299, 299, 346, 307, + /* 110 */ 306, 314, 321, 322, 328, 330, 332, 320, 290, 346, + /* 120 */ 346, 369, 369, 346, 365, 367, 402, 372, 371, 401, + /* 130 */ 374, 377, 346, 381, 346, 381, 346, 566, 566, 27, + /* 140 */ 67, 67, 67, 94, 119, 208, 208, 208, 206, 187, + /* 150 */ 187, 187, 187, 217, 229, 24, 15, 86, 86, 198, + /* 160 */ 138, 110, 222, 231, 232, 233, 275, 311, 291, 241, + /* 170 */ 286, 220, 230, 238, 244, 252, 216, 224, 301, 333, + /* 180 */ 283, 297, 454, 326, 457, 458, 334, 463, 466, 387, + /* 190 */ 349, 382, 388, 384, 395, 400, 403, 499, 404, 405, + /* 200 */ 407, 406, 389, 408, 392, 409, 412, 410, 414, 413, + /* 210 */ 417, 416, 434, 508, 513, 514, 515, 516, 517, 446, + /* 220 */ 509, 452, 510, 398, 399, 426, 525, 526, 433, 435, + /* 230 */ 426, 529, 530, 531, 532, 533, 534, 535, 536, 537, + /* 240 */ 538, 539, 540, 541, 542, 445, 472, 543, 544, 491, + /* 250 */ 493, 552, }; -#define YY_REDUCE_COUNT (135) -#define YY_REDUCE_MIN (-257) -#define YY_REDUCE_MAX (270) +#define YY_REDUCE_COUNT (138) +#define YY_REDUCE_MIN (-258) +#define YY_REDUCE_MAX (277) static const short yy_reduce_ofst[] = { - /* 0 */ -201, -33, -225, -237, -223, -97, -180, -115, -99, -98, - /* 10 */ -73, -174, -190, -197, -169, -52, -17, -194, -48, -159, - /* 20 */ 46, -77, 23, 55, 71, 93, -109, -257, -236, -186, - /* 30 */ -154, -84, 32, 74, 85, 91, 95, 96, 97, 98, - /* 40 */ 100, 101, 102, 103, 104, 119, 120, 126, 127, 128, - /* 50 */ 130, 131, 132, 133, 135, 134, 167, 169, 170, 171, - /* 60 */ 115, 117, 137, 173, 176, 180, 181, 182, 183, 184, - /* 70 */ 185, 186, 187, 188, 189, 190, 191, 193, 194, 195, - /* 80 */ 196, 197, 198, 200, 201, 203, 204, 206, 208, 209, - /* 90 */ 210, 212, 214, 217, 221, 223, 224, 225, 226, 230, - /* 100 */ 145, 231, 232, 149, 152, 154, 233, 166, 172, 174, - /* 110 */ 236, 239, 237, 240, 244, 246, 241, 242, 245, 247, - /* 120 */ 248, 250, 251, 253, 252, 254, 256, 259, 260, 262, - /* 130 */ 255, 257, 261, 258, 266, 270, + /* 0 */ -202, -54, -226, -224, -211, -73, -11, -147, 21, 44, + /* 10 */ 62, -111, -191, -238, -130, -19, 42, -155, -22, -93, + /* 20 */ -9, 55, -103, 85, 96, 98, -197, -258, -231, -230, + /* 30 */ -225, -57, -12, 51, 100, 101, 102, 103, 104, 105, + /* 40 */ 106, 107, 108, 109, 111, -116, 124, 113, 131, 132, + /* 50 */ 133, 134, 135, 136, 139, 137, 167, 169, 172, 173, + /* 60 */ 79, 117, 140, 175, 176, 177, 179, 181, 182, 183, + /* 70 */ 184, 186, 188, 189, 190, 191, 192, 193, 194, 196, + /* 80 */ 197, 199, 200, 201, 202, 203, 204, 207, 210, 212, + /* 90 */ 213, 214, 215, 218, 219, 221, 223, 225, 226, 227, + /* 100 */ 228, 234, 153, 235, 236, 152, 155, 158, 237, 159, + /* 110 */ 174, 209, 239, 242, 240, 243, 246, 248, 245, 247, + /* 120 */ 249, 250, 251, 256, 253, 255, 254, 257, 258, 261, + /* 130 */ 262, 264, 259, 260, 263, 272, 274, 270, 277, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 638, 690, 679, 858, 858, 638, 638, 638, 638, 638, - /* 10 */ 638, 783, 656, 858, 638, 638, 638, 638, 638, 638, - /* 20 */ 638, 638, 638, 692, 692, 692, 778, 638, 638, 638, - /* 30 */ 638, 638, 638, 638, 638, 638, 638, 638, 638, 638, - /* 40 */ 638, 638, 638, 638, 638, 638, 638, 638, 638, 638, - /* 50 */ 638, 638, 638, 638, 638, 638, 638, 785, 787, 638, - /* 60 */ 805, 805, 776, 638, 638, 638, 638, 638, 638, 638, - /* 70 */ 638, 638, 638, 638, 638, 638, 638, 638, 638, 638, - /* 80 */ 638, 677, 638, 675, 638, 638, 638, 638, 638, 638, - /* 90 */ 638, 638, 638, 638, 638, 638, 638, 664, 638, 638, - /* 100 */ 638, 658, 658, 638, 638, 638, 658, 812, 816, 810, - /* 110 */ 798, 806, 797, 793, 792, 820, 638, 658, 658, 687, - /* 120 */ 687, 658, 708, 706, 704, 696, 702, 698, 700, 694, - /* 130 */ 658, 685, 658, 685, 724, 738, 638, 821, 857, 811, - /* 140 */ 847, 846, 853, 845, 844, 638, 840, 841, 843, 842, - /* 150 */ 638, 638, 638, 638, 849, 848, 638, 638, 638, 638, - /* 160 */ 638, 638, 638, 638, 638, 638, 823, 638, 817, 813, - /* 170 */ 638, 638, 638, 638, 638, 638, 638, 638, 638, 638, - /* 180 */ 638, 638, 638, 638, 638, 638, 638, 775, 638, 638, - /* 190 */ 784, 638, 638, 638, 638, 638, 638, 807, 638, 799, - /* 200 */ 638, 638, 638, 638, 638, 638, 638, 752, 638, 638, - /* 210 */ 638, 638, 638, 638, 638, 638, 638, 638, 638, 638, - /* 220 */ 638, 862, 638, 638, 638, 746, 860, 638, 638, 638, - /* 230 */ 638, 638, 638, 638, 638, 638, 638, 638, 638, 638, - /* 240 */ 638, 711, 638, 662, 660, 638, 654, 638, + /* 0 */ 646, 700, 689, 868, 868, 646, 646, 646, 646, 646, + /* 10 */ 646, 793, 664, 868, 646, 646, 646, 646, 646, 646, + /* 20 */ 646, 646, 646, 702, 702, 702, 788, 646, 646, 646, + /* 30 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 646, + /* 40 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 646, + /* 50 */ 646, 646, 646, 646, 646, 646, 646, 795, 797, 646, + /* 60 */ 815, 815, 786, 646, 646, 646, 646, 646, 646, 646, + /* 70 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 646, + /* 80 */ 646, 687, 646, 685, 646, 646, 646, 646, 646, 646, + /* 90 */ 646, 646, 646, 646, 646, 646, 674, 646, 646, 646, + /* 100 */ 646, 646, 646, 666, 666, 646, 646, 646, 666, 822, + /* 110 */ 826, 820, 808, 816, 807, 803, 802, 830, 646, 666, + /* 120 */ 666, 697, 697, 666, 718, 716, 714, 706, 712, 708, + /* 130 */ 710, 704, 666, 695, 666, 695, 666, 734, 748, 646, + /* 140 */ 831, 867, 821, 857, 856, 863, 855, 854, 646, 850, + /* 150 */ 851, 853, 852, 646, 646, 646, 646, 859, 858, 646, + /* 160 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 833, + /* 170 */ 646, 827, 823, 646, 646, 646, 646, 646, 646, 646, + /* 180 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 646, + /* 190 */ 646, 785, 646, 646, 794, 646, 646, 646, 646, 646, + /* 200 */ 646, 817, 646, 809, 646, 646, 646, 646, 646, 646, + /* 210 */ 646, 762, 646, 646, 646, 646, 646, 646, 646, 646, + /* 220 */ 646, 646, 646, 646, 646, 872, 646, 646, 646, 756, + /* 230 */ 870, 646, 646, 646, 646, 646, 646, 646, 646, 646, + /* 240 */ 646, 646, 646, 646, 646, 721, 646, 672, 670, 646, + /* 250 */ 662, 646, }; /********** End of lemon-generated parsing tables *****************************/ @@ -506,12 +499,13 @@ static const YYCODETYPE yyFallback[] = { 0, /* VNODES => nothing */ 1, /* IPTOKEN => ID */ 0, /* DOT => nothing */ + 0, /* CREATE => nothing */ + 0, /* TABLE => nothing */ + 1, /* DATABASE => ID */ 0, /* TABLES => nothing */ 0, /* STABLES => nothing */ 0, /* VGROUPS => nothing */ 0, /* DROP => nothing */ - 0, /* TABLE => nothing */ - 1, /* DATABASE => ID */ 0, /* DNODE => nothing */ 0, /* USER => nothing */ 0, /* ACCOUNT => nothing */ @@ -523,7 +517,6 @@ static const YYCODETYPE yyFallback[] = { 0, /* LOCAL => nothing */ 0, /* IF => nothing */ 0, /* EXISTS => nothing */ - 0, /* CREATE => nothing */ 0, /* PPS => nothing */ 0, /* TSERIES => nothing */ 0, /* DBS => nothing */ @@ -691,7 +684,6 @@ struct yyParser { int yyerrcnt; /* Shifts left before out of the error */ #endif ParseARG_SDECL /* A place to hold %extra_argument */ - ParseCTX_SDECL /* A place to hold %extra_context */ #if YYSTACKDEPTH<=0 int yystksz; /* Current side of the stack */ yyStackEntry *yystack; /* The parser's stack */ @@ -799,24 +791,24 @@ static const char *const yyTokenName[] = { /* 57 */ "VNODES", /* 58 */ "IPTOKEN", /* 59 */ "DOT", - /* 60 */ "TABLES", - /* 61 */ "STABLES", - /* 62 */ "VGROUPS", - /* 63 */ "DROP", - /* 64 */ "TABLE", - /* 65 */ "DATABASE", - /* 66 */ "DNODE", - /* 67 */ "USER", - /* 68 */ "ACCOUNT", - /* 69 */ "USE", - /* 70 */ "DESCRIBE", - /* 71 */ "ALTER", - /* 72 */ "PASS", - /* 73 */ "PRIVILEGE", - /* 74 */ "LOCAL", - /* 75 */ "IF", - /* 76 */ "EXISTS", - /* 77 */ "CREATE", + /* 60 */ "CREATE", + /* 61 */ "TABLE", + /* 62 */ "DATABASE", + /* 63 */ "TABLES", + /* 64 */ "STABLES", + /* 65 */ "VGROUPS", + /* 66 */ "DROP", + /* 67 */ "DNODE", + /* 68 */ "USER", + /* 69 */ "ACCOUNT", + /* 70 */ "USE", + /* 71 */ "DESCRIBE", + /* 72 */ "ALTER", + /* 73 */ "PASS", + /* 74 */ "PRIVILEGE", + /* 75 */ "LOCAL", + /* 76 */ "IF", + /* 77 */ "EXISTS", /* 78 */ "PPS", /* 79 */ "TSERIES", /* 80 */ "DBS", @@ -945,70 +937,71 @@ static const char *const yyTokenName[] = { /* 203 */ "INSERT", /* 204 */ "INTO", /* 205 */ "VALUES", - /* 206 */ "program", - /* 207 */ "cmd", - /* 208 */ "dbPrefix", - /* 209 */ "ids", - /* 210 */ "cpxName", - /* 211 */ "ifexists", - /* 212 */ "alter_db_optr", - /* 213 */ "acct_optr", - /* 214 */ "ifnotexists", - /* 215 */ "db_optr", - /* 216 */ "pps", - /* 217 */ "tseries", - /* 218 */ "dbs", - /* 219 */ "streams", - /* 220 */ "storage", - /* 221 */ "qtime", - /* 222 */ "users", - /* 223 */ "conns", - /* 224 */ "state", - /* 225 */ "keep", - /* 226 */ "tagitemlist", - /* 227 */ "cache", - /* 228 */ "replica", - /* 229 */ "quorum", - /* 230 */ "days", - /* 231 */ "minrows", - /* 232 */ "maxrows", - /* 233 */ "blocks", - /* 234 */ "ctime", - /* 235 */ "wal", - /* 236 */ "fsync", - /* 237 */ "comp", - /* 238 */ "prec", - /* 239 */ "typename", - /* 240 */ "signed", - /* 241 */ "create_table_args", - /* 242 */ "columnlist", - /* 243 */ "select", - /* 244 */ "column", - /* 245 */ "tagitem", - /* 246 */ "selcollist", - /* 247 */ "from", - /* 248 */ "where_opt", - /* 249 */ "interval_opt", - /* 250 */ "fill_opt", - /* 251 */ "sliding_opt", - /* 252 */ "groupby_opt", - /* 253 */ "orderby_opt", - /* 254 */ "having_opt", - /* 255 */ "slimit_opt", - /* 256 */ "limit_opt", - /* 257 */ "union", - /* 258 */ "sclp", - /* 259 */ "expr", - /* 260 */ "as", - /* 261 */ "tablelist", - /* 262 */ "tmvar", - /* 263 */ "sortlist", - /* 264 */ "sortitem", - /* 265 */ "item", - /* 266 */ "sortorder", - /* 267 */ "grouplist", - /* 268 */ "exprlist", - /* 269 */ "expritem", + /* 206 */ "error", + /* 207 */ "program", + /* 208 */ "cmd", + /* 209 */ "dbPrefix", + /* 210 */ "ids", + /* 211 */ "cpxName", + /* 212 */ "ifexists", + /* 213 */ "alter_db_optr", + /* 214 */ "acct_optr", + /* 215 */ "ifnotexists", + /* 216 */ "db_optr", + /* 217 */ "pps", + /* 218 */ "tseries", + /* 219 */ "dbs", + /* 220 */ "streams", + /* 221 */ "storage", + /* 222 */ "qtime", + /* 223 */ "users", + /* 224 */ "conns", + /* 225 */ "state", + /* 226 */ "keep", + /* 227 */ "tagitemlist", + /* 228 */ "cache", + /* 229 */ "replica", + /* 230 */ "quorum", + /* 231 */ "days", + /* 232 */ "minrows", + /* 233 */ "maxrows", + /* 234 */ "blocks", + /* 235 */ "ctime", + /* 236 */ "wal", + /* 237 */ "fsync", + /* 238 */ "comp", + /* 239 */ "prec", + /* 240 */ "typename", + /* 241 */ "signed", + /* 242 */ "create_table_args", + /* 243 */ "columnlist", + /* 244 */ "select", + /* 245 */ "column", + /* 246 */ "tagitem", + /* 247 */ "selcollist", + /* 248 */ "from", + /* 249 */ "where_opt", + /* 250 */ "interval_opt", + /* 251 */ "fill_opt", + /* 252 */ "sliding_opt", + /* 253 */ "groupby_opt", + /* 254 */ "orderby_opt", + /* 255 */ "having_opt", + /* 256 */ "slimit_opt", + /* 257 */ "limit_opt", + /* 258 */ "union", + /* 259 */ "sclp", + /* 260 */ "expr", + /* 261 */ "as", + /* 262 */ "tablelist", + /* 263 */ "tmvar", + /* 264 */ "sortlist", + /* 265 */ "sortitem", + /* 266 */ "item", + /* 267 */ "sortorder", + /* 268 */ "grouplist", + /* 269 */ "exprlist", + /* 270 */ "expritem", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1035,215 +1028,217 @@ static const char *const yyRuleName[] = { /* 16 */ "dbPrefix ::= ids DOT", /* 17 */ "cpxName ::=", /* 18 */ "cpxName ::= DOT ids", - /* 19 */ "cmd ::= SHOW dbPrefix TABLES", - /* 20 */ "cmd ::= SHOW dbPrefix TABLES LIKE ids", - /* 21 */ "cmd ::= SHOW dbPrefix STABLES", - /* 22 */ "cmd ::= SHOW dbPrefix STABLES LIKE ids", - /* 23 */ "cmd ::= SHOW dbPrefix VGROUPS", - /* 24 */ "cmd ::= SHOW dbPrefix VGROUPS ids", - /* 25 */ "cmd ::= DROP TABLE ifexists ids cpxName", - /* 26 */ "cmd ::= DROP DATABASE ifexists ids", - /* 27 */ "cmd ::= DROP DNODE ids", - /* 28 */ "cmd ::= DROP USER ids", - /* 29 */ "cmd ::= DROP ACCOUNT ids", - /* 30 */ "cmd ::= USE ids", - /* 31 */ "cmd ::= DESCRIBE ids cpxName", - /* 32 */ "cmd ::= ALTER USER ids PASS ids", - /* 33 */ "cmd ::= ALTER USER ids PRIVILEGE ids", - /* 34 */ "cmd ::= ALTER DNODE ids ids", - /* 35 */ "cmd ::= ALTER DNODE ids ids ids", - /* 36 */ "cmd ::= ALTER LOCAL ids", - /* 37 */ "cmd ::= ALTER LOCAL ids ids", - /* 38 */ "cmd ::= ALTER DATABASE ids alter_db_optr", - /* 39 */ "cmd ::= ALTER ACCOUNT ids acct_optr", - /* 40 */ "cmd ::= ALTER ACCOUNT ids PASS ids acct_optr", - /* 41 */ "ids ::= ID", - /* 42 */ "ids ::= STRING", - /* 43 */ "ifexists ::= IF EXISTS", - /* 44 */ "ifexists ::=", - /* 45 */ "ifnotexists ::= IF NOT EXISTS", - /* 46 */ "ifnotexists ::=", - /* 47 */ "cmd ::= CREATE DNODE ids", - /* 48 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", - /* 49 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", - /* 50 */ "cmd ::= CREATE USER ids PASS ids", - /* 51 */ "pps ::=", - /* 52 */ "pps ::= PPS INTEGER", - /* 53 */ "tseries ::=", - /* 54 */ "tseries ::= TSERIES INTEGER", - /* 55 */ "dbs ::=", - /* 56 */ "dbs ::= DBS INTEGER", - /* 57 */ "streams ::=", - /* 58 */ "streams ::= STREAMS INTEGER", - /* 59 */ "storage ::=", - /* 60 */ "storage ::= STORAGE INTEGER", - /* 61 */ "qtime ::=", - /* 62 */ "qtime ::= QTIME INTEGER", - /* 63 */ "users ::=", - /* 64 */ "users ::= USERS INTEGER", - /* 65 */ "conns ::=", - /* 66 */ "conns ::= CONNS INTEGER", - /* 67 */ "state ::=", - /* 68 */ "state ::= STATE ids", - /* 69 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", - /* 70 */ "keep ::= KEEP tagitemlist", - /* 71 */ "cache ::= CACHE INTEGER", - /* 72 */ "replica ::= REPLICA INTEGER", - /* 73 */ "quorum ::= QUORUM INTEGER", - /* 74 */ "days ::= DAYS INTEGER", - /* 75 */ "minrows ::= MINROWS INTEGER", - /* 76 */ "maxrows ::= MAXROWS INTEGER", - /* 77 */ "blocks ::= BLOCKS INTEGER", - /* 78 */ "ctime ::= CTIME INTEGER", - /* 79 */ "wal ::= WAL INTEGER", - /* 80 */ "fsync ::= FSYNC INTEGER", - /* 81 */ "comp ::= COMP INTEGER", - /* 82 */ "prec ::= PRECISION STRING", - /* 83 */ "db_optr ::=", - /* 84 */ "db_optr ::= db_optr cache", - /* 85 */ "db_optr ::= db_optr replica", - /* 86 */ "db_optr ::= db_optr quorum", - /* 87 */ "db_optr ::= db_optr days", - /* 88 */ "db_optr ::= db_optr minrows", - /* 89 */ "db_optr ::= db_optr maxrows", - /* 90 */ "db_optr ::= db_optr blocks", - /* 91 */ "db_optr ::= db_optr ctime", - /* 92 */ "db_optr ::= db_optr wal", - /* 93 */ "db_optr ::= db_optr fsync", - /* 94 */ "db_optr ::= db_optr comp", - /* 95 */ "db_optr ::= db_optr prec", - /* 96 */ "db_optr ::= db_optr keep", - /* 97 */ "alter_db_optr ::=", - /* 98 */ "alter_db_optr ::= alter_db_optr replica", - /* 99 */ "alter_db_optr ::= alter_db_optr quorum", - /* 100 */ "alter_db_optr ::= alter_db_optr keep", - /* 101 */ "alter_db_optr ::= alter_db_optr blocks", - /* 102 */ "alter_db_optr ::= alter_db_optr comp", - /* 103 */ "alter_db_optr ::= alter_db_optr wal", - /* 104 */ "alter_db_optr ::= alter_db_optr fsync", - /* 105 */ "typename ::= ids", - /* 106 */ "typename ::= ids LP signed RP", - /* 107 */ "signed ::= INTEGER", - /* 108 */ "signed ::= PLUS INTEGER", - /* 109 */ "signed ::= MINUS INTEGER", - /* 110 */ "cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args", - /* 111 */ "create_table_args ::= LP columnlist RP", - /* 112 */ "create_table_args ::= LP columnlist RP TAGS LP columnlist RP", - /* 113 */ "create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP", - /* 114 */ "create_table_args ::= AS select", - /* 115 */ "columnlist ::= columnlist COMMA column", - /* 116 */ "columnlist ::= column", - /* 117 */ "column ::= ids typename", - /* 118 */ "tagitemlist ::= tagitemlist COMMA tagitem", - /* 119 */ "tagitemlist ::= tagitem", - /* 120 */ "tagitem ::= INTEGER", - /* 121 */ "tagitem ::= FLOAT", - /* 122 */ "tagitem ::= STRING", - /* 123 */ "tagitem ::= BOOL", - /* 124 */ "tagitem ::= NULL", - /* 125 */ "tagitem ::= MINUS INTEGER", - /* 126 */ "tagitem ::= MINUS FLOAT", - /* 127 */ "tagitem ::= PLUS INTEGER", - /* 128 */ "tagitem ::= PLUS FLOAT", - /* 129 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", - /* 130 */ "union ::= select", - /* 131 */ "union ::= LP union RP", - /* 132 */ "union ::= union UNION ALL select", - /* 133 */ "union ::= union UNION ALL LP select RP", - /* 134 */ "cmd ::= union", - /* 135 */ "select ::= SELECT selcollist", - /* 136 */ "sclp ::= selcollist COMMA", - /* 137 */ "sclp ::=", - /* 138 */ "selcollist ::= sclp expr as", - /* 139 */ "selcollist ::= sclp STAR", - /* 140 */ "as ::= AS ids", - /* 141 */ "as ::= ids", - /* 142 */ "as ::=", - /* 143 */ "from ::= FROM tablelist", - /* 144 */ "tablelist ::= ids cpxName", - /* 145 */ "tablelist ::= ids cpxName ids", - /* 146 */ "tablelist ::= tablelist COMMA ids cpxName", - /* 147 */ "tablelist ::= tablelist COMMA ids cpxName ids", - /* 148 */ "tmvar ::= VARIABLE", - /* 149 */ "interval_opt ::= INTERVAL LP tmvar RP", - /* 150 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", - /* 151 */ "interval_opt ::=", - /* 152 */ "fill_opt ::=", - /* 153 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 154 */ "fill_opt ::= FILL LP ID RP", - /* 155 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 156 */ "sliding_opt ::=", - /* 157 */ "orderby_opt ::=", - /* 158 */ "orderby_opt ::= ORDER BY sortlist", - /* 159 */ "sortlist ::= sortlist COMMA item sortorder", - /* 160 */ "sortlist ::= item sortorder", - /* 161 */ "item ::= ids cpxName", - /* 162 */ "sortorder ::= ASC", - /* 163 */ "sortorder ::= DESC", - /* 164 */ "sortorder ::=", - /* 165 */ "groupby_opt ::=", - /* 166 */ "groupby_opt ::= GROUP BY grouplist", - /* 167 */ "grouplist ::= grouplist COMMA item", - /* 168 */ "grouplist ::= item", - /* 169 */ "having_opt ::=", - /* 170 */ "having_opt ::= HAVING expr", - /* 171 */ "limit_opt ::=", - /* 172 */ "limit_opt ::= LIMIT signed", - /* 173 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 174 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 175 */ "slimit_opt ::=", - /* 176 */ "slimit_opt ::= SLIMIT signed", - /* 177 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 178 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 179 */ "where_opt ::=", - /* 180 */ "where_opt ::= WHERE expr", - /* 181 */ "expr ::= LP expr RP", - /* 182 */ "expr ::= ID", - /* 183 */ "expr ::= ID DOT ID", - /* 184 */ "expr ::= ID DOT STAR", - /* 185 */ "expr ::= INTEGER", - /* 186 */ "expr ::= MINUS INTEGER", - /* 187 */ "expr ::= PLUS INTEGER", - /* 188 */ "expr ::= FLOAT", - /* 189 */ "expr ::= MINUS FLOAT", - /* 190 */ "expr ::= PLUS FLOAT", - /* 191 */ "expr ::= STRING", - /* 192 */ "expr ::= NOW", - /* 193 */ "expr ::= VARIABLE", - /* 194 */ "expr ::= BOOL", - /* 195 */ "expr ::= ID LP exprlist RP", - /* 196 */ "expr ::= ID LP STAR RP", - /* 197 */ "expr ::= expr IS NULL", - /* 198 */ "expr ::= expr IS NOT NULL", - /* 199 */ "expr ::= expr LT expr", - /* 200 */ "expr ::= expr GT expr", - /* 201 */ "expr ::= expr LE expr", - /* 202 */ "expr ::= expr GE expr", - /* 203 */ "expr ::= expr NE expr", - /* 204 */ "expr ::= expr EQ expr", - /* 205 */ "expr ::= expr AND expr", - /* 206 */ "expr ::= expr OR expr", - /* 207 */ "expr ::= expr PLUS expr", - /* 208 */ "expr ::= expr MINUS expr", - /* 209 */ "expr ::= expr STAR expr", - /* 210 */ "expr ::= expr SLASH expr", - /* 211 */ "expr ::= expr REM expr", - /* 212 */ "expr ::= expr LIKE expr", - /* 213 */ "expr ::= expr IN LP exprlist RP", - /* 214 */ "exprlist ::= exprlist COMMA expritem", - /* 215 */ "exprlist ::= expritem", - /* 216 */ "expritem ::= expr", - /* 217 */ "expritem ::=", - /* 218 */ "cmd ::= RESET QUERY CACHE", - /* 219 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 220 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 221 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 222 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 223 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 224 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 225 */ "cmd ::= KILL CONNECTION INTEGER", - /* 226 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 227 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 19 */ "cmd ::= SHOW CREATE TABLE ids cpxName", + /* 20 */ "cmd ::= SHOW CREATE DATABASE ids", + /* 21 */ "cmd ::= SHOW dbPrefix TABLES", + /* 22 */ "cmd ::= SHOW dbPrefix TABLES LIKE ids", + /* 23 */ "cmd ::= SHOW dbPrefix STABLES", + /* 24 */ "cmd ::= SHOW dbPrefix STABLES LIKE ids", + /* 25 */ "cmd ::= SHOW dbPrefix VGROUPS", + /* 26 */ "cmd ::= SHOW dbPrefix VGROUPS ids", + /* 27 */ "cmd ::= DROP TABLE ifexists ids cpxName", + /* 28 */ "cmd ::= DROP DATABASE ifexists ids", + /* 29 */ "cmd ::= DROP DNODE ids", + /* 30 */ "cmd ::= DROP USER ids", + /* 31 */ "cmd ::= DROP ACCOUNT ids", + /* 32 */ "cmd ::= USE ids", + /* 33 */ "cmd ::= DESCRIBE ids cpxName", + /* 34 */ "cmd ::= ALTER USER ids PASS ids", + /* 35 */ "cmd ::= ALTER USER ids PRIVILEGE ids", + /* 36 */ "cmd ::= ALTER DNODE ids ids", + /* 37 */ "cmd ::= ALTER DNODE ids ids ids", + /* 38 */ "cmd ::= ALTER LOCAL ids", + /* 39 */ "cmd ::= ALTER LOCAL ids ids", + /* 40 */ "cmd ::= ALTER DATABASE ids alter_db_optr", + /* 41 */ "cmd ::= ALTER ACCOUNT ids acct_optr", + /* 42 */ "cmd ::= ALTER ACCOUNT ids PASS ids acct_optr", + /* 43 */ "ids ::= ID", + /* 44 */ "ids ::= STRING", + /* 45 */ "ifexists ::= IF EXISTS", + /* 46 */ "ifexists ::=", + /* 47 */ "ifnotexists ::= IF NOT EXISTS", + /* 48 */ "ifnotexists ::=", + /* 49 */ "cmd ::= CREATE DNODE ids", + /* 50 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", + /* 51 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", + /* 52 */ "cmd ::= CREATE USER ids PASS ids", + /* 53 */ "pps ::=", + /* 54 */ "pps ::= PPS INTEGER", + /* 55 */ "tseries ::=", + /* 56 */ "tseries ::= TSERIES INTEGER", + /* 57 */ "dbs ::=", + /* 58 */ "dbs ::= DBS INTEGER", + /* 59 */ "streams ::=", + /* 60 */ "streams ::= STREAMS INTEGER", + /* 61 */ "storage ::=", + /* 62 */ "storage ::= STORAGE INTEGER", + /* 63 */ "qtime ::=", + /* 64 */ "qtime ::= QTIME INTEGER", + /* 65 */ "users ::=", + /* 66 */ "users ::= USERS INTEGER", + /* 67 */ "conns ::=", + /* 68 */ "conns ::= CONNS INTEGER", + /* 69 */ "state ::=", + /* 70 */ "state ::= STATE ids", + /* 71 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", + /* 72 */ "keep ::= KEEP tagitemlist", + /* 73 */ "cache ::= CACHE INTEGER", + /* 74 */ "replica ::= REPLICA INTEGER", + /* 75 */ "quorum ::= QUORUM INTEGER", + /* 76 */ "days ::= DAYS INTEGER", + /* 77 */ "minrows ::= MINROWS INTEGER", + /* 78 */ "maxrows ::= MAXROWS INTEGER", + /* 79 */ "blocks ::= BLOCKS INTEGER", + /* 80 */ "ctime ::= CTIME INTEGER", + /* 81 */ "wal ::= WAL INTEGER", + /* 82 */ "fsync ::= FSYNC INTEGER", + /* 83 */ "comp ::= COMP INTEGER", + /* 84 */ "prec ::= PRECISION STRING", + /* 85 */ "db_optr ::=", + /* 86 */ "db_optr ::= db_optr cache", + /* 87 */ "db_optr ::= db_optr replica", + /* 88 */ "db_optr ::= db_optr quorum", + /* 89 */ "db_optr ::= db_optr days", + /* 90 */ "db_optr ::= db_optr minrows", + /* 91 */ "db_optr ::= db_optr maxrows", + /* 92 */ "db_optr ::= db_optr blocks", + /* 93 */ "db_optr ::= db_optr ctime", + /* 94 */ "db_optr ::= db_optr wal", + /* 95 */ "db_optr ::= db_optr fsync", + /* 96 */ "db_optr ::= db_optr comp", + /* 97 */ "db_optr ::= db_optr prec", + /* 98 */ "db_optr ::= db_optr keep", + /* 99 */ "alter_db_optr ::=", + /* 100 */ "alter_db_optr ::= alter_db_optr replica", + /* 101 */ "alter_db_optr ::= alter_db_optr quorum", + /* 102 */ "alter_db_optr ::= alter_db_optr keep", + /* 103 */ "alter_db_optr ::= alter_db_optr blocks", + /* 104 */ "alter_db_optr ::= alter_db_optr comp", + /* 105 */ "alter_db_optr ::= alter_db_optr wal", + /* 106 */ "alter_db_optr ::= alter_db_optr fsync", + /* 107 */ "typename ::= ids", + /* 108 */ "typename ::= ids LP signed RP", + /* 109 */ "signed ::= INTEGER", + /* 110 */ "signed ::= PLUS INTEGER", + /* 111 */ "signed ::= MINUS INTEGER", + /* 112 */ "cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args", + /* 113 */ "create_table_args ::= LP columnlist RP", + /* 114 */ "create_table_args ::= LP columnlist RP TAGS LP columnlist RP", + /* 115 */ "create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP", + /* 116 */ "create_table_args ::= AS select", + /* 117 */ "columnlist ::= columnlist COMMA column", + /* 118 */ "columnlist ::= column", + /* 119 */ "column ::= ids typename", + /* 120 */ "tagitemlist ::= tagitemlist COMMA tagitem", + /* 121 */ "tagitemlist ::= tagitem", + /* 122 */ "tagitem ::= INTEGER", + /* 123 */ "tagitem ::= FLOAT", + /* 124 */ "tagitem ::= STRING", + /* 125 */ "tagitem ::= BOOL", + /* 126 */ "tagitem ::= NULL", + /* 127 */ "tagitem ::= MINUS INTEGER", + /* 128 */ "tagitem ::= MINUS FLOAT", + /* 129 */ "tagitem ::= PLUS INTEGER", + /* 130 */ "tagitem ::= PLUS FLOAT", + /* 131 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", + /* 132 */ "union ::= select", + /* 133 */ "union ::= LP union RP", + /* 134 */ "union ::= union UNION ALL select", + /* 135 */ "union ::= union UNION ALL LP select RP", + /* 136 */ "cmd ::= union", + /* 137 */ "select ::= SELECT selcollist", + /* 138 */ "sclp ::= selcollist COMMA", + /* 139 */ "sclp ::=", + /* 140 */ "selcollist ::= sclp expr as", + /* 141 */ "selcollist ::= sclp STAR", + /* 142 */ "as ::= AS ids", + /* 143 */ "as ::= ids", + /* 144 */ "as ::=", + /* 145 */ "from ::= FROM tablelist", + /* 146 */ "tablelist ::= ids cpxName", + /* 147 */ "tablelist ::= ids cpxName ids", + /* 148 */ "tablelist ::= tablelist COMMA ids cpxName", + /* 149 */ "tablelist ::= tablelist COMMA ids cpxName ids", + /* 150 */ "tmvar ::= VARIABLE", + /* 151 */ "interval_opt ::= INTERVAL LP tmvar RP", + /* 152 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", + /* 153 */ "interval_opt ::=", + /* 154 */ "fill_opt ::=", + /* 155 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 156 */ "fill_opt ::= FILL LP ID RP", + /* 157 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 158 */ "sliding_opt ::=", + /* 159 */ "orderby_opt ::=", + /* 160 */ "orderby_opt ::= ORDER BY sortlist", + /* 161 */ "sortlist ::= sortlist COMMA item sortorder", + /* 162 */ "sortlist ::= item sortorder", + /* 163 */ "item ::= ids cpxName", + /* 164 */ "sortorder ::= ASC", + /* 165 */ "sortorder ::= DESC", + /* 166 */ "sortorder ::=", + /* 167 */ "groupby_opt ::=", + /* 168 */ "groupby_opt ::= GROUP BY grouplist", + /* 169 */ "grouplist ::= grouplist COMMA item", + /* 170 */ "grouplist ::= item", + /* 171 */ "having_opt ::=", + /* 172 */ "having_opt ::= HAVING expr", + /* 173 */ "limit_opt ::=", + /* 174 */ "limit_opt ::= LIMIT signed", + /* 175 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 176 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 177 */ "slimit_opt ::=", + /* 178 */ "slimit_opt ::= SLIMIT signed", + /* 179 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 180 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 181 */ "where_opt ::=", + /* 182 */ "where_opt ::= WHERE expr", + /* 183 */ "expr ::= LP expr RP", + /* 184 */ "expr ::= ID", + /* 185 */ "expr ::= ID DOT ID", + /* 186 */ "expr ::= ID DOT STAR", + /* 187 */ "expr ::= INTEGER", + /* 188 */ "expr ::= MINUS INTEGER", + /* 189 */ "expr ::= PLUS INTEGER", + /* 190 */ "expr ::= FLOAT", + /* 191 */ "expr ::= MINUS FLOAT", + /* 192 */ "expr ::= PLUS FLOAT", + /* 193 */ "expr ::= STRING", + /* 194 */ "expr ::= NOW", + /* 195 */ "expr ::= VARIABLE", + /* 196 */ "expr ::= BOOL", + /* 197 */ "expr ::= ID LP exprlist RP", + /* 198 */ "expr ::= ID LP STAR RP", + /* 199 */ "expr ::= expr IS NULL", + /* 200 */ "expr ::= expr IS NOT NULL", + /* 201 */ "expr ::= expr LT expr", + /* 202 */ "expr ::= expr GT expr", + /* 203 */ "expr ::= expr LE expr", + /* 204 */ "expr ::= expr GE expr", + /* 205 */ "expr ::= expr NE expr", + /* 206 */ "expr ::= expr EQ expr", + /* 207 */ "expr ::= expr AND expr", + /* 208 */ "expr ::= expr OR expr", + /* 209 */ "expr ::= expr PLUS expr", + /* 210 */ "expr ::= expr MINUS expr", + /* 211 */ "expr ::= expr STAR expr", + /* 212 */ "expr ::= expr SLASH expr", + /* 213 */ "expr ::= expr REM expr", + /* 214 */ "expr ::= expr LIKE expr", + /* 215 */ "expr ::= expr IN LP exprlist RP", + /* 216 */ "exprlist ::= exprlist COMMA expritem", + /* 217 */ "exprlist ::= expritem", + /* 218 */ "expritem ::= expr", + /* 219 */ "expritem ::=", + /* 220 */ "cmd ::= RESET QUERY CACHE", + /* 221 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 222 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 223 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 224 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 225 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 226 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 227 */ "cmd ::= KILL CONNECTION INTEGER", + /* 228 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 229 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1292,29 +1287,28 @@ static int yyGrowStack(yyParser *p){ /* Initialize a new parser that has already been allocated. */ -void ParseInit(void *yypRawParser ParseCTX_PDECL){ - yyParser *yypParser = (yyParser*)yypRawParser; - ParseCTX_STORE +void ParseInit(void *yypParser){ + yyParser *pParser = (yyParser*)yypParser; #ifdef YYTRACKMAXSTACKDEPTH - yypParser->yyhwm = 0; + pParser->yyhwm = 0; #endif #if YYSTACKDEPTH<=0 - yypParser->yytos = NULL; - yypParser->yystack = NULL; - yypParser->yystksz = 0; - if( yyGrowStack(yypParser) ){ - yypParser->yystack = &yypParser->yystk0; - yypParser->yystksz = 1; + pParser->yytos = NULL; + pParser->yystack = NULL; + pParser->yystksz = 0; + if( yyGrowStack(pParser) ){ + pParser->yystack = &pParser->yystk0; + pParser->yystksz = 1; } #endif #ifndef YYNOERRORRECOVERY - yypParser->yyerrcnt = -1; + pParser->yyerrcnt = -1; #endif - yypParser->yytos = yypParser->yystack; - yypParser->yystack[0].stateno = 0; - yypParser->yystack[0].major = 0; + pParser->yytos = pParser->yystack; + pParser->yystack[0].stateno = 0; + pParser->yystack[0].major = 0; #if YYSTACKDEPTH>0 - yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1]; + pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1]; #endif } @@ -1331,14 +1325,11 @@ void ParseInit(void *yypRawParser ParseCTX_PDECL){ ** A pointer to a parser. This pointer is used in subsequent calls ** to Parse and ParseFree. */ -void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) ParseCTX_PDECL){ - yyParser *yypParser; - yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); - if( yypParser ){ - ParseCTX_STORE - ParseInit(yypParser ParseCTX_PARAM); - } - return (void*)yypParser; +void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){ + yyParser *pParser; + pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); + if( pParser ) ParseInit(pParser); + return pParser; } #endif /* Parse_ENGINEALWAYSONSTACK */ @@ -1355,8 +1346,7 @@ static void yy_destructor( YYCODETYPE yymajor, /* Type code for object to destroy */ YYMINORTYPE *yypminor /* The object to be destroyed */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; switch( yymajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen @@ -1369,50 +1359,50 @@ static void yy_destructor( ** inside the C code. */ /********* Begin destructor definitions ***************************************/ - case 225: /* keep */ - case 226: /* tagitemlist */ - case 250: /* fill_opt */ - case 252: /* groupby_opt */ - case 253: /* orderby_opt */ - case 263: /* sortlist */ - case 267: /* grouplist */ + case 226: /* keep */ + case 227: /* tagitemlist */ + case 251: /* fill_opt */ + case 253: /* groupby_opt */ + case 254: /* orderby_opt */ + case 264: /* sortlist */ + case 268: /* grouplist */ { -tVariantListDestroy((yypminor->yy156)); +tVariantListDestroy((yypminor->yy494)); } break; - case 242: /* columnlist */ + case 243: /* columnlist */ { -tFieldListDestroy((yypminor->yy511)); +tFieldListDestroy((yypminor->yy449)); } break; - case 243: /* select */ + case 244: /* select */ { -doDestroyQuerySql((yypminor->yy444)); +doDestroyQuerySql((yypminor->yy150)); } break; - case 246: /* selcollist */ - case 258: /* sclp */ - case 268: /* exprlist */ + case 247: /* selcollist */ + case 259: /* sclp */ + case 269: /* exprlist */ { -tSQLExprListDestroy((yypminor->yy158)); +tSQLExprListDestroy((yypminor->yy224)); } break; - case 248: /* where_opt */ - case 254: /* having_opt */ - case 259: /* expr */ - case 269: /* expritem */ + case 249: /* where_opt */ + case 255: /* having_opt */ + case 260: /* expr */ + case 270: /* expritem */ { -tSQLExprDestroy((yypminor->yy190)); +tSQLExprDestroy((yypminor->yy66)); } break; - case 257: /* union */ + case 258: /* union */ { -destroyAllSelectClause((yypminor->yy333)); +destroyAllSelectClause((yypminor->yy25)); } break; - case 264: /* sortitem */ + case 265: /* sortitem */ { -tVariantDestroy(&(yypminor->yy506)); +tVariantDestroy(&(yypminor->yy312)); } break; /********* End destructor definitions *****************************************/ @@ -1524,12 +1514,13 @@ int ParseCoverage(FILE *out){ ** Find the appropriate action for a parser given the terminal ** look-ahead token iLookAhead. */ -static YYACTIONTYPE yy_find_shift_action( - YYCODETYPE iLookAhead, /* The look-ahead token */ - YYACTIONTYPE stateno /* Current state number */ +static unsigned int yy_find_shift_action( + yyParser *pParser, /* The parser */ + YYCODETYPE iLookAhead /* The look-ahead token */ ){ int i; - + int stateno = pParser->yytos->stateno; + if( stateno>YY_MAX_SHIFT ) return stateno; assert( stateno <= YY_SHIFT_COUNT ); #if defined(YYCOVERAGE) @@ -1537,19 +1528,15 @@ static YYACTIONTYPE yy_find_shift_action( #endif do{ i = yy_shift_ofst[stateno]; - assert( i>=0 ); - assert( i<=YY_ACTTAB_COUNT ); - assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); + assert( i>=0 && i+YYNTOKEN<=sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) ); assert( iLookAhead!=YYNOCODE ); assert( iLookAhead < YYNTOKEN ); i += iLookAhead; - assert( i<(int)YY_NLOOKAHEAD ); if( yy_lookahead[i]!=iLookAhead ){ #ifdef YYFALLBACK YYCODETYPE iFallback; /* Fallback token */ - assert( iLookAhead %s\n", @@ -1564,8 +1551,15 @@ static YYACTIONTYPE yy_find_shift_action( #ifdef YYWILDCARD { int j = i - iLookAhead + YYWILDCARD; - assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) ); - if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){ + if( +#if YY_SHIFT_MIN+YYWILDCARD<0 + j>=0 && +#endif +#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT + j0 + ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", @@ -1579,7 +1573,6 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && iyytos; - yytos->stateno = yyNewState; - yytos->major = yyMajor; + yytos->stateno = (YYACTIONTYPE)yyNewState; + yytos->major = (YYCODETYPE)yyMajor; yytos->minor.yy0 = yyMinor; yyTraceShift(yypParser, yyNewState, "Shift"); } -/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side -** of that rule */ -static const YYCODETYPE yyRuleInfoLhs[] = { - 206, /* (0) program ::= cmd */ - 207, /* (1) cmd ::= SHOW DATABASES */ - 207, /* (2) cmd ::= SHOW MNODES */ - 207, /* (3) cmd ::= SHOW DNODES */ - 207, /* (4) cmd ::= SHOW ACCOUNTS */ - 207, /* (5) cmd ::= SHOW USERS */ - 207, /* (6) cmd ::= SHOW MODULES */ - 207, /* (7) cmd ::= SHOW QUERIES */ - 207, /* (8) cmd ::= SHOW CONNECTIONS */ - 207, /* (9) cmd ::= SHOW STREAMS */ - 207, /* (10) cmd ::= SHOW VARIABLES */ - 207, /* (11) cmd ::= SHOW SCORES */ - 207, /* (12) cmd ::= SHOW GRANTS */ - 207, /* (13) cmd ::= SHOW VNODES */ - 207, /* (14) cmd ::= SHOW VNODES IPTOKEN */ - 208, /* (15) dbPrefix ::= */ - 208, /* (16) dbPrefix ::= ids DOT */ - 210, /* (17) cpxName ::= */ - 210, /* (18) cpxName ::= DOT ids */ - 207, /* (19) cmd ::= SHOW dbPrefix TABLES */ - 207, /* (20) cmd ::= SHOW dbPrefix TABLES LIKE ids */ - 207, /* (21) cmd ::= SHOW dbPrefix STABLES */ - 207, /* (22) cmd ::= SHOW dbPrefix STABLES LIKE ids */ - 207, /* (23) cmd ::= SHOW dbPrefix VGROUPS */ - 207, /* (24) cmd ::= SHOW dbPrefix VGROUPS ids */ - 207, /* (25) cmd ::= DROP TABLE ifexists ids cpxName */ - 207, /* (26) cmd ::= DROP DATABASE ifexists ids */ - 207, /* (27) cmd ::= DROP DNODE ids */ - 207, /* (28) cmd ::= DROP USER ids */ - 207, /* (29) cmd ::= DROP ACCOUNT ids */ - 207, /* (30) cmd ::= USE ids */ - 207, /* (31) cmd ::= DESCRIBE ids cpxName */ - 207, /* (32) cmd ::= ALTER USER ids PASS ids */ - 207, /* (33) cmd ::= ALTER USER ids PRIVILEGE ids */ - 207, /* (34) cmd ::= ALTER DNODE ids ids */ - 207, /* (35) cmd ::= ALTER DNODE ids ids ids */ - 207, /* (36) cmd ::= ALTER LOCAL ids */ - 207, /* (37) cmd ::= ALTER LOCAL ids ids */ - 207, /* (38) cmd ::= ALTER DATABASE ids alter_db_optr */ - 207, /* (39) cmd ::= ALTER ACCOUNT ids acct_optr */ - 207, /* (40) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - 209, /* (41) ids ::= ID */ - 209, /* (42) ids ::= STRING */ - 211, /* (43) ifexists ::= IF EXISTS */ - 211, /* (44) ifexists ::= */ - 214, /* (45) ifnotexists ::= IF NOT EXISTS */ - 214, /* (46) ifnotexists ::= */ - 207, /* (47) cmd ::= CREATE DNODE ids */ - 207, /* (48) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - 207, /* (49) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - 207, /* (50) cmd ::= CREATE USER ids PASS ids */ - 216, /* (51) pps ::= */ - 216, /* (52) pps ::= PPS INTEGER */ - 217, /* (53) tseries ::= */ - 217, /* (54) tseries ::= TSERIES INTEGER */ - 218, /* (55) dbs ::= */ - 218, /* (56) dbs ::= DBS INTEGER */ - 219, /* (57) streams ::= */ - 219, /* (58) streams ::= STREAMS INTEGER */ - 220, /* (59) storage ::= */ - 220, /* (60) storage ::= STORAGE INTEGER */ - 221, /* (61) qtime ::= */ - 221, /* (62) qtime ::= QTIME INTEGER */ - 222, /* (63) users ::= */ - 222, /* (64) users ::= USERS INTEGER */ - 223, /* (65) conns ::= */ - 223, /* (66) conns ::= CONNS INTEGER */ - 224, /* (67) state ::= */ - 224, /* (68) state ::= STATE ids */ - 213, /* (69) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - 225, /* (70) keep ::= KEEP tagitemlist */ - 227, /* (71) cache ::= CACHE INTEGER */ - 228, /* (72) replica ::= REPLICA INTEGER */ - 229, /* (73) quorum ::= QUORUM INTEGER */ - 230, /* (74) days ::= DAYS INTEGER */ - 231, /* (75) minrows ::= MINROWS INTEGER */ - 232, /* (76) maxrows ::= MAXROWS INTEGER */ - 233, /* (77) blocks ::= BLOCKS INTEGER */ - 234, /* (78) ctime ::= CTIME INTEGER */ - 235, /* (79) wal ::= WAL INTEGER */ - 236, /* (80) fsync ::= FSYNC INTEGER */ - 237, /* (81) comp ::= COMP INTEGER */ - 238, /* (82) prec ::= PRECISION STRING */ - 215, /* (83) db_optr ::= */ - 215, /* (84) db_optr ::= db_optr cache */ - 215, /* (85) db_optr ::= db_optr replica */ - 215, /* (86) db_optr ::= db_optr quorum */ - 215, /* (87) db_optr ::= db_optr days */ - 215, /* (88) db_optr ::= db_optr minrows */ - 215, /* (89) db_optr ::= db_optr maxrows */ - 215, /* (90) db_optr ::= db_optr blocks */ - 215, /* (91) db_optr ::= db_optr ctime */ - 215, /* (92) db_optr ::= db_optr wal */ - 215, /* (93) db_optr ::= db_optr fsync */ - 215, /* (94) db_optr ::= db_optr comp */ - 215, /* (95) db_optr ::= db_optr prec */ - 215, /* (96) db_optr ::= db_optr keep */ - 212, /* (97) alter_db_optr ::= */ - 212, /* (98) alter_db_optr ::= alter_db_optr replica */ - 212, /* (99) alter_db_optr ::= alter_db_optr quorum */ - 212, /* (100) alter_db_optr ::= alter_db_optr keep */ - 212, /* (101) alter_db_optr ::= alter_db_optr blocks */ - 212, /* (102) alter_db_optr ::= alter_db_optr comp */ - 212, /* (103) alter_db_optr ::= alter_db_optr wal */ - 212, /* (104) alter_db_optr ::= alter_db_optr fsync */ - 239, /* (105) typename ::= ids */ - 239, /* (106) typename ::= ids LP signed RP */ - 240, /* (107) signed ::= INTEGER */ - 240, /* (108) signed ::= PLUS INTEGER */ - 240, /* (109) signed ::= MINUS INTEGER */ - 207, /* (110) cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */ - 241, /* (111) create_table_args ::= LP columnlist RP */ - 241, /* (112) create_table_args ::= LP columnlist RP TAGS LP columnlist RP */ - 241, /* (113) create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */ - 241, /* (114) create_table_args ::= AS select */ - 242, /* (115) columnlist ::= columnlist COMMA column */ - 242, /* (116) columnlist ::= column */ - 244, /* (117) column ::= ids typename */ - 226, /* (118) tagitemlist ::= tagitemlist COMMA tagitem */ - 226, /* (119) tagitemlist ::= tagitem */ - 245, /* (120) tagitem ::= INTEGER */ - 245, /* (121) tagitem ::= FLOAT */ - 245, /* (122) tagitem ::= STRING */ - 245, /* (123) tagitem ::= BOOL */ - 245, /* (124) tagitem ::= NULL */ - 245, /* (125) tagitem ::= MINUS INTEGER */ - 245, /* (126) tagitem ::= MINUS FLOAT */ - 245, /* (127) tagitem ::= PLUS INTEGER */ - 245, /* (128) tagitem ::= PLUS FLOAT */ - 243, /* (129) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ - 257, /* (130) union ::= select */ - 257, /* (131) union ::= LP union RP */ - 257, /* (132) union ::= union UNION ALL select */ - 257, /* (133) union ::= union UNION ALL LP select RP */ - 207, /* (134) cmd ::= union */ - 243, /* (135) select ::= SELECT selcollist */ - 258, /* (136) sclp ::= selcollist COMMA */ - 258, /* (137) sclp ::= */ - 246, /* (138) selcollist ::= sclp expr as */ - 246, /* (139) selcollist ::= sclp STAR */ - 260, /* (140) as ::= AS ids */ - 260, /* (141) as ::= ids */ - 260, /* (142) as ::= */ - 247, /* (143) from ::= FROM tablelist */ - 261, /* (144) tablelist ::= ids cpxName */ - 261, /* (145) tablelist ::= ids cpxName ids */ - 261, /* (146) tablelist ::= tablelist COMMA ids cpxName */ - 261, /* (147) tablelist ::= tablelist COMMA ids cpxName ids */ - 262, /* (148) tmvar ::= VARIABLE */ - 249, /* (149) interval_opt ::= INTERVAL LP tmvar RP */ - 249, /* (150) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - 249, /* (151) interval_opt ::= */ - 250, /* (152) fill_opt ::= */ - 250, /* (153) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - 250, /* (154) fill_opt ::= FILL LP ID RP */ - 251, /* (155) sliding_opt ::= SLIDING LP tmvar RP */ - 251, /* (156) sliding_opt ::= */ - 253, /* (157) orderby_opt ::= */ - 253, /* (158) orderby_opt ::= ORDER BY sortlist */ - 263, /* (159) sortlist ::= sortlist COMMA item sortorder */ - 263, /* (160) sortlist ::= item sortorder */ - 265, /* (161) item ::= ids cpxName */ - 266, /* (162) sortorder ::= ASC */ - 266, /* (163) sortorder ::= DESC */ - 266, /* (164) sortorder ::= */ - 252, /* (165) groupby_opt ::= */ - 252, /* (166) groupby_opt ::= GROUP BY grouplist */ - 267, /* (167) grouplist ::= grouplist COMMA item */ - 267, /* (168) grouplist ::= item */ - 254, /* (169) having_opt ::= */ - 254, /* (170) having_opt ::= HAVING expr */ - 256, /* (171) limit_opt ::= */ - 256, /* (172) limit_opt ::= LIMIT signed */ - 256, /* (173) limit_opt ::= LIMIT signed OFFSET signed */ - 256, /* (174) limit_opt ::= LIMIT signed COMMA signed */ - 255, /* (175) slimit_opt ::= */ - 255, /* (176) slimit_opt ::= SLIMIT signed */ - 255, /* (177) slimit_opt ::= SLIMIT signed SOFFSET signed */ - 255, /* (178) slimit_opt ::= SLIMIT signed COMMA signed */ - 248, /* (179) where_opt ::= */ - 248, /* (180) where_opt ::= WHERE expr */ - 259, /* (181) expr ::= LP expr RP */ - 259, /* (182) expr ::= ID */ - 259, /* (183) expr ::= ID DOT ID */ - 259, /* (184) expr ::= ID DOT STAR */ - 259, /* (185) expr ::= INTEGER */ - 259, /* (186) expr ::= MINUS INTEGER */ - 259, /* (187) expr ::= PLUS INTEGER */ - 259, /* (188) expr ::= FLOAT */ - 259, /* (189) expr ::= MINUS FLOAT */ - 259, /* (190) expr ::= PLUS FLOAT */ - 259, /* (191) expr ::= STRING */ - 259, /* (192) expr ::= NOW */ - 259, /* (193) expr ::= VARIABLE */ - 259, /* (194) expr ::= BOOL */ - 259, /* (195) expr ::= ID LP exprlist RP */ - 259, /* (196) expr ::= ID LP STAR RP */ - 259, /* (197) expr ::= expr IS NULL */ - 259, /* (198) expr ::= expr IS NOT NULL */ - 259, /* (199) expr ::= expr LT expr */ - 259, /* (200) expr ::= expr GT expr */ - 259, /* (201) expr ::= expr LE expr */ - 259, /* (202) expr ::= expr GE expr */ - 259, /* (203) expr ::= expr NE expr */ - 259, /* (204) expr ::= expr EQ expr */ - 259, /* (205) expr ::= expr AND expr */ - 259, /* (206) expr ::= expr OR expr */ - 259, /* (207) expr ::= expr PLUS expr */ - 259, /* (208) expr ::= expr MINUS expr */ - 259, /* (209) expr ::= expr STAR expr */ - 259, /* (210) expr ::= expr SLASH expr */ - 259, /* (211) expr ::= expr REM expr */ - 259, /* (212) expr ::= expr LIKE expr */ - 259, /* (213) expr ::= expr IN LP exprlist RP */ - 268, /* (214) exprlist ::= exprlist COMMA expritem */ - 268, /* (215) exprlist ::= expritem */ - 269, /* (216) expritem ::= expr */ - 269, /* (217) expritem ::= */ - 207, /* (218) cmd ::= RESET QUERY CACHE */ - 207, /* (219) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - 207, /* (220) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - 207, /* (221) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - 207, /* (222) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - 207, /* (223) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - 207, /* (224) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - 207, /* (225) cmd ::= KILL CONNECTION INTEGER */ - 207, /* (226) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - 207, /* (227) cmd ::= KILL QUERY INTEGER COLON INTEGER */ -}; - -/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number -** of symbols on the right-hand side of that rule. */ -static const signed char yyRuleInfoNRhs[] = { - -1, /* (0) program ::= cmd */ - -2, /* (1) cmd ::= SHOW DATABASES */ - -2, /* (2) cmd ::= SHOW MNODES */ - -2, /* (3) cmd ::= SHOW DNODES */ - -2, /* (4) cmd ::= SHOW ACCOUNTS */ - -2, /* (5) cmd ::= SHOW USERS */ - -2, /* (6) cmd ::= SHOW MODULES */ - -2, /* (7) cmd ::= SHOW QUERIES */ - -2, /* (8) cmd ::= SHOW CONNECTIONS */ - -2, /* (9) cmd ::= SHOW STREAMS */ - -2, /* (10) cmd ::= SHOW VARIABLES */ - -2, /* (11) cmd ::= SHOW SCORES */ - -2, /* (12) cmd ::= SHOW GRANTS */ - -2, /* (13) cmd ::= SHOW VNODES */ - -3, /* (14) cmd ::= SHOW VNODES IPTOKEN */ - 0, /* (15) dbPrefix ::= */ - -2, /* (16) dbPrefix ::= ids DOT */ - 0, /* (17) cpxName ::= */ - -2, /* (18) cpxName ::= DOT ids */ - -3, /* (19) cmd ::= SHOW dbPrefix TABLES */ - -5, /* (20) cmd ::= SHOW dbPrefix TABLES LIKE ids */ - -3, /* (21) cmd ::= SHOW dbPrefix STABLES */ - -5, /* (22) cmd ::= SHOW dbPrefix STABLES LIKE ids */ - -3, /* (23) cmd ::= SHOW dbPrefix VGROUPS */ - -4, /* (24) cmd ::= SHOW dbPrefix VGROUPS ids */ - -5, /* (25) cmd ::= DROP TABLE ifexists ids cpxName */ - -4, /* (26) cmd ::= DROP DATABASE ifexists ids */ - -3, /* (27) cmd ::= DROP DNODE ids */ - -3, /* (28) cmd ::= DROP USER ids */ - -3, /* (29) cmd ::= DROP ACCOUNT ids */ - -2, /* (30) cmd ::= USE ids */ - -3, /* (31) cmd ::= DESCRIBE ids cpxName */ - -5, /* (32) cmd ::= ALTER USER ids PASS ids */ - -5, /* (33) cmd ::= ALTER USER ids PRIVILEGE ids */ - -4, /* (34) cmd ::= ALTER DNODE ids ids */ - -5, /* (35) cmd ::= ALTER DNODE ids ids ids */ - -3, /* (36) cmd ::= ALTER LOCAL ids */ - -4, /* (37) cmd ::= ALTER LOCAL ids ids */ - -4, /* (38) cmd ::= ALTER DATABASE ids alter_db_optr */ - -4, /* (39) cmd ::= ALTER ACCOUNT ids acct_optr */ - -6, /* (40) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - -1, /* (41) ids ::= ID */ - -1, /* (42) ids ::= STRING */ - -2, /* (43) ifexists ::= IF EXISTS */ - 0, /* (44) ifexists ::= */ - -3, /* (45) ifnotexists ::= IF NOT EXISTS */ - 0, /* (46) ifnotexists ::= */ - -3, /* (47) cmd ::= CREATE DNODE ids */ - -6, /* (48) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - -5, /* (49) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - -5, /* (50) cmd ::= CREATE USER ids PASS ids */ - 0, /* (51) pps ::= */ - -2, /* (52) pps ::= PPS INTEGER */ - 0, /* (53) tseries ::= */ - -2, /* (54) tseries ::= TSERIES INTEGER */ - 0, /* (55) dbs ::= */ - -2, /* (56) dbs ::= DBS INTEGER */ - 0, /* (57) streams ::= */ - -2, /* (58) streams ::= STREAMS INTEGER */ - 0, /* (59) storage ::= */ - -2, /* (60) storage ::= STORAGE INTEGER */ - 0, /* (61) qtime ::= */ - -2, /* (62) qtime ::= QTIME INTEGER */ - 0, /* (63) users ::= */ - -2, /* (64) users ::= USERS INTEGER */ - 0, /* (65) conns ::= */ - -2, /* (66) conns ::= CONNS INTEGER */ - 0, /* (67) state ::= */ - -2, /* (68) state ::= STATE ids */ - -9, /* (69) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - -2, /* (70) keep ::= KEEP tagitemlist */ - -2, /* (71) cache ::= CACHE INTEGER */ - -2, /* (72) replica ::= REPLICA INTEGER */ - -2, /* (73) quorum ::= QUORUM INTEGER */ - -2, /* (74) days ::= DAYS INTEGER */ - -2, /* (75) minrows ::= MINROWS INTEGER */ - -2, /* (76) maxrows ::= MAXROWS INTEGER */ - -2, /* (77) blocks ::= BLOCKS INTEGER */ - -2, /* (78) ctime ::= CTIME INTEGER */ - -2, /* (79) wal ::= WAL INTEGER */ - -2, /* (80) fsync ::= FSYNC INTEGER */ - -2, /* (81) comp ::= COMP INTEGER */ - -2, /* (82) prec ::= PRECISION STRING */ - 0, /* (83) db_optr ::= */ - -2, /* (84) db_optr ::= db_optr cache */ - -2, /* (85) db_optr ::= db_optr replica */ - -2, /* (86) db_optr ::= db_optr quorum */ - -2, /* (87) db_optr ::= db_optr days */ - -2, /* (88) db_optr ::= db_optr minrows */ - -2, /* (89) db_optr ::= db_optr maxrows */ - -2, /* (90) db_optr ::= db_optr blocks */ - -2, /* (91) db_optr ::= db_optr ctime */ - -2, /* (92) db_optr ::= db_optr wal */ - -2, /* (93) db_optr ::= db_optr fsync */ - -2, /* (94) db_optr ::= db_optr comp */ - -2, /* (95) db_optr ::= db_optr prec */ - -2, /* (96) db_optr ::= db_optr keep */ - 0, /* (97) alter_db_optr ::= */ - -2, /* (98) alter_db_optr ::= alter_db_optr replica */ - -2, /* (99) alter_db_optr ::= alter_db_optr quorum */ - -2, /* (100) alter_db_optr ::= alter_db_optr keep */ - -2, /* (101) alter_db_optr ::= alter_db_optr blocks */ - -2, /* (102) alter_db_optr ::= alter_db_optr comp */ - -2, /* (103) alter_db_optr ::= alter_db_optr wal */ - -2, /* (104) alter_db_optr ::= alter_db_optr fsync */ - -1, /* (105) typename ::= ids */ - -4, /* (106) typename ::= ids LP signed RP */ - -1, /* (107) signed ::= INTEGER */ - -2, /* (108) signed ::= PLUS INTEGER */ - -2, /* (109) signed ::= MINUS INTEGER */ - -6, /* (110) cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */ - -3, /* (111) create_table_args ::= LP columnlist RP */ - -7, /* (112) create_table_args ::= LP columnlist RP TAGS LP columnlist RP */ - -7, /* (113) create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */ - -2, /* (114) create_table_args ::= AS select */ - -3, /* (115) columnlist ::= columnlist COMMA column */ - -1, /* (116) columnlist ::= column */ - -2, /* (117) column ::= ids typename */ - -3, /* (118) tagitemlist ::= tagitemlist COMMA tagitem */ - -1, /* (119) tagitemlist ::= tagitem */ - -1, /* (120) tagitem ::= INTEGER */ - -1, /* (121) tagitem ::= FLOAT */ - -1, /* (122) tagitem ::= STRING */ - -1, /* (123) tagitem ::= BOOL */ - -1, /* (124) tagitem ::= NULL */ - -2, /* (125) tagitem ::= MINUS INTEGER */ - -2, /* (126) tagitem ::= MINUS FLOAT */ - -2, /* (127) tagitem ::= PLUS INTEGER */ - -2, /* (128) tagitem ::= PLUS FLOAT */ - -12, /* (129) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ - -1, /* (130) union ::= select */ - -3, /* (131) union ::= LP union RP */ - -4, /* (132) union ::= union UNION ALL select */ - -6, /* (133) union ::= union UNION ALL LP select RP */ - -1, /* (134) cmd ::= union */ - -2, /* (135) select ::= SELECT selcollist */ - -2, /* (136) sclp ::= selcollist COMMA */ - 0, /* (137) sclp ::= */ - -3, /* (138) selcollist ::= sclp expr as */ - -2, /* (139) selcollist ::= sclp STAR */ - -2, /* (140) as ::= AS ids */ - -1, /* (141) as ::= ids */ - 0, /* (142) as ::= */ - -2, /* (143) from ::= FROM tablelist */ - -2, /* (144) tablelist ::= ids cpxName */ - -3, /* (145) tablelist ::= ids cpxName ids */ - -4, /* (146) tablelist ::= tablelist COMMA ids cpxName */ - -5, /* (147) tablelist ::= tablelist COMMA ids cpxName ids */ - -1, /* (148) tmvar ::= VARIABLE */ - -4, /* (149) interval_opt ::= INTERVAL LP tmvar RP */ - -6, /* (150) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - 0, /* (151) interval_opt ::= */ - 0, /* (152) fill_opt ::= */ - -6, /* (153) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - -4, /* (154) fill_opt ::= FILL LP ID RP */ - -4, /* (155) sliding_opt ::= SLIDING LP tmvar RP */ - 0, /* (156) sliding_opt ::= */ - 0, /* (157) orderby_opt ::= */ - -3, /* (158) orderby_opt ::= ORDER BY sortlist */ - -4, /* (159) sortlist ::= sortlist COMMA item sortorder */ - -2, /* (160) sortlist ::= item sortorder */ - -2, /* (161) item ::= ids cpxName */ - -1, /* (162) sortorder ::= ASC */ - -1, /* (163) sortorder ::= DESC */ - 0, /* (164) sortorder ::= */ - 0, /* (165) groupby_opt ::= */ - -3, /* (166) groupby_opt ::= GROUP BY grouplist */ - -3, /* (167) grouplist ::= grouplist COMMA item */ - -1, /* (168) grouplist ::= item */ - 0, /* (169) having_opt ::= */ - -2, /* (170) having_opt ::= HAVING expr */ - 0, /* (171) limit_opt ::= */ - -2, /* (172) limit_opt ::= LIMIT signed */ - -4, /* (173) limit_opt ::= LIMIT signed OFFSET signed */ - -4, /* (174) limit_opt ::= LIMIT signed COMMA signed */ - 0, /* (175) slimit_opt ::= */ - -2, /* (176) slimit_opt ::= SLIMIT signed */ - -4, /* (177) slimit_opt ::= SLIMIT signed SOFFSET signed */ - -4, /* (178) slimit_opt ::= SLIMIT signed COMMA signed */ - 0, /* (179) where_opt ::= */ - -2, /* (180) where_opt ::= WHERE expr */ - -3, /* (181) expr ::= LP expr RP */ - -1, /* (182) expr ::= ID */ - -3, /* (183) expr ::= ID DOT ID */ - -3, /* (184) expr ::= ID DOT STAR */ - -1, /* (185) expr ::= INTEGER */ - -2, /* (186) expr ::= MINUS INTEGER */ - -2, /* (187) expr ::= PLUS INTEGER */ - -1, /* (188) expr ::= FLOAT */ - -2, /* (189) expr ::= MINUS FLOAT */ - -2, /* (190) expr ::= PLUS FLOAT */ - -1, /* (191) expr ::= STRING */ - -1, /* (192) expr ::= NOW */ - -1, /* (193) expr ::= VARIABLE */ - -1, /* (194) expr ::= BOOL */ - -4, /* (195) expr ::= ID LP exprlist RP */ - -4, /* (196) expr ::= ID LP STAR RP */ - -3, /* (197) expr ::= expr IS NULL */ - -4, /* (198) expr ::= expr IS NOT NULL */ - -3, /* (199) expr ::= expr LT expr */ - -3, /* (200) expr ::= expr GT expr */ - -3, /* (201) expr ::= expr LE expr */ - -3, /* (202) expr ::= expr GE expr */ - -3, /* (203) expr ::= expr NE expr */ - -3, /* (204) expr ::= expr EQ expr */ - -3, /* (205) expr ::= expr AND expr */ - -3, /* (206) expr ::= expr OR expr */ - -3, /* (207) expr ::= expr PLUS expr */ - -3, /* (208) expr ::= expr MINUS expr */ - -3, /* (209) expr ::= expr STAR expr */ - -3, /* (210) expr ::= expr SLASH expr */ - -3, /* (211) expr ::= expr REM expr */ - -3, /* (212) expr ::= expr LIKE expr */ - -5, /* (213) expr ::= expr IN LP exprlist RP */ - -3, /* (214) exprlist ::= exprlist COMMA expritem */ - -1, /* (215) exprlist ::= expritem */ - -1, /* (216) expritem ::= expr */ - 0, /* (217) expritem ::= */ - -3, /* (218) cmd ::= RESET QUERY CACHE */ - -7, /* (219) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (220) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - -7, /* (221) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - -7, /* (222) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - -8, /* (223) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (224) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - -3, /* (225) cmd ::= KILL CONNECTION INTEGER */ - -5, /* (226) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - -5, /* (227) cmd ::= KILL QUERY INTEGER COLON INTEGER */ +/* The following table contains information about every rule that +** is used during the reduce. +*/ +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[] = { + { 207, -1 }, /* (0) program ::= cmd */ + { 208, -2 }, /* (1) cmd ::= SHOW DATABASES */ + { 208, -2 }, /* (2) cmd ::= SHOW MNODES */ + { 208, -2 }, /* (3) cmd ::= SHOW DNODES */ + { 208, -2 }, /* (4) cmd ::= SHOW ACCOUNTS */ + { 208, -2 }, /* (5) cmd ::= SHOW USERS */ + { 208, -2 }, /* (6) cmd ::= SHOW MODULES */ + { 208, -2 }, /* (7) cmd ::= SHOW QUERIES */ + { 208, -2 }, /* (8) cmd ::= SHOW CONNECTIONS */ + { 208, -2 }, /* (9) cmd ::= SHOW STREAMS */ + { 208, -2 }, /* (10) cmd ::= SHOW VARIABLES */ + { 208, -2 }, /* (11) cmd ::= SHOW SCORES */ + { 208, -2 }, /* (12) cmd ::= SHOW GRANTS */ + { 208, -2 }, /* (13) cmd ::= SHOW VNODES */ + { 208, -3 }, /* (14) cmd ::= SHOW VNODES IPTOKEN */ + { 209, 0 }, /* (15) dbPrefix ::= */ + { 209, -2 }, /* (16) dbPrefix ::= ids DOT */ + { 211, 0 }, /* (17) cpxName ::= */ + { 211, -2 }, /* (18) cpxName ::= DOT ids */ + { 208, -5 }, /* (19) cmd ::= SHOW CREATE TABLE ids cpxName */ + { 208, -4 }, /* (20) cmd ::= SHOW CREATE DATABASE ids */ + { 208, -3 }, /* (21) cmd ::= SHOW dbPrefix TABLES */ + { 208, -5 }, /* (22) cmd ::= SHOW dbPrefix TABLES LIKE ids */ + { 208, -3 }, /* (23) cmd ::= SHOW dbPrefix STABLES */ + { 208, -5 }, /* (24) cmd ::= SHOW dbPrefix STABLES LIKE ids */ + { 208, -3 }, /* (25) cmd ::= SHOW dbPrefix VGROUPS */ + { 208, -4 }, /* (26) cmd ::= SHOW dbPrefix VGROUPS ids */ + { 208, -5 }, /* (27) cmd ::= DROP TABLE ifexists ids cpxName */ + { 208, -4 }, /* (28) cmd ::= DROP DATABASE ifexists ids */ + { 208, -3 }, /* (29) cmd ::= DROP DNODE ids */ + { 208, -3 }, /* (30) cmd ::= DROP USER ids */ + { 208, -3 }, /* (31) cmd ::= DROP ACCOUNT ids */ + { 208, -2 }, /* (32) cmd ::= USE ids */ + { 208, -3 }, /* (33) cmd ::= DESCRIBE ids cpxName */ + { 208, -5 }, /* (34) cmd ::= ALTER USER ids PASS ids */ + { 208, -5 }, /* (35) cmd ::= ALTER USER ids PRIVILEGE ids */ + { 208, -4 }, /* (36) cmd ::= ALTER DNODE ids ids */ + { 208, -5 }, /* (37) cmd ::= ALTER DNODE ids ids ids */ + { 208, -3 }, /* (38) cmd ::= ALTER LOCAL ids */ + { 208, -4 }, /* (39) cmd ::= ALTER LOCAL ids ids */ + { 208, -4 }, /* (40) cmd ::= ALTER DATABASE ids alter_db_optr */ + { 208, -4 }, /* (41) cmd ::= ALTER ACCOUNT ids acct_optr */ + { 208, -6 }, /* (42) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + { 210, -1 }, /* (43) ids ::= ID */ + { 210, -1 }, /* (44) ids ::= STRING */ + { 212, -2 }, /* (45) ifexists ::= IF EXISTS */ + { 212, 0 }, /* (46) ifexists ::= */ + { 215, -3 }, /* (47) ifnotexists ::= IF NOT EXISTS */ + { 215, 0 }, /* (48) ifnotexists ::= */ + { 208, -3 }, /* (49) cmd ::= CREATE DNODE ids */ + { 208, -6 }, /* (50) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + { 208, -5 }, /* (51) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + { 208, -5 }, /* (52) cmd ::= CREATE USER ids PASS ids */ + { 217, 0 }, /* (53) pps ::= */ + { 217, -2 }, /* (54) pps ::= PPS INTEGER */ + { 218, 0 }, /* (55) tseries ::= */ + { 218, -2 }, /* (56) tseries ::= TSERIES INTEGER */ + { 219, 0 }, /* (57) dbs ::= */ + { 219, -2 }, /* (58) dbs ::= DBS INTEGER */ + { 220, 0 }, /* (59) streams ::= */ + { 220, -2 }, /* (60) streams ::= STREAMS INTEGER */ + { 221, 0 }, /* (61) storage ::= */ + { 221, -2 }, /* (62) storage ::= STORAGE INTEGER */ + { 222, 0 }, /* (63) qtime ::= */ + { 222, -2 }, /* (64) qtime ::= QTIME INTEGER */ + { 223, 0 }, /* (65) users ::= */ + { 223, -2 }, /* (66) users ::= USERS INTEGER */ + { 224, 0 }, /* (67) conns ::= */ + { 224, -2 }, /* (68) conns ::= CONNS INTEGER */ + { 225, 0 }, /* (69) state ::= */ + { 225, -2 }, /* (70) state ::= STATE ids */ + { 214, -9 }, /* (71) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + { 226, -2 }, /* (72) keep ::= KEEP tagitemlist */ + { 228, -2 }, /* (73) cache ::= CACHE INTEGER */ + { 229, -2 }, /* (74) replica ::= REPLICA INTEGER */ + { 230, -2 }, /* (75) quorum ::= QUORUM INTEGER */ + { 231, -2 }, /* (76) days ::= DAYS INTEGER */ + { 232, -2 }, /* (77) minrows ::= MINROWS INTEGER */ + { 233, -2 }, /* (78) maxrows ::= MAXROWS INTEGER */ + { 234, -2 }, /* (79) blocks ::= BLOCKS INTEGER */ + { 235, -2 }, /* (80) ctime ::= CTIME INTEGER */ + { 236, -2 }, /* (81) wal ::= WAL INTEGER */ + { 237, -2 }, /* (82) fsync ::= FSYNC INTEGER */ + { 238, -2 }, /* (83) comp ::= COMP INTEGER */ + { 239, -2 }, /* (84) prec ::= PRECISION STRING */ + { 216, 0 }, /* (85) db_optr ::= */ + { 216, -2 }, /* (86) db_optr ::= db_optr cache */ + { 216, -2 }, /* (87) db_optr ::= db_optr replica */ + { 216, -2 }, /* (88) db_optr ::= db_optr quorum */ + { 216, -2 }, /* (89) db_optr ::= db_optr days */ + { 216, -2 }, /* (90) db_optr ::= db_optr minrows */ + { 216, -2 }, /* (91) db_optr ::= db_optr maxrows */ + { 216, -2 }, /* (92) db_optr ::= db_optr blocks */ + { 216, -2 }, /* (93) db_optr ::= db_optr ctime */ + { 216, -2 }, /* (94) db_optr ::= db_optr wal */ + { 216, -2 }, /* (95) db_optr ::= db_optr fsync */ + { 216, -2 }, /* (96) db_optr ::= db_optr comp */ + { 216, -2 }, /* (97) db_optr ::= db_optr prec */ + { 216, -2 }, /* (98) db_optr ::= db_optr keep */ + { 213, 0 }, /* (99) alter_db_optr ::= */ + { 213, -2 }, /* (100) alter_db_optr ::= alter_db_optr replica */ + { 213, -2 }, /* (101) alter_db_optr ::= alter_db_optr quorum */ + { 213, -2 }, /* (102) alter_db_optr ::= alter_db_optr keep */ + { 213, -2 }, /* (103) alter_db_optr ::= alter_db_optr blocks */ + { 213, -2 }, /* (104) alter_db_optr ::= alter_db_optr comp */ + { 213, -2 }, /* (105) alter_db_optr ::= alter_db_optr wal */ + { 213, -2 }, /* (106) alter_db_optr ::= alter_db_optr fsync */ + { 240, -1 }, /* (107) typename ::= ids */ + { 240, -4 }, /* (108) typename ::= ids LP signed RP */ + { 241, -1 }, /* (109) signed ::= INTEGER */ + { 241, -2 }, /* (110) signed ::= PLUS INTEGER */ + { 241, -2 }, /* (111) signed ::= MINUS INTEGER */ + { 208, -6 }, /* (112) cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */ + { 242, -3 }, /* (113) create_table_args ::= LP columnlist RP */ + { 242, -7 }, /* (114) create_table_args ::= LP columnlist RP TAGS LP columnlist RP */ + { 242, -7 }, /* (115) create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */ + { 242, -2 }, /* (116) create_table_args ::= AS select */ + { 243, -3 }, /* (117) columnlist ::= columnlist COMMA column */ + { 243, -1 }, /* (118) columnlist ::= column */ + { 245, -2 }, /* (119) column ::= ids typename */ + { 227, -3 }, /* (120) tagitemlist ::= tagitemlist COMMA tagitem */ + { 227, -1 }, /* (121) tagitemlist ::= tagitem */ + { 246, -1 }, /* (122) tagitem ::= INTEGER */ + { 246, -1 }, /* (123) tagitem ::= FLOAT */ + { 246, -1 }, /* (124) tagitem ::= STRING */ + { 246, -1 }, /* (125) tagitem ::= BOOL */ + { 246, -1 }, /* (126) tagitem ::= NULL */ + { 246, -2 }, /* (127) tagitem ::= MINUS INTEGER */ + { 246, -2 }, /* (128) tagitem ::= MINUS FLOAT */ + { 246, -2 }, /* (129) tagitem ::= PLUS INTEGER */ + { 246, -2 }, /* (130) tagitem ::= PLUS FLOAT */ + { 244, -12 }, /* (131) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + { 258, -1 }, /* (132) union ::= select */ + { 258, -3 }, /* (133) union ::= LP union RP */ + { 258, -4 }, /* (134) union ::= union UNION ALL select */ + { 258, -6 }, /* (135) union ::= union UNION ALL LP select RP */ + { 208, -1 }, /* (136) cmd ::= union */ + { 244, -2 }, /* (137) select ::= SELECT selcollist */ + { 259, -2 }, /* (138) sclp ::= selcollist COMMA */ + { 259, 0 }, /* (139) sclp ::= */ + { 247, -3 }, /* (140) selcollist ::= sclp expr as */ + { 247, -2 }, /* (141) selcollist ::= sclp STAR */ + { 261, -2 }, /* (142) as ::= AS ids */ + { 261, -1 }, /* (143) as ::= ids */ + { 261, 0 }, /* (144) as ::= */ + { 248, -2 }, /* (145) from ::= FROM tablelist */ + { 262, -2 }, /* (146) tablelist ::= ids cpxName */ + { 262, -3 }, /* (147) tablelist ::= ids cpxName ids */ + { 262, -4 }, /* (148) tablelist ::= tablelist COMMA ids cpxName */ + { 262, -5 }, /* (149) tablelist ::= tablelist COMMA ids cpxName ids */ + { 263, -1 }, /* (150) tmvar ::= VARIABLE */ + { 250, -4 }, /* (151) interval_opt ::= INTERVAL LP tmvar RP */ + { 250, -6 }, /* (152) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + { 250, 0 }, /* (153) interval_opt ::= */ + { 251, 0 }, /* (154) fill_opt ::= */ + { 251, -6 }, /* (155) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 251, -4 }, /* (156) fill_opt ::= FILL LP ID RP */ + { 252, -4 }, /* (157) sliding_opt ::= SLIDING LP tmvar RP */ + { 252, 0 }, /* (158) sliding_opt ::= */ + { 254, 0 }, /* (159) orderby_opt ::= */ + { 254, -3 }, /* (160) orderby_opt ::= ORDER BY sortlist */ + { 264, -4 }, /* (161) sortlist ::= sortlist COMMA item sortorder */ + { 264, -2 }, /* (162) sortlist ::= item sortorder */ + { 266, -2 }, /* (163) item ::= ids cpxName */ + { 267, -1 }, /* (164) sortorder ::= ASC */ + { 267, -1 }, /* (165) sortorder ::= DESC */ + { 267, 0 }, /* (166) sortorder ::= */ + { 253, 0 }, /* (167) groupby_opt ::= */ + { 253, -3 }, /* (168) groupby_opt ::= GROUP BY grouplist */ + { 268, -3 }, /* (169) grouplist ::= grouplist COMMA item */ + { 268, -1 }, /* (170) grouplist ::= item */ + { 255, 0 }, /* (171) having_opt ::= */ + { 255, -2 }, /* (172) having_opt ::= HAVING expr */ + { 257, 0 }, /* (173) limit_opt ::= */ + { 257, -2 }, /* (174) limit_opt ::= LIMIT signed */ + { 257, -4 }, /* (175) limit_opt ::= LIMIT signed OFFSET signed */ + { 257, -4 }, /* (176) limit_opt ::= LIMIT signed COMMA signed */ + { 256, 0 }, /* (177) slimit_opt ::= */ + { 256, -2 }, /* (178) slimit_opt ::= SLIMIT signed */ + { 256, -4 }, /* (179) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 256, -4 }, /* (180) slimit_opt ::= SLIMIT signed COMMA signed */ + { 249, 0 }, /* (181) where_opt ::= */ + { 249, -2 }, /* (182) where_opt ::= WHERE expr */ + { 260, -3 }, /* (183) expr ::= LP expr RP */ + { 260, -1 }, /* (184) expr ::= ID */ + { 260, -3 }, /* (185) expr ::= ID DOT ID */ + { 260, -3 }, /* (186) expr ::= ID DOT STAR */ + { 260, -1 }, /* (187) expr ::= INTEGER */ + { 260, -2 }, /* (188) expr ::= MINUS INTEGER */ + { 260, -2 }, /* (189) expr ::= PLUS INTEGER */ + { 260, -1 }, /* (190) expr ::= FLOAT */ + { 260, -2 }, /* (191) expr ::= MINUS FLOAT */ + { 260, -2 }, /* (192) expr ::= PLUS FLOAT */ + { 260, -1 }, /* (193) expr ::= STRING */ + { 260, -1 }, /* (194) expr ::= NOW */ + { 260, -1 }, /* (195) expr ::= VARIABLE */ + { 260, -1 }, /* (196) expr ::= BOOL */ + { 260, -4 }, /* (197) expr ::= ID LP exprlist RP */ + { 260, -4 }, /* (198) expr ::= ID LP STAR RP */ + { 260, -3 }, /* (199) expr ::= expr IS NULL */ + { 260, -4 }, /* (200) expr ::= expr IS NOT NULL */ + { 260, -3 }, /* (201) expr ::= expr LT expr */ + { 260, -3 }, /* (202) expr ::= expr GT expr */ + { 260, -3 }, /* (203) expr ::= expr LE expr */ + { 260, -3 }, /* (204) expr ::= expr GE expr */ + { 260, -3 }, /* (205) expr ::= expr NE expr */ + { 260, -3 }, /* (206) expr ::= expr EQ expr */ + { 260, -3 }, /* (207) expr ::= expr AND expr */ + { 260, -3 }, /* (208) expr ::= expr OR expr */ + { 260, -3 }, /* (209) expr ::= expr PLUS expr */ + { 260, -3 }, /* (210) expr ::= expr MINUS expr */ + { 260, -3 }, /* (211) expr ::= expr STAR expr */ + { 260, -3 }, /* (212) expr ::= expr SLASH expr */ + { 260, -3 }, /* (213) expr ::= expr REM expr */ + { 260, -3 }, /* (214) expr ::= expr LIKE expr */ + { 260, -5 }, /* (215) expr ::= expr IN LP exprlist RP */ + { 269, -3 }, /* (216) exprlist ::= exprlist COMMA expritem */ + { 269, -1 }, /* (217) exprlist ::= expritem */ + { 270, -1 }, /* (218) expritem ::= expr */ + { 270, 0 }, /* (219) expritem ::= */ + { 208, -3 }, /* (220) cmd ::= RESET QUERY CACHE */ + { 208, -7 }, /* (221) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 208, -7 }, /* (222) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 208, -7 }, /* (223) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 208, -7 }, /* (224) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 208, -8 }, /* (225) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 208, -9 }, /* (226) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 208, -3 }, /* (227) cmd ::= KILL CONNECTION INTEGER */ + { 208, -5 }, /* (228) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 208, -5 }, /* (229) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2176,34 +1940,30 @@ static void yy_accept(yyParser*); /* Forward Declaration */ ** only called from one place, optimizing compilers will in-line it, which ** means that the extra parameters have no performance impact. */ -static YYACTIONTYPE yy_reduce( +static void yy_reduce( yyParser *yypParser, /* The parser */ unsigned int yyruleno, /* Number of the rule by which to reduce */ int yyLookahead, /* Lookahead token, or YYNOCODE if none */ ParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */ - ParseCTX_PDECL /* %extra_context */ ){ int yygoto; /* The next state */ - YYACTIONTYPE yyact; /* The next action */ + int yyact; /* The next action */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ - ParseARG_FETCH + ParseARG_FETCH; (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - yysize = yyRuleInfoNRhs[yyruleno]; + yysize = yyRuleInfo[yyruleno].nrhs; if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", + fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", yyTracePrompt, - yyruleno, yyRuleName[yyruleno], - yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ yypParser->yyhwm++; @@ -2221,19 +1981,13 @@ static YYACTIONTYPE yy_reduce( #if YYSTACKDEPTH>0 if( yypParser->yytos>=yypParser->yystackEnd ){ yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; + return; } #else if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ if( yyGrowStack(yypParser) ){ yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; + return; } yymsp = yypParser->yytos; } @@ -2309,708 +2063,719 @@ static YYACTIONTYPE yy_reduce( case 18: /* cpxName ::= DOT ids */ {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n += 1; } break; - case 19: /* cmd ::= SHOW dbPrefix TABLES */ + case 19: /* cmd ::= SHOW CREATE TABLE ids cpxName */ +{ + yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; + setDCLSQLElems(pInfo, TSDB_SQL_SHOW_CREATE_TABLE, 1, &yymsp[-1].minor.yy0); +} + break; + case 20: /* cmd ::= SHOW CREATE DATABASE ids */ +{ + setDCLSQLElems(pInfo, TSDB_SQL_SHOW_CREATE_DATABASE, 1, &yymsp[0].minor.yy0); +} + break; + case 21: /* cmd ::= SHOW dbPrefix TABLES */ { setShowOptions(pInfo, TSDB_MGMT_TABLE_TABLE, &yymsp[-1].minor.yy0, 0); } break; - case 20: /* cmd ::= SHOW dbPrefix TABLES LIKE ids */ + case 22: /* cmd ::= SHOW dbPrefix TABLES LIKE ids */ { setShowOptions(pInfo, TSDB_MGMT_TABLE_TABLE, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0); } break; - case 21: /* cmd ::= SHOW dbPrefix STABLES */ + case 23: /* cmd ::= SHOW dbPrefix STABLES */ { setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &yymsp[-1].minor.yy0, 0); } break; - case 22: /* cmd ::= SHOW dbPrefix STABLES LIKE ids */ + case 24: /* cmd ::= SHOW dbPrefix STABLES LIKE ids */ { SStrToken token; setDBName(&token, &yymsp[-3].minor.yy0); setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &token, &yymsp[0].minor.yy0); } break; - case 23: /* cmd ::= SHOW dbPrefix VGROUPS */ + case 25: /* cmd ::= SHOW dbPrefix VGROUPS */ { SStrToken token; setDBName(&token, &yymsp[-1].minor.yy0); setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, 0); } break; - case 24: /* cmd ::= SHOW dbPrefix VGROUPS ids */ + case 26: /* cmd ::= SHOW dbPrefix VGROUPS ids */ { SStrToken token; setDBName(&token, &yymsp[-2].minor.yy0); setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, &yymsp[0].minor.yy0); } break; - case 25: /* cmd ::= DROP TABLE ifexists ids cpxName */ + case 27: /* cmd ::= DROP TABLE ifexists ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; setDropDBTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &yymsp[-1].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 26: /* cmd ::= DROP DATABASE ifexists ids */ + case 28: /* cmd ::= DROP DATABASE ifexists ids */ { setDropDBTableInfo(pInfo, TSDB_SQL_DROP_DB, &yymsp[0].minor.yy0, &yymsp[-1].minor.yy0); } break; - case 27: /* cmd ::= DROP DNODE ids */ + case 29: /* cmd ::= DROP DNODE ids */ { setDCLSQLElems(pInfo, TSDB_SQL_DROP_DNODE, 1, &yymsp[0].minor.yy0); } break; - case 28: /* cmd ::= DROP USER ids */ + case 30: /* cmd ::= DROP USER ids */ { setDCLSQLElems(pInfo, TSDB_SQL_DROP_USER, 1, &yymsp[0].minor.yy0); } break; - case 29: /* cmd ::= DROP ACCOUNT ids */ + case 31: /* cmd ::= DROP ACCOUNT ids */ { setDCLSQLElems(pInfo, TSDB_SQL_DROP_ACCT, 1, &yymsp[0].minor.yy0); } break; - case 30: /* cmd ::= USE ids */ + case 32: /* cmd ::= USE ids */ { setDCLSQLElems(pInfo, TSDB_SQL_USE_DB, 1, &yymsp[0].minor.yy0);} break; - case 31: /* cmd ::= DESCRIBE ids cpxName */ + case 33: /* cmd ::= DESCRIBE ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; setDCLSQLElems(pInfo, TSDB_SQL_DESCRIBE_TABLE, 1, &yymsp[-1].minor.yy0); } break; - case 32: /* cmd ::= ALTER USER ids PASS ids */ + case 34: /* cmd ::= ALTER USER ids PASS ids */ { setAlterUserSQL(pInfo, TSDB_ALTER_USER_PASSWD, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, NULL); } break; - case 33: /* cmd ::= ALTER USER ids PRIVILEGE ids */ + case 35: /* cmd ::= ALTER USER ids PRIVILEGE ids */ { setAlterUserSQL(pInfo, TSDB_ALTER_USER_PRIVILEGES, &yymsp[-2].minor.yy0, NULL, &yymsp[0].minor.yy0);} break; - case 34: /* cmd ::= ALTER DNODE ids ids */ + case 36: /* cmd ::= ALTER DNODE ids ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CFG_DNODE, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 35: /* cmd ::= ALTER DNODE ids ids ids */ + case 37: /* cmd ::= ALTER DNODE ids ids ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CFG_DNODE, 3, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 36: /* cmd ::= ALTER LOCAL ids */ + case 38: /* cmd ::= ALTER LOCAL ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &yymsp[0].minor.yy0); } break; - case 37: /* cmd ::= ALTER LOCAL ids ids */ + case 39: /* cmd ::= ALTER LOCAL ids ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 38: /* cmd ::= ALTER DATABASE ids alter_db_optr */ -{ SStrToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy118, &t);} + case 40: /* cmd ::= ALTER DATABASE ids alter_db_optr */ +{ SStrToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy158, &t);} break; - case 39: /* cmd ::= ALTER ACCOUNT ids acct_optr */ -{ setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy479);} + case 41: /* cmd ::= ALTER ACCOUNT ids acct_optr */ +{ setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy73);} break; - case 40: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy479);} + case 42: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ +{ setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy73);} break; - case 41: /* ids ::= ID */ - case 42: /* ids ::= STRING */ yytestcase(yyruleno==42); + case 43: /* ids ::= ID */ + case 44: /* ids ::= STRING */ yytestcase(yyruleno==44); {yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 43: /* ifexists ::= IF EXISTS */ + case 45: /* ifexists ::= IF EXISTS */ {yymsp[-1].minor.yy0.n = 1;} break; - case 44: /* ifexists ::= */ - case 46: /* ifnotexists ::= */ yytestcase(yyruleno==46); + case 46: /* ifexists ::= */ + case 48: /* ifnotexists ::= */ yytestcase(yyruleno==48); {yymsp[1].minor.yy0.n = 0;} break; - case 45: /* ifnotexists ::= IF NOT EXISTS */ + case 47: /* ifnotexists ::= IF NOT EXISTS */ {yymsp[-2].minor.yy0.n = 1;} break; - case 47: /* cmd ::= CREATE DNODE ids */ + case 49: /* cmd ::= CREATE DNODE ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);} break; - case 48: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSQL(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy479);} + case 50: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ +{ setCreateAcctSQL(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy73);} break; - case 49: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ -{ setCreateDBSQL(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy118, &yymsp[-2].minor.yy0);} + case 51: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ +{ setCreateDBSQL(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy158, &yymsp[-2].minor.yy0);} break; - case 50: /* cmd ::= CREATE USER ids PASS ids */ + case 52: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSQL(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} break; - case 51: /* pps ::= */ - case 53: /* tseries ::= */ yytestcase(yyruleno==53); - case 55: /* dbs ::= */ yytestcase(yyruleno==55); - case 57: /* streams ::= */ yytestcase(yyruleno==57); - case 59: /* storage ::= */ yytestcase(yyruleno==59); - case 61: /* qtime ::= */ yytestcase(yyruleno==61); - case 63: /* users ::= */ yytestcase(yyruleno==63); - case 65: /* conns ::= */ yytestcase(yyruleno==65); - case 67: /* state ::= */ yytestcase(yyruleno==67); + case 53: /* pps ::= */ + case 55: /* tseries ::= */ yytestcase(yyruleno==55); + case 57: /* dbs ::= */ yytestcase(yyruleno==57); + case 59: /* streams ::= */ yytestcase(yyruleno==59); + case 61: /* storage ::= */ yytestcase(yyruleno==61); + case 63: /* qtime ::= */ yytestcase(yyruleno==63); + case 65: /* users ::= */ yytestcase(yyruleno==65); + case 67: /* conns ::= */ yytestcase(yyruleno==67); + case 69: /* state ::= */ yytestcase(yyruleno==69); {yymsp[1].minor.yy0.n = 0; } break; - case 52: /* pps ::= PPS INTEGER */ - case 54: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==54); - case 56: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==56); - case 58: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==58); - case 60: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==60); - case 62: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==62); - case 64: /* users ::= USERS INTEGER */ yytestcase(yyruleno==64); - case 66: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==66); - case 68: /* state ::= STATE ids */ yytestcase(yyruleno==68); + case 54: /* pps ::= PPS INTEGER */ + case 56: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==56); + case 58: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==58); + case 60: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==60); + case 62: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==62); + case 64: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==64); + case 66: /* users ::= USERS INTEGER */ yytestcase(yyruleno==66); + case 68: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==68); + case 70: /* state ::= STATE ids */ yytestcase(yyruleno==70); {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 69: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + case 71: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { - yylhsminor.yy479.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; - yylhsminor.yy479.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; - yylhsminor.yy479.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; - yylhsminor.yy479.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; - yylhsminor.yy479.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; - yylhsminor.yy479.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy479.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy479.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; - yylhsminor.yy479.stat = yymsp[0].minor.yy0; -} - yymsp[-8].minor.yy479 = yylhsminor.yy479; - break; - case 70: /* keep ::= KEEP tagitemlist */ -{ yymsp[-1].minor.yy156 = yymsp[0].minor.yy156; } - break; - case 71: /* cache ::= CACHE INTEGER */ - case 72: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==72); - case 73: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==73); - case 74: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==74); - case 75: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==75); - case 76: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==76); - case 77: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==77); - case 78: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==78); - case 79: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==79); - case 80: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==80); - case 81: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==81); - case 82: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==82); + yylhsminor.yy73.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; + yylhsminor.yy73.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; + yylhsminor.yy73.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; + yylhsminor.yy73.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; + yylhsminor.yy73.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; + yylhsminor.yy73.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy73.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy73.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; + yylhsminor.yy73.stat = yymsp[0].minor.yy0; +} + yymsp[-8].minor.yy73 = yylhsminor.yy73; + break; + case 72: /* keep ::= KEEP tagitemlist */ +{ yymsp[-1].minor.yy494 = yymsp[0].minor.yy494; } + break; + case 73: /* cache ::= CACHE INTEGER */ + case 74: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==74); + case 75: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==75); + case 76: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==76); + case 77: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==77); + case 78: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==78); + case 79: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==79); + case 80: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==80); + case 81: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==81); + case 82: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==82); + case 83: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==83); + case 84: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==84); { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 83: /* db_optr ::= */ -{setDefaultCreateDbOption(&yymsp[1].minor.yy118);} + case 85: /* db_optr ::= */ +{setDefaultCreateDbOption(&yymsp[1].minor.yy158);} break; - case 84: /* db_optr ::= db_optr cache */ -{ yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy118 = yylhsminor.yy118; + case 86: /* db_optr ::= db_optr cache */ +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 85: /* db_optr ::= db_optr replica */ - case 98: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==98); -{ yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy118 = yylhsminor.yy118; + case 87: /* db_optr ::= db_optr replica */ + case 100: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==100); +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 86: /* db_optr ::= db_optr quorum */ - case 99: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==99); -{ yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy118 = yylhsminor.yy118; + case 88: /* db_optr ::= db_optr quorum */ + case 101: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==101); +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 87: /* db_optr ::= db_optr days */ -{ yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy118 = yylhsminor.yy118; + case 89: /* db_optr ::= db_optr days */ +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 88: /* db_optr ::= db_optr minrows */ -{ yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy118 = yylhsminor.yy118; + case 90: /* db_optr ::= db_optr minrows */ +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 89: /* db_optr ::= db_optr maxrows */ -{ yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy118 = yylhsminor.yy118; + case 91: /* db_optr ::= db_optr maxrows */ +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 90: /* db_optr ::= db_optr blocks */ - case 101: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==101); -{ yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy118 = yylhsminor.yy118; + case 92: /* db_optr ::= db_optr blocks */ + case 103: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==103); +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 91: /* db_optr ::= db_optr ctime */ -{ yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy118 = yylhsminor.yy118; + case 93: /* db_optr ::= db_optr ctime */ +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 92: /* db_optr ::= db_optr wal */ - case 103: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==103); -{ yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy118 = yylhsminor.yy118; + case 94: /* db_optr ::= db_optr wal */ + case 105: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==105); +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 93: /* db_optr ::= db_optr fsync */ - case 104: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==104); -{ yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy118 = yylhsminor.yy118; + case 95: /* db_optr ::= db_optr fsync */ + case 106: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==106); +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 94: /* db_optr ::= db_optr comp */ - case 102: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==102); -{ yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy118 = yylhsminor.yy118; + case 96: /* db_optr ::= db_optr comp */ + case 104: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==104); +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 95: /* db_optr ::= db_optr prec */ -{ yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.precision = yymsp[0].minor.yy0; } - yymsp[-1].minor.yy118 = yylhsminor.yy118; + case 97: /* db_optr ::= db_optr prec */ +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.precision = yymsp[0].minor.yy0; } + yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 96: /* db_optr ::= db_optr keep */ - case 100: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==100); -{ yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.keep = yymsp[0].minor.yy156; } - yymsp[-1].minor.yy118 = yylhsminor.yy118; + case 98: /* db_optr ::= db_optr keep */ + case 102: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==102); +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.keep = yymsp[0].minor.yy494; } + yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 97: /* alter_db_optr ::= */ -{ setDefaultCreateDbOption(&yymsp[1].minor.yy118);} + case 99: /* alter_db_optr ::= */ +{ setDefaultCreateDbOption(&yymsp[1].minor.yy158);} break; - case 105: /* typename ::= ids */ + case 107: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; - tSQLSetColumnType (&yylhsminor.yy343, &yymsp[0].minor.yy0); + tSQLSetColumnType (&yylhsminor.yy181, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy343 = yylhsminor.yy343; + yymsp[0].minor.yy181 = yylhsminor.yy181; break; - case 106: /* typename ::= ids LP signed RP */ + case 108: /* typename ::= ids LP signed RP */ { - if (yymsp[-1].minor.yy369 <= 0) { + if (yymsp[-1].minor.yy271 <= 0) { yymsp[-3].minor.yy0.type = 0; - tSQLSetColumnType(&yylhsminor.yy343, &yymsp[-3].minor.yy0); + tSQLSetColumnType(&yylhsminor.yy181, &yymsp[-3].minor.yy0); } else { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy369; // negative value of name length - tSQLSetColumnType(&yylhsminor.yy343, &yymsp[-3].minor.yy0); + yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy271; // negative value of name length + tSQLSetColumnType(&yylhsminor.yy181, &yymsp[-3].minor.yy0); } } - yymsp[-3].minor.yy343 = yylhsminor.yy343; + yymsp[-3].minor.yy181 = yylhsminor.yy181; break; - case 107: /* signed ::= INTEGER */ -{ yylhsminor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[0].minor.yy369 = yylhsminor.yy369; + case 109: /* signed ::= INTEGER */ +{ yylhsminor.yy271 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[0].minor.yy271 = yylhsminor.yy271; break; - case 108: /* signed ::= PLUS INTEGER */ -{ yymsp[-1].minor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + case 110: /* signed ::= PLUS INTEGER */ +{ yymsp[-1].minor.yy271 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 109: /* signed ::= MINUS INTEGER */ -{ yymsp[-1].minor.yy369 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} + case 111: /* signed ::= MINUS INTEGER */ +{ yymsp[-1].minor.yy271 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; - case 110: /* cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */ + case 112: /* cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-2].minor.yy0, &yymsp[-3].minor.yy0); } break; - case 111: /* create_table_args ::= LP columnlist RP */ + case 113: /* create_table_args ::= LP columnlist RP */ { - yymsp[-2].minor.yy398 = tSetCreateSQLElems(yymsp[-1].minor.yy511, NULL, NULL, NULL, NULL, TSQL_CREATE_TABLE); - setSQLInfo(pInfo, yymsp[-2].minor.yy398, NULL, TSDB_SQL_CREATE_TABLE); + yymsp[-2].minor.yy374 = tSetCreateSQLElems(yymsp[-1].minor.yy449, NULL, NULL, NULL, NULL, TSQL_CREATE_TABLE); + setSQLInfo(pInfo, yymsp[-2].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE); } break; - case 112: /* create_table_args ::= LP columnlist RP TAGS LP columnlist RP */ + case 114: /* create_table_args ::= LP columnlist RP TAGS LP columnlist RP */ { - yymsp[-6].minor.yy398 = tSetCreateSQLElems(yymsp[-5].minor.yy511, yymsp[-1].minor.yy511, NULL, NULL, NULL, TSQL_CREATE_STABLE); - setSQLInfo(pInfo, yymsp[-6].minor.yy398, NULL, TSDB_SQL_CREATE_TABLE); + yymsp[-6].minor.yy374 = tSetCreateSQLElems(yymsp[-5].minor.yy449, yymsp[-1].minor.yy449, NULL, NULL, NULL, TSQL_CREATE_STABLE); + setSQLInfo(pInfo, yymsp[-6].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE); } break; - case 113: /* create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */ + case 115: /* create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; - yymsp[-6].minor.yy398 = tSetCreateSQLElems(NULL, NULL, &yymsp[-5].minor.yy0, yymsp[-1].minor.yy156, NULL, TSQL_CREATE_TABLE_FROM_STABLE); - setSQLInfo(pInfo, yymsp[-6].minor.yy398, NULL, TSDB_SQL_CREATE_TABLE); + yymsp[-6].minor.yy374 = tSetCreateSQLElems(NULL, NULL, &yymsp[-5].minor.yy0, yymsp[-1].minor.yy494, NULL, TSQL_CREATE_TABLE_FROM_STABLE); + setSQLInfo(pInfo, yymsp[-6].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE); } break; - case 114: /* create_table_args ::= AS select */ + case 116: /* create_table_args ::= AS select */ { - yymsp[-1].minor.yy398 = tSetCreateSQLElems(NULL, NULL, NULL, NULL, yymsp[0].minor.yy444, TSQL_CREATE_STREAM); - setSQLInfo(pInfo, yymsp[-1].minor.yy398, NULL, TSDB_SQL_CREATE_TABLE); + yymsp[-1].minor.yy374 = tSetCreateSQLElems(NULL, NULL, NULL, NULL, yymsp[0].minor.yy150, TSQL_CREATE_STREAM); + setSQLInfo(pInfo, yymsp[-1].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE); } break; - case 115: /* columnlist ::= columnlist COMMA column */ -{yylhsminor.yy511 = tFieldListAppend(yymsp[-2].minor.yy511, &yymsp[0].minor.yy343); } - yymsp[-2].minor.yy511 = yylhsminor.yy511; + case 117: /* columnlist ::= columnlist COMMA column */ +{yylhsminor.yy449 = tFieldListAppend(yymsp[-2].minor.yy449, &yymsp[0].minor.yy181); } + yymsp[-2].minor.yy449 = yylhsminor.yy449; break; - case 116: /* columnlist ::= column */ -{yylhsminor.yy511 = tFieldListAppend(NULL, &yymsp[0].minor.yy343);} - yymsp[0].minor.yy511 = yylhsminor.yy511; + case 118: /* columnlist ::= column */ +{yylhsminor.yy449 = tFieldListAppend(NULL, &yymsp[0].minor.yy181);} + yymsp[0].minor.yy449 = yylhsminor.yy449; break; - case 117: /* column ::= ids typename */ + case 119: /* column ::= ids typename */ { - tSQLSetColumnInfo(&yylhsminor.yy343, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy343); + tSQLSetColumnInfo(&yylhsminor.yy181, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy181); } - yymsp[-1].minor.yy343 = yylhsminor.yy343; + yymsp[-1].minor.yy181 = yylhsminor.yy181; break; - case 118: /* tagitemlist ::= tagitemlist COMMA tagitem */ -{ yylhsminor.yy156 = tVariantListAppend(yymsp[-2].minor.yy156, &yymsp[0].minor.yy506, -1); } - yymsp[-2].minor.yy156 = yylhsminor.yy156; + case 120: /* tagitemlist ::= tagitemlist COMMA tagitem */ +{ yylhsminor.yy494 = tVariantListAppend(yymsp[-2].minor.yy494, &yymsp[0].minor.yy312, -1); } + yymsp[-2].minor.yy494 = yylhsminor.yy494; break; - case 119: /* tagitemlist ::= tagitem */ -{ yylhsminor.yy156 = tVariantListAppend(NULL, &yymsp[0].minor.yy506, -1); } - yymsp[0].minor.yy156 = yylhsminor.yy156; + case 121: /* tagitemlist ::= tagitem */ +{ yylhsminor.yy494 = tVariantListAppend(NULL, &yymsp[0].minor.yy312, -1); } + yymsp[0].minor.yy494 = yylhsminor.yy494; break; - case 120: /* tagitem ::= INTEGER */ - case 121: /* tagitem ::= FLOAT */ yytestcase(yyruleno==121); - case 122: /* tagitem ::= STRING */ yytestcase(yyruleno==122); - case 123: /* tagitem ::= BOOL */ yytestcase(yyruleno==123); -{toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy506 = yylhsminor.yy506; + case 122: /* tagitem ::= INTEGER */ + case 123: /* tagitem ::= FLOAT */ yytestcase(yyruleno==123); + case 124: /* tagitem ::= STRING */ yytestcase(yyruleno==124); + case 125: /* tagitem ::= BOOL */ yytestcase(yyruleno==125); +{toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy312, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy312 = yylhsminor.yy312; break; - case 124: /* tagitem ::= NULL */ -{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy506 = yylhsminor.yy506; + case 126: /* tagitem ::= NULL */ +{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy312, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy312 = yylhsminor.yy312; break; - case 125: /* tagitem ::= MINUS INTEGER */ - case 126: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==126); - case 127: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==127); - case 128: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==128); + case 127: /* tagitem ::= MINUS INTEGER */ + case 128: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==128); + case 129: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==129); + case 130: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==130); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; toTSDBType(yymsp[-1].minor.yy0.type); - tVariantCreate(&yylhsminor.yy506, &yymsp[-1].minor.yy0); + tVariantCreate(&yylhsminor.yy312, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy506 = yylhsminor.yy506; + yymsp[-1].minor.yy312 = yylhsminor.yy312; break; - case 129: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + case 131: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ { - yylhsminor.yy444 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy158, yymsp[-9].minor.yy156, yymsp[-8].minor.yy190, yymsp[-4].minor.yy156, yymsp[-3].minor.yy156, &yymsp[-7].minor.yy340, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy156, &yymsp[0].minor.yy414, &yymsp[-1].minor.yy414); + yylhsminor.yy150 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy224, yymsp[-9].minor.yy494, yymsp[-8].minor.yy66, yymsp[-4].minor.yy494, yymsp[-3].minor.yy494, &yymsp[-7].minor.yy314, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy494, &yymsp[0].minor.yy188, &yymsp[-1].minor.yy188); } - yymsp[-11].minor.yy444 = yylhsminor.yy444; + yymsp[-11].minor.yy150 = yylhsminor.yy150; break; - case 130: /* union ::= select */ -{ yylhsminor.yy333 = setSubclause(NULL, yymsp[0].minor.yy444); } - yymsp[0].minor.yy333 = yylhsminor.yy333; + case 132: /* union ::= select */ +{ yylhsminor.yy25 = setSubclause(NULL, yymsp[0].minor.yy150); } + yymsp[0].minor.yy25 = yylhsminor.yy25; break; - case 131: /* union ::= LP union RP */ -{ yymsp[-2].minor.yy333 = yymsp[-1].minor.yy333; } + case 133: /* union ::= LP union RP */ +{ yymsp[-2].minor.yy25 = yymsp[-1].minor.yy25; } break; - case 132: /* union ::= union UNION ALL select */ -{ yylhsminor.yy333 = appendSelectClause(yymsp[-3].minor.yy333, yymsp[0].minor.yy444); } - yymsp[-3].minor.yy333 = yylhsminor.yy333; + case 134: /* union ::= union UNION ALL select */ +{ yylhsminor.yy25 = appendSelectClause(yymsp[-3].minor.yy25, yymsp[0].minor.yy150); } + yymsp[-3].minor.yy25 = yylhsminor.yy25; break; - case 133: /* union ::= union UNION ALL LP select RP */ -{ yylhsminor.yy333 = appendSelectClause(yymsp[-5].minor.yy333, yymsp[-1].minor.yy444); } - yymsp[-5].minor.yy333 = yylhsminor.yy333; + case 135: /* union ::= union UNION ALL LP select RP */ +{ yylhsminor.yy25 = appendSelectClause(yymsp[-5].minor.yy25, yymsp[-1].minor.yy150); } + yymsp[-5].minor.yy25 = yylhsminor.yy25; break; - case 134: /* cmd ::= union */ -{ setSQLInfo(pInfo, yymsp[0].minor.yy333, NULL, TSDB_SQL_SELECT); } + case 136: /* cmd ::= union */ +{ setSQLInfo(pInfo, yymsp[0].minor.yy25, NULL, TSDB_SQL_SELECT); } break; - case 135: /* select ::= SELECT selcollist */ + case 137: /* select ::= SELECT selcollist */ { - yylhsminor.yy444 = tSetQuerySQLElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy158, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + yylhsminor.yy150 = tSetQuerySQLElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy224, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } - yymsp[-1].minor.yy444 = yylhsminor.yy444; + yymsp[-1].minor.yy150 = yylhsminor.yy150; break; - case 136: /* sclp ::= selcollist COMMA */ -{yylhsminor.yy158 = yymsp[-1].minor.yy158;} - yymsp[-1].minor.yy158 = yylhsminor.yy158; + case 138: /* sclp ::= selcollist COMMA */ +{yylhsminor.yy224 = yymsp[-1].minor.yy224;} + yymsp[-1].minor.yy224 = yylhsminor.yy224; break; - case 137: /* sclp ::= */ -{yymsp[1].minor.yy158 = 0;} + case 139: /* sclp ::= */ +{yymsp[1].minor.yy224 = 0;} break; - case 138: /* selcollist ::= sclp expr as */ + case 140: /* selcollist ::= sclp expr as */ { - yylhsminor.yy158 = tSQLExprListAppend(yymsp[-2].minor.yy158, yymsp[-1].minor.yy190, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); + yylhsminor.yy224 = tSQLExprListAppend(yymsp[-2].minor.yy224, yymsp[-1].minor.yy66, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } - yymsp[-2].minor.yy158 = yylhsminor.yy158; + yymsp[-2].minor.yy224 = yylhsminor.yy224; break; - case 139: /* selcollist ::= sclp STAR */ + case 141: /* selcollist ::= sclp STAR */ { tSQLExpr *pNode = tSQLExprIdValueCreate(NULL, TK_ALL); - yylhsminor.yy158 = tSQLExprListAppend(yymsp[-1].minor.yy158, pNode, 0); + yylhsminor.yy224 = tSQLExprListAppend(yymsp[-1].minor.yy224, pNode, 0); } - yymsp[-1].minor.yy158 = yylhsminor.yy158; + yymsp[-1].minor.yy224 = yylhsminor.yy224; break; - case 140: /* as ::= AS ids */ + case 142: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 141: /* as ::= ids */ + case 143: /* as ::= ids */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 142: /* as ::= */ + case 144: /* as ::= */ { yymsp[1].minor.yy0.n = 0; } break; - case 143: /* from ::= FROM tablelist */ -{yymsp[-1].minor.yy156 = yymsp[0].minor.yy156;} + case 145: /* from ::= FROM tablelist */ +{yymsp[-1].minor.yy494 = yymsp[0].minor.yy494;} break; - case 144: /* tablelist ::= ids cpxName */ + case 146: /* tablelist ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy156 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); - yylhsminor.yy156 = tVariantListAppendToken(yylhsminor.yy156, &yymsp[-1].minor.yy0, -1); // table alias name + yylhsminor.yy494 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); + yylhsminor.yy494 = tVariantListAppendToken(yylhsminor.yy494, &yymsp[-1].minor.yy0, -1); // table alias name } - yymsp[-1].minor.yy156 = yylhsminor.yy156; + yymsp[-1].minor.yy494 = yylhsminor.yy494; break; - case 145: /* tablelist ::= ids cpxName ids */ + case 147: /* tablelist ::= ids cpxName ids */ { toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type); yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy156 = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - yylhsminor.yy156 = tVariantListAppendToken(yylhsminor.yy156, &yymsp[0].minor.yy0, -1); + yylhsminor.yy494 = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); + yylhsminor.yy494 = tVariantListAppendToken(yylhsminor.yy494, &yymsp[0].minor.yy0, -1); } - yymsp[-2].minor.yy156 = yylhsminor.yy156; + yymsp[-2].minor.yy494 = yylhsminor.yy494; break; - case 146: /* tablelist ::= tablelist COMMA ids cpxName */ + case 148: /* tablelist ::= tablelist COMMA ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy156 = tVariantListAppendToken(yymsp[-3].minor.yy156, &yymsp[-1].minor.yy0, -1); - yylhsminor.yy156 = tVariantListAppendToken(yylhsminor.yy156, &yymsp[-1].minor.yy0, -1); + yylhsminor.yy494 = tVariantListAppendToken(yymsp[-3].minor.yy494, &yymsp[-1].minor.yy0, -1); + yylhsminor.yy494 = tVariantListAppendToken(yylhsminor.yy494, &yymsp[-1].minor.yy0, -1); } - yymsp[-3].minor.yy156 = yylhsminor.yy156; + yymsp[-3].minor.yy494 = yylhsminor.yy494; break; - case 147: /* tablelist ::= tablelist COMMA ids cpxName ids */ + case 149: /* tablelist ::= tablelist COMMA ids cpxName ids */ { toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type); yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy156 = tVariantListAppendToken(yymsp[-4].minor.yy156, &yymsp[-2].minor.yy0, -1); - yylhsminor.yy156 = tVariantListAppendToken(yylhsminor.yy156, &yymsp[0].minor.yy0, -1); + yylhsminor.yy494 = tVariantListAppendToken(yymsp[-4].minor.yy494, &yymsp[-2].minor.yy0, -1); + yylhsminor.yy494 = tVariantListAppendToken(yylhsminor.yy494, &yymsp[0].minor.yy0, -1); } - yymsp[-4].minor.yy156 = yylhsminor.yy156; + yymsp[-4].minor.yy494 = yylhsminor.yy494; break; - case 148: /* tmvar ::= VARIABLE */ + case 150: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 149: /* interval_opt ::= INTERVAL LP tmvar RP */ -{yymsp[-3].minor.yy340.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy340.offset.n = 0; yymsp[-3].minor.yy340.offset.z = NULL; yymsp[-3].minor.yy340.offset.type = 0;} + case 151: /* interval_opt ::= INTERVAL LP tmvar RP */ +{yymsp[-3].minor.yy314.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy314.offset.n = 0; yymsp[-3].minor.yy314.offset.z = NULL; yymsp[-3].minor.yy314.offset.type = 0;} break; - case 150: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ -{yymsp[-5].minor.yy340.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy340.offset = yymsp[-1].minor.yy0;} + case 152: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ +{yymsp[-5].minor.yy314.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy314.offset = yymsp[-1].minor.yy0;} break; - case 151: /* interval_opt ::= */ -{memset(&yymsp[1].minor.yy340, 0, sizeof(yymsp[1].minor.yy340));} + case 153: /* interval_opt ::= */ +{memset(&yymsp[1].minor.yy314, 0, sizeof(yymsp[1].minor.yy314));} break; - case 152: /* fill_opt ::= */ -{yymsp[1].minor.yy156 = 0; } + case 154: /* fill_opt ::= */ +{yymsp[1].minor.yy494 = 0; } break; - case 153: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + case 155: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { tVariant A = {0}; toTSDBType(yymsp[-3].minor.yy0.type); tVariantCreate(&A, &yymsp[-3].minor.yy0); - tVariantListInsert(yymsp[-1].minor.yy156, &A, -1, 0); - yymsp[-5].minor.yy156 = yymsp[-1].minor.yy156; + tVariantListInsert(yymsp[-1].minor.yy494, &A, -1, 0); + yymsp[-5].minor.yy494 = yymsp[-1].minor.yy494; } break; - case 154: /* fill_opt ::= FILL LP ID RP */ + case 156: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); - yymsp[-3].minor.yy156 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); + yymsp[-3].minor.yy494 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; - case 155: /* sliding_opt ::= SLIDING LP tmvar RP */ + case 157: /* sliding_opt ::= SLIDING LP tmvar RP */ {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } break; - case 156: /* sliding_opt ::= */ + case 158: /* sliding_opt ::= */ {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; - case 157: /* orderby_opt ::= */ - case 165: /* groupby_opt ::= */ yytestcase(yyruleno==165); -{yymsp[1].minor.yy156 = 0;} + case 159: /* orderby_opt ::= */ + case 167: /* groupby_opt ::= */ yytestcase(yyruleno==167); +{yymsp[1].minor.yy494 = 0;} break; - case 158: /* orderby_opt ::= ORDER BY sortlist */ - case 166: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==166); -{yymsp[-2].minor.yy156 = yymsp[0].minor.yy156;} + case 160: /* orderby_opt ::= ORDER BY sortlist */ + case 168: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==168); +{yymsp[-2].minor.yy494 = yymsp[0].minor.yy494;} break; - case 159: /* sortlist ::= sortlist COMMA item sortorder */ + case 161: /* sortlist ::= sortlist COMMA item sortorder */ { - yylhsminor.yy156 = tVariantListAppend(yymsp[-3].minor.yy156, &yymsp[-1].minor.yy506, yymsp[0].minor.yy112); + yylhsminor.yy494 = tVariantListAppend(yymsp[-3].minor.yy494, &yymsp[-1].minor.yy312, yymsp[0].minor.yy82); } - yymsp[-3].minor.yy156 = yylhsminor.yy156; + yymsp[-3].minor.yy494 = yylhsminor.yy494; break; - case 160: /* sortlist ::= item sortorder */ + case 162: /* sortlist ::= item sortorder */ { - yylhsminor.yy156 = tVariantListAppend(NULL, &yymsp[-1].minor.yy506, yymsp[0].minor.yy112); + yylhsminor.yy494 = tVariantListAppend(NULL, &yymsp[-1].minor.yy312, yymsp[0].minor.yy82); } - yymsp[-1].minor.yy156 = yylhsminor.yy156; + yymsp[-1].minor.yy494 = yylhsminor.yy494; break; - case 161: /* item ::= ids cpxName */ + case 163: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - tVariantCreate(&yylhsminor.yy506, &yymsp[-1].minor.yy0); + tVariantCreate(&yylhsminor.yy312, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy506 = yylhsminor.yy506; + yymsp[-1].minor.yy312 = yylhsminor.yy312; break; - case 162: /* sortorder ::= ASC */ -{yymsp[0].minor.yy112 = TSDB_ORDER_ASC; } + case 164: /* sortorder ::= ASC */ +{yymsp[0].minor.yy82 = TSDB_ORDER_ASC; } break; - case 163: /* sortorder ::= DESC */ -{yymsp[0].minor.yy112 = TSDB_ORDER_DESC;} + case 165: /* sortorder ::= DESC */ +{yymsp[0].minor.yy82 = TSDB_ORDER_DESC;} break; - case 164: /* sortorder ::= */ -{yymsp[1].minor.yy112 = TSDB_ORDER_ASC;} + case 166: /* sortorder ::= */ +{yymsp[1].minor.yy82 = TSDB_ORDER_ASC;} break; - case 167: /* grouplist ::= grouplist COMMA item */ + case 169: /* grouplist ::= grouplist COMMA item */ { - yylhsminor.yy156 = tVariantListAppend(yymsp[-2].minor.yy156, &yymsp[0].minor.yy506, -1); + yylhsminor.yy494 = tVariantListAppend(yymsp[-2].minor.yy494, &yymsp[0].minor.yy312, -1); } - yymsp[-2].minor.yy156 = yylhsminor.yy156; + yymsp[-2].minor.yy494 = yylhsminor.yy494; break; - case 168: /* grouplist ::= item */ + case 170: /* grouplist ::= item */ { - yylhsminor.yy156 = tVariantListAppend(NULL, &yymsp[0].minor.yy506, -1); + yylhsminor.yy494 = tVariantListAppend(NULL, &yymsp[0].minor.yy312, -1); } - yymsp[0].minor.yy156 = yylhsminor.yy156; + yymsp[0].minor.yy494 = yylhsminor.yy494; break; - case 169: /* having_opt ::= */ - case 179: /* where_opt ::= */ yytestcase(yyruleno==179); - case 217: /* expritem ::= */ yytestcase(yyruleno==217); -{yymsp[1].minor.yy190 = 0;} + case 171: /* having_opt ::= */ + case 181: /* where_opt ::= */ yytestcase(yyruleno==181); + case 219: /* expritem ::= */ yytestcase(yyruleno==219); +{yymsp[1].minor.yy66 = 0;} break; - case 170: /* having_opt ::= HAVING expr */ - case 180: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==180); -{yymsp[-1].minor.yy190 = yymsp[0].minor.yy190;} + case 172: /* having_opt ::= HAVING expr */ + case 182: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==182); +{yymsp[-1].minor.yy66 = yymsp[0].minor.yy66;} break; - case 171: /* limit_opt ::= */ - case 175: /* slimit_opt ::= */ yytestcase(yyruleno==175); -{yymsp[1].minor.yy414.limit = -1; yymsp[1].minor.yy414.offset = 0;} + case 173: /* limit_opt ::= */ + case 177: /* slimit_opt ::= */ yytestcase(yyruleno==177); +{yymsp[1].minor.yy188.limit = -1; yymsp[1].minor.yy188.offset = 0;} break; - case 172: /* limit_opt ::= LIMIT signed */ - case 176: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==176); -{yymsp[-1].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-1].minor.yy414.offset = 0;} + case 174: /* limit_opt ::= LIMIT signed */ + case 178: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==178); +{yymsp[-1].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-1].minor.yy188.offset = 0;} break; - case 173: /* limit_opt ::= LIMIT signed OFFSET signed */ - case 177: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==177); -{yymsp[-3].minor.yy414.limit = yymsp[-2].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[0].minor.yy369;} + case 175: /* limit_opt ::= LIMIT signed OFFSET signed */ + case 179: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==179); +{yymsp[-3].minor.yy188.limit = yymsp[-2].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[0].minor.yy271;} break; - case 174: /* limit_opt ::= LIMIT signed COMMA signed */ - case 178: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==178); -{yymsp[-3].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[-2].minor.yy369;} + case 176: /* limit_opt ::= LIMIT signed COMMA signed */ + case 180: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==180); +{yymsp[-3].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[-2].minor.yy271;} break; - case 181: /* expr ::= LP expr RP */ -{yymsp[-2].minor.yy190 = yymsp[-1].minor.yy190; } + case 183: /* expr ::= LP expr RP */ +{yymsp[-2].minor.yy66 = yymsp[-1].minor.yy66; } break; - case 182: /* expr ::= ID */ -{yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);} - yymsp[0].minor.yy190 = yylhsminor.yy190; + case 184: /* expr ::= ID */ +{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);} + yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 183: /* expr ::= ID DOT ID */ -{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);} - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 185: /* expr ::= ID DOT ID */ +{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);} + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 184: /* expr ::= ID DOT STAR */ -{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);} - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 186: /* expr ::= ID DOT STAR */ +{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);} + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 185: /* expr ::= INTEGER */ -{yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy190 = yylhsminor.yy190; + case 187: /* expr ::= INTEGER */ +{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 186: /* expr ::= MINUS INTEGER */ - case 187: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==187); -{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy190 = yylhsminor.yy190; + case 188: /* expr ::= MINUS INTEGER */ + case 189: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==189); +{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy66 = yylhsminor.yy66; break; - case 188: /* expr ::= FLOAT */ -{yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);} - yymsp[0].minor.yy190 = yylhsminor.yy190; + case 190: /* expr ::= FLOAT */ +{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);} + yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 189: /* expr ::= MINUS FLOAT */ - case 190: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==190); -{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);} - yymsp[-1].minor.yy190 = yylhsminor.yy190; + case 191: /* expr ::= MINUS FLOAT */ + case 192: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==192); +{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);} + yymsp[-1].minor.yy66 = yylhsminor.yy66; break; - case 191: /* expr ::= STRING */ -{yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy190 = yylhsminor.yy190; + case 193: /* expr ::= STRING */ +{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 192: /* expr ::= NOW */ -{yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy190 = yylhsminor.yy190; + case 194: /* expr ::= NOW */ +{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 193: /* expr ::= VARIABLE */ -{yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);} - yymsp[0].minor.yy190 = yylhsminor.yy190; + case 195: /* expr ::= VARIABLE */ +{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);} + yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 194: /* expr ::= BOOL */ -{yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);} - yymsp[0].minor.yy190 = yylhsminor.yy190; + case 196: /* expr ::= BOOL */ +{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);} + yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 195: /* expr ::= ID LP exprlist RP */ -{ yylhsminor.yy190 = tSQLExprCreateFunction(yymsp[-1].minor.yy158, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy190 = yylhsminor.yy190; + case 197: /* expr ::= ID LP exprlist RP */ +{ yylhsminor.yy66 = tSQLExprCreateFunction(yymsp[-1].minor.yy224, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy66 = yylhsminor.yy66; break; - case 196: /* expr ::= ID LP STAR RP */ -{ yylhsminor.yy190 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy190 = yylhsminor.yy190; + case 198: /* expr ::= ID LP STAR RP */ +{ yylhsminor.yy66 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy66 = yylhsminor.yy66; break; - case 197: /* expr ::= expr IS NULL */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, NULL, TK_ISNULL);} - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 199: /* expr ::= expr IS NULL */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, NULL, TK_ISNULL);} + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 198: /* expr ::= expr IS NOT NULL */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-3].minor.yy190, NULL, TK_NOTNULL);} - yymsp[-3].minor.yy190 = yylhsminor.yy190; + case 200: /* expr ::= expr IS NOT NULL */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-3].minor.yy66, NULL, TK_NOTNULL);} + yymsp[-3].minor.yy66 = yylhsminor.yy66; break; - case 199: /* expr ::= expr LT expr */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_LT);} - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 201: /* expr ::= expr LT expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LT);} + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 200: /* expr ::= expr GT expr */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_GT);} - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 202: /* expr ::= expr GT expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_GT);} + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 201: /* expr ::= expr LE expr */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_LE);} - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 203: /* expr ::= expr LE expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LE);} + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 202: /* expr ::= expr GE expr */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_GE);} - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 204: /* expr ::= expr GE expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_GE);} + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 203: /* expr ::= expr NE expr */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_NE);} - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 205: /* expr ::= expr NE expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_NE);} + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 204: /* expr ::= expr EQ expr */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_EQ);} - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 206: /* expr ::= expr EQ expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_EQ);} + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 205: /* expr ::= expr AND expr */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_AND);} - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 207: /* expr ::= expr AND expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_AND);} + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 206: /* expr ::= expr OR expr */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_OR); } - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 208: /* expr ::= expr OR expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_OR); } + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 207: /* expr ::= expr PLUS expr */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_PLUS); } - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 209: /* expr ::= expr PLUS expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_PLUS); } + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 208: /* expr ::= expr MINUS expr */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_MINUS); } - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 210: /* expr ::= expr MINUS expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_MINUS); } + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 209: /* expr ::= expr STAR expr */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_STAR); } - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 211: /* expr ::= expr STAR expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_STAR); } + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 210: /* expr ::= expr SLASH expr */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_DIVIDE);} - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 212: /* expr ::= expr SLASH expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_DIVIDE);} + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 211: /* expr ::= expr REM expr */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_REM); } - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 213: /* expr ::= expr REM expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_REM); } + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 212: /* expr ::= expr LIKE expr */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_LIKE); } - yymsp[-2].minor.yy190 = yylhsminor.yy190; + case 214: /* expr ::= expr LIKE expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LIKE); } + yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 213: /* expr ::= expr IN LP exprlist RP */ -{yylhsminor.yy190 = tSQLExprCreate(yymsp[-4].minor.yy190, (tSQLExpr*)yymsp[-1].minor.yy158, TK_IN); } - yymsp[-4].minor.yy190 = yylhsminor.yy190; + case 215: /* expr ::= expr IN LP exprlist RP */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-4].minor.yy66, (tSQLExpr*)yymsp[-1].minor.yy224, TK_IN); } + yymsp[-4].minor.yy66 = yylhsminor.yy66; break; - case 214: /* exprlist ::= exprlist COMMA expritem */ -{yylhsminor.yy158 = tSQLExprListAppend(yymsp[-2].minor.yy158,yymsp[0].minor.yy190,0);} - yymsp[-2].minor.yy158 = yylhsminor.yy158; + case 216: /* exprlist ::= exprlist COMMA expritem */ +{yylhsminor.yy224 = tSQLExprListAppend(yymsp[-2].minor.yy224,yymsp[0].minor.yy66,0);} + yymsp[-2].minor.yy224 = yylhsminor.yy224; break; - case 215: /* exprlist ::= expritem */ -{yylhsminor.yy158 = tSQLExprListAppend(0,yymsp[0].minor.yy190,0);} - yymsp[0].minor.yy158 = yylhsminor.yy158; + case 217: /* exprlist ::= expritem */ +{yylhsminor.yy224 = tSQLExprListAppend(0,yymsp[0].minor.yy66,0);} + yymsp[0].minor.yy224 = yylhsminor.yy224; break; - case 216: /* expritem ::= expr */ -{yylhsminor.yy190 = yymsp[0].minor.yy190;} - yymsp[0].minor.yy190 = yylhsminor.yy190; + case 218: /* expritem ::= expr */ +{yylhsminor.yy66 = yymsp[0].minor.yy66;} + yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 218: /* cmd ::= RESET QUERY CACHE */ + case 220: /* cmd ::= RESET QUERY CACHE */ { setDCLSQLElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 219: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 221: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy511, NULL, TSDB_ALTER_TABLE_ADD_COLUMN); + SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy449, NULL, TSDB_ALTER_TABLE_ADD_COLUMN); setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 220: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 222: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3021,14 +2786,14 @@ static YYACTIONTYPE yy_reduce( setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 221: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 223: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy511, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN); + SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy449, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN); setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 222: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 224: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3039,7 +2804,7 @@ static YYACTIONTYPE yy_reduce( setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 223: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 225: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3053,34 +2818,34 @@ static YYACTIONTYPE yy_reduce( setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 224: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 226: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; toTSDBType(yymsp[-2].minor.yy0.type); tVariantList* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - A = tVariantListAppend(A, &yymsp[0].minor.yy506, -1); + A = tVariantListAppend(A, &yymsp[0].minor.yy312, -1); SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL); setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 225: /* cmd ::= KILL CONNECTION INTEGER */ + case 227: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSQL(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 226: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 228: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSQL(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);} break; - case 227: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 229: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSQL(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);} break; default: break; /********** End reduce actions ************************************************/ }; - assert( yyrulenostateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yyTraceShift(yypParser, yyact, "... then shift"); - return yyact; } /* @@ -3105,8 +2869,7 @@ static YYACTIONTYPE yy_reduce( static void yy_parse_failed( yyParser *yypParser /* The parser */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); @@ -3117,8 +2880,7 @@ static void yy_parse_failed( ** parser fails */ /************ Begin %parse_failure code ***************************************/ /************ End %parse_failure code *****************************************/ - ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ - ParseCTX_STORE + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } #endif /* YYNOERRORRECOVERY */ @@ -3130,8 +2892,7 @@ static void yy_syntax_error( int yymajor, /* The major type of the error token */ ParseTOKENTYPE yyminor /* The minor type of the error token */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ @@ -3157,8 +2918,7 @@ static void yy_syntax_error( assert(len <= outputBufLen); /************ End %syntax_error code ******************************************/ - ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ - ParseCTX_STORE + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* @@ -3167,8 +2927,7 @@ static void yy_syntax_error( static void yy_accept( yyParser *yypParser /* The parser */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); @@ -3183,8 +2942,7 @@ static void yy_accept( /*********** Begin %parse_accept code *****************************************/ /*********** End %parse_accept code *******************************************/ - ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ - ParseCTX_STORE + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* The main parser program. @@ -3213,47 +2971,45 @@ void Parse( ParseARG_PDECL /* Optional %extra_argument parameter */ ){ YYMINORTYPE yyminorunion; - YYACTIONTYPE yyact; /* The parser action. */ + unsigned int yyact; /* The parser action. */ #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) int yyendofinput; /* True if we are at the end of input */ #endif #ifdef YYERRORSYMBOL int yyerrorhit = 0; /* True if yymajor has invoked an error */ #endif - yyParser *yypParser = (yyParser*)yyp; /* The parser */ - ParseCTX_FETCH - ParseARG_STORE + yyParser *yypParser; /* The parser */ + yypParser = (yyParser*)yyp; assert( yypParser->yytos!=0 ); #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) yyendofinput = (yymajor==0); #endif + ParseARG_STORE; - yyact = yypParser->yytos->stateno; #ifndef NDEBUG if( yyTraceFILE ){ - if( yyact < YY_MIN_REDUCE ){ + int stateno = yypParser->yytos->stateno; + if( stateno < YY_MIN_REDUCE ){ fprintf(yyTraceFILE,"%sInput '%s' in state %d\n", - yyTracePrompt,yyTokenName[yymajor],yyact); + yyTracePrompt,yyTokenName[yymajor],stateno); }else{ fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n", - yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE); + yyTracePrompt,yyTokenName[yymajor],stateno-YY_MIN_REDUCE); } } #endif do{ - assert( yyact==yypParser->yytos->stateno ); - yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); + yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); if( yyact >= YY_MIN_REDUCE ){ - yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, - yyminor ParseCTX_PARAM); + yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,yyminor); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ - yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); + yy_shift(yypParser,yyact,yymajor,yyminor); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt--; #endif - break; + yymajor = YYNOCODE; }else if( yyact==YY_ACCEPT_ACTION ){ yypParser->yytos--; yy_accept(yypParser); @@ -3304,9 +3060,10 @@ void Parse( yymajor = YYNOCODE; }else{ while( yypParser->yytos >= yypParser->yystack + && yymx != YYERRORSYMBOL && (yyact = yy_find_reduce_action( yypParser->yytos->stateno, - YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE + YYERRORSYMBOL)) >= YY_MIN_REDUCE ){ yy_pop_parser_stack(yypParser); } @@ -3323,8 +3080,6 @@ void Parse( } yypParser->yyerrcnt = 3; yyerrorhit = 1; - if( yymajor==YYNOCODE ) break; - yyact = yypParser->yytos->stateno; #elif defined(YYNOERRORRECOVERY) /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to ** do any kind of error recovery. Instead, simply invoke the syntax @@ -3335,7 +3090,8 @@ void Parse( */ yy_syntax_error(yypParser,yymajor, yyminor); yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - break; + yymajor = YYNOCODE; + #else /* YYERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: ** @@ -3357,10 +3113,10 @@ void Parse( yypParser->yyerrcnt = -1; #endif } - break; + yymajor = YYNOCODE; #endif } - }while( yypParser->yytos>yypParser->yystack ); + }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack ); #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; @@ -3375,17 +3131,3 @@ void Parse( #endif return; } - -/* -** Return the fallback token corresponding to canonical token iToken, or -** 0 if iToken has no fallback. -*/ -int ParseFallback(int iToken){ -#ifdef YYFALLBACK - assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); - return yyFallback[iToken]; -#else - (void)iToken; - return 0; -#endif -} diff --git a/src/query/tests/tsBufTest.cpp b/src/query/tests/tsBufTest.cpp index b78c5314f243874e348748a6434d224592489528..8cd3a9cbef0bbf268db074a935a7b25cb389944e 100644 --- a/src/query/tests/tsBufTest.cpp +++ b/src/query/tests/tsBufTest.cpp @@ -304,7 +304,7 @@ void TSTraverse() { int32_t totalOutput = 10; while (1) { STSElem elem = tsBufGetElem(pTSBuf); - printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.vnode, elem.tag.i64Key, elem.ts); + printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.vnode, elem.tag->i64Key, elem.ts); if (!tsBufNextPos(pTSBuf)) { break; @@ -352,7 +352,7 @@ void TSTraverse() { totalOutput = 10; while (1) { STSElem elem = tsBufGetElem(pTSBuf); - printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.vnode, elem.tag.i64Key, elem.ts); + printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.vnode, elem.tag->i64Key, elem.ts); if (!tsBufNextPos(pTSBuf)) { break; @@ -416,8 +416,8 @@ void mergeDiffVnodeBufferTest() { int64_t* list = createTsList(num, start, step); t.i64Key = i; - tsBufAppend(pTSBuf1, 0, &t, (const char*)list, num * sizeof(int64_t)); - tsBufAppend(pTSBuf2, 0, &t, (const char*)list, num * sizeof(int64_t)); + tsBufAppend(pTSBuf1, 1, &t, (const char*)list, num * sizeof(int64_t)); + tsBufAppend(pTSBuf2, 9, &t, (const char*)list, num * sizeof(int64_t)); free(list); @@ -426,7 +426,7 @@ void mergeDiffVnodeBufferTest() { tsBufFlush(pTSBuf2); - tsBufMerge(pTSBuf1, pTSBuf2, 9); + tsBufMerge(pTSBuf1, pTSBuf2); EXPECT_EQ(pTSBuf1->numOfVnodes, 2); EXPECT_EQ(pTSBuf1->numOfTotal, numOfTags * 2 * num); @@ -459,8 +459,6 @@ void mergeIdenticalVnodeBufferTest() { start += step * num; } - - for (int32_t i = numOfTags; i < numOfTags * 2; ++i) { int64_t* list = createTsList(num, start, step); @@ -473,7 +471,7 @@ void mergeIdenticalVnodeBufferTest() { tsBufFlush(pTSBuf2); - tsBufMerge(pTSBuf1, pTSBuf2, 12); + tsBufMerge(pTSBuf1, pTSBuf2); EXPECT_EQ(pTSBuf1->numOfVnodes, 1); EXPECT_EQ(pTSBuf1->numOfTotal, numOfTags * 2 * num); @@ -482,7 +480,7 @@ void mergeIdenticalVnodeBufferTest() { STSElem elem = tsBufGetElem(pTSBuf1); EXPECT_EQ(elem.vnode, 12); - printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.vnode, elem.tag.i64Key, elem.ts); + printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.vnode, elem.tag->i64Key, elem.ts); } tsBufDestroy(pTSBuf1); diff --git a/src/rpc/src/rpcCache.c b/src/rpc/src/rpcCache.c index 751f03e52ac3d8b4cb1a36f7330bbd4c7faef328..46b0d4e3bb9428f98c1022556f2f57c6ec0e9a14 100644 --- a/src/rpc/src/rpcCache.c +++ b/src/rpc/src/rpcCache.c @@ -216,6 +216,7 @@ static void rpcCleanConnCache(void *handle, void *tmrId) { if (pCache == NULL || pCache->maxSessions == 0) return; if (pCache->pTimer != tmrId) return; + pthread_mutex_lock(&pCache->mutex); uint64_t time = taosGetTimestampMs(); for (hash = 0; hash < pCache->maxSessions; ++hash) { @@ -227,6 +228,7 @@ static void rpcCleanConnCache(void *handle, void *tmrId) { // tTrace("timer, total connections in cache:%d", pCache->total); taosTmrReset(rpcCleanConnCache, (int32_t)(pCache->keepTimer * 2), pCache, pCache->tmrCtrl, &pCache->pTimer); + pthread_mutex_unlock(&pCache->mutex); } static void rpcRemoveExpiredNodes(SConnCache *pCache, SConnHash *pNode, int hash, uint64_t time) { diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index f59bf62ec504444c561107bb5b5dcf3ec6f8c000..6e9088d9fb82a80bb28857d563ad51f19594e6b7 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -195,7 +195,7 @@ static void rpcSendMsgToPeer(SRpcConn *pConn, void *data, int dataLen); static void rpcSendReqHead(SRpcConn *pConn); static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv); -static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead); +static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead, SRpcReqContext *pContext); static void rpcProcessConnError(void *param, void *id); static void rpcProcessRetryTimer(void *, void *); static void rpcProcessIdleTimer(void *param, void *tmrId); @@ -240,7 +240,7 @@ void *rpcOpen(const SRpcInit *pInit) { size_t size = sizeof(SRpcConn) * pRpc->sessions; pRpc->connList = (SRpcConn *)calloc(1, size); if (pRpc->connList == NULL) { - tError("%s failed to allocate memory for taos connections, size:%ld", pRpc->label, size); + tError("%s failed to allocate memory for taos connections, size:%" PRId64, pRpc->label, (int64_t)size); rpcClose(pRpc); return NULL; } @@ -323,17 +323,17 @@ void *rpcMallocCont(int contLen) { tError("failed to malloc msg, size:%d", size); return NULL; } else { - tDebug("malloc mem: %p", start); + tTrace("malloc mem: %p", start); } return start + sizeof(SRpcReqContext) + sizeof(SRpcHead); } void rpcFreeCont(void *cont) { - if ( cont ) { + if (cont) { char *temp = ((char *)cont) - sizeof(SRpcHead) - sizeof(SRpcReqContext); free(temp); - tDebug("free mem: %p", temp); + tTrace("free mem: %p", temp); } } @@ -412,7 +412,7 @@ void rpcSendResponse(const SRpcMsg *pRsp) { rpcLockConn(pConn); if ( pConn->inType == 0 || pConn->user[0] == 0 ) { - tDebug("%s, connection is already released, rsp wont be sent", pConn->info); + tError("%s, connection is already released, rsp wont be sent", pConn->info); rpcUnlockConn(pConn); rpcFreeCont(pMsg->pCont); rpcDecRef(pRpc); @@ -542,10 +542,7 @@ void rpcCancelRequest(void *handle) { if (pContext->pConn) { tDebug("%s, app tries to cancel request", pContext->pConn->info); - pContext->pConn->pReqMsg = NULL; rpcCloseConn(pContext->pConn); - pContext->pConn = NULL; - rpcFreeCont(pContext->pCont); } } @@ -553,7 +550,7 @@ static void rpcFreeMsg(void *msg) { if ( msg ) { char *temp = (char *)msg - sizeof(SRpcReqContext); free(temp); - tDebug("free mem: %p", temp); + tTrace("free mem: %p", temp); } } @@ -580,6 +577,8 @@ static SRpcConn *rpcOpenConn(SRpcInfo *pRpc, char *peerFqdn, uint16_t peerPort, void *shandle = (connType & RPC_CONN_TCP)? pRpc->tcphandle:pRpc->udphandle; pConn->chandle = (*taosOpenConn[connType])(shandle, pConn, pConn->peerIp, pConn->peerPort); if (pConn->chandle == NULL) { + tError("failed to connect to:0x%x:%d", pConn->peerIp, pConn->peerPort); + terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL; rpcCloseConn(pConn); pConn = NULL; @@ -611,8 +610,10 @@ static void rpcReleaseConn(SRpcConn *pConn) { if (pConn->pReqMsg) rpcFreeCont(pConn->pReqMsg); // do not use rpcFreeMsg } else { // if there is an outgoing message, free it - if (pConn->outType && pConn->pReqMsg) + if (pConn->outType && pConn->pReqMsg) { + if (pConn->pContext) pConn->pContext->pConn = NULL; rpcFreeMsg(pConn->pReqMsg); + } } // memset could not be used, since lockeBy can not be reset @@ -817,9 +818,18 @@ static int rpcProcessReqHead(SRpcConn *pConn, SRpcHead *pHead) { return TSDB_CODE_RPC_LAST_SESSION_NOT_FINISHED; } + if (rpcContLenFromMsg(pHead->msgLen) <= 0) { + tDebug("%s, message body is empty, ignore", pConn->info); + return TSDB_CODE_RPC_APP_ERROR; + } + pConn->inTranId = pHead->tranId; pConn->inType = pHead->msgType; + // start the progress timer to monitor the response from server app + if (pConn->connType != RPC_CONN_TCPS) + pConn->pTimer = taosTmrStart(rpcProcessProgressTimer, tsProgressTimer, pConn, pConn->pRpc->tmrCtrl); + return 0; } @@ -879,17 +889,32 @@ static int rpcProcessRspHead(SRpcConn *pConn, SRpcHead *pHead) { pConn->outType = 0; pConn->pReqMsg = NULL; pConn->reqMsgLen = 0; + SRpcReqContext *pContext = pConn->pContext; + + if (pHead->code == TSDB_CODE_RPC_REDIRECT) { + if (rpcContLenFromMsg(pHead->msgLen) < sizeof(SRpcEpSet)) { + // if EpSet is not included in the msg, treat it as NOT_READY + pHead->code = TSDB_CODE_RPC_NOT_READY; + } else { + pContext->redirect++; + if (pContext->redirect > TSDB_MAX_REPLICA) { + pHead->code = TSDB_CODE_RPC_NETWORK_UNAVAIL; + tWarn("%s, too many redirects, quit", pConn->info); + } + } + } return TSDB_CODE_SUCCESS; } -static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) { +static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv, SRpcReqContext **ppContext) { int32_t sid; SRpcConn *pConn = NULL; SRpcHead *pHead = (SRpcHead *)pRecv->msg; sid = htonl(pHead->destId); + *ppContext = NULL; if (pHead->msgType >= TSDB_MSG_TYPE_MAX || pHead->msgType <= 0) { tDebug("%s sid:%d, invalid message type:%d", pRpc->label, sid, pHead->msgType); @@ -943,6 +968,7 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) { pConn->pIdleTimer = taosTmrStart(rpcProcessIdleTimer, tsRpcTimer*2, pConn, pRpc->tmrCtrl); } else { terrno = rpcProcessRspHead(pConn, pHead); + *ppContext = pConn->pContext; } } @@ -1007,7 +1033,8 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) { } terrno = 0; - pConn = rpcProcessMsgHead(pRpc, pRecv); + SRpcReqContext *pContext; + pConn = rpcProcessMsgHead(pRpc, pRecv, &pContext); if (pHead->msgType >= 1 && pHead->msgType < TSDB_MSG_TYPE_MAX) { tDebug("%s %p %p, %s received from 0x%x:%hu, parse code:0x%x len:%d sig:0x%08x:0x%08x:%d code:0x%x", pRpc->label, @@ -1024,10 +1051,13 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) { if (code != 0) { // parsing error if (rpcIsReq(pHead->msgType)) { rpcSendErrorMsgToPeer(pRecv, code); + if (code == TSDB_CODE_RPC_INVALID_TIME_STAMP || code == TSDB_CODE_RPC_AUTH_FAILURE) { + rpcCloseConn(pConn); + } tDebug("%s %p %p, %s is sent with error code:0x%x", pRpc->label, pConn, (void *)pHead->ahandle, taosMsg[pHead->msgType+1], code); } } else { // msg is passed to app only parsing is ok - rpcProcessIncomingMsg(pConn, pHead); + rpcProcessIncomingMsg(pConn, pHead, pContext); } } @@ -1058,7 +1088,7 @@ static void rpcNotifyClient(SRpcReqContext *pContext, SRpcMsg *pMsg) { rpcFreeCont(pContext->pCont); } -static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) { +static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead, SRpcReqContext *pContext) { SRpcInfo *pRpc = pConn->pRpc; SRpcMsg rpcMsg; @@ -1068,29 +1098,18 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) { rpcMsg.pCont = pHead->content; rpcMsg.msgType = pHead->msgType; rpcMsg.code = pHead->code; - rpcMsg.ahandle = pConn->ahandle; if ( rpcIsReq(pHead->msgType) ) { - if (rpcMsg.contLen > 0) { - rpcMsg.handle = pConn; - rpcAddRef(pRpc); // add the refCount for requests + rpcMsg.ahandle = pConn->ahandle; + rpcMsg.handle = pConn; + rpcAddRef(pRpc); // add the refCount for requests - // start the progress timer to monitor the response from server app - if (pConn->connType != RPC_CONN_TCPS) - pConn->pTimer = taosTmrStart(rpcProcessProgressTimer, tsProgressTimer, pConn, pRpc->tmrCtrl); - - // notify the server app - (*(pRpc->cfp))(&rpcMsg, NULL); - } else { - tDebug("%s, message body is empty, ignore", pConn->info); - rpcFreeCont(rpcMsg.pCont); - } + // notify the server app + (*(pRpc->cfp))(&rpcMsg, NULL); } else { // it's a response - SRpcReqContext *pContext = pConn->pContext; rpcMsg.handle = pContext; - pConn->pContext = NULL; - pConn->pReqMsg = NULL; + rpcMsg.ahandle = pContext->ahandle; // for UDP, port may be changed by server, the port in epSet shall be used for cache if (pHead->code != TSDB_CODE_RPC_TOO_SLOW) { @@ -1099,27 +1118,18 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) { rpcCloseConn(pConn); } - if (pHead->code == TSDB_CODE_RPC_REDIRECT) { - if (rpcMsg.contLen < sizeof(SRpcEpSet)) { - // if EpSet is not included in the msg, treat it as NOT_READY - pHead->code = TSDB_CODE_RPC_NOT_READY; - } else { - pContext->redirect++; - if (pContext->redirect > TSDB_MAX_REPLICA) { - pHead->code = TSDB_CODE_RPC_NETWORK_UNAVAIL; - tWarn("%s, too many redirects, quit", pConn->info); - } - } - } - if (pHead->code == TSDB_CODE_RPC_REDIRECT) { pContext->numOfTry = 0; SRpcEpSet *pEpSet = (SRpcEpSet*)pHead->content; if (pEpSet->numOfEps > 0) { memcpy(&pContext->epSet, pHead->content, sizeof(pContext->epSet)); - tDebug("%s, redirect is received, numOfEps:%d", pConn->info, pContext->epSet.numOfEps); - for (int i=0; iepSet.numOfEps; ++i) + tDebug("%s, redirect is received, numOfEps:%d inUse:%d", pConn->info, pContext->epSet.numOfEps, + pContext->epSet.inUse); + for (int i = 0; i < pContext->epSet.numOfEps; ++i) { pContext->epSet.port[i] = htons(pContext->epSet.port[i]); + tDebug("%s, redirect is received, index:%d ep:%s:%u", pConn->info, i, pContext->epSet.fqdn[i], + pContext->epSet.port[i]); + } } rpcSendReqToServer(pRpc, pContext); rpcFreeCont(rpcMsg.pCont); @@ -1443,7 +1453,7 @@ static SRpcHead *rpcDecompressRpcMsg(SRpcHead *pHead) { pNewHead->msgLen = rpcMsgLenFromCont(origLen); rpcFreeMsg(pHead); // free the compressed message buffer pHead = pNewHead; - //tTrace("decompress rpc msg, compLen:%d, after:%d", compLen, contLen); + tTrace("decomp malloc mem: %p", temp); } else { tError("failed to allocate memory to decompress msg, contLen:%d", contLen); } diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index 56b3fa8616089e72cfb9ba55e96520fa084a0176..bc8d360d39509ce9a2fdbe6a9dd883c5c5c99190 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -62,7 +62,7 @@ typedef struct { char label[TSDB_LABEL_LEN]; int numOfThreads; void * shandle; - SThreadObj *pThreadObj; + SThreadObj **pThreadObj; pthread_t thread; } SServerObj; @@ -90,7 +90,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread tstrncpy(pServerObj->label, label, sizeof(pServerObj->label)); pServerObj->numOfThreads = numOfThreads; - pServerObj->pThreadObj = (SThreadObj *)calloc(sizeof(SThreadObj), numOfThreads); + pServerObj->pThreadObj = (SThreadObj **)calloc(sizeof(SThreadObj *), numOfThreads); if (pServerObj->pThreadObj == NULL) { tError("TCP:%s no enough memory", label); terrno = TAOS_SYSTEM_ERROR(errno); @@ -104,19 +104,28 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); // initialize parameters in case it may encounter error later - pThreadObj = pServerObj->pThreadObj; for (int i = 0; i < numOfThreads; ++i) { + pThreadObj = (SThreadObj *)calloc(sizeof(SThreadObj), 1); + if (pThreadObj == NULL) { + tError("TCP:%s no enough memory", label); + terrno = TAOS_SYSTEM_ERROR(errno); + for (int j=0; jpThreadObj[j]); + free(pServerObj->pThreadObj); + free(pServerObj); + return NULL; + } + + pServerObj->pThreadObj[i] = pThreadObj; pThreadObj->pollFd = -1; taosResetPthread(&pThreadObj->thread); pThreadObj->processData = fp; tstrncpy(pThreadObj->label, label, sizeof(pThreadObj->label)); pThreadObj->shandle = shandle; - pThreadObj++; } // initialize mutex, thread, fd which may fail - pThreadObj = pServerObj->pThreadObj; for (int i = 0; i < numOfThreads; ++i) { + pThreadObj = pServerObj->pThreadObj[i]; code = pthread_mutex_init(&(pThreadObj->mutex), NULL); if (code < 0) { tError("%s failed to init TCP process data mutex(%s)", label, strerror(errno)); @@ -137,7 +146,6 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread } pThreadObj->threadId = i; - pThreadObj++; } pServerObj->fd = taosOpenTcpServerSocket(pServerObj->ip, pServerObj->port); @@ -166,7 +174,15 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) { pThreadObj->stop = true; eventfd_t fd = -1; - if (taosCheckPthreadValid(pThreadObj->thread) && pThreadObj->pollFd >= 0) { + // save thread into local variable since pThreadObj is freed when thread exits + pthread_t thread = pThreadObj->thread; + + if (taosComparePthread(pThreadObj->thread, pthread_self())) { + pthread_detach(pthread_self()); + return; + } + + if (taosCheckPthreadValid(pThreadObj->thread)) { // signal the thread to stop, try graceful method first, // and use pthread_cancel when failed struct epoll_event event = { .events = EPOLLIN }; @@ -183,15 +199,12 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) { } } - if (taosCheckPthreadValid(pThreadObj->thread)) pthread_join(pThreadObj->thread, NULL); - if (pThreadObj->pollFd >=0) taosCloseSocket(pThreadObj->pollFd); - if (fd != -1) taosCloseSocket(fd); - - while (pThreadObj->pHead) { - SFdObj *pFdObj = pThreadObj->pHead; - pThreadObj->pHead = pFdObj->next; - taosFreeFdObj(pFdObj); + // at this step, pThreadObj has already been released + if (taosCheckPthreadValid(thread)) { + pthread_join(thread, NULL); } + + if (fd != -1) taosCloseSocket(fd); } void taosStopTcpServer(void *handle) { @@ -199,7 +212,14 @@ void taosStopTcpServer(void *handle) { if (pServerObj == NULL) return; if(pServerObj->fd >=0) shutdown(pServerObj->fd, SHUT_RD); - if (taosCheckPthreadValid(pServerObj->thread)) pthread_join(pServerObj->thread, NULL); + + if (taosCheckPthreadValid(pServerObj->thread)) { + if (taosComparePthread(pServerObj->thread, pthread_self())) { + pthread_detach(pthread_self()); + } else { + pthread_join(pServerObj->thread, NULL); + } + } tDebug("%s TCP server is stopped", pServerObj->label); } @@ -210,9 +230,8 @@ void taosCleanUpTcpServer(void *handle) { if (pServerObj == NULL) return; for (int i = 0; i < pServerObj->numOfThreads; ++i) { - pThreadObj = pServerObj->pThreadObj + i; + pThreadObj = pServerObj->pThreadObj[i]; taosStopTcpThread(pThreadObj); - pthread_mutex_destroy(&(pThreadObj->mutex)); } tDebug("%s TCP server is cleaned up", pServerObj->label); @@ -249,7 +268,7 @@ static void *taosAcceptTcpConnection(void *arg) { taosSetSockOpt(connFd, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof(to)); // pick up the thread to handle this connection - pThreadObj = pServerObj->pThreadObj + threadId; + pThreadObj = pServerObj->pThreadObj[threadId]; SFdObj *pFdObj = taosMallocFdObj(pThreadObj, connFd); if (pFdObj) { @@ -327,10 +346,8 @@ void taosCleanUpTcpClient(void *chandle) { SThreadObj *pThreadObj = chandle; if (pThreadObj == NULL) return; + tDebug ("%s TCP client will be cleaned up", pThreadObj->label); taosStopTcpThread(pThreadObj); - tDebug ("%s TCP client is cleaned up", pThreadObj->label); - - taosTFree(pThreadObj); } void *taosOpenTcpClientConnection(void *shandle, void *thandle, uint32_t ip, uint16_t port) { @@ -365,7 +382,7 @@ void *taosOpenTcpClientConnection(void *shandle, void *thandle, uint32_t ip, uin void taosCloseTcpConnection(void *chandle) { SFdObj *pFdObj = chandle; - if (pFdObj == NULL) return; + if (pFdObj == NULL || pFdObj->signature != pFdObj) return; SThreadObj *pThreadObj = pFdObj->pThreadObj; tDebug("%s %p TCP connection will be closed, FD:%p", pThreadObj->label, pFdObj->thandle, pFdObj); @@ -378,7 +395,7 @@ void taosCloseTcpConnection(void *chandle) { int taosSendTcpData(uint32_t ip, uint16_t port, void *data, int len, void *chandle) { SFdObj *pFdObj = chandle; - if (chandle == NULL) return -1; + if (pFdObj == NULL || pFdObj->signature != pFdObj) return -1; return taosWriteMsg(pFdObj->fd, data, len); } @@ -421,11 +438,11 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) { msgLen = (int32_t)htonl((uint32_t)rpcHead.msgLen); buffer = malloc(msgLen + tsRpcOverhead); - if ( NULL == buffer) { + if (NULL == buffer) { tError("%s %p TCP malloc(size:%d) fail", pThreadObj->label, pFdObj->thandle, msgLen); return -1; } else { - tDebug("TCP malloc mem: %p", buffer); + tTrace("TCP malloc mem: %p", buffer); } msg = buffer + tsRpcOverhead; @@ -503,8 +520,22 @@ static void *taosProcessTcpData(void *param) { pFdObj->thandle = (*(pThreadObj->processData))(&recvInfo); if (pFdObj->thandle == NULL) taosFreeFdObj(pFdObj); } + + if (pThreadObj->stop) break; } + if (pThreadObj->pollFd >=0) taosCloseSocket(pThreadObj->pollFd); + + while (pThreadObj->pHead) { + SFdObj *pFdObj = pThreadObj->pHead; + pThreadObj->pHead = pFdObj->next; + taosReportBrokenLink(pFdObj); + } + + pthread_mutex_destroy(&(pThreadObj->mutex)); + tDebug("%s TCP thread exits ...", pThreadObj->label); + taosTFree(pThreadObj); + return NULL; } diff --git a/src/rpc/src/rpcUdp.c b/src/rpc/src/rpcUdp.c index 8e24aed8f789f03ef324c05922c38ecefe747256..6f653046615f162c516b5eebf08995d30c6214d7 100644 --- a/src/rpc/src/rpcUdp.c +++ b/src/rpc/src/rpcUdp.c @@ -211,10 +211,10 @@ static void *taosRecvUdpData(void *param) { char *tmsg = malloc(dataLen + tsRpcOverhead); if (NULL == tmsg) { - tError("%s failed to allocate memory, size:%ld", pConn->label, dataLen); + tError("%s failed to allocate memory, size:%" PRId64, pConn->label, (int64_t)dataLen); continue; } else { - tDebug("UDP malloc mem: %p", tmsg); + tTrace("UDP malloc mem: %p", tmsg); } tmsg += tsRpcOverhead; // overhead for SRpcReqContext diff --git a/src/sync/CMakeLists.txt b/src/sync/CMakeLists.txt index efdf2bd185cb5db46d7f0918725ebe8886d5bd98..60271c771ca0a01bd449cb878fe2269759250fd3 100644 --- a/src/sync/CMakeLists.txt +++ b/src/sync/CMakeLists.txt @@ -5,14 +5,14 @@ INCLUDE_DIRECTORIES(inc) AUX_SOURCE_DIRECTORY(src SRC) IF (TD_LINUX) - LIST(REMOVE_ITEM SRC ./src/tarbitrator.c) + LIST(REMOVE_ITEM SRC src/tarbitrator.c) ADD_LIBRARY(sync ${SRC}) TARGET_LINK_LIBRARIES(sync tutil pthread common) - LIST(APPEND BIN_SRC ./src/tarbitrator.c) - LIST(APPEND BIN_SRC ./src/taosTcpPool.c) + LIST(APPEND BIN_SRC src/tarbitrator.c) + LIST(APPEND BIN_SRC src/taosTcpPool.c) ADD_EXECUTABLE(tarbitrator ${BIN_SRC}) TARGET_LINK_LIBRARIES(tarbitrator sync common osdetail tutil) - ADD_SUBDIRECTORY(test) + #ADD_SUBDIRECTORY(test) ENDIF () diff --git a/src/sync/inc/syncInt.h b/src/sync/inc/syncInt.h index cd1252f4b414f5ad2dcd56e2a7969ab433e40452..f6818106462cb9c9d694d59c7cb9012cd1a54c8b 100644 --- a/src/sync/inc/syncInt.h +++ b/src/sync/inc/syncInt.h @@ -114,26 +114,26 @@ typedef struct { } SSyncFwds; typedef struct SsyncPeer { - int32_t nodeId; - uint32_t ip; - uint16_t port; - char fqdn[TSDB_FQDN_LEN]; // peer ip string - char id[TSDB_EP_LEN+16]; // peer vgId + end point - int8_t role; - int8_t sstatus; // sync status - uint64_t version; - uint64_t sversion; // track the peer version in retrieve process - int syncFd; - int peerFd; // forward FD - int numOfRetrieves; // number of retrieves tried - int fileChanged; // a flag to indicate file is changed during retrieving process - void *timer; - void *pConn; - int notifyFd; - int watchNum; - int *watchFd; - int8_t refCount; // reference count - struct SSyncNode *pSyncNode; + int32_t nodeId; + uint32_t ip; + uint16_t port; + char fqdn[TSDB_FQDN_LEN]; // peer ip string + char id[TSDB_EP_LEN + 32]; // peer vgId + end point + int8_t role; + int8_t sstatus; // sync status + uint64_t version; + uint64_t sversion; // track the peer version in retrieve process + int syncFd; + int peerFd; // forward FD + int numOfRetrieves; // number of retrieves tried + int fileChanged; // a flag to indicate file is changed during retrieving process + void * timer; + void * pConn; + int notifyFd; + int watchNum; + int * watchFd; + int8_t refCount; // reference count + struct SSyncNode *pSyncNode; } SSyncPeer; typedef struct SSyncNode { @@ -171,7 +171,6 @@ void syncBroadcastStatus(SSyncNode *pNode); void syncAddPeerRef(SSyncPeer *pPeer); int syncDecPeerRef(SSyncPeer *pPeer); - #ifdef __cplusplus } #endif diff --git a/src/sync/inc/taosTcpPool.h b/src/sync/inc/taosTcpPool.h index 5f7ca9ede587a6d609c8c449e66c462f0d9f6dad..261d190ad3b7cbe4fbf46a061a1432c217262d24 100644 --- a/src/sync/inc/taosTcpPool.h +++ b/src/sync/inc/taosTcpPool.h @@ -38,7 +38,6 @@ void taosCloseTcpThreadPool(ttpool_h); void *taosAllocateTcpConn(void *, void *ahandle, int connFd); void taosFreeTcpConn(void *); - #ifdef __cplusplus } #endif diff --git a/src/sync/src/syncMain.c b/src/sync/src/syncMain.c index f96b902efde28c62af194047b64485a8f83c0e45..ef635e6efc1ca5f071c64dbe00920c3987837494 100644 --- a/src/sync/src/syncMain.c +++ b/src/sync/src/syncMain.c @@ -134,7 +134,7 @@ void syncCleanUp() { void *syncStart(const SSyncInfo *pInfo) { const SSyncCfg *pCfg = &pInfo->syncCfg; - SSyncNode *pNode = (SSyncNode *) calloc(sizeof(SSyncNode), 1); + SSyncNode *pNode = (SSyncNode *)calloc(sizeof(SSyncNode), 1); if (pNode == NULL) { sError("no memory to allocate syncNode"); terrno = TAOS_SYSTEM_ERROR(errno); @@ -167,6 +167,8 @@ void *syncStart(const SSyncInfo *pInfo) { } } + syncAddNodeRef(pNode); + if (pNode->selfIndex < 0) { sInfo("vgId:%d, this node is not configured", pNode->vgId); terrno = TSDB_CODE_SYN_INVALID_CONFIG; @@ -174,11 +176,12 @@ void *syncStart(const SSyncInfo *pInfo) { return NULL; } - nodeVersion = pInfo->version; // set the initial version + nodeVersion = pInfo->version; // set the initial version nodeRole = (pNode->replica > 1) ? TAOS_SYNC_ROLE_UNSYNCED : TAOS_SYNC_ROLE_MASTER; - sInfo("vgId:%d, %d replicas are configured, quorum:%d role:%s", pNode->vgId, pNode->replica, pNode->quorum, syncRole[nodeRole]); + sInfo("vgId:%d, %d replicas are configured, quorum:%d role:%s", pNode->vgId, pNode->replica, pNode->quorum, + syncRole[nodeRole]); - pNode->pSyncFwds = calloc(sizeof(SSyncFwds) + tsMaxFwdInfo*sizeof(SFwdInfo), 1); + pNode->pSyncFwds = calloc(sizeof(SSyncFwds) + tsMaxFwdInfo * sizeof(SFwdInfo), 1); if (pNode->pSyncFwds == NULL) { sError("vgId:%d, no memory to allocate syncFwds", pNode->vgId); terrno = TAOS_SYSTEM_ERROR(errno); @@ -194,7 +197,6 @@ void *syncStart(const SSyncInfo *pInfo) { } syncAddArbitrator(pNode); - syncAddNodeRef(pNode); taosHashPut(vgIdHash, (const char *)&pNode->vgId, sizeof(int32_t), (char *)(&pNode), sizeof(SSyncNode *)); if (pNode->notifyRole) { @@ -213,6 +215,9 @@ void syncStop(void *param) { pthread_mutex_lock(&(pNode->mutex)); + if (vgIdHash) taosHashRemove(vgIdHash, (const char *)&pNode->vgId, sizeof(int32_t)); + if (pNode->pFwdTimer) taosTmrStop(pNode->pFwdTimer); + for (int i = 0; i < pNode->replica; ++i) { pPeer = pNode->peerInfo[i]; if (pPeer) syncRemovePeer(pPeer); @@ -221,9 +226,6 @@ void syncStop(void *param) { pPeer = pNode->peerInfo[TAOS_SYNC_MAX_REPLICA]; if (pPeer) syncRemovePeer(pPeer); - if (vgIdHash) taosHashRemove(vgIdHash, (const char *)&pNode->vgId, sizeof(int32_t)); - if (pNode->pFwdTimer) taosTmrStop(pNode->pFwdTimer); - pthread_mutex_unlock(&(pNode->mutex)); syncDecNodeRef(pNode); @@ -309,8 +311,21 @@ int32_t syncForwardToPeer(void *param, void *data, void *mhandle, int qtype) { if (pNode == NULL) return 0; + if (nodeRole == TAOS_SYNC_ROLE_SLAVE && pWalHead->version != nodeVersion + 1) { + sError("vgId:%d, received ver:%" PRIu64 ", inconsistent with last ver:%" PRIu64 ", restart connection", pNode->vgId, + pWalHead->version, nodeVersion); + for (int i = 0; i < pNode->replica; ++i) { + pPeer = pNode->peerInfo[i]; + syncRestartConnection(pPeer); + } + return TSDB_CODE_SYN_INVALID_VERSION; + } + // always update version nodeVersion = pWalHead->version; + sDebug("vgId:%d, replica:%d nodeRole:%s qtype:%d ver:%" PRIu64, pNode->vgId, pNode->replica, syncRole[nodeRole], + qtype, pWalHead->version); + if (pNode->replica == 1 || nodeRole != TAOS_SYNC_ROLE_MASTER) return 0; // only pkt from RPC or CQ can be forwarded @@ -442,9 +457,7 @@ static void syncAddArbitrator(SSyncNode *pNode) { pNode->peerInfo[TAOS_SYNC_MAX_REPLICA] = syncAddPeer(pNode, &nodeInfo); } -static void syncAddNodeRef(SSyncNode *pNode) { - atomic_add_fetch_8(&pNode->refCount, 1); -} +static void syncAddNodeRef(SSyncNode *pNode) { atomic_add_fetch_8(&pNode->refCount, 1); } static void syncDecNodeRef(SSyncNode *pNode) { if (atomic_sub_fetch_8(&pNode->refCount, 1) == 0) { @@ -455,9 +468,7 @@ static void syncDecNodeRef(SSyncNode *pNode) { } } -void syncAddPeerRef(SSyncPeer *pPeer) { - atomic_add_fetch_8(&pPeer->refCount, 1); -} +void syncAddPeerRef(SSyncPeer *pPeer) { atomic_add_fetch_8(&pPeer->refCount, 1); } int syncDecPeerRef(SSyncPeer *pPeer) { if (atomic_sub_fetch_8(&pPeer->refCount, 1) == 0) { @@ -493,14 +504,15 @@ static SSyncPeer *syncAddPeer(SSyncNode *pNode, const SNodeInfo *pInfo) { uint32_t ip = taosGetIpFromFqdn(pInfo->nodeFqdn); if (ip == -1) return NULL; - SSyncPeer *pPeer = (SSyncPeer *)calloc(1, sizeof(SSyncPeer)); + SSyncPeer *pPeer = calloc(1, sizeof(SSyncPeer)); if (pPeer == NULL) return NULL; pPeer->nodeId = pInfo->nodeId; tstrncpy(pPeer->fqdn, pInfo->nodeFqdn, sizeof(pPeer->fqdn)); pPeer->ip = ip; pPeer->port = pInfo->nodePort; - snprintf(pPeer->id, sizeof(pPeer->id), "vgId:%d peer:%s:%d", pNode->vgId, pPeer->fqdn, pPeer->port); + pPeer->fqdn[sizeof(pPeer->fqdn) - 1] = 0; + snprintf(pPeer->id, sizeof(pPeer->id), "vgId:%d peer:%s:%u", pNode->vgId, pPeer->fqdn, pPeer->port); pPeer->peerFd = -1; pPeer->syncFd = -1; @@ -511,9 +523,9 @@ static SSyncPeer *syncAddPeer(SSyncNode *pNode, const SNodeInfo *pInfo) { sInfo("%s, it is configured", pPeer->id); int ret = strcmp(pPeer->fqdn, tsNodeFqdn); if (pPeer->nodeId == 0 || (ret > 0) || (ret == 0 && pPeer->port > tsSyncPort)) { - sDebug("%s, start to check peer connection", pPeer->id); int32_t checkMs = 100 + (pNode->vgId * 10) % 100; - if (pNode->vgId) checkMs = tsStatusInterval * 2000 + 100; + if (pNode->vgId > 1) checkMs = tsStatusInterval * 2000 + checkMs; + sDebug("%s, start to check peer connection after %d ms", pPeer->id, checkMs); taosTmrReset(syncCheckPeerConnection, checkMs, pPeer, syncTmrCtrl, &pPeer->timer); } @@ -572,10 +584,10 @@ static void syncChooseMaster(SSyncNode *pNode) { replica = pNode->replica + 1; } - if (index < 0 && onlineNum > replica/2.0) { + if (index < 0 && onlineNum > replica / 2.0) { // over half of nodes are online for (int i = 0; i < pNode->replica; ++i) { - //slave with highest version shall be master + // slave with highest version shall be master pPeer = pNode->peerInfo[i]; if (pPeer->role == TAOS_SYNC_ROLE_SLAVE || pPeer->role == TAOS_SYNC_ROLE_MASTER) { if (index < 0 || pPeer->version > pNode->peerInfo[index]->version) { @@ -621,7 +633,7 @@ static SSyncPeer *syncCheckMaster(SSyncNode *pNode) { if (onlineNum <= replica * 0.5) { if (nodeRole != TAOS_SYNC_ROLE_UNSYNCED) { nodeRole = TAOS_SYNC_ROLE_UNSYNCED; - pNode->peerInfo[pNode->selfIndex]->role = nodeRole; + // pNode->peerInfo[pNode->selfIndex]->role = nodeRole; (*pNode->notifyRole)(pNode->ahandle, nodeRole); sInfo("vgId:%d, change to unsynced state, online:%d replica:%d", pNode->vgId, onlineNum, replica); } @@ -647,7 +659,7 @@ static SSyncPeer *syncCheckMaster(SSyncNode *pNode) { static int syncValidateMaster(SSyncPeer *pPeer) { SSyncNode *pNode = pPeer->pSyncNode; - int code = 0; + int code = 0; if (nodeRole == TAOS_SYNC_ROLE_MASTER && nodeVersion < pPeer->version) { sDebug("%s, slave has higher version, restart all connections!!!", pPeer->id); @@ -670,7 +682,7 @@ static void syncCheckRole(SSyncPeer *pPeer, SPeerStatus peersStatus[], int8_t ne int8_t selfOldRole = nodeRole; int8_t i, syncRequired = 0; - pNode->peerInfo[pNode->selfIndex]->version = nodeVersion; + // pNode->peerInfo[pNode->selfIndex]->version = nodeVersion; pPeer->role = newRole; sDebug("%s, own role:%s, new peer role:%s", pPeer->id, syncRole[nodeRole], syncRole[pPeer->role]); @@ -876,15 +888,13 @@ static void syncProcessForwardFromPeer(char *cont, SSyncPeer *pPeer) { sError("%s, forward discarded, ver:%" PRIu64, pPeer->id, pHead->version); } } - - return; } static void syncProcessPeersStatusMsg(char *cont, SSyncPeer *pPeer) { SSyncNode * pNode = pPeer->pSyncNode; SPeersStatus *pPeersStatus = (SPeersStatus *)cont; - sDebug("%s, status msg received, self:%s ver:%" PRIu64 " peer:%s ver:%" PRIu64 ", ack:%d", pPeer->id, + sDebug("%s, status msg is received, self:%s ver:%" PRIu64 " peer:%s ver:%" PRIu64 ", ack:%d", pPeer->id, syncRole[nodeRole], nodeVersion, syncRole[pPeersStatus->role], pPeersStatus->version, pPeersStatus->ack); pPeer->version = pPeersStatus->version; @@ -922,7 +932,7 @@ static int syncReadPeerMsg(SSyncPeer *pPeer, SSyncHead *pHead, char *cont) { static int syncProcessPeerMsg(void *param, void *buffer) { SSyncPeer *pPeer = param; SSyncHead head; - char * cont = (char *)buffer; + char * cont = buffer; SSyncNode *pNode = pPeer->pSyncNode; pthread_mutex_lock(&(pNode->mutex)); @@ -971,7 +981,8 @@ static void syncSendPeersStatusMsgToPeer(SSyncPeer *pPeer, char ack) { int retLen = write(pPeer->peerFd, msg, statusMsgLen); if (retLen == statusMsgLen) { - sDebug("%s, status msg is sent", pPeer->id); + sDebug("%s, status msg is sent, self:%s ver:%" PRIu64 ", ack:%d", pPeer->id, syncRole[pPeersStatus->role], + pPeersStatus->version, pPeersStatus->ack); } else { sDebug("%s, failed to send status msg, restart", pPeer->id); syncRestartConnection(pPeer); @@ -1065,7 +1076,7 @@ static void syncProcessIncommingConnection(int connFd, uint32_t sourceIp) { return; } - int32_t vgId = firstPkt.syncHead.vgId; + int32_t vgId = firstPkt.syncHead.vgId; SSyncNode **ppNode = (SSyncNode **)taosHashGet(vgIdHash, (const char *)&vgId, sizeof(int32_t)); if (ppNode == NULL || *ppNode == NULL) { sError("vgId:%d, vgId could not be found", vgId); @@ -1192,6 +1203,8 @@ static void syncProcessFwdAck(SSyncNode *pNode, SFwdInfo *pFwdInfo, int32_t code static void syncMonitorFwdInfos(void *param, void *tmrId) { SSyncNode *pNode = param; SSyncFwds *pSyncFwds = pNode->pSyncFwds; + if (pSyncFwds == NULL) return; + uint64_t time = taosGetTimestampMs(); if (pSyncFwds->fwds > 0) { diff --git a/src/sync/src/syncRestore.c b/src/sync/src/syncRestore.c index 2a0bee3726d939cc9da436af36ce02d45dad34d5..ebb6c3a0a9edff5acfc5f2ce7da8b58f03d8ab4a 100644 --- a/src/sync/src/syncRestore.c +++ b/src/sync/src/syncRestore.c @@ -23,10 +23,10 @@ #include "tsync.h" #include "syncInt.h" -static void syncRemoveExtraFile(SSyncPeer *pPeer, uint32_t sindex, uint32_t eindex) { - char name[TSDB_FILENAME_LEN*2] = {0}; - char fname[TSDB_FILENAME_LEN*3] = {0}; - uint32_t magic; +static void syncRemoveExtraFile(SSyncPeer *pPeer, int32_t sindex, int32_t eindex) { + char name[TSDB_FILENAME_LEN * 2] = {0}; + char fname[TSDB_FILENAME_LEN * 3] = {0}; + uint32_t magic; uint64_t fversion; int64_t size; uint32_t index = sindex; @@ -40,12 +40,12 @@ static void syncRemoveExtraFile(SSyncPeer *pPeer, uint32_t sindex, uint32_t eind if (magic == 0) break; snprintf(fname, sizeof(fname), "%s/%s", pNode->path, name); - remove(fname); + (void)remove(fname); sDebug("%s, %s is removed", pPeer->id, fname); index++; if (index > eindex) break; - } + } } static int syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) { @@ -62,35 +62,36 @@ static int syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) { while (1) { // read file info int ret = taosReadMsg(pPeer->syncFd, &(minfo), sizeof(minfo)); - if (ret < 0 ) break; + if (ret < 0) break; // if no more file from master, break; if (minfo.name[0] == 0 || minfo.magic == 0) { sDebug("%s, no more files to restore", pPeer->id); // remove extra files after the current index - syncRemoveExtraFile(pPeer, sinfo.index+1, TAOS_SYNC_MAX_INDEX); - code = 0; + syncRemoveExtraFile(pPeer, sinfo.index + 1, TAOS_SYNC_MAX_INDEX); + code = 0; break; } - + // remove extra files on slave between the current and last index - syncRemoveExtraFile(pPeer, pindex+1, minfo.index-1); + syncRemoveExtraFile(pPeer, pindex + 1, minfo.index - 1); pindex = minfo.index; // check the file info sinfo = minfo; sDebug("%s, get file info:%s", pPeer->id, minfo.name); - sinfo.magic = (*pNode->getFileInfo)(pNode->ahandle, sinfo.name, &sinfo.index, TAOS_SYNC_MAX_INDEX, &sinfo.size, &sinfo.fversion); + sinfo.magic = (*pNode->getFileInfo)(pNode->ahandle, sinfo.name, &sinfo.index, TAOS_SYNC_MAX_INDEX, &sinfo.size, + &sinfo.fversion); // if file not there or magic is not the same, file shall be synced memset(&fileAck, 0, sizeof(fileAck)); - fileAck.sync = (sinfo.magic != minfo.magic || sinfo.name[0] == 0) ? 1:0; + fileAck.sync = (sinfo.magic != minfo.magic || sinfo.name[0] == 0) ? 1 : 0; // send file ack ret = taosWriteMsg(pPeer->syncFd, &(fileAck), sizeof(fileAck)); - if (ret <0) break; - + if (ret < 0) break; + // if sync is not required, continue if (fileAck.sync == 0) { sDebug("%s, %s is the same", pPeer->id, minfo.name); @@ -99,10 +100,11 @@ static int syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) { // if sync is required, open file, receive from master, and write to file // get the full path to file + minfo.name[sizeof(minfo.name) - 1] = 0; snprintf(name, sizeof(name), "%s/%s", pNode->path, minfo.name); int dfd = open(name, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO); - if ( dfd < 0 ) { + if (dfd < 0) { sError("%s, failed to open file:%s", pPeer->id, name); break; } @@ -110,16 +112,15 @@ static int syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) { ret = taosCopyFds(pPeer->syncFd, dfd, minfo.size); fsync(dfd); close(dfd); - if (ret<0) break; + if (ret < 0) break; sDebug("%s, %s is received, size:%" PRId64, pPeer->id, minfo.name, minfo.size); - } if (code == 0 && (minfo.fversion != sinfo.fversion)) { - // data file is changed, code shall be set to 1 + // data file is changed, code shall be set to 1 *fversion = minfo.fversion; - code = 1; + code = 1; } if (code < 0) { @@ -130,8 +131,8 @@ static int syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) { } static int syncRestoreWal(SSyncPeer *pPeer) { - SSyncNode *pNode = pPeer->pSyncNode; - int ret, code = -1; + SSyncNode *pNode = pPeer->pSyncNode; + int ret, code = -1; void *buffer = calloc(1024000, 1); // size for one record if (buffer == NULL) return -1; @@ -140,18 +141,21 @@ static int syncRestoreWal(SSyncPeer *pPeer) { while (1) { ret = taosReadMsg(pPeer->syncFd, pHead, sizeof(SWalHead)); - if (ret <0) break; + if (ret < 0) break; + + if (pHead->len == 0) { + code = 0; + break; + } // wal sync over - if (pHead->len == 0) {code = 0; break;} // wal sync over - ret = taosReadMsg(pPeer->syncFd, pHead->cont, pHead->len); - if (ret <0) break; + if (ret < 0) break; sDebug("%s, restore a record, ver:%" PRIu64, pPeer->id, pHead->version); (*pNode->writeToCache)(pNode->ahandle, pHead, TAOS_QTYPE_WAL); } - if (code<0) { + if (code < 0) { sError("%s, failed to restore wal(%s)", pPeer->id, strerror(errno)); } @@ -159,10 +163,9 @@ static int syncRestoreWal(SSyncPeer *pPeer) { return code; } -static char *syncProcessOneBufferedFwd(SSyncPeer *pPeer, char *offset) -{ +static char *syncProcessOneBufferedFwd(SSyncPeer *pPeer, char *offset) { SSyncNode *pNode = pPeer->pSyncNode; - SWalHead *pHead = (SWalHead *) offset; + SWalHead * pHead = (SWalHead *)offset; (*pNode->writeToCache)(pNode->ahandle, pHead, TAOS_QTYPE_FWD); offset += pHead->len + sizeof(SWalHead); @@ -171,7 +174,7 @@ static char *syncProcessOneBufferedFwd(SSyncPeer *pPeer, char *offset) } static int syncProcessBufferedFwd(SSyncPeer *pPeer) { - SSyncNode *pNode = pPeer->pSyncNode; + SSyncNode * pNode = pPeer->pSyncNode; SRecvBuffer *pRecv = pNode->pRecv; int forwards = 0; @@ -182,7 +185,7 @@ static int syncProcessBufferedFwd(SSyncPeer *pPeer) { offset = syncProcessOneBufferedFwd(pPeer, offset); forwards++; } - + pthread_mutex_lock(&pNode->mutex); while (forwards < pRecv->forwards && pRecv->code == 0) { @@ -199,7 +202,7 @@ static int syncProcessBufferedFwd(SSyncPeer *pPeer) { } int syncSaveIntoBuffer(SSyncPeer *pPeer, SWalHead *pHead) { - SSyncNode *pNode = pPeer->pSyncNode; + SSyncNode * pNode = pPeer->pSyncNode; SRecvBuffer *pRecv = pNode->pRecv; if (pRecv == NULL) return -1; @@ -259,9 +262,9 @@ static int syncRestoreDataStepByStep(SSyncPeer *pPeer) { return -1; } - // if code > 0, data file is changed, notify app, and pass the version + // if code > 0, data file is changed, notify app, and pass the version if (code > 0 && pNode->notifyFileSynced) { - if ( (*pNode->notifyFileSynced)(pNode->ahandle, fversion) < 0 ) { + if ((*pNode->notifyFileSynced)(pNode->ahandle, fversion) < 0) { sError("%s, app not in ready state", pPeer->id); return -1; } @@ -296,8 +299,8 @@ void *syncRestoreData(void *param) { if (syncOpenRecvBuffer(pNode) < 0) { sError("%s, failed to allocate recv buffer", pPeer->id); - } else { - if ( syncRestoreDataStepByStep(pPeer) == 0) { + } else { + if (syncRestoreDataStepByStep(pPeer) == 0) { sInfo("%s, it is synced successfully", pPeer->id); nodeRole = TAOS_SYNC_ROLE_SLAVE; syncBroadcastStatus(pNode); @@ -311,7 +314,7 @@ void *syncRestoreData(void *param) { (*pNode->notifyRole)(pNode->ahandle, nodeRole); nodeSStatus = TAOS_SYNC_STATUS_INIT; - taosClose(pPeer->syncFd) + taosClose(pPeer->syncFd); syncCloseRecvBuffer(pNode); __sync_fetch_and_sub(&tsSyncNum, 1); syncDecPeerRef(pPeer); diff --git a/src/sync/src/syncRetrieve.c b/src/sync/src/syncRetrieve.c index 8aa317b1ac7c770b6b102545716656541b8bb67e..60625d75eccdbe6bbb29f97b31ecd8e9855480a7 100644 --- a/src/sync/src/syncRetrieve.c +++ b/src/sync/src/syncRetrieve.c @@ -38,13 +38,13 @@ static int syncAddIntoWatchList(SSyncPeer *pPeer, char *name) { return -1; } - if (pPeer->watchFd == NULL) pPeer->watchFd = malloc(sizeof(int)*tsMaxWatchFiles); + if (pPeer->watchFd == NULL) pPeer->watchFd = malloc(sizeof(int) * tsMaxWatchFiles); if (pPeer->watchFd == NULL) { sError("%s, failed to allocate watchFd", pPeer->id); return -1; } - memset(pPeer->watchFd, -1, sizeof(int)*tsMaxWatchFiles); + memset(pPeer->watchFd, -1, sizeof(int) * tsMaxWatchFiles); } int *wd = pPeer->watchFd + pPeer->watchNum; @@ -64,7 +64,7 @@ static int syncAddIntoWatchList(SSyncPeer *pPeer, char *name) { sDebug("%s, monitor %s, wd:%d watchNum:%d", pPeer->id, name, *wd, pPeer->watchNum); } - pPeer->watchNum = (pPeer->watchNum +1) % tsMaxWatchFiles; + pPeer->watchNum = (pPeer->watchNum + 1) % tsMaxWatchFiles; return 0; } @@ -72,20 +72,20 @@ static int syncAddIntoWatchList(SSyncPeer *pPeer, char *name) { static int syncAreFilesModified(SSyncPeer *pPeer) { if (pPeer->notifyFd <= 0) return 0; - char buf[2048]; - int len = read(pPeer->notifyFd, buf, sizeof(buf)); + char buf[2048]; + int len = read(pPeer->notifyFd, buf, sizeof(buf)); if (len < 0 && errno != EAGAIN) { - sError("%s, failed to read notify FD(%s)", pPeer->id, strerror(errno)); + sError("%s, failed to read notify FD(%s)", pPeer->id, strerror(errno)); return -1; } - - int code = 0; - if (len > 0) { + + int code = 0; + if (len > 0) { const struct inotify_event *event; char *ptr; for (ptr = buf; ptr < buf + len; ptr += sizeof(struct inotify_event) + event->len) { - event = (const struct inotify_event *) ptr; - if ((event->mask & IN_MODIFY) || (event->mask & IN_DELETE)) { + event = (const struct inotify_event *)ptr; + if ((event->mask & IN_MODIFY) || (event->mask & IN_DELETE)) { sDebug("%s, processed file is changed", pPeer->id); pPeer->fileChanged = 1; code = 1; @@ -98,11 +98,11 @@ static int syncAreFilesModified(SSyncPeer *pPeer) { } static int syncRetrieveFile(SSyncPeer *pPeer) { - SSyncNode * pNode = pPeer->pSyncNode; - SFileInfo fileInfo; - SFileAck fileAck; - int code = -1; - char name[TSDB_FILENAME_LEN * 2] = {0}; + SSyncNode *pNode = pPeer->pSyncNode; + SFileInfo fileInfo; + SFileAck fileAck; + int code = -1; + char name[TSDB_FILENAME_LEN * 2] = {0}; memset(&fileInfo, 0, sizeof(fileInfo)); memset(&fileAck, 0, sizeof(fileAck)); @@ -110,17 +110,19 @@ static int syncRetrieveFile(SSyncPeer *pPeer) { while (1) { // retrieve file info fileInfo.name[0] = 0; - fileInfo.magic = (*pNode->getFileInfo)(pNode->ahandle, fileInfo.name, &fileInfo.index, TAOS_SYNC_MAX_INDEX, &fileInfo.size, &fileInfo.fversion); - //fileInfo.size = htonl(size); + fileInfo.magic = (*pNode->getFileInfo)(pNode->ahandle, fileInfo.name, &fileInfo.index, TAOS_SYNC_MAX_INDEX, + &fileInfo.size, &fileInfo.fversion); + // fileInfo.size = htonl(size); // send the file info int32_t ret = taosWriteMsg(pPeer->syncFd, &(fileInfo), sizeof(fileInfo)); - if (ret < 0 ) break; + if (ret < 0) break; // if no file anymore, break - if (fileInfo.magic == 0 || fileInfo.name[0] == 0) { - sDebug("%s, no more files to sync", pPeer->id); - code = 0; break; + if (fileInfo.magic == 0 || fileInfo.name[0] == 0) { + sDebug("%s, no more files to sync", pPeer->id); + code = 0; + break; } // wait for the ack from peer @@ -132,29 +134,29 @@ static int syncRetrieveFile(SSyncPeer *pPeer) { // get the full path to file snprintf(name, sizeof(name), "%s/%s", pNode->path, fileInfo.name); - + // add the file into watch list - if ( syncAddIntoWatchList(pPeer, name) <0) break; + if (syncAddIntoWatchList(pPeer, name) < 0) break; // if sync is not required, continue if (fileAck.sync == 0) { - fileInfo.index++; - sDebug("%s, %s is the same", pPeer->id, fileInfo.name); - continue; + fileInfo.index++; + sDebug("%s, %s is the same", pPeer->id, fileInfo.name); + continue; } // send the file to peer int sfd = open(name, O_RDONLY); if (sfd < 0) break; - ret = taosTSendFile(pPeer->syncFd, sfd, NULL, fileInfo.size); + ret = taosTSendFile(pPeer->syncFd, sfd, NULL, fileInfo.size); close(sfd); if (ret < 0) break; - sDebug("%s, %s is sent, size:%" PRId64, pPeer->id, name, fileInfo.size); - fileInfo.index++; + sDebug("%s, %s is sent, size:%" PRId64, pPeer->id, name, fileInfo.size); + fileInfo.index++; - // check if processed files are modified + // check if processed files are modified if (syncAreFilesModified(pPeer) != 0) break; } @@ -201,15 +203,15 @@ static int syncMonitorLastWal(SSyncPeer *pPeer, char *name) { return -1; } - if (pPeer->watchFd == NULL) pPeer->watchFd = malloc(sizeof(int)*tsMaxWatchFiles); + if (pPeer->watchFd == NULL) pPeer->watchFd = malloc(sizeof(int) * tsMaxWatchFiles); if (pPeer->watchFd == NULL) { sError("%s, failed to allocate watchFd", pPeer->id); return -1; } - memset(pPeer->watchFd, -1, sizeof(int)*tsMaxWatchFiles); + memset(pPeer->watchFd, -1, sizeof(int) * tsMaxWatchFiles); int *wd = pPeer->watchFd; - + *wd = inotify_add_watch(pPeer->notifyFd, name, IN_MODIFY | IN_CLOSE_WRITE); if (*wd == -1) { sError("%s, failed to watch last wal(%s)", pPeer->id, strerror(errno)); @@ -219,8 +221,8 @@ static int syncMonitorLastWal(SSyncPeer *pPeer, char *name) { return 0; } -static uint32_t syncCheckLastWalChanges(SSyncPeer *pPeer, uint32_t *pEvent) { - char buf[2048]; +static int32_t syncCheckLastWalChanges(SSyncPeer *pPeer, uint32_t *pEvent) { + char buf[2048]; int len = read(pPeer->notifyFd, buf, sizeof(buf)); if (len < 0 && errno != EAGAIN) { sError("%s, failed to read notify FD(%s)", pPeer->id, strerror(errno)); @@ -231,26 +233,29 @@ static uint32_t syncCheckLastWalChanges(SSyncPeer *pPeer, uint32_t *pEvent) { struct inotify_event *event; for (char *ptr = buf; ptr < buf + len; ptr += sizeof(struct inotify_event) + event->len) { - event = (struct inotify_event *) ptr; + event = (struct inotify_event *)ptr; if (event->mask & IN_MODIFY) *pEvent = *pEvent | IN_MODIFY; if (event->mask & IN_CLOSE_WRITE) *pEvent = *pEvent | IN_CLOSE_WRITE; } - if (pEvent != 0) - sDebug("%s, last wal event:0x%x", pPeer->id, *pEvent); + if (pEvent != 0) sDebug("%s, last wal event:0x%x", pPeer->id, *pEvent); return 0; } static int syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversion, int64_t offset, uint32_t *pEvent) { - SWalHead *pHead = (SWalHead *) malloc(640000); - int code = -1; - int32_t bytes = 0; - int sfd; + SWalHead *pHead = malloc(640000); + int code = -1; + int32_t bytes = 0; + int sfd; sfd = open(name, O_RDONLY); - if (sfd < 0) return -1; - lseek(sfd, offset, SEEK_SET); + if (sfd < 0) { + free(pHead); + return -1; + } + + (void)lseek(sfd, offset, SEEK_SET); sDebug("%s, retrieve last wal, offset:%" PRId64 " fversion:%" PRIu64, pPeer->id, offset, fversion); while (1) { @@ -263,34 +268,34 @@ static int syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversion, sDebug("%s, last wal is forwarded, ver:%" PRIu64, pPeer->id, pHead->version); int ret = taosWriteMsg(pPeer->syncFd, pHead, wsize); - if ( ret != wsize ) break; + if (ret != wsize) break; pPeer->sversion = pHead->version; bytes += wsize; - + if (pHead->version >= fversion && fversion > 0) { - code = 0; - bytes = 0; + code = 0; + bytes = 0; break; } } free(pHead); - taosClose(sfd); + close(sfd); if (code == 0) return bytes; return -1; } static int syncProcessLastWal(SSyncPeer *pPeer, char *wname, uint32_t index) { - SSyncNode *pNode = pPeer->pSyncNode; - int code = -1; - char fname[TSDB_FILENAME_LEN * 2]; // full path to wal file + SSyncNode *pNode = pPeer->pSyncNode; + int code = -1; + char fname[TSDB_FILENAME_LEN * 2]; // full path to wal file if (syncAreFilesModified(pPeer) != 0) return -1; while (1) { - int32_t once = 0; // last WAL has once ever been processed + int32_t once = 0; // last WAL has once ever been processed int64_t offset = 0; uint64_t fversion = 0; uint32_t event = 0; @@ -300,48 +305,48 @@ static int syncProcessLastWal(SSyncPeer *pPeer, char *wname, uint32_t index) { sDebug("%s, start to retrieve last wal:%s", pPeer->id, fname); // monitor last wal - if (syncMonitorLastWal(pPeer, fname) <0) break; + if (syncMonitorLastWal(pPeer, fname) < 0) break; while (1) { int32_t bytes = syncRetrieveLastWal(pPeer, fname, fversion, offset, &event); if (bytes < 0) break; // check file changes - if (syncCheckLastWalChanges(pPeer, &event) <0) break; + if (syncCheckLastWalChanges(pPeer, &event) < 0) break; // if file is not updated or updated once, set the fversion and sstatus if (((event & IN_MODIFY) == 0) || once) { if (fversion == 0) { pPeer->sstatus = TAOS_SYNC_STATUS_CACHE; // start to forward pkt - fversion = nodeVersion; // must read data to fversion + fversion = nodeVersion; // must read data to fversion } } // if all data up to fversion is read out, it is over if (pPeer->sversion >= fversion && fversion > 0) { - code = 0; - sDebug("%s, data up to fversion:%ld has been read out, bytes:%d", pPeer->id, fversion, bytes); + code = 0; + sDebug("%s, data up to fversion:%" PRId64 " has been read out, bytes:%d", pPeer->id, fversion, bytes); break; - } + } // if all data are read out, and no update if ((bytes == 0) && ((event & IN_MODIFY) == 0)) { // wal file is closed, break - if (event & IN_CLOSE_WRITE) { - code = 0; + if (event & IN_CLOSE_WRITE) { + code = 0; sDebug("%s, current wal is closed", pPeer->id); break; } - + // wal not closed, it means some data not flushed to disk, wait for a while usleep(10000); } - // if bytes>0, file is updated, or fversion is not reached but file still open, read again + // if bytes>0, file is updated, or fversion is not reached but file still open, read again once = 1; - offset += bytes; + offset += bytes; sDebug("%s, retrieve last wal, bytes:%d", pPeer->id, bytes); - event = event & (~IN_MODIFY); // clear IN_MODIFY flag + event = event & (~IN_MODIFY); // clear IN_MODIFY flag } if (code < 0) break; @@ -356,7 +361,7 @@ static int syncProcessLastWal(SSyncPeer *pPeer, char *wname, uint32_t index) { break; } - // current last wal is closed, there is a new one + // current last wal is closed, there is a new one sDebug("%s, last wal is closed, try new one", pPeer->id); } @@ -377,14 +382,14 @@ static int syncRetrieveWal(SSyncPeer *pPeer) { while (1) { // retrieve wal info wname[0] = 0; - code = (*pNode->getWalInfo)(pNode->ahandle, wname, &index); + code = (*pNode->getWalInfo)(pNode->ahandle, wname, &index); if (code < 0) break; // error if (wname[0] == 0) { // no wal file sDebug("%s, no wal file", pPeer->id); break; - } - - if (code == 0) { // last wal + } + + if (code == 0) { // last wal code = syncProcessLastWal(pPeer, wname, index); break; } @@ -392,26 +397,26 @@ static int syncRetrieveWal(SSyncPeer *pPeer) { // get the full path to wal file snprintf(fname, sizeof(fname), "%s/%s", pNode->path, wname); - // send wal file, + // send wal file, // inotify is not required, old wal file won't be modified, even remove is ok if (stat(fname, &fstat) < 0) break; size = fstat.st_size; - sDebug("%s, retrieve wal:%s size:%d", pPeer->id, fname, size); + sDebug("%s, retrieve wal:%s size:%d", pPeer->id, fname, size); int sfd = open(fname, O_RDONLY); if (sfd < 0) break; - code = taosTSendFile(pPeer->syncFd, sfd, NULL, size); - close(sfd); - if (code <0) break; + code = taosTSendFile(pPeer->syncFd, sfd, NULL, size); + close(sfd); + if (code < 0) break; - index++; + index++; - if (syncAreFilesModified(pPeer) != 0) break; + if (syncAreFilesModified(pPeer) != 0) break; } if (code == 0) { - sDebug("%s, wal retrieve is finished", pPeer->id); + sDebug("%s, wal retrieve is finished", pPeer->id); pPeer->sstatus = TAOS_SYNC_STATUS_CACHE; SWalHead walHead; memset(&walHead, 0, sizeof(walHead)); @@ -433,12 +438,12 @@ static int syncRetrieveDataStepByStep(SSyncPeer *pPeer) { tstrncpy(firstPkt.fqdn, tsNodeFqdn, sizeof(firstPkt.fqdn)); firstPkt.port = tsSyncPort; - if (write(pPeer->syncFd, (char *) &firstPkt, sizeof(firstPkt)) < 0) { + if (write(pPeer->syncFd, (char *)&firstPkt, sizeof(firstPkt)) < 0) { sError("%s, failed to send syncCmd", pPeer->id); return -1; } - pPeer->sversion = 0; + pPeer->sversion = 0; pPeer->sstatus = TAOS_SYNC_STATUS_FILE; sDebug("%s, start to retrieve file", pPeer->id); if (syncRetrieveFile(pPeer) < 0) { @@ -447,8 +452,7 @@ static int syncRetrieveDataStepByStep(SSyncPeer *pPeer) { } // if no files are synced, there must be wal to sync, sversion must be larger than one - if (pPeer->sversion == 0) - pPeer->sversion = 1; + if (pPeer->sversion == 0) pPeer->sversion = 1; sDebug("%s, start to retrieve wal", pPeer->id); if (syncRetrieveWal(pPeer) < 0) { @@ -460,8 +464,8 @@ static int syncRetrieveDataStepByStep(SSyncPeer *pPeer) { } void *syncRetrieveData(void *param) { - SSyncPeer * pPeer = (SSyncPeer *)param; - SSyncNode *pNode = pPeer->pSyncNode; + SSyncPeer *pPeer = (SSyncPeer *)param; + SSyncNode *pNode = pPeer->pSyncNode; taosBlockSIGPIPE(); pPeer->fileChanged = 0; @@ -470,7 +474,7 @@ void *syncRetrieveData(void *param) { sError("%s, failed to open socket to sync", pPeer->id); } else { sInfo("%s, sync tcp is setup", pPeer->id); - + if (syncRetrieveDataStepByStep(pPeer) == 0) { sDebug("%s, sync retrieve process is successful", pPeer->id); } else { @@ -482,12 +486,11 @@ void *syncRetrieveData(void *param) { if (pPeer->fileChanged) { // if file is changed 3 times continuously, start flow control pPeer->numOfRetrieves++; - if (pPeer->numOfRetrieves >= 2 && pNode->notifyFlowCtrl) + if (pPeer->numOfRetrieves >= 2 && pNode->notifyFlowCtrl) (*pNode->notifyFlowCtrl)(pNode->ahandle, 4 << (pPeer->numOfRetrieves - 2)); } else { pPeer->numOfRetrieves = 0; - if (pNode->notifyFlowCtrl) - (*pNode->notifyFlowCtrl)(pNode->ahandle, 0); + if (pNode->notifyFlowCtrl) (*pNode->notifyFlowCtrl)(pNode->ahandle, 0); } pPeer->fileChanged = 0; diff --git a/src/sync/src/taosTcpPool.c b/src/sync/src/taosTcpPool.c index 2f064ceb3690e4e8111d67fd2fce224add74717c..6a210a136ffe67b2e1394d26bac4cb5083452c8c 100644 --- a/src/sync/src/taosTcpPool.c +++ b/src/sync/src/taosTcpPool.c @@ -45,8 +45,8 @@ typedef struct { static void *taosAcceptPeerTcpConnection(void *argv); static void *taosProcessTcpData(void *param); +static void taosStopPoolThread(SThreadObj *pThread); static SThreadObj *taosGetTcpThread(SPoolObj *pPool); -static void taosStopPoolThread(SThreadObj* pThread); void *taosOpenTcpThreadPool(SPoolInfo *pInfo) { pthread_attr_t thattr; @@ -58,8 +58,8 @@ void *taosOpenTcpThreadPool(SPoolInfo *pInfo) { } pPool->info = *pInfo; - - pPool->pThread = (SThreadObj **) calloc(sizeof(SThreadObj *), pInfo->numOfThreads); + + pPool->pThread = (SThreadObj **)calloc(sizeof(SThreadObj *), pInfo->numOfThreads); if (pPool->pThread == NULL) { uError("TCP server, no enough memory"); free(pPool); @@ -68,17 +68,19 @@ void *taosOpenTcpThreadPool(SPoolInfo *pInfo) { pPool->acceptFd = taosOpenTcpServerSocket(pInfo->serverIp, pInfo->port); if (pPool->acceptFd < 0) { - free(pPool->pThread); free(pPool); + free(pPool->pThread); + free(pPool); uError("failed to create TCP server socket, port:%d (%s)", pInfo->port, strerror(errno)); return NULL; } pthread_attr_init(&thattr); pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); - if (pthread_create(&(pPool->thread), &thattr, (void *) taosAcceptPeerTcpConnection, pPool) != 0) { + if (pthread_create(&(pPool->thread), &thattr, (void *)taosAcceptPeerTcpConnection, pPool) != 0) { uError("TCP server, failed to create accept thread, reason:%s", strerror(errno)); close(pPool->acceptFd); - free(pPool->pThread); free(pPool); + free(pPool->pThread); + free(pPool); return NULL; } @@ -89,29 +91,30 @@ void *taosOpenTcpThreadPool(SPoolInfo *pInfo) { } void taosCloseTcpThreadPool(void *param) { - SPoolObj *pPool = (SPoolObj *)param; - SThreadObj *pThread; + SPoolObj * pPool = (SPoolObj *)param; + SThreadObj *pThread; - shutdown(pPool->acceptFd, SHUT_RD); + shutdown(pPool->acceptFd, SHUT_RD); pthread_join(pPool->thread, NULL); for (int i = 0; i < pPool->info.numOfThreads; ++i) { pThread = pPool->pThread[i]; - if (pThread) taosStopPoolThread(pThread); + if (pThread) taosStopPoolThread(pThread); } + uDebug("%p TCP pool is closed", pPool); + taosTFree(pPool->pThread); free(pPool); - uDebug("%p TCP pool is closed", pPool); } void *taosAllocateTcpConn(void *param, void *pPeer, int connFd) { struct epoll_event event; SPoolObj *pPool = (SPoolObj *)param; - SConnObj *pConn = (SConnObj *) calloc(sizeof(SConnObj), 1); + SConnObj *pConn = (SConnObj *)calloc(sizeof(SConnObj), 1); if (pConn == NULL) { - terrno = TAOS_SYSTEM_ERROR(errno); + terrno = TAOS_SYSTEM_ERROR(errno); return NULL; } @@ -131,7 +134,7 @@ void *taosAllocateTcpConn(void *param, void *pPeer, int connFd) { if (epoll_ctl(pThread->pollFd, EPOLL_CTL_ADD, connFd, &event) < 0) { uError("failed to add fd:%d(%s)", connFd, strerror(errno)); - terrno = TAOS_SYSTEM_ERROR(errno); + terrno = TAOS_SYSTEM_ERROR(errno); free(pConn); pConn = NULL; } else { @@ -143,8 +146,8 @@ void *taosAllocateTcpConn(void *param, void *pPeer, int connFd) { } void taosFreeTcpConn(void *param) { - SConnObj * pConn = (SConnObj *)param; - SThreadObj *pThread = pConn->pThread; + SConnObj * pConn = (SConnObj *)param; + SThreadObj *pThread = pConn->pThread; uDebug("%p TCP connection will be closed, fd:%d", pThread, pConn->fd); pConn->closedByApp = 1; @@ -153,9 +156,9 @@ void taosFreeTcpConn(void *param) { static void taosProcessBrokenLink(SConnObj *pConn) { SThreadObj *pThread = pConn->pThread; - SPoolObj *pPool = pThread->pPool; - SPoolInfo *pInfo = &pPool->info; - + SPoolObj * pPool = pThread->pPool; + SPoolInfo * pInfo = &pPool->info; + if (pConn->closedByApp == 0) shutdown(pConn->fd, SHUT_WR); (*pInfo->processBrokenLink)(pConn->ahandle); @@ -169,24 +172,24 @@ static void taosProcessBrokenLink(SConnObj *pConn) { #define maxEvents 10 static void *taosProcessTcpData(void *param) { - SThreadObj *pThread = (SThreadObj *) param; - SPoolObj *pPool = pThread->pPool; - SPoolInfo *pInfo = &pPool->info; - SConnObj *pConn = NULL; + SThreadObj *pThread = (SThreadObj *)param; + SPoolObj * pPool = pThread->pPool; + SPoolInfo * pInfo = &pPool->info; + SConnObj * pConn = NULL; struct epoll_event events[maxEvents]; void *buffer = malloc(pInfo->bufferSize); taosBlockSIGPIPE(); while (1) { - if (pThread->stop) break; + if (pThread->stop) break; int fdNum = epoll_wait(pThread->pollFd, events, maxEvents, TAOS_EPOLL_WAIT_TIME); if (pThread->stop) { uDebug("%p TCP epoll thread is exiting...", pThread); break; } - if (fdNum < 0) { + if (fdNum < 0) { uError("epoll_wait failed (%s)", strerror(errno)); continue; } @@ -215,27 +218,31 @@ static void *taosProcessTcpData(void *param) { taosFreeTcpConn(pConn); continue; } - } + } + } + + if (pThread->stop) break; } + uDebug("%p TCP epoll thread exits", pThread); + close(pThread->pollFd); free(pThread); free(buffer); - uDebug("%p TCP epoll thread exits", pThread); - return NULL; + return NULL; } static void *taosAcceptPeerTcpConnection(void *argv) { - SPoolObj *pPool = (SPoolObj *)argv; - SPoolInfo *pInfo = &pPool->info; + SPoolObj * pPool = (SPoolObj *)argv; + SPoolInfo *pInfo = &pPool->info; taosBlockSIGPIPE(); while (1) { struct sockaddr_in clientAddr; socklen_t addrlen = sizeof(clientAddr); - int connFd = accept(pPool->acceptFd, (struct sockaddr *) &clientAddr, &addrlen); + int connFd = accept(pPool->acceptFd, (struct sockaddr *)&clientAddr, &addrlen); if (connFd < 0) { if (errno == EINVAL) { uDebug("%p TCP server accept is exiting...", pPool); @@ -246,7 +253,7 @@ static void *taosAcceptPeerTcpConnection(void *argv) { } } - //uDebug("TCP connection from: 0x%x:%d", clientAddr.sin_addr.s_addr, clientAddr.sin_port); + // uDebug("TCP connection from: 0x%x:%d", clientAddr.sin_addr.s_addr, clientAddr.sin_port); taosKeepTcpAlive(connFd); (*pInfo->processIncomingConn)(connFd, clientAddr.sin_addr.s_addr); } @@ -260,7 +267,7 @@ static SThreadObj *taosGetTcpThread(SPoolObj *pPool) { if (pThread) return pThread; - pThread = (SThreadObj *) calloc(1, sizeof(SThreadObj)); + pThread = (SThreadObj *)calloc(1, sizeof(SThreadObj)); if (pThread == NULL) return NULL; pThread->pPool = pPool; @@ -273,7 +280,7 @@ static SThreadObj *taosGetTcpThread(SPoolObj *pPool) { pthread_attr_t thattr; pthread_attr_init(&thattr); pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); - int ret = pthread_create(&(pThread->thread), &thattr, (void *) taosProcessTcpData, pThread); + int ret = pthread_create(&(pThread->thread), &thattr, (void *)taosProcessTcpData, pThread); pthread_attr_destroy(&thattr); if (ret != 0) { @@ -290,20 +297,20 @@ static SThreadObj *taosGetTcpThread(SPoolObj *pPool) { return pThread; } -static void taosStopPoolThread(SThreadObj* pThread) { +static void taosStopPoolThread(SThreadObj *pThread) { pThread->stop = true; - + if (pThread->thread == pthread_self()) { pthread_detach(pthread_self()); return; } - // save thread ID into a local variable, since pThread is freed when the thread exits + // save thread ID into a local variable, since pThread is freed when the thread exits pthread_t thread = pThread->thread; // signal the thread to stop, try graceful method first, // and use pthread_cancel when failed - struct epoll_event event = { .events = EPOLLIN }; + struct epoll_event event = {.events = EPOLLIN}; eventfd_t fd = eventfd(1, 0); if (fd == -1) { // failed to create eventfd, call pthread_cancel instead, which may result in data corruption @@ -317,6 +324,5 @@ static void taosStopPoolThread(SThreadObj* pThread) { } pthread_join(thread, NULL); - taosClose(fd); + if (fd >= 0) taosClose(fd); } - diff --git a/src/sync/src/tarbitrator.c b/src/sync/src/tarbitrator.c index b704b1ecaec45577c52665a6c857bfbe49b05e72..360ea93f6c3fcd41e1df03702a0c963029deaacc 100644 --- a/src/sync/src/tarbitrator.c +++ b/src/sync/src/tarbitrator.c @@ -27,29 +27,29 @@ #include "tsync.h" #include "syncInt.h" -static void arbSignalHandler(int32_t signum, siginfo_t *sigInfo, void *context); -static void arbProcessIncommingConnection(int connFd, uint32_t sourceIp); -static void arbProcessBrokenLink(void *param); -static int arbProcessPeerMsg(void *param, void *buffer); +static void arbSignalHandler(int32_t signum, siginfo_t *sigInfo, void *context); +static void arbProcessIncommingConnection(int connFd, uint32_t sourceIp); +static void arbProcessBrokenLink(void *param); +static int arbProcessPeerMsg(void *param, void *buffer); static tsem_t tsArbSem; static ttpool_h tsArbTcpPool; typedef struct { - char id[TSDB_EP_LEN+24]; + char id[TSDB_EP_LEN + 24]; int nodeFd; void *pConn; } SNodeConn; int main(int argc, char *argv[]) { - char arbLogPath[TSDB_FILENAME_LEN + 16] = {0}; + char arbLogPath[TSDB_FILENAME_LEN + 16] = {0}; - for (int i=1; i TSDB_FILENAME_LEN) continue; + } else if (strcmp(argv[i], "-g") == 0 && i < argc - 1) { + if (strlen(argv[++i]) > TSDB_FILENAME_LEN) continue; tstrncpy(arbLogPath, argv[i], sizeof(arbLogPath)); } else { printf("\nusage: %s [options] \n", argv[0]); @@ -62,8 +62,8 @@ int main(int argc, char *argv[]) { } sDebugFlag = debugFlag; - - if (tsem_init(&tsArbSem, 0, 0) != 0) { + + if (tsem_init(&tsArbSem, 0, 0) != 0) { printf("failed to create exit semphore\n"); exit(EXIT_FAILURE); } @@ -91,10 +91,10 @@ int main(int argc, char *argv[]) { info.processIncomingMsg = arbProcessPeerMsg; info.processIncomingConn = arbProcessIncommingConnection; tsArbTcpPool = taosOpenTcpThreadPool(&info); - + if (tsArbTcpPool == NULL) { - sDebug("failed to open TCP thread pool, exit..."); - return -1; + sDebug("failed to open TCP thread pool, exit..."); + return -1; } sInfo("TAOS arbitrator: %s:%d is running", tsNodeFqdn, tsArbitratorPort); @@ -108,9 +108,8 @@ int main(int argc, char *argv[]) { return 0; } -static void arbProcessIncommingConnection(int connFd, uint32_t sourceIp) -{ - char ipstr[24]; +static void arbProcessIncommingConnection(int connFd, uint32_t sourceIp) { + char ipstr[24]; tinet_ntoa(ipstr, sourceIp); sDebug("peer TCP connection from ip:%s", ipstr); @@ -121,15 +120,16 @@ static void arbProcessIncommingConnection(int connFd, uint32_t sourceIp) return; } - SNodeConn *pNode = (SNodeConn *) calloc(sizeof(SNodeConn), 1); + SNodeConn *pNode = (SNodeConn *)calloc(sizeof(SNodeConn), 1); if (pNode == NULL) { sError("failed to allocate memory(%s)", strerror(errno)); taosCloseSocket(connFd); return; } - snprintf(pNode->id, sizeof(pNode->id), "vgId:%d peer:%s:%d", firstPkt.sourceId, firstPkt.fqdn, firstPkt.port); - if (firstPkt.syncHead.vgId) { + firstPkt.fqdn[sizeof(firstPkt.fqdn) - 1] = 0; + snprintf(pNode->id, sizeof(pNode->id), "vgId:%d peer:%s:%d", firstPkt.sourceId, firstPkt.fqdn, firstPkt.port); + if (firstPkt.syncHead.vgId) { sDebug("%s, vgId in head is not zero, close the connection", pNode->id); taosTFree(pNode); taosCloseSocket(connFd); @@ -151,10 +151,10 @@ static void arbProcessBrokenLink(void *param) { } static int arbProcessPeerMsg(void *param, void *buffer) { - SNodeConn * pNode = param; - SSyncHead head; - int bytes = 0; - char *cont = (char *)buffer; + SNodeConn *pNode = param; + SSyncHead head; + int bytes = 0; + char * cont = (char *)buffer; int hlen = taosReadMsg(pNode->nodeFd, &head, sizeof(head)); if (hlen != sizeof(head)) { diff --git a/src/sync/test/syncClient.c b/src/sync/test/syncClient.c index 16053d10886be5dd63d7227ac4da7b4c5ade4442..23264dc8a0d969e238f35951b0a02e10261ab0c3 100644 --- a/src/sync/test/syncClient.c +++ b/src/sync/test/syncClient.c @@ -25,31 +25,32 @@ typedef struct { int num; int numOfReqs; int msgSize; - tsem_t rspSem; - tsem_t *pOverSem; + tsem_t rspSem; + tsem_t * pOverSem; pthread_t thread; - void *pRpc; + void * pRpc; } SInfo; void processResponse(SRpcMsg *pMsg, SRpcEpSet *pEpSet) { SInfo *pInfo = (SInfo *)pMsg->ahandle; - uDebug("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, pMsg->code); + uDebug("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); + tsem_post(&pInfo->rspSem); } int tcount = 0; void *sendRequest(void *param) { - SInfo *pInfo = (SInfo *)param; - SRpcMsg rpcMsg = {0}; - + SInfo * pInfo = (SInfo *)param; + SRpcMsg rpcMsg = {0}; + uDebug("thread:%d, start to send request", pInfo->index); - while ( pInfo->numOfReqs == 0 || pInfo->num < pInfo->numOfReqs) { + while (pInfo->numOfReqs == 0 || pInfo->num < pInfo->numOfReqs) { pInfo->num++; rpcMsg.pCont = rpcMallocCont(pInfo->msgSize); rpcMsg.contLen = pInfo->msgSize; @@ -57,8 +58,9 @@ void *sendRequest(void *param) { rpcMsg.msgType = 1; uDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num); rpcSendRequest(pInfo->pRpc, &pInfo->epSet, &rpcMsg); - if ( pInfo->num % 20000 == 0 ) + if (pInfo->num % 20000 == 0) { uInfo("thread:%d, %d requests have been sent", pInfo->index, pInfo->num); + } tsem_wait(&pInfo->rspSem); } @@ -72,12 +74,12 @@ int main(int argc, char *argv[]) { SRpcInit rpcInit; SRpcEpSet epSet; char secret[TSDB_KEY_LEN] = "mypassword"; - int msgSize = 128; - int numOfReqs = 0; - int appThreads = 1; - char serverIp[40] = "127.0.0.1"; - struct timeval systemTime; - int64_t startTime, endTime; + int msgSize = 128; + int numOfReqs = 0; + int appThreads = 1; + char serverIp[40] = "127.0.0.1"; + struct timeval systemTime; + int64_t startTime, endTime; pthread_attr_t thattr; // server info @@ -102,30 +104,30 @@ int main(int argc, char *argv[]) { rpcInit.spi = 1; rpcInit.connType = TAOS_CONN_CLIENT; - for (int i=1; iindex = i; pInfo->epSet = epSet; pInfo->numOfReqs = numOfReqs; @@ -177,18 +179,16 @@ int main(int argc, char *argv[]) { do { usleep(1); - } while ( tcount < appThreads); + } while (tcount < appThreads); gettimeofday(&systemTime, NULL); - endTime = systemTime.tv_sec*1000000 + systemTime.tv_usec; - float usedTime = (endTime - startTime)/1000.0; // mseconds + endTime = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + float usedTime = (endTime - startTime) / 1000.0; // mseconds - uInfo("it takes %.3f mseconds to send %d requests to server", usedTime, numOfReqs*appThreads); - uInfo("Performance: %.3f requests per second, msgSize:%d bytes", 1000.0*numOfReqs*appThreads/usedTime, msgSize); + uInfo("it takes %.3f mseconds to send %d requests to server", usedTime, numOfReqs * appThreads); + uInfo("Performance: %.3f requests per second, msgSize:%d bytes", 1000.0 * numOfReqs * appThreads / usedTime, msgSize); taosCloseLog(); return 0; } - - diff --git a/src/sync/test/syncServer.c b/src/sync/test/syncServer.c index b802905038f5ac7cb67321d4e6db637283d7875e..380b971fa89bd1726e138c973a974bc995500693 100644 --- a/src/sync/test/syncServer.c +++ b/src/sync/test/syncServer.c @@ -24,28 +24,27 @@ #include "twal.h" #include "tsync.h" -int msgSize = 128; -int commit = 0; -int dataFd = -1; -void *qhandle = NULL; -int walNum = 0; +int msgSize = 128; +int commit = 0; +int dataFd = -1; +void * qhandle = NULL; +int walNum = 0; uint64_t tversion = 0; -void *syncHandle; -int role; -int nodeId; -char path[256]; -int numOfWrites ; +void * syncHandle; +int role; +int nodeId; +char path[256]; +int numOfWrites; SSyncInfo syncInfo; SSyncCfg *pCfg; -int writeIntoWal(SWalHead *pHead) -{ +int writeIntoWal(SWalHead *pHead) { if (dataFd < 0) { - char walName[280]; + char walName[280]; snprintf(walName, sizeof(walName), "%s/wal/wal.%d", path, walNum); - remove(walName); - dataFd = open(walName, O_CREAT | O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO); - if (dataFd < 0) { + (void)remove(walName); + dataFd = open(walName, O_CREAT | O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO); + if (dataFd < 0) { uInfo("failed to open wal file:%s(%s)", walName, strerror(errno)); return -1; } else { @@ -67,66 +66,63 @@ int writeIntoWal(SWalHead *pHead) dataFd = -1; numOfWrites = 0; } - + return 0; } -void confirmForward(void *ahandle, void *mhandle, int32_t code) -{ - SRpcMsg *pMsg = (SRpcMsg *)mhandle; +void confirmForward(void *ahandle, void *mhandle, int32_t code) { + SRpcMsg * pMsg = (SRpcMsg *)mhandle; SWalHead *pHead = (SWalHead *)(((char *)pMsg->pCont) - sizeof(SWalHead)); uDebug("ver:%" PRIu64 ", confirm is received", pHead->version); rpcFreeCont(pMsg->pCont); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg = {0}; rpcMsg.pCont = rpcMallocCont(msgSize); rpcMsg.contLen = msgSize; rpcMsg.handle = pMsg->handle; rpcMsg.code = code; rpcSendResponse(&rpcMsg); - taosFreeQitem(mhandle); + taosFreeQitem(mhandle); } int processRpcMsg(void *item) { - SRpcMsg *pMsg = (SRpcMsg *)item; - SWalHead *pHead = (SWalHead *)(((char *)pMsg->pCont) - sizeof(SWalHead)); - int code = -1; + SRpcMsg * pMsg = (SRpcMsg *)item; + SWalHead *pHead = (SWalHead *)(((char *)pMsg->pCont) - sizeof(SWalHead)); + int code = -1; if (role != TAOS_SYNC_ROLE_MASTER) { uError("not master, write failed, role:%s", syncRole[role]); } else { - pHead->version = ++tversion; pHead->msgType = pMsg->msgType; pHead->len = pMsg->contLen; uDebug("ver:%" PRIu64 ", pkt from client processed", pHead->version); - writeIntoWal(pHead); + writeIntoWal(pHead); syncForwardToPeer(syncHandle, pHead, item, TAOS_QTYPE_RPC); code = 0; } - if (pCfg->quorum <= 1) { - taosFreeQitem(item); + if (pCfg->quorum <= 1) { rpcFreeCont(pMsg->pCont); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg = {0}; rpcMsg.pCont = rpcMallocCont(msgSize); rpcMsg.contLen = msgSize; rpcMsg.handle = pMsg->handle; rpcMsg.code = code; rpcSendResponse(&rpcMsg); + taosFreeQitem(item); } return code; } int processFwdMsg(void *item) { - SWalHead *pHead = (SWalHead *)item; if (pHead->version <= tversion) { @@ -142,11 +138,11 @@ int processFwdMsg(void *item) { // write into cache -/* - if (pHead->handle) { - syncSendFwdAck(syncHandle, pHead->handle, 0); - } -*/ + /* + if (pHead->handle) { + syncSendFwdAck(syncHandle, pHead->handle, 0); + } + */ taosFreeQitem(item); @@ -154,7 +150,6 @@ int processFwdMsg(void *item) { } int processWalMsg(void *item) { - SWalHead *pHead = (SWalHead *)item; if (pHead->version <= tversion) { @@ -168,11 +163,11 @@ int processWalMsg(void *item) { // write into cache -/* - if (pHead->handle) { - syncSendFwdAck(syncHandle, pHead->handle, 0); - } -*/ + /* + if (pHead->handle) { + syncSendFwdAck(syncHandle, pHead->handle, 0); + } + */ taosFreeQitem(item); @@ -180,15 +175,15 @@ int processWalMsg(void *item) { } void *processWriteQueue(void *param) { - int type; - void *item; + int type; + void *item; while (1) { int ret = taosReadQitem(qhandle, &type, &item); if (ret <= 0) { usleep(1000); continue; - } + } if (type == TAOS_QTYPE_RPC) { processRpcMsg(item); @@ -196,8 +191,7 @@ void *processWriteQueue(void *param) { processWalMsg(item); } else if (type == TAOS_QTYPE_FWD) { processFwdMsg(item); - } - + } } return NULL; @@ -224,21 +218,19 @@ int retrieveAuthInfo(char *meterId, char *spi, char *encrypt, char *secret, char } void processRequestMsg(SRpcMsg *pMsg, SRpcEpSet *pEpSet) { - SRpcMsg *pTemp; pTemp = taosAllocateQitem(sizeof(SRpcMsg)); memcpy(pTemp, pMsg, sizeof(SRpcMsg)); - + uDebug("request is received, type:%d, len:%d", pMsg->msgType, pMsg->contLen); - taosWriteQitem(qhandle, TAOS_QTYPE_RPC, pTemp); + taosWriteQitem(qhandle, TAOS_QTYPE_RPC, pTemp); } -uint32_t getFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int64_t *size, uint64_t *fversion) -{ - uint32_t magic; - struct stat fstat; - char aname[280]; +uint32_t getFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int64_t *size, uint64_t *fversion) { + uint32_t magic; + struct stat fstat; + char aname[280]; if (*index == 2) { uInfo("wait for a while ....."); @@ -246,15 +238,15 @@ uint32_t getFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex } if (name[0] == 0) { - // find the file + // find the file snprintf(aname, sizeof(aname), "%s/data/data.%d", path, *index); - sprintf(name, "data/data.%d", *index); + sprintf(name, "data/data.%d", *index); } else { snprintf(aname, sizeof(aname), "%s/%s", path, name); } uInfo("get file info:%s", aname); - if ( stat(aname, &fstat) < 0 ) return 0; + if (stat(aname, &fstat) < 0) return 0; *size = fstat.st_size; magic = fstat.st_size; @@ -262,24 +254,22 @@ uint32_t getFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex return magic; } -int getWalInfo(void *ahandle, char *name, uint32_t *index) { - - struct stat fstat; - char aname[280]; +int getWalInfo(void *ahandle, char *name, uint32_t *index) { + struct stat fstat; + char aname[280]; name[0] = 0; - if (*index + 1> walNum) return 0; + if (*index + 1 > walNum) return 0; snprintf(aname, sizeof(aname), "%s/wal/wal.%d", path, *index); - sprintf(name, "wal/wal.%d", *index); + sprintf(name, "wal/wal.%d", *index); uInfo("get wal info:%s", aname); - if ( stat(aname, &fstat) < 0 ) return -1; + if (stat(aname, &fstat) < 0) return -1; - if (*index >= walNum-1) return 0; // no more + if (*index >= walNum - 1) return 0; // no more return 1; - } int writeToCache(void *ahandle, void *data, int type) { @@ -290,24 +280,19 @@ int writeToCache(void *ahandle, void *data, int type) { int msgSize = pHead->len + sizeof(SWalHead); void *pMsg = taosAllocateQitem(msgSize); memcpy(pMsg, pHead, msgSize); - taosWriteQitem(qhandle, type, pMsg); + taosWriteQitem(qhandle, type, pMsg); return 0; } -void confirmFwd(void *ahandle, int64_t version) { - - return; -} +void confirmFwd(void *ahandle, int64_t version) { return; } void notifyRole(void *ahandle, int8_t r) { role = r; printf("current role:%s\n", syncRole[role]); } - void initSync() { - pCfg->replica = 1; pCfg->quorum = 1; syncInfo.vgId = 1; @@ -339,20 +324,18 @@ void initSync() { taosGetFqdn(pCfg->nodeInfo[4].nodeFqdn); } -void doSync() -{ - for (int i=0; i<5; ++i) { - if (tsSyncPort == pCfg->nodeInfo[i].nodePort) - nodeId = pCfg->nodeInfo[i].nodeId; +void doSync() { + for (int i = 0; i < 5; ++i) { + if (tsSyncPort == pCfg->nodeInfo[i].nodePort) nodeId = pCfg->nodeInfo[i].nodeId; } snprintf(path, sizeof(path), "/root/test/d%d", nodeId); - strcpy(syncInfo.path, path); + tstrncpy(syncInfo.path, path, sizeof(syncInfo.path)); - if ( syncHandle == NULL) { - syncHandle = syncStart(&syncInfo); + if (syncHandle == NULL) { + syncHandle = syncStart(&syncInfo); } else { - if (syncReconfig(syncHandle, pCfg) < 0) syncHandle = NULL; + if (syncReconfig(syncHandle, pCfg) < 0) syncHandle = NULL; } uInfo("nodeId:%d path:%s syncPort:%d", nodeId, path, tsSyncPort); @@ -361,39 +344,39 @@ void doSync() int main(int argc, char *argv[]) { SRpcInit rpcInit; char dataName[20] = "server.data"; - pCfg = &syncInfo.syncCfg; + pCfg = &syncInfo.syncCfg; initSync(); memset(&rpcInit, 0, sizeof(rpcInit)); - rpcInit.localPort = 7000; - rpcInit.label = "SER"; + rpcInit.localPort = 7000; + rpcInit.label = "SER"; rpcInit.numOfThreads = 1; - rpcInit.cfp = processRequestMsg; - rpcInit.sessions = 1000; - rpcInit.idleTime = tsShellActivityTimer*1500; - rpcInit.afp = retrieveAuthInfo; + rpcInit.cfp = processRequestMsg; + rpcInit.sessions = 1000; + rpcInit.idleTime = tsShellActivityTimer * 1500; + rpcInit.afp = retrieveAuthInfo; - for (int i=1; ireplica = atoi(argv[++i]); - } else if (strcmp(argv[i], "-q")==0 && i < argc-1) { + } else if (strcmp(argv[i], "-q") == 0 && i < argc - 1) { pCfg->quorum = atoi(argv[++i]); - } else if (strcmp(argv[i], "-d")==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]); @@ -403,7 +386,7 @@ int main(int argc, char *argv[]) { printf(" [-m msgSize]: message body size, default is:%d\n", msgSize); printf(" [-o compSize]: compression message size, default is:%d\n", tsCompressMsgSize); printf(" [-w write]: write received data to file(0, 1, 2), default is:%d\n", commit); - printf(" [-v version]: initial node version, default is:%ld\n", syncInfo.version); + printf(" [-v version]: initial node version, default is:%" PRId64 "\n", syncInfo.version); printf(" [-r replica]: replicacation number, default is:%d\n", pCfg->replica); printf(" [-q quorum]: quorum, default is:%d\n", pCfg->quorum); printf(" [-d debugFlag]: debug flag, default:%d\n", rpcDebugFlag); @@ -411,10 +394,10 @@ int main(int argc, char *argv[]) { exit(0); } } - + uDebugFlag = rpcDebugFlag; - dDebugFlag = rpcDebugFlag; - //tmrDebugFlag = rpcDebugFlag; + dDebugFlag = rpcDebugFlag; + // tmrDebugFlag = rpcDebugFlag; tsAsyncLog = 0; taosInitLog("server.log", 1000000, 10); @@ -443,35 +426,39 @@ int main(int argc, char *argv[]) { SNodesRole nroles; while (1) { - char c = getchar(); + int c = getchar(); - switch(c) { + switch (c) { case '1': - pCfg->replica = 1; doSync(); - break; + pCfg->replica = 1; + doSync(); + break; case '2': - pCfg->replica = 2; doSync(); + pCfg->replica = 2; + doSync(); break; case '3': - pCfg->replica = 3; doSync(); + pCfg->replica = 3; + doSync(); break; case '4': - pCfg->replica = 4; doSync(); + pCfg->replica = 4; + doSync(); break; case '5': - pCfg->replica = 5; doSync(); + pCfg->replica = 5; + doSync(); break; case 's': syncGetNodesRole(syncHandle, &nroles); - for (int i=0; ireplica; ++i) + for (int i = 0; i < pCfg->replica; ++i) printf("=== nodeId:%d role:%s\n", nroles.nodeId[i], syncRole[nroles.role[i]]); break; default: break; } - if (c=='q') break; - + if (c == 'q') break; } syncStop(syncHandle); @@ -483,5 +470,3 @@ int main(int argc, char *argv[]) { return 0; } - - diff --git a/src/tsdb/src/tsdbMemTable.c b/src/tsdb/src/tsdbMemTable.c index f6a7f1b35cf7992b3bb9ccdab5892418c8174eb1..4cf8ddd4bd8df396352ad66b8499552018d5d322 100644 --- a/src/tsdb/src/tsdbMemTable.c +++ b/src/tsdb/src/tsdbMemTable.c @@ -262,7 +262,9 @@ int tsdbAsyncCommit(STsdbRepo *pRepo) { if (pIMem != NULL) { ASSERT(pRepo->commit); + tsdbDebug("vgId:%d waiting for the commit thread", REPO_ID(pRepo)); code = pthread_join(pRepo->commitThread, NULL); + tsdbDebug("vgId:%d commit thread is finished", REPO_ID(pRepo)); if (code != 0) { tsdbError("vgId:%d failed to thread join since %s", REPO_ID(pRepo), strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 564d7f5db51c80929391283e4b6fa1128275ea14..f3bd91f038cf209827b1c252160019a6b0aac27f 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -239,7 +239,7 @@ STableCfg *tsdbCreateTableCfgFromMsg(SMDCreateTableMsg *pMsg) { return NULL; } - if (tsdbInitTableCfg(pCfg, pMsg->tableType, htobe64(pMsg->uid), htonl(pMsg->sid)) < 0) goto _err; + if (tsdbInitTableCfg(pCfg, pMsg->tableType, htobe64(pMsg->uid), htonl(pMsg->tid)) < 0) goto _err; if (tdInitTSchemaBuilder(&schemaBuilder, htonl(pMsg->sversion)) < 0) { terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; goto _err; diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 3a39d5fc49565958b849e1a913b4f1e3b8130ead..ac6c2e0c5a9d5590e7dd57863dd18d8726912de5 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -20,6 +20,7 @@ #include "exception.h" #include "../../query/inc/qAst.h" // todo move to common module +#include "../../query/inc/qExecutor.h" // todo move to common module #include "tlosertree.h" #include "tsdb.h" #include "tsdbMain.h" @@ -72,7 +73,6 @@ typedef struct STableCheckInfo { SCompInfo* pCompInfo; int32_t compSize; int32_t numOfBlocks; // number of qualified data blocks not the original blocks - SDataCols* pDataCols; int32_t chosen; // indicate which iterator should move forward bool initBuf; // whether to initialize the in-memory skip list iterator or not SSkipListIterator* iter; // mem buffer skip list iterator @@ -117,10 +117,12 @@ typedef struct STsdbQueryHandle { SFileGroupIter fileIter; SRWHelper rhelper; STableBlockInfo* pDataBlockInfo; + + SDataCols *pDataCols; // in order to hold current file data block int32_t allocSize; // allocated data block size - SMemTable* mem; // mem-table - SMemTable* imem; // imem-table, acquired from snapshot - SArray* defaultLoadColumn;// default load column + SMemTable *mem; // mem-table + SMemTable *imem; // imem-table, acquired from snapshot + SArray *defaultLoadColumn;// default load column SDataBlockLoadInfo dataBlockLoadInfo; /* record current block load information */ SLoadCompBlockInfo compBlockLoadInfo; /* record current compblock information in SQuery */ @@ -142,6 +144,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, STsdbQueryHandle* pQueryHandle); static int tsdbCheckInfoCompar(const void* key1, const void* key2); + static void tsdbInitDataBlockLoadInfo(SDataBlockLoadInfo* pBlockLoadInfo) { pBlockLoadInfo->slot = -1; pBlockLoadInfo->tid = -1; @@ -181,7 +184,93 @@ static SArray* getDefaultLoadColumns(STsdbQueryHandle* pQueryHandle, bool loadTS return pLocalIdList; } -TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STableGroupInfo* groupList, void* qinfo) { +static void tsdbMayTakeMemSnapshot(TsdbQueryHandleT pHandle) { + STsdbQueryHandle* pSecQueryHandle = (STsdbQueryHandle*) pHandle; + SQInfo *pQInfo = (SQInfo *)(pSecQueryHandle->qinfo); + + if (pQInfo->memRef.ref++ == 0) { + tsdbTakeMemSnapshot(pSecQueryHandle->pTsdb, &pSecQueryHandle->mem, &pSecQueryHandle->imem); + pQInfo->memRef.mem = pSecQueryHandle->mem; + pQInfo->memRef.imem = pSecQueryHandle->imem; + } else { + pSecQueryHandle->mem = (SMemTable *)(pQInfo->memRef.mem); + pSecQueryHandle->imem = (SMemTable *)(pQInfo->memRef.imem); + } +} +static void tsdbMayUnTakeMemSnapshot(TsdbQueryHandleT pHandle) { + STsdbQueryHandle* pSecQueryHandle = (STsdbQueryHandle*) pHandle; + SQInfo *pQInfo = (SQInfo *)(pSecQueryHandle->qinfo); + + if (--pQInfo->memRef.ref == 0) { + tsdbUnTakeMemSnapShot(pSecQueryHandle->pTsdb, pSecQueryHandle->mem, pSecQueryHandle->imem); + } +} +static SArray* createCheckInfoFromTableGroup(STsdbQueryHandle* pQueryHandle, STableGroupInfo* pGroupList, STsdbMeta* pMeta) { + size_t sizeOfGroup = taosArrayGetSize(pGroupList->pGroupList); + assert(sizeOfGroup >= 1 && pMeta != NULL); + + // allocate buffer in order to load data blocks from file + SArray* pTableCheckInfo = taosArrayInit(pGroupList->numOfTables, sizeof(STableCheckInfo)); + if (pTableCheckInfo == NULL) { + return NULL; + } + + // todo apply the lastkey of table check to avoid to load header file + for (int32_t i = 0; i < sizeOfGroup; ++i) { + SArray* group = *(SArray**) taosArrayGet(pGroupList->pGroupList, i); + + size_t gsize = taosArrayGetSize(group); + assert(gsize > 0); + + for (int32_t j = 0; j < gsize; ++j) { + STableKeyInfo* pKeyInfo = (STableKeyInfo*) taosArrayGet(group, j); + + STableCheckInfo info = { .lastKey = pKeyInfo->lastKey, .pTableObj = pKeyInfo->pTable }; + info.tableId = ((STable*)(pKeyInfo->pTable))->tableId; + + assert(info.pTableObj != NULL && (info.pTableObj->type == TSDB_NORMAL_TABLE || + info.pTableObj->type == TSDB_CHILD_TABLE || info.pTableObj->type == TSDB_STREAM_TABLE)); + + info.tableId.tid = info.pTableObj->tableId.tid; + info.tableId.uid = info.pTableObj->tableId.uid; + + if (ASCENDING_TRAVERSE(pQueryHandle->order)) { + assert(info.lastKey >= pQueryHandle->window.skey); + } else { + assert(info.lastKey <= pQueryHandle->window.skey); + } + + taosArrayPush(pTableCheckInfo, &info); + tsdbDebug("%p check table uid:%"PRId64", tid:%d from lastKey:%"PRId64" %p", pQueryHandle, info.tableId.uid, + info.tableId.tid, info.lastKey, pQueryHandle->qinfo); + } + } + + taosArraySort(pTableCheckInfo, tsdbCheckInfoCompar); + return pTableCheckInfo; +} + +static SArray* createCheckInfoFromCheckInfo(SArray* pTableCheckInfo, TSKEY skey) { + size_t si = taosArrayGetSize(pTableCheckInfo); + SArray* pNew = taosArrayInit(si, sizeof(STableCheckInfo)); + if (pNew == NULL) { + return NULL; + } + + for (int32_t j = 0; j < si; ++j) { + STableCheckInfo* pCheckInfo = (STableCheckInfo*) taosArrayGet(pTableCheckInfo, j); + STableCheckInfo info = { .lastKey = skey, .pTableObj = pCheckInfo->pTableObj}; + + info.tableId = pCheckInfo->tableId; + taosArrayPush(pNew, &info); + } + + // it is ordered already, no need to sort again. + taosArraySort(pNew, tsdbCheckInfoCompar); + return pNew; +} + +static STsdbQueryHandle* tsdbQueryTablesImpl(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, void* qinfo) { STsdbQueryHandle* pQueryHandle = calloc(1, sizeof(STsdbQueryHandle)); if (pQueryHandle == NULL) { goto out_of_memory; @@ -204,10 +293,8 @@ TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STab goto out_of_memory; } - tsdbTakeMemSnapshot(pQueryHandle->pTsdb, &pQueryHandle->mem, &pQueryHandle->imem); - - size_t sizeOfGroup = taosArrayGetSize(groupList->pGroupList); - assert(sizeOfGroup >= 1 && pCond != NULL && pCond->numOfCols > 0); + tsdbMayTakeMemSnapshot(pQueryHandle); + assert(pCond != NULL && pCond->numOfCols > 0); if (ASCENDING_TRAVERSE(pCond->order)) { assert(pQueryHandle->window.skey <= pQueryHandle->window.ekey); @@ -216,21 +303,19 @@ TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STab } // allocate buffer in order to load data blocks from file - int32_t numOfCols = pCond->numOfCols; - - pQueryHandle->statis = calloc(numOfCols, sizeof(SDataStatis)); + pQueryHandle->statis = calloc(pCond->numOfCols, sizeof(SDataStatis)); if (pQueryHandle->statis == NULL) { goto out_of_memory; } - pQueryHandle->pColumns = taosArrayInit(numOfCols, sizeof(SColumnInfoData)); // todo: use list instead of array? + pQueryHandle->pColumns = taosArrayInit(pCond->numOfCols, sizeof(SColumnInfoData)); // todo: use list instead of array? if (pQueryHandle->pColumns == NULL) { goto out_of_memory; } - for (int32_t i = 0; i < numOfCols; ++i) { + for (int32_t i = 0; i < pCond->numOfCols; ++i) { SColumnInfoData colInfo = {{0}, 0}; - + colInfo.info = pCond->colList[i]; colInfo.pData = calloc(1, EXTRA_BYTES + pQueryHandle->outputCapacity * pCond->colList[i].bytes); if (colInfo.pData == NULL) { @@ -240,61 +325,47 @@ TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STab pQueryHandle->statis[i].colId = colInfo.info.colId; } - pQueryHandle->pTableCheckInfo = taosArrayInit(groupList->numOfTables, sizeof(STableCheckInfo)); - if (pQueryHandle->pTableCheckInfo == NULL) { - goto out_of_memory; - } + pQueryHandle->defaultLoadColumn = getDefaultLoadColumns(pQueryHandle, true); STsdbMeta* pMeta = tsdbGetMeta(tsdb); - assert(pMeta != NULL && sizeOfGroup >= 1 && pCond != NULL && pCond->numOfCols > 0); - - // todo apply the lastkey of table check to avoid to load header file - for (int32_t i = 0; i < sizeOfGroup; ++i) { - SArray* group = *(SArray**) taosArrayGet(groupList->pGroupList, i); - - size_t gsize = taosArrayGetSize(group); - assert(gsize > 0); + assert(pMeta != NULL); - for (int32_t j = 0; j < gsize; ++j) { - STableKeyInfo* pKeyInfo = (STableKeyInfo*) taosArrayGet(group, j); - - STableCheckInfo info = { .lastKey = pKeyInfo->lastKey, .pTableObj = pKeyInfo->pTable }; - info.tableId = ((STable*)(pKeyInfo->pTable))->tableId; - - assert(info.pTableObj != NULL && (info.pTableObj->type == TSDB_NORMAL_TABLE || - info.pTableObj->type == TSDB_CHILD_TABLE || info.pTableObj->type == TSDB_STREAM_TABLE)); - - info.tableId.tid = info.pTableObj->tableId.tid; - info.tableId.uid = info.pTableObj->tableId.uid; - - if (ASCENDING_TRAVERSE(pQueryHandle->order)) { - assert(info.lastKey >= pQueryHandle->window.skey); - } else { - assert(info.lastKey <= pQueryHandle->window.skey); - } - - taosArrayPush(pQueryHandle->pTableCheckInfo, &info); - tsdbDebug("%p check table uid:%"PRId64", tid:%d from lastKey:%"PRId64" %p", pQueryHandle, info.tableId.uid, - info.tableId.tid, info.lastKey, qinfo); - } + pQueryHandle->pDataCols = tdNewDataCols(pMeta->maxRowBytes, pMeta->maxCols, pQueryHandle->pTsdb->config.maxRowsPerFileBlock); + if (pQueryHandle->pDataCols == NULL) { + tsdbError("%p failed to malloc buf for pDataCols, %p", pQueryHandle, pQueryHandle->qinfo); + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + goto out_of_memory; } - - taosArraySort(pQueryHandle->pTableCheckInfo, tsdbCheckInfoCompar); - pQueryHandle->defaultLoadColumn = getDefaultLoadColumns(pQueryHandle, true); - - tsdbDebug("%p total numOfTable:%" PRIzu " in query, %p", pQueryHandle, taosArrayGetSize(pQueryHandle->pTableCheckInfo), pQueryHandle->qinfo); tsdbInitDataBlockLoadInfo(&pQueryHandle->dataBlockLoadInfo); tsdbInitCompBlockLoadInfo(&pQueryHandle->compBlockLoadInfo); return (TsdbQueryHandleT) pQueryHandle; -out_of_memory: + out_of_memory: tsdbCleanupQueryHandle(pQueryHandle); terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; return NULL; } +TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STableGroupInfo* groupList, void* qinfo) { + STsdbQueryHandle* pQueryHandle = tsdbQueryTablesImpl(tsdb, pCond, qinfo); + + STsdbMeta* pMeta = tsdbGetMeta(tsdb); + assert(pMeta != NULL); + + // todo apply the lastkey of table check to avoid to load header file + pQueryHandle->pTableCheckInfo = createCheckInfoFromTableGroup(pQueryHandle, groupList, pMeta); + if (pQueryHandle->pTableCheckInfo == NULL) { + tsdbCleanupQueryHandle(pQueryHandle); + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + return NULL; + } + + tsdbDebug("%p total numOfTable:%" PRIzu " in query, %p", pQueryHandle, taosArrayGetSize(pQueryHandle->pTableCheckInfo), pQueryHandle->qinfo); + return (TsdbQueryHandleT) pQueryHandle; +} + TsdbQueryHandleT tsdbQueryLastRow(TSDB_REPO_T *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupList, void* qinfo) { pCond->twindow = changeTableGroupByLastrow(groupList); @@ -689,30 +760,37 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo } static int32_t doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo, int32_t slotIndex) { - STsdbRepo *pRepo = pQueryHandle->pTsdb; - int64_t st = taosGetTimestampUs(); + int64_t st = taosGetTimestampUs(); - if (pCheckInfo->pDataCols == NULL) { - STsdbMeta* pMeta = tsdbGetMeta(pRepo); + STSchema *pSchema = tsdbGetTableSchema(pCheckInfo->pTableObj); + int32_t code = tdInitDataCols(pQueryHandle->pDataCols, pSchema); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("%p failed to malloc buf for pDataCols, %p", pQueryHandle, pQueryHandle->qinfo); + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + goto _error; + } - pCheckInfo->pDataCols = tdNewDataCols(pMeta->maxRowBytes, pMeta->maxCols, pRepo->config.maxRowsPerFileBlock); - if (pCheckInfo->pDataCols == NULL) { - tsdbError("%p failed to malloc buf, %p", pQueryHandle, pQueryHandle->qinfo); - terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; - return terrno; - } + code = tdInitDataCols(pQueryHandle->rhelper.pDataCols[0], pSchema); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("%p failed to malloc buf for rhelper.pDataCols[0], %p", pQueryHandle, pQueryHandle->qinfo); + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + goto _error; } - STSchema* pSchema = tsdbGetTableSchema(pCheckInfo->pTableObj); - tdInitDataCols(pCheckInfo->pDataCols, pSchema); - tdInitDataCols(pQueryHandle->rhelper.pDataCols[0], pSchema); - tdInitDataCols(pQueryHandle->rhelper.pDataCols[1], pSchema); + code = tdInitDataCols(pQueryHandle->rhelper.pDataCols[1], pSchema); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("%p failed to malloc buf for rhelper.pDataCols[1], %p", pQueryHandle, pQueryHandle->qinfo); + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + goto _error; + } int16_t* colIds = pQueryHandle->defaultLoadColumn->pData; int32_t ret = tsdbLoadBlockDataCols(&(pQueryHandle->rhelper), pBlock, pCheckInfo->pCompInfo, colIds, (int)(QH_GET_NUM_OF_COLS(pQueryHandle))); if (ret != TSDB_CODE_SUCCESS) { - return terrno; + int32_t c = terrno; + assert(c != TSDB_CODE_SUCCESS); + goto _error; } SDataBlockLoadInfo* pBlockLoadInfo = &pQueryHandle->dataBlockLoadInfo; @@ -729,10 +807,16 @@ static int32_t doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* p int64_t elapsedTime = (taosGetTimestampUs() - st); pQueryHandle->cost.blockLoadTime += elapsedTime; - tsdbDebug("%p load file block into buffer, index:%d, brange:%"PRId64"-%"PRId64" , rows:%d, elapsed time:%"PRId64 " us, %p", + tsdbDebug("%p load file block into buffer, index:%d, brange:%"PRId64"-%"PRId64", rows:%d, elapsed time:%"PRId64 " us, %p", pQueryHandle, slotIndex, pBlock->keyFirst, pBlock->keyLast, pBlock->numOfRows, elapsedTime, pQueryHandle->qinfo); - return TSDB_CODE_SUCCESS; + +_error: + pBlock->numOfRows = 0; + + tsdbError("%p error occurs in loading file block, index:%d, brange:%"PRId64"-%"PRId64", rows:%d, %p", + pQueryHandle, slotIndex, pBlock->keyFirst, pBlock->keyLast, pBlock->numOfRows, pQueryHandle->qinfo); + return terrno; } static int32_t getEndPosInDataBlock(STsdbQueryHandle* pQueryHandle, SDataBlockInfo* pBlockInfo); @@ -1241,6 +1325,7 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* cur->pos >= 0 && cur->pos < pBlock->numOfRows); TSKEY* tsArray = pCols->cols[0].pData; + assert(pCols->numOfRows == pBlock->numOfRows && tsArray[0] == pBlock->keyFirst && tsArray[pBlock->numOfRows-1] == pBlock->keyLast); // for search the endPos, so the order needs to reverse int32_t order = (pQueryHandle->order == TSDB_ORDER_ASC)? TSDB_ORDER_DESC:TSDB_ORDER_ASC; @@ -1898,77 +1983,34 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) { pQueryHandle->type = TSDB_QUERY_TYPE_ALL; return true; } else { - STsdbQueryHandle* pSecQueryHandle = calloc(1, sizeof(STsdbQueryHandle)); - if (pSecQueryHandle == NULL) { - terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + STimeWindow win = (STimeWindow) {pQueryHandle->window.skey, INT64_MAX}; + STsdbQueryCond cond = { + .order = TSDB_ORDER_ASC, + .numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pQueryHandle)) + }; + cond.twindow = win; + + cond.colList = calloc(cond.numOfCols, sizeof(SColumnInfo)); + if (cond.colList == NULL) { + terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; return false; } - pSecQueryHandle->order = TSDB_ORDER_ASC; - pSecQueryHandle->window = (STimeWindow) {pQueryHandle->window.skey, INT64_MAX}; - pSecQueryHandle->pTsdb = pQueryHandle->pTsdb; - pSecQueryHandle->type = TSDB_QUERY_TYPE_ALL; - pSecQueryHandle->cur.fid = -1; - pSecQueryHandle->cur.win = TSWINDOW_INITIALIZER; - pSecQueryHandle->checkFiles = true; - pSecQueryHandle->activeIndex = 0; - pSecQueryHandle->outputCapacity = ((STsdbRepo*)pSecQueryHandle->pTsdb)->config.maxRowsPerFileBlock; - - if (tsdbInitReadHelper(&pSecQueryHandle->rhelper, (STsdbRepo*) pSecQueryHandle->pTsdb) != 0) { - terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; - free(pSecQueryHandle); - return false; + for(int32_t i = 0; i < cond.numOfCols; ++i) { + SColumnInfoData* pColInfoData = taosArrayGet(pQueryHandle->pColumns, i); + memcpy(&cond.colList[i], &pColInfoData->info, sizeof(SColumnInfo)); } - tsdbTakeMemSnapshot(pSecQueryHandle->pTsdb, &pSecQueryHandle->mem, &pSecQueryHandle->imem); + STsdbQueryHandle* pSecQueryHandle = tsdbQueryTablesImpl(pQueryHandle->pTsdb, &cond, pQueryHandle->qinfo); - // allocate buffer in order to load data blocks from file - int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pQueryHandle)); + taosTFree(cond.colList); - pSecQueryHandle->statis = calloc(numOfCols, sizeof(SDataStatis)); - pSecQueryHandle->pColumns = taosArrayInit(numOfCols, sizeof(SColumnInfoData)); - if (pSecQueryHandle->statis == NULL || pSecQueryHandle->pColumns == NULL) { - terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + pSecQueryHandle->pTableCheckInfo = createCheckInfoFromCheckInfo(pQueryHandle->pTableCheckInfo, pSecQueryHandle->window.skey); + if (pSecQueryHandle->pTableCheckInfo == NULL) { tsdbCleanupQueryHandle(pSecQueryHandle); return false; } - for (int32_t i = 0; i < numOfCols; ++i) { - SColumnInfoData colInfo = {{0}, 0}; - SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i); - - colInfo.info = pCol->info; - colInfo.pData = calloc(1, EXTRA_BYTES + pQueryHandle->outputCapacity * pCol->info.bytes); - if (colInfo.pData == NULL) { - terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; - tsdbCleanupQueryHandle(pSecQueryHandle); - return false; - } - - taosArrayPush(pSecQueryHandle->pColumns, &colInfo); - } - - size_t si = taosArrayGetSize(pQueryHandle->pTableCheckInfo); - pSecQueryHandle->pTableCheckInfo = taosArrayInit(si, sizeof(STableCheckInfo)); - STsdbMeta* pMeta = tsdbGetMeta(pQueryHandle->pTsdb); - assert(pMeta != NULL); - - for (int32_t j = 0; j < si; ++j) { - STableCheckInfo* pCheckInfo = (STableCheckInfo*) taosArrayGet(pQueryHandle->pTableCheckInfo, j); - STableCheckInfo info = { - .lastKey = pSecQueryHandle->window.skey, - .pTableObj = pCheckInfo->pTableObj, - }; - - info.tableId = pCheckInfo->tableId; - - taosArrayPush(pSecQueryHandle->pTableCheckInfo, &info); - } - - tsdbInitDataBlockLoadInfo(&pSecQueryHandle->dataBlockLoadInfo); - tsdbInitCompBlockLoadInfo(&pSecQueryHandle->compBlockLoadInfo); - pSecQueryHandle->defaultLoadColumn = taosArrayClone(pQueryHandle->defaultLoadColumn); - if (!tsdbNextDataBlock((void*) pSecQueryHandle)) { tsdbCleanupQueryHandle(pSecQueryHandle); return false; @@ -1977,6 +2019,9 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) { tsdbRetrieveDataBlockInfo((void*) pSecQueryHandle, &blockInfo); tsdbRetrieveDataBlock((void*) pSecQueryHandle, pSecQueryHandle->defaultLoadColumn); + int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pSecQueryHandle)); + size_t si = taosArrayGetSize(pSecQueryHandle->pTableCheckInfo); + for (int32_t i = 0; i < numOfCols; ++i) { SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i); memcpy((char*)pCol->pData, (char*)pCol->pData + pCol->info.bytes * (pQueryHandle->cur.rows - 1), pCol->info.bytes); @@ -1990,11 +2035,11 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) { SColumnInfoData* pTSCol = taosArrayGet(pQueryHandle->pColumns, 0); // it is ascending order - pQueryHandle->cur.win = (STimeWindow){((TSKEY*)pTSCol->pData)[0], ((TSKEY*)pTSCol->pData)[1]}; + pQueryHandle->order = TSDB_ORDER_DESC; pQueryHandle->window = pQueryHandle->cur.win; + pQueryHandle->cur.win = (STimeWindow){((TSKEY*)pTSCol->pData)[0], ((TSKEY*)pTSCol->pData)[1]}; pQueryHandle->cur.rows = 2; pQueryHandle->cur.mixBlock = true; - pQueryHandle->order = TSDB_ORDER_DESC; int32_t step = -1;// one step for ascending order traverse for (int32_t j = 0; j < si; ++j) { @@ -2085,6 +2130,8 @@ STimeWindow changeTableGroupByLastrow(STableGroupInfo *groupList) { totalNumOfTable++; taosArrayPush(pGroup, &keyInfo); } else { + taosArrayDestroy(pGroup); + taosArrayRemove(groupList->pGroupList, j); numOfGroups -= 1; j -= 1; @@ -2256,7 +2303,7 @@ void filterPrepare(void* expr, void* param) { if (pInfo->optr == TSDB_RELATION_IN) { pInfo->q = (char*) pCond->arr; } else { - pInfo->q = calloc(1, pSchema->bytes); + pInfo->q = calloc(1, pSchema->bytes + TSDB_NCHAR_SIZE); // to make sure tonchar does not cause invalid write, since the '\0' needs at least sizeof(wchar_t) space. tVariantDump(pCond, pInfo->q, pSchema->type, true); } } @@ -2611,8 +2658,7 @@ int32_t tsdbGetTableGroupFromIdList(TSDB_REPO_T* tsdb, SArray* pTableIdList, STa pGroupInfo->pGroupList = taosArrayInit(1, POINTER_BYTES); SArray* group = taosArrayInit(1, sizeof(STableKeyInfo)); - int32_t i = 0; - for(; i < size; ++i) { + for(int32_t i = 0; i < size; ++i) { STableIdInfo *id = taosArrayGet(pTableIdList, i); STable* pTable = tsdbGetTableByUid(tsdbGetMeta(tsdb), id->uid); @@ -2637,8 +2683,12 @@ int32_t tsdbGetTableGroupFromIdList(TSDB_REPO_T* tsdb, SArray* pTableIdList, STa return terrno; } - pGroupInfo->numOfTables = i; - taosArrayPush(pGroupInfo->pGroupList, &group); + pGroupInfo->numOfTables = taosArrayGetSize(group); + if (pGroupInfo->numOfTables > 0) { + taosArrayPush(pGroupInfo->pGroupList, &group); + } else { + taosArrayDestroy(group); + } return TSDB_CODE_SUCCESS; } @@ -2655,8 +2705,6 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) { STableCheckInfo* pTableCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, i); destroyTableMemIterator(pTableCheckInfo); - tdFreeDataCols(pTableCheckInfo->pDataCols); - pTableCheckInfo->pDataCols = NULL; taosTFree(pTableCheckInfo->pCompInfo); } taosArrayDestroy(pQueryHandle->pTableCheckInfo); @@ -2676,10 +2724,13 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) { taosTFree(pQueryHandle->statis); // todo check error - tsdbUnTakeMemSnapShot(pQueryHandle->pTsdb, pQueryHandle->mem, pQueryHandle->imem); + tsdbMayUnTakeMemSnapshot(pQueryHandle); tsdbDestroyHelper(&pQueryHandle->rhelper); + tdFreeDataCols(pQueryHandle->pDataCols); + pQueryHandle->pDataCols = NULL; + SIOCostSummary* pCost = &pQueryHandle->cost; tsdbDebug("%p :io-cost summary: statis-info:%"PRId64" us, datablock:%" PRId64" us, check data:%"PRId64" us, %p", pQueryHandle, pCost->statisInfoLoadTime, pCost->blockLoadTime, pCost->checkForNextTime, pQueryHandle->qinfo); @@ -2707,4 +2758,5 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList) { } taosArrayDestroy(pGroupList->pGroupList); + pGroupList->numOfTables = 0; } diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index e63a085cc8d9e81d68e770df64f6c0d6c43e1807..89c8e3dc39211eca1b6c877f7789ad4313917ea2 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -3,7 +3,7 @@ PROJECT(TDengine) AUX_SOURCE_DIRECTORY(src SRC) ADD_LIBRARY(tutil ${SRC}) -TARGET_LINK_LIBRARIES(tutil pthread osdetail lz4) +TARGET_LINK_LIBRARIES(tutil pthread osdetail lz4 z) IF (TD_LINUX) TARGET_LINK_LIBRARIES(tutil m rt) diff --git a/src/util/inc/tcache.h b/src/util/inc/tcache.h index af5f30c7c3858ee37af253589cdd5e4323ad1d69..efd51f90ce8739050971856dd4f2dbdd1c44d5a4 100644 --- a/src/util/inc/tcache.h +++ b/src/util/inc/tcache.h @@ -24,6 +24,14 @@ extern "C" { #include "tlockfree.h" #include "hash.h" +#if defined(_TD_ARM_32) + #define TSDB_CACHE_PTR_KEY TSDB_DATA_TYPE_INT + #define TSDB_CACHE_PTR_TYPE int32_t +#else + #define TSDB_CACHE_PTR_KEY TSDB_DATA_TYPE_BIGINT + #define TSDB_CACHE_PTR_TYPE int64_t +#endif + typedef void (*__cache_free_fn_t)(void*); typedef struct SCacheStatis { diff --git a/src/util/inc/tconfig.h b/src/util/inc/tconfig.h index 0520cf29a87c9d4727ef6db48d8f5712ac845b89..33819f6a20ee64ada194d520ef09c6133d4dad96 100644 --- a/src/util/inc/tconfig.h +++ b/src/util/inc/tconfig.h @@ -53,7 +53,7 @@ enum { TAOS_CFG_UTYPE_NONE, TAOS_CFG_UTYPE_PERCENT, TAOS_CFG_UTYPE_GB, - TAOS_CFG_UTYPE_Mb, + TAOS_CFG_UTYPE_MB, TAOS_CFG_UTYPE_BYTE, TAOS_CFG_UTYPE_SECOND, TAOS_CFG_UTYPE_MS diff --git a/src/util/inc/tscompression.h b/src/util/inc/tscompression.h index 37d1e7b5909cf68f4dc7a25803f94442dc2cf7b0..cca6d6e25054e7736ea28590fa4cb5ab788d6b07 100644 --- a/src/util/inc/tscompression.h +++ b/src/util/inc/tscompression.h @@ -26,7 +26,7 @@ extern "C" { #define COMP_OVERFLOW_BYTES 2 #define BITS_PER_BYTE 8 // Masks -#define INT64MASK(_x) ((1ul << _x) - 1) +#define INT64MASK(_x) ((((uint64_t)1) << _x) - 1) #define INT32MASK(_x) (((uint32_t)1 << _x) - 1) #define INT8MASK(_x) (((uint8_t)1 << _x) - 1) // Compression algorithm diff --git a/src/util/inc/tskiplist.h b/src/util/inc/tskiplist.h index 4ba620dce03c51cd49faeb0ed113d64fe2d24959..a14a8565617bc08eefc989168a93f523f2e6caff 100644 --- a/src/util/inc/tskiplist.h +++ b/src/util/inc/tskiplist.h @@ -136,6 +136,7 @@ typedef struct SSkipListIterator { SSkipListNode *cur; int32_t step; // the number of nodes that have been checked already int32_t order; // order of the iterator + SSkipListNode *next; // next points to the true qualified node in skip list } SSkipListIterator; /** diff --git a/src/util/src/hash.c b/src/util/src/hash.c index 7427a2e4f345887888afe6a6e2901ef8e0d21252..625d4af1ac981c5d1f5f079f5b15533a4d63ef24 100644 --- a/src/util/src/hash.c +++ b/src/util/src/hash.c @@ -738,7 +738,7 @@ void taosHashTableResize(SHashObj *pHashObj) { int64_t et = taosGetTimestampUs(); - uDebug("hash table resize completed, new capacity:%"PRId64", load factor:%f, elapsed time:%fms", pHashObj->capacity, + uDebug("hash table resize completed, new capacity:%d, load factor:%f, elapsed time:%fms", (int32_t)pHashObj->capacity, ((double)pHashObj->size) / pHashObj->capacity, (et - st) / 1000.0); } diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index 4d737ebe66f1e82614d4eb71c1d93129949c5c4e..5be7253f6db80802feac5e51778fe89f5858733f 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -97,7 +97,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo int32_t size = (int32_t)taosHashGetSize(pCacheObj->pHashTable); assert(size > 0); - uDebug("cache:%s, key:%p, %p is destroyed from cache, size:%dbytes, num:%d size:%" PRId64 "bytes", + uDebug("cache:%s, key:%p, %p is destroyed from cache, size:%dbytes, totalNum:%d size:%" PRId64 "bytes", pCacheObj->name, pNode->key, pNode->data, pNode->size, size - 1, pCacheObj->totalSize); if (pCacheObj->freeFp) { @@ -107,12 +107,14 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo free(pNode); } -static FORCE_INLINE void doRemoveElemInTrashcan(SCacheObj* pCacheObj, STrashElem *pElem) { +static FORCE_INLINE STrashElem* doRemoveElemInTrashcan(SCacheObj* pCacheObj, STrashElem *pElem) { if (pElem->pData->signature != (uint64_t) pElem->pData) { uWarn("key:sig:0x%" PRIx64 " %p data has been released, ignore", pElem->pData->signature, pElem->pData); - return; + return NULL; } + STrashElem* next = pElem->next; + pCacheObj->numOfElemsInTrash--; if (pElem->prev) { pElem->prev->next = pElem->next; @@ -120,9 +122,15 @@ static FORCE_INLINE void doRemoveElemInTrashcan(SCacheObj* pCacheObj, STrashElem pCacheObj->pTrash = pElem->next; } - if (pElem->next) { - pElem->next->prev = pElem->prev; + if (next) { + next->prev = pElem->prev; + } + + if (pCacheObj->numOfElemsInTrash == 0) { + assert(pCacheObj->pTrash == NULL); } + + return next; } static FORCE_INLINE void doDestroyTrashcanElem(SCacheObj* pCacheObj, STrashElem *pElem) { @@ -260,7 +268,12 @@ static void incRefFn(void* ptNode) { } void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen) { - if (pCacheObj == NULL || taosHashGetSize(pCacheObj->pHashTable) == 0 || pCacheObj->deleting == 1) { + if (pCacheObj == NULL || pCacheObj->deleting == 1) { + return NULL; + } + + if (taosHashGetSize(pCacheObj->pHashTable) == 0) { + atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1); return NULL; } @@ -322,7 +335,7 @@ void *taosCacheTransfer(SCacheObj *pCacheObj, void **data) { } void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) { - if (pCacheObj == NULL || taosHashGetSize(pCacheObj->pHashTable) + pCacheObj->numOfElemsInTrash == 0) { + if (pCacheObj == NULL) { return; } @@ -330,7 +343,12 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) { uError("cache:%s, NULL data to release", pCacheObj->name); return; } - + + + // The operation of removal from hash table and addition to trashcan is not an atomic operation, + // therefore the check for the empty of both the hash table and the trashcan has a race condition. + // It happens when there is only one object in the cache, and two threads which has referenced this object + // start to free the it simultaneously [TD-1569]. size_t offset = offsetof(SCacheDataNode, data); SCacheDataNode *pNode = (SCacheDataNode *)((char *)(*data) - offset); @@ -545,8 +563,8 @@ void taosAddToTrashcan(SCacheObj *pCacheObj, SCacheDataNode *pNode) { pCacheObj->numOfElemsInTrash++; __cache_unlock(pCacheObj); - uDebug("cache:%s key:%p, %p move to trashcan, numOfElem in trashcan:%d", pCacheObj->name, pNode->key, pNode->data, - pCacheObj->numOfElemsInTrash); + uDebug("cache:%s key:%p, %p move to trashcan, pTrashElem:%p, numOfElem in trashcan:%d", pCacheObj->name, + pNode->key, pNode->data, pElem, pCacheObj->numOfElemsInTrash); } void taosTrashcanEmpty(SCacheObj *pCacheObj, bool force) { @@ -554,31 +572,30 @@ void taosTrashcanEmpty(SCacheObj *pCacheObj, bool force) { if (pCacheObj->numOfElemsInTrash == 0) { if (pCacheObj->pTrash != NULL) { + pCacheObj->pTrash = NULL; uError("cache:%s, key:inconsistency data in cache, numOfElem in trashcan:%d", pCacheObj->name, pCacheObj->numOfElemsInTrash); } - pCacheObj->pTrash = NULL; __cache_unlock(pCacheObj); return; } - STrashElem *pElem = pCacheObj->pTrash; + const char* stat[] = {"false", "true"}; + uDebug("cache:%s start to cleanup trashcan, numOfElem in trashcan:%d, free:%s", pCacheObj->name, + pCacheObj->numOfElemsInTrash, (force? stat[1]:stat[0])); + STrashElem *pElem = pCacheObj->pTrash; while (pElem) { T_REF_VAL_CHECK(pElem->pData); - if (pElem->next == pElem) { - pElem->next = NULL; - } + assert(pElem->next != pElem && pElem->prev != pElem); if (force || (T_REF_VAL_GET(pElem->pData) == 0)) { uDebug("cache:%s, key:%p, %p removed from trashcan. numOfElem in trashcan:%d", pCacheObj->name, pElem->pData->key, pElem->pData->data, pCacheObj->numOfElemsInTrash - 1); - STrashElem *p = pElem; - pElem = pElem->next; - - doRemoveElemInTrashcan(pCacheObj, p); - doDestroyTrashcanElem(pCacheObj, p); + doRemoveElemInTrashcan(pCacheObj, pElem); + doDestroyTrashcanElem(pCacheObj, pElem); + pElem = pCacheObj->pTrash; } else { pElem = pElem->next; } diff --git a/src/util/src/tlog.c b/src/util/src/tlog.c index e5afe1b68e789e4c5500aad21ea3f074302bc36f..09b0933fd6e32e9b65c8c7acbb81fbfe7d5c005b 100644 --- a/src/util/src/tlog.c +++ b/src/util/src/tlog.c @@ -139,14 +139,22 @@ static void taosUnLockFile(int32_t fd) { } static void taosKeepOldLog(char *oldName) { - if (tsLogKeepDays <= 0) return; + if (tsLogKeepDays == 0) return; int64_t fileSec = taosGetTimestampSec(); char fileName[LOG_FILE_NAME_LEN + 20]; snprintf(fileName, LOG_FILE_NAME_LEN + 20, "%s.%" PRId64, tsLogObj.logName, fileSec); taosRename(oldName, fileName); - taosRemoveOldLogFiles(tsLogDir, tsLogKeepDays); + if (tsLogKeepDays < 0) { + char compressFileName[LOG_FILE_NAME_LEN + 20]; + snprintf(compressFileName, LOG_FILE_NAME_LEN + 20, "%s.%" PRId64 ".gz", tsLogObj.logName, fileSec); + if (taosCompressFile(fileName, compressFileName) == 0) { + (void)remove(fileName); + } + } + + taosRemoveOldLogFiles(tsLogDir, ABS(tsLogKeepDays)); } static void *taosThreadToOpenNewFile(void *param) { diff --git a/src/util/src/tqueue.c b/src/util/src/tqueue.c index 8c6d6243eb4f677e9a5436b4449e07df011d2b52..d3c17e7626c4566df32c1e4257bda1a4e68a200a 100644 --- a/src/util/src/tqueue.c +++ b/src/util/src/tqueue.c @@ -263,6 +263,7 @@ void taosCloseQset(taos_qset param) { // thread to exit. void taosQsetThreadResume(taos_qset param) { STaosQset *qset = (STaosQset *)param; + uDebug("qset:%p, it will exit", qset); tsem_post(&qset->sem); } diff --git a/src/util/src/tskiplist.c b/src/util/src/tskiplist.c index 303c2440bf9b59282b8347604d58d3368dd312c0..bacdaef6c8da1e42218331aaa34d25aa40ab5dc4 100644 --- a/src/util/src/tskiplist.c +++ b/src/util/src/tskiplist.c @@ -79,9 +79,12 @@ static SSkipListIterator* doCreateSkipListIterator(SSkipList *pSkipList, int32_t // when order is TSDB_ORDER_ASC, return the last node with key less than val // when order is TSDB_ORDER_DESC, return the first node with key large than val -static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_t order) { +static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_t order, SSkipListNode** pCur) { __compar_fn_t comparFn = pSkipList->comparFn; SSkipListNode *pNode = NULL; + if (pCur != NULL) { + *pCur = NULL; + } if (order == TSDB_ORDER_ASC) { pNode = pSkipList->pHead; @@ -93,6 +96,9 @@ static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_ pNode = p; p = SL_GET_FORWARD_POINTER(p, i); } else { + if (pCur != NULL) { + *pCur = p; + } break; } } @@ -107,6 +113,9 @@ static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_ pNode = p; p = SL_GET_BACKWARD_POINTER(p, i); } else { + if (pCur != NULL) { + *pCur = p; + } break; } } @@ -295,7 +304,7 @@ SArray* tSkipListGet(SSkipList *pSkipList, SSkipListKey key) { pthread_rwlock_wrlock(pSkipList->lock); } - SSkipListNode* pNode = getPriorNode(pSkipList, key, TSDB_ORDER_ASC); + SSkipListNode* pNode = getPriorNode(pSkipList, key, TSDB_ORDER_ASC, NULL); while (1) { SSkipListNode *p = SL_GET_FORWARD_POINTER(pNode, 0); if (p == pSkipList->pTail) { @@ -452,7 +461,7 @@ uint32_t tSkipListRemove(SSkipList *pSkipList, SSkipListKey key) { pthread_rwlock_wrlock(pSkipList->lock); } - SSkipListNode* pNode = getPriorNode(pSkipList, key, TSDB_ORDER_ASC); + SSkipListNode* pNode = getPriorNode(pSkipList, key, TSDB_ORDER_ASC, NULL); while (1) { SSkipListNode *p = SL_GET_FORWARD_POINTER(pNode, 0); if (p == pSkipList->pTail) { @@ -545,7 +554,7 @@ SSkipListIterator *tSkipListCreateIterFromVal(SSkipList* pSkipList, const char* pthread_rwlock_rdlock(pSkipList->lock); } - iter->cur = getPriorNode(pSkipList, val, order); + iter->cur = getPriorNode(pSkipList, val, order, &iter->next); if (pSkipList->lock) { pthread_rwlock_unlock(pSkipList->lock); @@ -567,8 +576,22 @@ bool tSkipListIterNext(SSkipListIterator *iter) { if (iter->order == TSDB_ORDER_ASC) { // ascending order iterate iter->cur = SL_GET_FORWARD_POINTER(iter->cur, 0); + + // a new node is inserted into between iter->cur and iter->next, ignore it + if (iter->cur != iter->next && (iter->next != NULL)) { + iter->cur = iter->next; + } + + iter->next = SL_GET_FORWARD_POINTER(iter->cur, 0); } else { // descending order iterate iter->cur = SL_GET_BACKWARD_POINTER(iter->cur, 0); + + // a new node is inserted into between iter->cur and iter->next, ignore it + if (iter->cur != iter->next && (iter->next != NULL)) { + iter->cur = iter->next; + } + + iter->next = SL_GET_BACKWARD_POINTER(iter->cur, 0); } if (pSkipList->lock) { @@ -715,9 +738,11 @@ SSkipListIterator* doCreateSkipListIterator(SSkipList *pSkipList, int32_t order) iter->order = order; if(order == TSDB_ORDER_ASC) { iter->cur = pSkipList->pHead; + iter->next = SL_GET_FORWARD_POINTER(iter->cur, 0); } else { iter->cur = pSkipList->pTail; + iter->next = SL_GET_BACKWARD_POINTER(iter->cur, 0); } - + return iter; } \ No newline at end of file diff --git a/src/vnode/CMakeLists.txt b/src/vnode/CMakeLists.txt index 09cfa632fbfaaa77b32c09b49f051c0714b33564..de0cdb028b5f9231f57c78fa3411714c93de85c7 100644 --- a/src/vnode/CMakeLists.txt +++ b/src/vnode/CMakeLists.txt @@ -4,6 +4,7 @@ PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/tsdb/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/dnode/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/sync/inc) INCLUDE_DIRECTORIES(${TD_ENTERPRISE_DIR}/src/inc) INCLUDE_DIRECTORIES(inc) AUX_SOURCE_DIRECTORY(src SRC) diff --git a/src/vnode/inc/vnodeInt.h b/src/vnode/inc/vnodeInt.h index 38f7c8e6056644591993027b410283b41fb8560c..169334c6119a35f53fd0a69dd1f7cb6952fbb727 100644 --- a/src/vnode/inc/vnodeInt.h +++ b/src/vnode/inc/vnodeInt.h @@ -62,6 +62,7 @@ typedef struct { } SVnodeObj; int vnodeWriteToQueue(void *param, void *pHead, int type); +int vnodeWriteCqMsgToQueue(void *param, void *pHead, int type); void vnodeInitWriteFp(void); void vnodeInitReadFp(void); diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index a4e88fb9468e47f91e908ea669456d52b2592765..e529f27f55abe99e0a842fb839f2916a0f303bfc 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -56,6 +56,14 @@ int syncGetNodesRole(tsync_h shandle, SNodesRole * cfg) { return 0; } void syncConfirmForward(tsync_h shandle, uint64_t version, int32_t code) {} #endif +char* vnodeStatus[] = { + "init", + "ready", + "closing", + "updating", + "reset" +}; + int32_t vnodeInitResources() { int code = syncInit(); if (code != 0) return code; @@ -74,6 +82,7 @@ int32_t vnodeInitResources() { void vnodeCleanupResources() { if (tsDnodeVnodesHash != NULL) { + vDebug("vnode list is cleanup"); taosHashCleanup(tsDnodeVnodesHash); tsDnodeVnodesHash = NULL; } @@ -84,9 +93,10 @@ void vnodeCleanupResources() { int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) { int32_t code; - SVnodeObj *pTemp = (SVnodeObj *)taosHashGet(tsDnodeVnodesHash, (const char *)&pVnodeCfg->cfg.vgId, sizeof(int32_t)); - if (pTemp != NULL) { - vInfo("vgId:%d, vnode already exist, pVnode:%p", pVnodeCfg->cfg.vgId, pTemp); + SVnodeObj *pVnode = vnodeAcquire(pVnodeCfg->cfg.vgId); + if (pVnode != NULL) { + vDebug("vgId:%d, vnode already exist, refCount:%d pVnode:%p", pVnodeCfg->cfg.vgId, pVnode->refCount, pVnode); + vnodeRelease(pVnode); return TSDB_CODE_SUCCESS; } @@ -143,22 +153,24 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) { return TSDB_CODE_VND_INIT_FAILED; } - vInfo("vgId:%d, vnode is created, walLevel:%d fsyncPeriod:%d", pVnodeCfg->cfg.vgId, pVnodeCfg->cfg.walLevel, pVnodeCfg->cfg.fsyncPeriod); + vInfo("vgId:%d, vnode dir is created, walLevel:%d fsyncPeriod:%d", pVnodeCfg->cfg.vgId, pVnodeCfg->cfg.walLevel, + pVnodeCfg->cfg.fsyncPeriod); code = vnodeOpen(pVnodeCfg->cfg.vgId, rootDir); return code; } int32_t vnodeDrop(int32_t vgId) { - SVnodeObj **ppVnode = (SVnodeObj **)taosHashGet(tsDnodeVnodesHash, (const char *)&vgId, sizeof(int32_t)); - if (ppVnode == NULL || *ppVnode == NULL) { - vDebug("vgId:%d, failed to drop, vgId not find", vgId); + SVnodeObj *pVnode = vnodeAcquire(vgId); + if (pVnode == NULL) { + vDebug("vgId:%d, failed to drop, vnode not find", vgId); return TSDB_CODE_VND_INVALID_VGROUP_ID; } - SVnodeObj *pVnode = *ppVnode; - vTrace("vgId:%d, vnode will be dropped, refCount:%d", pVnode->vgId, pVnode->refCount); + vInfo("vgId:%d, vnode will be dropped, refCount:%d pVnode:%p", pVnode->vgId, pVnode->refCount, pVnode); pVnode->dropped = 1; + + vnodeRelease(pVnode); vnodeCleanUp(pVnode); return TSDB_CODE_SUCCESS; @@ -186,6 +198,12 @@ int32_t vnodeAlter(void *param, SMDCreateVnodeMsg *pVnodeCfg) { return code; } + code = walAlter(pVnode->wal, &pVnode->walCfg); + if (code != TSDB_CODE_SUCCESS) { + pVnode->status = TAOS_VN_STATUS_READY; + return code; + } + code = syncReconfig(pVnode->sync, &pVnode->syncCfg); if (code != TSDB_CODE_SUCCESS) { pVnode->status = TAOS_VN_STATUS_READY; @@ -233,8 +251,10 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { code = vnodeReadVersion(pVnode); if (code != TSDB_CODE_SUCCESS) { - vnodeCleanUp(pVnode); - return code; + vError("vgId:%d, failed to read version, generate it from data file", pVnode->vgId); + // Allow vnode start even when read version fails, set version as walVersion or zero + // vnodeCleanUp(pVnode); + // return code; } pVnode->fversion = pVnode->version; @@ -251,7 +271,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { strcpy(cqCfg.pass, tsInternalPass); strcpy(cqCfg.db, pVnode->db); cqCfg.vgId = vnode; - cqCfg.cqWrite = vnodeWriteToQueue; + cqCfg.cqWrite = vnodeWriteCqMsgToQueue; pVnode->cq = cqOpen(pVnode, &cqCfg); if (pVnode->cq == NULL) { vnodeCleanUp(pVnode); @@ -286,6 +306,9 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { } walRestore(pVnode->wal, pVnode, vnodeWriteToQueue); + if (pVnode->version == 0) { + pVnode->version = walGetVersion(pVnode->wal); + } SSyncInfo syncInfo; syncInfo.vgId = pVnode->vgId; @@ -329,11 +352,11 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { } int32_t vnodeClose(int32_t vgId) { - SVnodeObj **ppVnode = (SVnodeObj **)taosHashGet(tsDnodeVnodesHash, (const char *)&vgId, sizeof(int32_t)); - if (ppVnode == NULL || *ppVnode == NULL) return 0; + SVnodeObj *pVnode = vnodeAcquire(vgId); + if (pVnode == NULL) return 0; - SVnodeObj *pVnode = *ppVnode; - vDebug("vgId:%d, vnode will be closed", pVnode->vgId); + vDebug("vgId:%d, vnode will be closed, pVnode:%p", pVnode->vgId, pVnode); + vnodeRelease(pVnode); vnodeCleanUp(pVnode); return 0; @@ -344,21 +367,27 @@ void vnodeRelease(void *pVnodeRaw) { int32_t vgId = pVnode->vgId; int32_t refCount = atomic_sub_fetch_32(&pVnode->refCount, 1); + vTrace("vgId:%d, release vnode, refCount:%d pVnode:%p", vgId, refCount, pVnode); assert(refCount >= 0); if (refCount > 0) { - vDebug("vgId:%d, release vnode, refCount:%d", vgId, refCount); - if (pVnode->status == TAOS_VN_STATUS_RESET && refCount == 2) + if (pVnode->status == TAOS_VN_STATUS_RESET && refCount == 2) { tsem_post(&pVnode->sem); + } return; } - qCleanupQueryMgmt(pVnode->qMgmt); - pVnode->qMgmt = NULL; + vDebug("vgId:%d, vnode will be destroyed, refCount:%d pVnode:%p", vgId, refCount, pVnode); + + if (pVnode->qMgmt) { + qCleanupQueryMgmt(pVnode->qMgmt); + pVnode->qMgmt = NULL; + } - if (pVnode->tsdb) + if (pVnode->tsdb) { tsdbCloseRepo(pVnode->tsdb, 1); - pVnode->tsdb = NULL; + pVnode->tsdb = NULL; + } // stop continuous query if (pVnode->cq) { @@ -367,18 +396,21 @@ void vnodeRelease(void *pVnodeRaw) { cqClose(cq); } - if (pVnode->wal) + if (pVnode->wal) { walClose(pVnode->wal); - pVnode->wal = NULL; + pVnode->wal = NULL; + } - if (pVnode->wqueue) + if (pVnode->wqueue) { dnodeFreeVnodeWqueue(pVnode->wqueue); - pVnode->wqueue = NULL; + pVnode->wqueue = NULL; + } - if (pVnode->rqueue) + if (pVnode->rqueue) { dnodeFreeVnodeRqueue(pVnode->rqueue); - pVnode->rqueue = NULL; - + pVnode->rqueue = NULL; + } + taosTFree(pVnode->rootDir); if (pVnode->dropped) { @@ -390,6 +422,7 @@ void vnodeRelease(void *pVnodeRaw) { if (0 == tsEnableVnodeBak) { vInfo("vgId:%d, vnode backup not enabled", pVnode->vgId); } else { + taosRemoveDir(newDir); taosRename(rootDir, newDir); } @@ -401,31 +434,41 @@ void vnodeRelease(void *pVnodeRaw) { free(pVnode); int32_t count = taosHashGetSize(tsDnodeVnodesHash); - vDebug("vgId:%d, vnode is released, vnodes:%d", vgId, count); + vDebug("vgId:%d, vnode is destroyed, vnodes:%d", vgId, count); +} + +static void vnodeIncRef(void *ptNode) { + assert(ptNode != NULL); + + SVnodeObj **ppVnode = (SVnodeObj **)ptNode; + assert(ppVnode); + assert(*ppVnode); + + SVnodeObj *pVnode = *ppVnode; + atomic_add_fetch_32(&pVnode->refCount, 1); + vTrace("vgId:%d, get vnode, refCount:%d pVnode:%p", pVnode->vgId, pVnode->refCount, pVnode); } void *vnodeAcquire(int32_t vgId) { - SVnodeObj **ppVnode = (SVnodeObj **)taosHashGet(tsDnodeVnodesHash, (const char *)&vgId, sizeof(int32_t)); + SVnodeObj **ppVnode = taosHashGetCB(tsDnodeVnodesHash, &vgId, sizeof(int32_t), vnodeIncRef, NULL, sizeof(void *)); + if (ppVnode == NULL || *ppVnode == NULL) { terrno = TSDB_CODE_VND_INVALID_VGROUP_ID; - vInfo("vgId:%d, not exist", vgId); + vDebug("vgId:%d, not exist", vgId); return NULL; } - SVnodeObj *pVnode = *ppVnode; - atomic_add_fetch_32(&pVnode->refCount, 1); - vDebug("vgId:%d, get vnode, refCount:%d", pVnode->vgId, pVnode->refCount); - - return pVnode; + return *ppVnode; } void *vnodeAcquireRqueue(int32_t vgId) { SVnodeObj *pVnode = vnodeAcquire(vgId); if (pVnode == NULL) return NULL; - if (pVnode->status == TAOS_VN_STATUS_RESET) { - terrno = TSDB_CODE_APP_NOT_READY; - vInfo("vgId:%d, status is in reset", vgId); + int32_t code = vnodeCheckRead(pVnode); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + vInfo("vgId:%d, can not provide read service, status is %s", vgId, vnodeStatus[pVnode->status]); vnodeRelease(pVnode); return NULL; } @@ -437,13 +480,14 @@ void *vnodeAcquireWqueue(int32_t vgId) { SVnodeObj *pVnode = vnodeAcquire(vgId); if (pVnode == NULL) return NULL; - if (pVnode->status == TAOS_VN_STATUS_RESET) { - terrno = TSDB_CODE_APP_NOT_READY; - vInfo("vgId:%d, status is in reset", vgId); + int32_t code = vnodeCheckWrite(pVnode); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + vInfo("vgId:%d, can not provide write service, status is %s", vgId, vnodeStatus[pVnode->status]); vnodeRelease(pVnode); return NULL; } - + return pVnode->wqueue; } @@ -516,7 +560,7 @@ void vnodeSetAccess(SDMVgroupAccess *pAccess, int32_t numOfVnodes) { if (pVnode != NULL) { pVnode->accessState = pAccess[i].accessState; if (pVnode->accessState != TSDB_VN_ALL_ACCCESS) { - vDebug("vgId:%d, access state is set to %d", pAccess[i].vgId, pVnode->accessState) + vDebug("vgId:%d, access state is set to %d", pAccess[i].vgId, pVnode->accessState); } vnodeRelease(pVnode); } @@ -526,11 +570,12 @@ void vnodeSetAccess(SDMVgroupAccess *pAccess, int32_t numOfVnodes) { static void vnodeCleanUp(SVnodeObj *pVnode) { // remove from hash, so new messages wont be consumed taosHashRemove(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t)); - int i = 0; if (pVnode->status != TAOS_VN_STATUS_INIT) { // it may be in updateing or reset state, then it shall wait - while (atomic_val_compare_exchange_8(&pVnode->status, TAOS_VN_STATUS_READY, TAOS_VN_STATUS_CLOSING) != TAOS_VN_STATUS_READY) { + int i = 0; + while (atomic_val_compare_exchange_8(&pVnode->status, TAOS_VN_STATUS_READY, TAOS_VN_STATUS_CLOSING) != + TAOS_VN_STATUS_READY) { if (++i % 1000 == 0) { sched_yield(); } @@ -544,7 +589,7 @@ static void vnodeCleanUp(SVnodeObj *pVnode) { syncStop(sync); } - vTrace("vgId:%d, vnode will cleanup, refCount:%d", pVnode->vgId, pVnode->refCount); + vDebug("vgId:%d, vnode will cleanup, refCount:%d pVnode:%p", pVnode->vgId, pVnode->refCount, pVnode); // release local resources only after cutting off outside connections qQueryMgmtNotifyClosed(pVnode->qMgmt); @@ -601,17 +646,19 @@ static int vnodeResetTsdb(SVnodeObj *pVnode) char rootDir[128] = "\0"; sprintf(rootDir, "%s/tsdb", pVnode->rootDir); - if (atomic_val_compare_exchange_8(&pVnode->status, TAOS_VN_STATUS_READY, TAOS_VN_STATUS_RESET) != TAOS_VN_STATUS_READY) + if (atomic_val_compare_exchange_8(&pVnode->status, TAOS_VN_STATUS_READY, TAOS_VN_STATUS_RESET) != TAOS_VN_STATUS_READY) { return -1; + } void *tsdb = pVnode->tsdb; pVnode->tsdb = NULL; // acquire vnode - int32_t refCount = atomic_add_fetch_32(&pVnode->refCount, 1); + int32_t refCount = atomic_add_fetch_32(&pVnode->refCount, 1); - if (refCount > 2) + if (refCount > 2) { tsem_wait(&pVnode->sem); + } // close tsdb, then open tsdb tsdbCloseRepo(tsdb, 0); @@ -940,6 +987,7 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) { len += snprintf(content + len, maxLen - len, "}\n"); fwrite(content, 1, len, fp); + fflush(fp); fclose(fp); vInfo("vgId:%d, save vnode version:%" PRId64 " succeed", pVnode->vgId, pVnode->fversion); @@ -953,7 +1001,7 @@ static int32_t vnodeReadVersion(SVnodeObj *pVnode) { cJSON *root = NULL; int maxLen = 100; - terrno = TSDB_CODE_VND_APP_ERROR; + terrno = TSDB_CODE_VND_INVALID_VRESION_FILE; sprintf(versionFile, "%s/vnode%d/version.json", tsVnodeDir, pVnode->vgId); FILE *fp = fopen(versionFile, "r"); if (!fp) { @@ -967,7 +1015,7 @@ static int32_t vnodeReadVersion(SVnodeObj *pVnode) { } content = calloc(1, maxLen + 1); - int len = fread(content, 1, maxLen, fp); + int len = fread(content, 1, maxLen, fp); if (len <= 0) { vError("vgId:%d, failed to read vnode version, content is null", pVnode->vgId); goto PARSE_OVER; @@ -992,6 +1040,6 @@ static int32_t vnodeReadVersion(SVnodeObj *pVnode) { PARSE_OVER: taosTFree(content); cJSON_Delete(root); - if(fp) fclose(fp); + if (fp) fclose(fp); return terrno; } diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c index 017eeaf4269aa2de78a8167c73a9e9f3596f7096..99aed03e54ccd069e5879104f62eb01ff7bb3d05 100644 --- a/src/vnode/src/vnodeRead.c +++ b/src/vnode/src/vnodeRead.c @@ -14,7 +14,8 @@ */ #define _DEFAULT_SOURCE -//#include +#define _NON_BLOCKING_RETRIEVE 0 + #include "os.h" #include "tglobal.h" @@ -38,6 +39,11 @@ void vnodeInitReadFp(void) { vnodeProcessReadMsgFp[TSDB_MSG_TYPE_FETCH] = vnodeProcessFetchMsg; } +// +// After the fetch request enters the vnode queue, if the vnode cannot provide services, the process function are +// still required, or there will be a deadlock, so we don’t do any check here, but put the check codes before the +// request enters the queue +// int32_t vnodeProcessRead(void *param, SReadMsg *pReadMsg) { SVnodeObj *pVnode = (SVnodeObj *)param; int msgType = pReadMsg->rpcMsg.msgType; @@ -47,47 +53,72 @@ int32_t vnodeProcessRead(void *param, SReadMsg *pReadMsg) { return TSDB_CODE_VND_MSG_NOT_PROCESSED; } + return (*vnodeProcessReadMsgFp[msgType])(pVnode, pReadMsg); +} + +int32_t vnodeCheckRead(void *param) { + SVnodeObj *pVnode = param; if (pVnode->status != TAOS_VN_STATUS_READY) { - vDebug("vgId:%d, msgType:%s not processed, vnode status is %d", pVnode->vgId, taosMsg[msgType], pVnode->status); - return TSDB_CODE_APP_NOT_READY; + vDebug("vgId:%d, vnode status is %s, recCount:%d pVnode:%p", pVnode->vgId, vnodeStatus[pVnode->status], + pVnode->refCount, pVnode); + return TSDB_CODE_APP_NOT_READY; } - // tsdb may be in reset state - if (pVnode->tsdb == NULL) return TSDB_CODE_APP_NOT_READY; - if (pVnode->status == TAOS_VN_STATUS_CLOSING) + // tsdb may be in reset state + if (pVnode->tsdb == NULL) { + vDebug("vgId:%d, tsdb is null, recCount:%d pVnode:%p", pVnode->vgId, pVnode->refCount, pVnode); return TSDB_CODE_APP_NOT_READY; + } - // TODO: Later, let slave to support query - if (pVnode->syncCfg.replica > 1 && pVnode->role != TAOS_SYNC_ROLE_MASTER) { - vDebug("vgId:%d, msgType:%s not processed, replica:%d role:%d", pVnode->vgId, taosMsg[msgType], pVnode->syncCfg.replica, pVnode->role); + if (pVnode->role != TAOS_SYNC_ROLE_SLAVE && pVnode->role != TAOS_SYNC_ROLE_MASTER) { + vDebug("vgId:%d, replica:%d role:%s, recCount:%d pVnode:%p", pVnode->vgId, pVnode->syncCfg.replica, + syncRole[pVnode->role], pVnode->refCount, pVnode); return TSDB_CODE_APP_NOT_READY; } - return (*vnodeProcessReadMsgFp[msgType])(pVnode, pReadMsg); + return TSDB_CODE_SUCCESS; } +static int32_t vnodePutItemIntoReadQueue(SVnodeObj *pVnode, void **qhandle, void *ahandle) { + int32_t code = vnodeCheckRead(pVnode); + if (code != TSDB_CODE_SUCCESS) return code; -static void vnodePutItemIntoReadQueue(SVnodeObj *pVnode, void **qhandle) { SReadMsg *pRead = (SReadMsg *)taosAllocateQitem(sizeof(SReadMsg)); pRead->rpcMsg.msgType = TSDB_MSG_TYPE_QUERY; pRead->pCont = qhandle; pRead->contLen = 0; - pRead->rpcMsg.handle = NULL; + pRead->rpcMsg.ahandle = ahandle; atomic_add_fetch_32(&pVnode->refCount, 1); vDebug("QInfo:%p add to vread queue for exec query, msg:%p", *qhandle, pRead); taosWriteQitem(pVnode->rqueue, TAOS_QTYPE_QUERY, pRead); + + return TSDB_CODE_SUCCESS; } -static int32_t vnodeDumpQueryResult(SRspRet *pRet, void* pVnode, void** handle, bool* freeHandle) { +/** + * + * @param pRet response message object + * @param pVnode the vnode object + * @param handle qhandle for executing query + * @param freeHandle free qhandle or not + * @param ahandle sqlObj address at client side + * @return + */ +static int32_t vnodeDumpQueryResult(SRspRet *pRet, void *pVnode, void **handle, bool *freeHandle, void *ahandle) { bool continueExec = false; int32_t code = TSDB_CODE_SUCCESS; if ((code = qDumpRetrieveResult(*handle, (SRetrieveTableRsp **)&pRet->rsp, &pRet->len, &continueExec)) == TSDB_CODE_SUCCESS) { if (continueExec) { *freeHandle = false; - vnodePutItemIntoReadQueue(pVnode, handle); - pRet->qhandle = *handle; + code = vnodePutItemIntoReadQueue(pVnode, handle, ahandle); + if (code != TSDB_CODE_SUCCESS) { + *freeHandle = true; + return code; + } else { + pRet->qhandle = *handle; + } } else { *freeHandle = true; vDebug("QInfo:%p exec completed, free handle:%d", *handle, *freeHandle); @@ -105,55 +136,56 @@ static int32_t vnodeDumpQueryResult(SRspRet *pRet, void* pVnode, void** handle, return code; } -static void vnodeBuildNoResultQueryRsp(SRspRet* pRet) { +static void vnodeBuildNoResultQueryRsp(SRspRet *pRet) { pRet->rsp = (SRetrieveTableRsp *)rpcMallocCont(sizeof(SRetrieveTableRsp)); pRet->len = sizeof(SRetrieveTableRsp); memset(pRet->rsp, 0, sizeof(SRetrieveTableRsp)); - SRetrieveTableRsp* pRsp = pRet->rsp; + SRetrieveTableRsp *pRsp = pRet->rsp; pRsp->completed = true; } static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) { - void *pCont = pReadMsg->pCont; + void * pCont = pReadMsg->pCont; int32_t contLen = pReadMsg->contLen; SRspRet *pRet = &pReadMsg->rspRet; - SQueryTableMsg* pQueryTableMsg = (SQueryTableMsg*) pCont; + SQueryTableMsg *pQueryTableMsg = (SQueryTableMsg *)pCont; memset(pRet, 0, sizeof(SRspRet)); // qHandle needs to be freed correctly if (pReadMsg->rpcMsg.code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { - SRetrieveTableMsg* killQueryMsg = (SRetrieveTableMsg*) pReadMsg->pCont; + SRetrieveTableMsg *killQueryMsg = (SRetrieveTableMsg *)pReadMsg->pCont; killQueryMsg->free = htons(killQueryMsg->free); killQueryMsg->qhandle = htobe64(killQueryMsg->qhandle); - vWarn("QInfo:%p connection %p broken, kill query", (void*) killQueryMsg->qhandle, pReadMsg->rpcMsg.handle); + vWarn("QInfo:%p connection %p broken, kill query", (void *)killQueryMsg->qhandle, pReadMsg->rpcMsg.handle); assert(pReadMsg->rpcMsg.contLen > 0 && killQueryMsg->free == 1); - void** qhandle = qAcquireQInfo(pVnode->qMgmt, (uint64_t) killQueryMsg->qhandle); + void **qhandle = qAcquireQInfo(pVnode->qMgmt, (uint64_t)killQueryMsg->qhandle); if (qhandle == NULL || *qhandle == NULL) { - vWarn("QInfo:%p invalid qhandle, no matched query handle, conn:%p", (void*) killQueryMsg->qhandle, pReadMsg->rpcMsg.handle); + vWarn("QInfo:%p invalid qhandle, no matched query handle, conn:%p", (void *)killQueryMsg->qhandle, + pReadMsg->rpcMsg.handle); } else { - assert(*qhandle == (void*) killQueryMsg->qhandle); + assert(*qhandle == (void *)killQueryMsg->qhandle); qKillQuery(*qhandle); - qReleaseQInfo(pVnode->qMgmt, (void**) &qhandle, true); + qReleaseQInfo(pVnode->qMgmt, (void **)&qhandle, true); } return TSDB_CODE_TSC_QUERY_CANCELLED; } int32_t code = TSDB_CODE_SUCCESS; - void** handle = NULL; + void ** handle = NULL; if (contLen != 0) { qinfo_t pQInfo = NULL; code = qCreateQueryInfo(pVnode->tsdb, pVnode->vgId, pQueryTableMsg, &pQInfo); - SQueryTableRsp *pRsp = (SQueryTableRsp *) rpcMallocCont(sizeof(SQueryTableRsp)); - pRsp->code = code; + SQueryTableRsp *pRsp = (SQueryTableRsp *)rpcMallocCont(sizeof(SQueryTableRsp)); + pRsp->code = code; pRsp->qhandle = 0; pRet->len = sizeof(SQueryTableRsp); @@ -162,21 +194,25 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) { // current connect is broken if (code == TSDB_CODE_SUCCESS) { - handle = qRegisterQInfo(pVnode->qMgmt, (uint64_t) pQInfo); - if (handle == NULL) { // failed to register qhandle, todo add error test case + handle = qRegisterQInfo(pVnode->qMgmt, (uint64_t)pQInfo); + if (handle == NULL) { // failed to register qhandle + pRsp->code = terrno; + terrno = 0; vError("vgId:%d QInfo:%p register qhandle failed, return to app, code:%s", pVnode->vgId, (void *)pQInfo, tstrerror(pRsp->code)); - pRsp->code = TSDB_CODE_QRY_INVALID_QHANDLE; qDestroyQueryInfo(pQInfo); // destroy it directly + return pRsp->code; } else { assert(*handle == pQInfo); - pRsp->qhandle = htobe64((uint64_t) pQInfo); + pRsp->qhandle = htobe64((uint64_t)pQInfo); } - if (handle != NULL && vnodeNotifyCurrentQhandle(pReadMsg->rpcMsg.handle, *handle, pVnode->vgId) != TSDB_CODE_SUCCESS) { - vError("vgId:%d, QInfo:%p, query discarded since link is broken, %p", pVnode->vgId, *handle, pReadMsg->rpcMsg.handle); + if (handle != NULL && + vnodeNotifyCurrentQhandle(pReadMsg->rpcMsg.handle, *handle, pVnode->vgId) != TSDB_CODE_SUCCESS) { + vError("vgId:%d, QInfo:%p, query discarded since link is broken, %p", pVnode->vgId, *handle, + pReadMsg->rpcMsg.handle); pRsp->code = TSDB_CODE_RPC_NETWORK_UNAVAIL; - qReleaseQInfo(pVnode->qMgmt, (void**) &handle, true); + qReleaseQInfo(pVnode->qMgmt, (void **)&handle, true); return pRsp->code; } } else { @@ -185,16 +221,23 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) { if (handle != NULL) { vDebug("vgId:%d, QInfo:%p, dnode query msg disposed, create qhandle and returns to app", vgId, *handle); - vnodePutItemIntoReadQueue(pVnode, handle); + code = vnodePutItemIntoReadQueue(pVnode, handle, pReadMsg->rpcMsg.ahandle); + if (code != TSDB_CODE_SUCCESS) { + pRsp->code = code; + qReleaseQInfo(pVnode->qMgmt, (void **)&handle, true); + return pRsp->code; + } } } else { assert(pCont != NULL); - void** qhandle = (void**) pCont; + void **qhandle = (void **)pCont; vDebug("vgId:%d, QInfo:%p, dnode continues to exec query", pVnode->vgId, *qhandle); + +#if _NON_BLOCKING_RETRIEVE bool freehandle = false; - bool buildRes = qTableQuery(*qhandle); // do execute query + bool buildRes = qTableQuery(*qhandle); // do execute query // build query rsp, the retrieve request has reached here already if (buildRes) { @@ -206,11 +249,14 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) { pReadMsg->rpcMsg.handle); // set the real rsp error code - pReadMsg->rpcMsg.code = vnodeDumpQueryResult(&pReadMsg->rspRet, pVnode, qhandle, &freehandle); + pReadMsg->rpcMsg.code = vnodeDumpQueryResult(&pReadMsg->rspRet, pVnode, qhandle, &freehandle, pReadMsg->rpcMsg.ahandle); // NOTE: set return code to be TSDB_CODE_QRY_HAS_RSP to notify dnode to return msg to client code = TSDB_CODE_QRY_HAS_RSP; } else { + void* h1 = qGetResultRetrieveMsg(*qhandle); + assert(h1 == NULL); + freehandle = qQueryCompleted(*qhandle); } @@ -219,6 +265,10 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) { if (freehandle || (!buildRes)) { qReleaseQInfo(pVnode->qMgmt, (void **)&qhandle, freehandle); } +#else + qTableQuery(*qhandle); // do execute query + qReleaseQInfo(pVnode->qMgmt, (void **)&qhandle, false); +#endif } return code; @@ -232,24 +282,31 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) { pRetrieve->free = htons(pRetrieve->free); pRetrieve->qhandle = htobe64(pRetrieve->qhandle); - vDebug("vgId:%d, QInfo:%p, retrieve msg is disposed, free:%d, conn:%p", pVnode->vgId, (void*) pRetrieve->qhandle, pRetrieve->free, pReadMsg->rpcMsg.handle); + vDebug("vgId:%d, QInfo:%p, retrieve msg is disposed, free:%d, conn:%p", pVnode->vgId, (void *)pRetrieve->qhandle, + pRetrieve->free, pReadMsg->rpcMsg.handle); memset(pRet, 0, sizeof(SRspRet)); + terrno = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS; - void** handle = qAcquireQInfo(pVnode->qMgmt, pRetrieve->qhandle); - if (handle == NULL || (*handle) != (void*) pRetrieve->qhandle) { + void ** handle = qAcquireQInfo(pVnode->qMgmt, pRetrieve->qhandle); + if (handle == NULL) { + code = terrno; + terrno = TSDB_CODE_SUCCESS; + } else if ((*handle) != (void *)pRetrieve->qhandle) { code = TSDB_CODE_QRY_INVALID_QHANDLE; - vDebug("vgId:%d, invalid qhandle in retrieving result, QInfo:%p", pVnode->vgId, (void*) pRetrieve->qhandle); - + } + + if (code != TSDB_CODE_SUCCESS) { + vDebug("vgId:%d, invalid handle in retrieving result, code:0x%08x, QInfo:%p", pVnode->vgId, code, (void *)pRetrieve->qhandle); vnodeBuildNoResultQueryRsp(pRet); return code; } - + if (pRetrieve->free == 1) { vWarn("vgId:%d, QInfo:%p, retrieve msg received to kill query and free qhandle", pVnode->vgId, *handle); qKillQuery(*handle); - qReleaseQInfo(pVnode->qMgmt, (void**) &handle, true); + qReleaseQInfo(pVnode->qMgmt, (void **)&handle, true); vnodeBuildNoResultQueryRsp(pRet); code = TSDB_CODE_TSC_QUERY_CANCELLED; @@ -258,35 +315,43 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) { // register the qhandle to connect to quit query immediate if connection is broken if (vnodeNotifyCurrentQhandle(pReadMsg->rpcMsg.handle, *handle, pVnode->vgId) != TSDB_CODE_SUCCESS) { - vError("vgId:%d, QInfo:%p, retrieve discarded since link is broken, %p", pVnode->vgId, *handle, pReadMsg->rpcMsg.handle); + vError("vgId:%d, QInfo:%p, retrieve discarded since link is broken, %p", pVnode->vgId, *handle, + pReadMsg->rpcMsg.handle); code = TSDB_CODE_RPC_NETWORK_UNAVAIL; - qReleaseQInfo(pVnode->qMgmt, (void**) &handle, true); + qKillQuery(*handle); + qReleaseQInfo(pVnode->qMgmt, (void **)&handle, true); return code; } bool freeHandle = true; - bool buildRes = false; + bool buildRes = false; code = qRetrieveQueryResultInfo(*handle, &buildRes, pReadMsg->rpcMsg.handle); if (code != TSDB_CODE_SUCCESS) { - //TODO handle malloc failure + // TODO handle malloc failure pRet->rsp = (SRetrieveTableRsp *)rpcMallocCont(sizeof(SRetrieveTableRsp)); pRet->len = sizeof(SRetrieveTableRsp); memset(pRet->rsp, 0, sizeof(SRetrieveTableRsp)); freeHandle = true; - } else { // result is not ready, return immediately + } else { // result is not ready, return immediately + assert(buildRes == true); +#if _NON_BLOCKING_RETRIEVE if (!buildRes) { - qReleaseQInfo(pVnode->qMgmt, (void**) &handle, false); + assert(pReadMsg->rpcMsg.handle != NULL); + + qReleaseQInfo(pVnode->qMgmt, (void **)&handle, false); return TSDB_CODE_QRY_NOT_READY; } +#endif - code = vnodeDumpQueryResult(pRet, pVnode, handle, &freeHandle); + // ahandle is the sqlObj pointer + code = vnodeDumpQueryResult(pRet, pVnode, handle, &freeHandle, pReadMsg->rpcMsg.ahandle); } // If qhandle is not added into vread queue, the query should be completed already or paused with error. // Here free qhandle immediately if (freeHandle) { - qReleaseQInfo(pVnode->qMgmt, (void**) &handle, true); + qReleaseQInfo(pVnode->qMgmt, (void **)&handle, true); } return code; @@ -294,13 +359,13 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) { // notify connection(handle) that current qhandle is created, if current connection from // client is broken, the query needs to be killed immediately. -int32_t vnodeNotifyCurrentQhandle(void* handle, void* qhandle, int32_t vgId) { - SRetrieveTableMsg* killQueryMsg = rpcMallocCont(sizeof(SRetrieveTableMsg)); - killQueryMsg->qhandle = htobe64((uint64_t) qhandle); +int32_t vnodeNotifyCurrentQhandle(void *handle, void *qhandle, int32_t vgId) { + SRetrieveTableMsg *killQueryMsg = rpcMallocCont(sizeof(SRetrieveTableMsg)); + killQueryMsg->qhandle = htobe64((uint64_t)qhandle); killQueryMsg->free = htons(1); killQueryMsg->header.vgId = htonl(vgId); killQueryMsg->header.contLen = htonl(sizeof(SRetrieveTableMsg)); vDebug("QInfo:%p register qhandle to connect:%p", qhandle, handle); - return rpcReportProgress(handle, (char*) killQueryMsg, sizeof(SRetrieveTableMsg)); + return rpcReportProgress(handle, (char *)killQueryMsg, sizeof(SRetrieveTableMsg)); } diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 1a9b05ed34eb787ba6594c99f2fdf7c3f3b81945..855df81a1b9029d7ddd2f5e5ca6d42e8c680f7ac 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -22,9 +22,11 @@ #include "tutil.h" #include "tsdb.h" #include "twal.h" +#include "tsync.h" #include "tdataformat.h" #include "vnode.h" #include "vnodeInt.h" +#include "syncInt.h" #include "tcq.h" static int32_t (*vnodeProcessWriteMsgFp[TSDB_MSG_TYPE_MAX])(SVnodeObj *, void *, SRspRet *); @@ -47,62 +49,75 @@ void vnodeInitWriteFp(void) { int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) { int32_t code = 0; SVnodeObj *pVnode = (SVnodeObj *)param1; - SWalHead *pHead = param2; + SWalHead * pHead = param2; if (vnodeProcessWriteMsgFp[pHead->msgType] == NULL) { vDebug("vgId:%d, msgType:%s not processed, no handle", pVnode->vgId, taosMsg[pHead->msgType]); - return TSDB_CODE_VND_MSG_NOT_PROCESSED; + return TSDB_CODE_VND_MSG_NOT_PROCESSED; } - if (!(pVnode->accessState & TSDB_VN_WRITE_ACCCESS)) { - vDebug("vgId:%d, msgType:%s not processed, no write auth", pVnode->vgId, taosMsg[pHead->msgType]); - return TSDB_CODE_VND_NO_WRITE_AUTH; - } - - // tsdb may be in reset state - if (pVnode->tsdb == NULL) return TSDB_CODE_APP_NOT_READY; - if (pVnode->status == TAOS_VN_STATUS_CLOSING) - return TSDB_CODE_APP_NOT_READY; - - if (pHead->version == 0) { // from client or CQ + if (pHead->version == 0) { // from client or CQ if (pVnode->status != TAOS_VN_STATUS_READY) { - vDebug("vgId:%d, msgType:%s not processed, vnode status is %d", pVnode->vgId, taosMsg[pHead->msgType], pVnode->status); + vDebug("vgId:%d, msgType:%s not processed, vnode status is %d", pVnode->vgId, taosMsg[pHead->msgType], + pVnode->status); return TSDB_CODE_APP_NOT_READY; // it may be in deleting or closing state } if (pVnode->role != TAOS_SYNC_ROLE_MASTER) { - vDebug("vgId:%d, msgType:%s not processed, replica:%d role:%d", pVnode->vgId, taosMsg[pHead->msgType], pVnode->syncCfg.replica, pVnode->role); + vDebug("vgId:%d, msgType:%s not processed, replica:%d role:%s", pVnode->vgId, taosMsg[pHead->msgType], + pVnode->syncCfg.replica, syncRole[pVnode->role]); return TSDB_CODE_APP_NOT_READY; } // assign version - pVnode->version++; - pHead->version = pVnode->version; - if (pVnode->delay) usleep(pVnode->delay*1000); + pHead->version = pVnode->version + 1; + if (pVnode->delay) usleep(pVnode->delay * 1000); - } else { // from wal or forward + } else { // from wal or forward // for data from WAL or forward, version may be smaller if (pHead->version <= pVnode->version) return 0; } - pVnode->version = pHead->version; + // forward to peers, even it is WAL/FWD, it shall be called to update version in sync + int32_t syncCode = 0; + syncCode = syncForwardToPeer(pVnode->sync, pHead, item, qtype); + if (syncCode < 0) return syncCode; // write into WAL code = walWrite(pVnode->wal, pHead); if (code < 0) return code; - // forward to peers, even it is WAL/FWD, it shall be called to update version in sync - int32_t syncCode = 0; - syncCode = syncForwardToPeer(pVnode->sync, pHead, item, qtype); - if (syncCode < 0) return syncCode; + pVnode->version = pHead->version; - // write data locally + // write data locally code = (*vnodeProcessWriteMsgFp[pHead->msgType])(pVnode, pHead->cont, item); if (code < 0) return code; return syncCode; } +int32_t vnodeCheckWrite(void *param) { + SVnodeObj *pVnode = param; + if (!(pVnode->accessState & TSDB_VN_WRITE_ACCCESS)) { + vDebug("vgId:%d, no write auth, recCount:%d pVnode:%p", pVnode->vgId, pVnode->refCount, pVnode); + return TSDB_CODE_VND_NO_WRITE_AUTH; + } + + // tsdb may be in reset state + if (pVnode->tsdb == NULL) { + vDebug("vgId:%d, tsdb is null, recCount:%d pVnode:%p", pVnode->vgId, pVnode->refCount, pVnode); + return TSDB_CODE_APP_NOT_READY; + } + + if (pVnode->status == TAOS_VN_STATUS_CLOSING) { + vDebug("vgId:%d, vnode status is %s, recCount:%d pVnode:%p", pVnode->vgId, vnodeStatus[pVnode->status], + pVnode->refCount, pVnode); + return TSDB_CODE_APP_NOT_READY; + } + + return TSDB_CODE_SUCCESS; +} + void vnodeConfirmForward(void *param, uint64_t version, int32_t code) { SVnodeObj *pVnode = (SVnodeObj *)param; syncConfirmForward(pVnode->sync, version, code); @@ -115,14 +130,14 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR // save insert result into item SShellSubmitRspMsg *pRsp = NULL; - if (pRet) { + if (pRet) { pRet->len = sizeof(SShellSubmitRspMsg); pRet->rsp = rpcMallocCont(pRet->len); pRsp = pRet->rsp; } if (tsdbInsertData(pVnode->tsdb, pCont, pRsp) < 0) code = terrno; - + return code; } @@ -130,8 +145,15 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe int code = TSDB_CODE_SUCCESS; STableCfg *pCfg = tsdbCreateTableCfgFromMsg((SMDCreateTableMsg *)pCont); - if (pCfg == NULL) return terrno; - if (tsdbCreateTable(pVnode->tsdb, pCfg) < 0) code = terrno; + if (pCfg == NULL) { + ASSERT(terrno != 0); + return terrno; + } + + if (tsdbCreateTable(pVnode->tsdb, pCfg) < 0) { + code = terrno; + ASSERT(code != 0); + } tsdbClearTableCfg(pCfg); return code; @@ -142,7 +164,7 @@ static int32_t vnodeProcessDropTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet int32_t code = TSDB_CODE_SUCCESS; vDebug("vgId:%d, table:%s, start to drop", pVnode->vgId, pTable->tableId); - STableId tableId = {.uid = htobe64(pTable->uid), .tid = htonl(pTable->sid)}; + STableId tableId = {.uid = htobe64(pTable->uid), .tid = htonl(pTable->tid)}; if (tsdbDropTable(pVnode->tsdb, tableId) < 0) code = terrno; @@ -182,19 +204,37 @@ static int32_t vnodeProcessUpdateTagValMsg(SVnodeObj *pVnode, void *pCont, SRspR return TSDB_CODE_SUCCESS; } + +int vnodeWriteCqMsgToQueue(void *param, void *data, int type) { + SVnodeObj *pVnode = param; + SWalHead * pHead = data; + + int size = sizeof(SWalHead) + pHead->len; + SSyncHead *pSync = (SSyncHead*) taosAllocateQitem(size + sizeof(SSyncHead)); + SWalHead *pWal = (SWalHead *)(pSync + 1); + memcpy(pWal, pHead, size); + + atomic_add_fetch_32(&pVnode->refCount, 1); + vTrace("CQ: vgId:%d, get vnode wqueue, refCount:%d pVnode:%p", pVnode->vgId, pVnode->refCount, pVnode); + + taosWriteQitem(pVnode->wqueue, type, pSync); + + return 0; +} + + int vnodeWriteToQueue(void *param, void *data, int type) { SVnodeObj *pVnode = param; - SWalHead *pHead = data; + SWalHead * pHead = data; int size = sizeof(SWalHead) + pHead->len; SWalHead *pWal = (SWalHead *)taosAllocateQitem(size); memcpy(pWal, pHead, size); atomic_add_fetch_32(&pVnode->refCount, 1); - vDebug("vgId:%d, get vnode wqueue, refCount:%d", pVnode->vgId, pVnode->refCount); + vTrace("vgId:%d, get vnode wqueue, refCount:%d pVnode:%p", pVnode->vgId, pVnode->refCount, pVnode); taosWriteQitem(pVnode->wqueue, type, pWal); return 0; } - diff --git a/src/wal/src/walMain.c b/src/wal/src/walMain.c index bebad69f3224e70efb795dad51e77745ea3053e4..182600204259e703d171d6598f46a2a16cdcb27b 100644 --- a/src/wal/src/walMain.c +++ b/src/wal/src/walMain.c @@ -60,15 +60,23 @@ static int walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp); static int walRemoveWalFiles(const char *path); static void walProcessFsyncTimer(void *param, void *tmrId); static void walRelease(SWal *pWal); +static int walGetMaxOldFileId(char *odir); static void walModuleInitFunc() { walTmrCtrl = taosTmrInit(1000, 100, 300000, "WAL"); - if (walTmrCtrl == NULL) + if (walTmrCtrl == NULL) walModuleInit = PTHREAD_ONCE_INIT; else wDebug("WAL module is initialized"); } +static inline bool walNeedFsyncTimer(SWal *pWal) { + if (pWal->fsyncPeriod > 0 && pWal->level == TAOS_WAL_FSYNC) { + return true; + } + return false; +} + void *walOpen(const char *path, const SWalCfg *pCfg) { SWal *pWal = calloc(sizeof(SWal), 1); if (pWal == NULL) { @@ -83,7 +91,7 @@ void *walOpen(const char *path, const SWalCfg *pCfg) { return NULL; } - atomic_add_fetch_32(&tsWalNum, 1); + atomic_add_fetch_32(&tsWalNum, 1); pWal->fd = -1; pWal->max = pCfg->wals; pWal->id = 0; @@ -95,7 +103,7 @@ void *walOpen(const char *path, const SWalCfg *pCfg) { tstrncpy(pWal->path, path, sizeof(pWal->path)); pthread_mutex_init(&pWal->mutex, NULL); - if (pWal->fsyncPeriod > 0 && pWal->level == TAOS_WAL_FSYNC) { + if (walNeedFsyncTimer(pWal)) { pWal->timer = taosTmrStart(walProcessFsyncTimer, pWal->fsyncPeriod, pWal, walTmrCtrl); if (pWal->timer == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); @@ -110,35 +118,65 @@ void *walOpen(const char *path, const SWalCfg *pCfg) { walRelease(pWal); pWal = NULL; } - + if (pCfg->keep == 1) return pWal; - if (walHandleExistingFiles(path) == 0) - walRenew(pWal); + if (walHandleExistingFiles(path) == 0) walRenew(pWal); - if (pWal && pWal->fd <0) { + if (pWal && pWal->fd < 0) { terrno = TAOS_SYSTEM_ERROR(errno); wError("wal:%s, failed to open(%s)", path, strerror(errno)); walRelease(pWal); pWal = NULL; - } + } if (pWal) wDebug("wal:%s, it is open, level:%d fsyncPeriod:%d", path, pWal->level, pWal->fsyncPeriod); return pWal; } +int walAlter(twalh wal, const SWalCfg *pCfg) { + SWal *pWal = wal; + if (pWal == NULL) { + return TSDB_CODE_WAL_APP_ERROR; + } + + if (pWal->level == pCfg->walLevel && pWal->fsyncPeriod == pCfg->fsyncPeriod) { + wDebug("wal:%s, old walLevel:%d fsync:%d, new walLevel:%d fsync:%d not change", pWal->name, pWal->level, + pWal->fsyncPeriod, pCfg->walLevel, pCfg->fsyncPeriod); + return TSDB_CODE_SUCCESS; + } + + wInfo("wal:%s, change old walLevel:%d fsync:%d, new walLevel:%d fsync:%d", pWal->name, pWal->level, pWal->fsyncPeriod, + pCfg->walLevel, pCfg->fsyncPeriod); + + pthread_mutex_lock(&pWal->mutex); + pWal->level = pCfg->walLevel; + pWal->fsyncPeriod = pCfg->fsyncPeriod; + if (walNeedFsyncTimer(pWal)) { + wInfo("wal:%s, reset fsync timer, walLevel:%d fsyncPeriod:%d", pWal->name, pWal->level, pWal->fsyncPeriod); + taosTmrReset(walProcessFsyncTimer, pWal->fsyncPeriod, pWal, &pWal->timer, walTmrCtrl); + } else { + wInfo("wal:%s, stop fsync timer, walLevel:%d fsyncPeriod:%d", pWal->name, pWal->level, pWal->fsyncPeriod); + taosTmrStop(pWal->timer); + pWal->timer = NULL; + } + pthread_mutex_unlock(&pWal->mutex); + + return TSDB_CODE_SUCCESS; +} + void walClose(void *handle) { if (handle == NULL) return; - - SWal *pWal = handle; + + SWal *pWal = handle; taosClose(pWal->fd); if (pWal->timer) taosTmrStopA(&pWal->timer); if (pWal->keep == 0) { // remove all files in the directory - for (int i=0; inum; ++i) { - snprintf(pWal->name, sizeof(pWal->name), "%s/%s%d", pWal->path, walPrefix, pWal->id-i); - if (remove(pWal->name) <0) { + for (int i = 0; i < pWal->num; ++i) { + snprintf(pWal->name, sizeof(pWal->name), "%s/%s%d", pWal->path, walPrefix, pWal->id - i); + if (remove(pWal->name) < 0) { wError("wal:%s, failed to remove", pWal->name); } else { wDebug("wal:%s, it is removed", pWal->name); @@ -159,7 +197,7 @@ int walRenew(void *handle) { pthread_mutex_lock(&pWal->mutex); - if (pWal->fd >=0) { + if (pWal->fd >= 0) { close(pWal->fd); pWal->id++; wDebug("wal:%s, it is closed", pWal->name); @@ -180,7 +218,7 @@ int walRenew(void *handle) { // remove the oldest wal file char name[TSDB_FILENAME_LEN * 3]; snprintf(name, sizeof(name), "%s/%s%d", pWal->path, walPrefix, pWal->id - pWal->max); - if (remove(name) <0) { + if (remove(name) < 0) { wError("wal:%s, failed to remove(%s)", name, strerror(errno)); } else { wDebug("wal:%s, it is removed", name); @@ -188,8 +226,8 @@ int walRenew(void *handle) { pWal->num--; } - } - + } + pthread_mutex_unlock(&pWal->mutex); return terrno; @@ -201,7 +239,7 @@ int walWrite(void *handle, SWalHead *pHead) { terrno = 0; - // no wal + // no wal if (pWal->level == TAOS_WAL_NOLOG) return 0; if (pHead->version <= pWal->version) return 0; @@ -209,7 +247,7 @@ int walWrite(void *handle, SWalHead *pHead) { taosCalcChecksumAppend(0, (uint8_t *)pHead, sizeof(SWalHead)); int contLen = pHead->len + sizeof(SWalHead); - if(taosTWrite(pWal->fd, pHead, contLen) != contLen) { + if (taosTWrite(pWal->fd, pHead, contLen) != contLen) { wError("wal:%s, failed to write(%s)", pWal->name, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); } else { @@ -220,7 +258,6 @@ int walWrite(void *handle, SWalHead *pHead) { } void walFsync(void *handle) { - SWal *pWal = handle; if (pWal == NULL || pWal->level != TAOS_WAL_FSYNC || pWal->fd < 0) return; @@ -238,12 +275,11 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int)) uint32_t maxId = 0, minId = -1, index =0; terrno = 0; - int plen = strlen(walPrefix); - char opath[TSDB_FILENAME_LEN+5]; - + int plen = strlen(walPrefix); + char opath[TSDB_FILENAME_LEN + 5]; + int slen = snprintf(opath, sizeof(opath), "%s", pWal->path); - if ( pWal->keep == 0) - strcpy(opath+slen, "/old"); + if (pWal->keep == 0) strcpy(opath + slen, "/old"); DIR *dir = opendir(opath); if (dir == NULL && errno == ENOENT) return 0; @@ -252,8 +288,8 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int)) return terrno; } - while ((ent = readdir(dir))!= NULL) { - if ( strncmp(ent->d_name, walPrefix, plen) == 0) { + while ((ent = readdir(dir)) != NULL) { + if (strncmp(ent->d_name, walPrefix, plen) == 0) { index = atol(ent->d_name + plen); if (index > maxId) maxId = index; if (index < minId) minId = index; @@ -268,16 +304,16 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int)) return terrno; } - if ( count != (maxId-minId+1) ) { + if (count != (maxId - minId + 1)) { wError("wal:%s, messed up, count:%d max:%d min:%d", opath, count, maxId, minId); terrno = TSDB_CODE_WAL_APP_ERROR; } else { wDebug("wal:%s, %d files will be restored", opath, count); - for (index = minId; index<=maxId; ++index) { + for (index = minId; index <= maxId; ++index) { snprintf(pWal->name, sizeof(pWal->name), "%s/%s%d", opath, walPrefix, index); terrno = walRestoreWalFile(pWal, pVnode, writeFp); - if (terrno < 0) break; + if (terrno < 0) continue; } } @@ -290,7 +326,7 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int)) terrno = TAOS_SYSTEM_ERROR(errno); } } - } else { + } else { // open the existing WAL file in append mode pWal->num = count; pWal->id = maxId; @@ -307,9 +343,9 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int)) } int walGetWalFile(void *handle, char *name, uint32_t *index) { - SWal *pWal = handle; + SWal * pWal = handle; int code = 1; - int32_t first = 0; + int32_t first = 0; name[0] = 0; if (pWal == NULL || pWal->num == 0) return 0; @@ -321,18 +357,17 @@ int walGetWalFile(void *handle, char *name, uint32_t *index) { if (*index < first && *index > pWal->id) { code = -1; // index out of range - } else { + } else { sprintf(name, "wal/%s%d", walPrefix, *index); - code = (*index == pWal->id) ? 0:1; + code = (*index == pWal->id) ? 0 : 1; } pthread_mutex_unlock(&(pWal->mutex)); return code; -} +} static void walRelease(SWal *pWal) { - pthread_mutex_destroy(&pWal->mutex); pWal->signature = NULL; free(pWal); @@ -347,17 +382,18 @@ static void walRelease(SWal *pWal) { static int walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp) { char *name = pWal->name; + int size = 1024 * 1024; // default 1M buffer size terrno = 0; - char *buffer = malloc(1024000); // size for one record + char *buffer = malloc(size); if (buffer == NULL) { - terrno = TAOS_SYSTEM_ERROR(errno); + terrno = TAOS_SYSTEM_ERROR(errno); return terrno; } SWalHead *pHead = (SWalHead *)buffer; - int fd = open(name, O_RDONLY); + int fd = open(name, O_RDWR); if (fd < 0) { wError("wal:%s, failed to open for restore(%s)", name, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); @@ -367,29 +403,58 @@ static int walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp) { wDebug("wal:%s, start to restore", name); + size_t offset = 0; while (1) { int ret = taosTRead(fd, pHead, sizeof(SWalHead)); - if ( ret == 0) break; + if (ret == 0) break; - if (ret != sizeof(SWalHead)) { - wWarn("wal:%s, failed to read head, skip, ret:%d(%s)", name, ret, strerror(errno)); + if (ret < 0) { + wError("wal:%s, failed to read wal head part since %s", name, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); break; } + if (ret < sizeof(SWalHead)) { + wError("wal:%s, failed to read head, ret:%d, skip the rest of file", name, ret); + taosFtruncate(fd, offset); + fsync(fd); + break; + } + if (!taosCheckChecksumWhole((uint8_t *)pHead, sizeof(SWalHead))) { wWarn("wal:%s, cksum is messed up, skip the rest of file", name); - terrno = TAOS_SYSTEM_ERROR(errno); + terrno = TSDB_CODE_WAL_FILE_CORRUPTED; + // ASSERT(false); break; - } + } + + if (pHead->len > size - sizeof(SWalHead)) { + size = sizeof(SWalHead) + pHead->len; + buffer = realloc(buffer, size); + if (buffer == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + break; + } + + pHead = (SWalHead *)buffer; + } ret = taosTRead(fd, pHead->cont, pHead->len); - if ( ret != pHead->len) { - wWarn("wal:%s, failed to read body, skip, len:%d ret:%d", name, pHead->len, ret); + if (ret < 0) { + wError("wal:%s failed to read wal body part since %s", name, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); break; } + if (ret < pHead->len) { + wError("wal:%s, failed to read body, len:%d ret:%d, skip the rest of file", name, pHead->len, ret); + taosFtruncate(fd, offset); + fsync(fd); + break; + } + + offset = offset + sizeof(SWalHead) + pHead->len; + if (pWal->keep) pWal->version = pHead->version; (*writeFp)(pVnode, pHead, TAOS_QTYPE_WAL); } @@ -412,63 +477,58 @@ int walHandleExistingFiles(const char *path) { int plen = strlen(walPrefix); terrno = 0; - if (access(opath, F_OK) == 0) { - // old directory is there, it means restore process is not finished - walRemoveWalFiles(path); - - } else { - // move all files to old directory - int count = 0; - while ((ent = readdir(dir))!= NULL) { - if ( strncmp(ent->d_name, walPrefix, plen) == 0) { - snprintf(oname, sizeof(oname), "%s/%s", path, ent->d_name); - snprintf(nname, sizeof(nname), "%s/old/%s", path, ent->d_name); - if (taosMkDir(opath, 0755) != 0) { - wError("wal:%s, failed to create directory:%s(%s)", oname, opath, strerror(errno)); - terrno = TAOS_SYSTEM_ERROR(errno); - break; - } - - if (rename(oname, nname) < 0) { - wError("wal:%s, failed to move to new:%s", oname, nname); - terrno = TAOS_SYSTEM_ERROR(errno); - break; - } + int midx = walGetMaxOldFileId(opath); + int count = 0; + while ((ent = readdir(dir)) != NULL) { + if (strncmp(ent->d_name, walPrefix, plen) == 0) { + midx++; + snprintf(oname, sizeof(oname), "%s/%s", path, ent->d_name); + snprintf(nname, sizeof(nname), "%s/old/wal%d", path, midx); + if (taosMkDir(opath, 0755) != 0) { + wError("wal:%s, failed to create directory:%s(%s)", oname, opath, strerror(errno)); + terrno = TAOS_SYSTEM_ERROR(errno); + break; + } - count++; + if (rename(oname, nname) < 0) { + wError("wal:%s, failed to move to new:%s", oname, nname); + terrno = TAOS_SYSTEM_ERROR(errno); + break; } + + count++; } wDebug("wal:%s, %d files are moved for restoration", path, count); } - + closedir(dir); return terrno; } static int walRemoveWalFiles(const char *path) { - int plen = strlen(walPrefix); - char name[TSDB_FILENAME_LEN * 3]; - + int plen = strlen(walPrefix); + char name[TSDB_FILENAME_LEN * 3]; + terrno = 0; struct dirent *ent; - DIR *dir = opendir(path); + DIR *dir = opendir(path); if (dir == NULL && errno == ENOENT) return 0; if (dir == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); return terrno; - } + } - while ((ent = readdir(dir))!= NULL) { - if ( strncmp(ent->d_name, walPrefix, plen) == 0) { + while ((ent = readdir(dir)) != NULL) { + if (strncmp(ent->d_name, walPrefix, plen) == 0) { snprintf(name, sizeof(name), "%s/%s", path, ent->d_name); - if (remove(name) <0) { + if (remove(name) < 0) { wError("wal:%s, failed to remove(%s)", name, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); } } - } + } closedir(dir); @@ -484,6 +544,45 @@ static void walProcessFsyncTimer(void *param, void *tmrId) { if (fsync(pWal->fd) < 0) { wError("wal:%s, fsync failed(%s)", pWal->name, strerror(errno)); } - - pWal->timer = taosTmrStart(walProcessFsyncTimer, pWal->fsyncPeriod, pWal, walTmrCtrl); + + if (walNeedFsyncTimer(pWal)) { + pWal->timer = taosTmrStart(walProcessFsyncTimer, pWal->fsyncPeriod, pWal, walTmrCtrl); + } else { + wInfo("wal:%s, stop fsync timer for walLevel:%d fsyncPeriod:%d", pWal->name, pWal->level, pWal->fsyncPeriod); + taosTmrStop(pWal->timer); + pWal->timer = NULL; + } } + +int64_t walGetVersion(twalh param) { + SWal *pWal = param; + if (pWal == 0) return 0; + + return pWal->version; +} + +static int walGetMaxOldFileId(char *odir) { + int midx = 0; + DIR * dir = NULL; + struct dirent *dp = NULL; + int plen = strlen(walPrefix); + + if (access(odir, F_OK) != 0) return midx; + + dir = opendir(odir); + if (dir == NULL) { + wError("failed to open directory %s since %s", odir, strerror(errno)); + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + + while ((dp = readdir(dir)) != NULL) { + if (strncmp(dp->d_name, walPrefix, plen) == 0) { + int idx = atol(dp->d_name + plen); + if (midx < idx) midx = idx; + } + } + + closedir(dir); + return midx; +} \ No newline at end of file diff --git a/src/wal/test/waltest.c b/src/wal/test/waltest.c index 073dbf72af02437dc494fdf18ceeebaa24777dca..bbee1347b8f92aa6cfad448fdfb369de8f5a6301 100644 --- a/src/wal/test/waltest.c +++ b/src/wal/test/waltest.c @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) { printf(" [-t total]: total wal files, default is:%d\n", total); printf(" [-r rows]: rows of records per wal file, default is:%d\n", rows); printf(" [-k keep]: keep the wal after closing, default is:%d\n", keep); - printf(" [-v version]: initial version, default is:%ld\n", ver); + printf(" [-v version]: initial version, default is:%" PRId64 "\n", ver); printf(" [-d debugFlag]: debug flag, default:%d\n", dDebugFlag); printf(" [-h help]: print out this help\n\n"); exit(0); @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) { exit(-1); } - printf("version starts from:%ld\n", ver); + printf("version starts from:%" PRId64 "\n", ver); int contLen = sizeof(SWalHead) + size; SWalHead *pHead = (SWalHead *) malloc(contLen); diff --git a/tests/comparisonTest/tdengine/tdengineTest.c b/tests/comparisonTest/tdengine/tdengineTest.c index 3d78a3d0a54ac571aceb13c1bb9a6f133589bd86..1298aa8323b0f876e3c64ff88323031b8d529648 100644 --- a/tests/comparisonTest/tdengine/tdengineTest.c +++ b/tests/comparisonTest/tdengine/tdengineTest.c @@ -108,9 +108,9 @@ void parseArg(int argc, char *argv[]) { } } -void taos_error(TAOS *con) { - printf("TDengine error: %s\n", taos_errstr(con)); - taos_close(con); +static void taos_error(TAOS_RES *tres, TAOS *conn) { + printf("TDengine error: %s\n", tres?taos_errstr(tres):"null result"); + taos_close(conn); exit(1); } @@ -125,13 +125,17 @@ void writeDataImp(void *param) { printf("Thread %d, writing sID %d, eID %d\n", pThread->threadId, pThread->sID, pThread->eID); void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); - if (taos == NULL) - taos_error(taos); + if (taos == NULL) { + // where to find errstr? + // taos_error(NULL, taos); + printf("TDengine error: %s\n", "failed to connect"); + exit(1); + } TAOS_RES* result = taos_query(taos, "use db"); int32_t code = taos_errno(result); if (code != 0) { - taos_error(taos); + taos_error(result, taos); } taos_free_result(result); @@ -227,12 +231,17 @@ void writeData() { taos_init(); void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); - if (taos == NULL) taos_error(taos); + if (taos == NULL) { + // where to find errstr? + // taos_error(NULL, taos); + printf("TDengine error: %s\n", "failed to connect"); + exit(1); + } TAOS_RES *result = taos_query(taos, "create database if not exists db"); int32_t code = taos_errno(result); if (code != 0) { - taos_error(taos); + taos_error(result, taos); } taos_free_result(result); @@ -241,7 +250,7 @@ void writeData() { "tags(devid int, devname binary(16), devgroup int)"); code = taos_errno(result); if (code != 0) { - taos_error(taos); + taos_error(result, taos); } taos_free_result(result); @@ -278,7 +287,7 @@ void writeData() { free(threads); - printf("---- Spent %f seconds to insert %ld records, speed: %f Rows/Second\n", seconds, statis.totalRows, rs); + printf("---- Spent %f seconds to insert %" PRId64 " records, speed: %f Rows/Second\n", seconds, statis.totalRows, rs); } void readDataImp(void *param) @@ -293,8 +302,12 @@ void readDataImp(void *param) printf("open file %s success\n", arguments.sql); void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); - if (taos == NULL) - taos_error(taos); + if (taos == NULL) { + // where to find errstr? + // taos_error(NULL, taos); + printf("TDengine error: %s\n", "failed to connect"); + exit(1); + } char *line = NULL; size_t len = 0; @@ -313,7 +326,7 @@ void readDataImp(void *param) TAOS_RES *result = taos_query(taos, line); int32_t code = taos_errno(result); if (code != 0) { - taos_error(taos); + taos_error(result, taos); } TAOS_ROW row; @@ -343,8 +356,12 @@ void readData() { printf("---- clients: %d\n", arguments.clients); void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); - if (taos == NULL) - taos_error(taos); + if (taos == NULL) { + // where to find errstr? + // taos_error(NULL, taos); + printf("TDengine error: %s\n", "failed to connect"); + exit(1); + } ThreadObj *threads = calloc((size_t)arguments.clients, sizeof(ThreadObj)); diff --git a/tests/examples/C#/C#checker/C#checker.cs b/tests/examples/C#/C#checker/C#checker.cs new file mode 100644 index 0000000000000000000000000000000000000000..24b7060b14862e220b9b08a362e27cd65ae4eb7d --- /dev/null +++ b/tests/examples/C#/C#checker/C#checker.cs @@ -0,0 +1,377 @@ +/* + * 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 . + */ + +using System; +using System.Text; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Collections; + +namespace TDengineDriver +{ + class TDengineTest + { + //connect parameters + private string host; + private string configDir; + private string user; + private string password; + private short port = 0; + + //sql parameters + private string dbName; + private string tbName; + + + private bool isInsertData; + private bool isQueryData; + + private long tableCount; + private long totalRows; + private long batchRows; + private long beginTimestamp = 1551369600000L; + + private IntPtr conn = IntPtr.Zero; + private long rowsInserted = 0; + + static void Main(string[] args) + { + TDengineTest tester = new TDengineTest(); + tester.ReadArgument(args); + + + tester.InitTDengine(); + tester.ConnectTDengine(); + tester.createDatabase(); + tester.useDatabase(); + tester.checkDropTable(); + tester.createTable(); + tester.checkInsert(); + tester.checkSelect(); + tester.checkDropTable(); + + tester.CloseConnection(); + + + + } + + public long GetArgumentAsLong(String[] argv, String argName, int minVal, int maxVal, int defaultValue) + { + int argc = argv.Length; + for (int i = 0; i < argc; ++i) + { + if (argName != argv[i]) + { + continue; + } + if (i < argc - 1) + { + String tmp = argv[i + 1]; + if (tmp[0] == '-') + { + Console.WriteLine("option {0:G} requires an argument", tmp); + ExitProgram(); + } + + long tmpVal = Convert.ToInt64(tmp); + if (tmpVal < minVal || tmpVal > maxVal) + { + Console.WriteLine("option {0:G} should in range [{1:G}, {2:G}]", argName, minVal, maxVal); + ExitProgram(); + } + + return tmpVal; + } + } + + return defaultValue; + } + + public String GetArgumentAsString(String[] argv, String argName, String defaultValue) + { + int argc = argv.Length; + for (int i = 0; i < argc; ++i) + { + if (argName != argv[i]) + { + continue; + } + if (i < argc - 1) + { + String tmp = argv[i + 1]; + if (tmp[0] == '-') + { + Console.WriteLine("option {0:G} requires an argument", tmp); + ExitProgram(); + } + return tmp; + } + } + + return defaultValue; + } + + public void PrintHelp(String[] argv) + { + for (int i = 0; i < argv.Length; ++i) + { + if ("--help" == argv[i]) + { + String indent = " "; + Console.WriteLine("taosTest is simple example to operate TDengine use C# Language.\n"); + Console.WriteLine("{0:G}{1:G}", indent, "-h"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "TDEngine server IP address to connect"); + Console.WriteLine("{0:G}{1:G}", indent, "-u"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDEngine user name to use when connecting to the server, default is root"); + Console.WriteLine("{0:G}{1:G}", indent, "-p"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDEngine user name to use when connecting to the server, default is taosdata"); + Console.WriteLine("{0:G}{1:G}", indent, "-d"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Database used to create table or import data, default is db"); + Console.WriteLine("{0:G}{1:G}", indent, "-s"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Super Tables used to create table, default is mt"); + Console.WriteLine("{0:G}{1:G}", indent, "-t"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Table prefixs, default is t"); + Console.WriteLine("{0:G}{1:G}", indent, "-w"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Whether to insert data"); + Console.WriteLine("{0:G}{1:G}", indent, "-r"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Whether to query data"); + Console.WriteLine("{0:G}{1:G}", indent, "-n"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many Tables to create, default is 10"); + Console.WriteLine("{0:G}{1:G}", indent, "-b"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many rows per insert batch, default is 10"); + Console.WriteLine("{0:G}{1:G}", indent, "-i"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many rows to insert, default is 100"); + Console.WriteLine("{0:G}{1:G}", indent, "-c"); + Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Configuration directory"); + + ExitProgram(); + } + } + } + + public void ReadArgument(String[] argv) + { + PrintHelp(argv); + host = this.GetArgumentAsString(argv, "-h", "127.0.0.1"); + user = this.GetArgumentAsString(argv, "-u", "root"); + password = this.GetArgumentAsString(argv, "-p", "taosdata"); + dbName = this.GetArgumentAsString(argv, "-db", "test"); + tbName = this.GetArgumentAsString(argv, "-s", "weather"); + + isInsertData = this.GetArgumentAsLong(argv, "-w", 0, 1, 1) != 0; + isQueryData = this.GetArgumentAsLong(argv, "-r", 0, 1, 1) != 0; + tableCount = this.GetArgumentAsLong(argv, "-n", 1, 10000, 10); + batchRows = this.GetArgumentAsLong(argv, "-b", 1, 1000, 500); + totalRows = this.GetArgumentAsLong(argv, "-i", 1, 10000000, 10000); + configDir = this.GetArgumentAsString(argv, "-c", "C:/TDengine/cfg"); + } + + public void InitTDengine() + { + TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir); + TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); + TDengine.Init(); + Console.WriteLine("get connection starting..."); + } + + public void ConnectTDengine() + { + string db = ""; + this.conn = TDengine.Connect(this.host, this.user, this.password, db, this.port); + if (this.conn == IntPtr.Zero) + { + Console.WriteLine("connection failed: " + this.host); + ExitProgram(); + } + else + { + Console.WriteLine("[ OK ] Connection established."); + } + } + public void createDatabase() + { + StringBuilder sql = new StringBuilder(); + sql.Append("create database if not exists ").Append(this.dbName); + execute(sql.ToString()); + } + public void useDatabase() + { + StringBuilder sql = new StringBuilder(); + sql.Append("use ").Append(this.dbName); + execute(sql.ToString()); + } + public void checkSelect() + { + StringBuilder sql = new StringBuilder(); + sql.Append("select * from test.weather"); + execute(sql.ToString()); + } + public void createTable() + { + StringBuilder sql = new StringBuilder(); + sql.Append("create table if not exists ").Append(this.dbName).Append(".").Append(this.tbName).Append("(ts timestamp, temperature float, humidity int)"); + execute(sql.ToString()); + } + public void checkInsert() + { + StringBuilder sql = new StringBuilder(); + sql.Append("insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)"); + execute(sql.ToString()); + } + public void checkDropTable() + { + StringBuilder sql = new StringBuilder(); + sql.Append("drop table if exists ").Append(this.dbName).Append(".").Append(this.tbName).Append(""); + execute(sql.ToString()); + } + public void execute(string sql) + { + DateTime dt1 = DateTime.Now; + IntPtr res = TDengine.Query(this.conn, sql.ToString()); + DateTime dt2 = DateTime.Now; + TimeSpan span = dt2 - dt1; + + if (res != IntPtr.Zero) + { + Console.WriteLine("[OK] time cost: " + span.ToString() + "ms, execute statement ====> " + sql.ToString()); + } + else + { + Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res)); + ExitProgram(); + } + TDengine.FreeResult(res); + } + + public void ExecuteQuery(string sql) + { + + DateTime dt1 = DateTime.Now; + long queryRows = 0; + IntPtr res = TDengine.Query(conn, sql); + if (res == IntPtr.Zero) + { + Console.WriteLine(sql + " failure, reason: " + TDengine.Error(res)); + ExitProgram(); + } + DateTime dt2 = DateTime.Now; + TimeSpan span = dt2 - dt1; + Console.WriteLine("[OK] time cost: " + span.ToString() + "ms, execute statement ====> " + sql.ToString()); + int fieldCount = TDengine.FieldCount(res); + + List metas = TDengine.FetchFields(res); + for (int j = 0; j < metas.Count; j++) + { + TDengineMeta meta = (TDengineMeta)metas[j]; + } + + IntPtr rowdata; + StringBuilder builder = new StringBuilder(); + while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero) + { + queryRows++; + for (int fields = 0; fields < fieldCount; ++fields) + { + TDengineMeta meta = metas[fields]; + int offset = IntPtr.Size * fields; + IntPtr data = Marshal.ReadIntPtr(rowdata, offset); + + builder.Append("---"); + + if (data == IntPtr.Zero) + { + builder.Append("NULL"); + continue; + } + + switch ((TDengineDataType)meta.type) + { + case TDengineDataType.TSDB_DATA_TYPE_BOOL: + bool v1 = Marshal.ReadByte(data) == 0 ? false : true; + builder.Append(v1); + break; + case TDengineDataType.TSDB_DATA_TYPE_TINYINT: + byte v2 = Marshal.ReadByte(data); + builder.Append(v2); + break; + case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: + short v3 = Marshal.ReadInt16(data); + builder.Append(v3); + break; + case TDengineDataType.TSDB_DATA_TYPE_INT: + int v4 = Marshal.ReadInt32(data); + builder.Append(v4); + break; + case TDengineDataType.TSDB_DATA_TYPE_BIGINT: + long v5 = Marshal.ReadInt64(data); + builder.Append(v5); + break; + case TDengineDataType.TSDB_DATA_TYPE_FLOAT: + float v6 = (float)Marshal.PtrToStructure(data, typeof(float)); + builder.Append(v6); + break; + case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: + double v7 = (double)Marshal.PtrToStructure(data, typeof(double)); + builder.Append(v7); + break; + case TDengineDataType.TSDB_DATA_TYPE_BINARY: + string v8 = Marshal.PtrToStringAnsi(data); + builder.Append(v8); + break; + case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: + long v9 = Marshal.ReadInt64(data); + builder.Append(v9); + break; + case TDengineDataType.TSDB_DATA_TYPE_NCHAR: + string v10 = Marshal.PtrToStringAnsi(data); + builder.Append(v10); + break; + } + } + builder.Append("---"); + + if (queryRows <= 10) + { + Console.WriteLine(builder.ToString()); + } + builder.Clear(); + } + + if (TDengine.ErrorNo(res) != 0) + { + Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res)); + } + + TDengine.FreeResult(res); + + } + + public void CloseConnection() + { + if (this.conn != IntPtr.Zero) + { + TDengine.Close(this.conn); + Console.WriteLine("connection closed."); + } + } + + static void ExitProgram() + { + TDengine.Cleanup(); + System.Environment.Exit(0); + } + } +} diff --git a/tests/examples/C#/C#checker/TDengineDriver.cs b/tests/examples/C#/C#checker/TDengineDriver.cs new file mode 100644 index 0000000000000000000000000000000000000000..b6f143e1813d60c1ac4ae8356efdca4929c51345 --- /dev/null +++ b/tests/examples/C#/C#checker/TDengineDriver.cs @@ -0,0 +1,154 @@ +/* + * 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 . + */ + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace TDengineDriver +{ + enum TDengineDataType { + TSDB_DATA_TYPE_NULL = 0, // 1 bytes + TSDB_DATA_TYPE_BOOL = 1, // 1 bytes + TSDB_DATA_TYPE_TINYINT = 2, // 1 bytes + TSDB_DATA_TYPE_SMALLINT = 3, // 2 bytes + TSDB_DATA_TYPE_INT = 4, // 4 bytes + TSDB_DATA_TYPE_BIGINT = 5, // 8 bytes + TSDB_DATA_TYPE_FLOAT = 6, // 4 bytes + TSDB_DATA_TYPE_DOUBLE = 7, // 8 bytes + TSDB_DATA_TYPE_BINARY = 8, // string + TSDB_DATA_TYPE_TIMESTAMP = 9,// 8 bytes + TSDB_DATA_TYPE_NCHAR = 10 // unicode string + } + + enum TDengineInitOption + { + TSDB_OPTION_LOCALE = 0, + TSDB_OPTION_CHARSET = 1, + TSDB_OPTION_TIMEZONE = 2, + TDDB_OPTION_CONFIGDIR = 3, + TDDB_OPTION_SHELL_ACTIVITY_TIMER = 4 + } + + class TDengineMeta + { + public string name; + public short size; + public byte type; + public string TypeName() + { + switch ((TDengineDataType)type) + { + case TDengineDataType.TSDB_DATA_TYPE_BOOL: + return "BOOLEAN"; + case TDengineDataType.TSDB_DATA_TYPE_TINYINT: + return "BYTE"; + case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: + return "SHORT"; + case TDengineDataType.TSDB_DATA_TYPE_INT: + return "INT"; + case TDengineDataType.TSDB_DATA_TYPE_BIGINT: + return "LONG"; + case TDengineDataType.TSDB_DATA_TYPE_FLOAT: + return "FLOAT"; + case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: + return "DOUBLE"; + case TDengineDataType.TSDB_DATA_TYPE_BINARY: + return "STRING"; + case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: + return "TIMESTAMP"; + case TDengineDataType.TSDB_DATA_TYPE_NCHAR: + return "NCHAR"; + default: + return "undefine"; + } + } + } + + class TDengine + { + public const int TSDB_CODE_SUCCESS = 0; + + [DllImport("taos.dll", EntryPoint = "taos_init", CallingConvention = CallingConvention.Cdecl)] + static extern public void Init(); + + [DllImport("taos.dll", EntryPoint = "taos_cleanup", CallingConvention = CallingConvention.Cdecl)] + static extern public void Cleanup(); + + [DllImport("taos.dll", EntryPoint = "taos_options", CallingConvention = CallingConvention.Cdecl)] + static extern public void Options(int option, string value); + + [DllImport("taos.dll", EntryPoint = "taos_connect", CallingConvention = CallingConvention.Cdecl)] + static extern public IntPtr Connect(string ip, string user, string password, string db, short port); + + [DllImport("taos.dll", EntryPoint = "taos_errstr", CallingConvention = CallingConvention.Cdecl)] + static extern private IntPtr taos_errstr(IntPtr res); + static public string Error(IntPtr res) + { + IntPtr errPtr = taos_errstr(res); + return Marshal.PtrToStringAnsi(errPtr); + } + + [DllImport("taos.dll", EntryPoint = "taos_errno", CallingConvention = CallingConvention.Cdecl)] + static extern public int ErrorNo(IntPtr res); + + [DllImport("taos.dll", EntryPoint = "taos_query", CallingConvention = CallingConvention.Cdecl)] + static extern public IntPtr Query(IntPtr conn, string sqlstr); + + [DllImport("taos.dll", EntryPoint = "taos_affected_rows", CallingConvention = CallingConvention.Cdecl)] + static extern public int AffectRows(IntPtr res); + + [DllImport("taos.dll", EntryPoint = "taos_field_count", CallingConvention = CallingConvention.Cdecl)] + static extern public int FieldCount(IntPtr res); + + [DllImport("taos.dll", EntryPoint = "taos_fetch_fields", CallingConvention = CallingConvention.Cdecl)] + static extern private IntPtr taos_fetch_fields(IntPtr res); + static public List FetchFields(IntPtr res) + { + const int fieldSize = 68; + + List metas = new List(); + if (res == IntPtr.Zero) + { + return metas; + } + + int fieldCount = FieldCount(res); + IntPtr fieldsPtr = taos_fetch_fields(res); + + for (int i = 0; i < fieldCount; ++i) + { + int offset = i * fieldSize; + + TDengineMeta meta = new TDengineMeta(); + meta.name = Marshal.PtrToStringAnsi(fieldsPtr + offset); + meta.type = Marshal.ReadByte(fieldsPtr + offset + 65); + meta.size = Marshal.ReadInt16(fieldsPtr + offset + 66); + metas.Add(meta); + } + + return metas; + } + + [DllImport("taos.dll", EntryPoint = "taos_fetch_row", CallingConvention = CallingConvention.Cdecl)] + static extern public IntPtr FetchRows(IntPtr res); + + [DllImport("taos.dll", EntryPoint = "taos_free_result", CallingConvention = CallingConvention.Cdecl)] + static extern public IntPtr FreeResult(IntPtr res); + + [DllImport("taos.dll", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)] + static extern public int Close(IntPtr taos); + } +} \ No newline at end of file diff --git a/tests/examples/JDBC/JDBCDemo/.gitignore b/tests/examples/JDBC/JDBCDemo/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b79f223d17fd22185243066700aede395f6328fd --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/.gitignore @@ -0,0 +1,19 @@ +# custom +/out/ +/logs/ +*.jar + +# Created by .ignore support plugin (hsz.mobi) +.gitignore + +# Build Artifacts +.gradle/* +build/* +target/* +bin/* +dependency-reduced-pom.xml + +# Eclipse Project Files +.classpath +.project +.settings/* diff --git a/tests/examples/JDBC/JDBCDemo/pom.xml b/tests/examples/JDBC/JDBCDemo/pom.xml index 92d757edfdea304084b5971613da231db2b9daef..121a3b5cd63579b47fb166c7365090f06d05c0da 100644 --- a/tests/examples/JDBC/JDBCDemo/pom.xml +++ b/tests/examples/JDBC/JDBCDemo/pom.xml @@ -5,18 +5,11 @@ 4.0.0 com.taosdata.jdbc - jdbcdemo - 1.0-SNAPSHOT + jdbcChecker + SNAPSHOT jar - - - org.apache.maven.plugins - maven-plugins - 30 - - org.apache.maven.plugins maven-assembly-plugin @@ -30,7 +23,7 @@ - TSDBSyncSample + com.taosdata.example.JdbcChecker @@ -63,7 +56,18 @@ com.taosdata.jdbc taos-jdbcdriver - 2.0.4 + 2.0.8 + + + log4j + log4j + 1.2.17 + + + junit + junit + 4.13.1 + test diff --git a/tests/examples/JDBC/JDBCDemo/readme.md b/tests/examples/JDBC/JDBCDemo/readme.md index a91624a9e47a3015d88e2e9aa9f62cf8dd0672cc..9b8790adaddb20246232392dd323ec502102fa18 100644 --- a/tests/examples/JDBC/JDBCDemo/readme.md +++ b/tests/examples/JDBC/JDBCDemo/readme.md @@ -2,12 +2,14 @@ TDengine's JDBC demo project is organized in a Maven way so that users can easily compile, package and run the project. If you don't have Maven on your server, you may install it using
    sudo apt-get install maven
    -## Compile and Install JDBC Driver -TDengine's JDBC driver jar is not yet published to maven center repo, so we need to manually compile it and install it to the local Maven repository. This can be easily done with Maven. Go to source directory of the JDBC driver ``TDengine/src/connector/jdbc`` and execute -
    mvn clean package install
    +## Install TDengine Client +Make sure you have already installed a tdengine client on your current develop environment. +Download the tdengine package on our website: ``https://www.taosdata.com/cn/all-downloads/`` and install the client. ## Compile the Demo Code and Run It To compile the demo project, go to the source directory ``TDengine/tests/examples/JDBC/JDBCDemo`` and execute -
    mvn clean assembly:single package
    -The ``pom.xml`` is configured to package all the dependencies into one executable jar file. To run it, go to ``examples/JDBC/JDBCDemo/target`` and execute -
    java -jar jdbcdemo-1.0-SNAPSHOT-jar-with-dependencies.jar
    +
    mvn clean package assembly:single
    +The ``pom.xml`` is configured to package all the dependencies into one executable jar file. + +To run it, go to ``examples/JDBC/JDBCDemo/target`` and execute +
    java -jar jdbcChecker-SNAPSHOT-jar-with-dependencies.jar -host localhost
    \ No newline at end of file diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/TSDBSyncSample.java b/tests/examples/JDBC/JDBCDemo/src/main/java/TSDBSyncSample.java deleted file mode 100644 index c093b604da6dc6f815272f99d7fc786dab87928b..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/TSDBSyncSample.java +++ /dev/null @@ -1,205 +0,0 @@ -import java.sql.*; - -public class TSDBSyncSample { - private static final String JDBC_PROTOCAL = "jdbc:TAOS://"; - private static final String TSDB_DRIVER = "com.taosdata.jdbc.TSDBDriver"; - - private String host = "127.0.0.1"; - private String user = "root"; - private String password = "taosdata"; - private int port = 0; - private String jdbcUrl = ""; - - private String databaseName = "db"; - private String metricsName = "mt"; - private String tablePrefix = "t"; - - private int tablesCount = 1; - private int loopCount = 2; - private int batchSize = 10; - private long beginTimestamp = 1519833600000L; - - private long rowsInserted = 0; - - static { - try { - Class.forName(TSDB_DRIVER); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * @param args - */ - public static void main(String[] args) { - TSDBSyncSample tester = new TSDBSyncSample(); - tester.doReadArgument(args); - - System.out.println("---------------------------------------------------------------"); - System.out.println("Start testing..."); - System.out.println("---------------------------------------------------------------"); - - tester.doMakeJdbcUrl(); - tester.doCreateDbAndTable(); - tester.doExecuteInsert(); - tester.doExecuteQuery(); - - System.out.println("\n---------------------------------------------------------------"); - System.out.println("Stop testing..."); - System.out.println("---------------------------------------------------------------"); - } - - private void doReadArgument(String[] args) { - System.out.println("Arguments format: host tables loop batchs"); - if (args.length >= 1) { - this.host = args[0]; - } - - if (args.length >= 2) { - this.tablesCount = Integer.parseInt(args[1]); - } - - if (args.length >= 3) { - this.loopCount = Integer.parseInt(args[2]); - } - - if (args.length >= 4) { - this.batchSize = Integer.parseInt(args[3]); - } - } - - private void doMakeJdbcUrl() { - // jdbc:TSDB://127.0.0.1:0/dbname?user=root&password=taosdata - System.out.println("\nJDBC URL to use:"); - this.jdbcUrl = String.format("%s%s:%d/%s?user=%s&password=%s", JDBC_PROTOCAL, this.host, this.port, "", - this.user, this.password); - System.out.println(this.jdbcUrl); - } - - private void doCreateDbAndTable() { - System.out.println("\n---------------------------------------------------------------"); - System.out.println("Start creating databases and tables..."); - String sql = ""; - try (Connection conn = DriverManager.getConnection(jdbcUrl); - Statement stmt = conn.createStatement()){ - - sql = "create database if not exists " + this.databaseName; - stmt.executeUpdate(sql); - System.out.printf("Successfully executed: %s\n", sql); - - sql = "use " + this.databaseName; - stmt.executeUpdate(sql); - System.out.printf("Successfully executed: %s\n", sql); - - sql = "create table if not exists " + this.metricsName + " (ts timestamp, v1 int) tags(t1 int)"; - stmt.executeUpdate(sql); - System.out.printf("Successfully executed: %s\n", sql); - - for (int i = 0; i < this.tablesCount; i++) { - sql = String.format("create table if not exists %s%d using %s tags(%d)", this.tablePrefix, i, - this.metricsName, i); - stmt.executeUpdate(sql); - System.out.printf("Successfully executed: %s\n", sql); - } - } catch (SQLException e) { - e.printStackTrace(); - System.out.printf("Failed to execute SQL: %s\n", sql); - System.exit(4); - } catch (Exception e) { - e.printStackTrace(); - System.exit(4); - } - System.out.println("Successfully created databases and tables"); - } - - public void doExecuteInsert() { - System.out.println("\n---------------------------------------------------------------"); - System.out.println("Start inserting data..."); - int start = (int) System.currentTimeMillis(); - StringBuilder sql = new StringBuilder(""); - try (Connection conn = DriverManager.getConnection(jdbcUrl); - Statement stmt = conn.createStatement()){ - stmt.executeUpdate("use " + databaseName); - for (int loop = 0; loop < this.loopCount; loop++) { - for (int table = 0; table < this.tablesCount; ++table) { - sql = new StringBuilder("insert into "); - sql.append(this.tablePrefix).append(table).append(" values"); - for (int batch = 0; batch < this.batchSize; ++batch) { - int rows = loop * this.batchSize + batch; - sql.append("(").append(this.beginTimestamp + rows).append(",").append(rows).append(")"); - } - int affectRows = stmt.executeUpdate(sql.toString()); - this.rowsInserted += affectRows; - } - } - } catch (SQLException e) { - e.printStackTrace(); - System.out.printf("Failed to execute SQL: %s\n", sql.toString()); - System.exit(4); - } catch (Exception e) { - e.printStackTrace(); - System.exit(4); - } - int end = (int) System.currentTimeMillis(); - System.out.println("Inserting completed!"); - System.out.printf("Total %d rows inserted, %d rows failed, time spend %d seconds.\n", this.rowsInserted, - this.loopCount * this.batchSize - this.rowsInserted, (end - start) / 1000); - } - - public void doExecuteQuery() { - System.out.println("\n---------------------------------------------------------------"); - System.out.println("Starting querying data..."); - ResultSet resSet = null; - StringBuilder sql = new StringBuilder(""); - StringBuilder resRow = new StringBuilder(""); - try (Connection conn = DriverManager.getConnection(jdbcUrl); - Statement stmt = conn.createStatement()){ - stmt.executeUpdate("use " + databaseName); - for (int i = 0; i < this.tablesCount; ++i) { - sql = new StringBuilder("select * from ").append(this.tablePrefix).append(i); - - resSet = stmt.executeQuery(sql.toString()); - if (resSet == null) { - System.out.println(sql + " failed"); - System.exit(4); - } - - ResultSetMetaData metaData = resSet.getMetaData(); - System.out.println("Retrieve metadata of " + tablePrefix + i); - for (int column = 1; column <= metaData.getColumnCount(); ++column) { - System.out.printf("Column%d: name = %s, type = %d, type name = %s, display size = %d\n", column, metaData.getColumnName(column), metaData.getColumnType(column), - metaData.getColumnTypeName(column), metaData.getColumnDisplaySize(column)); - } - int rows = 0; - System.out.println("Retrieve data of " + tablePrefix + i); - while (resSet.next()) { - resRow = new StringBuilder(); - for (int col = 1; col <= metaData.getColumnCount(); col++) { - resRow.append(metaData.getColumnName(col)).append("=").append(resSet.getObject(col)) - .append(" "); - } - System.out.println(resRow.toString()); - rows++; - } - - try { - if (resSet != null) - resSet.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - System.out.printf("Successfully executed query: %s;\nTotal rows returned: %d\n", sql.toString(), rows); - } - } catch (SQLException e) { - e.printStackTrace(); - System.out.printf("Failed to execute query: %s\n", sql.toString()); - System.exit(4); - } catch (Exception e) { - e.printStackTrace(); - System.exit(4); - } - System.out.println("Query completed!"); - } - -} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCConnectorChecker.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcChecker.java similarity index 98% rename from tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCConnectorChecker.java rename to tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcChecker.java index 1e801bc65894ef437ee41d692f9ef725b4f639ef..4be71c52214c348ed7b41c3e763de0d908514907 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCConnectorChecker.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcChecker.java @@ -5,13 +5,12 @@ import com.taosdata.jdbc.TSDBDriver; import java.sql.*; import java.util.Properties; -public class JDBCConnectorChecker { +public class JdbcChecker { private static String host; private static String dbName = "test"; private static String tbName = "weather"; private Connection connection; - /** * get connection **/ @@ -121,6 +120,7 @@ public class JDBCConnectorChecker { printSql(sql, execute, (end - start)); } catch (SQLException e) { e.printStackTrace(); + } } @@ -158,7 +158,7 @@ public class JDBCConnectorChecker { return; } - JDBCConnectorChecker checker = new JDBCConnectorChecker(); + JdbcChecker checker = new JdbcChecker(); checker.init(); checker.createDatabase(); checker.useDatabase(); @@ -170,5 +170,4 @@ public class JDBCConnectorChecker { checker.close(); } - } diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java new file mode 100644 index 0000000000000000000000000000000000000000..259985ec9f4708b9317575fd97919adcc82d7161 --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java @@ -0,0 +1,357 @@ +package com.taosdata.example.jdbcTaosdemo; + +import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig; +import com.taosdata.example.jdbcTaosdemo.task.CreateTableTask; +import com.taosdata.example.jdbcTaosdemo.task.InsertTableDatetimeTask; +import com.taosdata.example.jdbcTaosdemo.task.InsertTableTask; +import com.taosdata.example.jdbcTaosdemo.utils.ConnectionFactory; +import com.taosdata.example.jdbcTaosdemo.utils.SqlSpeller; +import com.taosdata.example.jdbcTaosdemo.utils.TimeStampUtil; +import org.apache.log4j.Logger; + +import java.sql.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class JdbcTaosdemo { + + private static Logger logger = Logger.getLogger(JdbcTaosdemo.class); + private final JdbcTaosdemoConfig config; + private Connection connection; + + public JdbcTaosdemo(JdbcTaosdemoConfig config) { + this.config = config; + } + + public static void main(String[] args) { + // parse config from args + JdbcTaosdemoConfig config = new JdbcTaosdemoConfig(args); + + boolean isHelp = Arrays.asList(args).contains("--help"); + if (isHelp) { + JdbcTaosdemoConfig.printHelp(); + return; + } + if (config.getHost() == null) { + JdbcTaosdemoConfig.printHelp(); + return; + } + + JdbcTaosdemo taosdemo = new JdbcTaosdemo(config); + // establish connection + taosdemo.init(); + // drop database + taosdemo.dropDatabase(); + // create database + taosdemo.createDatabase(); + // use db + taosdemo.useDatabase(); + // create super table + taosdemo.createSuperTable(); + // create sub tables + taosdemo.createTableMultiThreads(); + + boolean infinite = Arrays.asList(args).contains("--infinite"); + if (infinite) { + logger.info("!!! Infinite Insert Mode Started. !!!"); + taosdemo.insertInfinite(); + } else { + // insert into table + taosdemo.insertMultiThreads(); + // select from sub table + taosdemo.selectFromTableLimit(); + taosdemo.selectCountFromTable(); + taosdemo.selectAvgMinMaxFromTable(); + // select last from + taosdemo.selectLastFromTable(); + // select from super table + taosdemo.selectFromSuperTableLimit(); + taosdemo.selectCountFromSuperTable(); + taosdemo.selectAvgMinMaxFromSuperTable(); + //select avg ,max from stb where tag + taosdemo.selectAvgMinMaxFromSuperTableWhereTag(); + //select last from stb where location = '' + taosdemo.selectLastFromSuperTableWhere(); + // select group by + taosdemo.selectGroupBy(); + // select like + taosdemo.selectLike(); + // select where ts >= ts<= + taosdemo.selectLastOneHour(); + taosdemo.selectLastOneDay(); + taosdemo.selectLastOneWeek(); + taosdemo.selectLastOneMonth(); + taosdemo.selectLastOneYear(); + + // drop super table + if (config.isDeleteTable()) + taosdemo.dropSuperTable(); + taosdemo.close(); + } + } + + + /** + * establish the connection + */ + private void init() { + try { + Class.forName("com.taosdata.jdbc.TSDBDriver"); + connection = ConnectionFactory.build(config); + if (connection != null) + logger.info("[ OK ] Connection established."); + } catch (ClassNotFoundException | SQLException e) { + logger.error(e.getMessage()); + throw new RuntimeException("connection failed: " + config.getHost()); + } + } + + /** + * create database + */ + private void createDatabase() { + String sql = SqlSpeller.createDatabaseSQL(config.getDbName(), config.getKeep(), config.getDays()); + execute(sql); + } + + /** + * drop database + */ + private void dropDatabase() { + String sql = SqlSpeller.dropDatabaseSQL(config.getDbName()); + execute(sql); + } + + /** + * use database + */ + private void useDatabase() { + String sql = SqlSpeller.useDatabaseSQL(config.getDbName()); + execute(sql); + } + + /** + * create super table + */ + private void createSuperTable() { + String sql = SqlSpeller.createSuperTableSQL(config.getStbName()); + execute(sql); + } + + /** + * create table use super table with multi threads + */ + private void createTableMultiThreads() { + try { + final int tableSize = config.getNumberOfTable() / config.getNumberOfThreads(); + List threads = new ArrayList<>(); + for (int i = 0; i < config.getNumberOfThreads(); i++) { + Thread thread = new Thread(new CreateTableTask(config, i * tableSize, tableSize), "Thread-" + i); + threads.add(thread); + thread.start(); + } + for (Thread thread : threads) { + thread.join(); + } + logger.info("<<< Multi Threads create table finished."); + } catch (InterruptedException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } + + /** + * insert data infinitely + */ + private void insertInfinite() { + try { + final long startDatetime = TimeStampUtil.datetimeToLong("2005-01-01 00:00:00.000"); + final long finishDatetime = TimeStampUtil.datetimeToLong("2030-01-01 00:00:00.000"); + + final int tableSize = config.getNumberOfTable() / config.getNumberOfThreads(); + List threads = new ArrayList<>(); + for (int i = 0; i < config.getNumberOfThreads(); i++) { + Thread thread = new Thread(new InsertTableDatetimeTask(config, i * tableSize, tableSize, startDatetime, finishDatetime), "Thread-" + i); + threads.add(thread); + thread.start(); + } + for (Thread thread : threads) { + thread.join(); + } + logger.info("<<< Multi Threads insert table finished."); + } catch (InterruptedException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } + + private void insertMultiThreads() { + try { + final int tableSize = config.getNumberOfTable() / config.getNumberOfThreads(); + final int numberOfRecordsPerTable = config.getNumberOfRecordsPerTable(); + List threads = new ArrayList<>(); + for (int i = 0; i < config.getNumberOfThreads(); i++) { + Thread thread = new Thread(new InsertTableTask(config, i * tableSize, tableSize, numberOfRecordsPerTable), "Thread-" + i); + threads.add(thread); + thread.start(); + } + for (Thread thread : threads) { + thread.join(); + } + logger.info("<<< Multi Threads insert table finished."); + } catch (InterruptedException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } + + private void selectFromTableLimit() { + String sql = SqlSpeller.selectFromTableLimitSQL(config.getDbName(), config.getTbPrefix(), 1, 10, 0); + executeQuery(sql); + } + + private void selectCountFromTable() { + String sql = SqlSpeller.selectCountFromTableSQL(config.getDbName(), config.getTbPrefix(), 1); + executeQuery(sql); + } + + private void selectAvgMinMaxFromTable() { + String sql = SqlSpeller.selectAvgMinMaxFromTableSQL("current", config.getDbName(), config.getTbPrefix(), 1); + executeQuery(sql); + } + + private void selectLastFromTable() { + String sql = SqlSpeller.selectLastFromTableSQL(config.getDbName(), config.getTbPrefix(), 1); + executeQuery(sql); + } + + private void selectFromSuperTableLimit() { + String sql = SqlSpeller.selectFromSuperTableLimitSQL(config.getDbName(), config.getStbName(), 10, 0); + executeQuery(sql); + } + + private void selectCountFromSuperTable() { + String sql = SqlSpeller.selectCountFromSuperTableSQL(config.getDbName(), config.getStbName()); + executeQuery(sql); + } + + private void selectAvgMinMaxFromSuperTable() { + String sql = SqlSpeller.selectAvgMinMaxFromSuperTableSQL("current", config.getDbName(), config.getStbName()); + executeQuery(sql); + } + + private void selectAvgMinMaxFromSuperTableWhereTag() { + String sql = SqlSpeller.selectAvgMinMaxFromSuperTableWhere("current", config.getDbName(), config.getStbName()); + executeQuery(sql); + } + + private void selectLastFromSuperTableWhere() { + String sql = SqlSpeller.selectLastFromSuperTableWhere("current", config.getDbName(), config.getStbName()); + executeQuery(sql); + } + + private void selectGroupBy() { + String sql = SqlSpeller.selectGroupBy("current", config.getDbName(), config.getStbName()); + executeQuery(sql); + } + + private void selectLike() { + String sql = SqlSpeller.selectLike(config.getDbName(), config.getStbName()); + executeQuery(sql); + } + + private void selectLastOneHour() { + String sql = SqlSpeller.selectLastOneHour(config.getDbName(), config.getStbName()); + executeQuery(sql); + } + + private void selectLastOneDay() { + String sql = SqlSpeller.selectLastOneDay(config.getDbName(), config.getStbName()); + executeQuery(sql); + } + + private void selectLastOneWeek() { + String sql = SqlSpeller.selectLastOneWeek(config.getDbName(), config.getStbName()); + executeQuery(sql); + } + + private void selectLastOneMonth() { + String sql = SqlSpeller.selectLastOneMonth(config.getDbName(), config.getStbName()); + executeQuery(sql); + } + + private void selectLastOneYear() { + String sql = SqlSpeller.selectLastOneYear(config.getDbName(), config.getStbName()); + executeQuery(sql); + } + + + private void close() { + try { + if (connection != null) { + this.connection.close(); + logger.info("connection closed."); + } + } catch (SQLException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } + + /** + * drop super table + */ + private void dropSuperTable() { + String sql = SqlSpeller.dropSuperTableSQL(config.getDbName(), config.getStbName()); + execute(sql); + } + + /** + * execute sql, use this method when sql is create, alter, drop.. + */ + private void execute(String sql) { + try (Statement statement = connection.createStatement()) { + long start = System.currentTimeMillis(); + boolean execute = statement.execute(sql); + long end = System.currentTimeMillis(); + printSql(sql, execute, (end - start)); + } catch (SQLException e) { + logger.error("ERROR execute SQL ===> " + sql); + logger.error(e.getMessage()); + e.printStackTrace(); + } + } + + private static void printSql(String sql, boolean succeed, long cost) { + System.out.println("[ " + (succeed ? "OK" : "ERROR!") + " ] time cost: " + cost + " ms, execute statement ====> " + sql); + } + + private void executeQuery(String sql) { + try (Statement statement = connection.createStatement()) { + long start = System.currentTimeMillis(); + ResultSet resultSet = statement.executeQuery(sql); + long end = System.currentTimeMillis(); + printSql(sql, true, (end - start)); + printResult(resultSet); + } catch (SQLException e) { + logger.error("ERROR execute SQL ===> " + sql); + logger.error(e.getMessage()); + e.printStackTrace(); + } + } + + private static void printResult(ResultSet resultSet) throws SQLException { + ResultSetMetaData metaData = resultSet.getMetaData(); + while (resultSet.next()) { + StringBuilder sb = new StringBuilder(); + for (int i = 1; i <= metaData.getColumnCount(); i++) { + String columnLabel = metaData.getColumnLabel(i); + String value = resultSet.getString(i); + sb.append(columnLabel + ": " + value + "\t"); + } + System.out.println(sb.toString()); + } + } + +} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..82613037dbccd3be1f2c8a85a2f25e7a25ffad01 --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java @@ -0,0 +1,153 @@ +package com.taosdata.example.jdbcTaosdemo.domain; + +public final class JdbcTaosdemoConfig { + + //The host to connect to TDengine. Must insert one + private String host; + //The TCP/IP port number to use for the connection. Default is 6030. + private int port = 6030; + //The TDengine user name to use when connecting to the server. Default is 'root' + private String user = "root"; + //The password to use when connecting to the server. Default is 'taosdata' + private String password = "taosdata"; + + //Destination database. Default is 'test' + private String dbName = "test"; + //keep + private int keep = 3650; + //days + private int days = 10; + + //Super table Name. Default is 'meters' + private String stbName = "meters"; + //Table name prefix. Default is 'd' + private String tbPrefix = "d"; + //The number of tables. Default is 10. + private int numberOfTable = 10; + //The number of records per table. Default is 2 + private int numberOfRecordsPerTable = 2; + //The number of records per request. Default is 100 + private int numberOfRecordsPerRequest = 100; + + //The number of threads. Default is 1. + private int numberOfThreads = 1; + //Delete data. Default is false + private boolean deleteTable = false; + + public static void printHelp() { + System.out.println("Usage: java -jar JdbcTaosDemo.jar [OPTION...]"); + System.out.println("-h host The host to connect to TDengine. you must input one"); + System.out.println("-p port The TCP/IP port number to use for the connection. Default is 6030"); + System.out.println("-u user The TDengine user name to use when connecting to the server. Default is 'root'"); + System.out.println("-P password The password to use when connecting to the server.Default is 'taosdata'"); + System.out.println("-d database Destination database. Default is 'test'"); + System.out.println("-m tablePrefix Table prefix name. Default is 'd'"); + System.out.println("-t num_of_tables The number of tables. Default is 10"); + System.out.println("-n num_of_records_per_table The number of records per table. Default is 2"); + System.out.println("-r num_of_records_per_req The number of records per request. Default is 100"); + System.out.println("-T num_of_threads The number of threads. Default is 1"); + System.out.println("-D delete table Delete data methods. Default is false"); + System.out.println("--help Give this help list"); +// System.out.println("--infinite infinite insert mode"); + } + + /** + * parse args from command line + * + * @param args command line args + * @return JdbcTaosdemoConfig + */ + public JdbcTaosdemoConfig(String[] args) { + for (int i = 0; i < args.length; i++) { + if ("-h".equals(args[i]) && i < args.length - 1) { + host = args[++i]; + } + if ("-p".equals(args[i]) && i < args.length - 1) { + port = Integer.parseInt(args[++i]); + } + if ("-u".equals(args[i]) && i < args.length - 1) { + user = args[++i]; + } + if ("-P".equals(args[i]) && i < args.length - 1) { + password = args[++i]; + } + if ("-d".equals(args[i]) && i < args.length - 1) { + dbName = args[++i]; + } + if ("-m".equals(args[i]) && i < args.length - 1) { + tbPrefix = args[++i]; + } + if ("-t".equals(args[i]) && i < args.length - 1) { + numberOfTable = Integer.parseInt(args[++i]); + } + if ("-n".equals(args[i]) && i < args.length - 1) { + numberOfRecordsPerTable = Integer.parseInt(args[++i]); + } + if ("-r".equals(args[i]) && i < args.length - 1) { + numberOfRecordsPerRequest = Integer.parseInt(args[++i]); + } + if ("-T".equals(args[i]) && i < args.length - 1) { + numberOfThreads = Integer.parseInt(args[++i]); + } + if ("-D".equals(args[i]) && i < args.length - 1) { + deleteTable = Boolean.parseBoolean(args[++i]); + } + } + } + + public String getHost() { + return host; + } + + public int getPort() { + return port; + } + + public String getUser() { + return user; + } + + public String getPassword() { + return password; + } + + public String getDbName() { + return dbName; + } + + public int getKeep() { + return keep; + } + + public int getDays() { + return days; + } + + public String getStbName() { + return stbName; + } + + public String getTbPrefix() { + return tbPrefix; + } + + public int getNumberOfTable() { + return numberOfTable; + } + + public int getNumberOfRecordsPerTable() { + return numberOfRecordsPerTable; + } + + public int getNumberOfThreads() { + return numberOfThreads; + } + + public boolean isDeleteTable() { + return deleteTable; + } + + public int getNumberOfRecordsPerRequest() { + return numberOfRecordsPerRequest; + } +} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/CreateTableTask.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/CreateTableTask.java new file mode 100644 index 0000000000000000000000000000000000000000..1da2c8647efe0e9204f1a591ba9431a489c91cb0 --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/CreateTableTask.java @@ -0,0 +1,42 @@ +package com.taosdata.example.jdbcTaosdemo.task; + +import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig; +import com.taosdata.example.jdbcTaosdemo.utils.ConnectionFactory; +import com.taosdata.example.jdbcTaosdemo.utils.SqlSpeller; +import org.apache.log4j.Logger; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +public class CreateTableTask implements Runnable { + + private static Logger logger = Logger.getLogger(CreateTableTask.class); + private final JdbcTaosdemoConfig config; + private final int startIndex; + private final int tableNumber; + + public CreateTableTask(JdbcTaosdemoConfig config, int startIndex, int tableNumber) { + this.config = config; + this.startIndex = startIndex; + this.tableNumber = tableNumber; + } + + @Override + public void run() { + try { + Connection connection = ConnectionFactory.build(config); + for (int i = startIndex; i < startIndex + tableNumber; i++) { + Statement statement = connection.createStatement(); + String sql = SqlSpeller.createTableSQL(i + 1, config.getDbName(), config.getStbName()); + statement.execute(sql); + statement.close(); + logger.info(">>> " + sql); + } + connection.close(); + } catch (SQLException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableDatetimeTask.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableDatetimeTask.java new file mode 100644 index 0000000000000000000000000000000000000000..4f60c25646573223a9cbfd820c8eb37e4f6f6c8c --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableDatetimeTask.java @@ -0,0 +1,49 @@ +package com.taosdata.example.jdbcTaosdemo.task; + +import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig; +import com.taosdata.example.jdbcTaosdemo.utils.ConnectionFactory; +import com.taosdata.example.jdbcTaosdemo.utils.SqlSpeller; +import org.apache.log4j.Logger; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +public class InsertTableDatetimeTask implements Runnable { + private static Logger logger = Logger.getLogger(InsertTableDatetimeTask.class); + + private final JdbcTaosdemoConfig config; + private final int startTableIndex; + private final int tableNumber; + private final long startDatetime; + private final long finishedDatetime; + + public InsertTableDatetimeTask(JdbcTaosdemoConfig config, int startTableIndex, int tableNumber, long startDatetime, long finishedDatetime) { + this.config = config; + this.startTableIndex = startTableIndex; + this.tableNumber = tableNumber; + this.startDatetime = startDatetime; + this.finishedDatetime = finishedDatetime; + } + + @Override + public void run() { + try { + Connection connection = ConnectionFactory.build(config); + int valuesCount = config.getNumberOfRecordsPerRequest(); + for (long ts = startDatetime; ts < finishedDatetime; ts += valuesCount) { + for (int i = startTableIndex; i < startTableIndex + tableNumber; i++) { + String sql = SqlSpeller.insertBatchSizeRowsSQL(config.getDbName(), config.getTbPrefix(), i + 1, ts, valuesCount); + Statement statement = connection.createStatement(); + statement.execute(sql); + statement.close(); + logger.info(Thread.currentThread().getName() + ">>> " + sql); + } + } + connection.close(); + } catch (SQLException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java new file mode 100644 index 0000000000000000000000000000000000000000..a35628bb58c6630d92bd2b6aebb09f9912e57536 --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java @@ -0,0 +1,57 @@ +package com.taosdata.example.jdbcTaosdemo.task; + +import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig; +import com.taosdata.example.jdbcTaosdemo.utils.ConnectionFactory; +import com.taosdata.example.jdbcTaosdemo.utils.SqlSpeller; +import org.apache.log4j.Logger; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; +import java.time.Duration; +import java.time.Instant; +import java.time.temporal.ChronoUnit; + +public class InsertTableTask implements Runnable { + private static final Logger logger = Logger.getLogger(InsertTableTask.class); + + private final JdbcTaosdemoConfig config; + private final int startTbIndex; + private final int tableNumber; + private final int recordsNumberPerTable; + + public InsertTableTask(JdbcTaosdemoConfig config, int startTbIndex, int tableNumber, int recordsNumberPerTable) { + this.config = config; + this.startTbIndex = startTbIndex; + this.tableNumber = tableNumber; + this.recordsNumberPerTable = recordsNumberPerTable; + } + + @Override + public void run() { + try { + Connection connection = ConnectionFactory.build(config); + int keep = config.getKeep(); + Instant end = Instant.now(); + Instant start = end.minus(Duration.ofDays(keep - 1)); + long timeGap = ChronoUnit.MILLIS.between(start, end) / (recordsNumberPerTable - 1); + + // iterate insert + for (int j = 0; j < recordsNumberPerTable; j++) { + long ts = start.toEpochMilli() + (j * timeGap); + // insert data into echo table + for (int i = startTbIndex; i < startTbIndex + tableNumber; i++) { + String sql = SqlSpeller.insertOneRowSQL(config.getDbName(), config.getTbPrefix(), i + 1, ts); + logger.info(Thread.currentThread().getName() + ">>> " + sql); + Statement statement = connection.createStatement(); + statement.execute(sql); + statement.close(); + } + } + connection.close(); + } catch (SQLException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/ConnectionFactory.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/ConnectionFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..52691f4de722db2eb17e7061e09ff0e59a390077 --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/ConnectionFactory.java @@ -0,0 +1,32 @@ +package com.taosdata.example.jdbcTaosdemo.utils; + +import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig; +import com.taosdata.jdbc.TSDBDriver; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.Properties; + +public class ConnectionFactory { + + public static Connection build(JdbcTaosdemoConfig config) throws SQLException { + return build(config.getHost(), config.getPort(), config.getDbName(), config.getUser(), config.getPassword()); + } + + public static Connection build(String host, int port, String dbName) throws SQLException { + return build(host, port, dbName, "root", "taosdata"); + } + + private static Connection build(String host, int port, String dbName, String user, String password) throws SQLException { + Properties properties = new Properties(); + properties.setProperty(TSDBDriver.PROPERTY_KEY_USER, user); + properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD, password); + properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); + return DriverManager.getConnection("jdbc:TAOS://" + host + ":" + port + "/" + dbName + "", properties); + } + + +} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java new file mode 100644 index 0000000000000000000000000000000000000000..b4a79e9eba47cc947d822b645d0ae1f9952f08f0 --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java @@ -0,0 +1,126 @@ +package com.taosdata.example.jdbcTaosdemo.utils; + +import java.util.Random; + +public class SqlSpeller { + private static final Random random = new Random(System.currentTimeMillis()); + private static final String[] locations = { + "Beijing", "Shanghai", "Guangzhou", "Shenzhen", + "HangZhou", "Tianjin", "Wuhan", "Changsha", "Nanjing", "Xian" + }; + + public static String createDatabaseSQL(String dbName, int keep, int days) { + return "create database if not exists " + dbName + " keep " + keep + " days " + days; + } + + public static String dropDatabaseSQL(String dbName) { + return "drop database if exists " + dbName; + } + + public static String useDatabaseSQL(String dbName) { + return "use " + dbName; + } + + public static String createSuperTableSQL(String superTableName) { + return "create table if not exists " + superTableName + "(ts timestamp, current float, voltage int, phase float) tags(location binary(64), groupId int)"; + } + + public static String dropSuperTableSQL(String dbName, String superTableName) { + return "drop table if exists " + dbName + "." + superTableName; + } + + public static String createTableSQL(int tableIndex, String dbName, String superTableName) { + String location = locations[random.nextInt(locations.length)]; + return "create table d" + tableIndex + " using " + dbName + "." + superTableName + " tags('" + location + "'," + tableIndex + ")"; + } + + public static String insertOneRowSQL(String dbName, String tbPrefix, int tableIndex, long ts) { + float current = 10 + random.nextFloat(); + int voltage = 200 + random.nextInt(20); + float phase = random.nextFloat(); + String sql = "insert into " + dbName + "." + tbPrefix + "" + tableIndex + " " + "values(" + ts + ", " + current + ", " + voltage + ", " + phase + ")"; + return sql; + } + + public static String insertBatchSizeRowsSQL(String dbName, String tbPrefix, int tbIndex, long ts, int valuesCount) { + float current = 10 + random.nextFloat(); + int voltage = 200 + random.nextInt(20); + float phase = random.nextFloat(); + StringBuilder sb = new StringBuilder(); + sb.append("insert into " + dbName + "." + tbPrefix + "" + tbIndex + " " + "values"); + for (int i = 0; i < valuesCount; i++) { + sb.append("(" + (ts + i) + ", " + current + ", " + voltage + ", " + phase + ") "); + } + return sb.toString(); + } + + public static String selectFromTableLimitSQL(String dbName, String tbPrefix, int tbIndex, int limit, int offset) { + return "select * from " + dbName + "." + tbPrefix + "" + tbIndex + " limit " + limit + " offset " + offset; + } + + public static String selectCountFromTableSQL(String dbName, String tbPrefix, int tbIndex) { + return "select count(*) from " + dbName + "." + tbPrefix + "" + tbIndex; + } + + public static String selectAvgMinMaxFromTableSQL(String field, String dbName, String tbPrefix, int tbIndex) { + return "select avg(" + field + "),min(" + field + "),max(" + field + ") from " + dbName + "." + tbPrefix + "" + tbIndex; + } + + public static String selectFromSuperTableLimitSQL(String dbName, String stbName, int limit, int offset) { + return "select * from " + dbName + "." + stbName + " limit " + limit + " offset " + offset; + } + + public static String selectCountFromSuperTableSQL(String dbName, String stableName) { + return "select count(*) from " + dbName + "." + stableName; + } + + public static String selectAvgMinMaxFromSuperTableSQL(String field, String dbName, String stbName) { + return "select avg(" + field + "),min(" + field + "),max(" + field + ") from " + dbName + "." + stbName + ""; + } + + public static String selectLastFromTableSQL(String dbName, String tbPrefix, int tbIndex) { + return "select last(*) from " + dbName + "." + tbPrefix + "" + tbIndex; + } + + //select avg ,max from stb where tag + public static String selectAvgMinMaxFromSuperTableWhere(String field, String dbName, String stbName) { + return "select avg(" + field + "),min(" + field + "),max(" + field + ") from " + dbName + "." + stbName + " where location = '" + locations[random.nextInt(locations.length)] + "'"; + } + + //select last from stb where + public static String selectLastFromSuperTableWhere(String field, String dbName, String stbName) { + return "select last(" + field + ") from " + dbName + "." + stbName + " where location = '" + locations[random.nextInt(locations.length)] + "'"; + } + + public static String selectGroupBy(String field, String dbName, String stbName) { + return "select avg(" + field + ") from " + dbName + "." + stbName + " group by location"; + } + + public static String selectLike(String dbName, String stbName) { + return "select * from " + dbName + "." + stbName + " where location like 'S%'"; + } + + public static String selectLastOneHour(String dbName, String stbName) { + return "select * from " + dbName + "." + stbName + " where ts >= now - 1h"; + } + + public static String selectLastOneDay(String dbName, String stbName) { + return "select * from " + dbName + "." + stbName + " where ts >= now - 1d"; + } + + public static String selectLastOneWeek(String dbName, String stbName) { + return "select * from " + dbName + "." + stbName + " where ts >= now - 1w"; + } + + public static String selectLastOneMonth(String dbName, String stbName) { + return "select * from " + dbName + "." + stbName + " where ts >= now - 1n"; + } + + public static String selectLastOneYear(String dbName, String stbName) { + return "select * from " + dbName + "." + stbName + " where ts >= now - 1y"; + } + + // select group by + // select like + // select ts >= ts<= +} \ No newline at end of file diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtil.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..0a345afdd1e45123d889d7ee198cf8efd201176b --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtil.java @@ -0,0 +1,37 @@ +package com.taosdata.example.jdbcTaosdemo.utils; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.Duration; +import java.time.Instant; +import java.util.Date; + +public class TimeStampUtil { + private static final String datetimeFormat = "yyyy-MM-dd HH:mm:ss.SSS"; + + public static long datetimeToLong(String dateTime) { + SimpleDateFormat sdf = new SimpleDateFormat(datetimeFormat); + try { + return sdf.parse(dateTime).getTime(); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + + public static String longToDatetime(long time) { + SimpleDateFormat sdf = new SimpleDateFormat(datetimeFormat); + return sdf.format(new Date(time)); + } + + public static void main(String[] args) throws ParseException { + +// Instant now = Instant.now(); +// System.out.println(now); +// Instant years20Ago = now.minus(Duration.ofDays(365)); +// System.out.println(years20Ago); + + + } + + +} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties b/tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties new file mode 100644 index 0000000000000000000000000000000000000000..b445e5f52edf1a2b19c35c1be187716d17cdd7b1 --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties @@ -0,0 +1,21 @@ +### 设置### +log4j.rootLogger=debug,stdout,DebugLog,ErrorLog +### 输出信息到控制抬 ### +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n +### 输出DEBUG 级别以上的日志到=logs/error.log ### +log4j.appender.DebugLog=org.apache.log4j.DailyRollingFileAppender +log4j.appender.DebugLog.File=logs/debug.log +log4j.appender.DebugLog.Append=true +log4j.appender.DebugLog.Threshold=DEBUG +log4j.appender.DebugLog.layout=org.apache.log4j.PatternLayout +log4j.appender.DebugLog.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n +### 输出ERROR 级别以上的日志到=logs/error.log ### +log4j.appender.ErrorLog=org.apache.log4j.DailyRollingFileAppender +log4j.appender.ErrorLog.File=logs/error.log +log4j.appender.ErrorLog.Append=true +log4j.appender.ErrorLog.Threshold=ERROR +log4j.appender.ErrorLog.layout=org.apache.log4j.PatternLayout +log4j.appender.ErrorLog.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n \ No newline at end of file diff --git a/tests/examples/JDBC/JDBCDemo/src/test/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtilTest.java b/tests/examples/JDBC/JDBCDemo/src/test/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtilTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f370b2ef6eaa708b061ebf4a7f58f3d31f78f999 --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/test/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtilTest.java @@ -0,0 +1,52 @@ +package com.taosdata.example.jdbcTaosdemo.utils; + +import org.junit.Test; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.Duration; +import java.time.Instant; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.util.Date; + +import static org.junit.Assert.*; + +public class TimeStampUtilTest { + + @Test + public void datetimeToLong() { + final String startTime = "2005-01-01 00:00:00.000"; + long start = TimeStampUtil.datetimeToLong(startTime); + assertEquals(1104508800000l, start); + } + + @Test + public void longToDatetime() { + String datetime = TimeStampUtil.longToDatetime(1510000000000L); + assertEquals("2017-11-07 04:26:40.000", datetime); + } + + @Test + public void getStartDateTime() { + int keep = 365; + + Instant end = Instant.now(); + System.out.println(end.toString()); + System.out.println(end.toEpochMilli()); + + Instant start = end.minus(Duration.ofDays(keep)); + System.out.println(start.toString()); + System.out.println(start.toEpochMilli()); + + int numberOfRecordsPerTable = 10; + long timeGap = ChronoUnit.MILLIS.between(start, end) / (numberOfRecordsPerTable - 1); + System.out.println(timeGap); + + System.out.println("==========================="); + for (int i = 0; i < numberOfRecordsPerTable; i++) { + long ts = start.toEpochMilli() + (i * timeGap); + System.out.println(i + " : " + ts); + } + } +} \ No newline at end of file diff --git a/tests/examples/JDBC/calciteDemo/pom.xml b/tests/examples/JDBC/calciteDemo/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..a7d47837d9ba407f3959a00d522a9cd26b5622db --- /dev/null +++ b/tests/examples/JDBC/calciteDemo/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + com.taosdata.example.calcite + calciteDemo + 1.0-SNAPSHOT + + + + + org.slf4j + slf4j-simple + 1.7.25 + compile + + + + org.apache.calcite + calcite-core + 1.23.0 + + + org.apache.commons + commons-dbcp2 + 2.7.0 + + + org.apache.calcite.avatica + avatica-core + 1.17.0 + + + + + mysql + mysql-connector-java + 5.1.47 + + + + + com.taosdata.jdbc + taos-jdbcdriver + 2.0.8 + + + + + + \ No newline at end of file diff --git a/tests/examples/JDBC/calciteDemo/src/main/java/com/taosdata/example/calcite/CalciteDemo.java b/tests/examples/JDBC/calciteDemo/src/main/java/com/taosdata/example/calcite/CalciteDemo.java new file mode 100644 index 0000000000000000000000000000000000000000..7e97956b7879c26056b9b0e27cce4786284ff96c --- /dev/null +++ b/tests/examples/JDBC/calciteDemo/src/main/java/com/taosdata/example/calcite/CalciteDemo.java @@ -0,0 +1,67 @@ +package com.taosdata.example.calcite; + +import org.apache.calcite.adapter.jdbc.JdbcSchema; +import org.apache.calcite.jdbc.CalciteConnection; +import org.apache.calcite.schema.Schema; +import org.apache.calcite.schema.SchemaPlus; +import org.apache.calcite.sql.parser.SqlParseException; +import org.apache.commons.dbcp2.BasicDataSource; + +import java.sql.*; +import java.util.Properties; + +public class CalciteDemo { + + private static String url_taos = "jdbc:TAOS://192.168.236.135:6030/test"; + private static String url_mysql = "jdbc:mysql://master:3306/test?useSSL=false&useUnicode=true&characterEncoding=UTF-8"; + + public static void main(String[] args) throws SqlParseException, ClassNotFoundException, SQLException { + Class.forName("org.apache.calcite.jdbc.Driver"); + Properties info = new Properties(); + info.setProperty("caseSensitive", "false"); + + Connection connection = DriverManager.getConnection("jdbc:calcite:", info); + CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class); + + SchemaPlus rootSchema = calciteConnection.getRootSchema(); + + //这里hdb是在tdengine中创建的数据库名 + Schema schema = mysqlTest(rootSchema); +// Schema schema = tdengineTest(rootSchema); + + //创建新的schema自动映射到原来的hdb数据库 + rootSchema.add("test", schema); + + Statement stmt = calciteConnection.createStatement(); + //查询schema test中的表,表名是tdengine中的表 + ResultSet rs = stmt.executeQuery("select * from test.t"); + ResultSetMetaData metaData = rs.getMetaData(); + while (rs.next()) { + for (int i = 1; i <= metaData.getColumnCount(); i++) { + System.out.println(metaData.getColumnLabel(i) + " : " + rs.getString(i)); + } + } + } + + + private static Schema tdengineTest(SchemaPlus rootSchema) throws ClassNotFoundException { + Class.forName("com.taosdata.jdbc.TSDBDriver"); + BasicDataSource dataSource = new BasicDataSource(); + dataSource.setUrl(url_taos); + dataSource.setUsername("root"); + dataSource.setPassword("taosdata"); + + return JdbcSchema.create(rootSchema, "test", dataSource, "hdb", null); + } + + private static Schema mysqlTest(SchemaPlus rootSchema) throws ClassNotFoundException { + Class.forName("com.mysql.jdbc.Driver"); + BasicDataSource dataSource = new BasicDataSource(); + dataSource.setUrl(url_mysql); + dataSource.setUsername("root"); + dataSource.setPassword("123456"); + + //Schema schema = JdbcSchema.create(rootSchema, "test", dataSource, "hdb", null); + return JdbcSchema.create(rootSchema, "test", dataSource, "test", null); + } +} diff --git a/tests/examples/JDBC/calciteDemo/src/main/resources/log4j.properties b/tests/examples/JDBC/calciteDemo/src/main/resources/log4j.properties new file mode 100644 index 0000000000000000000000000000000000000000..1a77ec520cd3e727ac51acb4b8f647b7cf188d97 --- /dev/null +++ b/tests/examples/JDBC/calciteDemo/src/main/resources/log4j.properties @@ -0,0 +1,6 @@ +log4j.rootLogger=info,stdout + +#console +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern= [%d{yyyy-MM-dd HH:mm:ss a}]:%p %l%m%n \ No newline at end of file diff --git a/tests/examples/c/demo.c b/tests/examples/c/demo.c index f0e970c3325346eb5ebd341dae8fcbc7d968a8c2..8f8a66a32593bc25d71b554808719ca42f5b32ac 100644 --- a/tests/examples/c/demo.c +++ b/tests/examples/c/demo.c @@ -19,6 +19,7 @@ #include #include #include +#include #include // TAOS header file int main(int argc, char *argv[]) { @@ -37,7 +38,7 @@ int main(int argc, char *argv[]) { taos = taos_connect(argv[1], "root", "taosdata", NULL, 0); if (taos == NULL) { - printf("failed to connect to server, reason:%s\n", taos_errstr(taos)); + printf("failed to connect to server, reason:%s\n", "null taos"/*taos_errstr(taos)*/); exit(1); } printf("success to connect to server\n"); @@ -47,7 +48,7 @@ int main(int argc, char *argv[]) { result = taos_query(taos, "create database demo"); if (result == NULL) { - printf("failed to create database, reason:%s\n", taos_errstr(taos)); + printf("failed to create database, reason:%s\n", "null result"/*taos_errstr(taos)*/); exit(1); } printf("success to create database\n"); @@ -56,7 +57,7 @@ int main(int argc, char *argv[]) { // create table if (taos_query(taos, "create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))") == 0) { - printf("failed to create table, reason:%s\n", taos_errstr(taos)); + printf("failed to create table, reason:%s\n", taos_errstr(result)); exit(1); } printf("success to create table\n"); @@ -67,11 +68,21 @@ int main(int argc, char *argv[]) { // insert 10 records int i = 0; for (i = 0; i < 10; ++i) { - sprintf(qstr, "insert into m1 values (%ld, %d, %d, %d, %d, %f, %lf, '%s')", 1546300800000 + i * 1000, i, i, i, i*10000000, i*1.0, i*2.0, "hello"); + sprintf(qstr, "insert into m1 values (%" PRId64 ", %d, %d, %d, %d, %f, %lf, '%s')", 1546300800000 + i * 1000, i, i, i, i*10000000, i*1.0, i*2.0, "hello"); printf("qstr: %s\n", qstr); - if (taos_query(taos, qstr)) { - printf("insert row: %i, reason:%s\n", i, taos_errstr(taos)); + + // note: how do you wanna do if taos_query returns non-NULL + // if (taos_query(taos, qstr)) { + // printf("insert row: %i, reason:%s\n", i, taos_errstr(taos)); + // } + TAOS_RES *result = taos_query(taos, qstr); + if (result) { + printf("insert row: %i\n", i); + } else { + printf("failed to insert row: %i, reason:%s\n", i, "null result"/*taos_errstr(result)*/); + exit(1); } + //sleep(1); } printf("success to insert rows, total %d rows\n", i); diff --git a/tests/examples/go/src/taosapp/taosapp.go b/tests/examples/go/src/taosapp/taosapp.go deleted file mode 100644 index 30126ea571beeb84f8a46e7053ede97f8202ee71..0000000000000000000000000000000000000000 --- a/tests/examples/go/src/taosapp/taosapp.go +++ /dev/null @@ -1,302 +0,0 @@ -/* - * 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 . - */ -package main - -import ( - "database/sql" - "time" - "log" - "fmt" - _ "github.com/taosdata/driver-go/taosSql" -) - -func main() { - taosDriverName := "taosSql" - demodb := "demodb" - demot := "demot" - - fmt.Printf("\n======== start demo test ========\n") - // open connect to taos server - db, err := sql.Open(taosDriverName, "root:taosdata@/tcp(127.0.0.1:0)/") - if err != nil { - log.Fatalf("Open database error: %s\n", err) - } - defer db.Close() - - drop_database(db, demodb) - create_database(db, demodb) - use_database(db, demodb) - create_table(db, demot) - insert_data(db, demot) - select_data(db, demot) - - fmt.Printf("\n======== start stmt mode test ========\n") - - demodbStmt := "demodbStmt" - demotStmt := "demotStmt" - drop_database_stmt(db, demodbStmt) - create_database_stmt(db, demodbStmt) - use_database_stmt(db, demodbStmt) - create_table_stmt(db, demotStmt) - insert_data_stmt(db, demotStmt) - select_data_stmt(db, demotStmt) - - fmt.Printf("\n======== end demo test ========\n") -} - -func drop_database(db *sql.DB, demodb string) { - st := time.Now().Nanosecond() - res, err := db.Exec("drop database if exists " + demodb) - checkErr(err, "drop database if exists " + demodb) - - affectd, err := res.RowsAffected() - checkErr(err, "drop db, res.RowsAffected") - - et := time.Now().Nanosecond() - - fmt.Printf("drop database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) -} - -func create_database(db *sql.DB, demodb string) { - st := time.Now().Nanosecond() - // create database - res, err := db.Exec("create database " + demodb) - checkErr(err, "create db, db.Exec") - - affectd, err := res.RowsAffected() - checkErr(err, "create db, res.RowsAffected") - - et := time.Now().Nanosecond() - - fmt.Printf("create database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) - - return -} - -func use_database(db *sql.DB, demodb string) { - st := time.Now().Nanosecond() - // use database - res, err := db.Exec("use " + demodb) // notes: must no quote to db name - checkErr(err, "use db db.Exec") - - affectd, err := res.RowsAffected() - checkErr(err, "use db, res.RowsAffected") - - et := time.Now().Nanosecond() - - fmt.Printf("use database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) -} - -func create_table(db *sql.DB, demot string) { - st := time.Now().Nanosecond() - // create table - res, err := db.Exec("create table " + demot + " (ts timestamp, id int, name binary(8), len tinyint, flag bool, notes binary(8), fv float, dv double)") - checkErr(err, "create table db.Exec") - - affectd, err := res.RowsAffected() - checkErr(err, "create table res.RowsAffected") - - et := time.Now().Nanosecond() - fmt.Printf("create table result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) -} - -func insert_data(db *sql.DB, demot string) { - st := time.Now().Nanosecond() - // insert data - res, err := db.Exec("insert into " + demot + - " values (now, 100, 'beijing', 10, true, 'one', 123.456, 123.456)" + - " (now+1s, 101, 'shanghai', 11, true, 'two', 789.123, 789.123)" + - " (now+2s, 102, 'shenzhen', 12, false, 'three', 456.789, 456.789)") - - checkErr(err, "insert data, db.Exec") - - affectd, err := res.RowsAffected() - checkErr(err, "insert data res.RowsAffected") - - et := time.Now().Nanosecond() - fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) -} - -func select_data(db *sql.DB, demot string) { - st := time.Now().Nanosecond() - - rows, err := db.Query("select * from ? " , demot) // go text mode - checkErr(err, "select db.Query") - - fmt.Printf("%10s%s%8s %5s %9s%s %s %8s%s %7s%s %8s%s %4s%s %5s%s\n", " ","ts", " ", "id"," ", "name"," ","len", " ","flag"," ", "notes", " ", "fv", " ", " ", "dv") - var affectd int - for rows.Next() { - var ts string - var name string - var id int - var len int8 - var flag bool - var notes string - var fv float32 - var dv float64 - - err = rows.Scan(&ts, &id, &name, &len, &flag, ¬es, &fv, &dv) - checkErr(err, "select rows.Scan") - - fmt.Printf("%s\t", ts) - fmt.Printf("%d\t",id) - fmt.Printf("%10s\t",name) - fmt.Printf("%d\t",len) - fmt.Printf("%t\t",flag) - fmt.Printf("%s\t",notes) - fmt.Printf("%06.3f\t",fv) - fmt.Printf("%09.6f\n",dv) - - affectd++ - } - - et := time.Now().Nanosecond() - fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) - fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) -} - -func drop_database_stmt(db *sql.DB,demodb string) { - st := time.Now().Nanosecond() - // drop test db - res, err := db.Exec("drop database if exists " + demodb) - checkErr(err, "drop database " + demodb) - - affectd, err := res.RowsAffected() - checkErr(err, "drop db, res.RowsAffected") - - et := time.Now().Nanosecond() - fmt.Printf("drop database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) -} - -func create_database_stmt(db *sql.DB,demodb string) { - st := time.Now().Nanosecond() - // create database - //var stmt interface{} - stmt, err := db.Prepare("create database ?") - checkErr(err, "create db, db.Prepare") - - //var res driver.Result - res, err := stmt.Exec(demodb) - checkErr(err, "create db, stmt.Exec") - - //fmt.Printf("Query OK, %d row(s) affected()", res.RowsAffected()) - affectd, err := res.RowsAffected() - checkErr(err, "create db, res.RowsAffected") - - et := time.Now().Nanosecond() - fmt.Printf("create database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) -} - -func use_database_stmt (db *sql.DB,demodb string) { - st := time.Now().Nanosecond() - // create database - //var stmt interface{} - stmt, err := db.Prepare("use " + demodb) - checkErr(err, "use db, db.Prepare") - - res, err := stmt.Exec() - checkErr(err, "use db, stmt.Exec") - - affectd, err := res.RowsAffected() - checkErr(err, "use db, res.RowsAffected") - - et := time.Now().Nanosecond() - fmt.Printf("use database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) -} - -func create_table_stmt (db *sql.DB,demot string) { - st := time.Now().Nanosecond() - // create table - // (ts timestamp, id int, name binary(8), len tinyint, flag bool, notes binary(8), fv float, dv double) - stmt, err := db.Prepare("create table ? (? timestamp, ? int, ? binary(10), ? tinyint, ? bool, ? binary(8), ? float, ? double)") - checkErr(err, "create table db.Prepare") - - res, err := stmt.Exec(demot, "ts", "id", "name", "len", "flag", "notes", "fv", "dv") - checkErr(err, "create table stmt.Exec") - - affectd, err := res.RowsAffected() - checkErr(err, "create table res.RowsAffected") - - et := time.Now().Nanosecond() - fmt.Printf("create table result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) -} - -func insert_data_stmt(db *sql.DB,demot string) { - st := time.Now().Nanosecond() - // insert data into table - stmt, err := db.Prepare("insert into ? values(?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?)") - checkErr(err, "insert db.Prepare") - - res, err := stmt.Exec(demot, "now" , 1000, "'haidian'" , 6, true, "'AI world'", 6987.654, 321.987, - "now+1s", 1001, "'changyang'" , 7, false, "'DeepMode'", 12356.456, 128634.456, - "now+2s", 1002, "'chuangping'" , 8, true, "'database'", 3879.456, 65433478.456,) - checkErr(err, "insert data, stmt.Exec") - - affectd, err := res.RowsAffected() - checkErr(err, "res.RowsAffected") - - et := time.Now().Nanosecond() - fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) -} - -func select_data_stmt(db *sql.DB, demot string) { - st := time.Now().Nanosecond() - - stmt, err := db.Prepare("select ?, ?, ?, ?, ?, ?, ?, ? from ?" ) // go binary mode - checkErr(err, "db.Prepare") - - rows, err := stmt.Query("ts", "id","name","len", "flag","notes", "fv", "dv", demot) - checkErr(err, "stmt.Query") - - fmt.Printf("%10s%s%8s %5s %8s%s %s %10s%s %7s%s %8s%s %11s%s %14s%s\n", " ","ts", " ", "id"," ", "name"," ","len", " ","flag"," ", "notes", " ", "fv", " ", " ", "dv") - var affectd int - for rows.Next() { - var ts string - var name string - var id int - var len int8 - var flag bool - var notes string - var fv float32 - var dv float64 - - err = rows.Scan(&ts, &id, &name, &len, &flag, ¬es, &fv, &dv) - //fmt.Println("start scan fields from row.rs, &fv:", &fv) - //err = rows.Scan(&fv) - checkErr(err, "rows.Scan") - - fmt.Printf("%s\t", ts) - fmt.Printf("%d\t",id) - fmt.Printf("%10s\t",name) - fmt.Printf("%d\t",len) - fmt.Printf("%t\t",flag) - fmt.Printf("%s\t",notes) - fmt.Printf("%06.3f\t",fv) - fmt.Printf("%09.6f\n",dv) - - affectd++ - - } - - et := time.Now().Nanosecond() - fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) -} - -func checkErr(err error, prompt string) { - if err != nil { - fmt.Printf("%s\n", prompt) - panic(err) - } -} diff --git a/tests/examples/go/taosdemo.go b/tests/examples/go/taosdemo.go new file mode 100644 index 0000000000000000000000000000000000000000..b42e1e6d703a96bb86454f177a7207577c6d4d4c --- /dev/null +++ b/tests/examples/go/taosdemo.go @@ -0,0 +1,409 @@ +/* + * 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 . + */ +package main + +import ( + "database/sql" + "fmt" + _ "github.com/taosdata/driver-go/taosSql" + "os" + "sync" + "runtime" + "strconv" + "time" + "flag" + "math/rand" + //"golang.org/x/sys/unix" +) + +const ( + maxLocationSize = 32 + maxSqlBufSize = 65480 +) + +var locations = [maxLocationSize]string { + "Beijing", "Shanghai", "Guangzhou", "Shenzhen", + "HangZhou", "Tianjin", "Wuhan", "Changsha", + "Nanjing", "Xian"} + +type config struct { + hostName string + serverPort int + user string + password string + dbName string + supTblName string + tablePrefix string + numOftables int + numOfRecordsPerTable int + numOfRecordsPerReq int + numOfThreads int + startTimestamp string + startTs int64 + + keep int + days int +} + +var configPara config +var taosDriverName = "taosSql" +var url string + +func init() { + flag.StringVar(&configPara.hostName, "h", "127.0.0.1","The host to connect to TDengine server.") + flag.IntVar(&configPara.serverPort, "p", 6030, "The TCP/IP port number to use for the connection to TDengine server.") + flag.StringVar(&configPara.user, "u", "root", "The TDengine user name to use when connecting to the server.") + flag.StringVar(&configPara.password, "P", "taosdata", "The password to use when connecting to the server.") + flag.StringVar(&configPara.dbName, "d", "test", "Destination database.") + flag.StringVar(&configPara.tablePrefix, "m", "d", "Table prefix name.") + flag.IntVar(&configPara.numOftables, "t", 2, "The number of tables.") + flag.IntVar(&configPara.numOfRecordsPerTable, "n", 10, "The number of records per table.") + flag.IntVar(&configPara.numOfRecordsPerReq, "r", 3, "The number of records per request.") + flag.IntVar(&configPara.numOfThreads, "T", 1, "The number of threads.") + flag.StringVar(&configPara.startTimestamp, "s", "2020-10-01 08:00:00", "The start timestamp for one table.") + flag.Parse() + + configPara.keep = 365 * 20 + configPara.days = 30 + configPara.supTblName = "meters" + + startTs, err := time.ParseInLocation("2006-01-02 15:04:05", configPara.startTimestamp, time.Local) + if err==nil { + configPara.startTs = startTs.UnixNano() / 1e6 + } +} + +func printAllArgs() { + fmt.Printf("\n============= args parse result: =============\n") + fmt.Printf("dbName: %v\n", configPara.hostName) + fmt.Printf("serverPort: %v\n", configPara.serverPort) + fmt.Printf("usr: %v\n", configPara.user) + fmt.Printf("password: %v\n", configPara.password) + fmt.Printf("dbName: %v\n", configPara.dbName) + fmt.Printf("tablePrefix: %v\n", configPara.tablePrefix) + fmt.Printf("numOftables: %v\n", configPara.numOftables) + fmt.Printf("numOfRecordsPerTable: %v\n", configPara.numOfRecordsPerTable) + fmt.Printf("numOfRecordsPerReq: %v\n", configPara.numOfRecordsPerReq) + fmt.Printf("numOfThreads: %v\n", configPara.numOfThreads) + fmt.Printf("startTimestamp: %v[%v]\n", configPara.startTimestamp, configPara.startTs) + fmt.Printf("================================================\n") +} + +func main() { + printAllArgs() + fmt.Printf("Please press enter key to continue....\n") + fmt.Scanln() + + url = "root:taosdata@/tcp(" + configPara.hostName + ":" + strconv.Itoa(configPara.serverPort) + ")/" + //url = fmt.Sprintf("%s:%s@/tcp(%s:%d)/%s?interpolateParams=true", configPara.user, configPara.password, configPara.hostName, configPara.serverPort, configPara.dbName) + // open connect to taos server + //db, err := sql.Open(taosDriverName, url) + //if err != nil { + // fmt.Println("Open database error: %s\n", err) + // os.Exit(1) + //} + //defer db.Close() + + createDatabase(configPara.dbName, configPara.supTblName) + fmt.Printf("======== create database success! ========\n\n") + + //create_table(db, stblName) + multiThreadCreateTable(configPara.numOfThreads, configPara.numOftables, configPara.dbName, configPara.tablePrefix) + fmt.Printf("======== create super table and child tables success! ========\n\n") + + //insert_data(db, demot) + multiThreadInsertData(configPara.numOfThreads, configPara.numOftables, configPara.dbName, configPara.tablePrefix) + fmt.Printf("======== insert data into child tables success! ========\n\n") + + //select_data(db, demot) + selectTest(configPara.dbName, configPara.tablePrefix, configPara.supTblName) + fmt.Printf("======== select data success! ========\n\n") + + fmt.Printf("======== end demo ========\n") +} + +func createDatabase(dbName string, supTblName string) { + db, err := sql.Open(taosDriverName, url) + if err != nil { + fmt.Println("Open database error: %s\n", err) + os.Exit(1) + } + defer db.Close() + + // drop database if exists + sqlStr := "drop database if exists " + dbName + _, err = db.Exec(sqlStr) + checkErr(err, sqlStr) + + time.Sleep(time.Second) + + // create database + sqlStr = "create database " + dbName + " keep " + strconv.Itoa(configPara.keep) + " days " + strconv.Itoa(configPara.days) + _, err = db.Exec(sqlStr) + checkErr(err, sqlStr) + + // use database + //sqlStr = "use " + dbName + //_, err = db.Exec(sqlStr) + //checkErr(err, sqlStr) + + sqlStr = "create table if not exists " + dbName + "." + supTblName + " (ts timestamp, current float, voltage int, phase float) tags(location binary(64), groupId int);" + _, err = db.Exec(sqlStr) + checkErr(err, sqlStr) +} + +func multiThreadCreateTable(threads int, ntables int, dbName string, tablePrefix string) { + st := time.Now().UnixNano() + + if (threads < 1) { + threads = 1; + } + + a := ntables / threads; + if (a < 1) { + threads = ntables; + a = 1; + } + + b := ntables % threads; + + last := 0; + endTblId := 0 + wg := sync.WaitGroup{} + for i := 0; i < threads; i++ { + startTblId := last + if (i < b ) { + endTblId = last + a + } else { + endTblId = last + a - 1 + } + last = endTblId + 1 + wg.Add(1) + go createTable(dbName, tablePrefix, startTblId, endTblId, &wg) + } + wg.Wait() + + et := time.Now().UnixNano() + fmt.Printf("create tables spent duration: %6.6fs\n", (float32(et-st))/1e9) +} + +func createTable(dbName string, childTblPrefix string, startTblId int, endTblId int, wg *sync.WaitGroup) { + //fmt.Printf("subThread[%d]: create table from %d to %d \n", unix.Gettid(), startTblId, endTblId) + // windows.GetCurrentThreadId() + + db, err := sql.Open(taosDriverName, url) + if err != nil { + fmt.Println("Open database error: %s\n", err) + os.Exit(1) + } + defer db.Close() + + for i := startTblId; i <= endTblId; i++ { + sqlStr := "create table if not exists " + dbName + "." + childTblPrefix + strconv.Itoa(i) + " using " + dbName + ".meters tags('" + locations[i%maxLocationSize] + "', " + strconv.Itoa(i) + ");" + //fmt.Printf("sqlStr: %v\n", sqlStr) + _, err = db.Exec(sqlStr) + checkErr(err, sqlStr) + } + wg.Done() + runtime.Goexit() +} + +func generateRowData(ts int64) string { + voltage := rand.Int() % 1000 + current := 200 + rand.Float32() + phase := rand.Float32() + values := "( " + strconv.FormatInt(ts, 10) + ", " + strconv.FormatFloat(float64(current), 'f', 6, 64) + ", " + strconv.Itoa(voltage) + ", " + strconv.FormatFloat(float64(phase), 'f', 6, 64) + " ) " + return values +} +func insertData(dbName string, childTblPrefix string, startTblId int, endTblId int, wg *sync.WaitGroup) { + //fmt.Printf("subThread[%d]: insert data to table from %d to %d \n", unix.Gettid(), startTblId, endTblId) + // windows.GetCurrentThreadId() + + db, err := sql.Open(taosDriverName, url) + if err != nil { + fmt.Println("Open database error: %s\n", err) + os.Exit(1) + } + defer db.Close() + + tmpTs := configPara.startTs; + //rand.New(rand.NewSource(time.Now().UnixNano())) + for tID := startTblId; tID <= endTblId; tID++{ + totalNum := 0 + for { + sqlStr := "insert into " + dbName + "." + childTblPrefix + strconv.Itoa(tID) + " values " + currRowNum := 0 + for { + tmpTs += 1000 + valuesOfRow := generateRowData(tmpTs) + currRowNum += 1 + totalNum += 1 + + sqlStr = fmt.Sprintf("%s %s", sqlStr, valuesOfRow) + + if (currRowNum >= configPara.numOfRecordsPerReq || totalNum >= configPara.numOfRecordsPerTable) { + break + } + } + + res, err := db.Exec(sqlStr) + checkErr(err, sqlStr) + + count, err := res.RowsAffected() + checkErr(err, "rows affected") + + if (count != int64(currRowNum)) { + fmt.Printf("insert data, expect affected:%d, actual:%d\n", currRowNum, count) + os.Exit(1) + } + + if (totalNum >= configPara.numOfRecordsPerTable) { + break + } + } + } + + wg.Done() + runtime.Goexit() +} +func multiThreadInsertData(threads int, ntables int, dbName string, tablePrefix string) { + st := time.Now().UnixNano() + + if (threads < 1) { + threads = 1; + } + + a := ntables / threads; + if (a < 1) { + threads = ntables; + a = 1; + } + + b := ntables % threads; + + last := 0; + endTblId := 0 + wg := sync.WaitGroup{} + for i := 0; i < threads; i++ { + startTblId := last + if (i < b ) { + endTblId = last + a + } else { + endTblId = last + a - 1 + } + last = endTblId + 1 + wg.Add(1) + go insertData(dbName, tablePrefix, startTblId , endTblId, &wg) + } + wg.Wait() + + et := time.Now().UnixNano() + fmt.Printf("insert data spent duration: %6.6fs\n", (float32(et-st))/1e9) +} +func selectTest(dbName string, tbPrefix string, supTblName string){ + db, err := sql.Open(taosDriverName, url) + if err != nil { + fmt.Println("Open database error: %s\n", err) + os.Exit(1) + } + defer db.Close() + + // select sql 1 + limit := 3 + offset := 0 + sqlStr := "select * from " + dbName + "." + supTblName + " limit " + strconv.Itoa(limit) + " offset " + strconv.Itoa(offset) + rows, err := db.Query(sqlStr) + checkErr(err, sqlStr) + + defer rows.Close() + fmt.Printf("query sql: %s\n", sqlStr) + for rows.Next() { + var ( + ts string + current float32 + voltage int + phase float32 + location string + groupid int + ) + err := rows.Scan(&ts, ¤t, &voltage, &phase, &location, &groupid) + if err != nil { + checkErr(err, "rows scan fail") + } + + fmt.Printf("ts:%s\t current:%f\t voltage:%d\t phase:%f\t location:%s\t groupid:%d\n", ts, current, voltage, phase, location, groupid) + } + // check iteration error + if rows.Err() != nil { + checkErr(err, "rows next iteration error") + } + + // select sql 2 + sqlStr = "select avg(voltage), min(voltage), max(voltage) from " + dbName + "." + tbPrefix + strconv.Itoa( rand.Int() % configPara.numOftables) + rows, err = db.Query(sqlStr) + checkErr(err, sqlStr) + + defer rows.Close() + fmt.Printf("\nquery sql: %s\n", sqlStr) + for rows.Next() { + var ( + voltageAvg float32 + voltageMin int + voltageMax int + ) + err := rows.Scan(&voltageAvg, &voltageMin, &voltageMax) + if err != nil { + checkErr(err, "rows scan fail") + } + + fmt.Printf("avg(voltage):%f\t min(voltage):%d\t max(voltage):%d\n", voltageAvg, voltageMin, voltageMax) + } + // check iteration error + if rows.Err() != nil { + checkErr(err, "rows next iteration error") + } + + // select sql 3 + sqlStr = "select last(*) from " + dbName + "." + supTblName + rows, err = db.Query(sqlStr) + checkErr(err, sqlStr) + + defer rows.Close() + fmt.Printf("\nquery sql: %s\n", sqlStr) + for rows.Next() { + var ( + lastTs string + lastCurrent float32 + lastVoltage int + lastPhase float32 + ) + err := rows.Scan(&lastTs, &lastCurrent, &lastVoltage, &lastPhase) + if err != nil { + checkErr(err, "rows scan fail") + } + + fmt.Printf("last(ts):%s\t last(current):%f\t last(voltage):%d\t last(phase):%f\n", lastTs, lastCurrent, lastVoltage, lastPhase) + } + // check iteration error + if rows.Err() != nil { + checkErr(err, "rows next iteration error") + } +} +func checkErr(err error, prompt string) { + if err != nil { + fmt.Printf("%s\n", prompt) + panic(err) + } +} diff --git a/tests/examples/nodejs/nodejsChecker.js b/tests/examples/nodejs/nodejsChecker.js new file mode 100644 index 0000000000000000000000000000000000000000..c77944f75243a50e6e2c738e659cb4e64f3e5574 --- /dev/null +++ b/tests/examples/nodejs/nodejsChecker.js @@ -0,0 +1,60 @@ +const taos = require('td2.0-connector'); + + +var host = null; +var port = 6030; +for(var i = 2; i < global.process.argv.length; i++){ + var key = global.process.argv[i].split("=")[0]; + var value = global.process.argv[i].split("=")[1]; + + if("host" == key){ + host = value; + } + if("port" == key){ + port = value; + } +} + +if(host == null){ + console.log("Usage: node nodejsChecker.js host= port="); + process.exit(0); +} + +// establish connection +var conn = taos.connect({host:host, user:"root", password:"taosdata",port:port}); +var cursor = conn.cursor(); +// create database +executeSql("create database if not exists test", 0); +// use db +executeSql("use test", 0); +// drop table +executeSql("drop table if exists test.weather", 0); +// create table +executeSql("create table if not exists test.weather(ts timestamp, temperature float, humidity int)", 0); +// insert +executeSql("insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)", 1); +// select +executeQuery("select * from test.weather"); +// close connection +conn.close(); + +function executeQuery(sql){ + var start = new Date().getTime(); + var promise = cursor.query(sql, true); + var end = new Date().getTime(); + printSql(sql, promise != null,(end - start)); + promise.then(function(result){ + result.pretty(); + }); +} + +function executeSql(sql, affectRows){ + var start = new Date().getTime(); + var promise = cursor.execute(sql); + var end = new Date().getTime(); + printSql(sql, promise == affectRows, (end - start)); +} + +function printSql(sql, succeed, cost){ + console.log("[ "+(succeed ? "OK" : "ERROR!")+" ] time cost: " + cost + " ms, execute statement ====> " + sql); +} diff --git a/tests/examples/python/PYTHONConnectorChecker/PythonChecker.py b/tests/examples/python/PYTHONConnectorChecker/PythonChecker.py new file mode 100644 index 0000000000000000000000000000000000000000..d74f021ffcf3aa33c551cc265243b5139c23b757 --- /dev/null +++ b/tests/examples/python/PYTHONConnectorChecker/PythonChecker.py @@ -0,0 +1,114 @@ +import taos +import time +import sys +import getopt +class ConnectorChecker: + def init(self): + self.host = "127.0.0.1" + self.dbName = "test" + self.tbName = "weather" + self.user = "root" + self.password = "taosdata" + + + def sethdt(self,FQDN,dbname,tbname): + if(FQDN): + self.host=FQDN + if(dbname): + self.dbname=dbname + if(tbname): + self.tbName + def printSql(self,sql,elapsed): + print("[ "+"OK"+" ]"+" time cost: %s ms, execute statement ====> %s" + %(elapsed,sql)) + def executeQuery(self,sql): + try: + start=time.time() + execute = self.cl.execute(sql) + elapsed = (time.time()-start)*1000 + self.printSql(sql,elapsed) + data = self.cl.fetchall() + numOfRows = self.cl.rowcount + numOfCols = len(self.cl.description) + for irow in range(numOfRows): + print("Row%d: ts=%s, temperature=%d, humidity=%f" %(irow, data[irow][0], data[irow][1],data[irow][2])) + except Exception as e: + print("Failure sql: %s,exception: %s" %sql,str(e)) + def execute(self,sql): + try: + start=time.time() + execute = self.cl.execute(sql) + elapsed = (time.time()-start)*1000 + self.printSql(sql,elapsed) + + except Exception as e: + print("Failure sql: %s,exception: %s" % + sql,str(e)) + def close(self): + print("connetion closed.") + self.cl.close() + self.conn.close() + def createDatabase(self): + sql="create database if not exists %s" % self.dbName + self.execute(sql) + def useDatabase(self): + sql="use %s" % self.dbName + self.execute(sql) + def createTable(self): + sql="create table if not exists %s.%s (ts timestamp, temperature float, humidity int)"%(self.dbName,self.tbName) + self.execute(sql) + def checkDropTable(self): + sql="drop table if exists " + self.dbName + "." + self.tbName + "" + self.execute(sql) + def checkInsert(self): + sql="insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)" + self.execute(sql) + def checkSelect(self): + sql = "select * from test.weather" + self.executeQuery(sql) + def srun(self): + try: + self.conn = taos.connect(host=self.host,user=self.user,password=self.password) + #self.conn = taos.connect(self.host,self.user,self.password) + except Exception as e: + print("connection failed: %s"%self.host) + exit(1) + print("[ OK ] Connection established.") + self.cl = self.conn.cursor() + +def main(argv): + FQDN='' + dbname='' + tbname='' + try: + opts, args = getopt.getopt(argv,"h:d:t:",["FQDN=","ifile=","ofile="]) + except getopt.GetoptError: + print ('PYTHONConnectorChecker.py -h ') + sys.exit(2) + for opt, arg in opts: + if opt in ("-h", "--FQDN"): + FQDN=arg + elif opt in ("-d", "--dbname"): + dbname = arg + elif opt in ("-t", "--tbname"): + tbname = arg + + checker = ConnectorChecker() + checker.init() + checker.sethdt(FQDN,dbname,tbname) + checker.srun() + checker.createDatabase() + checker.useDatabase() + checker.checkDropTable() + checker.createTable() + checker.checkInsert() + checker.checkSelect() + checker.checkDropTable() + checker.close() + + + +if __name__ == "__main__": + main(sys.argv[1:]) + + diff --git a/tests/examples/python/read_example.py b/tests/examples/python/read_example.py index dd1475ec1452d8c968d7aa575134ae11ac76d854..73052ab2df54fcee8fb01573e23eb7b29ed11712 100644 --- a/tests/examples/python/read_example.py +++ b/tests/examples/python/read_example.py @@ -22,8 +22,12 @@ if __name__ == '__main__': # @password : Password # @database : Database to use when connecting to TDengine server # @config : Configuration directory - conn = taos.connect(host="127.0.0.1", user="root", password="taosdata", config="/etc/taos") - + if len(sys.argv)>1: + hostname=sys.argv[1] + conn = taos.connect(host=hostname, user="root", password="taosdata", config="/etc/taos") + else: + conn = taos.connect(host="127.0.0.1", user="root", password="taosdata", config="/etc/taos") + # Generate a cursor object to run SQL commands c1 = conn.cursor() # Create a database named db diff --git a/tests/examples/rust/src/bindings.rs b/tests/examples/rust/src/bindings.rs index b93e833ba05dbc4bbf2a390a5cf801d27c340590..fc13647130995b2a85b485236ec9a7ba30c1cc1b 100644 --- a/tests/examples/rust/src/bindings.rs +++ b/tests/examples/rust/src/bindings.rs @@ -308,12 +308,6 @@ extern "C" { extern "C" { pub fn taos_unsubscribe(tsub: *mut ::std::os::raw::c_void); } -extern "C" { - pub fn taos_subfields_count(tsub: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn taos_fetch_subfields(tsub: *mut ::std::os::raw::c_void) -> *mut TAOS_FIELD; -} extern "C" { pub fn taos_open_stream( taos: *mut ::std::os::raw::c_void, diff --git a/tests/examples/rust/src/subscriber.rs b/tests/examples/rust/src/subscriber.rs index b6812d7b6e5b48016c62c3bb45d11bfb7fd85e0b..78c6f5cd8d036be537da11f34f829d48750d2a73 100644 --- a/tests/examples/rust/src/subscriber.rs +++ b/tests/examples/rust/src/subscriber.rs @@ -37,16 +37,16 @@ impl Subscriber { println!("subscribed to {} user:{}, db:{}, tb:{}, time:{}, mseconds:{}", host, username, db, table, time, mseconds); - let mut fields = taos_fetch_subfields(tsub); + let mut fields = taos_fetch_fields(tsub); if fields.is_null() { taos_unsubscribe(tsub); - return Err("fetch subfields error") + return Err("fetch fields error") } - let fcount = taos_subfields_count(tsub); + let fcount = taos_field_count(tsub); if fcount == 0 { taos_unsubscribe(tsub); - return Err("subfields count is 0") + return Err("fields count is 0") } Ok(Subscriber{tsub, fields, fcount}) @@ -74,4 +74,4 @@ impl Drop for Subscriber { fn drop(&mut self) { unsafe {taos_unsubscribe(self.tsub);} } -} \ No newline at end of file +} diff --git a/tests/gotest/batchtest.bat b/tests/gotest/batchtest.bat new file mode 100755 index 0000000000000000000000000000000000000000..efd8961bb0be2eb6f20e291114b92b00469b984f --- /dev/null +++ b/tests/gotest/batchtest.bat @@ -0,0 +1,20 @@ +@echo off +echo ==== start Go connector test cases test ==== +cd /d %~dp0 + +set severIp=%1 +set serverPort=%2 +if "%severIp%"=="" (set severIp=127.0.0.1) +if "%serverPort%"=="" (set serverPort=6030) + +go env -w GO111MODULE=on +go env -w GOPROXY=https://goproxy.io,direct + +cd case001 +case001.bat %severIp% %serverPort% + +rem cd case002 +rem case002.bat + +:: cd case002 +:: case002.bat diff --git a/tests/gotest/batchtest.sh b/tests/gotest/batchtest.sh new file mode 100755 index 0000000000000000000000000000000000000000..0fbbf40714b3349651beea9302e66628b31a22ac --- /dev/null +++ b/tests/gotest/batchtest.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +echo "==== start Go connector test cases test ====" + +severIp=$1 +serverPort=$2 + +if [ ! -n "$severIp" ]; then + severIp=127.0.0.1 +fi + +if [ ! -n "$serverPort" ]; then + serverPort=6030 +fi + +go env -w GO111MODULE=on +go env -w GOPROXY=https://goproxy.io,direct + +bash ./case001/case001.sh $severIp $serverPort +#bash ./case002/case002.sh $severIp $serverPort +#bash ./case003/case003.sh $severIp $serverPort diff --git a/tests/gotest/case001/case001.bat b/tests/gotest/case001/case001.bat new file mode 100644 index 0000000000000000000000000000000000000000..ebec576e724ccb14319dd380c9783a783ac0db62 --- /dev/null +++ b/tests/gotest/case001/case001.bat @@ -0,0 +1,9 @@ +@echo off +echo ==== start run cases001.go + +del go.* +go mod init demotest +go build +demotest.exe -h %1 -p %2 +cd .. + diff --git a/tests/gotest/case001/case001.go b/tests/gotest/case001/case001.go new file mode 100644 index 0000000000000000000000000000000000000000..fb94f566dd7fa9ef8932bc28326310681998b410 --- /dev/null +++ b/tests/gotest/case001/case001.go @@ -0,0 +1,341 @@ +/* + * 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 . + */ +package main + +import ( + "database/sql" + "flag" + "fmt" + _ "github.com/taosdata/driver-go/taosSql" + "log" + "strconv" + "time" +) + +type config struct { + hostName string + serverPort int + user string + password string +} + +var configPara config +var url string + +func init() { + flag.StringVar(&configPara.hostName, "h", "127.0.0.1","The host to connect to TDengine server.") + flag.IntVar(&configPara.serverPort, "p", 6030, "The TCP/IP port number to use for the connection to TDengine server.") + flag.StringVar(&configPara.user, "u", "root", "The TDengine user name to use when connecting to the server.") + flag.StringVar(&configPara.password, "P", "taosdata", "The password to use when connecting to the server.") + + flag.Parse() +} + +func printAllArgs() { + fmt.Printf("\n============= args parse result: =============\n") + fmt.Printf("hostName: %v\n", configPara.hostName) + fmt.Printf("serverPort: %v\n", configPara.serverPort) + fmt.Printf("usr: %v\n", configPara.user) + fmt.Printf("password: %v\n", configPara.password) + fmt.Printf("================================================\n") +} + +func main() { + printAllArgs() + taosDriverName := "taosSql" + demodb := "demodb" + demot := "demot" + + fmt.Printf("\n======== start demo test ========\n") + + url = "root:taosdata@/tcp(" + configPara.hostName + ":" + strconv.Itoa(configPara.serverPort) + ")/" + // open connect to taos server + db, err := sql.Open(taosDriverName, url) + if err != nil { + log.Fatalf("Open database error: %s\n", err) + } + defer db.Close() + + drop_database(db, demodb) + create_database(db, demodb) + use_database(db, demodb) + create_table(db, demot) + insert_data(db, demot) + select_data(db, demot) + + fmt.Printf("\n======== start stmt mode test ========\n") + + demodbStmt := "demodbStmt" + demotStmt := "demotStmt" + drop_database_stmt(db, demodbStmt) + create_database_stmt(db, demodbStmt) + use_database_stmt(db, demodbStmt) + create_table_stmt(db, demotStmt) + insert_data_stmt(db, demotStmt) + select_data_stmt(db, demotStmt) + + fmt.Printf("\n======== end demo test ========\n") +} + +func drop_database(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + res, err := db.Exec("drop database if exists " + demodb) + checkErr(err, "drop database if exists "+demodb) + + affectd, err := res.RowsAffected() + checkErr(err, "drop db, res.RowsAffected") + + et := time.Now().Nanosecond() + + fmt.Printf("drop database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) + + //sleep 50毫秒 + time.Sleep(time.Duration(50)* time.Millisecond) +} + +func create_database(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // create database + res, err := db.Exec("create database " + demodb) + checkErr(err, "create db, db.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "create db, res.RowsAffected") + + et := time.Now().Nanosecond() + + fmt.Printf("create database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) + + return +} + +func use_database(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // use database + res, err := db.Exec("use " + demodb) // notes: must no quote to db name + checkErr(err, "use db db.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "use db, res.RowsAffected") + + et := time.Now().Nanosecond() + + fmt.Printf("use database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func create_table(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + // create table + res, err := db.Exec("create table " + demot + " (ts timestamp, id int, name binary(8), len tinyint, flag bool, notes binary(8), fv float, dv double)") + checkErr(err, "create table db.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "create table res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("create table result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func insert_data(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + // insert data + res, err := db.Exec("insert into " + demot + + " values (now, 100, 'beijing', 10, true, 'one', 123.456, 123.456)" + + " (now+1s, 101, 'shanghai', 11, true, 'two', 789.123, 789.123)" + + " (now+2s, 102, 'shenzhen', 12, false, 'three', 456.789, 456.789)") + + checkErr(err, "insert data, db.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "insert data res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func select_data(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + + rows, err := db.Query("select * from ? ", demot) // go text mode + checkErr(err, "select db.Query") + + fmt.Printf("%10s%s%8s %5s %9s%s %s %8s%s %7s%s %8s%s %4s%s %5s%s\n", " ", "ts", " ", "id", " ", "name", " ", "len", " ", "flag", " ", "notes", " ", "fv", " ", " ", "dv") + var affectd int + + //decoder := mahonia.NewDecoder("gbk") // 把原来ANSI格式的文本文件里的字符,用gbk进行解码。 + + for rows.Next() { + var ts string + var name string + var id int + var len int8 + var flag bool + var notes string + var fv float32 + var dv float64 + + err = rows.Scan(&ts, &id, &name, &len, &flag, ¬es, &fv, &dv) + checkErr(err, "select rows.Scan") + + fmt.Printf("%s|\t", ts) + fmt.Printf("%d|\t", id) + fmt.Printf("%10s|\t", name) + fmt.Printf("%d|\t", len) + fmt.Printf("%t|\t", flag) + fmt.Printf("%s|\t", notes) + fmt.Printf("%06.3f|\t", fv) + fmt.Printf("%09.6f|\n\n", dv) + + affectd++ + } + + et := time.Now().Nanosecond() + fmt.Printf("select data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) + //fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) +} + +func drop_database_stmt(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // drop test db + res, err := db.Exec("drop database if exists " + demodb) + checkErr(err, "drop database "+demodb) + + affectd, err := res.RowsAffected() + checkErr(err, "drop db, res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("drop database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func create_database_stmt(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // create database + //var stmt interface{} + stmt, err := db.Prepare("create database ?") + checkErr(err, "create db, db.Prepare") + + //var res driver.Result + res, err := stmt.Exec(demodb) + checkErr(err, "create db, stmt.Exec") + + //fmt.Printf("Query OK, %d row(s) affected()", res.RowsAffected()) + affectd, err := res.RowsAffected() + checkErr(err, "create db, res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("create database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func use_database_stmt(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // create database + //var stmt interface{} + stmt, err := db.Prepare("use " + demodb) + checkErr(err, "use db, db.Prepare") + + res, err := stmt.Exec() + checkErr(err, "use db, stmt.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "use db, res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("use database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func create_table_stmt(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + // create table + // (ts timestamp, id int, name binary(8), len tinyint, flag bool, notes binary(8), fv float, dv double) + stmt, err := db.Prepare("create table ? (? timestamp, ? int, ? binary(10), ? tinyint, ? bool, ? binary(8), ? float, ? double)") + checkErr(err, "create table db.Prepare") + + res, err := stmt.Exec(demot, "ts", "id", "name", "len", "flag", "notes", "fv", "dv") + checkErr(err, "create table stmt.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "create table res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("create table result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func insert_data_stmt(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + // insert data into table + stmt, err := db.Prepare("insert into ? values(?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?)") + checkErr(err, "insert db.Prepare") + + res, err := stmt.Exec(demot, "now", 1000, "'haidian'", 6, true, "'AI world'", 6987.654, 321.987, + "now+1s", 1001, "'changyang'", 7, false, "'DeepMode'", 12356.456, 128634.456, + "now+2s", 1002, "'chuangping'", 8, true, "'database'", 3879.456, 65433478.456) + checkErr(err, "insert data, stmt.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func select_data_stmt(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + + stmt, err := db.Prepare("select ?, ?, ?, ?, ?, ?, ?, ? from ?") // go binary mode + checkErr(err, "db.Prepare") + + rows, err := stmt.Query("ts", "id", "name", "len", "flag", "notes", "fv", "dv", demot) + checkErr(err, "stmt.Query") + + fmt.Printf("%10s%s%8s %5s %8s%s %s %10s%s %7s%s %8s%s %11s%s %14s%s\n", " ", "ts", " ", "id", " ", "name", " ", "len", " ", "flag", " ", "notes", " ", "fv", " ", " ", "dv") + var affectd int + for rows.Next() { + var ts string + var name string + var id int + var len int8 + var flag bool + var notes string + var fv float32 + var dv float64 + + err = rows.Scan(&ts, &id, &name, &len, &flag, ¬es, &fv, &dv) + //fmt.Println("start scan fields from row.rs, &fv:", &fv) + //err = rows.Scan(&fv) + checkErr(err, "rows.Scan") + + fmt.Printf("%s|\t", ts) + fmt.Printf("%d|\t", id) + fmt.Printf("%10s|\t", name) + fmt.Printf("%d|\t", len) + fmt.Printf("%t|\t", flag) + fmt.Printf("%s|\t", notes) + fmt.Printf("%06.3f|\t", fv) + fmt.Printf("%09.6f|\n", dv) + + affectd++ + + } + + et := time.Now().Nanosecond() + fmt.Printf("select data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func checkErr(err error, prompt string) { + if err != nil { + fmt.Printf("%s\n", prompt) + panic(err) + } +} diff --git a/tests/gotest/case001/case001.sh b/tests/gotest/case001/case001.sh new file mode 100644 index 0000000000000000000000000000000000000000..831e9f83ac482c0a2c668e2ad0d16c4bf59f19aa --- /dev/null +++ b/tests/gotest/case001/case001.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +echo "==== start run cases001.go" + +set +e +#set -x + +script_dir="$(dirname $(readlink -f $0))" +#echo "pwd: $script_dir, para0: $0" + +#execName=$0 +#execName=`echo ${execName##*/}` +#goName=`echo ${execName%.*}` + +###### step 3: start build +cd $script_dir +rm -f go.* +go mod init demotest +go build +sleep 1s +./demotest -h $1 -p $2 diff --git a/tests/gotest/test.sh b/tests/gotest/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fe80d4429546513521286db657a961e0ca8ffc14 --- /dev/null +++ b/tests/gotest/test.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +################################################## +# +# Do go test +# +################################################## + +set +e +#set -x + +FILE_NAME= +RELEASE=0 +while getopts "f:" arg +do + case $arg in + f) + FILE_NAME=$OPTARG + echo "input file: $FILE_NAME" + ;; + ?) + echo "unknow argument" + ;; + esac +done + +# start one taosd +bash ../script/sh/stop_dnodes.sh +bash ../script/sh/deploy.sh -n dnode1 -i 1 +bash ../script/sh/cfg.sh -n dnode1 -c walLevel -v 0 +bash ../script/sh/exec.sh -n dnode1 -s start + +# start build test go file +caseDir=`echo ${FILE_NAME%/*}` +echo "caseDir: $caseDir" +cd $caseDir +rm go.* +go mod init $caseDir +go build +sleep 1s +./$caseDir + diff --git a/tests/perftest-scripts/coverage_test.sh b/tests/perftest-scripts/coverage_test.sh index a0c8fe4b3fe7c3477e233f1628d5ecf7d0744ec1..5085ec89d00def1a2147f24ccbeb488406541775 100755 --- a/tests/perftest-scripts/coverage_test.sh +++ b/tests/perftest-scripts/coverage_test.sh @@ -53,7 +53,7 @@ function buildTDengine { function runGeneralCaseOneByOne { while read -r line; do if [[ $line =~ ^./test.sh* ]]; then - case=`echo $line | grep -w "general\|unique\/mnode\/mgmt33.sim\|unique\/stable\/dnode3.sim\|unique\/cluster\/balance3.sim\|unique\/arbitrator\/offline_replica2_alterTable_online.sim"|awk '{print $NF}'` + case=`echo $line | grep sim$ |awk '{print $NF}'` if [ -n "$case" ]; then ./test.sh -f $case > /dev/null 2>&1 && \ diff --git a/tests/pytest/client/alterDatabase.py b/tests/pytest/client/alterDatabase.py new file mode 100644 index 0000000000000000000000000000000000000000..fa397d16c57625d53f6f1b2772afa99ade314e1a --- /dev/null +++ b/tests/pytest/client/alterDatabase.py @@ -0,0 +1,55 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.query('select database()') + tdSql.checkData(0, 0, "db") + + tdSql.execute("alter database db comp 2") + tdSql.query("show databases") + tdSql.checkData(0, 14, 2) + + tdSql.execute("alter database db keep 365") + tdSql.query("show databases") + tdSql.checkData(0, 7, "3650,3650,365") + + tdSql.execute("alter database db quorum 2") + tdSql.query("show databases") + tdSql.checkData(0, 5, 2) + + tdSql.execute("alter database db blocks 100") + tdSql.query("show databases") + tdSql.checkData(0, 9, 100) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/client/twoClients.py b/tests/pytest/client/twoClients.py new file mode 100644 index 0000000000000000000000000000000000000000..1a1b36c55438f8ea4050bb804b739be71c570960 --- /dev/null +++ b/tests/pytest/client/twoClients.py @@ -0,0 +1,96 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +import sys +sys.path.insert(0, os.getcwd()) +from util.log import * +from util.sql import * +from util.dnodes import * +import taos + + +class TwoClients: + def initConnection(self): + self.host = "127.0.0.1" + self.user = "root" + self.password = "taosdata" + self.config = "/home/xp/git/TDengine/sim/dnode1/cfg" + + def run(self): + tdDnodes.init("") + tdDnodes.setTestCluster(False) + tdDnodes.setValgrind(False) + + tdDnodes.stopAll() + tdDnodes.deploy(1) + tdDnodes.start(1) + + # first client create a stable and insert data + conn1 = taos.connect(self.host, self.user, self.password, self.config) + cursor1 = conn1.cursor() + cursor1.execute("drop database if exists db") + cursor1.execute("create database db") + cursor1.execute("use db") + cursor1.execute("create table tb (ts timestamp, id int) tags(loc nchar(30))") + cursor1.execute("insert into t0 using tb tags('beijing') values(now, 1)") + + # second client alter the table created by cleint + conn2 = taos.connect(self.host, self.user, self.password, self.config) + cursor2 = conn2.cursor() + cursor2.execute("use db") + cursor2.execute("alter table tb add column name nchar(30)") + + # first client should not be able to use the origin metadata + tdSql.init(cursor1, True) + tdSql.error("insert into t0 values(now, 2)") + + # first client should be able to insert data with udpated medadata + tdSql.execute("insert into t0 values(now, 2, 'test')") + tdSql.query("select * from tb") + tdSql.checkRows(2) + + # second client drop the table + cursor2.execute("drop table t0") + cursor2.execute("create table t0 using tb tags('beijing')") + + tdSql.execute("insert into t0 values(now, 2, 'test')") + tdSql.query("select * from tb") + tdSql.checkRows(1) + + # error expected for two clients drop the same cloumn + cursor2.execute("alter table tb drop column name") + tdSql.error("alter table tb drop column name") + + cursor2.execute("alter table tb add column speed int") + tdSql.error("alter table tb add column speed int") + + + tdSql.execute("alter table tb add column size int") + tdSql.query("describe tb") + tdSql.checkRows(5) + tdSql.checkData(0, 0, "ts") + tdSql.checkData(1, 0, "id") + tdSql.checkData(2, 0, "speed") + tdSql.checkData(3, 0, "size") + tdSql.checkData(4, 0, "loc") + + + cursor1.close() + cursor2.close() + conn1.close() + conn2.close() + +clients = TwoClients() +clients.initConnection() +clients.run() \ No newline at end of file diff --git a/tests/pytest/cluster/bananceTest.py b/tests/pytest/cluster/bananceTest.py new file mode 100644 index 0000000000000000000000000000000000000000..ef25afa7d2f7ea3b5358f8ba74d6702d28d54c85 --- /dev/null +++ b/tests/pytest/cluster/bananceTest.py @@ -0,0 +1,57 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random +import time + +class ClusterTestcase: + + ## test case 32 ## + def run(self): + + nodes = Nodes() + nodes.addConfigs("maxVgroupsPerDb", "10") + nodes.addConfigs("maxTablesPerVnode", "1000") + nodes.restartAllTaosd() + + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + ctest.createSTable(1) + ctest.run() + tdSql.init(ctest.conn.cursor(), False) + + tdSql.execute("use %s" % ctest.dbName) + tdSql.query("show vgroups") + dnodes = [] + for i in range(10): + dnodes.append(int(tdSql.getData(i, 4))) + + s = set(dnodes) + if len(s) < 3: + tdLog.exit("cluster is not balanced") + + tdLog.info("cluster is balanced") + + nodes.removeConfigs("maxVgroupsPerDb", "10") + nodes.removeConfigs("maxTablesPerVnode", "1000") + nodes.restartAllTaosd() + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() diff --git a/tests/pytest/cluster/basicTest.py b/tests/pytest/cluster/basicTest.py new file mode 100644 index 0000000000000000000000000000000000000000..b990d7fd982a490383939707a32635d37e546b13 --- /dev/null +++ b/tests/pytest/cluster/basicTest.py @@ -0,0 +1,47 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 1, 33 ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + + ctest.connectDB() + tdSql.init(ctest.conn.cursor(), False) + + ## Test case 1 ## + tdLog.info("Test case 1 repeat %d times" % ctest.repeat) + for i in range(ctest.repeat): + tdLog.info("Start Round %d" % (i + 1)) + replica = random.randint(1,3) + ctest.createSTable(replica) + ctest.run() + tdLog.sleep(10) + tdSql.query("select count(*) from %s.%s" %(ctest.dbName, ctest.stbName)) + tdSql.checkData(0, 0, ctest.numberOfRecords * ctest.numberOfTables) + tdLog.info("Round %d completed" % (i + 1)) + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() \ No newline at end of file diff --git a/tests/pytest/cluster/changeReplicaTest.py b/tests/pytest/cluster/changeReplicaTest.py new file mode 100644 index 0000000000000000000000000000000000000000..7fa68edbfee2db599076befdf9bed5f4b4be3c83 --- /dev/null +++ b/tests/pytest/cluster/changeReplicaTest.py @@ -0,0 +1,51 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 7, ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + tdSql.init(ctest.conn.cursor(), False) + + tdSql.execute("use %s" % ctest.dbName) + tdSql.query("show vgroups") + for i in range(10): + tdSql.checkData(i, 5, "master") + + tdSql.execute("alter database %s replica 2" % ctest.dbName) + tdLog.sleep(30) + tdSql.query("show vgroups") + for i in range(10): + tdSql.checkData(i, 5, "master") + tdSql.checkData(i, 7, "slave") + + tdSql.execute("alter database %s replica 3" % ctest.dbName) + tdLog.sleep(30) + tdSql.query("show vgroups") + for i in range(10): + tdSql.checkData(i, 5, "master") + tdSql.checkData(i, 7, "slave") + tdSql.checkData(i, 9, "slave") + +ct = ClusterTestcase() +ct.run() \ No newline at end of file diff --git a/tests/pytest/cluster/clusterSetup.py b/tests/pytest/cluster/clusterSetup.py new file mode 100644 index 0000000000000000000000000000000000000000..36af8ac42e56e1b8a7ab2237305a6bf286103552 --- /dev/null +++ b/tests/pytest/cluster/clusterSetup.py @@ -0,0 +1,202 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +import sys +sys.path.insert(0, os.getcwd()) +from fabric import Connection +from util.sql import * +from util.log import * +import taos +import random +import threading +import logging + +class Node: + def __init__(self, index, username, hostIP, hostName, password, homeDir): + self.index = index + self.username = username + self.hostIP = hostIP + self.hostName = hostName + self.homeDir = homeDir + self.conn = Connection("{}@{}".format(username, hostName), connect_kwargs={"password": "{}".format(password)}) + + def startTaosd(self): + try: + self.conn.run("sudo systemctl start taosd") + except Exception as e: + print("Start Taosd error for node %d " % self.index) + logging.exception(e) + + def stopTaosd(self): + try: + self.conn.run("sudo systemctl stop taosd") + except Exception as e: + print("Stop Taosd error for node %d " % self.index) + logging.exception(e) + + def restartTaosd(self): + try: + self.conn.run("sudo systemctl restart taosd") + except Exception as e: + print("Stop Taosd error for node %d " % self.index) + logging.exception(e) + + def removeTaosd(self): + try: + self.conn.run("rmtaos") + except Exception as e: + print("remove taosd error for node %d " % self.index) + logging.exception(e) + + def installTaosd(self, packagePath): + self.conn.put(packagePath, self.homeDir) + self.conn.cd(self.homeDir) + self.conn.run("tar -zxf $(basename '%s')" % packagePath) + with self.conn.cd("TDengine-enterprise-server"): + self.conn.run("yes|./install.sh") + + def configTaosd(self, taosConfigKey, taosConfigValue): + self.conn.run("sudo echo '%s %s' >> %s" % (taosConfigKey, taosConfigValue, "/etc/taos/taos.cfg")) + + def removeTaosConfig(self, taosConfigKey, taosConfigValue): + self.conn.run("sudo sed -in-place -e '/%s %s/d' %s" % (taosConfigKey, taosConfigValue, "/etc/taos/taos.cfg")) + + def configHosts(self, ip, name): + self.conn.run("echo '%s %s' >> %s" % (ip, name, '/etc/hosts')) + + def removeData(self): + try: + self.conn.run("sudo rm -rf /var/lib/taos/*") + except Exception as e: + print("remove taosd data error for node %d " % self.index) + logging.exception(e) + + def removeLog(self): + try: + self.conn.run("sudo rm -rf /var/log/taos/*") + except Exception as e: + print("remove taosd error for node %d " % self.index) + logging.exception(e) + + def removeDataForMnode(self): + try: + self.conn.run("sudo rm -rf /var/lib/taos/*") + except Exception as e: + print("remove taosd error for node %d " % self.index) + logging.exception(e) + + def removeDataForVnode(self, id): + try: + self.conn.run("sudo rm -rf /var/lib/taos/vnode%d/*.data" % id) + except Exception as e: + print("remove taosd error for node %d " % self.index) + logging.exception(e) + +class Nodes: + def __init__(self): + self.node1 = Node(1, 'ubuntu', '192.168.1.52', 'node1', 'tbase125!', '/home/ubuntu') + self.node2 = Node(2, 'ubuntu', '192.168.1.53', 'node2', 'tbase125!', '/home/ubuntu') + self.node3 = Node(3, 'ubuntu', '192.168.1.54', 'node3', 'tbase125!', '/home/ubuntu') + + def stopAllTaosd(self): + self.node1.stopTaosd() + self.node2.stopTaosd() + self.node3.stopTaosd() + + def startAllTaosd(self): + self.node1.startTaosd() + self.node2.startTaosd() + self.node3.startTaosd() + + def restartAllTaosd(self): + self.node1.restartTaosd() + self.node2.restartTaosd() + self.node3.restartTaosd() + + def addConfigs(self, configKey, configValue): + self.node1.configTaosd(configKey, configValue) + self.node2.configTaosd(configKey, configValue) + self.node3.configTaosd(configKey, configValue) + + def removeConfigs(self, configKey, configValue): + self.node1.removeTaosConfig(configKey, configValue) + self.node2.removeTaosConfig(configKey, configValue) + self.node3.removeTaosConfig(configKey, configValue) + + def removeAllDataFiles(self): + self.node1.removeData() + self.node2.removeData() + self.node3.removeData() + +class ClusterTest: + def __init__(self, hostName): + self.host = hostName + self.user = "root" + self.password = "taosdata" + self.config = "/etc/taos" + self.dbName = "mytest" + self.stbName = "meters" + self.numberOfThreads = 20 + self.numberOfTables = 10000 + self.numberOfRecords = 1000 + self.tbPrefix = "t" + self.ts = 1538548685000 + self.repeat = 1 + + def connectDB(self): + self.conn = taos.connect( + host=self.host, + user=self.user, + password=self.password, + config=self.config) + + def createSTable(self, replica): + cursor = self.conn.cursor() + tdLog.info("drop database if exists %s" % self.dbName) + cursor.execute("drop database if exists %s" % self.dbName) + tdLog.info("create database %s replica %d" % (self.dbName, replica)) + cursor.execute("create database %s replica %d" % (self.dbName, replica)) + tdLog.info("use %s" % self.dbName) + cursor.execute("use %s" % self.dbName) + tdLog.info("drop table if exists %s" % self.stbName) + cursor.execute("drop table if exists %s" % self.stbName) + tdLog.info("create table %s(ts timestamp, current float, voltage int, phase int) tags(id int)" % self.stbName) + cursor.execute("create table %s(ts timestamp, current float, voltage int, phase int) tags(id int)" % self.stbName) + cursor.close() + + def insertData(self, threadID): + print("Thread %d: starting" % threadID) + cursor = self.conn.cursor() + tablesPerThread = int(self.numberOfTables / self.numberOfThreads) + baseTableID = tablesPerThread * threadID + for i in range (tablesPerThread): + cursor.execute("create table %s%d using %s tags(%d)" % (self.tbPrefix, baseTableID + i, self.stbName, baseTableID + i)) + query = "insert into %s%d values" % (self.tbPrefix, baseTableID + i) + base = self.numberOfRecords * i + for j in range(self.numberOfRecords): + query += "(%d, %f, %d, %d)" % (self.ts + base + j, random.random(), random.randint(210, 230), random.randint(0, 10)) + cursor.execute(query) + cursor.close() + print("Thread %d: finishing" % threadID) + + def run(self): + threads = [] + tdLog.info("Inserting data") + for i in range(self.numberOfThreads): + thread = threading.Thread(target=self.insertData, args=(i,)) + threads.append(thread) + thread.start() + + for i in range(self.numberOfThreads): + threads[i].join() \ No newline at end of file diff --git a/tests/pytest/cluster/dataFileRecoveryTest.py b/tests/pytest/cluster/dataFileRecoveryTest.py new file mode 100644 index 0000000000000000000000000000000000000000..089d3fffc1499a8d9cafc87a8d94252111fcd604 --- /dev/null +++ b/tests/pytest/cluster/dataFileRecoveryTest.py @@ -0,0 +1,53 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 20, 21, 22 ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + ctest.createSTable(3) + ctest.run() + tdSql.init(ctest.conn.cursor(), False) + + nodes.node2.stopTaosd() + tdSql.execute("use %s" % ctest.dbName) + tdSql.query("show vgroups") + vnodeID = tdSql.getData(0, 0) + nodes.node2.removeDataForVnode(vnodeID) + nodes.node2.startTaosd() + + # Wait for vnode file to recover + for i in range(10): + tdSql.query("select count(*) from t0") + + tdLog.sleep(10) + + for i in range(10): + tdSql.query("select count(*) from t0") + tdSql.checkData(0, 0, 1000) + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() diff --git a/tests/pytest/cluster/fullDnodesTest.py b/tests/pytest/cluster/fullDnodesTest.py new file mode 100644 index 0000000000000000000000000000000000000000..3c4b10d97a24dfbb156122aa0afdbb5d22ce3941 --- /dev/null +++ b/tests/pytest/cluster/fullDnodesTest.py @@ -0,0 +1,47 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ##Cover test case 5 ## + def run(self): + # cluster environment set up + nodes = Nodes() + nodes.addConfigs("maxVgroupsPerDb", "10") + nodes.addConfigs("maxTablesPerVnode", "1000") + nodes.restartAllTaosd() + + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + ctest.createSTable(1) + ctest.run() + + tdSql.init(ctest.conn.cursor(), False) + tdSql.execute("use %s" % ctest.dbName) + tdSql.error("create table tt1 using %s tags(1)" % ctest.stbName) + + nodes.removeConfigs("maxVgroupsPerDb", "10") + nodes.removeConfigs("maxTablesPerVnode", "1000") + nodes.restartAllTaosd() + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() \ No newline at end of file diff --git a/tests/pytest/cluster/killAndRestartDnodesTest.py b/tests/pytest/cluster/killAndRestartDnodesTest.py new file mode 100644 index 0000000000000000000000000000000000000000..be927e862f616c7fbe490e733a18984b6971ef1f --- /dev/null +++ b/tests/pytest/cluster/killAndRestartDnodesTest.py @@ -0,0 +1,75 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 7, 10 ## + def run(self): + # cluster environment set up + tdLog.info("Test case 7, 10") + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + tdSql.init(ctest.conn.cursor(), False) + + nodes.node1.stopTaosd() + tdSql.query("show dnodes") + tdSql.checkRows(3) + tdSql.checkData(0, 4, "offline") + tdSql.checkData(1, 4, "ready") + tdSql.checkData(2, 4, "ready") + + nodes.node1.startTaosd() + tdSql.checkRows(3) + tdSql.checkData(0, 4, "ready") + tdSql.checkData(1, 4, "ready") + tdSql.checkData(2, 4, "ready") + + nodes.node2.stopTaosd() + tdSql.query("show dnodes") + tdSql.checkRows(3) + tdSql.checkData(0, 4, "ready") + tdSql.checkData(1, 4, "offline") + tdSql.checkData(2, 4, "ready") + + nodes.node2.startTaosd() + tdSql.checkRows(3) + tdSql.checkData(0, 4, "ready") + tdSql.checkData(1, 4, "ready") + tdSql.checkData(2, 4, "ready") + + nodes.node3.stopTaosd() + tdSql.query("show dnodes") + tdSql.checkRows(3) + tdSql.checkData(0, 4, "ready") + tdSql.checkData(1, 4, "ready") + tdSql.checkData(2, 4, "offline") + + nodes.node3.startTaosd() + tdSql.checkRows(3) + tdSql.checkData(0, 4, "ready") + tdSql.checkData(1, 4, "ready") + tdSql.checkData(2, 4, "ready") + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() \ No newline at end of file diff --git a/tests/pytest/cluster/offlineThresholdTest.py b/tests/pytest/cluster/offlineThresholdTest.py new file mode 100644 index 0000000000000000000000000000000000000000..8373424f93c8217250907e09620c8523d63071ad --- /dev/null +++ b/tests/pytest/cluster/offlineThresholdTest.py @@ -0,0 +1,54 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## cover test case 6, 8, 9, 11 ## + def run(self): + # cluster environment set up + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + tdSql.init(ctest.conn.cursor(), False) + + nodes.addConfigs("offlineThreshold", "10") + nodes.removeAllDataFiles() + nodes.restartAllTaosd() + nodes.node3.stopTaosd() + + tdLog.sleep(10) + tdSql.query("show dnodes") + tdSql.checkRows(3) + tdSql.checkData(2, 4, "offline") + + tdLog.sleep(60) + tdSql.checkRows(3) + tdSql.checkData(2, 4, "dropping") + + tdLog.sleep(300) + tdSql.checkRows(2) + + nodes.removeConfigs("offlineThreshold", "10") + nodes.restartAllTaosd() + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() \ No newline at end of file diff --git a/tests/pytest/cluster/oneReplicaOfflineTest.py b/tests/pytest/cluster/oneReplicaOfflineTest.py new file mode 100644 index 0000000000000000000000000000000000000000..0223dfe01add9faca7987d7767f5c41a58b8edd2 --- /dev/null +++ b/tests/pytest/cluster/oneReplicaOfflineTest.py @@ -0,0 +1,65 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 28, 29, 30, 31 ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + ctest.createSTable(3) + ctest.run() + tdSql.init(ctest.conn.cursor(), False) + + tdSql.execute("use %s" % ctest.dbName) + + nodes.node2.stopTaosd() + for i in range(100): + tdSql.execute("drop table t%d" % i) + + nodes.node2.startTaosd() + tdSql.query("show tables") + tdSql.checkRows(9900) + + nodes.node2.stopTaosd() + for i in range(10): + tdSql.execute("create table a%d using meters tags(2)" % i) + + nodes.node2.startTaosd() + tdSql.query("show tables") + tdSql.checkRows(9910) + + nodes.node2.stopTaosd() + tdSql.execute("alter table meters add col col6 int") + nodes.node2.startTaosd() + + nodes.node2.stopTaosd() + tdSql.execute("drop database %s" % ctest.dbName) + + nodes.node2.startTaosd() + tdSql.query("show databases") + tdSql.checkRows(0) + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() diff --git a/tests/pytest/cluster/queryTimeTest.py b/tests/pytest/cluster/queryTimeTest.py new file mode 100644 index 0000000000000000000000000000000000000000..74a9081ccf4fd8abc175e2e0c82b0c6feedcbb26 --- /dev/null +++ b/tests/pytest/cluster/queryTimeTest.py @@ -0,0 +1,54 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random +import time + +class ClusterTestcase: + + ## test case 32 ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + ctest.createSTable(1) + ctest.run() + tdSql.init(ctest.conn.cursor(), False) + + tdSql.execute("use %s" % ctest.dbName) + totalTime = 0 + for i in range(10): + startTime = time.time() + tdSql.query("select * from %s" % ctest.stbName) + totalTime += time.time() - startTime + print("replica 1: avarage query time for %d records: %f seconds" % (ctest.numberOfTables * ctest.numberOfRecords,totalTime / 10)) + + tdSql.execute("alter database %s replica 3" % ctest.dbName) + tdLog.sleep(60) + totalTime = 0 + for i in range(10): + startTime = time.time() + tdSql.query("select * from %s" % ctest.stbName) + totalTime += time.time() - startTime + print("replica 3: avarage query time for %d records: %f seconds" % (ctest.numberOfTables * ctest.numberOfRecords,totalTime / 10)) + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() diff --git a/tests/pytest/cluster/stopAllDnodesTest.py b/tests/pytest/cluster/stopAllDnodesTest.py new file mode 100644 index 0000000000000000000000000000000000000000..a71ae52e3d7a640bb589f3bafe16b2e4d45c7b93 --- /dev/null +++ b/tests/pytest/cluster/stopAllDnodesTest.py @@ -0,0 +1,45 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 19 ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + tdSql.init(ctest.conn.cursor(), False) + + tdSql.query("show databases") + count = tdSql.queryRows; + + nodes.stopAllTaosd() + nodes.node1.startTaosd() + tdSql.error("show databases") + + nodes.node2.startTaosd() + tdSql.error("show databases") + + nodes.node3.startTaosd() + tdLog.sleep(10) + tdSql.query("show databases") + tdSql.checkRows(count) + +ct = ClusterTestcase() +ct.run() diff --git a/tests/pytest/cluster/stopTwoDnodesTest.py b/tests/pytest/cluster/stopTwoDnodesTest.py new file mode 100644 index 0000000000000000000000000000000000000000..9e9958e2d32018b6a89a3e0d08da2c1597151ff2 --- /dev/null +++ b/tests/pytest/cluster/stopTwoDnodesTest.py @@ -0,0 +1,48 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 17, 18 ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + ctest.createSTable(1) + ctest.run() + tdSql.init(ctest.conn.cursor(), False) + + tdSql.query("show databases") + count = tdSql.queryRows; + tdSql.execute("use %s" % ctest.dbName) + tdSql.execute("alter database %s replica 3" % ctest.dbName) + nodes.node2.stopTaosd() + nodes.node3.stopTaosd() + tdSql.error("show databases") + + nodes.node2.startTaosd() + tdSql.error("show databases") + + nodes.node3.startTaosd() + tdSql.query("show databases") + tdSql.checkRows(count) + +ct = ClusterTestcase() +ct.run() diff --git a/tests/pytest/cluster/syncingTest.py b/tests/pytest/cluster/syncingTest.py new file mode 100644 index 0000000000000000000000000000000000000000..96be048d231e35f67e40fc4785d2e19337ed408b --- /dev/null +++ b/tests/pytest/cluster/syncingTest.py @@ -0,0 +1,50 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 24, 25, 26, 27 ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + ctest.createSTable(1) + ctest.run() + tdSql.init(ctest.conn.cursor(), False) + + + tdSql.execute("use %s" % ctest.dbName) + tdSql.execute("alter database %s replica 3" % ctest.dbName) + + for i in range(100): + tdSql.execute("drop table t%d" % i) + + for i in range(100): + tdSql.execute("create table a%d using meters tags(1)" % i) + + tdSql.execute("alter table meters add col col5 int") + tdSql.execute("alter table meters drop col col5 int") + tdSql.execute("drop database %s" % ctest.dbName) + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() diff --git a/tests/pytest/cluster/testcluster.sh b/tests/pytest/cluster/testcluster.sh new file mode 100644 index 0000000000000000000000000000000000000000..6e15a498c0a73db450699fe66d63d07c3b18dbe5 --- /dev/null +++ b/tests/pytest/cluster/testcluster.sh @@ -0,0 +1,12 @@ +python3 basicTest.py +python3 bananceTest.py +python3 changeReplicaTest.py +python3 dataFileRecoveryTest.py +python3 fullDnodesTest.py +python3 killAndRestartDnodesTest.py +python3 offlineThresholdTest.py +python3 oneReplicaOfflineTest.py +python3 queryTimeTest.py +python3 stopAllDnodesTest.py +python3 stopTwoDnodesTest.py +python3 syncingTest.py \ No newline at end of file diff --git a/tests/pytest/concurrent_inquiry.py b/tests/pytest/concurrent_inquiry.py new file mode 100644 index 0000000000000000000000000000000000000000..39a4cb48fdc22060f63f443a4ac8142cd6a6903e --- /dev/null +++ b/tests/pytest/concurrent_inquiry.py @@ -0,0 +1,169 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import threading +import taos +import sys +import json +import time +import random +# query sql +query_sql = [ +# first supertable +"select count(*) from test.meters ;", +"select count(*) from test.meters where t3 > 2;", +"select count(*) from test.meters where ts <> '2020-05-13 10:00:00.002';", +"select count(*) from test.meters where t7 like 'taos_1%';", +"select count(*) from test.meters where t7 like '_____2';", +"select count(*) from test.meters where t8 like '%思%';", +"select count(*) from test.meters interval(1n) order by ts desc;", +#"select max(c0) from test.meters group by tbname", +"select first(ts) from test.meters where t5 >5000 and t5<5100;", +"select last(ts) from test.meters where t5 >5000 and t5<5100;", +"select last_row(*) from test.meters;", +"select twa(c1) from test.t1 where ts > 1500000001000 and ts < 1500000101000" , +"select avg(c1) from test.meters where t5 >5000 and t5<5100;", +"select bottom(c1, 2) from test.t1;", +"select diff(c1) from test.t1;", +"select leastsquares(c1, 1, 1) from test.t1 ;", +"select max(c1) from test.meters where t5 >5000 and t5<5100;", +"select min(c1) from test.meters where t5 >5000 and t5<5100;", +"select c1 + c2 + c1 / c5 + c4 + c2 from test.t1;", +"select percentile(c1, 50) from test.t1;", +"select spread(c1) from test.t1 ;", +"select stddev(c1) from test.t1;", +"select sum(c1) from test.meters where t5 >5000 and t5<5100;", +"select top(c1, 2) from test.meters where t5 >5000 and t5<5100;" +"select twa(c4) from test.t1 where ts > 1500000001000 and ts < 1500000101000" , +"select avg(c4) from test.meters where t5 >5000 and t5<5100;", +"select bottom(c4, 2) from test.t1 where t5 >5000 and t5<5100;", +"select diff(c4) from test.t1 where t5 >5000 and t5<5100;", +"select leastsquares(c4, 1, 1) from test.t1 ;", +"select max(c4) from test.meters where t5 >5000 and t5<5100;", +"select min(c4) from test.meters where t5 >5000 and t5<5100;", +"select c5 + c2 + c4 / c5 + c4 + c2 from test.t1 ;", +"select percentile(c5, 50) from test.t1;", +"select spread(c5) from test.t1 ;", +"select stddev(c5) from test.t1 where t5 >5000 and t5<5100;", +"select sum(c5) from test.meters where t5 >5000 and t5<5100;", +"select top(c5, 2) from test.meters where t5 >5000 and t5<5100;", +#all vnode +"select count(*) from test.meters where t5 >5000 and t5<5100", +"select max(c0),avg(c1) from test.meters where t5 >5000 and t5<5100", +"select sum(c5),avg(c1) from test.meters where t5 >5000 and t5<5100", +"select max(c0),min(c5) from test.meters where t5 >5000 and t5<5100", +"select min(c0),avg(c5) from test.meters where t5 >5000 and t5<5100", +# second supertable +"select count(*) from test.meters1 where t3 > 2;", +"select count(*) from test.meters1 where ts <> '2020-05-13 10:00:00.002';", +"select count(*) from test.meters where t7 like 'taos_1%';", +"select count(*) from test.meters where t7 like '_____2';", +"select count(*) from test.meters where t8 like '%思%';", +"select count(*) from test.meters1 interval(1n) order by ts desc;", +#"select max(c0) from test.meters1 group by tbname", +"select first(ts) from test.meters1 where t5 >5000 and t5<5100;", +"select last(ts) from test.meters1 where t5 >5000 and t5<5100;", +"select last_row(*) from test.meters1 ;", +"select twa(c1) from test.m1 where ts > 1500000001000 and ts < 1500000101000" , +"select avg(c1) from test.meters1 where t5 >5000 and t5<5100;", +"select bottom(c1, 2) from test.m1 where t5 >5000 and t5<5100;", +"select diff(c1) from test.m1 ;", +"select leastsquares(c1, 1, 1) from test.m1 ;", +"select max(c1) from test.meters1 where t5 >5000 and t5<5100;", +"select min(c1) from test.meters1 where t5 >5000 and t5<5100;", +"select c1 + c2 + c1 / c0 + c2 from test.m1 ;", +"select percentile(c1, 50) from test.m1;", +"select spread(c1) from test.m1 ;", +"select stddev(c1) from test.m1;", +"select sum(c1) from test.meters1 where t5 >5000 and t5<5100;", +"select top(c1, 2) from test.meters1 where t5 >5000 and t5<5100;", +"select twa(c5) from test.m1 where ts > 1500000001000 and ts < 1500000101000" , +"select avg(c5) from test.meters1 where t5 >5000 and t5<5100;", +"select bottom(c5, 2) from test.m1;", +"select diff(c5) from test.m1;", +"select leastsquares(c5, 1, 1) from test.m1 ;", +"select max(c5) from test.meters1 where t5 >5000 and t5<5100;", +"select min(c5) from test.meters1 where t5 >5000 and t5<5100;", +"select c5 + c2 + c4 / c5 + c0 from test.m1;", +"select percentile(c4, 50) from test.m1;", +"select spread(c4) from test.m1 ;", +"select stddev(c4) from test.m1;", +"select sum(c4) from test.meters1 where t5 >5100 and t5<5300;", +"select top(c4, 2) from test.meters1 where t5 >5100 and t5<5300;", +"select count(*) from test.meters1 where t5 >5100 and t5<5300", +#all vnode +"select count(*) from test.meters1 where t5 >5100 and t5<5300", +"select max(c0),avg(c1) from test.meters1 where t5 >5000 and t5<5100", +"select sum(c5),avg(c1) from test.meters1 where t5 >5000 and t5<5100", +"select max(c0),min(c5) from test.meters1 where t5 >5000 and t5<5100", +"select min(c0),avg(c5) from test.meters1 where t5 >5000 and t5<5100", +#join +# "select * from meters,meters1 where meters.ts = meters1.ts and meters.t5 = meters1.t5", +# "select * from meters,meters1 where meters.ts = meters1.ts and meters.t7 = meters1.t7", +# "select * from meters,meters1 where meters.ts = meters1.ts and meters.t8 = meters1.t8", +# "select meters.ts,meters1.c2 from meters,meters1 where meters.ts = meters1.ts and meters.t8 = meters1.t8" +] + +class ConcurrentInquiry: + def initConnection(self): + self.numOfTherads = 50 + self.ts=1500000001000 + + def SetThreadsNum(self,num): + self.numOfTherads=num + def query_thread(self,threadID): + host = "10.211.55.14" + user = "root" + password = "taosdata" + conn = taos.connect( + host, + user, + password, + ) + cl = conn.cursor() + cl.execute("use test;") + + print("Thread %d: starting" % threadID) + + while True: + ran_query_sql=query_sql + random.shuffle(ran_query_sql) + for i in ran_query_sql: + print("Thread %d : %s"% (threadID,i)) + try: + start = time.time() + cl.execute(i) + cl.fetchall + end = time.time() + print("time cost :",end-start) + except Exception as e: + print( + "Failure thread%d, sql: %s,exception: %s" % + (threadID, str(i),str(e))) + exit(-1) + + + print("Thread %d: finishing" % threadID) + + + + def run(self): + + threads = [] + for i in range(self.numOfTherads): + thread = threading.Thread(target=self.query_thread, args=(i,)) + threads.append(thread) + thread.start() + +q = ConcurrentInquiry() +q.initConnection() +q.run() diff --git a/tests/pytest/crash_gen.sh b/tests/pytest/crash_gen.sh index df1a9f595b986215deb69a5f9f99a3a5847f41dd..9cca23ac79e89224593bade2ed518eaa0ecd3da0 100755 --- a/tests/pytest/crash_gen.sh +++ b/tests/pytest/crash_gen.sh @@ -35,18 +35,46 @@ CURR_DIR=`pwd` IN_TDINTERNAL="community" if [[ "$CURR_DIR" == *"$IN_TDINTERNAL"* ]]; then TAOS_DIR=$CURR_DIR/../../.. + TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1` + LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6,7|rev`/lib else TAOS_DIR=$CURR_DIR/../.. + TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1` + LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/lib fi -TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1` -LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/lib +# Now getting ready to execute Python +# The following is the default of our standard dev env (Ubuntu 20.04), modify/adjust at your own risk +PYTHON_EXEC=python3.8 # First we need to set up a path for Python to find our own TAOS modules, so that "import" can work. -export PYTHONPATH=$(pwd)/../../src/connector/python/linux/python3 +export PYTHONPATH=$(pwd)/../../src/connector/python/linux/python3:$(pwd) # Then let us set up the library path so that our compiled SO file can be loaded by Python export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_DIR # Now we are all let, and let's see if we can find a crash. Note we pass all params -python3.8 ./crash_gen.py $@ +CRASH_GEN_EXEC=crash_gen_bootstrap.py +if [[ $1 == '--valgrind' ]]; then + shift + export PYTHONMALLOC=malloc + VALGRIND_OUT=valgrind.out + VALGRIND_ERR=valgrind.err + # How to generate valgrind suppression file: https://stackoverflow.com/questions/17159578/generating-suppressions-for-memory-leaks + # valgrind --leak-check=full --gen-suppressions=all --log-fd=9 python3.8 ./crash_gen.py $@ 9>>memcheck.log + echo Executing under VALGRIND, with STDOUT/ERR going to $VALGRIND_OUT and $VALGRIND_ERR, please watch them from a different terminal. + valgrind \ + --leak-check=yes \ + --suppressions=crash_gen/valgrind_taos.supp \ + $PYTHON_EXEC \ + $CRASH_GEN_EXEC $@ > $VALGRIND_OUT 2> $VALGRIND_ERR +elif [[ $1 == '--helgrind' ]]; then + shift + valgrind \ + --tool=helgrind \ + $PYTHON_EXEC \ + $CRASH_GEN_EXEC $@ +else + $PYTHON_EXEC $CRASH_GEN_EXEC $@ +fi + diff --git a/tests/pytest/crash_gen/README.md b/tests/pytest/crash_gen/README.md new file mode 100644 index 0000000000000000000000000000000000000000..6788ab1a63d0a7c515558695605d1ec8ac5fb7f9 --- /dev/null +++ b/tests/pytest/crash_gen/README.md @@ -0,0 +1,130 @@ +

    User's Guide to the Crash_Gen Tool

    + +# Introduction + +To effectively test and debug our TDengine product, we have developed a simple tool to +exercise various functions of the system in a randomized fashion, hoping to expose +maximum number of problems, hopefully without a pre-determined scenario. + +# Preparation + +To run this tool, please ensure the followed preparation work is done first. + +1. Fetch a copy of the TDengine source code, and build it successfully in the `build/` + directory +1. Ensure that the system has Python3.8 or above properly installed. We use + Ubuntu 20.04LTS as our own development environment, and suggest you also use such + an environment if possible. + +# Simple Execution + +To run the tool with the simplest method, follow the steps below: + +1. Open a terminal window, start the `taosd` service in the `build/` directory + (or however you prefer to start the `taosd` service) +1. Open another terminal window, go into the `tests/pytest/` directory, and + run `./crash_gen.sh -p -t 3 -s 10` (change the two parameters here as you wish) +1. Watch the output to the end and see if you get a `SUCCESS` or `FAILURE` + +That's it! + +# Running Clusters + +This tool also makes it easy to test/verify the clustering capabilities of TDengine. You +can start a cluster quite easily with the following command: + +``` +$ cd tests/pytest/ +$ ./crash_gen.sh -e -o 3 +``` + +The `-e` option above tells the tool to start the service, and do not run any tests, while +the `-o 3` option tells the tool to start 3 DNodes and join them together in a cluster. +Obviously you can adjust the the number here. + +## Behind the Scenes + +When the tool runs a cluster, it users a number of directories, each holding the information +for a single DNode, see: + +``` +$ ls build/cluster* +build/cluster_dnode_0: +cfg data log + +build/cluster_dnode_1: +cfg data log + +build/cluster_dnode_2: +cfg data log +``` + +Therefore, when something goes wrong and you want to reset everything with the cluster, simple +erase all the files: + +``` +$ rm -rf build/cluster_dnode_* +``` + +## Addresses and Ports + +The DNodes in the cluster all binds the the `127.0.0.1` IP address (for now anyway), and +uses port 6030 for the first DNode, and 6130 for the 2nd one, and so on. + +## Testing Against a Cluster + +In a separate terminal window, you can invoke the tool in client mode and test against +a cluster, such as: + +``` +$ ./crash_gen.sh -p -t 10 -s 100 -i 3 +``` + +Here the `-i` option tells the tool to always create tables with 3 replicas, and run +all tests against such tables. + +# Additional Features + +The exhaustive features of the tool is available through the `-h` option: + +``` +$ ./crash_gen.sh -h +usage: crash_gen_bootstrap.py [-h] [-a] [-b MAX_DBS] [-c CONNECTOR_TYPE] [-d] [-e] [-g IGNORE_ERRORS] [-i MAX_REPLICAS] [-l] [-n] [-o NUM_DNODES] [-p] [-r] + [-s MAX_STEPS] [-t NUM_THREADS] [-v] [-x] + +TDengine Auto Crash Generator (PLEASE NOTICE the Prerequisites Below) +--------------------------------------------------------------------- +1. You build TDengine in the top level ./build directory, as described in offical docs +2. You run the server there before this script: ./build/bin/taosd -c test/cfg + +optional arguments: + -h, --help show this help message and exit + -a, --auto-start-service + Automatically start/stop the TDengine service (default: false) + -b MAX_DBS, --max-dbs MAX_DBS + Maximum number of DBs to keep, set to disable dropping DB. (default: 0) + -c CONNECTOR_TYPE, --connector-type CONNECTOR_TYPE + Connector type to use: native, rest, or mixed (default: 10) + -d, --debug Turn on DEBUG mode for more logging (default: false) + -e, --run-tdengine Run TDengine service in foreground (default: false) + -g IGNORE_ERRORS, --ignore-errors IGNORE_ERRORS + Ignore error codes, comma separated, 0x supported (default: None) + -i MAX_REPLICAS, --max-replicas MAX_REPLICAS + Maximum number of replicas to use, when testing against clusters. (default: 1) + -l, --larger-data Write larger amount of data during write operations (default: false) + -n, --dynamic-db-table-names + Use non-fixed names for dbs/tables, useful for multi-instance executions (default: false) + -o NUM_DNODES, --num-dnodes NUM_DNODES + Number of Dnodes to initialize, used with -e option. (default: 1) + -p, --per-thread-db-connection + Use a single shared db connection (default: false) + -r, --record-ops Use a pair of always-fsynced fils to record operations performing + performed, for power-off tests (default: false) + -s MAX_STEPS, --max-steps MAX_STEPS + Maximum number of steps to run (default: 100) + -t NUM_THREADS, --num-threads NUM_THREADS + Number of threads to run (default: 10) + -v, --verify-data Verify data written in a number of places by reading back (default: false) + -x, --continue-on-exception + Continue execution after encountering unexpected/disallowed errors/exceptions (default: false) +``` + diff --git a/tests/pytest/crash_gen.py b/tests/pytest/crash_gen/crash_gen.py similarity index 52% rename from tests/pytest/crash_gen.py rename to tests/pytest/crash_gen/crash_gen.py index 1ea19dfac35678bc632357db8368fc61b359dd65..102d7d9bdd6a893014342f46552ae1b34cafc84c 100755 --- a/tests/pytest/crash_gen.py +++ b/tests/pytest/crash_gen/crash_gen.py @@ -14,85 +14,76 @@ # For type hinting before definition, ref: # https://stackoverflow.com/questions/33533148/how-do-i-specify-that-the-return-type-of-a-method-is-the-same-as-the-class-itsel from __future__ import annotations -import taos -import crash_gen -from util.sql import * -from util.cases import * -from util.dnodes import * -from util.log import * -from queue import Queue, Empty -from typing import IO + from typing import Set from typing import Dict from typing import List -from requests.auth import HTTPBasicAuth +from typing import Optional # Type hinting, ref: https://stackoverflow.com/questions/19202633/python-3-type-hinting-for-none + import textwrap -import datetime -import logging import time +import datetime import random +import logging import threading -import requests import copy import argparse import getopt import sys import os -import io import signal import traceback +import resource +from guppy import hpy +import gc -try: - import psutil -except: - print("Psutil module needed, please install: sudo pip3 install psutil") - sys.exit(-1) +from .service_manager import ServiceManager, TdeInstance +from .misc import Logging, Status, CrashGenError, Dice, Helper, Progress +from .db import DbConn, MyTDSql, DbConnNative, DbManager + +import taos +import requests # Require Python 3 if sys.version_info[0] < 3: raise Exception("Must be using Python 3") - # Global variables, tried to keep a small number. # Command-line/Environment Configurations, will set a bit later # ConfigNameSpace = argparse.Namespace -gConfig = argparse.Namespace() # Dummy value, will be replaced later -gSvcMgr = None # TODO: refactor this hack, use dep injection -logger = None - -def runThread(wt: WorkerThread): - wt.run() +gConfig: argparse.Namespace +gSvcMgr: ServiceManager # TODO: refactor this hack, use dep injection +# logger: logging.Logger +gContainer: Container -class CrashGenError(Exception): - def __init__(self, msg=None, errno=None): - self.msg = msg - self.errno = errno - - def __str__(self): - return self.msg +# def runThread(wt: WorkerThread): +# wt.run() class WorkerThread: - def __init__(self, pool: ThreadPool, tid, tc: ThreadCoordinator, - # te: TaskExecutor, - ): # note: main thread context! + def __init__(self, pool: ThreadPool, tid, tc: ThreadCoordinator): + """ + Note: this runs in the main thread context + """ # self._curStep = -1 self._pool = pool self._tid = tid self._tc = tc # type: ThreadCoordinator # self.threadIdent = threading.get_ident() - self._thread = threading.Thread(target=runThread, args=(self,)) + # self._thread = threading.Thread(target=runThread, args=(self,)) + self._thread = threading.Thread(target=self.run) self._stepGate = threading.Event() # Let us have a DB connection of our own if (gConfig.per_thread_db_connection): # type: ignore # print("connector_type = {}".format(gConfig.connector_type)) - if gConfig.connector_type == 'native': - self._dbConn = DbConn.createNative() + tInst = gContainer.defTdeInstance + if gConfig.connector_type == 'native': + self._dbConn = DbConn.createNative(tInst.getDbTarget()) elif gConfig.connector_type == 'rest': - self._dbConn = DbConn.createRest() + self._dbConn = DbConn.createRest(tInst.getDbTarget()) elif gConfig.connector_type == 'mixed': if Dice.throw(2) == 0: # 1/2 chance self._dbConn = DbConn.createNative() @@ -101,21 +92,21 @@ class WorkerThread: else: raise RuntimeError("Unexpected connector type: {}".format(gConfig.connector_type)) - self._dbInUse = False # if "use db" was executed already + # self._dbInUse = False # if "use db" was executed already def logDebug(self, msg): - logger.debug(" TRD[{}] {}".format(self._tid, msg)) + Logging.debug(" TRD[{}] {}".format(self._tid, msg)) def logInfo(self, msg): - logger.info(" TRD[{}] {}".format(self._tid, msg)) + Logging.info(" TRD[{}] {}".format(self._tid, msg)) - def dbInUse(self): - return self._dbInUse + # def dbInUse(self): + # return self._dbInUse - def useDb(self): - if (not self._dbInUse): - self.execSql("use db") - self._dbInUse = True + # def useDb(self): + # if (not self._dbInUse): + # self.execSql("use db") + # self._dbInUse = True def getTaskExecutor(self): return self._tc.getTaskExecutor() @@ -126,10 +117,10 @@ class WorkerThread: def run(self): # initialization after thread starts, in the thread context # self.isSleeping = False - logger.info("Starting to run thread: {}".format(self._tid)) + Logging.info("Starting to run thread: {}".format(self._tid)) if (gConfig.per_thread_db_connection): # type: ignore - logger.debug("Worker thread openning database connection") + Logging.debug("Worker thread openning database connection") self._dbConn.open() self._doTaskLoop() @@ -139,7 +130,7 @@ class WorkerThread: if self._dbConn.isOpen: #sometimes it is not open self._dbConn.close() else: - logger.warning("Cleaning up worker thread, dbConn already closed") + Logging.warning("Cleaning up worker thread, dbConn already closed") def _doTaskLoop(self): # while self._curStep < self._pool.maxSteps: @@ -150,23 +141,23 @@ class WorkerThread: tc.crossStepBarrier() # shared barrier first, INCLUDING the last one except threading.BrokenBarrierError as err: # main thread timed out print("_bto", end="") - logger.debug("[TRD] Worker thread exiting due to main thread barrier time-out") + Logging.debug("[TRD] Worker thread exiting due to main thread barrier time-out") break - logger.debug("[TRD] Worker thread [{}] exited barrier...".format(self._tid)) + Logging.debug("[TRD] Worker thread [{}] exited barrier...".format(self._tid)) self.crossStepGate() # then per-thread gate, after being tapped - logger.debug("[TRD] Worker thread [{}] exited step gate...".format(self._tid)) + Logging.debug("[TRD] Worker thread [{}] exited step gate...".format(self._tid)) if not self._tc.isRunning(): print("_wts", end="") - logger.debug("[TRD] Thread Coordinator not running any more, worker thread now stopping...") + Logging.debug("[TRD] Thread Coordinator not running any more, worker thread now stopping...") break - # Before we fetch the task and run it, let's ensure we properly "use" the database + # Before we fetch the task and run it, let's ensure we properly "use" the database (not needed any more) try: if (gConfig.per_thread_db_connection): # most likely TRUE if not self._dbConn.isOpen: # might have been closed during server auto-restart self._dbConn.open() - self.useDb() # might encounter exceptions. TODO: catch + # self.useDb() # might encounter exceptions. TODO: catch except taos.error.ProgrammingError as err: errno = Helper.convertErrno(err.errno) if errno in [0x383, 0x386, 0x00B, 0x014] : # invalid database, dropping, Unable to establish connection, Database not ready @@ -177,18 +168,17 @@ class WorkerThread: raise # Fetch a task from the Thread Coordinator - logger.debug( "[TRD] Worker thread [{}] about to fetch task".format(self._tid)) + Logging.debug( "[TRD] Worker thread [{}] about to fetch task".format(self._tid)) task = tc.fetchTask() # Execute such a task - logger.debug( - "[TRD] Worker thread [{}] about to execute task: {}".format( + Logging.debug("[TRD] Worker thread [{}] about to execute task: {}".format( self._tid, task.__class__.__name__)) task.execute(self) tc.saveExecutedTask(task) - logger.debug("[TRD] Worker thread [{}] finished executing task".format(self._tid)) + Logging.debug("[TRD] Worker thread [{}] finished executing task".format(self._tid)) - self._dbInUse = False # there may be changes between steps + # self._dbInUse = False # there may be changes between steps # print("_wtd", end=None) # worker thread died def verifyThreadSelf(self): # ensure we are called by this own thread @@ -209,7 +199,7 @@ class WorkerThread: self.verifyThreadSelf() # only allowed by ourselves # Wait again at the "gate", waiting to be "tapped" - logger.debug( + Logging.debug( "[TRD] Worker thread {} about to cross the step gate".format( self._tid)) self._stepGate.wait() @@ -222,7 +212,7 @@ class WorkerThread: self.verifyThreadMain() # only allowed for main thread if self._thread.is_alive(): - logger.debug("[TRD] Tapping worker thread {}".format(self._tid)) + Logging.debug("[TRD] Tapping worker thread {}".format(self._tid)) self._stepGate.set() # wake up! time.sleep(0) # let the released thread run a bit else: @@ -237,7 +227,7 @@ class WorkerThread: def getQueryResult(self): return self.getDbConn().getQueryResult() - def getDbConn(self): + def getDbConn(self) -> DbConn : if (gConfig.per_thread_db_connection): return self._dbConn else: @@ -253,9 +243,9 @@ class WorkerThread: class ThreadCoordinator: - WORKER_THREAD_TIMEOUT = 60 # one minute + WORKER_THREAD_TIMEOUT = 180 # one minute - def __init__(self, pool: ThreadPool, dbManager): + def __init__(self, pool: ThreadPool, dbManager: DbManager): self._curStep = -1 # first step is 0 self._pool = pool # self._wd = wd @@ -267,7 +257,8 @@ class ThreadCoordinator: self._stepBarrier = threading.Barrier( self._pool.numThreads + 1) # one barrier for all threads self._execStats = ExecutionStats() - self._runStatus = MainExec.STATUS_RUNNING + self._runStatus = Status.STATUS_RUNNING + self._initDbs() def getTaskExecutor(self): return self._te @@ -279,14 +270,14 @@ class ThreadCoordinator: self._stepBarrier.wait(timeout) def requestToStop(self): - self._runStatus = MainExec.STATUS_STOPPING + self._runStatus = Status.STATUS_STOPPING self._execStats.registerFailure("User Interruption") def _runShouldEnd(self, transitionFailed, hasAbortedTask, workerTimeout): maxSteps = gConfig.max_steps # type: ignore if self._curStep >= (maxSteps - 1): # maxStep==10, last curStep should be 9 return True - if self._runStatus != MainExec.STATUS_RUNNING: + if self._runStatus != Status.STATUS_RUNNING: return True if transitionFailed: return True @@ -307,7 +298,7 @@ class ThreadCoordinator: def _releaseAllWorkerThreads(self, transitionFailed): self._curStep += 1 # we are about to get into next step. TODO: race condition here! # Now not all threads had time to go to sleep - logger.debug( + Logging.debug( "--\r\n\n--> Step {} starts with main thread waking up".format(self._curStep)) # A new TE for the new step @@ -315,41 +306,46 @@ class ThreadCoordinator: if not transitionFailed: # only if not failed self._te = TaskExecutor(self._curStep) - logger.debug("[TRD] Main thread waking up at step {}, tapping worker threads".format( + Logging.debug("[TRD] Main thread waking up at step {}, tapping worker threads".format( self._curStep)) # Now not all threads had time to go to sleep # Worker threads will wake up at this point, and each execute it's own task - self.tapAllThreads() # release all worker thread from their "gate" + self.tapAllThreads() # release all worker thread from their "gates" def _syncAtBarrier(self): # Now main thread (that's us) is ready to enter a step # let other threads go past the pool barrier, but wait at the # thread gate - logger.debug("[TRD] Main thread about to cross the barrier") + Logging.debug("[TRD] Main thread about to cross the barrier") self.crossStepBarrier(timeout=self.WORKER_THREAD_TIMEOUT) self._stepBarrier.reset() # Other worker threads should now be at the "gate" - logger.debug("[TRD] Main thread finished crossing the barrier") + Logging.debug("[TRD] Main thread finished crossing the barrier") def _doTransition(self): transitionFailed = False try: - sm = self._dbManager.getStateMachine() - logger.debug("[STT] starting transitions") - # at end of step, transiton the DB state - sm.transition(self._executedTasks) - logger.debug("[STT] transition ended") - # Due to limitation (or maybe not) of the Python library, + for x in self._dbs: + db = x # type: Database + sm = db.getStateMachine() + Logging.debug("[STT] starting transitions for DB: {}".format(db.getName())) + # at end of step, transiton the DB state + tasksForDb = db.filterTasks(self._executedTasks) + sm.transition(tasksForDb, self.getDbManager().getDbConn()) + Logging.debug("[STT] transition ended for DB: {}".format(db.getName())) + + # Due to limitation (or maybe not) of the TD Python library, # we cannot share connections across threads # Here we are in main thread, we cannot operate the connections created in workers # Moving below to task loop # if sm.hasDatabase(): # for t in self._pool.threadList: - # logger.debug("[DB] use db for all worker threads") + # Logging.debug("[DB] use db for all worker threads") # t.useDb() # t.execSql("use db") # main thread executing "use # db" on behalf of every worker thread + except taos.error.ProgrammingError as err: if (err.msg == 'network unavailable'): # broken DB connection - logger.info("DB connection broken, execution failed") + Logging.info("DB connection broken, execution failed") traceback.print_stack() transitionFailed = True self._te = None # Not running any more @@ -358,11 +354,11 @@ class ThreadCoordinator: # end, and maybe signal them to stop else: raise - return transitionFailed + # return transitionFailed # Why did we have this??!! self.resetExecutedTasks() # clear the tasks after we are done # Get ready for next step - logger.debug("<-- Step {} finished, trasition failed = {}".format(self._curStep, transitionFailed)) + Logging.debug("<-- Step {} finished, trasition failed = {}".format(self._curStep, transitionFailed)) return transitionFailed def run(self): @@ -376,13 +372,23 @@ class ThreadCoordinator: hasAbortedTask = False workerTimeout = False while not self._runShouldEnd(transitionFailed, hasAbortedTask, workerTimeout): - if not gConfig.debug: # print this only if we are not in debug mode - print(".", end="", flush=True) + if not gConfig.debug: # print this only if we are not in debug mode + Progress.emit(Progress.STEP_BOUNDARY) + # print(".", end="", flush=True) + # if (self._curStep % 2) == 0: # print memory usage once every 10 steps + # memUsage = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss + # print("[m:{}]".format(memUsage), end="", flush=True) # print memory usage + # if (self._curStep % 10) == 3: + # h = hpy() + # print("\n") + # print(h.heap()) + try: self._syncAtBarrier() # For now just cross the barrier + Progress.emit(Progress.END_THREAD_STEP) except threading.BrokenBarrierError as err: - logger.info("Main loop aborted, caused by worker thread time-out") + Logging.info("Main loop aborted, caused by worker thread time-out") self._execStats.registerFailure("Aborted due to worker thread timeout") print("\n\nWorker Thread time-out detected, important thread info:") ts = ThreadStacks() @@ -395,7 +401,7 @@ class ThreadCoordinator: # threads are QUIET. hasAbortedTask = self._hasAbortedTask() # from previous step if hasAbortedTask: - logger.info("Aborted task encountered, exiting test program") + Logging.info("Aborted task encountered, exiting test program") self._execStats.registerFailure("Aborted Task Encountered") break # do transition only if tasks are error free @@ -406,30 +412,45 @@ class ThreadCoordinator: transitionFailed = True errno2 = Helper.convertErrno(err.errno) # correct error scheme errMsg = "Transition failed: errno=0x{:X}, msg: {}".format(errno2, err) - logger.info(errMsg) + Logging.info(errMsg) + traceback.print_exc() self._execStats.registerFailure(errMsg) # Then we move on to the next step + Progress.emit(Progress.BEGIN_THREAD_STEP) self._releaseAllWorkerThreads(transitionFailed) if hasAbortedTask or transitionFailed : # abnormal ending, workers waiting at "gate" - logger.debug("Abnormal ending of main thraed") + Logging.debug("Abnormal ending of main thraed") elif workerTimeout: - logger.debug("Abnormal ending of main thread, due to worker timeout") + Logging.debug("Abnormal ending of main thread, due to worker timeout") else: # regular ending, workers waiting at "barrier" - logger.debug("Regular ending, main thread waiting for all worker threads to stop...") + Logging.debug("Regular ending, main thread waiting for all worker threads to stop...") self._syncAtBarrier() self._te = None # No more executor, time to end - logger.debug("Main thread tapping all threads one last time...") + Logging.debug("Main thread tapping all threads one last time...") self.tapAllThreads() # Let the threads run one last time - logger.debug("\r\n\n--> Main thread ready to finish up...") - logger.debug("Main thread joining all threads") + Logging.debug("\r\n\n--> Main thread ready to finish up...") + Logging.debug("Main thread joining all threads") self._pool.joinAll() # Get all threads to finish - logger.info("\nAll worker threads finished") + Logging.info("\nAll worker threads finished") self._execStats.endExec() + def cleanup(self): # free resources + self._pool.cleanup() + + self._pool = None + self._te = None + self._dbManager = None + self._executedTasks = None + self._lock = None + self._stepBarrier = None + self._execStats = None + self._runStatus = None + + def printStats(self): self._execStats.printStats() @@ -446,7 +467,7 @@ class ThreadCoordinator: wakeSeq.append(i) else: wakeSeq.insert(0, i) - logger.debug( + Logging.debug( "[TRD] Main thread waking up worker threads: {}".format( str(wakeSeq))) # TODO: set dice seed to a deterministic value @@ -458,23 +479,36 @@ class ThreadCoordinator: def isRunning(self): return self._te is not None + def _initDbs(self): + ''' Initialize multiple databases, invoked at __ini__() time ''' + self._dbs = [] # type: List[Database] + dbc = self.getDbManager().getDbConn() + if gConfig.max_dbs == 0: + self._dbs.append(Database(0, dbc)) + else: + baseDbNumber = int(datetime.datetime.now().timestamp( # Don't use Dice/random, as they are deterministic + )*333) % 888 if gConfig.dynamic_db_table_names else 0 + for i in range(gConfig.max_dbs): + self._dbs.append(Database(baseDbNumber + i, dbc)) + + def pickDatabase(self): + idxDb = 0 + if gConfig.max_dbs != 0 : + idxDb = Dice.throw(gConfig.max_dbs) # 0 to N-1 + db = self._dbs[idxDb] # type: Database + return db + def fetchTask(self) -> Task: + ''' The thread coordinator (that's us) is responsible for fetching a task + to be executed next. + ''' if (not self.isRunning()): # no task raise RuntimeError("Cannot fetch task when not running") - # return self._wd.pickTask() - # Alternatively, let's ask the DbState for the appropriate task - # dbState = self.getDbState() - # tasks = dbState.getTasksAtState() # TODO: create every time? - # nTasks = len(tasks) - # i = Dice.throw(nTasks) - # logger.debug(" (dice:{}/{}) ".format(i, nTasks)) - # # return copy.copy(tasks[i]) # Needs a fresh copy, to save execution results, etc. - # return tasks[i].clone() # TODO: still necessary? + # pick a task type for current state - taskType = self.getDbManager().getStateMachine().pickTaskType() - return taskType( - self.getDbManager(), - self._execStats) # create a task from it + db = self.pickDatabase() + taskType = db.getStateMachine().pickTaskType() # dynamic name of class + return taskType(self._execStats, db) # create a task from it def resetExecutedTasks(self): self._executedTasks = [] # should be under single thread @@ -483,13 +517,6 @@ class ThreadCoordinator: with self._lock: self._executedTasks.append(task) -# We define a class to run a number of threads in locking steps. - -class Helper: - @classmethod - def convertErrno(cls, errno): - return errno if (errno > 0) else 0x80000000 + errno - class ThreadPool: def __init__(self, numThreads, maxSteps): self.numThreads = numThreads @@ -507,9 +534,12 @@ class ThreadPool: def joinAll(self): for workerThread in self.threadList: - logger.debug("Joining thread...") + Logging.debug("Joining thread...") workerThread._thread.join() + def cleanup(self): + self.threadList = None # maybe clean up each? + # A queue of continguous POSITIVE integers, used by DbManager to generate continuous numbers # for new table names @@ -561,7 +591,7 @@ class LinearQueue(): def allocate(self, i): with self._lock: - # logger.debug("LQ allocating item {}".format(i)) + # Logging.debug("LQ allocating item {}".format(i)) if (i in self.inUse): raise RuntimeError( "Cannot re-use same index in queue: {}".format(i)) @@ -569,7 +599,7 @@ class LinearQueue(): def release(self, i): with self._lock: - # logger.debug("LQ releasing item {}".format(i)) + # Logging.debug("LQ releasing item {}".format(i)) self.inUse.remove(i) # KeyError possible, TODO: why? def size(self): @@ -591,327 +621,6 @@ class LinearQueue(): return ret -class DbConn: - TYPE_NATIVE = "native-c" - TYPE_REST = "rest-api" - TYPE_INVALID = "invalid" - - @classmethod - def create(cls, connType): - if connType == cls.TYPE_NATIVE: - return DbConnNative() - elif connType == cls.TYPE_REST: - return DbConnRest() - else: - raise RuntimeError( - "Unexpected connection type: {}".format(connType)) - - @classmethod - def createNative(cls): - return cls.create(cls.TYPE_NATIVE) - - @classmethod - def createRest(cls): - return cls.create(cls.TYPE_REST) - - def __init__(self): - self.isOpen = False - self._type = self.TYPE_INVALID - self._lastSql = None - - def getLastSql(self): - return self._lastSql - - def open(self): - if (self.isOpen): - raise RuntimeError("Cannot re-open an existing DB connection") - - # below implemented by child classes - self.openByType() - - logger.debug("[DB] data connection opened, type = {}".format(self._type)) - self.isOpen = True - - def resetDb(self): # reset the whole database, etc. - if (not self.isOpen): - raise RuntimeError("Cannot reset database until connection is open") - # self._tdSql.prepare() # Recreate database, etc. - - self.execute('drop database if exists db') - logger.debug("Resetting DB, dropped database") - # self._cursor.execute('create database db') - # self._cursor.execute('use db') - # tdSql.execute('show databases') - - def queryScalar(self, sql) -> int: - return self._queryAny(sql) - - def queryString(self, sql) -> str: - return self._queryAny(sql) - - def _queryAny(self, sql): # actual query result as an int - if (not self.isOpen): - raise RuntimeError("Cannot query database until connection is open") - nRows = self.query(sql) - if nRows != 1: - raise RuntimeError("Unexpected result for query: {}, rows = {}".format(sql, nRows)) - if self.getResultRows() != 1 or self.getResultCols() != 1: - raise RuntimeError("Unexpected result set for query: {}".format(sql)) - return self.getQueryResult()[0][0] - - def use(self, dbName): - self.execute("use {}".format(dbName)) - - def hasDatabases(self): - return self.query("show databases") > 1 # We now have a "log" database by default - - def hasTables(self): - return self.query("show tables") > 0 - - def execute(self, sql): - raise RuntimeError("Unexpected execution, should be overriden") - - def query(self, sql) -> int: # return num rows returned - raise RuntimeError("Unexpected execution, should be overriden") - - def openByType(self): - raise RuntimeError("Unexpected execution, should be overriden") - - def getQueryResult(self): - raise RuntimeError("Unexpected execution, should be overriden") - - def getResultRows(self): - raise RuntimeError("Unexpected execution, should be overriden") - - def getResultCols(self): - raise RuntimeError("Unexpected execution, should be overriden") - -# Sample: curl -u root:taosdata -d "show databases" localhost:6020/rest/sql - - -class DbConnRest(DbConn): - def __init__(self): - super().__init__() - self._type = self.TYPE_REST - self._url = "http://localhost:6041/rest/sql" # fixed for now - self._result = None - - def openByType(self): # Open connection - pass # do nothing, always open - - def close(self): - if (not self.isOpen): - raise RuntimeError("Cannot clean up database until connection is open") - # Do nothing for REST - logger.debug("[DB] REST Database connection closed") - self.isOpen = False - - def _doSql(self, sql): - self._lastSql = sql # remember this, last SQL attempted - try: - r = requests.post(self._url, - data = sql, - auth = HTTPBasicAuth('root', 'taosdata')) - except: - print("REST API Failure (TODO: more info here)") - raise - rj = r.json() - # Sanity check for the "Json Result" - if ('status' not in rj): - raise RuntimeError("No status in REST response") - - if rj['status'] == 'error': # clearly reported error - if ('code' not in rj): # error without code - raise RuntimeError("REST error return without code") - errno = rj['code'] # May need to massage this in the future - # print("Raising programming error with REST return: {}".format(rj)) - raise taos.error.ProgrammingError( - rj['desc'], errno) # todo: check existance of 'desc' - - if rj['status'] != 'succ': # better be this - raise RuntimeError( - "Unexpected REST return status: {}".format( - rj['status'])) - - nRows = rj['rows'] if ('rows' in rj) else 0 - self._result = rj - return nRows - - def execute(self, sql): - if (not self.isOpen): - raise RuntimeError( - "Cannot execute database commands until connection is open") - logger.debug("[SQL-REST] Executing SQL: {}".format(sql)) - nRows = self._doSql(sql) - logger.debug( - "[SQL-REST] Execution Result, nRows = {}, SQL = {}".format(nRows, sql)) - return nRows - - def query(self, sql): # return rows affected - return self.execute(sql) - - def getQueryResult(self): - return self._result['data'] - - def getResultRows(self): - print(self._result) - raise RuntimeError("TBD") - # return self._tdSql.queryRows - - def getResultCols(self): - print(self._result) - raise RuntimeError("TBD") - - # Duplicate code from TDMySQL, TODO: merge all this into DbConnNative - - -class MyTDSql: - def __init__(self, hostAddr, cfgPath): - # Make the DB connection - self._conn = taos.connect(host=hostAddr, config=cfgPath) - self._cursor = self._conn.cursor() - - self.queryRows = 0 - self.queryCols = 0 - self.affectedRows = 0 - - # def init(self, cursor, log=True): - # self.cursor = cursor - # if (log): - # caller = inspect.getframeinfo(inspect.stack()[1][0]) - # self.cursor.log(caller.filename + ".sql") - - def close(self): - self._conn.close() # TODO: very important, cursor close does NOT close DB connection! - self._cursor.close() - - def query(self, sql): - self.sql = sql - try: - self._cursor.execute(sql) - self.queryResult = self._cursor.fetchall() - self.queryRows = len(self.queryResult) - self.queryCols = len(self._cursor.description) - except Exception as e: - # caller = inspect.getframeinfo(inspect.stack()[1][0]) - # args = (caller.filename, caller.lineno, sql, repr(e)) - # tdLog.exit("%s(%d) failed: sql:%s, %s" % args) - raise - return self.queryRows - - def execute(self, sql): - self.sql = sql - try: - self.affectedRows = self._cursor.execute(sql) - except Exception as e: - # caller = inspect.getframeinfo(inspect.stack()[1][0]) - # args = (caller.filename, caller.lineno, sql, repr(e)) - # tdLog.exit("%s(%d) failed: sql:%s, %s" % args) - raise - return self.affectedRows - - -class DbConnNative(DbConn): - # Class variables - _lock = threading.Lock() - _connInfoDisplayed = False - totalConnections = 0 # Not private - - def __init__(self): - super().__init__() - self._type = self.TYPE_NATIVE - self._conn = None - # self._cursor = None - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("communit")] - else: - projPath = selfPath[:selfPath.find("tests")] - - buildPath = None - 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 - if buildPath == None: - raise RuntimeError("Failed to determine buildPath, selfPath={}, projPath={}" - .format(selfPath, projPath)) - return buildPath - - - def openByType(self): # Open connection - cfgPath = self.getBuildPath() + "/test/cfg" - hostAddr = "127.0.0.1" - - cls = self.__class__ # Get the class, to access class variables - with cls._lock: # force single threading for opening DB connections. # TODO: whaaat??!!! - if not cls._connInfoDisplayed: - cls._connInfoDisplayed = True # updating CLASS variable - logger.info("Initiating TAOS native connection to {}, using config at {}".format(hostAddr, cfgPath)) - # Make the connection - # self._conn = taos.connect(host=hostAddr, config=cfgPath) # TODO: make configurable - # self._cursor = self._conn.cursor() - # Record the count in the class - self._tdSql = MyTDSql(hostAddr, cfgPath) # making DB connection - cls.totalConnections += 1 - - self._tdSql.execute('reset query cache') - # self._cursor.execute('use db') # do this at the beginning of every - - # Open connection - # self._tdSql = MyTDSql() - # self._tdSql.init(self._cursor) - - def close(self): - if (not self.isOpen): - raise RuntimeError("Cannot clean up database until connection is open") - self._tdSql.close() - # Decrement the class wide counter - cls = self.__class__ # Get the class, to access class variables - with cls._lock: - cls.totalConnections -= 1 - - logger.debug("[DB] Database connection closed") - self.isOpen = False - - def execute(self, sql): - if (not self.isOpen): - raise RuntimeError("Cannot execute database commands until connection is open") - logger.debug("[SQL] Executing SQL: {}".format(sql)) - self._lastSql = sql - nRows = self._tdSql.execute(sql) - logger.debug( - "[SQL] Execution Result, nRows = {}, SQL = {}".format( - nRows, sql)) - return nRows - - def query(self, sql): # return rows affected - if (not self.isOpen): - raise RuntimeError( - "Cannot query database until connection is open") - logger.debug("[SQL] Executing SQL: {}".format(sql)) - self._lastSql = sql - nRows = self._tdSql.query(sql) - logger.debug( - "[SQL] Query Result, nRows = {}, SQL = {}".format( - nRows, sql)) - return nRows - # results are in: return self._tdSql.queryResult - - def getQueryResult(self): - return self._tdSql.queryResult - - def getResultRows(self): - return self._tdSql.queryRows - - def getResultCols(self): - return self._tdSql.queryCols - - class AnyState: STATE_INVALID = -1 STATE_EMPTY = 0 # nothing there, no even a DB @@ -922,7 +631,9 @@ class AnyState: STATE_VAL_IDX = 0 CAN_CREATE_DB = 1 - CAN_DROP_DB = 2 + # For below, if we can "drop the DB", but strictly speaking + # only "under normal circumstances", as we may override it with the -b option + CAN_DROP_DB = 2 CAN_CREATE_FIXED_SUPER_TABLE = 3 CAN_DROP_FIXED_SUPER_TABLE = 4 CAN_ADD_DATA = 5 @@ -935,6 +646,8 @@ class AnyState: # -1 hack to accomodate the STATE_INVALID case return self._stateNames[self._info[self.STATE_VAL_IDX] + 1] + # Each sub state tells us the "info", about itself, so we can determine + # on things like canDropDB() def getInfo(self): raise RuntimeError("Must be overriden by child classes") @@ -961,6 +674,10 @@ class AnyState: return self._info[self.CAN_CREATE_DB] def canDropDb(self): + # If user requests to run up to a number of DBs, + # we'd then not do drop_db operations any more + if gConfig.max_dbs > 0 : + return False return self._info[self.CAN_DROP_DB] def canCreateFixedSuperTable(self): @@ -997,8 +714,8 @@ class AnyState: if task.isSuccess(): sCnt += 1 if (exists and sCnt <= 0): - raise RuntimeError( - "Unexpected zero success for task: {}".format(cls)) + raise RuntimeError("Unexpected zero success for task type: {}, from tasks: {}" + .format(cls, tasks)) def assertNoTask(self, tasks, cls): for task in tasks: @@ -1145,13 +862,16 @@ class StateHasData(AnyState): class StateMechine: - def __init__(self, dbConn): - self._dbConn = dbConn - self._curState = self._findCurrentState() # starting state - # transitition target probabilities, indexed with value of STATE_EMPTY, - # STATE_DB_ONLY, etc. + def __init__(self, db: Database): + self._db = db + # transitition target probabilities, indexed with value of STATE_EMPTY, STATE_DB_ONLY, etc. self._stateWeights = [1, 2, 10, 40] + def init(self, dbc: DbConn): # late initailization, don't save the dbConn + self._curState = self._findCurrentState(dbc) # starting state + Logging.debug("Found Starting State: {}".format(self._curState)) + + # TODO: seems no lnoger used, remove? def getCurrentState(self): return self._curState @@ -1187,40 +907,41 @@ class StateMechine: raise RuntimeError( "No suitable task types found for state: {}".format( self._curState)) - logger.debug( + Logging.debug( "[OPS] Tasks found for state {}: {}".format( self._curState, typesToStrings(taskTypes))) return taskTypes - def _findCurrentState(self): - dbc = self._dbConn + def _findCurrentState(self, dbc: DbConn): ts = time.time() # we use this to debug how fast/slow it is to do the various queries to find the current DB state - if not dbc.hasDatabases(): # no database?! - logger.debug( "[STT] empty database found, between {} and {}".format(ts, time.time())) + dbName =self._db.getName() + if not dbc.existsDatabase(dbName): # dbc.hasDatabases(): # no database?! + Logging.debug( "[STT] empty database found, between {} and {}".format(ts, time.time())) return StateEmpty() # did not do this when openning connection, and this is NOT the worker # thread, which does this on their own - dbc.use("db") + dbc.use(dbName) if not dbc.hasTables(): # no tables - logger.debug("[STT] DB_ONLY found, between {} and {}".format(ts, time.time())) + Logging.debug("[STT] DB_ONLY found, between {} and {}".format(ts, time.time())) return StateDbOnly() - sTable = DbManager.getFixedSuperTable() - if sTable.hasRegTables(dbc): # no regular tables - logger.debug("[STT] SUPER_TABLE_ONLY found, between {} and {}".format(ts, time.time())) + sTable = self._db.getFixedSuperTable() + if sTable.hasRegTables(dbc, dbName): # no regular tables + Logging.debug("[STT] SUPER_TABLE_ONLY found, between {} and {}".format(ts, time.time())) return StateSuperTableOnly() else: # has actual tables - logger.debug("[STT] HAS_DATA found, between {} and {}".format(ts, time.time())) + Logging.debug("[STT] HAS_DATA found, between {} and {}".format(ts, time.time())) return StateHasData() - def transition(self, tasks): + # We transition the system to a new state by examining the current state itself + def transition(self, tasks, dbc: DbConn): if (len(tasks) == 0): # before 1st step, or otherwise empty - logger.debug("[STT] Starting State: {}".format(self._curState)) + Logging.debug("[STT] Starting State: {}".format(self._curState)) return # do nothing # this should show up in the server log, separating steps - self._dbConn.execute("show dnodes") + dbc.execute("show dnodes") # Generic Checks, first based on the start state if self._curState.canCreateDb(): @@ -1251,8 +972,8 @@ class StateMechine: # if self._state.canReadData(): # Nothing for sure - newState = self._findCurrentState() - logger.debug("[STT] New DB state determined: {}".format(newState)) + 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) self._curState = newState @@ -1270,7 +991,7 @@ class StateMechine: # read data task, default to 10: TODO: change to a constant weights.append(10) i = self._weighted_choice_sub(weights) - # logger.debug(" (weighted random:{}/{}) ".format(i, len(taskTypes))) + # Logging.debug(" (weighted random:{}/{}) ".format(i, len(taskTypes))) return taskTypes[i] # ref: @@ -1283,49 +1004,55 @@ class StateMechine: if rnd < 0: return i -# Manager of the Database Data/Connection +class Database: + ''' We use this to represent an actual TDengine database inside a service instance, + possibly in a cluster environment. + For now we use it to manage state transitions in that database -class DbManager(): - def __init__(self, resetDb=True): - self.tableNumQueue = LinearQueue() - # datetime.datetime(2019, 1, 1) # initial date time tick - self._lastTick = self.setupLastTick() - self._lastInt = 0 # next one is initial integer + TODO: consider moving, but keep in mind it contains "StateMachine" + ''' + _clsLock = threading.Lock() # class wide lock + _lastInt = 101 # next one is initial integer + _lastTick = 0 + _lastLaggingTick = 0 # lagging tick, for unsequenced insersions + + def __init__(self, dbNum: int, dbc: DbConn): # TODO: remove dbc + self._dbNum = dbNum # we assign a number to databases, for our testing purpose + self._stateMachine = StateMechine(self) + self._stateMachine.init(dbc) + self._lock = threading.RLock() - # self.openDbServerConnection() - self._dbConn = DbConn.createNative() if ( - gConfig.connector_type == 'native') else DbConn.createRest() - try: - self._dbConn.open() # may throw taos.error.ProgrammingError: disconnected - except taos.error.ProgrammingError as err: - # print("Error type: {}, msg: {}, value: {}".format(type(err), err.msg, err)) - if (err.msg == 'client disconnected'): # cannot open DB connection - print( - "Cannot establish DB connection, please re-run script without parameter, and follow the instructions.") - sys.exit(2) - else: - print("Failed to connect to DB, errno = {}, msg: {}".format(Helper.convertErrno(err.errno), err.msg)) - raise - except BaseException: - print("[=] Unexpected exception") - raise + def getStateMachine(self) -> StateMechine: + return self._stateMachine - if resetDb: - self._dbConn.resetDb() # drop and recreate DB + def getDbNum(self): + return self._dbNum - # Do this after dbConn is in proper shape - self._stateMachine = StateMechine(self._dbConn) + def getName(self): + return "db_{}".format(self._dbNum) - def getDbConn(self): - return self._dbConn + def filterTasks(self, inTasks: List[Task]): # Pick out those belonging to us + outTasks = [] + for task in inTasks: + if task.getDb().isSame(self): + outTasks.append(task) + return outTasks - def getStateMachine(self) -> StateMechine: - return self._stateMachine + def isSame(self, other): + return self._dbNum == other._dbNum + + def exists(self, dbc: DbConn): + return dbc.existsDatabase(self.getName()) + + @classmethod + def getFixedSuperTableName(cls): + return "fs_table" - # def getState(self): - # return self._stateMachine.getCurrentState() + @classmethod + def getFixedSuperTable(cls) -> TdSuperTable: + return TdSuperTable(cls.getFixedSuperTableName()) # We aim to create a starting time tick, such that, whenever we run our test here once # We should be able to safely create 100,000 records, which will not have any repeated time stamp @@ -1333,7 +1060,8 @@ class DbManager(): # by a factor of 500. # TODO: what if it goes beyond 10 years into the future # TODO: fix the error as result of above: "tsdb timestamp is out of range" - def setupLastTick(self): + @classmethod + def setupLastTick(cls): t1 = datetime.datetime(2020, 6, 1) t2 = datetime.datetime.now() # maybe a very large number, takes 69 years to exceed Python int range @@ -1344,36 +1072,25 @@ class DbManager(): t3 = datetime.datetime(2012, 1, 1) # default "keep" is 10 years t4 = datetime.datetime.fromtimestamp( t3.timestamp() + elSec2) # see explanation above - logger.info("Setting up TICKS to start from: {}".format(t4)) + Logging.info("Setting up TICKS to start from: {}".format(t4)) return t4 - def pickAndAllocateTable(self): # pick any table, and "use" it - return self.tableNumQueue.pickAndAllocate() - - def addTable(self): - with self._lock: - tIndex = self.tableNumQueue.push() - return tIndex - @classmethod - def getFixedSuperTableName(cls): - return "fs_table" - - @classmethod - def getFixedSuperTable(cls): - return TdSuperTable(cls.getFixedSuperTableName()) - - def releaseTable(self, i): # return the table back, so others can use it - self.tableNumQueue.release(i) - - def getNextTick(self): - with self._lock: # prevent duplicate tick - if Dice.throw(20) == 0: # 1 in 20 chance - return self._lastTick + datetime.timedelta(0, -100) # Go back in time 100 seconds + def getNextTick(cls): + with cls._clsLock: # prevent duplicate tick + if cls._lastLaggingTick==0: + # 10k at 1/20 chance, should be enough to avoid overlaps + cls._lastLaggingTick = cls.setupLastTick() + datetime.timedelta(0, -10000) + if cls._lastTick==0: # should be quite a bit into the future + cls._lastTick = cls.setupLastTick() + + if Dice.throw(20) == 0: # 1 in 20 chance, return lagging tick + cls._lastLaggingTick += datetime.timedelta(0, 1) # Go back in time 100 seconds + return cls._lastLaggingTick else: # regular # add one second to it - self._lastTick += datetime.timedelta(0, 1) - return self._lastTick + cls._lastTick += datetime.timedelta(0, 1) + return cls._lastTick def getNextInt(self): with self._lock: @@ -1389,16 +1106,6 @@ class DbManager(): # print("Float obtained: {}".format(ret)) return ret - def getTableNameToDelete(self): - tblNum = self.tableNumQueue.pop() # TODO: race condition! - if (not tblNum): # maybe false - return False - - return "table_{}".format(tblNum) - - def cleanUp(self): - self._dbConn.close() - class TaskExecutor(): class BoundedList: @@ -1458,34 +1165,38 @@ class TaskExecutor(): self._boundedList.add(n) # def logInfo(self, msg): - # logger.info(" T[{}.x]: ".format(self._curStep) + msg) + # Logging.info(" T[{}.x]: ".format(self._curStep) + msg) # def logDebug(self, msg): - # logger.debug(" T[{}.x]: ".format(self._curStep) + msg) + # Logging.debug(" T[{}.x]: ".format(self._curStep) + msg) class Task(): + ''' A generic "Task" to be executed. For now we decide that there is no + need to embed a DB connection here, we use whatever the Worker Thread has + instead. But a task is always associated with a DB + ''' taskSn = 100 @classmethod def allocTaskNum(cls): Task.taskSn += 1 # IMPORTANT: cannot use cls.taskSn, since each sub class will have a copy - # logger.debug("Allocating taskSN: {}".format(Task.taskSn)) + # Logging.debug("Allocating taskSN: {}".format(Task.taskSn)) return Task.taskSn - def __init__(self, dbManager: DbManager, execStats: ExecutionStats): - self._dbManager = dbManager + def __init__(self, execStats: ExecutionStats, db: Database): self._workerThread = None - self._err = None + self._err: Optional[Exception] = None self._aborted = False self._curStep = None self._numRows = None # Number of rows affected # Assign an incremental task serial number self._taskNum = self.allocTaskNum() - # logger.debug("Creating new task {}...".format(self._taskNum)) + # Logging.debug("Creating new task {}...".format(self._taskNum)) self._execStats = execStats + self._db = db # A task is always associated/for a specific DB def isSuccess(self): return self._err is None @@ -1494,9 +1205,12 @@ class Task(): return self._aborted def clone(self): # TODO: why do we need this again? - newTask = self.__class__(self._dbManager, self._execStats) + newTask = self.__class__(self._execStats, self._db) return newTask + def getDb(self): + return self._db + def logDebug(self, msg): self._workerThread.logDebug( "Step[{}.{}] {}".format( @@ -1515,9 +1229,13 @@ class Task(): def _isErrAcceptable(self, errno, msg): if errno in [ 0x05, # TSDB_CODE_RPC_NOT_READY - # 0x200, # invalid SQL, TODO: re-examine with TD-934 - 0x360, 0x362, - 0x369, # tag already exists + 0x0B, # Unable to establish connection, more details in TD-1648 + 0x200, # invalid SQL, TODO: re-examine with TD-934 + 0x217, # "db not selected", client side defined error code + # 0x218, # "Table does not exist" client side defined error code + 0x360, # Table already exists + 0x362, + # 0x369, # tag already exists 0x36A, 0x36B, 0x36D, 0x381, 0x380, # "db not selected" @@ -1526,12 +1244,17 @@ class Task(): 0x503, 0x510, # vnode not in ready state 0x14, # db not ready, errno changed - 0x600, + 0x600, # Invalid table ID, why? 1000 # REST catch-all error ]: return True # These are the ALWAYS-ACCEPTABLE ones - elif (errno in [ 0x0B ]) and gConfig.auto_start_service: - return True # We may get "network unavilable" when restarting service + # This case handled below already. + # elif (errno in [ 0x0B ]) and gConfig.auto_start_service: + # return True # We may get "network unavilable" when restarting service + elif gConfig.ignore_errors: # something is specified on command line + moreErrnos = [int(v, 0) for v in gConfig.ignore_errors.split(',')] + if errno in moreErrnos: + return True elif errno == 0x200 : # invalid SQL, we need to div in a bit more if msg.find("invalid column name") != -1: return True @@ -1539,8 +1262,8 @@ class Task(): return True elif msg.find("duplicated column names") != -1: # also alter table tag issues return True - elif (gSvcMgr!=None) and gSvcMgr.isRestarting(): - logger.info("Ignoring error when service is restarting: errno = {}, msg = {}".format(errno, msg)) + elif gSvcMgr and (not gSvcMgr.isStable()): # We are managing service, and ... + Logging.info("Ignoring error when service starting/stopping: errno = {}, msg = {}".format(errno, msg)) return True return False # Not an acceptable error @@ -1555,9 +1278,12 @@ class Task(): self.logDebug( "[-] executing task {}...".format(self.__class__.__name__)) - self._err = None + self._err = None # TODO: type hint mess up? self._execStats.beginTaskType(self.__class__.__name__) # mark beginning errno2 = None + + # Now pick a database, and stick with it for the duration of the task execution + dbName = self._db.getName() try: self._executeInternal(te, wt) # TODO: no return value? except taos.error.ProgrammingError as err: @@ -1595,11 +1321,12 @@ class Task(): self._err = e self._aborted = True traceback.print_exc() - except BaseException: - self.logDebug( - "[=] Unexpected exception, SQL: {}".format( - wt.getDbConn().getLastSql())) - raise + except BaseException: # TODO: what is this again??!! + raise RuntimeError("Punt") + # self.logDebug( + # "[=] Unexpected exception, SQL: {}".format( + # wt.getDbConn().getLastSql())) + # raise self._execStats.endTaskType(self.__class__.__name__, self.isSuccess()) self.logDebug("[X] task execution completed, {}, status: {}".format( @@ -1607,10 +1334,9 @@ class Task(): # TODO: merge with above. self._execStats.incExecCount(self.__class__.__name__, self.isSuccess(), errno2) - def execSql(self, sql): - return self._dbManager.execute(sql) - + # TODO: refactor away, just provide the dbConn def execWtSql(self, wt: WorkerThread, sql): # execute an SQL on the worker thread + """ Haha """ return wt.execSql(sql) def queryWtSql(self, wt: WorkerThread, sql): # execute an SQL on the worker thread @@ -1679,14 +1405,14 @@ class ExecutionStats: self._failureReason = reason def printStats(self): - logger.info( + Logging.info( "----------------------------------------------------------------------") - logger.info( + Logging.info( "| Crash_Gen test {}, with the following stats:". format( "FAILED (reason: {})".format( self._failureReason) if self._failed else "SUCCEEDED")) - logger.info("| Task Execution Times (success/total):") - execTimesAny = 0 + Logging.info("| Task Execution Times (success/total):") + execTimesAny = 0.0 for k, n in self._execTimes.items(): execTimesAny += n[0] errStr = None @@ -1696,24 +1422,28 @@ class ExecutionStats: errStrs = ["0x{:X}:{}".format(eno, n) for (eno, n) in errors.items()] # print("error strings = {}".format(errStrs)) errStr = ", ".join(errStrs) - logger.info("| {0:<24}: {1}/{2} (Errors: {3})".format(k, n[1], n[0], errStr)) + Logging.info("| {0:<24}: {1}/{2} (Errors: {3})".format(k, n[1], n[0], errStr)) - logger.info( + Logging.info( "| Total Tasks Executed (success or not): {} ".format(execTimesAny)) - logger.info( + Logging.info( "| Total Tasks In Progress at End: {}".format( self._tasksInProgress)) - logger.info( + Logging.info( "| Total Task Busy Time (elapsed time when any task is in progress): {:.3f} seconds".format( self._accRunTime)) - logger.info( + Logging.info( "| Average Per-Task Execution Time: {:.3f} seconds".format(self._accRunTime / execTimesAny)) - logger.info( + Logging.info( "| Total Elapsed Time (from wall clock): {:.3f} seconds".format( self._elapsedTime)) - logger.info("| Top numbers written: {}".format(TaskExecutor.getBoundedList())) - logger.info("| Total Number of Active DB Native Connections: {}".format(DbConnNative.totalConnections)) - logger.info( + Logging.info("| Top numbers written: {}".format(TaskExecutor.getBoundedList())) + Logging.info("| Active DB Native Connections (now): {}".format(DbConnNative.totalConnections)) + Logging.info("| Longest native query time: {:.3f} seconds, started: {}". + format(MyTDSql.longestQueryTime, + time.strftime("%x %X", time.localtime(MyTDSql.lqStartTime))) ) + Logging.info("| Longest native query: {}".format(MyTDSql.longestQuery)) + Logging.info( "----------------------------------------------------------------------") @@ -1723,11 +1453,14 @@ class StateTransitionTask(Task): LARGE_NUMBER_OF_RECORDS = 50 SMALL_NUMBER_OF_RECORDS = 3 + _baseTableNumber = None + + _endState = None + @classmethod def getInfo(cls): # each sub class should supply their own information raise RuntimeError("Overriding method expected") - - _endState = None + @classmethod def getEndState(cls): # TODO: optimize by calling it fewer times raise RuntimeError("Overriding method expected") @@ -1747,7 +1480,10 @@ class StateTransitionTask(Task): @classmethod def getRegTableName(cls, i): - return "reg_table_{}".format(i) + if ( StateTransitionTask._baseTableNumber is None): + StateTransitionTask._baseTableNumber = Dice.throw( + 999) if gConfig.dynamic_db_table_names else 0 + return "reg_table_{}".format(StateTransitionTask._baseTableNumber + i) def execute(self, wt: WorkerThread): super().execute(wt) @@ -1762,9 +1498,16 @@ class TaskCreateDb(StateTransitionTask): def canBeginFrom(cls, state: AnyState): return state.canCreateDb() + # Actually creating the database(es) def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): - # self.execWtSql(wt, "create database db replica {}".format(Dice.throw(3)+1)) - self.execWtSql(wt, "create database db") + # was: self.execWtSql(wt, "create database db") + repStr = "" + if gConfig.max_replicas != 1: + # numReplica = Dice.throw(gConfig.max_replicas) + 1 # 1,2 ... N + numReplica = gConfig.max_replicas # fixed, always + repStr = "replica {}".format(numReplica) + self.execWtSql(wt, "create database {} {}" + .format(self._db.getName(), repStr) ) class TaskDropDb(StateTransitionTask): @classmethod @@ -1776,9 +1519,8 @@ class TaskDropDb(StateTransitionTask): return state.canDropDb() def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): - self.execWtSql(wt, "drop database db") - logger.debug("[OPS] database dropped at {}".format(time.time())) - + self.execWtSql(wt, "drop database {}".format(self._db.getName())) + Logging.debug("[OPS] database dropped at {}".format(time.time())) class TaskCreateSuperTable(StateTransitionTask): @classmethod @@ -1790,13 +1532,14 @@ class TaskCreateSuperTable(StateTransitionTask): return state.canCreateFixedSuperTable() def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): - if not wt.dbInUse(): # no DB yet, to the best of our knowledge - logger.debug("Skipping task, no DB yet") + if not self._db.exists(wt.getDbConn()): + Logging.debug("Skipping task, no DB yet") return - sTable = self._dbManager.getFixedSuperTable() + sTable = self._db.getFixedSuperTable() # type: TdSuperTable # wt.execSql("use db") # should always be in place - sTable.create(wt.getDbConn(), {'ts':'timestamp', 'speed':'int'}, {'b':'binary(200)', 'f':'float'}) + sTable.create(wt.getDbConn(), self._db.getName(), + {'ts':'timestamp', 'speed':'int'}, {'b':'binary(200)', 'f':'float'}) # self.execWtSql(wt,"create table db.{} (ts timestamp, speed int) tags (b binary(200), f float) ".format(tblName)) # No need to create the regular tables, INSERT will do that # automatically @@ -1809,39 +1552,42 @@ class TdSuperTable: def getName(self): return self._stName - def create(self, dbc, cols: dict, tags: dict): - sql = "CREATE TABLE db.{} ({}) TAGS ({})".format( + # TODO: odd semantic, create() method is usually static? + def create(self, dbc, dbName, cols: dict, tags: dict): + '''Creating a super table''' + sql = "CREATE TABLE {}.{} ({}) TAGS ({})".format( + dbName, self._stName, ",".join(['%s %s'%(k,v) for (k,v) in cols.items()]), ",".join(['%s %s'%(k,v) for (k,v) in tags.items()]) ) dbc.execute(sql) - def getRegTables(self, dbc: DbConn): + def getRegTables(self, dbc: DbConn, dbName: str): try: - dbc.query("select TBNAME from db.{}".format(self._stName)) # TODO: analyze result set later + dbc.query("select TBNAME from {}.{}".format(dbName, self._stName)) # TODO: analyze result set later except taos.error.ProgrammingError as err: errno2 = Helper.convertErrno(err.errno) - logger.debug("[=] Failed to get tables from super table: errno=0x{:X}, msg: {}".format(errno2, err)) + Logging.debug("[=] Failed to get tables from super table: errno=0x{:X}, msg: {}".format(errno2, err)) raise qr = dbc.getQueryResult() return [v[0] for v in qr] # list transformation, ref: https://stackoverflow.com/questions/643823/python-list-transformation - def hasRegTables(self, dbc: DbConn): - return dbc.query("SELECT * FROM db.{}".format(self._stName)) > 0 + def hasRegTables(self, dbc: DbConn, dbName: str): + return dbc.query("SELECT * FROM {}.{}".format(dbName, self._stName)) > 0 - def ensureTable(self, dbc: DbConn, regTableName: str): - sql = "select tbname from db.{} where tbname in ('{}')".format(self._stName, regTableName) + def ensureTable(self, dbc: DbConn, dbName: str, regTableName: str): + sql = "select tbname from {}.{} where tbname in ('{}')".format(dbName, self._stName, regTableName) if dbc.query(sql) >= 1 : # reg table exists already return - sql = "CREATE TABLE {} USING {} tags ({})".format( - regTableName, self._stName, self._getTagStrForSql(dbc) + sql = "CREATE TABLE {}.{} USING {}.{} tags ({})".format( + dbName, regTableName, dbName, self._stName, self._getTagStrForSql(dbc, dbName) ) dbc.execute(sql) - def _getTagStrForSql(self, dbc) : - tags = self._getTags(dbc) + def _getTagStrForSql(self, dbc, dbName: str) : + tags = self._getTags(dbc, dbName) tagStrs = [] for tagName in tags: tagType = tags[tagName] @@ -1855,34 +1601,34 @@ class TdSuperTable: raise RuntimeError("Unexpected tag type: {}".format(tagType)) return ", ".join(tagStrs) - def _getTags(self, dbc) -> dict: - dbc.query("DESCRIBE {}".format(self._stName)) + def _getTags(self, dbc, dbName) -> dict: + dbc.query("DESCRIBE {}.{}".format(dbName, self._stName)) stCols = dbc.getQueryResult() # print(stCols) ret = {row[0]:row[1] for row in stCols if row[3]=='TAG'} # name:type # print("Tags retrieved: {}".format(ret)) return ret - def addTag(self, dbc, tagName, tagType): - if tagName in self._getTags(dbc): # already + def addTag(self, dbc, dbName, tagName, tagType): + if tagName in self._getTags(dbc, dbName): # already return # sTable.addTag("extraTag", "int") - sql = "alter table db.{} add tag {} {}".format(self._stName, tagName, tagType) + sql = "alter table {}.{} add tag {} {}".format(dbName, self._stName, tagName, tagType) dbc.execute(sql) - def dropTag(self, dbc, tagName): - if not tagName in self._getTags(dbc): # don't have this tag + def dropTag(self, dbc, dbName, tagName): + if not tagName in self._getTags(dbc, dbName): # don't have this tag return - sql = "alter table db.{} drop tag {}".format(self._stName, tagName) + sql = "alter table {}.{} drop tag {}".format(dbName, self._stName, tagName) dbc.execute(sql) - def changeTag(self, dbc, oldTag, newTag): - tags = self._getTags(dbc) + def changeTag(self, dbc, dbName, oldTag, newTag): + tags = self._getTags(dbc, dbName) if not oldTag in tags: # don't have this tag return if newTag in tags: # already have this tag return - sql = "alter table db.{} change tag {} {}".format(self._stName, oldTag, newTag) + sql = "alter table {}.{} change tag {} {}".format(dbName, self._stName, oldTag, newTag) dbc.execute(sql) class TaskReadData(StateTransitionTask): @@ -1895,19 +1641,21 @@ class TaskReadData(StateTransitionTask): return state.canReadData() def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): - sTable = self._dbManager.getFixedSuperTable() + sTable = self._db.getFixedSuperTable() - if random.randrange( - 5) == 0: # 1 in 5 chance, simulate a broken connection. TODO: break connection in all situations + # 1 in 5 chance, simulate a broken connection. + if random.randrange(5) == 0: # TODO: break connection in all situations wt.getDbConn().close() wt.getDbConn().open() + print("_r", end="", flush=True) dbc = wt.getDbConn() - for rTbName in sTable.getRegTables(dbc): # regular tables + dbName = self._db.getName() + for rTbName in sTable.getRegTables(dbc, dbName): # regular tables aggExpr = Dice.choice([ - '*', - 'count(*)', - 'avg(speed)', + '*', + 'count(*)', + 'avg(speed)', # 'twa(speed)', # TODO: this one REQUIRES a where statement, not reasonable 'sum(speed)', 'stddev(speed)', @@ -1929,13 +1677,13 @@ class TaskReadData(StateTransitionTask): ]) try: # Run the query against the regular table first - dbc.execute("select {} from db.{}".format(aggExpr, rTbName)) + dbc.execute("select {} from {}.{}".format(aggExpr, dbName, rTbName)) # Then run it against the super table if aggExpr not in ['stddev(speed)']: #TODO: STDDEV not valid for super tables?! - dbc.execute("select {} from db.{}".format(aggExpr, sTable.getName())) + dbc.execute("select {} from {}.{}".format(aggExpr, dbName, sTable.getName())) except taos.error.ProgrammingError as err: errno2 = Helper.convertErrno(err.errno) - logger.debug("[=] Read Failure: errno=0x{:X}, msg: {}, SQL: {}".format(errno2, err, dbc.getLastSql())) + Logging.debug("[=] Read Failure: errno=0x{:X}, msg: {}, SQL: {}".format(errno2, err, dbc.getLastSql())) raise class TaskDropSuperTable(StateTransitionTask): @@ -1948,27 +1696,25 @@ class TaskDropSuperTable(StateTransitionTask): return state.canDropFixedSuperTable() def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): - # 1/2 chance, we'll drop the regular tables one by one, in a randomized - # sequence + # 1/2 chance, we'll drop the regular tables one by one, in a randomized sequence if Dice.throw(2) == 0: + # print("_7_", end="", flush=True) tblSeq = list(range( 2 + (self.LARGE_NUMBER_OF_TABLES if gConfig.larger_data else self.SMALL_NUMBER_OF_TABLES))) random.shuffle(tblSeq) tickOutput = False # if we have spitted out a "d" character for "drop regular table" isSuccess = True for i in tblSeq: - regTableName = self.getRegTableName( - i) # "db.reg_table_{}".format(i) + regTableName = self.getRegTableName(i) # "db.reg_table_{}".format(i) try: - self.execWtSql(wt, "drop table {}".format( - regTableName)) # nRows always 0, like MySQL + self.execWtSql(wt, "drop table {}.{}". + format(self._db.getName(), regTableName)) # nRows always 0, like MySQL except taos.error.ProgrammingError as err: # correcting for strange error number scheme errno2 = Helper.convertErrno(err.errno) if (errno2 in [0x362]): # mnode invalid table name isSuccess = False - logger.debug( - "[DB] Acceptable error when dropping a table") + Logging.debug("[DB] Acceptable error when dropping a table") continue # try to delete next regular table if (not tickOutput): @@ -1979,8 +1725,8 @@ class TaskDropSuperTable(StateTransitionTask): print("f", end="", flush=True) # Drop the super table itself - tblName = self._dbManager.getFixedSuperTableName() - self.execWtSql(wt, "drop table db.{}".format(tblName)) + tblName = self._db.getFixedSuperTableName() + self.execWtSql(wt, "drop table {}.{}".format(self._db.getName(), tblName)) class TaskAlterTags(StateTransitionTask): @@ -1995,19 +1741,20 @@ class TaskAlterTags(StateTransitionTask): def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): # tblName = self._dbManager.getFixedSuperTableName() dbc = wt.getDbConn() - sTable = self._dbManager.getFixedSuperTable() + sTable = self._db.getFixedSuperTable() + dbName = self._db.getName() dice = Dice.throw(4) if dice == 0: - sTable.addTag(dbc, "extraTag", "int") + sTable.addTag(dbc, dbName, "extraTag", "int") # sql = "alter table db.{} add tag extraTag int".format(tblName) elif dice == 1: - sTable.dropTag(dbc, "extraTag") + sTable.dropTag(dbc, dbName, "extraTag") # sql = "alter table db.{} drop tag extraTag".format(tblName) elif dice == 2: - sTable.dropTag(dbc, "newTag") + sTable.dropTag(dbc, dbName, "newTag") # sql = "alter table db.{} drop tag newTag".format(tblName) else: # dice == 3 - sTable.changeTag(dbc, "extraTag", "newTag") + sTable.changeTag(dbc, dbName, "extraTag", "newTag") # sql = "alter table db.{} change tag extraTag newTag".format(tblName) class TaskRestartService(StateTransitionTask): @@ -2047,20 +1794,19 @@ class TaskAddData(StateTransitionTask): # Track which table is being actively worked on activeTable: Set[int] = set() - # We use these two files to record operations to DB, useful for power-off - # tests - fAddLogReady = None - fAddLogDone = None + # We use these two files to record operations to DB, useful for power-off tests + fAddLogReady = None # type: TextIOWrapper + fAddLogDone = None # type: TextIOWrapper @classmethod def prepToRecordOps(cls): if gConfig.record_ops: if (cls.fAddLogReady is None): - logger.info( + Logging.info( "Recording in a file operations to be performed...") cls.fAddLogReady = open("add_log_ready.txt", "w") if (cls.fAddLogDone is None): - logger.info("Recording in a file operations completed...") + Logging.info("Recording in a file operations completed...") cls.fAddLogDone = open("add_log_done.txt", "w") @classmethod @@ -2072,7 +1818,9 @@ class TaskAddData(StateTransitionTask): return state.canAddData() def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): - ds = self._dbManager # Quite DANGEROUS here, may result in multi-thread client access + # ds = self._dbManager # Quite DANGEROUS here, may result in multi-thread client access + db = self._db + dbc = wt.getDbConn() tblSeq = list(range( self.LARGE_NUMBER_OF_TABLES if gConfig.larger_data else self.SMALL_NUMBER_OF_TABLES)) random.shuffle(tblSeq) @@ -2082,23 +1830,25 @@ class TaskAddData(StateTransitionTask): else: self.activeTable.add(i) # marking it active - sTable = ds.getFixedSuperTable() + sTable = db.getFixedSuperTable() regTableName = self.getRegTableName(i) # "db.reg_table_{}".format(i) - sTable.ensureTable(wt.getDbConn(), regTableName) # Ensure the table exists + sTable.ensureTable(wt.getDbConn(), db.getName(), regTableName) # Ensure the table exists for j in range(self.LARGE_NUMBER_OF_RECORDS if gConfig.larger_data else self.SMALL_NUMBER_OF_RECORDS): # number of records per table - nextInt = ds.getNextInt() + nextInt = db.getNextInt() + nextTick = db.getNextTick() if gConfig.record_ops: self.prepToRecordOps() self.fAddLogReady.write("Ready to write {} to {}\n".format(nextInt, regTableName)) self.fAddLogReady.flush() os.fsync(self.fAddLogReady) - sql = "insert into {} values ('{}', {});".format( # removed: tags ('{}', {}) + sql = "insert into {}.{} values ('{}', {});".format( # removed: tags ('{}', {}) + db.getName(), regTableName, # ds.getFixedSuperTableName(), # ds.getNextBinary(), ds.getNextFloat(), - ds.getNextTick(), nextInt) - self.execWtSql(wt, sql) + nextTick, nextInt) + dbc.execute(sql) # Successfully wrote the data into the DB, let's record it # somehow te.recordDataMark(nextInt) @@ -2108,494 +1858,32 @@ class TaskAddData(StateTransitionTask): nextInt, regTableName)) self.fAddLogDone.flush() os.fsync(self.fAddLogDone) - self.activeTable.discard(i) # not raising an error, unlike remove + # Now read it back and verify, we might encounter an error if table is dropped + if gConfig.verify_data: # only if command line asks for it + try: + readBack = dbc.queryScalar("SELECT speed from {}.{} WHERE ts= '{}'". + format(db.getName(), regTableName, nextTick)) + if readBack != nextInt : + raise taos.error.ProgrammingError( + "Failed to read back same data, wrote: {}, read: {}" + .format(nextInt, readBack), 0x999) + except taos.error.ProgrammingError as err: + errno = Helper.convertErrno(err.errno) + if errno in [0x991, 0x992] : # not a single result + raise taos.error.ProgrammingError( + "Failed to read back same data for tick: {}, wrote: {}, read: {}" + .format(nextTick, nextInt, "Empty Result" if errno==0x991 else "Multiple Result"), + errno) + # Re-throw no matter what + raise + -# Deterministic random number generator -class Dice(): - seeded = False # static, uninitialized - - @classmethod - def seed(cls, s): # static - if (cls.seeded): - raise RuntimeError( - "Cannot seed the random generator more than once") - cls.verifyRNG() - random.seed(s) - cls.seeded = True # TODO: protect against multi-threading - - @classmethod - def verifyRNG(cls): # Verify that the RNG is determinstic - random.seed(0) - x1 = random.randrange(0, 1000) - x2 = random.randrange(0, 1000) - x3 = random.randrange(0, 1000) - if (x1 != 864 or x2 != 394 or x3 != 776): - raise RuntimeError("System RNG is not deterministic") - - @classmethod - def throw(cls, stop): # get 0 to stop-1 - return cls.throwRange(0, stop) - - @classmethod - def throwRange(cls, start, stop): # up to stop-1 - if (not cls.seeded): - raise RuntimeError("Cannot throw dice before seeding it") - return random.randrange(start, stop) - - @classmethod - def choice(cls, cList): - return random.choice(cList) - - -class LoggingFilter(logging.Filter): - def filter(self, record: logging.LogRecord): - if (record.levelno >= logging.INFO): - return True # info or above always log - - # Commenting out below to adjust... - - # if msg.startswith("[TRD]"): - # return False - return True - - -class MyLoggingAdapter(logging.LoggerAdapter): - def process(self, msg, kwargs): - return "[{}]{}".format(threading.get_ident() % 10000, msg), kwargs - # return '[%s] %s' % (self.extra['connid'], msg), kwargs - - -class SvcManager: - def __init__(self): - print("Starting TDengine Service Manager") - # signal.signal(signal.SIGTERM, self.sigIntHandler) # Moved to MainExec - # signal.signal(signal.SIGINT, self.sigIntHandler) - # signal.signal(signal.SIGUSR1, self.sigUsrHandler) # different handler! - - self.inSigHandler = False - # self._status = MainExec.STATUS_RUNNING # set inside - # _startTaosService() - self.svcMgrThread = None - self._lock = threading.Lock() - self._isRestarting = False - - def _doMenu(self): - choice = "" - while True: - print("\nInterrupting Service Program, Choose an Action: ") - print("1: Resume") - print("2: Terminate") - print("3: Restart") - # Remember to update the if range below - # print("Enter Choice: ", end="", flush=True) - while choice == "": - choice = input("Enter Choice: ") - if choice != "": - break # done with reading repeated input - if choice in ["1", "2", "3"]: - break # we are done with whole method - print("Invalid choice, please try again.") - choice = "" # reset - return choice - - def sigUsrHandler(self, signalNumber, frame): - print("Interrupting main thread execution upon SIGUSR1") - if self.inSigHandler: # already - print("Ignoring repeated SIG...") - return # do nothing if it's already not running - self.inSigHandler = True - - choice = self._doMenu() - if choice == "1": - # TODO: can the sub-process be blocked due to us not reading from - # queue? - self.sigHandlerResume() - elif choice == "2": - self.stopTaosService() - elif choice == "3": # Restart - self.restart() - else: - raise RuntimeError("Invalid menu choice: {}".format(choice)) - - self.inSigHandler = False - - def sigIntHandler(self, signalNumber, frame): - print("SvcManager: INT Signal Handler starting...") - if self.inSigHandler: - print("Ignoring repeated SIG_INT...") - return - self.inSigHandler = True - - self.stopTaosService() - print("SvcManager: INT Signal Handler returning...") - self.inSigHandler = False - - def sigHandlerResume(self): - print("Resuming TDengine service manager thread (main thread)...\n\n") - - def _checkServiceManagerThread(self): - if self.svcMgrThread: # valid svc mgr thread - if self.svcMgrThread.isStopped(): # done? - self.svcMgrThread.procIpcBatch() # one last time. TODO: appropriate? - self.svcMgrThread = None # no more - - def _procIpcAll(self): - while self.isRunning() or self.isRestarting() : # for as long as the svc mgr thread is still here - if self.isRunning(): - self.svcMgrThread.procIpcBatch() # regular processing, - self._checkServiceManagerThread() - elif self.isRetarting(): - print("Service restarting...") - time.sleep(0.5) # pause, before next round - print( - "Service Manager Thread (with subprocess) has ended, main thread now exiting...") - - def startTaosService(self): - with self._lock: - if self.svcMgrThread: - raise RuntimeError("Cannot start TAOS service when one may already be running") - - # Find if there's already a taosd service, and then kill it - for proc in psutil.process_iter(): - if proc.name() == 'taosd': - print("Killing an existing TAOSD process in 2 seconds... press CTRL-C to interrupe") - time.sleep(2.0) - proc.kill() - # print("Process: {}".format(proc.name())) - - self.svcMgrThread = ServiceManagerThread() # create the object - print("Attempting to start TAOS service started, printing out output...") - self.svcMgrThread.start() - self.svcMgrThread.procIpcBatch( - trimToTarget=10, - forceOutput=True) # for printing 10 lines - print("TAOS service started") - - def stopTaosService(self, outputLines=20): - with self._lock: - if not self.isRunning(): - logger.warning("Cannot stop TAOS service, not running") - return - - print("Terminating Service Manager Thread (SMT) execution...") - self.svcMgrThread.stop() - if self.svcMgrThread.isStopped(): - self.svcMgrThread.procIpcBatch(outputLines) # one last time - self.svcMgrThread = None - print("End of TDengine Service Output") - print("----- TDengine Service (managed by SMT) is now terminated -----\n") - else: - print("WARNING: SMT did not terminate as expected") - - def run(self): - self.startTaosService() - self._procIpcAll() # pump/process all the messages, may encounter SIG + restart - if self.isRunning(): # if sig handler hasn't destroyed it by now - self.stopTaosService() # should have started already - - def restart(self): - if self._isRestarting: - logger.warning("Cannot restart service when it's already restarting") - return - - self._isRestarting = True - if self.isRunning(): - self.stopTaosService() - else: - logger.warning("Service not running when restart requested") - - self.startTaosService() - self._isRestarting = False - - def isRunning(self): - return self.svcMgrThread != None - - def isRestarting(self): - return self._isRestarting - -class ServiceManagerThread: - MAX_QUEUE_SIZE = 10000 - - def __init__(self): - self._tdeSubProcess = None - self._thread = None - self._status = None - - def getStatus(self): - return self._status - - def isRunning(self): - # return self._thread and self._thread.is_alive() - return self._status == MainExec.STATUS_RUNNING - - def isStopping(self): - return self._status == MainExec.STATUS_STOPPING - - def isStopped(self): - return self._status == MainExec.STATUS_STOPPED - - # Start the thread (with sub process), and wait for the sub service - # to become fully operational - def start(self): - if self._thread: - raise RuntimeError("Unexpected _thread") - if self._tdeSubProcess: - raise RuntimeError("TDengine sub process already created/running") - - self._status = MainExec.STATUS_STARTING - - self._tdeSubProcess = TdeSubProcess() - self._tdeSubProcess.start() - - self._ipcQueue = Queue() - self._thread = threading.Thread( - target=self.svcOutputReader, - args=(self._tdeSubProcess.getStdOut(), self._ipcQueue)) - self._thread.daemon = True # thread dies with the program - self._thread.start() - - self._thread2 = threading.Thread( - target=self.svcErrorReader, - args=(self._tdeSubProcess.getStdErr(), self._ipcQueue)) - self._thread2.daemon = True # thread dies with the program - self._thread2.start() - - # wait for service to start - for i in range(0, 100): - time.sleep(1.0) - # self.procIpcBatch() # don't pump message during start up - print("_zz_", end="", flush=True) - if self._status == MainExec.STATUS_RUNNING: - logger.info("[] TDengine service READY to process requests") - return # now we've started - # TODO: handle this better? - self.procIpcBatch(100, True) # display output before cronking out, trim to last 20 msgs, force output - raise RuntimeError("TDengine service did not start successfully") - - def stop(self): - # can be called from both main thread or signal handler - print("Terminating TDengine service running as the sub process...") - if self.isStopped(): - print("Service already stopped") - return - if self.isStopping(): - print("Service is already being stopped") - return - # Linux will send Control-C generated SIGINT to the TDengine process - # already, ref: - # https://unix.stackexchange.com/questions/176235/fork-and-how-signals-are-delivered-to-processes - if not self._tdeSubProcess: - raise RuntimeError("sub process object missing") - - self._status = MainExec.STATUS_STOPPING - retCode = self._tdeSubProcess.stop() - print("Attempted to stop sub process, got return code: {}".format(retCode)) - if (retCode==-11): # SGV - logger.error("[[--ERROR--]]: TDengine service SEGV fault (check core file!)") - - if self._tdeSubProcess.isRunning(): # still running - print("FAILED to stop sub process, it is still running... pid = {}".format( - self._tdeSubProcess.getPid())) - else: - self._tdeSubProcess = None # not running any more - self.join() # stop the thread, change the status, etc. - - def join(self): - # TODO: sanity check - if not self.isStopping(): - raise RuntimeError( - "Unexpected status when ending svc mgr thread: {}".format( - self._status)) - - if self._thread: - self._thread.join() - self._thread = None - self._status = MainExec.STATUS_STOPPED - # STD ERR thread - self._thread2.join() - self._thread2 = None - else: - print("Joining empty thread, doing nothing") - - def _trimQueue(self, targetSize): - if targetSize <= 0: - return # do nothing - q = self._ipcQueue - if (q.qsize() <= targetSize): # no need to trim - return - - logger.debug("Triming IPC queue to target size: {}".format(targetSize)) - itemsToTrim = q.qsize() - targetSize - for i in range(0, itemsToTrim): - try: - q.get_nowait() - except Empty: - break # break out of for loop, no more trimming - - TD_READY_MSG = "TDengine is initialized successfully" - - def procIpcBatch(self, trimToTarget=0, forceOutput=False): - self._trimQueue(trimToTarget) # trim if necessary - # Process all the output generated by the underlying sub process, - # managed by IO thread - print("<", end="", flush=True) - while True: - try: - line = self._ipcQueue.get_nowait() # getting output at fast speed - self._printProgress("_o") - except Empty: - # time.sleep(2.3) # wait only if there's no output - # no more output - print(".>", end="", flush=True) - return # we are done with THIS BATCH - else: # got line, printing out - if forceOutput: - logger.info(line) - else: - logger.debug(line) - print(">", end="", flush=True) - - _ProgressBars = ["--", "//", "||", "\\\\"] - - def _printProgress(self, msg): # TODO: assuming 2 chars - print(msg, end="", flush=True) - pBar = self._ProgressBars[Dice.throw(4)] - print(pBar, end="", flush=True) - print('\b\b\b\b', end="", flush=True) - - def svcOutputReader(self, out: IO, queue): - # Important Reference: https://stackoverflow.com/questions/375427/non-blocking-read-on-a-subprocess-pipe-in-python - # print("This is the svcOutput Reader...") - # for line in out : - for line in iter(out.readline, b''): - # print("Finished reading a line: {}".format(line)) - # print("Adding item to queue...") - try: - line = line.decode("utf-8").rstrip() - except UnicodeError: - print("\nNon-UTF8 server output: {}\n".format(line)) - - # This might block, and then causing "out" buffer to block - queue.put(line) - self._printProgress("_i") - - if self._status == MainExec.STATUS_STARTING: # we are starting, let's see if we have started - if line.find(self.TD_READY_MSG) != -1: # found - logger.info("Waiting for the service to become FULLY READY") - time.sleep(1.0) # wait for the server to truly start. TODO: remove this - logger.info("Service is now FULLY READY") - self._status = MainExec.STATUS_RUNNING - - # Trim the queue if necessary: TODO: try this 1 out of 10 times - self._trimQueue(self.MAX_QUEUE_SIZE * 9 // 10) # trim to 90% size - - if self.isStopping(): # TODO: use thread status instead - # WAITING for stopping sub process to finish its outptu - print("_w", end="", flush=True) - - # queue.put(line) - # meaning sub process must have died - print("\nNo more output from IO thread managing TDengine service") - out.close() - - def svcErrorReader(self, err: IO, queue): - for line in iter(err.readline, b''): - print("\nTDengine Service (taosd) ERROR (from stderr): {}".format(line)) - - -class TdeSubProcess: - def __init__(self): - self.subProcess = None - - def getStdOut(self): - return self.subProcess.stdout - - def getStdErr(self): - return self.subProcess.stderr - - def isRunning(self): - return self.subProcess is not None + self.activeTable.discard(i) # not raising an error, unlike remove - def getPid(self): - return self.subProcess.pid - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("communit")] - 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 start(self): - ON_POSIX = 'posix' in sys.builtin_module_names - - taosdPath = self.getBuildPath() + "/build/bin/taosd" - cfgPath = self.getBuildPath() + "/test/cfg" - - # Delete the log files - logPath = self.getBuildPath() + "/test/log" - # ref: https://stackoverflow.com/questions/1995373/deleting-all-files-in-a-directory-with-python/1995397 - # filelist = [ f for f in os.listdir(logPath) ] # if f.endswith(".bak") ] - # for f in filelist: - # filePath = os.path.join(logPath, f) - # print("Removing log file: {}".format(filePath)) - # os.remove(filePath) - if os.path.exists(logPath): - logPathSaved = logPath + "_" + time.strftime('%Y-%m-%d-%H-%M-%S') - logger.info("Saving old log files to: {}".format(logPathSaved)) - os.rename(logPath, logPathSaved) - # os.mkdir(logPath) # recreate, no need actually, TDengine will auto-create with proper perms - - svcCmd = [taosdPath, '-c', cfgPath] - # svcCmdSingle = "{} -c {}".format(taosdPath, cfgPath) - # svcCmd = ['vmstat', '1'] - if self.subProcess: # already there - raise RuntimeError("Corrupt process state") - - # print("Starting service: {}".format(svcCmd)) - self.subProcess = subprocess.Popen( - svcCmd, shell=False, - # svcCmdSingle, shell=True, # capture core dump? - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - # bufsize=1, # not supported in binary mode - close_fds=ON_POSIX - ) # had text=True, which interferred with reading EOF - - def stop(self): - if not self.subProcess: - print("Sub process already stopped") - return -1 - - retCode = self.subProcess.poll() # contains real sub process return code - if retCode: # valid return code, process ended - self.subProcess = None - else: # process still alive, let's interrupt it - print( - "Sub process is running, sending SIG_INT and waiting for it to terminate...") - # sub process should end, then IPC queue should end, causing IO - # thread to end - self.subProcess.send_signal(signal.SIGINT) - try: - self.subProcess.wait(10) - retCode = self.subProcess.returncode - except subprocess.TimeoutExpired as err: - print("Time out waiting for TDengine service process to exit") - retCode = -3 - else: - print("TDengine service process terminated successfully from SIG_INT") - retCode = -4 - self.subProcess = None - return retCode class ThreadStacks: # stack info for all threads def __init__(self): @@ -2632,17 +1920,17 @@ class ClientManager: # signal.signal(signal.SIGTERM, self.sigIntHandler) # signal.signal(signal.SIGINT, self.sigIntHandler) - self._status = MainExec.STATUS_RUNNING + self._status = Status.STATUS_RUNNING self.tc = None self.inSigHandler = False def sigIntHandler(self, signalNumber, frame): - if self._status != MainExec.STATUS_RUNNING: + if self._status != Status.STATUS_RUNNING: print("Repeated SIGINT received, forced exit...") # return # do nothing if it's already not running sys.exit(-1) - self._status = MainExec.STATUS_STOPPING # immediately set our status + self._status = Status.STATUS_STOPPING # immediately set our status print("ClientManager: Terminating program...") self.tc.requestToStop() @@ -2688,69 +1976,87 @@ class ClientManager: self.inSigHandler = False - def _printLastNumbers(self): # to verify data durability - dbManager = DbManager(resetDb=False) - dbc = dbManager.getDbConn() - if dbc.query("show databases") <= 1: # no database (we have a default called "log") - return - dbc.execute("use db") - if dbc.query("show tables") == 0: # no tables - return - - sTbName = dbManager.getFixedSuperTableName() - - # get all regular tables - # TODO: analyze result set later - dbc.query("select TBNAME from db.{}".format(sTbName)) - rTables = dbc.getQueryResult() - - bList = TaskExecutor.BoundedList() - for rTbName in rTables: # regular tables - dbc.query("select speed from db.{}".format(rTbName[0])) - numbers = dbc.getQueryResult() - for row in numbers: - # print("<{}>".format(n), end="", flush=True) - bList.add(row[0]) - - print("Top numbers in DB right now: {}".format(bList)) - print("TDengine client execution is about to start in 2 seconds...") - time.sleep(2.0) - dbManager = None # release? - - def prepare(self): - self._printLastNumbers() + # TODO: need to revise how we verify data durability + # def _printLastNumbers(self): # to verify data durability + # dbManager = DbManager() + # dbc = dbManager.getDbConn() + # if dbc.query("show databases") <= 1: # no database (we have a default called "log") + # return + # dbc.execute("use db") + # if dbc.query("show tables") == 0: # no tables + # return + + # sTbName = dbManager.getFixedSuperTableName() + + # # get all regular tables + # # TODO: analyze result set later + # dbc.query("select TBNAME from db.{}".format(sTbName)) + # rTables = dbc.getQueryResult() + + # bList = TaskExecutor.BoundedList() + # for rTbName in rTables: # regular tables + # dbc.query("select speed from db.{}".format(rTbName[0])) + # numbers = dbc.getQueryResult() + # for row in numbers: + # # print("<{}>".format(n), end="", flush=True) + # bList.add(row[0]) + + # print("Top numbers in DB right now: {}".format(bList)) + # print("TDengine client execution is about to start in 2 seconds...") + # time.sleep(2.0) + # dbManager = None # release? def run(self, svcMgr): - self._printLastNumbers() + # self._printLastNumbers() + global gConfig + + # Prepare Tde Instance + global gContainer + tInst = gContainer.defTdeInstance = TdeInstance() # "subdir to hold the instance" - dbManager = DbManager() # Regular function + dbManager = DbManager(gConfig.connector_type, tInst.getDbTarget()) # Regular function thPool = ThreadPool(gConfig.num_threads, gConfig.max_steps) self.tc = ThreadCoordinator(thPool, dbManager) + print("Starting client instance to: {}".format(tInst)) self.tc.run() # print("exec stats: {}".format(self.tc.getExecStats())) # print("TC failed = {}".format(self.tc.isFailed())) if svcMgr: # gConfig.auto_start_service: - svcMgr.stopTaosService() + svcMgr.stopTaosServices() + svcMgr = None # Print exec status, etc., AFTER showing messages from the server self.conclude() # print("TC failed (2) = {}".format(self.tc.isFailed())) # Linux return code: ref https://shapeshed.com/unix-exit-codes/ - return 1 if self.tc.isFailed() else 0 + ret = 1 if self.tc.isFailed() else 0 + self.tc.cleanup() + + # Release global variables + gConfig = None + gSvcMgr = None + logger = None + + # Release variables here + self.tc = None + thPool = None + dbManager = None + + gc.collect() # force garbage collection + # h = hpy() + # print("\n----- Final Python Heap -----\n") + # print(h.heap()) + + return ret def conclude(self): + # self.tc.getDbManager().cleanUp() # clean up first, so we can show ZERO db connections self.tc.printStats() - self.tc.getDbManager().cleanUp() class MainExec: - STATUS_STARTING = 1 - STATUS_RUNNING = 2 - STATUS_STOPPING = 3 - STATUS_STOPPED = 4 - def __init__(self): self._clientMgr = None - self._svcMgr = None + self._svcMgr = None # type: ServiceManager signal.signal(signal.SIGTERM, self.sigIntHandler) signal.signal(signal.SIGINT, self.sigIntHandler) @@ -2763,200 +2069,185 @@ class MainExec: self._svcMgr.sigUsrHandler(signalNumber, frame) def sigIntHandler(self, signalNumber, frame): - if self._svcMgr: + if self._svcMgr: self._svcMgr.sigIntHandler(signalNumber, frame) - if self._clientMgr: + if self._clientMgr: self._clientMgr.sigIntHandler(signalNumber, frame) def runClient(self): global gSvcMgr if gConfig.auto_start_service: - self._svcMgr = SvcManager() - gSvcMgr = self._svcMgr # hack alert - self._svcMgr.startTaosService() # we start, don't run + gSvcMgr = self._svcMgr = ServiceManager(1) # hack alert + gSvcMgr.startTaosServices() # we start, don't run self._clientMgr = ClientManager() ret = None try: ret = self._clientMgr.run(self._svcMgr) # stop TAOS service inside except requests.exceptions.ConnectionError as err: - logger.warning("Failed to open REST connection to DB: {}".format(err.getMessage())) + Logging.warning("Failed to open REST connection to DB: {}".format(err.getMessage())) # don't raise return ret def runService(self): global gSvcMgr - self._svcMgr = SvcManager() - gSvcMgr = self._svcMgr # save it in a global variable TODO: hack alert - - self._svcMgr.run() # run to some end state - self._svcMgr = None - gSvcMgr = None - - def runTemp(self): # for debugging purposes - # # Hack to exercise reading from disk, imcreasing coverage. TODO: fix - # dbc = dbState.getDbConn() - # sTbName = dbState.getFixedSuperTableName() - # dbc.execute("create database if not exists db") - # if not dbState.getState().equals(StateEmpty()): - # dbc.execute("use db") - - # rTables = None - # try: # the super table may not exist - # sql = "select TBNAME from db.{}".format(sTbName) - # logger.info("Finding out tables in super table: {}".format(sql)) - # dbc.query(sql) # TODO: analyze result set later - # logger.info("Fetching result") - # rTables = dbc.getQueryResult() - # logger.info("Result: {}".format(rTables)) - # except taos.error.ProgrammingError as err: - # logger.info("Initial Super table OPS error: {}".format(err)) - - # # sys.exit() - # if ( not rTables == None): - # # print("rTables[0] = {}, type = {}".format(rTables[0], type(rTables[0]))) - # try: - # for rTbName in rTables : # regular tables - # ds = dbState - # logger.info("Inserting into table: {}".format(rTbName[0])) - # sql = "insert into db.{} values ('{}', {});".format( - # rTbName[0], - # ds.getNextTick(), ds.getNextInt()) - # dbc.execute(sql) - # for rTbName in rTables : # regular tables - # dbc.query("select * from db.{}".format(rTbName[0])) # TODO: check success failure - # logger.info("Initial READING operation is successful") - # except taos.error.ProgrammingError as err: - # logger.info("Initial WRITE/READ error: {}".format(err)) - - # Sandbox testing code - # dbc = dbState.getDbConn() - # while True: - # rows = dbc.query("show databases") - # print("Rows: {}, time={}".format(rows, time.time())) - return - - -def main(): - # Super cool Python argument library: - # https://docs.python.org/3/library/argparse.html - parser = argparse.ArgumentParser( - formatter_class=argparse.RawDescriptionHelpFormatter, - description=textwrap.dedent('''\ - TDengine Auto Crash Generator (PLEASE NOTICE the Prerequisites Below) - --------------------------------------------------------------------- - 1. You build TDengine in the top level ./build directory, as described in offical docs - 2. You run the server there before this script: ./build/bin/taosd -c test/cfg - - ''')) - - # parser.add_argument('-a', '--auto-start-service', action='store_true', - # help='Automatically start/stop the TDengine service (default: false)') - # parser.add_argument('-c', '--connector-type', action='store', default='native', type=str, - # help='Connector type to use: native, rest, or mixed (default: 10)') - # parser.add_argument('-d', '--debug', action='store_true', - # help='Turn on DEBUG mode for more logging (default: false)') - # parser.add_argument('-e', '--run-tdengine', action='store_true', - # help='Run TDengine service in foreground (default: false)') - # parser.add_argument('-l', '--larger-data', action='store_true', - # help='Write larger amount of data during write operations (default: false)') - # parser.add_argument('-p', '--per-thread-db-connection', action='store_true', - # help='Use a single shared db connection (default: false)') - # parser.add_argument('-r', '--record-ops', action='store_true', - # help='Use a pair of always-fsynced fils to record operations performing + performed, for power-off tests (default: false)') - # parser.add_argument('-s', '--max-steps', action='store', default=1000, type=int, - # help='Maximum number of steps to run (default: 100)') - # parser.add_argument('-t', '--num-threads', action='store', default=5, type=int, - # help='Number of threads to run (default: 10)') - # parser.add_argument('-x', '--continue-on-exception', action='store_true', - # help='Continue execution after encountering unexpected/disallowed errors/exceptions (default: false)') - - parser.add_argument( - '-a', - '--auto-start-service', - action='store_true', - help='Automatically start/stop the TDengine service (default: false)') - parser.add_argument( - '-c', - '--connector-type', - action='store', - default='native', - type=str, - help='Connector type to use: native, rest, or mixed (default: 10)') - parser.add_argument( - '-d', - '--debug', - action='store_true', - help='Turn on DEBUG mode for more logging (default: false)') - parser.add_argument( - '-e', - '--run-tdengine', - action='store_true', - help='Run TDengine service in foreground (default: false)') - parser.add_argument( - '-l', - '--larger-data', - action='store_true', - help='Write larger amount of data during write operations (default: false)') - parser.add_argument( - '-p', - '--per-thread-db-connection', - action='store_true', - help='Use a single shared db connection (default: false)') - parser.add_argument( - '-r', - '--record-ops', - action='store_true', - help='Use a pair of always-fsynced fils to record operations performing + performed, for power-off tests (default: false)') - parser.add_argument( - '-s', - '--max-steps', - action='store', - default=1000, - type=int, - help='Maximum number of steps to run (default: 100)') - parser.add_argument( - '-t', - '--num-threads', - action='store', - default=5, - type=int, - help='Number of threads to run (default: 10)') - parser.add_argument( - '-x', - '--continue-on-exception', - action='store_true', - help='Continue execution after encountering unexpected/disallowed errors/exceptions (default: false)') - - global gConfig - gConfig = parser.parse_args() - - # Logging Stuff - global logger - _logger = logging.getLogger('CrashGen') # real logger - _logger.addFilter(LoggingFilter()) - ch = logging.StreamHandler() - _logger.addHandler(ch) - - # Logging adapter, to be used as a logger - logger = MyLoggingAdapter(_logger, []) - - if (gConfig.debug): - logger.setLevel(logging.DEBUG) # default seems to be INFO - else: - logger.setLevel(logging.INFO) - - Dice.seed(0) # initial seeding of dice - - # Run server or client - mExec = MainExec() - if gConfig.run_tdengine: # run server - mExec.runService() - else: - return mExec.runClient() - - -if __name__ == "__main__": - exitCode = main() - # print("Exiting with code: {}".format(exitCode)) - sys.exit(exitCode) + gSvcMgr = self._svcMgr = ServiceManager(gConfig.num_dnodes) # save it in a global variable TODO: hack alert + + gSvcMgr.run() # run to some end state + gSvcMgr = self._svcMgr = None + + def init(self): # TODO: refactor + global gContainer + gContainer = Container() # micky-mouse DI + + global gSvcMgr # TODO: refactor away + gSvcMgr = None + + # Super cool Python argument library: + # https://docs.python.org/3/library/argparse.html + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description=textwrap.dedent('''\ + TDengine Auto Crash Generator (PLEASE NOTICE the Prerequisites Below) + --------------------------------------------------------------------- + 1. You build TDengine in the top level ./build directory, as described in offical docs + 2. You run the server there before this script: ./build/bin/taosd -c test/cfg + + ''')) + + parser.add_argument( + '-a', + '--auto-start-service', + action='store_true', + help='Automatically start/stop the TDengine service (default: false)') + parser.add_argument( + '-b', + '--max-dbs', + action='store', + default=0, + type=int, + help='Maximum number of DBs to keep, set to disable dropping DB. (default: 0)') + parser.add_argument( + '-c', + '--connector-type', + action='store', + default='native', + type=str, + help='Connector type to use: native, rest, or mixed (default: 10)') + parser.add_argument( + '-d', + '--debug', + action='store_true', + help='Turn on DEBUG mode for more logging (default: false)') + parser.add_argument( + '-e', + '--run-tdengine', + action='store_true', + help='Run TDengine service in foreground (default: false)') + parser.add_argument( + '-g', + '--ignore-errors', + action='store', + default=None, + type=str, + help='Ignore error codes, comma separated, 0x supported (default: None)') + parser.add_argument( + '-i', + '--max-replicas', + action='store', + default=1, + type=int, + help='Maximum number of replicas to use, when testing against clusters. (default: 1)') + parser.add_argument( + '-l', + '--larger-data', + action='store_true', + help='Write larger amount of data during write operations (default: false)') + parser.add_argument( + '-n', + '--dynamic-db-table-names', + action='store_true', + help='Use non-fixed names for dbs/tables, useful for multi-instance executions (default: false)') + parser.add_argument( + '-o', + '--num-dnodes', + action='store', + default=1, + type=int, + help='Number of Dnodes to initialize, used with -e option. (default: 1)') + parser.add_argument( + '-p', + '--per-thread-db-connection', + action='store_true', + help='Use a single shared db connection (default: false)') + parser.add_argument( + '-r', + '--record-ops', + action='store_true', + help='Use a pair of always-fsynced fils to record operations performing + performed, for power-off tests (default: false)') + parser.add_argument( + '-s', + '--max-steps', + action='store', + default=1000, + type=int, + help='Maximum number of steps to run (default: 100)') + parser.add_argument( + '-t', + '--num-threads', + action='store', + default=5, + type=int, + help='Number of threads to run (default: 10)') + parser.add_argument( + '-v', + '--verify-data', + action='store_true', + help='Verify data written in a number of places by reading back (default: false)') + parser.add_argument( + '-x', + '--continue-on-exception', + action='store_true', + help='Continue execution after encountering unexpected/disallowed errors/exceptions (default: false)') + + global gConfig + gConfig = parser.parse_args() + + Logging.clsInit(gConfig) + + Dice.seed(0) # initial seeding of dice + + def run(self): + if gConfig.run_tdengine: # run server + try: + self.runService() + return 0 # success + except ConnectionError as err: + Logging.error("Failed to make DB connection, please check DB instance manually") + return -1 # failure + else: + return self.runClient() + + +class Container(): + _propertyList = {'defTdeInstance'} + + def __init__(self): + self._cargo = {} # No cargo at the beginning + + def _verifyValidProperty(self, name): + if not name in self._propertyList: + raise CrashGenError("Invalid container property: {}".format(name)) + + # Called for an attribute, when other mechanisms fail (compare to __getattribute__) + def __getattr__(self, name): + self._verifyValidProperty(name) + return self._cargo[name] # just a simple lookup + + def __setattr__(self, name, value): + if name == '_cargo' : # reserved vars + super().__setattr__(name, value) + return + self._verifyValidProperty(name) + self._cargo[name] = value + diff --git a/tests/pytest/crash_gen/db.py b/tests/pytest/crash_gen/db.py new file mode 100644 index 0000000000000000000000000000000000000000..43c855647c03d1de3e55393eb85c77250a00a602 --- /dev/null +++ b/tests/pytest/crash_gen/db.py @@ -0,0 +1,435 @@ +from __future__ import annotations + +import sys +import time +import threading +import requests +from requests.auth import HTTPBasicAuth + +import taos +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.log import * + +from .misc import Logging, CrashGenError, Helper, Dice +import os +import datetime +# from .service_manager import TdeInstance + +class DbConn: + TYPE_NATIVE = "native-c" + TYPE_REST = "rest-api" + TYPE_INVALID = "invalid" + + @classmethod + def create(cls, connType, dbTarget): + if connType == cls.TYPE_NATIVE: + return DbConnNative(dbTarget) + elif connType == cls.TYPE_REST: + return DbConnRest(dbTarget) + else: + raise RuntimeError( + "Unexpected connection type: {}".format(connType)) + + @classmethod + def createNative(cls, dbTarget) -> DbConn: + return cls.create(cls.TYPE_NATIVE, dbTarget) + + @classmethod + def createRest(cls, dbTarget) -> DbConn: + return cls.create(cls.TYPE_REST, dbTarget) + + def __init__(self, dbTarget): + self.isOpen = False + self._type = self.TYPE_INVALID + self._lastSql = None + self._dbTarget = dbTarget + + def __repr__(self): + return "[DbConn: type={}, target={}]".format(self._type, self._dbTarget) + + def getLastSql(self): + return self._lastSql + + def open(self): + if (self.isOpen): + raise RuntimeError("Cannot re-open an existing DB connection") + + # below implemented by child classes + self.openByType() + + Logging.debug("[DB] data connection opened: {}".format(self)) + self.isOpen = True + + def close(self): + raise RuntimeError("Unexpected execution, should be overriden") + + def queryScalar(self, sql) -> int: + return self._queryAny(sql) + + def queryString(self, sql) -> str: + return self._queryAny(sql) + + def _queryAny(self, sql): # actual query result as an int + if (not self.isOpen): + raise RuntimeError("Cannot query database until connection is open") + nRows = self.query(sql) + if nRows != 1: + raise taos.error.ProgrammingError( + "Unexpected result for query: {}, rows = {}".format(sql, nRows), + (0x991 if nRows==0 else 0x992) + ) + if self.getResultRows() != 1 or self.getResultCols() != 1: + raise RuntimeError("Unexpected result set for query: {}".format(sql)) + return self.getQueryResult()[0][0] + + def use(self, dbName): + self.execute("use {}".format(dbName)) + + def existsDatabase(self, dbName: str): + ''' Check if a certain database exists ''' + self.query("show databases") + dbs = [v[0] for v in self.getQueryResult()] # ref: https://stackoverflow.com/questions/643823/python-list-transformation + # ret2 = dbName in dbs + # print("dbs = {}, str = {}, ret2={}, type2={}".format(dbs, dbName,ret2, type(dbName))) + return dbName in dbs # TODO: super weird type mangling seen, once here + + def hasTables(self): + return self.query("show tables") > 0 + + def execute(self, sql): + ''' Return the number of rows affected''' + raise RuntimeError("Unexpected execution, should be overriden") + + def safeExecute(self, sql): + '''Safely execute any SQL query, returning True/False upon success/failure''' + try: + self.execute(sql) + return True # ignore num of results, return success + except taos.error.ProgrammingError as err: + return False # failed, for whatever TAOS reason + # Not possile to reach here, non-TAOS exception would have been thrown + + def query(self, sql) -> int: # return num rows returned + ''' Return the number of rows affected''' + raise RuntimeError("Unexpected execution, should be overriden") + + def openByType(self): + raise RuntimeError("Unexpected execution, should be overriden") + + def getQueryResult(self): + raise RuntimeError("Unexpected execution, should be overriden") + + def getResultRows(self): + raise RuntimeError("Unexpected execution, should be overriden") + + def getResultCols(self): + raise RuntimeError("Unexpected execution, should be overriden") + +# Sample: curl -u root:taosdata -d "show databases" localhost:6020/rest/sql + + +class DbConnRest(DbConn): + REST_PORT_INCREMENT = 11 + + def __init__(self, dbTarget: DbTarget): + super().__init__(dbTarget) + self._type = self.TYPE_REST + restPort = dbTarget.port + 11 + self._url = "http://{}:{}/rest/sql".format( + dbTarget.hostAddr, dbTarget.port + self.REST_PORT_INCREMENT) + self._result = None + + def openByType(self): # Open connection + pass # do nothing, always open + + def close(self): + if (not self.isOpen): + raise RuntimeError("Cannot clean up database until connection is open") + # Do nothing for REST + Logging.debug("[DB] REST Database connection closed") + self.isOpen = False + + def _doSql(self, sql): + self._lastSql = sql # remember this, last SQL attempted + try: + r = requests.post(self._url, + data = sql, + auth = HTTPBasicAuth('root', 'taosdata')) + except: + print("REST API Failure (TODO: more info here)") + raise + rj = r.json() + # Sanity check for the "Json Result" + if ('status' not in rj): + raise RuntimeError("No status in REST response") + + if rj['status'] == 'error': # clearly reported error + if ('code' not in rj): # error without code + raise RuntimeError("REST error return without code") + errno = rj['code'] # May need to massage this in the future + # print("Raising programming error with REST return: {}".format(rj)) + raise taos.error.ProgrammingError( + rj['desc'], errno) # todo: check existance of 'desc' + + if rj['status'] != 'succ': # better be this + raise RuntimeError( + "Unexpected REST return status: {}".format( + rj['status'])) + + nRows = rj['rows'] if ('rows' in rj) else 0 + self._result = rj + return nRows + + def execute(self, sql): + if (not self.isOpen): + raise RuntimeError( + "Cannot execute database commands until connection is open") + Logging.debug("[SQL-REST] Executing SQL: {}".format(sql)) + nRows = self._doSql(sql) + Logging.debug( + "[SQL-REST] Execution Result, nRows = {}, SQL = {}".format(nRows, sql)) + return nRows + + def query(self, sql): # return rows affected + return self.execute(sql) + + def getQueryResult(self): + return self._result['data'] + + def getResultRows(self): + print(self._result) + raise RuntimeError("TBD") # TODO: finish here to support -v under -c rest + # return self._tdSql.queryRows + + def getResultCols(self): + print(self._result) + raise RuntimeError("TBD") + + # Duplicate code from TDMySQL, TODO: merge all this into DbConnNative + + +class MyTDSql: + # Class variables + _clsLock = threading.Lock() # class wide locking + longestQuery = None # type: str + longestQueryTime = 0.0 # seconds + lqStartTime = 0.0 + # lqEndTime = 0.0 # Not needed, as we have the two above already + + def __init__(self, hostAddr, cfgPath): + # Make the DB connection + self._conn = taos.connect(host=hostAddr, config=cfgPath) + self._cursor = self._conn.cursor() + + self.queryRows = 0 + self.queryCols = 0 + self.affectedRows = 0 + + # def init(self, cursor, log=True): + # self.cursor = cursor + # if (log): + # caller = inspect.getframeinfo(inspect.stack()[1][0]) + # self.cursor.log(caller.filename + ".sql") + + def close(self): + self._cursor.close() # can we double close? + self._conn.close() # TODO: very important, cursor close does NOT close DB connection! + self._cursor.close() + + def _execInternal(self, sql): + startTime = time.time() + ret = self._cursor.execute(sql) + # print("\nSQL success: {}".format(sql)) + queryTime = time.time() - startTime + # Record the query time + cls = self.__class__ + if queryTime > (cls.longestQueryTime + 0.01) : + with cls._clsLock: + cls.longestQuery = sql + cls.longestQueryTime = queryTime + cls.lqStartTime = startTime + return ret + + def query(self, sql): + self.sql = sql + try: + self._execInternal(sql) + self.queryResult = self._cursor.fetchall() + self.queryRows = len(self.queryResult) + self.queryCols = len(self._cursor.description) + except Exception as e: + # caller = inspect.getframeinfo(inspect.stack()[1][0]) + # args = (caller.filename, caller.lineno, sql, repr(e)) + # tdLog.exit("%s(%d) failed: sql:%s, %s" % args) + raise + return self.queryRows + + def execute(self, sql): + self.sql = sql + try: + self.affectedRows = self._execInternal(sql) + except Exception as e: + # caller = inspect.getframeinfo(inspect.stack()[1][0]) + # args = (caller.filename, caller.lineno, sql, repr(e)) + # tdLog.exit("%s(%d) failed: sql:%s, %s" % args) + raise + return self.affectedRows + +class DbTarget: + def __init__(self, cfgPath, hostAddr, port): + self.cfgPath = cfgPath + self.hostAddr = hostAddr + self.port = port + + def __repr__(self): + return "[DbTarget: cfgPath={}, host={}:{}]".format( + Helper.getFriendlyPath(self.cfgPath), self.hostAddr, self.port) + + def getEp(self): + return "{}:{}".format(self.hostAddr, self.port) + +class DbConnNative(DbConn): + # Class variables + _lock = threading.Lock() + # _connInfoDisplayed = False # TODO: find another way to display this + totalConnections = 0 # Not private + + def __init__(self, dbTarget): + super().__init__(dbTarget) + self._type = self.TYPE_NATIVE + self._conn = None + # self._cursor = None + + def openByType(self): # Open connection + # global gContainer + # tInst = tInst or gContainer.defTdeInstance # set up in ClientManager, type: TdeInstance + # cfgPath = self.getBuildPath() + "/test/cfg" + # cfgPath = tInst.getCfgDir() + # hostAddr = tInst.getHostAddr() + + cls = self.__class__ # Get the class, to access class variables + with cls._lock: # force single threading for opening DB connections. # TODO: whaaat??!!! + dbTarget = self._dbTarget + # if not cls._connInfoDisplayed: + # cls._connInfoDisplayed = True # updating CLASS variable + Logging.debug("Initiating TAOS native connection to {}".format(dbTarget)) + # Make the connection + # self._conn = taos.connect(host=hostAddr, config=cfgPath) # TODO: make configurable + # self._cursor = self._conn.cursor() + # Record the count in the class + self._tdSql = MyTDSql(dbTarget.hostAddr, dbTarget.cfgPath) # making DB connection + cls.totalConnections += 1 + + self._tdSql.execute('reset query cache') + # self._cursor.execute('use db') # do this at the beginning of every + + # Open connection + # self._tdSql = MyTDSql() + # self._tdSql.init(self._cursor) + + def close(self): + if (not self.isOpen): + raise RuntimeError("Cannot clean up database until connection is open") + self._tdSql.close() + # Decrement the class wide counter + cls = self.__class__ # Get the class, to access class variables + with cls._lock: + cls.totalConnections -= 1 + + Logging.debug("[DB] Database connection closed") + self.isOpen = False + + def execute(self, sql): + if (not self.isOpen): + raise RuntimeError("Cannot execute database commands until connection is open") + Logging.debug("[SQL] Executing SQL: {}".format(sql)) + self._lastSql = sql + nRows = self._tdSql.execute(sql) + Logging.debug( + "[SQL] Execution Result, nRows = {}, SQL = {}".format( + nRows, sql)) + return nRows + + def query(self, sql): # return rows affected + if (not self.isOpen): + raise RuntimeError( + "Cannot query database until connection is open") + Logging.debug("[SQL] Executing SQL: {}".format(sql)) + self._lastSql = sql + nRows = self._tdSql.query(sql) + Logging.debug( + "[SQL] Query Result, nRows = {}, SQL = {}".format( + nRows, sql)) + return nRows + # results are in: return self._tdSql.queryResult + + def getQueryResult(self): + return self._tdSql.queryResult + + def getResultRows(self): + return self._tdSql.queryRows + + def getResultCols(self): + return self._tdSql.queryCols + + +class DbManager(): + ''' This is a wrapper around DbConn(), to make it easier to use. + + TODO: rename this to DbConnManager + ''' + def __init__(self, cType, dbTarget): + # self.tableNumQueue = LinearQueue() # TODO: delete? + # self.openDbServerConnection() + self._dbConn = DbConn.createNative(dbTarget) if ( + cType == 'native') else DbConn.createRest(dbTarget) + try: + self._dbConn.open() # may throw taos.error.ProgrammingError: disconnected + except taos.error.ProgrammingError as err: + # print("Error type: {}, msg: {}, value: {}".format(type(err), err.msg, err)) + if (err.msg == 'client disconnected'): # cannot open DB connection + print( + "Cannot establish DB connection, please re-run script without parameter, and follow the instructions.") + sys.exit(2) + else: + print("Failed to connect to DB, errno = {}, msg: {}" + .format(Helper.convertErrno(err.errno), err.msg)) + raise + except BaseException: + print("[=] Unexpected exception") + raise + + # Do this after dbConn is in proper shape + # Moved to Database() + # self._stateMachine = StateMechine(self._dbConn) + + def getDbConn(self): + return self._dbConn + + # TODO: not used any more, to delete + def pickAndAllocateTable(self): # pick any table, and "use" it + return self.tableNumQueue.pickAndAllocate() + + # TODO: Not used any more, to delete + def addTable(self): + with self._lock: + tIndex = self.tableNumQueue.push() + return tIndex + + # Not used any more, to delete + def releaseTable(self, i): # return the table back, so others can use it + self.tableNumQueue.release(i) + + # TODO: not used any more, delete + def getTableNameToDelete(self): + tblNum = self.tableNumQueue.pop() # TODO: race condition! + if (not tblNum): # maybe false + return False + + return "table_{}".format(tblNum) + + def cleanUp(self): + self._dbConn.close() + diff --git a/tests/pytest/crash_gen/misc.py b/tests/pytest/crash_gen/misc.py new file mode 100644 index 0000000000000000000000000000000000000000..8a2817b3898ac5ca0f5518b95274c0826e1c42b4 --- /dev/null +++ b/tests/pytest/crash_gen/misc.py @@ -0,0 +1,175 @@ +import threading +import random +import logging +import os + + +class CrashGenError(Exception): + def __init__(self, msg=None, errno=None): + self.msg = msg + self.errno = errno + + def __str__(self): + return self.msg + + +class LoggingFilter(logging.Filter): + def filter(self, record: logging.LogRecord): + if (record.levelno >= logging.INFO): + return True # info or above always log + + # Commenting out below to adjust... + + # if msg.startswith("[TRD]"): + # return False + return True + + +class MyLoggingAdapter(logging.LoggerAdapter): + def process(self, msg, kwargs): + return "[{}] {}".format(threading.get_ident() % 10000, msg), kwargs + # return '[%s] %s' % (self.extra['connid'], msg), kwargs + + +class Logging: + logger = None + + @classmethod + def getLogger(cls): + return logger + + @classmethod + def clsInit(cls, gConfig): # TODO: refactor away gConfig + if cls.logger: + return + + # Logging Stuff + # global misc.logger + _logger = logging.getLogger('CrashGen') # real logger + _logger.addFilter(LoggingFilter()) + ch = logging.StreamHandler() + _logger.addHandler(ch) + + # Logging adapter, to be used as a logger + print("setting logger variable") + # global logger + cls.logger = MyLoggingAdapter(_logger, []) + + if (gConfig.debug): + cls.logger.setLevel(logging.DEBUG) # default seems to be INFO + else: + cls.logger.setLevel(logging.INFO) + + @classmethod + def info(cls, msg): + cls.logger.info(msg) + + @classmethod + def debug(cls, msg): + cls.logger.debug(msg) + + @classmethod + def warning(cls, msg): + cls.logger.warning(msg) + + @classmethod + def error(cls, msg): + cls.logger.error(msg) + +class Status: + STATUS_STARTING = 1 + STATUS_RUNNING = 2 + STATUS_STOPPING = 3 + STATUS_STOPPED = 4 + + def __init__(self, status): + self.set(status) + + def __repr__(self): + return "[Status: v={}]".format(self._status) + + def set(self, status): + self._status = status + + def get(self): + return self._status + + def isStarting(self): + return self._status == Status.STATUS_STARTING + + def isRunning(self): + # return self._thread and self._thread.is_alive() + return self._status == Status.STATUS_RUNNING + + def isStopping(self): + return self._status == Status.STATUS_STOPPING + + def isStopped(self): + return self._status == Status.STATUS_STOPPED + + def isStable(self): + return self.isRunning() or self.isStopped() + +# Deterministic random number generator +class Dice(): + seeded = False # static, uninitialized + + @classmethod + def seed(cls, s): # static + if (cls.seeded): + raise RuntimeError( + "Cannot seed the random generator more than once") + cls.verifyRNG() + random.seed(s) + cls.seeded = True # TODO: protect against multi-threading + + @classmethod + def verifyRNG(cls): # Verify that the RNG is determinstic + random.seed(0) + x1 = random.randrange(0, 1000) + x2 = random.randrange(0, 1000) + x3 = random.randrange(0, 1000) + if (x1 != 864 or x2 != 394 or x3 != 776): + raise RuntimeError("System RNG is not deterministic") + + @classmethod + def throw(cls, stop): # get 0 to stop-1 + return cls.throwRange(0, stop) + + @classmethod + def throwRange(cls, start, stop): # up to stop-1 + if (not cls.seeded): + raise RuntimeError("Cannot throw dice before seeding it") + return random.randrange(start, stop) + + @classmethod + def choice(cls, cList): + return random.choice(cList) + +class Helper: + @classmethod + def convertErrno(cls, errno): + return errno if (errno > 0) else 0x80000000 + errno + + @classmethod + def getFriendlyPath(cls, path): # returns .../xxx/yyy + ht1 = os.path.split(path) + ht2 = os.path.split(ht1[0]) + return ".../" + ht2[1] + '/' + ht1[1] + + +class Progress: + STEP_BOUNDARY = 0 + BEGIN_THREAD_STEP = 1 + END_THREAD_STEP = 2 + SERVICE_HEART_BEAT= 3 + tokens = { + STEP_BOUNDARY: '.', + BEGIN_THREAD_STEP: '[', + END_THREAD_STEP: '] ', + SERVICE_HEART_BEAT: '.Y.' + } + + @classmethod + def emit(cls, token): + print(cls.tokens[token], end="", flush=True) diff --git a/tests/pytest/crash_gen/service_manager.py b/tests/pytest/crash_gen/service_manager.py new file mode 100644 index 0000000000000000000000000000000000000000..bb2becb55bd317c9d57152c89bd0ad6c3994de33 --- /dev/null +++ b/tests/pytest/crash_gen/service_manager.py @@ -0,0 +1,729 @@ +import os +import io +import sys +import threading +import signal +import logging +import time +import subprocess + +from typing import IO, List + +try: + import psutil +except: + print("Psutil module needed, please install: sudo pip3 install psutil") + sys.exit(-1) + +from queue import Queue, Empty + +from .misc import Logging, Status, CrashGenError, Dice, Helper, Progress +from .db import DbConn, DbTarget + +class TdeInstance(): + """ + A class to capture the *static* information of a TDengine instance, + including the location of the various files/directories, and basica + configuration. + """ + + @classmethod + def _getBuildPath(cls): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("communit")] + else: + projPath = selfPath[:selfPath.find("tests")] + + buildPath = None + 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 + if buildPath == None: + raise RuntimeError("Failed to determine buildPath, selfPath={}, projPath={}" + .format(selfPath, projPath)) + return buildPath + + def __init__(self, subdir='test', tInstNum=0, port=6030, fepPort=6030): + self._buildDir = self._getBuildPath() + self._subdir = '/' + subdir # TODO: tolerate "/" + self._port = port # TODO: support different IP address too + self._fepPort = fepPort + + self._tInstNum = tInstNum + self._smThread = ServiceManagerThread() + + def getDbTarget(self): + return DbTarget(self.getCfgDir(), self.getHostAddr(), self._port) + + def getPort(self): + return self._port + + def __repr__(self): + return "[TdeInstance: {}, subdir={}]".format( + self._buildDir, Helper.getFriendlyPath(self._subdir)) + + def generateCfgFile(self): + # print("Logger = {}".format(logger)) + # buildPath = self.getBuildPath() + # taosdPath = self._buildPath + "/build/bin/taosd" + + cfgDir = self.getCfgDir() + cfgFile = cfgDir + "/taos.cfg" # TODO: inquire if this is fixed + if os.path.exists(cfgFile): + if os.path.isfile(cfgFile): + Logging.warning("Config file exists already, skip creation: {}".format(cfgFile)) + return # cfg file already exists, nothing to do + else: + raise CrashGenError("Invalid config file: {}".format(cfgFile)) + # Now that the cfg file doesn't exist + if os.path.exists(cfgDir): + if not os.path.isdir(cfgDir): + raise CrashGenError("Invalid config dir: {}".format(cfgDir)) + # else: good path + else: + os.makedirs(cfgDir, exist_ok=True) # like "mkdir -p" + # Now we have a good cfg dir + cfgValues = { + 'runDir': self.getRunDir(), + 'ip': '127.0.0.1', # TODO: change to a network addressable ip + 'port': self._port, + 'fepPort': self._fepPort, + } + cfgTemplate = """ +dataDir {runDir}/data +logDir {runDir}/log + +charset UTF-8 + +firstEp {ip}:{fepPort} +fqdn {ip} +serverPort {port} + +# was all 135 below +dDebugFlag 135 +cDebugFlag 135 +rpcDebugFlag 135 +qDebugFlag 135 +# httpDebugFlag 143 +# asyncLog 0 +# tables 10 +maxtablesPerVnode 10 +rpcMaxTime 101 +# cache 2 +keep 36500 +# walLevel 2 +walLevel 1 +# +# maxConnections 100 +""" + cfgContent = cfgTemplate.format_map(cfgValues) + f = open(cfgFile, "w") + f.write(cfgContent) + f.close() + + def rotateLogs(self): + logPath = self.getLogDir() + # ref: https://stackoverflow.com/questions/1995373/deleting-all-files-in-a-directory-with-python/1995397 + if os.path.exists(logPath): + logPathSaved = logPath + "_" + time.strftime('%Y-%m-%d-%H-%M-%S') + Logging.info("Saving old log files to: {}".format(logPathSaved)) + os.rename(logPath, logPathSaved) + # os.mkdir(logPath) # recreate, no need actually, TDengine will auto-create with proper perms + + + def getExecFile(self): # .../taosd + return self._buildDir + "/build/bin/taosd" + + def getRunDir(self): # TODO: rename to "root dir" ?! + return self._buildDir + self._subdir + + def getCfgDir(self): # path, not file + return self.getRunDir() + "/cfg" + + def getLogDir(self): + return self.getRunDir() + "/log" + + def getHostAddr(self): + return "127.0.0.1" + + def getServiceCmdLine(self): # to start the instance + return [self.getExecFile(), '-c', self.getCfgDir()] # used in subproce.Popen() + + def _getDnodes(self, dbc): + dbc.query("show dnodes") + cols = dbc.getQueryResult() # id,end_point,vnodes,cores,status,role,create_time,offline reason + return {c[1]:c[4] for c in cols} # {'xxx:6030':'ready', 'xxx:6130':'ready'} + + def createDnode(self, dbt: DbTarget): + """ + With a connection to the "first" EP, let's create a dnode for someone else who + wants to join. + """ + dbc = DbConn.createNative(self.getDbTarget()) + dbc.open() + + if dbt.getEp() in self._getDnodes(dbc): + Logging.info("Skipping DNode creation for: {}".format(dbt)) + dbc.close() + return + + sql = "CREATE DNODE \"{}\"".format(dbt.getEp()) + dbc.execute(sql) + dbc.close() + + def getStatus(self): + return self._smThread.getStatus() + + def getSmThread(self): + return self._smThread + + def start(self): + if not self.getStatus().isStopped(): + raise CrashGenError("Cannot start instance from status: {}".format(self.getStatus())) + + Logging.info("Starting TDengine instance: {}".format(self)) + self.generateCfgFile() # service side generates config file, client does not + self.rotateLogs() + + self._smThread.start(self.getServiceCmdLine()) + + def stop(self): + self._smThread.stop() + + def isFirst(self): + return self._tInstNum == 0 + + +class TdeSubProcess: + """ + A class to to represent the actual sub process that is the run-time + of a TDengine instance. + + It takes a TdeInstance object as its parameter, with the rationale being + "a sub process runs an instance". + """ + + # RET_ALREADY_STOPPED = -1 + # RET_TIME_OUT = -3 + # RET_SUCCESS = -4 + + def __init__(self): + self.subProcess = None + # if tInst is None: + # raise CrashGenError("Empty instance not allowed in TdeSubProcess") + # self._tInst = tInst # Default create at ServiceManagerThread + + def getStdOut(self): + return self.subProcess.stdout + + def getStdErr(self): + return self.subProcess.stderr + + def isRunning(self): + return self.subProcess is not None + + def getPid(self): + return self.subProcess.pid + + def start(self, cmdLine): + ON_POSIX = 'posix' in sys.builtin_module_names + + # Sanity check + if self.subProcess: # already there + raise RuntimeError("Corrupt process state") + + self.subProcess = subprocess.Popen( + cmdLine, + shell=False, + # svcCmdSingle, shell=True, # capture core dump? + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + # bufsize=1, # not supported in binary mode + close_fds=ON_POSIX + ) # had text=True, which interferred with reading EOF + + def stop(self): + """ + Stop a sub process, and try to return a meaningful return code. + + Common POSIX signal values (from man -7 signal): + SIGHUP 1 + SIGINT 2 + SIGQUIT 3 + SIGILL 4 + SIGTRAP 5 + SIGABRT 6 + SIGIOT 6 + SIGBUS 7 + SIGEMT - + SIGFPE 8 + SIGKILL 9 + SIGUSR1 10 + SIGSEGV 11 + SIGUSR2 12 + """ + if not self.subProcess: + print("Sub process already stopped") + return # -1 + + retCode = self.subProcess.poll() # ret -N means killed with signal N, otherwise it's from exit(N) + if retCode: # valid return code, process ended + retCode = -retCode # only if valid + Logging.warning("TSP.stop(): process ended itself") + self.subProcess = None + return retCode + + # process still alive, let's interrupt it + print("Terminate running process, send SIG_INT and wait...") + # sub process should end, then IPC queue should end, causing IO thread to end + self.subProcess.send_signal(signal.SIGINT) + self.subProcess.wait(20) + retCode = self.subProcess.returncode # should always be there + # May throw subprocess.TimeoutExpired exception above, therefore + # The process is guranteed to have ended by now + self.subProcess = None + if retCode != 0: # != (- signal.SIGINT): + Logging.error("TSP.stop(): Failed to stop sub proc properly w/ SIG_INT, retCode={}".format(retCode)) + else: + Logging.info("TSP.stop(): sub proc successfully terminated with SIG_INT") + return - retCode + +class ServiceManager: + PAUSE_BETWEEN_IPC_CHECK = 1.2 # seconds between checks on STDOUT of sub process + + def __init__(self, numDnodes): # >1 when we run a cluster + Logging.info("TDengine Service Manager (TSM) created") + self._numDnodes = numDnodes # >1 means we have a cluster + self._lock = threading.Lock() + # signal.signal(signal.SIGTERM, self.sigIntHandler) # Moved to MainExec + # signal.signal(signal.SIGINT, self.sigIntHandler) + # signal.signal(signal.SIGUSR1, self.sigUsrHandler) # different handler! + + self.inSigHandler = False + # self._status = MainExec.STATUS_RUNNING # set inside + # _startTaosService() + self._runCluster = (numDnodes > 1) + self._tInsts : List[TdeInstance] = [] + for i in range(0, numDnodes): + ti = self._createTdeInstance(i) # construct tInst + self._tInsts.append(ti) + + # self.svcMgrThreads : List[ServiceManagerThread] = [] + # for i in range(0, numDnodes): + # thread = self._createThread(i) # construct tInst + # self.svcMgrThreads.append(thread) + + def _createTdeInstance(self, dnIndex): + if not self._runCluster: # single instance + subdir = 'test' + else: # Create all threads in a cluster + subdir = 'cluster_dnode_{}'.format(dnIndex) + fepPort= 6030 # firstEP Port + port = fepPort + dnIndex * 100 + return TdeInstance(subdir, dnIndex, port, fepPort) + # return ServiceManagerThread(dnIndex, ti) + + def _doMenu(self): + choice = "" + while True: + print("\nInterrupting Service Program, Choose an Action: ") + print("1: Resume") + print("2: Terminate") + print("3: Restart") + # Remember to update the if range below + # print("Enter Choice: ", end="", flush=True) + while choice == "": + choice = input("Enter Choice: ") + if choice != "": + break # done with reading repeated input + if choice in ["1", "2", "3"]: + break # we are done with whole method + print("Invalid choice, please try again.") + choice = "" # reset + return choice + + def sigUsrHandler(self, signalNumber, frame): + print("Interrupting main thread execution upon SIGUSR1") + if self.inSigHandler: # already + print("Ignoring repeated SIG...") + return # do nothing if it's already not running + self.inSigHandler = True + + choice = self._doMenu() + if choice == "1": + self.sigHandlerResume() # TODO: can the sub-process be blocked due to us not reading from queue? + elif choice == "2": + self.stopTaosServices() + elif choice == "3": # Restart + self.restart() + else: + raise RuntimeError("Invalid menu choice: {}".format(choice)) + + self.inSigHandler = False + + def sigIntHandler(self, signalNumber, frame): + print("ServiceManager: INT Signal Handler starting...") + if self.inSigHandler: + print("Ignoring repeated SIG_INT...") + return + self.inSigHandler = True + + self.stopTaosServices() + print("ServiceManager: INT Signal Handler returning...") + self.inSigHandler = False + + def sigHandlerResume(self): + print("Resuming TDengine service manager (main thread)...\n\n") + + # def _updateThreadStatus(self): + # if self.svcMgrThread: # valid svc mgr thread + # if self.svcMgrThread.isStopped(): # done? + # self.svcMgrThread.procIpcBatch() # one last time. TODO: appropriate? + # self.svcMgrThread = None # no more + + def isActive(self): + """ + Determine if the service/cluster is active at all, i.e. at least + one thread is not "stopped". + """ + for ti in self._tInsts: + if not ti.getStatus().isStopped(): + return True + return False + + # def isRestarting(self): + # """ + # Determine if the service/cluster is being "restarted", i.e., at least + # one thread is in "restarting" status + # """ + # for thread in self.svcMgrThreads: + # if thread.isRestarting(): + # return True + # return False + + def isStable(self): + """ + Determine if the service/cluster is "stable", i.e. all of the + threads are in "stable" status. + """ + for ti in self._tInsts: + if not ti.getStatus().isStable(): + return False + return True + + def _procIpcAll(self): + while self.isActive(): + Progress.emit(Progress.SERVICE_HEART_BEAT) + for ti in self._tInsts: # all thread objects should always be valid + # while self.isRunning() or self.isRestarting() : # for as long as the svc mgr thread is still here + status = ti.getStatus() + if status.isRunning(): + th = ti.getSmThread() + th.procIpcBatch() # regular processing, + if status.isStopped(): + th.procIpcBatch() # one last time? + # self._updateThreadStatus() + + time.sleep(self.PAUSE_BETWEEN_IPC_CHECK) # pause, before next round + # raise CrashGenError("dummy") + print("Service Manager Thread (with subprocess) ended, main thread exiting...") + + def _getFirstInstance(self): + return self._tInsts[0] + + def startTaosServices(self): + with self._lock: + if self.isActive(): + raise RuntimeError("Cannot start TAOS service(s) when one/some may already be running") + + # Find if there's already a taosd service, and then kill it + for proc in psutil.process_iter(): + if proc.name() == 'taosd': + print("Killing an existing TAOSD process in 2 seconds... press CTRL-C to interrupt") + time.sleep(2.0) + proc.kill() + # print("Process: {}".format(proc.name())) + + # self.svcMgrThread = ServiceManagerThread() # create the object + + for ti in self._tInsts: + ti.start() + if not ti.isFirst(): + tFirst = self._getFirstInstance() + tFirst.createDnode(ti.getDbTarget()) + ti.getSmThread().procIpcBatch(trimToTarget=10, forceOutput=True) # for printing 10 lines + + def stopTaosServices(self): + with self._lock: + if not self.isActive(): + Logging.warning("Cannot stop TAOS service(s), already not active") + return + + for ti in self._tInsts: + ti.stop() + + def run(self): + self.startTaosServices() + self._procIpcAll() # pump/process all the messages, may encounter SIG + restart + if self.isActive(): # if sig handler hasn't destroyed it by now + self.stopTaosServices() # should have started already + + def restart(self): + if not self.isStable(): + Logging.warning("Cannot restart service/cluster, when not stable") + return + + # self._isRestarting = True + if self.isActive(): + self.stopTaosServices() + else: + Logging.warning("Service not active when restart requested") + + self.startTaosServices() + # self._isRestarting = False + + # def isRunning(self): + # return self.svcMgrThread != None + + # def isRestarting(self): + # return self._isRestarting + +class ServiceManagerThread: + """ + A class representing a dedicated thread which manages the "sub process" + of the TDengine service, interacting with its STDOUT/ERR. + + It takes a TdeInstance parameter at creation time, or create a default + """ + MAX_QUEUE_SIZE = 10000 + + def __init__(self): + # Set the sub process + self._tdeSubProcess = None # type: TdeSubProcess + + # Arrange the TDengine instance + # self._tInstNum = tInstNum # instance serial number in cluster, ZERO based + # self._tInst = tInst or TdeInstance() # Need an instance + + self._thread = None # The actual thread, # type: threading.Thread + self._status = Status(Status.STATUS_STOPPED) # The status of the underlying service, actually. + + def __repr__(self): + return "[SvcMgrThread: status={}, subProc={}]".format( + self.getStatus(), self._tdeSubProcess) + + def getStatus(self): + return self._status + + # Start the thread (with sub process), and wait for the sub service + # to become fully operational + def start(self, cmdLine): + if self._thread: + raise RuntimeError("Unexpected _thread") + if self._tdeSubProcess: + raise RuntimeError("TDengine sub process already created/running") + + Logging.info("Attempting to start TAOS service: {}".format(self)) + + self._status.set(Status.STATUS_STARTING) + self._tdeSubProcess = TdeSubProcess() + self._tdeSubProcess.start(cmdLine) + + self._ipcQueue = Queue() + self._thread = threading.Thread( # First thread captures server OUTPUT + target=self.svcOutputReader, + args=(self._tdeSubProcess.getStdOut(), self._ipcQueue)) + self._thread.daemon = True # thread dies with the program + self._thread.start() + + self._thread2 = threading.Thread( # 2nd thread captures server ERRORs + target=self.svcErrorReader, + args=(self._tdeSubProcess.getStdErr(), self._ipcQueue)) + self._thread2.daemon = True # thread dies with the program + self._thread2.start() + + # wait for service to start + for i in range(0, 100): + time.sleep(1.0) + # self.procIpcBatch() # don't pump message during start up + print("_zz_", end="", flush=True) + if self._status.isRunning(): + Logging.info("[] TDengine service READY to process requests") + Logging.info("[] TAOS service started: {}".format(self)) + # self._verifyDnode(self._tInst) # query and ensure dnode is ready + # Logging.debug("[] TAOS Dnode verified: {}".format(self)) + return # now we've started + # TODO: handle failure-to-start better? + self.procIpcBatch(100, True) # display output before cronking out, trim to last 20 msgs, force output + raise RuntimeError("TDengine service did not start successfully: {}".format(self)) + + def _verifyDnode(self, tInst: TdeInstance): + dbc = DbConn.createNative(tInst.getDbTarget()) + dbc.open() + dbc.query("show dnodes") + # dbc.query("DESCRIBE {}.{}".format(dbName, self._stName)) + cols = dbc.getQueryResult() # id,end_point,vnodes,cores,status,role,create_time,offline reason + # ret = {row[0]:row[1] for row in stCols if row[3]=='TAG'} # name:type + isValid = False + for col in cols: + # print("col = {}".format(col)) + ep = col[1].split(':') # 10.1.30.2:6030 + print("Found ep={}".format(ep)) + if tInst.getPort() == int(ep[1]): # That's us + # print("Valid Dnode matched!") + isValid = True # now we are valid + break + if not isValid: + print("Failed to start dnode, sleep for a while") + time.sleep(600) + raise RuntimeError("Failed to start Dnode, expected port not found: {}". + format(tInst.getPort())) + dbc.close() + + def stop(self): + # can be called from both main thread or signal handler + print("Terminating TDengine service running as the sub process...") + if self.getStatus().isStopped(): + print("Service already stopped") + return + if self.getStatus().isStopping(): + print("Service is already being stopped") + return + # Linux will send Control-C generated SIGINT to the TDengine process + # already, ref: + # https://unix.stackexchange.com/questions/176235/fork-and-how-signals-are-delivered-to-processes + if not self._tdeSubProcess: + raise RuntimeError("sub process object missing") + + self._status.set(Status.STATUS_STOPPING) + # retCode = self._tdeSubProcess.stop() + try: + retCode = self._tdeSubProcess.stop() + # print("Attempted to stop sub process, got return code: {}".format(retCode)) + if retCode == signal.SIGSEGV : # SGV + Logging.error("[[--ERROR--]]: TDengine service SEGV fault (check core file!)") + except subprocess.TimeoutExpired as err: + print("Time out waiting for TDengine service process to exit") + else: + if self._tdeSubProcess.isRunning(): # still running, should now never happen + print("FAILED to stop sub process, it is still running... pid = {}".format( + self._tdeSubProcess.getPid())) + else: + self._tdeSubProcess = None # not running any more + self.join() # stop the thread, change the status, etc. + + # Check if it's really stopped + outputLines = 10 # for last output + if self.getStatus().isStopped(): + self.procIpcBatch(outputLines) # one last time + Logging.debug("End of TDengine Service Output: {}".format(self)) + Logging.info("----- TDengine Service (managed by SMT) is now terminated -----\n") + else: + print("WARNING: SMT did not terminate as expected: {}".format(self)) + + def join(self): + # TODO: sanity check + if not self.getStatus().isStopping(): + raise RuntimeError( + "SMT.Join(): Unexpected status: {}".format(self._status)) + + if self._thread: + self._thread.join() + self._thread = None + self._status.set(Status.STATUS_STOPPED) + # STD ERR thread + self._thread2.join() + self._thread2 = None + else: + print("Joining empty thread, doing nothing") + + def _trimQueue(self, targetSize): + if targetSize <= 0: + return # do nothing + q = self._ipcQueue + if (q.qsize() <= targetSize): # no need to trim + return + + Logging.debug("Triming IPC queue to target size: {}".format(targetSize)) + itemsToTrim = q.qsize() - targetSize + for i in range(0, itemsToTrim): + try: + q.get_nowait() + except Empty: + break # break out of for loop, no more trimming + + TD_READY_MSG = "TDengine is initialized successfully" + + def procIpcBatch(self, trimToTarget=0, forceOutput=False): + self._trimQueue(trimToTarget) # trim if necessary + # Process all the output generated by the underlying sub process, + # managed by IO thread + print("<", end="", flush=True) + while True: + try: + line = self._ipcQueue.get_nowait() # getting output at fast speed + self._printProgress("_o") + except Empty: + # time.sleep(2.3) # wait only if there's no output + # no more output + print(".>", end="", flush=True) + return # we are done with THIS BATCH + else: # got line, printing out + if forceOutput: + Logging.info(line) + else: + Logging.debug(line) + print(">", end="", flush=True) + + _ProgressBars = ["--", "//", "||", "\\\\"] + + def _printProgress(self, msg): # TODO: assuming 2 chars + print(msg, end="", flush=True) + pBar = self._ProgressBars[Dice.throw(4)] + print(pBar, end="", flush=True) + print('\b\b\b\b', end="", flush=True) + + def svcOutputReader(self, out: IO, queue): + # Important Reference: https://stackoverflow.com/questions/375427/non-blocking-read-on-a-subprocess-pipe-in-python + # print("This is the svcOutput Reader...") + # for line in out : + for line in iter(out.readline, b''): + # print("Finished reading a line: {}".format(line)) + # print("Adding item to queue...") + try: + line = line.decode("utf-8").rstrip() + except UnicodeError: + print("\nNon-UTF8 server output: {}\n".format(line)) + + # This might block, and then causing "out" buffer to block + queue.put(line) + self._printProgress("_i") + + if self._status.isStarting(): # we are starting, let's see if we have started + if line.find(self.TD_READY_MSG) != -1: # found + Logging.info("Waiting for the service to become FULLY READY") + time.sleep(1.0) # wait for the server to truly start. TODO: remove this + Logging.info("Service is now FULLY READY") # TODO: more ID info here? + self._status.set(Status.STATUS_RUNNING) + + # Trim the queue if necessary: TODO: try this 1 out of 10 times + self._trimQueue(self.MAX_QUEUE_SIZE * 9 // 10) # trim to 90% size + + if self._status.isStopping(): # TODO: use thread status instead + # WAITING for stopping sub process to finish its outptu + print("_w", end="", flush=True) + + # queue.put(line) + # meaning sub process must have died + Logging.info("\nEnd of stream detected for TDengine STDOUT: {}".format(self)) + out.close() + + def svcErrorReader(self, err: IO, queue): + for line in iter(err.readline, b''): + print("\nTDengine Service (taosd) ERROR (from stderr): {}".format(line)) + Logging.info("\nEnd of stream detected for TDengine STDERR: {}".format(self)) + err.close() \ No newline at end of file diff --git a/tests/pytest/crash_gen/valgrind_taos.supp b/tests/pytest/crash_gen/valgrind_taos.supp new file mode 100644 index 0000000000000000000000000000000000000000..123858b3db3d66ddad8194e2a11338735288e7a8 --- /dev/null +++ b/tests/pytest/crash_gen/valgrind_taos.supp @@ -0,0 +1,17249 @@ +{ + + Memcheck:Cond + fun:PyUnicode_Decode + fun:PyUnicode_FromEncodedObject + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyFloat_FromDouble + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyFloat_FromDouble + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyFloat_FromDouble + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyLong_FromLong + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyLong_FromLong + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyLong_FromLong + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyLong_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyLong_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PySequence_Tuple + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyUnicode_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyUnicode_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyUnicode_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PyLong_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PyFloat_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PyErr_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyModuleDef_Init + fun:_PyModule_CreateInitialized + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyObject_SetAttr + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:PyThread_GetInfo + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + obj:/usr/bin/python3.8 + fun:_PyObject_LookupSpecial + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + fun:_PyErr_NormalizeException + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyStructSequence_NewType + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyStructSequence_NewType + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyStructSequence_NewType + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyStructSequence_NewType + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyStructSequence_NewType + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:PyInit_time + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__abc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + obj:/usr/bin/python3.8 + fun:PyObject_LengthHint + fun:PySequence_List + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__operator + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__operator + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__operator + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags + fun:Py_RunMain +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyList_AsTuple + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags + fun:Py_RunMain +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__datetime + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__datetime + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__datetime + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__datetime + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__datetime + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__datetime + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyStack_UnpackDict + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sre + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sre + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sre + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyErr_NewException + fun:PyErr_NewExceptionWithDoc + fun:PyInit__queue + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__queue + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyErr_NewException + fun:PyInit__socket + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyErr_NewException + fun:PyInit__socket + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyErr_NewException + fun:PyInit__socket + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + fun:PyErr_Format + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__random + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_FromSpecWithBases + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__hashlib + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__blake2 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__blake2 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit_zlib + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit_zlib + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyErr_NewException + fun:PyInit_zlib + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyErr_NewException + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__bz2 + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__bz2 + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyErr_NewException + fun:PyErr_NewExceptionWithDoc + fun:PyInit__lzma + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__lzma + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__lzma + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:PyInit_grp + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyObject_MakeTpCall + fun:PyObject_CallFunction +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__speedups + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__speedups + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nybitset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nybitset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nybitset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nybitset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyFloat_FromDouble + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:PyCapsule_New + fun:fsb_dx_nybitset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:PyCapsule_New + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:PyCapsule_New + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:PyObject_Call + fun:_PyCodec_Lookup + obj:/usr/bin/python3.8 + fun:_PyUnicode_InitEncodings + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_FromNodeObject + fun:PyParser_ASTFromStringObject + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_FromNodeObject + fun:PyParser_ASTFromFileObject + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyDict_SetItemId + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyDict_SetItemId + fun:_PySys_SetPreliminaryStderr + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyDict_SetItemId + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyList_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyUnicode_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyUnicode_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyUnicode_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyModuleDef_Init + fun:_PyModule_CreateInitialized + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyObject_SetAttr + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + fun:PyImport_ImportFrozenModuleObject +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + obj:/usr/bin/python3.8 + fun:_PyObject_LookupSpecial + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + obj:/usr/bin/python3.8 + fun:PyObject_LengthHint + fun:PySequence_List + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__operator + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__collections + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_FromNodeObject + fun:PyParser_ASTFromFileObject + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags + fun:Py_RunMain +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyType_GenericNew + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__speedups + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyUnicode_InternFromString + obj:/usr/bin/python3.8 + fun:_PyWarnings_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyImportHooks_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_SetPreliminaryStderr + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyImportHooks_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + fun:PyInit__imp + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyType_Ready + fun:PyInit__ctypes + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyUnicode_InternInPlace + fun:PyUnicode_InternFromString + obj:/usr/bin/python3.8 + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PyLong_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PyFloat_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PyErr_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyType_Ready + fun:PyModuleDef_Init + fun:_PyModule_CreateInitialized + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyModule_NewObject + fun:PyModule_New + fun:_PyModule_CreateInitialized + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:PyThread_GetInfo + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyModule_NewObject + fun:PyModule_New + fun:_PyModule_CreateInitialized + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:_PyWarnings_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:_PyDict_NewPresized + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/bin/python3.8 + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/bin/python3.8 + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:_PyObject_SetAttrId + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyObject_CallFunction_SizeT + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodId_SizeT + fun:PyFile_OpenCodeObject + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyModule_NewObject + fun:PyModule_New + fun:_PyModule_CreateInitialized + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_Copy + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PySymtable_BuildObject + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__openssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyContextVar_New + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:realloc + fun:_PyObject_GC_Resize + fun:_PyTuple_Resize + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__decimal +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:PyObject_CallFunction + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:fsb_dx_nybitset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:fsb_dx_nybitset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyImportHooks_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyModule_AddIntConstant + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyInit__imp + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_Call + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyFloat_FromDouble + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:_PyWarnings_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:_PyWarnings_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:_PyWarnings_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:_PyWarnings_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:_PyWarnings_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/bin/python3.8 + fun:PyContextVar_New + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__functools + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyImport_Cleanup + fun:Py_FinalizeEx + fun:Py_Exit + obj:/usr/bin/python3.8 + fun:PyErr_PrintEx + fun:PyRun_SimpleFileExFlags + fun:Py_RunMain + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__constant_time + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__openssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PySequence_List + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyType_GenericAlloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + fun:PySymtable_BuildObject + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PySymtable_BuildObject + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags + fun:Py_RunMain +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:PyObject_CallFunction + fun:PyImport_Import + fun:PyImport_ImportModule + fun:PyFile_OpenCodeObject + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PyErr_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyDict_SetItemId + obj:/usr/bin/python3.8 + fun:PyModule_NewObject + fun:PyModule_New + fun:_PyModule_CreateInitialized + fun:PyInit__imp + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyDict_Copy + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyDict_Copy + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyStack_AsDict + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PySymtable_BuildObject + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PySymtable_BuildObject + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PySymtable_BuildObject + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyCode_NewWithPosOnlyArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyCode_NewWithPosOnlyArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyCode_NewWithPosOnlyArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/bin/python3.8 + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_Copy + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:PyObject_CallFunction + fun:PyErr_NewException + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyObject_CallFunction_SizeT + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodId_SizeT + fun:PyFile_OpenCodeObject + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__openssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyList_AsTuple + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyErr_NewException + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_Copy + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyType_GenericAlloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_PyObject_GC_New + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__constant_time + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/bin/python3.8 + fun:PyObject_GenericGetDict + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_Copy + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:PyObject_CallFunction + fun:PyErr_NewException + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyDict_Copy + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyStack_UnpackDict + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_Copy + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:PyObject_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + fun:PyObject_IsSubclass + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + fun:PyInit__ctypes + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:_PyObject_SetAttrId + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyObject_CallFunction_SizeT + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodId_SizeT + fun:PyFile_OpenCodeObject + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyErr_NewException + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:PyObject_Call + fun:_PyCodec_Lookup +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit_itertools + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_Copy + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyType_GenericAlloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyDict_Copy + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:PyObject_CallFunction + fun:PyErr_NewException + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PySequence_List + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyDict_Copy + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyDict_Copy + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:PyObject_CallFunction + fun:PyErr_NewException + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:PyObject_SetAttr + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__ctypes + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyImport_Cleanup + fun:Py_FinalizeEx + fun:Py_Exit + obj:/usr/bin/python3.8 + fun:PyErr_PrintEx + fun:PyRun_SimpleFileExFlags + fun:Py_RunMain + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetDefault + fun:PyUnicode_InternInPlace + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} diff --git a/tests/pytest/crash_gen_bootstrap.py b/tests/pytest/crash_gen_bootstrap.py new file mode 100644 index 0000000000000000000000000000000000000000..a3417d21a85ec5ea26c7ebc22ffe398fc436eebe --- /dev/null +++ b/tests/pytest/crash_gen_bootstrap.py @@ -0,0 +1,23 @@ +# -----!/usr/bin/python3.7 +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +import sys +from crash_gen.crash_gen import MainExec + +if __name__ == "__main__": + + mExec = MainExec() + mExec.init() + exitCode = mExec.run() + + print("Exiting with code: {}".format(exitCode)) + sys.exit(exitCode) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index bfa546f92e6850cad1c4c070d149961221e41e22..39d0fa3d94d36aab88366cc9f428a08f6fd3d1dc 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -16,7 +16,11 @@ python3 ./test.py -f insert/nchar.py python3 ./test.py -f insert/nchar-unicode.py python3 ./test.py -f insert/multi.py python3 ./test.py -f insert/randomNullCommit.py +python3 insert/retentionpolicy.py +python3 ./test.py -f insert/alterTableAndInsert.py +python3 ./test.py -f insert/insertIntoTwoTables.py +python3 ./test.py -f table/alter_wal0.py python3 ./test.py -f table/column_name.py python3 ./test.py -f table/column_num.py python3 ./test.py -f table/db_table.py @@ -147,6 +151,7 @@ python3 ./test.py -f query/queryNullValueTest.py python3 ./test.py -f query/queryInsertValue.py python3 ./test.py -f query/queryConnection.py python3 ./test.py -f query/natualInterval.py +python3 ./test.py -f query/bug1471.py #stream python3 ./test.py -f stream/metric_1.py @@ -154,6 +159,7 @@ python3 ./test.py -f stream/new.py python3 ./test.py -f stream/stream1.py python3 ./test.py -f stream/stream2.py python3 ./test.py -f stream/parser.py +python3 ./test.py -f stream/history.py #alter table python3 ./test.py -f alter/alter_table_crash.py @@ -161,6 +167,7 @@ python3 ./test.py -f alter/alter_table_crash.py # client python3 ./test.py -f client/client.py python3 ./test.py -f client/version.py +python3 ./test.py -f client/alterDatabase.py # Misc python3 testCompress.py @@ -168,25 +175,32 @@ python3 testNoCompress.py python3 testMinTablesPerVnode.py # functions -python3 ./test.py -f functions/function_avg.py -python3 ./test.py -f functions/function_bottom.py -python3 ./test.py -f functions/function_count.py -python3 ./test.py -f functions/function_diff.py -python3 ./test.py -f functions/function_first.py -python3 ./test.py -f functions/function_last.py -python3 ./test.py -f functions/function_last_row.py -python3 ./test.py -f functions/function_leastsquares.py -python3 ./test.py -f functions/function_max.py -python3 ./test.py -f functions/function_min.py -python3 ./test.py -f functions/function_operations.py +python3 ./test.py -f functions/function_avg.py -r 1 +python3 ./test.py -f functions/function_bottom.py -r 1 +python3 ./test.py -f functions/function_count.py -r 1 +python3 ./test.py -f functions/function_diff.py -r 1 +python3 ./test.py -f functions/function_first.py -r 1 +python3 ./test.py -f functions/function_last.py -r 1 +python3 ./test.py -f functions/function_last_row.py -r 1 +python3 ./test.py -f functions/function_leastsquares.py -r 1 +python3 ./test.py -f functions/function_max.py -r 1 +python3 ./test.py -f functions/function_min.py -r 1 +python3 ./test.py -f functions/function_operations.py -r 1 python3 ./test.py -f functions/function_percentile.py -python3 ./test.py -f functions/function_spread.py -python3 ./test.py -f functions/function_stddev.py -python3 ./test.py -f functions/function_sum.py -python3 ./test.py -f functions/function_top.py -#python3 ./test.py -f functions/function_twa.py +python3 ./test.py -f functions/function_spread.py -r 1 +python3 ./test.py -f functions/function_stddev.py -r 1 +python3 ./test.py -f functions/function_sum.py -r 1 +python3 ./test.py -f functions/function_top.py -r 1 +#python3 ./test.py -f functions/function_twa.py -r 1 python3 queryCount.py python3 ./test.py -f query/queryGroupbyWithInterval.py +python3 client/twoClients.py +python3 test.py -f query/queryInterval.py # tools python3 test.py -f tools/taosdemo.py + +# subscribe +python3 test.py -f subscribe/singlemeter.py +#python3 test.py -f subscribe/stability.py +python3 test.py -f subscribe/supertable.py diff --git a/tests/pytest/functions/function_avg_restart.py b/tests/pytest/functions/function_avg_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..56b99cdf910869b5bc4f5bd93da208943b1b026e --- /dev/null +++ b/tests/pytest/functions/function_avg_restart.py @@ -0,0 +1,73 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + intData = [] + floatData = [] + + #tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + # col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))''') + #tdSql.execute("create table test1 using test tags('beijing')") + for i in range(self.rowNum): + #tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%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)) + intData.append(i + 1) + floatData.append(i + 0.1) + + # average verifacation + tdSql.error("select avg(ts) from test") + tdSql.error("select avg(ts) from test1") + tdSql.error("select avg(col7) from test") + tdSql.error("select avg(col7) from test1") + tdSql.error("select avg(col8) from test") + tdSql.error("select avg(col8) from test1") + tdSql.error("select avg(col9) from test") + tdSql.error("select avg(col9) from test1") + + tdSql.query("select avg(col1) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col2) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col3) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col4) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col5) from test") + tdSql.checkData(0, 0, np.average(floatData)) + tdSql.query("select avg(col6) from test") + tdSql.checkData(0, 0, np.average(floatData)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_bottom_restart.py b/tests/pytest/functions/function_bottom_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..74eb044645ffa6a54e286dd11d022672575a38db --- /dev/null +++ b/tests/pytest/functions/function_bottom_restart.py @@ -0,0 +1,93 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + #tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + # col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))''') + #tdSql.execute("create table test1 using test tags('beijing')") + #for i in range(self.rowNum): + # tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%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)) + + # bottom verifacation + tdSql.error("select bottom(ts, 10) from test") + tdSql.error("select bottom(col1, 0) from test") + tdSql.error("select bottom(col1, 101) from test") + tdSql.error("select bottom(col2, 0) from test") + tdSql.error("select bottom(col2, 101) from test") + tdSql.error("select bottom(col3, 0) from test") + tdSql.error("select bottom(col3, 101) from test") + tdSql.error("select bottom(col4, 0) from test") + tdSql.error("select bottom(col4, 101) from test") + tdSql.error("select bottom(col5, 0) from test") + tdSql.error("select bottom(col5, 101) from test") + tdSql.error("select bottom(col6, 0) from test") + tdSql.error("select bottom(col6, 101) from test") + tdSql.error("select bottom(col7, 10) from test") + tdSql.error("select bottom(col8, 10) from test") + tdSql.error("select bottom(col9, 10) from test") + + tdSql.query("select bottom(col1, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col2, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col3, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col4, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col5, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0.1) + tdSql.checkData(1, 1, 1.1) + + tdSql.query("select bottom(col6, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0.1) + tdSql.checkData(1, 1, 1.1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_count_restart.py b/tests/pytest/functions/function_count_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..5eabb47d952a1a461b6fd5c976f3f2a8c294222b --- /dev/null +++ b/tests/pytest/functions/function_count_restart.py @@ -0,0 +1,79 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + #tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + # col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))''') + #tdSql.execute("create table test1 using test tags('beijing')") + #for i in range(self.rowNum): + # tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%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)) + + # Count verifacation + tdSql.query("select count(*) from test") + tdSql.checkData(0, 0, 11) + + tdSql.query("select count(ts) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col1) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col2) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col3) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col4) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col5) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col6) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col7) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col8) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col9) from test") + tdSql.checkData(0, 0, 11) + + #tdSql.execute("alter table test add column col10 int") + #tdSql.query("select count(col10) from test") + #tdSql.checkRows(0) + + ##tdSql.execute("insert into test1 values(now, 1, 2, 3, 4, 1.1, 2.2, false, 'test', 'test' 1)") + tdSql.query("select count(col10) from test") + tdSql.checkData(0, 0, 1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_diff_restart.py b/tests/pytest/functions/function_diff_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..870ee03fc94cbd8dbf5e858726cd52b09010a884 --- /dev/null +++ b/tests/pytest/functions/function_diff_restart.py @@ -0,0 +1,99 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + #tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + # col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))''') + #tdSql.execute("create table test1 using test tags('beijing')") + #tdSql.execute("insert into test1 values(%d, 0, 0, 0, 0, 0.0, 0.0, False, ' ', ' ')" % (self.ts - 1)) + + # diff verifacation + #tdSql.query("select diff(col1) from test1") + #tdSql.checkRows(0) + # + #tdSql.query("select diff(col2) from test1") + #tdSql.checkRows(0) + + #tdSql.query("select diff(col3) from test1") + #tdSql.checkRows(0) + + #tdSql.query("select diff(col4) from test1") + #tdSql.checkRows(0) + + #tdSql.query("select diff(col5) from test1") + #tdSql.checkRows(0) + + #tdSql.query("select diff(col6) from test1") + #tdSql.checkRows(0) + + #for i in range(self.rowNum): + # tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%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)) + + tdSql.error("select diff(ts) from test") + tdSql.error("select diff(ts) from test1") + tdSql.error("select diff(col1) from test") + tdSql.error("select diff(col2) from test") + tdSql.error("select diff(col3) from test") + tdSql.error("select diff(col4) from test") + tdSql.error("select diff(col5) from test") + tdSql.error("select diff(col6) from test") + tdSql.error("select diff(col7) from test") + tdSql.error("select diff(col7) from test1") + tdSql.error("select diff(col8) from test") + tdSql.error("select diff(col8) from test1") + tdSql.error("select diff(col9) from test") + tdSql.error("select diff(col9) from test1") + + tdSql.query("select diff(col1) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col2) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col3) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col4) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col5) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col6) from test1") + tdSql.checkRows(10) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_first_restart.py b/tests/pytest/functions/function_first_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..31904c3cde6e1237472aac5767037e5e53e08a47 --- /dev/null +++ b/tests/pytest/functions/function_first_restart.py @@ -0,0 +1,78 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + tdSql.query("select first(*) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + + tdSql.query("select first(col1) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col2) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col3) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col4) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col5) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0.1) + + tdSql.query("select first(col6) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0.1) + + tdSql.query("select first(col7) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, False) + + tdSql.query("select first(col8) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'taosdata1') + + tdSql.query("select first(col9) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, '涛思数据1') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_last_restart.py b/tests/pytest/functions/function_last_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..69a588d28de7081da4469e9a407be1b68d07f82a --- /dev/null +++ b/tests/pytest/functions/function_last_restart.py @@ -0,0 +1,78 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + tdSql.query("select last(*) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 10) + + tdSql.query("select last(col1) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col2) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col3) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col4) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col5) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select last(col6) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select last(col7) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, True) + + tdSql.query("select last(col8) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'taosdata10') + + tdSql.query("select last(col9) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, '涛思数据10') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_last_row_restart.py b/tests/pytest/functions/function_last_row_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..1043a8809d640d5b57f808d83799f1f497776233 --- /dev/null +++ b/tests/pytest/functions/function_last_row_restart.py @@ -0,0 +1,78 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + tdSql.query("select last_row(*) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 10) + + tdSql.query("select last_row(col1) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col2) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col3) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col4) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col5) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select last_row(col6) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select last_row(col7) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, True) + + tdSql.query("select last_row(col8) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'taosdata10') + + tdSql.query("select last_row(col9) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, '涛思数据10') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_leastsquares_restart.py b/tests/pytest/functions/function_leastsquares_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..0221dc0aed865882e375f90c44f52b391d1ffee5 --- /dev/null +++ b/tests/pytest/functions/function_leastsquares_restart.py @@ -0,0 +1,68 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + # leastsquares verifacation + tdSql.error("select leastsquares(ts, 1, 1) from test1") + tdSql.error("select leastsquares(col1, 1, 1) from test") + tdSql.error("select leastsquares(col2, 1, 1) from test") + tdSql.error("select leastsquares(col3, 1, 1) from test") + tdSql.error("select leastsquares(col4, 1, 1) from test") + tdSql.error("select leastsquares(col5, 1, 1) from test") + tdSql.error("select leastsquares(col6, 1, 1) from test") + tdSql.error("select leastsquares(col7, 1, 1) from test1") + tdSql.error("select leastsquares(col8, 1, 1) from test1") + tdSql.error("select leastsquares(col9, 1, 1) from test1") + + tdSql.query("select leastsquares(col1, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col2, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col3, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col4, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col5, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:-0.900000}') + + tdSql.query("select leastsquares(col6, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:-0.900000}') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_max_restart.py b/tests/pytest/functions/function_max_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..8d1827561758f1ceebffab877aabd6cd79166d42 --- /dev/null +++ b/tests/pytest/functions/function_max_restart.py @@ -0,0 +1,76 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + intData = [] + floatData = [] + + #tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + # col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))''') + #tdSql.execute("create table test1 using test tags('beijing')") + for i in range(self.rowNum): + intData.append(i + 1) + floatData.append(i + 0.1) + + # max verifacation + tdSql.error("select max(ts) from test") + tdSql.error("select max(ts) from test1") + tdSql.error("select max(col7) from test") + tdSql.error("select max(col7) from test1") + tdSql.error("select max(col8) from test") + tdSql.error("select max(col8) from test1") + tdSql.error("select max(col9) from test") + tdSql.error("select max(col9) from test1") + + tdSql.query("select max(col1) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col2) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col3) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col4) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col5) from test1") + tdSql.checkData(0, 0, np.max(floatData)) + + tdSql.query("select max(col6) from test1") + tdSql.checkData(0, 0, np.max(floatData)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_min_restart.py b/tests/pytest/functions/function_min_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..c8329bffa5525c2386d264010acf7231059e344d --- /dev/null +++ b/tests/pytest/functions/function_min_restart.py @@ -0,0 +1,73 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + intData = [] + floatData = [] + + for i in range(self.rowNum): + intData.append(i + 1) + floatData.append(i + 0.1) + + # min verifacation + tdSql.error("select min(ts) from test") + tdSql.error("select min(ts) from test1") + tdSql.error("select min(col7) from test") + tdSql.error("select min(col7) from test1") + tdSql.error("select min(col8) from test") + tdSql.error("select min(col8) from test1") + tdSql.error("select min(col9) from test") + tdSql.error("select min(col9) from test1") + + tdSql.query("select min(col1) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col2) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col3) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col4) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col5) from test1") + tdSql.checkData(0, 0, np.min(floatData)) + + tdSql.query("select min(col6) from test1") + tdSql.checkData(0, 0, np.min(floatData)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_operations_restart.py b/tests/pytest/functions/function_operations_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..6e3990264cb91d8c063fe638a5f77231ef7be424 --- /dev/null +++ b/tests/pytest/functions/function_operations_restart.py @@ -0,0 +1,70 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + # min verifacation + tdSql.error("select ts + col1 from test") + tdSql.error("select ts + col1 from test1") + tdSql.error("select col1 + col7 from test") + tdSql.error("select col1 + col7 from test1") + tdSql.error("select col1 + col8 from test") + tdSql.error("select col1 + col8 from test1") + tdSql.error("select col1 + col9 from test") + tdSql.error("select col1 + col9 from test1") + + tdSql.query("select col1 + col2 from test1") + tdSql.checkRows(11) + tdSql.checkData(0, 0, 2.0) + + tdSql.query("select col1 + col2 * col3 + col3 / col4 + col5 + col6 from test1") + tdSql.checkRows(11) + tdSql.checkData(0, 0, 3.2) + + #tdSql.execute("insert into test1(ts, col1) values(%d, 11)" % (self.ts + 11)) + tdSql.query("select col1 + col2 from test1") + tdSql.checkRows(11) + tdSql.checkData(10, 0, None) + + tdSql.query("select col1 + col2 * col3 from test1") + tdSql.checkRows(11) + tdSql.checkData(10, 0, None) + + tdSql.query("select col1 + col2 * col3 + col3 / col4 + col5 + col6 from test1") + tdSql.checkRows(11) + tdSql.checkData(10, 0, None) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_percentile_restart.py b/tests/pytest/functions/function_percentile_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..ade10282dedd655bc7ccb912a30a2a3e88a72223 --- /dev/null +++ b/tests/pytest/functions/function_percentile_restart.py @@ -0,0 +1,136 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + intData = [] + floatData = [] + + for i in range(self.rowNum): + intData.append(i + 1) + floatData.append(i + 0.1) + + # percentile verifacation + tdSql.error("select percentile(ts 20) from test") + tdSql.error("select apercentile(ts 20) from test") + tdSql.error("select percentile(col7 20) from test") + tdSql.error("select apercentile(col7 20) from test") + tdSql.error("select percentile(col8 20) from test") + tdSql.error("select apercentile(col8 20) from test") + tdSql.error("select percentile(col9 20) from test") + tdSql.error("select apercentile(col9 20) from test") + + tdSql.query("select percentile(col1, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col1, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col1, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col1, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col1, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col1, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col2, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col2, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col2, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col2, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col2, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col2, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col3, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col3, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col3, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col3, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col3, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col3, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col4, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col4, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col4, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col4, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col4, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col4, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col5, 0) from test") + print("query result: %s" % tdSql.getData(0, 0)) + print("array result: %s" % np.percentile(floatData, 0)) + tdSql.query("select apercentile(col5, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col5, 50) from test") + print("query result: %s" % tdSql.getData(0, 0)) + print("array result: %s" % np.percentile(floatData, 50)) + tdSql.query("select apercentile(col5, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col5, 100) from test") + print("query result: %s" % tdSql.getData(0, 0)) + print("array result: %s" % np.percentile(floatData, 100)) + tdSql.query("select apercentile(col5, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col6, 0) from test") + tdSql.checkData(0, 0, np.percentile(floatData, 0)) + tdSql.query("select apercentile(col6, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col6, 50) from test") + tdSql.checkData(0, 0, np.percentile(floatData, 50)) + tdSql.query("select apercentile(col6, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col6, 100) from test") + tdSql.checkData(0, 0, np.percentile(floatData, 100)) + tdSql.query("select apercentile(col6, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_spread_restart.py b/tests/pytest/functions/function_spread_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..ba71da0a18ac2e1e2a1ead6ab3de9ff5cae6a600 --- /dev/null +++ b/tests/pytest/functions/function_spread_restart.py @@ -0,0 +1,69 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + tdSql.error("select spread(col7) from test") + tdSql.error("select spread(col7) from test1") + tdSql.error("select spread(col8) from test") + tdSql.error("select spread(col8) from test1") + tdSql.error("select spread(col9) from test") + tdSql.error("select spread(col9) from test1") + + tdSql.query("select spread(col1) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col2) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col3) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col4) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col5) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select spread(col6) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_stddev_restart.py b/tests/pytest/functions/function_stddev_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..ec413b94b20a89c210131188d2a09e38cdbc721c --- /dev/null +++ b/tests/pytest/functions/function_stddev_restart.py @@ -0,0 +1,75 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + intData = [] + floatData = [] + + for i in range(self.rowNum): + intData.append(i + 1) + floatData.append(i + 0.1) + + # stddev verifacation + tdSql.error("select stddev(ts) from test1") + tdSql.error("select stddev(col1) from test") + tdSql.error("select stddev(col2) from test") + tdSql.error("select stddev(col3) from test") + tdSql.error("select stddev(col4) from test") + tdSql.error("select stddev(col5) from test") + tdSql.error("select stddev(col6) from test") + tdSql.error("select stddev(col7) from test1") + tdSql.error("select stddev(col8) from test1") + tdSql.error("select stddev(col9) from test1") + + tdSql.query("select stddev(col1) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col2) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col3) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col4) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col5) from test1") + tdSql.checkData(0, 0, np.std(floatData)) + + tdSql.query("select stddev(col6) from test1") + tdSql.checkData(0, 0, np.std(floatData)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_sum_restart.py b/tests/pytest/functions/function_sum_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..7fd9ae7dd419faa7f9e00f5a043a0c5e2c3d5f03 --- /dev/null +++ b/tests/pytest/functions/function_sum_restart.py @@ -0,0 +1,64 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + intData = [] + floatData = [] + + for i in range(self.rowNum): + intData.append(i + 1) + floatData.append(i + 0.1) + + # sum verifacation + tdSql.error("select sum(ts) from test") + tdSql.error("select sum(col7) from test") + tdSql.error("select sum(col8) from test") + tdSql.error("select sum(col9) from test") + + tdSql.query("select sum(col1) from test") + tdSql.checkData(0, 0, np.sum(intData)) + tdSql.query("select sum(col2) from test") + tdSql.checkData(0, 0, np.sum(intData)) + tdSql.query("select sum(col3) from test") + tdSql.checkData(0, 0, np.sum(intData)) + tdSql.query("select sum(col4) from test") + tdSql.checkData(0, 0, np.sum(intData)) + tdSql.query("select sum(col5) from test") + tdSql.checkData(0, 0, np.sum(floatData)) + tdSql.query("select sum(col6) from test") + tdSql.checkData(0, 0, np.sum(floatData)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_top_restart.py b/tests/pytest/functions/function_top_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..5ae96a2505f98a1bfe4ce8602e098c5217816fda --- /dev/null +++ b/tests/pytest/functions/function_top_restart.py @@ -0,0 +1,93 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + intData = [] + floatData = [] + + for i in range(self.rowNum): + intData.append(i + 1) + floatData.append(i + 0.1) + + # top verifacation + tdSql.error("select top(ts, 10) from test") + tdSql.error("select top(col1, 0) from test") + tdSql.error("select top(col1, 101) from test") + tdSql.error("select top(col2, 0) from test") + tdSql.error("select top(col2, 101) from test") + tdSql.error("select top(col3, 0) from test") + tdSql.error("select top(col3, 101) from test") + tdSql.error("select top(col4, 0) from test") + tdSql.error("select top(col4, 101) from test") + tdSql.error("select top(col5, 0) from test") + tdSql.error("select top(col5, 101) from test") + tdSql.error("select top(col6, 0) from test") + tdSql.error("select top(col6, 101) from test") + tdSql.error("select top(col7, 10) from test") + tdSql.error("select top(col8, 10) from test") + tdSql.error("select top(col9, 10) from test") + + tdSql.query("select top(col1, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 9) + tdSql.checkData(1, 1, 10) + + tdSql.query("select top(col2, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 9) + tdSql.checkData(1, 1, 10) + + tdSql.query("select top(col3, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 9) + tdSql.checkData(1, 1, 10) + + tdSql.query("select top(col4, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 9) + tdSql.checkData(1, 1, 10) + + tdSql.query("select top(col5, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 8.1) + tdSql.checkData(1, 1, 9.1) + + tdSql.query("select top(col6, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 8.1) + tdSql.checkData(1, 1, 9.1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_twa_restart.py b/tests/pytest/functions/function_twa_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..2025e3c9ddcdd41aa18db949e5db0d059090e469 --- /dev/null +++ b/tests/pytest/functions/function_twa_restart.py @@ -0,0 +1,130 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + intData = [] + floatData = [] + + for i in range(self.rowNum): + intData.append(i + 1) + floatData.append(i + 0.1) + + # twa verifacation + tdSql.error("select twa(ts) from test") + tdSql.error("select twa(ts) from test1") + + tdSql.error("select twa(col1) from test") + tdSql.error("select twa(col1) from test1") + + tdSql.error("select twa(col2) from test") + tdSql.error("select twa(col2) from test1") + + tdSql.error("select twa(col3) from test") + tdSql.error("select twa(col3) from test1") + + tdSql.error("select twa(col4) from test") + tdSql.error("select twa(col4) from test1") + + tdSql.error("select twa(col5) from test") + tdSql.error("select twa(col5) from test1") + + tdSql.error("select twa(col6) from test") + tdSql.error("select twa(col6) from test1") + + tdSql.error("select twa(col7) from test") + tdSql.error("select twa(col7) from test1") + + tdSql.error("select twa(col8) from test") + tdSql.error("select twa(col8) from test1") + + tdSql.error("select twa(col9) from test") + tdSql.error("select twa(col9) from test1") + + tdSql.error("select twa(col1) from test where ts > %d" % self.ts) + tdSql.error("select twa(col1) from test1 where ts > %d" % self.ts) + + tdSql.error("select twa(col2) from test where ts > %d" % self.ts) + tdSql.error("select twa(col2) from test1 where ts > %d" % self.ts) + + tdSql.error("select twa(col3) from test where ts > %d" % self.ts) + tdSql.error("select twa(col3) from test1 where ts > %d" % self.ts) + + tdSql.error("select twa(col4) from test where ts > %d" % self.ts) + tdSql.error("select twa(col4) from test1 where ts > %d" % self.ts) + + tdSql.error("select twa(col5) from test where ts > %d" % self.ts) + tdSql.error("select twa(col5) from test1 where ts > %d" % self.ts) + + tdSql.error("select twa(col6) from test where ts > %d" % self.ts) + tdSql.error("select twa(col6) from test1 where ts > %d" % self.ts) + + tdSql.error("select twa(col1) from test where ts < %d" % (self.ts + self.rowNum)) + tdSql.error("select twa(col1) from test1 where ts < %d" % (self.ts + self.rowNum)) + + tdSql.error("select twa(col2) from test where ts < %d" % (self.ts + self.rowNum)) + tdSql.error("select twa(col2) from test1 where ts < %d" % (self.ts + self.rowNum)) + + tdSql.error("select twa(col3) from test where ts < %d" % (self.ts + self.rowNum)) + tdSql.error("select twa(col3) from test1 where ts < %d" % (self.ts + self.rowNum)) + + tdSql.error("select twa(col4) from test where ts < %d" % (self.ts + self.rowNum)) + tdSql.error("select twa(col4) from test1 where ts < %d" % (self.ts + self.rowNum)) + + tdSql.error("select twa(col5) from test where ts < %d" % (self.ts + self.rowNum)) + tdSql.error("select twa(col5) from test1 where ts < %d" % (self.ts + self.rowNum)) + + tdSql.error("select twa(col6) from test where ts < %d" % (self.ts + self.rowNum)) + tdSql.error("select twa(col6) from test1 where ts < %d" % (self.ts + self.rowNum)) + + tdSql.query("select twa(col1) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col1) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.query("select twa(col2) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col2) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.query("select twa(col3) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col3) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.query("select twa(col4) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col4) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.query("select twa(col5) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col5) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.query("select twa(col6) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col6) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/handle_val_log.sh b/tests/pytest/handle_val_log.sh new file mode 100755 index 0000000000000000000000000000000000000000..142cf1074552256d712bcef891fff74d4f4396b0 --- /dev/null +++ b/tests/pytest/handle_val_log.sh @@ -0,0 +1,29 @@ +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +grep 'start to execute\|ERROR SUMMARY' mem-error-out.log|grep -v 'grep'|uniq|tee uniq-mem-error-out.log + +for memError in `grep 'ERROR SUMMARY' uniq-mem-error-out.log | awk '{print $4}'` +do +if [ -n "$memError" ]; then + if [ "$memError" -gt 12 ]; then + echo -e "${RED} ## Memory errors number valgrind reports is $memError.\ + More than our threshold! ## ${NC}" + fi +fi +done + +grep 'start to execute\|definitely lost:' mem-error-out.log|grep -v 'grep'|uniq|tee uniq-definitely-lost-out.log +for defiMemError in `grep 'definitely lost:' uniq-definitely-lost-out.log | awk '{print $7}'` +do +if [ -n "$defiMemError" ]; then + if [ "$defiMemError" -gt 13 ]; then + echo -e "${RED} ## Memory errors number valgrind reports \ + Definitely lost is $defiMemError. More than our threshold! ## ${NC}" + fi +fi +done \ No newline at end of file diff --git a/tests/pytest/insert/alterTableAndInsert.py b/tests/pytest/insert/alterTableAndInsert.py new file mode 100644 index 0000000000000000000000000000000000000000..a0447704f3cfa594f3bda01cb0dd14b2e795bb5f --- /dev/null +++ b/tests/pytest/insert/alterTableAndInsert.py @@ -0,0 +1,40 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.execute("create table cars(ts timestamp, speed int) tags(id int)") + tdSql.execute("create table car0 using cars tags(0)") + tdSql.execute("insert into car0 values(now, 1)") + tdSql.execute("alter table cars add column c2 int") + tdSql.execute("insert into car0(ts, 'speed') values(now, 2)") + tdSql.checkAffectedRows(1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/before_1970.py b/tests/pytest/insert/before_1970.py new file mode 100644 index 0000000000000000000000000000000000000000..cb17b657aad1a3bfdb915c9661bad291b75d6f04 --- /dev/null +++ b/tests/pytest/insert/before_1970.py @@ -0,0 +1,80 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + + +class TDTestCase: + """ + add test data before 1970s + """ + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute("create database if not exists demo keep 36500;"); + print("==============create db demo keep 365000 days") + tdSql.execute("use demo;") + tdSql.execute("CREATE table if not exists test (ts timestamp, f1 int);") + print("==============create table test") + + print("==============step2") + #TODO : should add more testcases + tdSql.execute("insert into test values('1930-12-12 01:19:20.345', 1);") + tdSql.execute("insert into test values('1969-12-30 23:59:59.999', 2);") + tdSql.execute("insert into test values(-3600, 3);") + tdSql.execute("insert into test values('2020-10-20 14:02:53.770', 4);") + print("==============insert data") + + # tdSql.query("select * from test;") + # + # tdSql.checkRows(3) + # + # tdSql.checkData(0,0,'1969-12-12 01:19:20.345000') + # tdSql.checkData(1,0,'1970-01-01 07:00:00.000000') + # tdSql.checkData(2,0,'2020-10-20 14:02:53.770000') + print("==============step3") + tdDnodes.stopAll() + tdDnodes.start(1) + print("==============restart taosd") + + + print("==============step4") + tdSql.execute("use demo;") + tdSql.query("select * from test;") + # print(tdSql.queryResult) + tdSql.checkRows(4) + tdSql.checkData(0,0,'1930-12-12 01:19:20.345000') + tdSql.checkData(1,0,'1969-12-30 23:59:59.999000') + tdSql.checkData(2,0,'1970-01-01 07:00:00.000000') + tdSql.checkData(3,0,'2020-10-20 14:02:53.770000') + print("==============check data") + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/insertIntoTwoTables.py b/tests/pytest/insert/insertIntoTwoTables.py new file mode 100644 index 0000000000000000000000000000000000000000..8b4f423c3dae38a0d8218f7b113f2784259300b4 --- /dev/null +++ b/tests/pytest/insert/insertIntoTwoTables.py @@ -0,0 +1,53 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + ### test case for TD-1758 ### + print("==============step1") + tdSql.execute( + "create table t0(ts timestamp, c int)") + tdSql.execute( + 'create table t1(ts timestamp, c binary(1))') + tdSql.execute( + "insert into t0 values(now,1) t1 values(now,'0')(now+1a,'1')(now+2a,'2')(now+3a,'3')(now+4a,'4')") + + print("==============step2") + + tdSql.query("select * from t0") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + + tdSql.query("select * from t1") + tdSql.checkRows(5) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/restful.py b/tests/pytest/insert/restful.py new file mode 100644 index 0000000000000000000000000000000000000000..bf9bde99f0f97276e9a00aaa3290258274da988b --- /dev/null +++ b/tests/pytest/insert/restful.py @@ -0,0 +1,60 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import requests, json +import threading +import string +import random + +class RestfulInsert: + def init(self): + self.header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='} + self.url = "http://127.0.0.1:6041/rest/sql" + self.ts = 1104508800000 + self.numOfThreads = 50 + + def get_random_string(self, length): + letters = string.ascii_lowercase + result_str = ''.join(random.choice(letters) for i in range(length)) + return result_str + + def insertData(self, threadID): + print("thread %d started" % threadID) + data = "create table test.tb%d(ts timestamp, name nchar(20))" % threadID + requests.post(self.url, data, headers = self.header) + name = self.get_random_string(10) + start = self.ts + while True: + start += 1 + data = "insert into test.tb%d values(%d, '%s')" % (threadID, start, name) + requests.post(self.url, data, headers = self.header) + + def run(self): + data = "drop database if exists test" + requests.post(self.url, data, headers = self.header) + data = "create database test keep 7300" + requests.post(self.url, data, headers = self.header) + + threads = [] + for i in range(self.numOfThreads): + thread = threading.Thread(target=self.insertData, args=(i,)) + thread.start() + threads.append(thread) + + for i in range(self.numOfThreads): + threads[i].join() + +ri = RestfulInsert() +ri.init() +ri.run() \ No newline at end of file diff --git a/tests/pytest/insert/retentionpolicy.py b/tests/pytest/insert/retentionpolicy.py new file mode 100644 index 0000000000000000000000000000000000000000..c69060b5aec16b8d58aa2742e24c44d1ebe543ab --- /dev/null +++ b/tests/pytest/insert/retentionpolicy.py @@ -0,0 +1,122 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import datetime +sys.path.insert(0, os.getcwd()) +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestRetetion: + def init(self): + self.queryRows=0 + tdLog.debug("start to execute %s" % __file__) + tdLog.info("prepare cluster") + tdDnodes.init("") + tdDnodes.setTestCluster(False) + tdDnodes.setValgrind(False) + tdDnodes.stopAll() + tdDnodes.deploy(1) + tdDnodes.start(1) + print(tdDnodes.getDnodesRootDir()) + self.conn = taos.connect(config=tdDnodes.getSimCfgPath()) + tdSql.init(self.conn.cursor()) + tdSql.execute('reset query cache') + def checkRows(self, expectRows,sql): + if self.queryRows == expectRows: + tdLog.info("sql:%s, queryRows:%d == expect:%d" % (sql, self.queryRows, expectRows)) + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, self.queryRows, expectRows) + os.system("sudo timedatectl set-ntp true") + time.sleep(40) + tdLog.exit("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) + + def run(self): + + tdLog.info("=============== step1") + tdSql.execute('create database test keep 3 days 1;') + tdSql.execute('use test;') + tdSql.execute('create table test(ts timestamp,i int);') + + cmd = 'insert into test values(now-2d,1)(now-1d,2)(now,3)(now+1d,4);' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from test') + tdSql.checkRows(4) + + tdLog.info("=============== step2") + tdDnodes.stop(1) + os.system("sudo timedatectl set-ntp false") + os.system("sudo date -s $(date -d \"${DATE} 2 days\" \"+%Y%m%d\")") + tdDnodes.start(1) + cmd = 'insert into test values(now,5);' + tdDnodes.stop(1) + tdDnodes.start(1) + + tdLog.info(cmd) + tdSql.execute(cmd) + self.queryRows=tdSql.query('select * from test') + if self.queryRows==4: + self.checkRows(4,cmd) + return 0 + else: + self.checkRows(5,cmd) + tdLog.info("=============== step3") + tdDnodes.stop(1) + os.system("sudo date -s $(date -d \"${DATE} 2 days\" \"+%Y%m%d\")") + tdDnodes.start(1) + tdLog.info(cmd) + tdSql.execute(cmd) + self.queryRows=tdSql.query('select * from test') + if self.queryRows==4: + self.checkRows(4,cmd) + return 0 + cmd = 'insert into test values(now-1d,6);' + tdLog.info(cmd) + tdSql.execute(cmd) + self.queryRows=tdSql.query('select * from test') + self.checkRows(6,cmd) + tdLog.info("=============== step4") + tdDnodes.stop(1) + tdDnodes.start(1) + cmd = 'insert into test values(now,7);' + tdLog.info(cmd) + tdSql.execute(cmd) + self.queryRows=tdSql.query('select * from test') + self.checkRows(7,cmd) + + tdLog.info("=============== step5") + tdDnodes.stop(1) + tdDnodes.start(1) + cmd='select * from test where ts > now-1d' + self.queryRows=tdSql.query('select * from test where ts > now-1d') + self.checkRows(1,cmd) + + def stop(self): + os.system("sudo timedatectl set-ntp true") + time.sleep(40) + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +clients = TDTestRetetion() +clients.init() +clients.run() +clients.stop() + diff --git a/tests/pytest/query/bug1471.py b/tests/pytest/query/bug1471.py new file mode 100644 index 0000000000000000000000000000000000000000..f1cb0bdcdfbb085410d0001606208e11373687a1 --- /dev/null +++ b/tests/pytest/query/bug1471.py @@ -0,0 +1,73 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import time +import threading + + +class myThread(threading.Thread): + def __init__(self, conn): + threading.Thread.__init__(self) + self.event = threading.Event() + self.conn = taos.connect(conn._host, port=conn._port, config=conn._config) + + def run(self): + cur = self.conn.cursor() + self.event.wait() + cur.execute("drop database db") + cur.close() + self.conn.close() + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + for i in range(50): + print("round", i) + thread = myThread(tdSql.cursor._connection) + thread.start() + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + tdSql.execute("create table car (ts timestamp, s int)") + tdSql.execute("insert into car values('2020-10-19 17:00:00', 123)") + + thread.event.set() + try: + tdSql.query("select s from car where ts = '2020-10-19 17:00:00'") + except Exception as e: + pass + else: + tdSql.checkData(0, 0, 123) + + thread.join() + time.sleep(0.2) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryInterval.py b/tests/pytest/query/queryInterval.py new file mode 100644 index 0000000000000000000000000000000000000000..99222016048f71ae66768665fb70522d466b248b --- /dev/null +++ b/tests/pytest/query/queryInterval.py @@ -0,0 +1,66 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1593548685000 + + def run(self): + tdSql.prepare() + + tdSql.execute("create table st (ts timestamp, voltage int) tags (loc nchar(30))") + tdSql.execute("insert into t0 using st tags('beijing') values(%d, 220) (%d, 221) (%d, 225) (%d, 228) (%d, 222)" + % (self.ts, self.ts + 1000000000, self.ts + 2000000000, self.ts + 3000000000, self.ts + 6000000000)) + tdSql.execute("insert into t1 using st tags('shanghai') values(%d, 220) (%d, 221) (%d, 225) (%d, 228) (%d, 222)" + % (self.ts, self.ts + 2000000000, self.ts + 4000000000, self.ts + 5000000000, self.ts + 7000000000)) + + tdSql.query("select avg(voltage) from st interval(1n)") + tdSql.checkRows(3) + tdSql.checkData(0, 1, 221.4) + tdSql.checkData(1, 1, 227.0) + tdSql.checkData(2, 1, 222.0) + + tdSql.query("select avg(voltage) from st interval(1n, 15d)") + tdSql.checkRows(4) + tdSql.checkData(0, 1, 220.333333) + tdSql.checkData(1, 1, 224.666666) + tdSql.checkData(2, 1, 225.0) + tdSql.checkData(3, 1, 222.0) + + tdSql.query("select avg(voltage) from st interval(1n, 15d) group by loc") + tdSql.checkRows(7) + tdSql.checkData(0, 1, 220.5) + tdSql.checkData(1, 1, 226.5) + tdSql.checkData(2, 1, 222.0) + tdSql.checkData(3, 1, 220.0) + tdSql.checkData(4, 1, 221.0) + tdSql.checkData(5, 1, 226.5) + tdSql.checkData(6, 1, 222.0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryNormal.py b/tests/pytest/query/queryNormal.py index 208ac54ecd5192aec7880c49637794c1fa8e17b8..13393117d642ec1fbdf839d59429428ffee79a27 100644 --- a/tests/pytest/query/queryNormal.py +++ b/tests/pytest/query/queryNormal.py @@ -35,7 +35,8 @@ class TDTestCase: tdSql.execute( "insert into tb2 using stb1 tags(2,'tb2', '表2') values ('2020-04-18 15:00:02.000', 3, 2.1), ('2020-04-18 15:00:03.000', 4, 2.2)") - # inner join --- bug + tdSql.error("select * from tb 1") + tdSql.query("select * from tb1 a, tb2 b where a.ts = b.ts") tdSql.checkRows(0) diff --git a/tests/pytest/query/querySort.py b/tests/pytest/query/querySort.py index e5d3c8ce1f4eb9c1d2003bd659771562c9ea14e5..649e0dc1cb3191ba08b3f2da0a5edee3afc66575 100644 --- a/tests/pytest/query/querySort.py +++ b/tests/pytest/query/querySort.py @@ -96,6 +96,12 @@ class TDTestCase: tdSql.query("select * from st order by ts desc") self.checkColumnSorted(0, "desc") + print("======= step 2: verify order for special column =========") + + tdSql.query("select tbcol1 from st order by ts desc") + + tdSql.query("select tbcol6 from st order by ts desc") + for i in range(1, 10): tdSql.error("select * from st order by tbcol%d" % i) tdSql.error("select * from st order by tbcol%d asc" % i) diff --git a/tests/pytest/query/removeDBAndSTable.py b/tests/pytest/query/removeDBAndSTable.py new file mode 100644 index 0000000000000000000000000000000000000000..4616c7e378326af633a89905d746c7d51ce92139 --- /dev/null +++ b/tests/pytest/query/removeDBAndSTable.py @@ -0,0 +1,70 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute("create database db_vplu"); + tdSql.execute("use db_vplu") + tdSql.execute("CREATE table if not exists st (ts timestamp, speed int) tags(id int)") + tdSql.execute("CREATE table if not exists st_vplu (ts timestamp, speed int) tags(id int)") + + print("==============step2") + + tdSql.execute("drop table st") + + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "st_vplu") + + tdDnodes.stopAll() + tdDnodes.start(1) + + tdSql.execute("use db_vplu") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "st_vplu") + + tdSql.execute("drop database db") + tdSql.query("show databases") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "db_vplu") + + tdDnodes.stopAll() + tdDnodes.start(1) + + tdSql.query("show databases") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "db_vplu") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/history.py b/tests/pytest/stream/history.py new file mode 100644 index 0000000000000000000000000000000000000000..890580001cf40a13ba18f6f81a3bd0faaac67991 --- /dev/null +++ b/tests/pytest/stream/history.py @@ -0,0 +1,63 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.execute("create table cars(ts timestamp, s int) tags(id int)") + tdSql.execute("create table car0 using cars tags(0)") + tdSql.execute("create table car1 using cars tags(1)") + tdSql.execute("create table car2 using cars tags(2)") + tdSql.execute("create table car3 using cars tags(3)") + tdSql.execute("create table car4 using cars tags(4)") + + tdSql.execute("insert into car0 values('2019-01-01 00:00:00.103', 1)") + tdSql.execute("insert into car1 values('2019-01-01 00:00:00.234', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:01.012', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:02.003', 1)") + tdSql.execute("insert into car2 values('2019-01-01 00:00:02.328', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:03.139', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:04.348', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:05.783', 1)") + tdSql.execute("insert into car1 values('2019-01-01 00:00:01.893', 1)") + tdSql.execute("insert into car1 values('2019-01-01 00:00:02.712', 1)") + tdSql.execute("insert into car1 values('2019-01-01 00:00:03.982', 1)") + tdSql.execute("insert into car3 values('2019-01-01 00:00:01.389', 1)") + tdSql.execute("insert into car4 values('2019-01-01 00:00:01.829', 1)") + + tdSql.execute("create table strm as select count(*) from cars interval(4s)") + tdSql.waitedQuery("select * from strm", 2, 100) + tdSql.checkData(0, 1, 11) + tdSql.checkData(1, 1, 2) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/alter_wal0.py b/tests/pytest/table/alter_wal0.py new file mode 100644 index 0000000000000000000000000000000000000000..15ad69998f450b8e385cbf58052d246d9de27380 --- /dev/null +++ b/tests/pytest/table/alter_wal0.py @@ -0,0 +1,75 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + + +class TDTestCase: + """ + remove last tow bytes of file 'wal0',then restart taosd and create new tables. + """ + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute("create database if not exists demo;"); + tdSql.execute("use demo;") + tdSql.execute("create table if not exists meters(ts timestamp, f1 int) tags(t1 int);"); + for i in range(1,11): + tdSql.execute("CREATE table if not exists test{num} using meters tags({num});".format(num=i)) + print("==============insert 10 tables") + + tdSql.query('show tables;') + tdSql.checkRows(10) + + print("==============step2") + tdDnodes.stopAll() + filename = '/var/lib/taos/mnode/wal/wal0' + + with open(filename, 'rb') as f1: + temp = f1.read() + + with open(filename, 'wb') as f2: + f2.write(temp[:-2]) + + tdDnodes.start(1) + print("==============remove last tow bytes of file 'wal0' and restart taosd") + + print("==============step3") + tdSql.execute("use demo;") + tdSql.query('show tables;') + tdSql.checkRows(10) + for i in range(11,21): + tdSql.execute("CREATE table if not exists test{num} using meters tags({num});".format(num=i)) + + tdSql.query('show tables;') + tdSql.checkRows(20) + print("==============check table numbers and create 10 tables") + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/datatype.py b/tests/pytest/tag_lite/datatype.py index f7fa9fa3a2dddaa3f352d02f74872ba42bd32f44..40f0ed7a090683faf149e56620ff63db7a52acb3 100644 --- a/tests/pytest/tag_lite/datatype.py +++ b/tests/pytest/tag_lite/datatype.py @@ -103,7 +103,7 @@ class TDTestCase: tdSql.execute('alter table stb add tag tnc nchar(10)') for tid in range(1, self.ntables + 1): tdSql.execute('alter table tb%d set tag tnc=\"%s\"' % - (tid, str(tid * 1.2))) + (tid, str(tid + 1000000000))) tdLog.info("insert %d data in to each %d tables" % (2, self.ntables)) for rid in range(self.rowsPerTable + 1, self.rowsPerTable + 3): sqlcmd = ['insert into'] diff --git a/tests/pytest/test.py b/tests/pytest/test.py index 678bd873368325d97783fac1e0f94cd76be38cef..a2c35444b55fea9df55e46b4c81a9150b642b452 100644 --- a/tests/pytest/test.py +++ b/tests/pytest/test.py @@ -16,6 +16,7 @@ import sys import getopt import subprocess +import time from distutils.log import warn as printf from util.log import * @@ -33,7 +34,8 @@ if __name__ == "__main__": valgrind = 0 logSql = True stop = 0 - opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scgh', [ + restart = False + opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghr', [ 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help']) for key, value in opts: if key in ['-h', '--help']: @@ -46,8 +48,12 @@ if __name__ == "__main__": tdLog.printNoPrefix('-s stop All dnodes') tdLog.printNoPrefix('-c Test Cluster Flag') tdLog.printNoPrefix('-g valgrind Test Flag') + tdLog.printNoPrefix('-r taosd restart test') sys.exit(0) + if key in ['-r', '--restart']: + restart = True + if key in ['-f', '--file']: fileName = value @@ -138,5 +144,19 @@ if __name__ == "__main__": tdCases.runAllLinux(conn) else: tdCases.runOneLinux(conn, fileName) - + if restart: + if fileName == "all": + tdLog.info("not need to query ") + else: + sp = fileName.rsplit(".", 1) + if len(sp) == 2 and sp[1] == "py": + tdDnodes.stopAll() + tdDnodes.start(1) + time.sleep(1) + conn = taos.connect( host, config=tdDnodes.getSimCfgPath()) + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + tdLog.info("query test after taosd restart") + tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py") + else: + tdLog.info("not need to query") conn.close() diff --git a/tests/pytest/tools/taosdemo.py b/tests/pytest/tools/taosdemo.py index 54d33c90f36bc5f5b817f7ea9ec6d8787a3f0d78..5bf8ebaf03beb052f09d80b92c6b6b6d588e4f4f 100644 --- a/tests/pytest/tools/taosdemo.py +++ b/tests/pytest/tools/taosdemo.py @@ -16,6 +16,7 @@ import os from util.log import * from util.cases import * from util.sql import * +from util.dnodes import * class TDTestCase: @@ -25,11 +26,30 @@ class TDTestCase: self.numberOfTables = 10000 self.numberOfRecords = 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 run(self): tdSql.prepare() - - os.system("yes | taosdemo -t %d -n %d" % (self.numberOfTables, self.numberOfRecords)) + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + os.system("yes | %staosdemo -t %d -n %d" % (binPath,self.numberOfTables, self.numberOfRecords)) tdSql.execute("use test") tdSql.query("select count(*) from meters") diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index 7de8efdfe96c2312a7bb844329fb91f770c54180..9abec354c6d58507ff3bcc74d1c0dc03f691440c 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -123,8 +123,8 @@ class TDSql: def checkData(self, row, col, data): self.checkRowCol(row, col) - if self.queryResult[row][col] != data: - if str(self.queryResult[row][col]) != str(data): + if self.queryResult[row][col] != data: + if str(self.queryResult[row][col]) == str(data): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % (self.sql, row, col, self.queryResult[row][col], data)) return diff --git a/tests/pytest/valgrind-test.sh b/tests/pytest/valgrind-test.sh index 9dc9de1b152e5bf6611a2b9353a9879119ffcf04..468974d0983884a5df0ee4fcc06aaf1ce0a36a90 100755 --- a/tests/pytest/valgrind-test.sh +++ b/tests/pytest/valgrind-test.sh @@ -1,5 +1,26 @@ #!/bin/bash +IN_TDINTERNAL="community" +TDIR=`pwd` +if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then + cd ../.. +else + cd ../../.. +fi +TOP_DIR=`pwd` +TAOSLIB_DIR=`find . -name "libtaos.so"|grep -w lib|head -n1` +if [[ "$TAOSLIB_DIR" == *"$IN_TDINTERNAL"* ]]; then + LIB_DIR=`find . -name "libtaos.so"|grep -w lib|head -n1|cut -d '/' --fields=2,3,4,5` +else + LIB_DIR=`find . -name "libtaos.so"|grep -w lib|head -n1|cut -d '/' --fields=2,3,4` +fi +if [ ! $LD_LIBRARY_PATH ]; then + export LD_LIBRARY_PATH=$TOP_DIR/$LIB_DIR +else + export LD_LIBRARY_PATH=$TOP_DIR/$LIB_DIR:$LD_LIBRARY_PATH +fi + +cd $TDIR # client PYTHONMALLOC=malloc python3 ./test.py -g -f client/client.py PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 diff --git a/tests/script/fullGeneralSuite.sim b/tests/script/fullGeneralSuite.sim index 4df79002658056c44670baf0664fccfacefd0261..4dd3957f390237c6dddc6b1f66b14ee177b6dbcf 100644 --- a/tests/script/fullGeneralSuite.sim +++ b/tests/script/fullGeneralSuite.sim @@ -220,3 +220,5 @@ run general/stream/table_del.sim run general/stream/metrics_del.sim run general/stream/table_replica1_vnoden.sim run general/stream/metrics_replica1_vnoden.sim +run general/db/show_create_db.sim +run general/db/show_create_table.sim diff --git a/tests/script/general/compute/avg.sim b/tests/script/general/compute/avg.sim index 9a37363a6052e1098d2aa92221044a067b3abee7..52a270bc6d9b1581fb210693f74cce9ecc73b3fa 100644 --- a/tests/script/general/compute/avg.sim +++ b/tests/script/general/compute/avg.sim @@ -31,8 +31,10 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw @@ -52,7 +54,9 @@ if $data00 != 9.500000000 then endi print =============== step3 -sql select avg(tbcol) from $tb where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select avg(tbcol) from $tb where ts <= $ms print ===> $data00 if $data00 != 2.000000000 then return -1 @@ -79,7 +83,9 @@ if $data01 != 9.500000000 then endi print =============== step6 -sql select avg(tbcol) as b from $tb where ts < now + 4m interval(1m) +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select avg(tbcol) as b from $tb where ts <= $ms interval(1m) print ===> $data01 if $data41 != 4.000000000 then return -1 @@ -96,7 +102,9 @@ if $data00 != 9.500000000 then endi print =============== step8 -sql select avg(tbcol) as c from $mt where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select avg(tbcol) as c from $mt where ts <= $ms print ===> $data00 if $data00 != 2.000000000 then return -1 @@ -108,7 +116,9 @@ if $data00 != 9.500000000 then return -1 endi -sql select avg(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select avg(tbcol) as c from $mt where tgcol < 5 and ts <= $ms print ===> $data00 if $data00 != 2.000000000 then return -1 @@ -139,7 +149,9 @@ if $rows != $tbNum then endi print =============== step11 -sql select avg(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select avg(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol print ===> $data11 if $data11 != 1.000000000 then return -1 diff --git a/tests/script/general/compute/bottom.sim b/tests/script/general/compute/bottom.sim index 592f87651e118c0c7509cfcab26bbad4d9873047..415bd36e2e0417e8f9da2989e21f1a1908e01cfd 100644 --- a/tests/script/general/compute/bottom.sim +++ b/tests/script/general/compute/bottom.sim @@ -31,8 +31,10 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw @@ -52,7 +54,9 @@ if $data01 != 0 then endi print =============== step3 -sql select bottom(tbcol, 1) from $tb where ts > now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select bottom(tbcol, 1) from $tb where ts > $ms print ===> $data01 if $data01 != 5 then return -1 @@ -76,7 +80,9 @@ if $data11 != 1 then endi print =============== step6 -sql select bottom(tbcol, 2) as b from $tb where ts > now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select bottom(tbcol, 2) as b from $tb where ts > $ms print ===> $data01 $data11 if $data01 != 5 then return -1 diff --git a/tests/script/general/compute/count.sim b/tests/script/general/compute/count.sim index c2ed5af3ca4631ca37bdef4959fd1fc353171e8a..d8aeb18752a3fee18471a3402d259142486ecc1a 100644 --- a/tests/script/general/compute/count.sim +++ b/tests/script/general/compute/count.sim @@ -31,8 +31,10 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw @@ -65,7 +67,9 @@ if $data00 != $rowNum then endi print =============== step3 -sql select count(tbcol) from $tb where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol) from $tb where ts <= $ms print ===> $data00 if $data00 != 5 then return -1 @@ -92,7 +96,9 @@ if $data01 != $rowNum then endi print =============== step6 -sql select count(tbcol) as b from $tb where ts < now + 4m interval(1m) +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol) as b from $tb where ts <= $ms interval(1m) print ===> $data01 if $data01 != 1 then return -1 @@ -122,7 +128,9 @@ if $data00 != $totalNum then endi print =============== step10 -sql select count(tbcol) as c from $mt where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol) as c from $mt where ts <= $ms print ===> $data00 if $data00 != 50 then return -1 @@ -134,7 +142,9 @@ if $data00 != 100 then return -1 endi -sql select count(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= $ms print ===> $data00 if $data00 != 25 then return -1 @@ -168,7 +178,9 @@ if $rows != $tbNum then endi print =============== step11 -sql select count(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol print ===> $data01 if $data01 != 1 then return -1 diff --git a/tests/script/general/compute/diff.sim b/tests/script/general/compute/diff.sim index 8a60cd00bc745180d6f5d910e34650091b6b8945..88c2ecb09df9128499cef1426a53d5b922512164 100644 --- a/tests/script/general/compute/diff.sim +++ b/tests/script/general/compute/diff.sim @@ -31,8 +31,9 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw @@ -52,13 +53,17 @@ if $data11 != 1 then endi print =============== step3 -sql select diff(tbcol) from $tb where ts > now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select diff(tbcol) from $tb where ts > $ms print ===> $data11 if $data11 != 1 then return -1 endi -sql select diff(tbcol) from $tb where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select diff(tbcol) from $tb where ts <= $ms print ===> $data11 if $data11 != 1 then return -1 @@ -77,7 +82,9 @@ sql select diff(tbcol) as b from $tb interval(1m) -x step5 step5: print =============== step6 -sql select diff(tbcol) as b from $tb where ts < now + 4m interval(1m) -x step6 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select diff(tbcol) as b from $tb where ts <= $ms interval(1m) -x step6 return -1 step6: diff --git a/tests/script/general/compute/diff2.sim b/tests/script/general/compute/diff2.sim index 0be907c16ae20690e32eb2364f9b169f9e77f302..14675c823f04693c76fcb151169b6dba738b8aaf 100644 --- a/tests/script/general/compute/diff2.sim +++ b/tests/script/general/compute/diff2.sim @@ -31,9 +31,11 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m + $cc = $x * 60000 + $ms = 1601481600000 + $cc + $tinyint = $x / 128 - sql insert into $tb values (now + $ms , $x , $x , $x , $x , $tinyint , $x , $x , $x , $x ) + sql insert into $tb values ($ms , $x , $x , $x , $x , $tinyint , $x , $x , $x , $x ) $x = $x + 1 endw diff --git a/tests/script/general/compute/first.sim b/tests/script/general/compute/first.sim index 80f4f53cdbe8f498345a5f68e542b9914163485e..01b82cce62adbc13420289878ea01ed63776bbce 100644 --- a/tests/script/general/compute/first.sim +++ b/tests/script/general/compute/first.sim @@ -31,8 +31,10 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw @@ -52,7 +54,9 @@ if $data00 != 0 then endi print =============== step3 -sql select first(tbcol) from $tb where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select first(tbcol) from $tb where ts <= $ms print ===> $data00 if $data00 != 0 then return -1 @@ -79,7 +83,9 @@ if $data01 != 0 then endi print =============== step6 -sql select first(tbcol) as b from $tb where ts < now + 4m interval(1m) +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select first(tbcol) as b from $tb where ts <= $ms interval(1m) print ===> $data01 if $data41 != 4 then return -1 @@ -96,7 +102,9 @@ if $data00 != 0 then endi print =============== step8 -sql select first(tbcol) as c from $mt where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select first(tbcol) as c from $mt where ts <= $ms print ===> $data00 if $data00 != 0 then return -1 @@ -108,7 +116,9 @@ if $data00 != 0 then return -1 endi -sql select first(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select first(tbcol) as c from $mt where tgcol < 5 and ts <= $ms print ===> $data00 if $data00 != 0 then return -1 @@ -140,7 +150,9 @@ if $rows != $tbNum then endi print =============== step11 -sql select first(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select first(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol print ===> $data11 if $data11 != 1 then return -1 diff --git a/tests/script/general/compute/interval.sim b/tests/script/general/compute/interval.sim index 26f40eda5ae78a3f49d1341c8aae25d549fdb52e..8f9bf2ecb3013afe2bc11d5c851d8effbcf37686 100644 --- a/tests/script/general/compute/interval.sim +++ b/tests/script/general/compute/interval.sim @@ -31,8 +31,10 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw @@ -56,7 +58,9 @@ if $data05 != 1 then endi print =============== step3 -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now + 4m interval(1m) +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m) print ===> $rows if $rows > 10 then return -1 @@ -72,7 +76,13 @@ if $data05 != 1 then endi print =============== step4 -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now+40m and ts > now-1m interval(1m) +$cc = 40 * 60000 +$ms = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) print ===> $rows if $rows < 18 then return -1 @@ -88,7 +98,13 @@ if $data05 != 1 then endi print =============== step5 -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now+40m and ts > now+1m interval(1m) fill(value,0) +$cc = 40 * 60000 +$ms = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0) print ===> $rows if $rows < 30 then return -1 @@ -120,7 +136,9 @@ if $data11 < 5 then endi print =============== step7 -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now + 4m interval(1m) +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m) print ===> $rows if $rows < 3 then return -1 @@ -136,7 +154,13 @@ if $data11 < 5 then endi print =============== step8 -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now+40m and ts > now-1m interval(1m) +$cc = 40 * 60000 +$ms1 = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) print ===> $rows if $rows < 18 then return -1 @@ -152,7 +176,13 @@ if $data11 < 5 then endi print =============== step9 -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now+40m and ts > now+1m interval(1m) fill(value, 0) +$cc = 40 * 60000 +$ms1 = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0) if $rows < 30 then return -1 endi diff --git a/tests/script/general/compute/last.sim b/tests/script/general/compute/last.sim index 0e92bb6d456c92b8158faa59aa18d2bef82995e9..88a6a268463ef005dd4c611e2b127c3a0d8f3bf0 100644 --- a/tests/script/general/compute/last.sim +++ b/tests/script/general/compute/last.sim @@ -31,8 +31,10 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw @@ -52,7 +54,10 @@ if $data00 != 19 then endi print =============== step3 -sql select last(tbcol) from $tb where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select last(tbcol) from $tb where ts <= $ms print ===> $data00 if $data00 != 4 then return -1 @@ -79,7 +84,10 @@ if $data01 != 19 then endi print =============== step6 -sql select last(tbcol) as b from $tb where ts < now + 4m interval(1m) +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select last(tbcol) as b from $tb where ts <= $ms interval(1m) print ===> $data11 if $data11 != 1 then return -1 @@ -96,7 +104,10 @@ if $data00 != 19 then endi print =============== step8 -sql select last(tbcol) as c from $mt where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select last(tbcol) as c from $mt where ts <= $ms print ===> $data00 if $data00 != 4 then return -1 @@ -108,7 +119,10 @@ if $data00 != 19 then return -1 endi -sql select last(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select last(tbcol) as c from $mt where tgcol < 5 and ts <= $ms print ===> $data00 if $data00 != 4 then return -1 @@ -139,7 +153,10 @@ if $rows != $tbNum then endi print =============== step11 -sql select last(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select last(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol print ===> $data11 if $data11 != 1 then return -1 diff --git a/tests/script/general/compute/last_row.sim b/tests/script/general/compute/last_row.sim index cc5cc3edbbf47f57eec723eba007c79fc03f150b..55d97fe53c75b8df34caed98f4bd57bc05a9711f 100644 --- a/tests/script/general/compute/last_row.sim +++ b/tests/script/general/compute/last_row.sim @@ -31,8 +31,10 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw @@ -52,7 +54,9 @@ if $data00 != 19 then endi print =============== step3 -sql select last_row(tbcol) from $tb where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select last_row(tbcol) from $tb where ts <= $ms print ===> $data00 if $data00 != 4 then return -1 @@ -75,7 +79,9 @@ if $data00 != 19 then endi print =============== step8 -sql select last_row(tbcol) as c from $mt where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select last_row(tbcol) as c from $mt where ts <= $ms print ===> $data00 if $data00 != 4 then return -1 @@ -87,7 +93,9 @@ if $data00 != 19 then return -1 endi -sql select last_row(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select last_row(tbcol) as c from $mt where tgcol < 5 and ts <= $ms print ===> $data00 if $data00 != 4 then return -1 @@ -108,18 +116,37 @@ endi print =============== step11 -sql insert into $tb values(now + 1h, 10) -sql insert into $tb values(now + 3h, null) -sql insert into $tb values(now + 5h, -1) -sql insert into $tb values(now + 7h, null) +$cc = 1 * 3600000 +$ms = 1601481600000 + $cc +sql insert into $tb values( $ms , 10) + +$cc = 3 * 3600000 +$ms = 1601481600000 + $cc +sql insert into $tb values( $ms , null) + +$cc = 5 * 3600000 +$ms = 1601481600000 + $cc + +sql insert into $tb values( $ms , -1) + +$cc = 7 * 3600000 +$ms = 1601481600000 + $cc + +sql insert into $tb values( $ms , null) ## for super table -sql select last_row(*) from $mt where ts < now + 6h +$cc = 6 * 3600000 +$ms = 1601481600000 + $cc + +sql select last_row(*) from $mt where ts < $ms if $data01 != -1 then return -1 endi -sql select last_row(*) from $mt where ts < now + 8h +$cc = 8 * 3600000 +$ms = 1601481600000 + $cc + +sql select last_row(*) from $mt where ts < $ms if $data01 != NULL then return -1 endi @@ -129,23 +156,37 @@ if $data01 != NULL then return -1 endi -sql select last_row(*) from $mt where ts < now + 4h +$cc = 4 * 3600000 +$ms = 1601481600000 + $cc + +sql select last_row(*) from $mt where ts < $ms if $data01 != NULL then return -1 endi -sql select last_row(*) from $mt where ts > now + 1h and ts < now + 4h +$cc = 1 * 3600000 +$ms1 = 1601481600000 + $cc +$cc = 4 * 3600000 +$ms2 = 1601481600000 + $cc + +sql select last_row(*) from $mt where ts > $ms1 and ts <= $ms2 if $data01 != NULL then return -1 endi ## for table -sql select last_row(*) from $tb where ts < now + 6h +$cc = 6 * 3600000 +$ms = 1601481600000 + $cc + +sql select last_row(*) from $tb where ts <= $ms if $data01 != -1 then return -1 endi -sql select last_row(*) from $tb where ts < now + 8h +$cc = 8 * 3600000 +$ms = 1601481600000 + $cc + +sql select last_row(*) from $tb where ts <= $ms if $data01 != NULL then return -1 endi @@ -155,12 +196,20 @@ if $data01 != NULL then return -1 endi -sql select last_row(*) from $tb where ts < now + 4h +$cc = 4 * 3600000 +$ms = 1601481600000 + $cc + +sql select last_row(*) from $tb where ts <= $ms if $data01 != NULL then return -1 endi -sql select last_row(*) from $tb where ts > now + 1h and ts < now + 4h +$cc = 1 * 3600000 +$ms1 = 1601481600000 + $cc +$cc = 4 * 3600000 +$ms2 = 1601481600000 + $cc + +sql select last_row(*) from $tb where ts > $ms1 and ts <= $ms2 if $data01 != NULL then return -1 endi diff --git a/tests/script/general/compute/max.sim b/tests/script/general/compute/max.sim index 4fc760d66d1391e2b92ffc2fb01d00b4a0136c07..1029ba78cc595b70048f887c55a2393cb2b46e10 100644 --- a/tests/script/general/compute/max.sim +++ b/tests/script/general/compute/max.sim @@ -31,8 +31,10 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw @@ -52,7 +54,10 @@ if $data00 != 19 then endi print =============== step3 -sql select max(tbcol) from $tb where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select max(tbcol) from $tb where ts <= $ms print ===> $data00 if $data00 != 4 then return -1 @@ -79,7 +84,10 @@ if $data01 != 19 then endi print =============== step6 -sql select max(tbcol) as b from $tb where ts < now + 4m interval(1m) +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select max(tbcol) as b from $tb where ts <= $ms interval(1m) print ===> $data11 if $data11 != 1 then return -1 @@ -96,7 +104,10 @@ if $data00 != 19 then endi print =============== step8 -sql select max(tbcol) as c from $mt where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select max(tbcol) as c from $mt where ts <= $ms print ===> $data00 if $data00 != 4 then return -1 @@ -108,7 +119,10 @@ if $data00 != 19 then return -1 endi -sql select max(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select max(tbcol) as c from $mt where tgcol < 5 and ts <= $ms print ===> $data00 if $data00 != 4 then return -1 @@ -139,7 +153,10 @@ if $rows != $tbNum then endi print =============== step11 -sql select max(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select max(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol print ===> $data11 if $data11 != 1 then return -1 diff --git a/tests/script/general/compute/min.sim b/tests/script/general/compute/min.sim index 82a22b642e3f8f912eadb2a525c4fa1d38a788b3..d6a57f4f20d01a4ab1fc95ec902785363d1f004b 100644 --- a/tests/script/general/compute/min.sim +++ b/tests/script/general/compute/min.sim @@ -32,8 +32,10 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw @@ -53,7 +55,10 @@ if $data00 != 0 then endi print =============== step3 -sql select min(tbcol) from $tb where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select min(tbcol) from $tb where ts < $ms print ===> $data00 if $data00 != 0 then return -1 @@ -80,7 +85,11 @@ if $data01 != 0 then endi print =============== step6 -sql select min(tbcol) as b from $tb where ts < now + 4m interval(1m) +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select min(tbcol) as b from $tb where ts <= $ms interval(1m) +print select min(tbcol) as b from $tb where ts <= $ms interval(1m) print ===> $data11 if $data11 != 1 then return -1 @@ -97,7 +106,9 @@ if $data00 != 0 then endi print =============== step8 -sql select min(tbcol) as c from $mt where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select min(tbcol) as c from $mt where ts < $ms print ===> $data00 if $data00 != 0 then return -1 @@ -109,7 +120,9 @@ if $data00 != 0 then return -1 endi -sql select min(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select min(tbcol) as c from $mt where tgcol < 5 and ts <= $ms print ===> $data00 if $data00 != 0 then return -1 @@ -140,7 +153,9 @@ if $rows != $tbNum then endi print =============== step11 -sql select min(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select min(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol print ===> $data11 if $data11 != 1 then return -1 diff --git a/tests/script/general/compute/null.sim b/tests/script/general/compute/null.sim index cde95ca77f2ba741581a5ea82554b2b5112f662b..47f7a3c1b96152e5a30b4712831146187b98abc7 100644 --- a/tests/script/general/compute/null.sim +++ b/tests/script/general/compute/null.sim @@ -31,14 +31,16 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m + $cc = $x * 60000 + $ms = 1601481600000 + $cc - $v1 = $x - $v2 = $x - if $x == 0 then - $v1 = NULL - endi - sql insert into $tb values (now + $ms , $v1 , $v2 ) + $v1 = $x + $v2 = $x + if $x == 0 then + $v1 = NULL + endi + + sql insert into $tb values ($ms , $v1 , $v2 ) $x = $x + 1 endw diff --git a/tests/script/general/compute/percentile.sim b/tests/script/general/compute/percentile.sim index dd309c378943b69e87ea622bbdae133e7899209f..0fb88e7a40224404c2889696d6e8ba34655d18ee 100644 --- a/tests/script/general/compute/percentile.sim +++ b/tests/script/general/compute/percentile.sim @@ -31,8 +31,10 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw @@ -68,38 +70,56 @@ sql select percentile(tbcol, 110) from $tb -x step2 step2: print =============== step3 -sql select percentile(tbcol, 1) from $tb where ts > now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select percentile(tbcol, 1) from $tb where ts > $ms print ===> $data00 if $data00 != 5.140000000 then return -1 endi -sql select percentile(tbcol, 5) from $tb where ts > now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select percentile(tbcol, 5) from $tb where ts > $ms print ===> $data00 if $data00 != 5.700000000 then return -1 endi -sql select percentile(tbcol, 0) from $tb where ts > now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select percentile(tbcol, 0) from $tb where ts > $ms print ===> $data00 if $data00 != 5.000000000 then return -1 endi print =============== step4 -sql select percentile(tbcol, 1) as c from $tb where ts > now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select percentile(tbcol, 1) as c from $tb where ts > $ms print ===> $data00 if $data00 != 5.140000000 then return -1 endi -sql select percentile(tbcol, 5) as c from $tb where ts > now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select percentile(tbcol, 5) as c from $tb where ts > $ms print ===> $data00 if $data00 != 5.700000000 then return -1 endi -sql select percentile(tbcol, 0) as c from $tb where ts > now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select percentile(tbcol, 0) as c from $tb where ts > $ms print ===> $data00 if $data00 != 5.000000000 then return -1 diff --git a/tests/script/general/compute/stddev.sim b/tests/script/general/compute/stddev.sim index 7cea8726a9ed3d3d8215c97e368df623bb0a1c30..abe4025e961460803e33c63c7243a1112a1bfab5 100644 --- a/tests/script/general/compute/stddev.sim +++ b/tests/script/general/compute/stddev.sim @@ -31,8 +31,10 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw @@ -52,7 +54,10 @@ if $data00 != 5.766281297 then endi print =============== step3 -sql select stddev(tbcol) from $tb where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select stddev(tbcol) from $tb where ts <= $ms print ===> $data00 if $data00 != 1.414213562 then return -1 @@ -79,7 +84,10 @@ if $data01 != 5.766281297 then endi print =============== step6 -sql select stddev(tbcol) as b from $tb where ts < now + 4m interval(1m) +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select stddev(tbcol) as b from $tb where ts <= $ms interval(1m) print ===> $data01 if $data01 != 0.000000000 then return -1 diff --git a/tests/script/general/compute/sum.sim b/tests/script/general/compute/sum.sim index d05fe8930ecb882a14bd831e27925994179c888c..9d42e766b61e4c137b7f738dcb8b27d1f5061413 100644 --- a/tests/script/general/compute/sum.sim +++ b/tests/script/general/compute/sum.sim @@ -31,8 +31,10 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw @@ -52,7 +54,10 @@ if $data00 != 190 then endi print =============== step3 -sql select sum(tbcol) from $tb where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select sum(tbcol) from $tb where ts <= $ms print ===> $data00 if $data00 != 10 then return -1 @@ -79,7 +84,10 @@ if $data01 != 190 then endi print =============== step6 -sql select sum(tbcol) as b from $tb where ts < now + 4m interval(1m) +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select sum(tbcol) as b from $tb where ts <= $ms interval(1m) print ===> $data11 if $data11 != 1 then return -1 @@ -96,7 +104,10 @@ if $data00 != 1900 then endi print =============== step8 -sql select sum(tbcol) as c from $mt where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select sum(tbcol) as c from $mt where ts <= $ms print ===> $data00 if $data00 != 100 then return -1 @@ -108,7 +119,10 @@ if $data00 != 950 then return -1 endi -sql select sum(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select sum(tbcol) as c from $mt where tgcol < 5 and ts <= $ms print ===> $data00 if $data00 != 50 then return -1 @@ -139,8 +153,11 @@ if $rows != $tbNum then endi print =============== step11 -sql select sum(tbcol) as b from $mt where ts < now + 4m interval(1d) group by tgcol -print select sum(tbcol) as b from $mt where ts < now + 4m interval(1d) group by tgcol +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select sum(tbcol) as b from $mt where ts <= $ms interval(1d) group by tgcol +print select sum(tbcol) as b from $mt where ts <= $ms interval(1d) group by tgcol print ===> $data01 if $data01 != 10 then return -1 diff --git a/tests/script/general/compute/top.sim b/tests/script/general/compute/top.sim index 14b3b328a07e46759a17e206f1f3bc5d733e1c16..e6bcd4a5cb0cfb928d8e322b80aa10d801fe76e5 100644 --- a/tests/script/general/compute/top.sim +++ b/tests/script/general/compute/top.sim @@ -31,8 +31,10 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw @@ -52,7 +54,10 @@ if $data01 != 19 then endi print =============== step3 -sql select top(tbcol, 1) from $tb where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select top(tbcol, 1) from $tb where ts <= $ms print ===> $data01 if $data01 != 4 then return -1 @@ -76,7 +81,10 @@ if $data11 != 19 then endi print =============== step6 -sql select top(tbcol, 2) as b from $tb where ts < now + 4m +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select top(tbcol, 2) as b from $tb where ts <= $ms print ===> $data01 $data11 if $data01 != 3 then return -1 diff --git a/tests/script/general/db/alter_option.sim b/tests/script/general/db/alter_option.sim index 49c75966ca12524e0ae80fcb58d7d5e710e78293..c8aa2480c509353ede3c6ce6269afa9e6efd62b5 100644 --- a/tests/script/general/db/alter_option.sim +++ b/tests/script/general/db/alter_option.sim @@ -218,7 +218,10 @@ if $data12_db != 1 then return -1 endi -sql_error alter database db wal 2 +sql alter database db wal 1 +sql alter database db wal 2 +sql alter database db wal 1 +sql alter database db wal 2 sql_error alter database db wal 0 sql_error alter database db wal 3 sql_error alter database db wal 4 @@ -226,11 +229,13 @@ sql_error alter database db wal -1 sql_error alter database db wal 1000 print ============== step fsync -sql_error alter database db fsync 2 -sql_error alter database db fsync 3 -sql_error alter database db fsync 4 +sql alter database db fsync 0 +sql alter database db fsync 1 +sql alter database db fsync 3600 +sql alter database db fsync 18000 +sql alter database db fsync 180000 +sql_error alter database db fsync 180001 sql_error alter database db fsync -1 -sql_error alter database db fsync 1000 print ============== step comp sql show databases diff --git a/tests/script/general/db/show_create_db.sim b/tests/script/general/db/show_create_db.sim new file mode 100644 index 0000000000000000000000000000000000000000..baa7b253e12154c5d320dd6d8411e223ce1cd4e2 --- /dev/null +++ b/tests/script/general/db/show_create_db.sim @@ -0,0 +1,32 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 0 + +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print =============== step2 +sql create database db +sql show create database db + +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql use db +sql show create database db + +if $rows != 1 then + return -1 +endi + +if $data00 != db then + return -1 +endi + +sql drop database db + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/db/show_create_table.sim b/tests/script/general/db/show_create_table.sim new file mode 100644 index 0000000000000000000000000000000000000000..83386387093a7c4f778bb5696eea6019fd4691fa --- /dev/null +++ b/tests/script/general/db/show_create_table.sim @@ -0,0 +1,87 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 0 + +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print ===============create three type table +sql create database db +sql use db +sql create table meters(ts timestamp, f binary(8)) tags(loc int, zone binary(8)) +sql create table t0 using meters tags(1,'ch') +sql create table normalTbl(ts timestamp, zone binary(8)) + +sql use db +sql show create table meters +if $rows != 1 then + return -1 +endi + +print ===============check sub table +sql show create table t0 +if $rows != 1 then + return -1 +endi +if $data00 == 't0' then + return -1 +endi + +print ===============check normal table + +sql show create table normalTbl +if $rows != 1 then + return -1 +endi + +if $data00 == 'normalTbl' then + return -1 +endi + +print ===============check super table +sql show create table meters +if $rows != 1 then + return -1 +endi + +if $data00 == 'meters' then + return -1 +endi + +print ===============check sub table with prefix + +sql show create table db.t0 +if $rows != 1 then + return -1 +endi + +if $data00 == 't0' then + return -1 +endi + +print ===============check normal table with prefix +sql show create table db.normalTbl +if $rows != 1 then + return -1 +endi + +if $data00 == 'normalTbl' then + return -1 +endi + + +print ===============check super table with prefix +sql show create table db.meters +if $rows != 1 then + return -1 +endi + +if $data00 == 'meters' then + return -1 +endi + +sql drop database db + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/http/chunked.sim b/tests/script/general/http/chunked.sim index 8673655d969392873b297c82e8ae4d394ac3b190..6592c761c6ccaea94f385ac72982115c775f01d7 100644 --- a/tests/script/general/http/chunked.sim +++ b/tests/script/general/http/chunked.sim @@ -3,7 +3,7 @@ sleep 3000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c http -v 1 -system sh/cfg.sh -n dnode1 -c maxSQLLength -v 7340032 +system sh/cfg.sh -n dnode1 -c maxSQLLength -v 340032 system sh/exec.sh -n dnode1 -s start sleep 3000 diff --git a/tests/script/general/http/gzip.sim b/tests/script/general/http/gzip.sim index 0289e337a66f7fbb52752ef51f00432d8f1c3ff6..9c77567abb9874459a2363a93cb62cb57cf02b1a 100644 --- a/tests/script/general/http/gzip.sim +++ b/tests/script/general/http/gzip.sim @@ -3,7 +3,7 @@ sleep 3000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c http -v 1 -system sh/cfg.sh -n dnode1 -c maxSQLLength -v 7340032 +system sh/cfg.sh -n dnode1 -c maxSQLLength -v 340032 system sh/exec.sh -n dnode1 -s start sleep 3000 @@ -18,10 +18,22 @@ sql use d1 sql create table table_rest (ts timestamp, i int) print sql length is 270KB restful d1 table_rest 1591072800 10000 gzip +restful d1 table_rest 1591172800 10000 gzip +restful d1 table_rest 1591272800 10000 gzip +restful d1 table_rest 1591372800 10000 gzip +restful d1 table_rest 1591472800 10000 gzip +restful d1 table_rest 1591572800 10000 gzip +restful d1 table_rest 1591672800 10000 gzip +restful d1 table_rest 1591772800 10000 gzip +restful d1 table_rest 1591872800 10000 gzip +restful d1 table_rest 1591972800 10000 gzip + sql select * from table_rest; print rows: $rows -if $rows != 10000 then +if $rows != 100000 then return -1 endi +system curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_rest' 127.0.0.1:7111/rest/sql --compressed + system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/http/restful_full.sim b/tests/script/general/http/restful_full.sim index a02140a4199054775c405ec3c6223faa2ef681e4..8d2f1a7c00304c42c91311ae703bcef97aa6ace0 100644 --- a/tests/script/general/http/restful_full.sim +++ b/tests/script/general/http/restful_full.sim @@ -119,7 +119,7 @@ endi system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' used1' 127.0.0.1:7111/rest/sql print 17-> $system_content -if $system_content != @{"status":"error","code":534,"desc":"Syntax errr in SQL"}@ then +if $system_content != @{"status":"error","code":534,"desc":"Syntax error in SQL"}@ then return -1 endi diff --git a/tests/script/general/insert/insert_drop.sim b/tests/script/general/insert/insert_drop.sim index 80c16ff8e4c0de45bbc6e43991a96b75b6c924d3..9b68e5a6a6c7e77fc0e591e4950500369a88a650 100644 --- a/tests/script/general/insert/insert_drop.sim +++ b/tests/script/general/insert/insert_drop.sim @@ -52,10 +52,10 @@ sleep 1000 sql use $db sql drop table tb5 - +$i = 0 while $i < 4 - $tbId = $i + $halfNum - $tb = $tbPrefix . $i + + $tb = tb . $i $x = 0 while $x < $rowNum $xs = $x * $delta diff --git a/tests/script/general/insert/query_block1_memory.sim b/tests/script/general/insert/query_block1_memory.sim index 83509ad5b0de17500f87591f5cb0a9c3a3c21438..bec9190f9b93044d4321b96d6604209cbc78daba 100644 --- a/tests/script/general/insert/query_block1_memory.sim +++ b/tests/script/general/insert/query_block1_memory.sim @@ -30,9 +30,11 @@ print =============== step 1 $x = $N $y = $N / 2 while $x > $y - $ms = $x . m + $z = $x * 60000 + $ms = 1601481600000 - $z + $xt = - . $x - sql insert into $tb values (now - $ms , -$x ) + sql insert into $tb values ($ms , -$x ) $x = $x - 1 endw @@ -45,8 +47,10 @@ endi $x = $N / 2 $y = $N while $x < $y - $ms = $x . m - sql insert into $tb values (now + $ms , $x ) + $z = $x * 60000 + $ms = 1601481600000 + $z + + sql insert into $tb values ($ms , $x ) $x = $x + 1 endw sql select * from $tb @@ -60,14 +64,14 @@ print =============== step 2 $N1 = $N + 1 $result1 = $N / 2 $result2 = $N -$step = $N1 . m - -$start1 = now- . $step -$start2 = now -$start3 = now+ . $step -$end1 = now- . $step -$end2 = now -$end3 = now+ . $step +$step = $N1 * 60000 + +$start1 = 1601481600000 - $step +$start2 = 1601481600000 +$start3 = 1601481600000 + $step +$end1 = 1601481600000 - $step +$end2 = 1601481600000 +$end3 = 1601481600000 + $step sql select * from $tb where ts < $start1 and ts > $end1 if $rows != 0 then diff --git a/tests/script/general/parser/col_arithmetic_operation.sim b/tests/script/general/parser/col_arithmetic_operation.sim index 132ecf43428cbb5d12abb1a991136f1cbb335a98..3208df95e446f5f06494617fa33a71a5f09ab828 100644 --- a/tests/script/general/parser/col_arithmetic_operation.sim +++ b/tests/script/general/parser/col_arithmetic_operation.sim @@ -91,4 +91,60 @@ endi sql_error select max(c2*2) from $tb sql_error select max(c1-c2) from $tb +print =====================> td-1764 +sql select sum(c1)/count(*), sum(c1) as b, count(*) as b from $stb interval(1y) +if $rows != 1 then + return -1 +endi + +if $data00 != @18-01-01 00:00:00.000@ then + return -1 +endi + +if $data01 != 2.250000000 then + return -1 +endi + +if $data02 != 225000 then + return -1 +endi + +sql select first(c1) - last(c1), first(c1) as b, last(c1) as b, min(c1) - max(c1), spread(c1) from ca_stb0 interval(1y) +if $rows != 1 then + return -1 +endi + +if $data00 != @18-01-01 00:00:00.000@ then + return -1 +endi + +if $data01 != -9.000000000 then + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data03 != 9 then + return -1 +endi + +if $data04 != -9.000000000 then + return -1 +endi + +if $data05 != 9.000000000 then + return -1 +endi + +sql_error select first(c1, c2) - last(c1, c2) from stb interval(1y) +sql_error select first(ts) - last(ts) from stb interval(1y) +sql_error select top(c1, 2) - last(c1) from stb; +sql_error select stddev(c1) - last(c1) from stb; +sql_error select diff(c1) - last(c1) from stb; +sql_error select first(c7) - last(c7) from stb; +sql_error select first(c8) - last(c8) from stb; +sql_error select first(c9) - last(c9) from stb; + system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/constCol.sim b/tests/script/general/parser/constCol.sim index 13b4455779933e65d53f2556eb7b4946578c074f..7ae496f1ac60ca7c4eb2b143f4d906c0c18e3726 100644 --- a/tests/script/general/parser/constCol.sim +++ b/tests/script/general/parser/constCol.sim @@ -353,4 +353,36 @@ sql_error select from t1 sql_error select abc from t1 sql_error select abc as tu from t1 +print ========================> td-1756 +sql_error select * from t1 where ts>now-1y +sql_error select * from t1 where ts>now-1n + +print ========================> td-1752 +sql select * from db.st2 where t2 < 200 and t2 is not null; +if $rows != 1 then + return -1 +endi + +if $data00 != @19-12-09 16:27:35.000@ then + return -1 +endi + +if $data01 != 2 then + return -1 +endi + +if $data02 != 1 then + return -1 +endi + +sql select * from db.st2 where t2 > 200 or t2 is null; +if $rows != 0 then + return -1 +endi + +sql select * from st2 where t2 < 200 and t2 is null; +if $rows != 0 then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/first_last_query.sim b/tests/script/general/parser/first_last_query.sim index 8127c1923015e130a85a98a50cd8d4bca23fedb3..d43cd528781cb900f239e4e7549da91ace2d0e5c 100644 --- a/tests/script/general/parser/first_last_query.sim +++ b/tests/script/general/parser/first_last_query.sim @@ -14,12 +14,14 @@ $i = 0 $db = $dbPrefix . $i $stb = $stbPrefix . $i +print use $db sql use $db ##### select first/last from table ## TBASE-331 print ====== select first/last from table $tb = $tbPrefix . 0 +print select first(*) from $tb sql select first(*) from $tb if $rows != 1 then return -1 @@ -58,6 +60,7 @@ if $data09 != NCHAR then return -1 endi +print select last(*) from $tb sql select last(*) from $tb if $rows != 1 then return -1 diff --git a/tests/script/general/parser/lastrow_query.sim b/tests/script/general/parser/lastrow_query.sim index e9d8ce413dd6a4683019f70f3801cf2cc702c00d..f81a48d5b2d61ddf829920201dd01f5dd1ee44ba 100644 --- a/tests/script/general/parser/lastrow_query.sim +++ b/tests/script/general/parser/lastrow_query.sim @@ -218,4 +218,10 @@ endi if $data04 != 123.981000000 then print expect 123.981000000, actual: $data04 return -1 +endi + +sql create table tu(ts timestamp, k int) +sql select last_row(*) from tu +if $row != 0 then + return -1 endi \ No newline at end of file diff --git a/tests/script/general/parser/tags_dynamically_specifiy.sim b/tests/script/general/parser/tags_dynamically_specifiy.sim index 0a5d5c971649abae07d149f1cc914eb096e638fa..07bf4d8dd1cae6b0b374b9b67b1dca58f218fb3f 100644 --- a/tests/script/general/parser/tags_dynamically_specifiy.sim +++ b/tests/script/general/parser/tags_dynamically_specifiy.sim @@ -96,5 +96,10 @@ if $rows != 14 then return -1 endi +print ===============================> td-1765 +sql create table m1(ts timestamp, k int) tags(a binary(4), b nchar(4)); +sql create table tm0 using m1 tags('abcd', 'abcd'); +sql_error alter table tm0 set tag b = 'abcd1'; +sql_error alter table tm0 set tag a = 'abcd1'; system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/topbot.sim b/tests/script/general/parser/topbot.sim index 5c575b61633d77521ef0c8b51b6e46aaf84447aa..c2b41888d739c559b24784c42ad040d54d7ae160 100644 --- a/tests/script/general/parser/topbot.sim +++ b/tests/script/general/parser/topbot.sim @@ -213,4 +213,53 @@ if $data01 != 5195.000000000 then return -1 endi +print =======================>td-1596 +sql create table t2(ts timestamp, k int) +sql insert into t2 values('2020-1-2 1:1:1', 1); +sql insert into t2 values('2020-2-2 1:1:1', 1); + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 1000 + +sql use db +sql select count(*), first(ts), last(ts) from t2 interval(1d); +if $rows != 2 then + return -1 +endi + +if $data00 != @20-01-02 00:00:00.000@ then + print expect 20-01-02 00:00:00.000, actual: $data00 + return -1 +endi + +if $data10 != @20-02-02 00:00:00.000@ then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data02 != @20-01-02 01:01:01.000@ then + return -1 +endi + +if $data12 != @20-02-02 01:01:01.000@ then + return -1 +endi + +if $data03 != @20-01-02 01:01:01.000@ then + return -1 +endi + +if $data13 != @20-02-02 01:01:01.000@ then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/union.sim b/tests/script/general/parser/union.sim index 9e178537a291a3ccd4ab93b9ae03a25e7e619faa..4af482bde073000d9f2ba098b469f8ec33d7f419 100644 --- a/tests/script/general/parser/union.sim +++ b/tests/script/general/parser/union.sim @@ -251,7 +251,7 @@ if $rows != 15 then endi # first subclause are empty -sql select count(*) as c from union_tb0 where ts>now+10y union all select sum(c1) as c from union_tb1; +sql select count(*) as c from union_tb0 where ts > now + 3650d union all select sum(c1) as c from union_tb1; if $rows != 1 then return -1 endi @@ -346,7 +346,7 @@ if $data91 != 99 then return -1 endi -#1111111111111111111111111111111111111111111111111 +#================================================================================================= # two aggregated functions for normal tables sql select sum(c1) as a from union_tb0 limit 1 union all select sum(c3) as a from union_tb1 limit 2; if $rows != 2 then diff --git a/tests/script/general/parser/where.sim b/tests/script/general/parser/where.sim index fb15fb6dbe0f641d9d94c284d29b3ae7fbcb0f94..5cac3f47235c1321d740e373d0f5828f076c31c7 100644 --- a/tests/script/general/parser/where.sim +++ b/tests/script/general/parser/where.sim @@ -33,7 +33,8 @@ while $i < $tbNum $x = 0 while $x < $rowNum - $ms = $x . m + $y = $x * 60000 + $ms = 1600099200000 + $y $c = $x / 100 $c = $c * 100 $c = $x - $c @@ -41,7 +42,7 @@ while $i < $tbNum $binary = $binary . ' $nchar = 'nchar . $c $nchar = $nchar . ' - sql insert into $tb values (now + $ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + sql insert into $tb values ($ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) $x = $x + 1 endw @@ -94,7 +95,11 @@ endi ## select specified columns +print select c1 from $mt sql select c1 from $mt + +print rows $rows +print totalNum $totalNum if $rows != $totalNum then return -1 endi @@ -234,6 +239,13 @@ if $data11 != @19-01-01 09:10:00.000@ then endi sql create table tb_where_NULL (ts timestamp, c1 float, c2 binary(10)) + +print ===================>td-1604 +sql_error insert into tb_where_NULL values(?, ?, ?) +sql_error insert into tb_where_NULL values(now, 1, ?) +sql_error insert into tb_where_NULL values(?, 1, '') +sql_error insert into tb_where_NULL values(now, ?, '12') + sql insert into tb_where_NULL values ('2019-01-01 09:00:00.000', 1, 'val1') sql insert into tb_where_NULL values ('2019-01-01 09:00:01.000', NULL, NULL) sql insert into tb_where_NULL values ('2019-01-01 09:00:02.000', 2, 'val2') @@ -288,7 +300,8 @@ while $i < 1 $x = 0 while $x < 10000 - $ms = $x . m + $y = $x * 60000 + $ms = 1601481600000 + $y $c = $x / 100 $c = $c * 100 $c = $x - $c @@ -296,7 +309,7 @@ while $i < 1 $binary = $binary . ' $nchar = 'nchar . $c $nchar = $nchar . ' - sql insert into $tb values (now + $ms , null , null , null , null , null , null , null , null , null ) + sql insert into $tb values ($ms , null , null , null , null , null , null , null , null , null ) $x = $x + 1 endw @@ -308,14 +321,27 @@ sleep 2000 system sh/exec.sh -n dnode1 -s start -sql select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter'); +sql_error select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter'); + +sql select * from wh_mt0 where c3 = '1' and tbname in ('test_null_filter'); if $row != 0 then return -1 endi -sql select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter'); -if $row != 0 then +sql select * from wh_mt0 where c3 = '1'; +if $row == 0 then return -1 endi +sql select * from wh_mt0 where c3 is null and tbname in ('test_null_filter'); +if $rows != 10000 then + return -1 +endi + +sql select * from wh_mt0 where c3 is not null and tbname in ('test_null_filter'); +if $rows != 0 then + return -1 +endi + + system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/stream/table_n.sim b/tests/script/general/stream/table_n.sim index d1b4a87a9ea641a8f4d58e0d9fc61bd9ac7c7477..a336772a9819ec54607265913eb65c26a2ec1a28 100644 --- a/tests/script/general/stream/table_n.sim +++ b/tests/script/general/stream/table_n.sim @@ -289,3 +289,5 @@ endi if $data09 != 20 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index adb22aa265a34b95f61f881984dedb007805a268..4e68d1566a76468b06115a80aace70871665c9cb 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -79,6 +79,7 @@ cd ../../../debug; make ./test.sh -f general/http/autocreate.sim ./test.sh -f general/http/chunked.sim +./test.sh -f general/http/gzip.sim ./test.sh -f general/http/restful.sim ./test.sh -f general/http/restful_insert.sim ./test.sh -f general/http/restful_limit.sim @@ -271,12 +272,14 @@ cd ../../../debug; make ./test.sh -f unique/db/replica_part.sim ./test.sh -f unique/dnode/alternativeRole.sim +./test.sh -f unique/dnode/simple.sim ./test.sh -f unique/dnode/balance1.sim ./test.sh -f unique/dnode/balance2.sim ./test.sh -f unique/dnode/balance3.sim ./test.sh -f unique/dnode/balancex.sim ./test.sh -f unique/dnode/offline1.sim ./test.sh -f unique/dnode/offline2.sim +./test.sh -f unique/dnode/reason.sim ./test.sh -f unique/dnode/remove1.sim ./test.sh -f unique/dnode/remove2.sim ./test.sh -f unique/dnode/vnode_clean.sim diff --git a/tests/script/jenkins/basic_1.txt b/tests/script/jenkins/basic_1.txt new file mode 100644 index 0000000000000000000000000000000000000000..765e7139163952c43569e596d8ca8cf27d583cf6 --- /dev/null +++ b/tests/script/jenkins/basic_1.txt @@ -0,0 +1,205 @@ +./test.sh -f general/alter/cached_schema_after_alter.sim +./test.sh -f general/alter/count.sim +./test.sh -f general/alter/dnode.sim +./test.sh -f general/alter/import.sim +./test.sh -f general/alter/insert1.sim +./test.sh -f general/alter/insert2.sim +./test.sh -f general/alter/metrics.sim +./test.sh -f general/alter/table.sim + +./test.sh -f general/cache/new_metrics.sim +./test.sh -f general/cache/restart_metrics.sim +./test.sh -f general/cache/restart_table.sim + +./test.sh -f general/connection/connection.sim + +./test.sh -f general/column/commit.sim +./test.sh -f general/column/metrics.sim +./test.sh -f general/column/table.sim + +./test.sh -f general/compress/commitlog.sim +./test.sh -f general/compress/compress.sim +./test.sh -f general/compress/compress2.sim +./test.sh -f general/compress/uncompress.sim + +./test.sh -f general/compute/avg.sim +./test.sh -f general/compute/bottom.sim +./test.sh -f general/compute/count.sim +./test.sh -f general/compute/diff.sim +./test.sh -f general/compute/diff2.sim +./test.sh -f general/compute/first.sim +./test.sh -f general/compute/interval.sim +./test.sh -f general/compute/last.sim +./test.sh -f general/compute/leastsquare.sim +./test.sh -f general/compute/max.sim +./test.sh -f general/compute/min.sim +./test.sh -f general/compute/null.sim +./test.sh -f general/compute/percentile.sim +./test.sh -f general/compute/stddev.sim +./test.sh -f general/compute/sum.sim +./test.sh -f general/compute/top.sim + +./test.sh -f general/db/alter_option.sim +./test.sh -f general/db/alter_tables_d2.sim +./test.sh -f general/db/alter_tables_v1.sim +./test.sh -f general/db/alter_tables_v4.sim +./test.sh -f general/db/alter_vgroups.sim +./test.sh -f general/db/basic.sim +./test.sh -f general/db/basic1.sim +./test.sh -f general/db/basic2.sim +./test.sh -f general/db/basic3.sim +./test.sh -f general/db/basic4.sim +./test.sh -f general/db/basic5.sim +./test.sh -f general/db/delete_reuse1.sim +./test.sh -f general/db/delete_reuse2.sim +./test.sh -f general/db/delete_reusevnode.sim +./test.sh -f general/db/delete_reusevnode2.sim +./test.sh -f general/db/delete_writing1.sim +./test.sh -f general/db/delete_writing2.sim +./test.sh -f general/db/delete.sim +./test.sh -f general/db/len.sim +./test.sh -f general/db/repeat.sim +./test.sh -f general/db/tables.sim +./test.sh -f general/db/vnodes.sim + +./test.sh -f general/field/2.sim +./test.sh -f general/field/3.sim +./test.sh -f general/field/4.sim +./test.sh -f general/field/5.sim +./test.sh -f general/field/6.sim +./test.sh -f general/field/bigint.sim +./test.sh -f general/field/binary.sim +./test.sh -f general/field/bool.sim +./test.sh -f general/field/single.sim +./test.sh -f general/field/smallint.sim +./test.sh -f general/field/tinyint.sim + +./test.sh -f general/http/autocreate.sim +./test.sh -f general/http/chunked.sim +./test.sh -f general/http/gzip.sim +./test.sh -f general/http/restful.sim +./test.sh -f general/http/restful_insert.sim +./test.sh -f general/http/restful_limit.sim +./test.sh -f general/http/restful_full.sim +./test.sh -f general/http/prepare.sim +./test.sh -f general/http/telegraf.sim +./test.sh -f general/http/grafana_bug.sim +./test.sh -f general/http/grafana.sim + +./test.sh -f general/import/basic.sim +./test.sh -f general/import/commit.sim +./test.sh -f general/import/large.sim +./test.sh -f general/import/replica1.sim + +./test.sh -f general/insert/basic.sim +./test.sh -f general/insert/insert_drop.sim +./test.sh -f general/insert/query_block1_memory.sim +./test.sh -f general/insert/query_block2_memory.sim +./test.sh -f general/insert/query_block1_file.sim +./test.sh -f general/insert/query_block2_file.sim +./test.sh -f general/insert/query_file_memory.sim +./test.sh -f general/insert/query_multi_file.sim +./test.sh -f general/insert/tcp.sim + +./test.sh -f general/parser/alter.sim +./test.sh -f general/parser/alter1.sim +./test.sh -f general/parser/alter_stable.sim +./test.sh -f general/parser/auto_create_tb.sim +./test.sh -f general/parser/auto_create_tb_drop_tb.sim +./test.sh -f general/parser/col_arithmetic_operation.sim +./test.sh -f general/parser/columnValue.sim +./test.sh -f general/parser/commit.sim +./test.sh -f general/parser/create_db.sim +./test.sh -f general/parser/create_mt.sim +./test.sh -f general/parser/create_tb.sim +./test.sh -f general/parser/dbtbnameValidate.sim +./test.sh -f general/parser/import_commit1.sim +./test.sh -f general/parser/import_commit2.sim +./test.sh -f general/parser/import_commit3.sim +./test.sh -f general/parser/insert_tb.sim +./test.sh -f general/parser/first_last.sim +./test.sh -f general/parser/lastrow.sim +./test.sh -f general/parser/nchar.sim +./test.sh -f general/parser/null_char.sim +./test.sh -f general/parser/single_row_in_tb.sim +./test.sh -f general/parser/select_from_cache_disk.sim +./test.sh -f general/parser/mixed_blocks.sim +./test.sh -f general/parser/selectResNum.sim +./test.sh -f general/parser/limit.sim +./test.sh -f general/parser/limit1.sim +./test.sh -f general/parser/limit1_tblocks100.sim +./test.sh -f general/parser/select_across_vnodes.sim +./test.sh -f general/parser/slimit1.sim +./test.sh -f general/parser/tbnameIn.sim +./test.sh -f general/parser/projection_limit_offset.sim +./test.sh -f general/parser/limit2.sim +./test.sh -f general/parser/fill.sim +./test.sh -f general/parser/fill_stb.sim +./test.sh -f general/parser/where.sim +./test.sh -f general/parser/slimit.sim +./test.sh -f general/parser/select_with_tags.sim +./test.sh -f general/parser/interp.sim +./test.sh -f general/parser/tags_dynamically_specifiy.sim +./test.sh -f general/parser/groupby.sim +./test.sh -f general/parser/set_tag_vals.sim +./test.sh -f general/parser/tags_filter.sim +./test.sh -f general/parser/slimit_alter_tags.sim +./test.sh -f general/parser/join.sim +./test.sh -f general/parser/join_multivnode.sim +./test.sh -f general/parser/binary_escapeCharacter.sim +./test.sh -f general/parser/repeatAlter.sim +./test.sh -f general/parser/union.sim +./test.sh -f general/parser/topbot.sim + +./test.sh -f general/stable/disk.sim +./test.sh -f general/stable/dnode3.sim +./test.sh -f general/stable/metrics.sim +./test.sh -f general/stable/refcount.sim +./test.sh -f general/stable/show.sim +./test.sh -f general/stable/values.sim +./test.sh -f general/stable/vnode3.sim + +./test.sh -f general/table/autocreate.sim +./test.sh -f general/table/basic1.sim +./test.sh -f general/table/basic2.sim +./test.sh -f general/table/basic3.sim +./test.sh -f general/table/bigint.sim +./test.sh -f general/table/binary.sim +./test.sh -f general/table/bool.sim +./test.sh -f general/table/column_name.sim +./test.sh -f general/table/column_num.sim +./test.sh -f general/table/column_value.sim +./test.sh -f general/table/column2.sim +./test.sh -f general/table/date.sim +./test.sh -f general/table/db.table.sim +./test.sh -f general/table/delete_reuse1.sim +./test.sh -f general/table/delete_reuse2.sim +./test.sh -f general/table/delete_writing.sim +./test.sh -f general/table/describe.sim +./test.sh -f general/table/double.sim +./test.sh -f general/table/fill.sim +./test.sh -f general/table/float.sim +./test.sh -f general/table/int.sim +./test.sh -f general/table/limit.sim +./test.sh -f general/table/smallint.sim +./test.sh -f general/table/table_len.sim +./test.sh -f general/table/table.sim +./test.sh -f general/table/tinyint.sim +./test.sh -f general/table/vgroup.sim +./test.sh -f unique/dnode/alternativeRole.sim +./test.sh -f unique/dnode/balance1.sim +./test.sh -f unique/dnode/balance2.sim +./test.sh -f unique/dnode/balance3.sim +./test.sh -f unique/dnode/balancex.sim +./test.sh -f unique/dnode/offline1.sim +./test.sh -f unique/dnode/offline2.sim +./test.sh -f unique/dnode/reason.sim +./test.sh -f unique/dnode/remove1.sim +./test.sh -f unique/dnode/remove2.sim +./test.sh -f unique/dnode/vnode_clean.sim + +./test.sh -f unique/http/admin.sim +./test.sh -f unique/http/opentsdb.sim + +./test.sh -f unique/import/replica2.sim +./test.sh -f unique/import/replica3.sim diff --git a/tests/script/jenkins/basic_2.txt b/tests/script/jenkins/basic_2.txt new file mode 100644 index 0000000000000000000000000000000000000000..014313fafe9c7974baa7205cca41492dedee213a --- /dev/null +++ b/tests/script/jenkins/basic_2.txt @@ -0,0 +1,90 @@ +cd ../../../debug; cmake .. +cd ../../../debug; make + +./test.sh -f general/tag/3.sim +./test.sh -f general/tag/4.sim +./test.sh -f general/tag/5.sim +./test.sh -f general/tag/6.sim +./test.sh -f general/tag/add.sim +./test.sh -f general/tag/bigint.sim +./test.sh -f general/tag/binary_binary.sim +./test.sh -f general/tag/binary.sim +./test.sh -f general/tag/bool_binary.sim +./test.sh -f general/tag/bool_int.sim +./test.sh -f general/tag/bool.sim +./test.sh -f general/tag/change.sim +./test.sh -f general/tag/column.sim +./test.sh -f general/tag/commit.sim +./test.sh -f general/tag/create.sim +./test.sh -f general/tag/delete.sim +./test.sh -f general/tag/double.sim +./test.sh -f general/tag/filter.sim +./test.sh -f general/tag/float.sim +./test.sh -f general/tag/int_binary.sim +./test.sh -f general/tag/int_float.sim +./test.sh -f general/tag/int.sim +./test.sh -f general/tag/set.sim +./test.sh -f general/tag/smallint.sim +./test.sh -f general/tag/tinyint.sim + +./test.sh -f general/user/authority.sim +./test.sh -f general/user/monitor.sim +./test.sh -f general/user/pass_alter.sim +./test.sh -f general/user/pass_len.sim +./test.sh -f general/user/user_create.sim +./test.sh -f general/user/user_len.sim + +./test.sh -f general/vector/metrics_field.sim +./test.sh -f general/vector/metrics_mix.sim +./test.sh -f general/vector/metrics_query.sim +./test.sh -f general/vector/metrics_tag.sim +./test.sh -f general/vector/metrics_time.sim +./test.sh -f general/vector/multi.sim +./test.sh -f general/vector/single.sim +./test.sh -f general/vector/table_field.sim +./test.sh -f general/vector/table_mix.sim +./test.sh -f general/vector/table_query.sim +./test.sh -f general/vector/table_time.sim + +./test.sh -f unique/account/account_create.sim +./test.sh -f unique/account/account_delete.sim +./test.sh -f unique/account/account_len.sim +./test.sh -f unique/account/authority.sim +./test.sh -f unique/account/basic.sim +./test.sh -f unique/account/paras.sim +./test.sh -f unique/account/pass_alter.sim +./test.sh -f unique/account/pass_len.sim +./test.sh -f unique/account/usage.sim +./test.sh -f unique/account/user_create.sim +./test.sh -f unique/account/user_len.sim + +./test.sh -f unique/big/balance.sim +./test.sh -f unique/big/maxvnodes.sim +./test.sh -f unique/big/tcp.sim + +./test.sh -f unique/cluster/alter.sim +./test.sh -f unique/cluster/balance1.sim +./test.sh -f unique/cluster/balance2.sim +./test.sh -f unique/cluster/balance3.sim +./test.sh -f unique/cluster/cache.sim +./test.sh -f unique/cluster/vgroup100.sim + +./test.sh -f unique/column/replica3.sim + +./test.sh -f unique/db/commit.sim +./test.sh -f unique/db/delete.sim +./test.sh -f unique/db/delete_part.sim +./test.sh -f unique/db/replica_add12.sim +./test.sh -f unique/db/replica_add13.sim +./test.sh -f unique/db/replica_add23.sim +./test.sh -f unique/db/replica_reduce21.sim +./test.sh -f unique/db/replica_reduce32.sim +./test.sh -f unique/db/replica_reduce31.sim +./test.sh -f unique/db/replica_part.sim + +./test.sh -f unique/vnode/many.sim +./test.sh -f unique/vnode/replica2_basic2.sim +./test.sh -f unique/vnode/replica2_repeat.sim +./test.sh -f unique/vnode/replica3_basic.sim +./test.sh -f unique/vnode/replica3_repeat.sim +./test.sh -f unique/vnode/replica3_vgroup.sim \ No newline at end of file diff --git a/tests/script/jenkins/basic_3.txt b/tests/script/jenkins/basic_3.txt new file mode 100644 index 0000000000000000000000000000000000000000..83b10a371cbc354acc079a6307fe0dbee27e3533 --- /dev/null +++ b/tests/script/jenkins/basic_3.txt @@ -0,0 +1,81 @@ + +./test.sh -f unique/stable/balance_replica1.sim +./test.sh -f unique/stable/dnode2_stop.sim +./test.sh -f unique/stable/dnode2.sim +./test.sh -f unique/stable/dnode3.sim +./test.sh -f unique/stable/replica2_dnode4.sim +./test.sh -f unique/stable/replica2_vnode3.sim +./test.sh -f unique/stable/replica3_dnode6.sim +./test.sh -f unique/stable/replica3_vnode3.sim + +./test.sh -f unique/mnode/mgmt20.sim +./test.sh -f unique/mnode/mgmt21.sim +./test.sh -f unique/mnode/mgmt22.sim +./test.sh -f unique/mnode/mgmt23.sim +./test.sh -f unique/mnode/mgmt24.sim +#./test.sh -f unique/mnode/mgmt25.sim +#./test.sh -f unique/mnode/mgmt26.sim +./test.sh -f unique/mnode/mgmt33.sim +./test.sh -f unique/mnode/mgmt34.sim +./test.sh -f unique/mnode/mgmtr2.sim + + + +./test.sh -f general/parser/stream_on_sys.sim +./test.sh -f general/stream/metrics_del.sim +./test.sh -f general/stream/metrics_n.sim +./test.sh -f general/stream/metrics_replica1_vnoden.sim +./test.sh -f general/stream/restart_stream.sim +./test.sh -f general/stream/stream_3.sim +./test.sh -f general/stream/stream_restart.sim +./test.sh -f general/stream/table_1.sim +./test.sh -f general/stream/table_del.sim +./test.sh -f general/stream/table_n.sim +./test.sh -f general/stream/table_replica1_vnoden.sim + +./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim +#./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim +./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim +./test.sh -f unique/arbitrator/dn3_mn1_multiCreateDropTable.sim +#./test.sh -f unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim +#./test.sh -f unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim +./test.sh -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim +./test.sh -f unique/arbitrator/dn3_mn1_replica_change.sim +#./test.sh -f unique/arbitrator/dn3_mn1_stopDnode_timeout.sim +# lower the priority while file corruption +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_change.sim +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim +./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim +./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim +./test.sh -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim +./test.sh -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim +./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim +./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim +./test.sh -f unique/arbitrator/insert_duplicationTs.sim +./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim +./test.sh -f unique/arbitrator/offline_replica2_alterTag_online.sim +./test.sh -f unique/arbitrator/offline_replica2_createTable_online.sim +./test.sh -f unique/arbitrator/offline_replica2_dropDb_online.sim +./test.sh -f unique/arbitrator/offline_replica2_dropTable_online.sim +./test.sh -f unique/arbitrator/offline_replica3_alterTable_online.sim +./test.sh -f unique/arbitrator/offline_replica3_alterTag_online.sim +./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim +./test.sh -f unique/arbitrator/offline_replica3_dropDb_online.sim +./test.sh -f unique/arbitrator/offline_replica3_dropTable_online.sim +./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim +./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim +./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim + +./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim +./test.sh -f unique/arbitrator/sync_replica2_dropTable.sim +./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim +./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim +./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim +./test.sh -f unique/arbitrator/sync_replica3_dropTable.sim + +./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim +./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim +./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim +./test.sh -f unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index 0d444a5a6ed25329b857422cd8eb8bd06af87530..e26778e86b9876ab6e6f47f4b41207ea35cafbf5 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -111,23 +111,24 @@ echo "serverPort ${NODE}" >> $TAOS_CFG echo "dataDir $DATA_DIR" >> $TAOS_CFG echo "logDir $LOG_DIR" >> $TAOS_CFG echo "debugFlag 0" >> $TAOS_CFG -echo "mDebugFlag 135" >> $TAOS_CFG -echo "sdbDebugFlag 135" >> $TAOS_CFG -echo "dDebugFlag 135" >> $TAOS_CFG -echo "vDebugFlag 135" >> $TAOS_CFG -echo "tsdbDebugFlag 135" >> $TAOS_CFG -echo "cDebugFlag 135" >> $TAOS_CFG -echo "jnidebugFlag 135" >> $TAOS_CFG -echo "odbcdebugFlag 135" >> $TAOS_CFG -echo "httpDebugFlag 135" >> $TAOS_CFG -echo "monitorDebugFlag 135" >> $TAOS_CFG -echo "mqttDebugFlag 135" >> $TAOS_CFG -echo "qdebugFlag 135" >> $TAOS_CFG -echo "rpcDebugFlag 135" >> $TAOS_CFG +echo "mDebugFlag 143" >> $TAOS_CFG +echo "sdbDebugFlag 143" >> $TAOS_CFG +echo "dDebugFlag 143" >> $TAOS_CFG +echo "vDebugFlag 143" >> $TAOS_CFG +echo "tsdbDebugFlag 143" >> $TAOS_CFG +echo "cDebugFlag 143" >> $TAOS_CFG +echo "jnidebugFlag 143" >> $TAOS_CFG +echo "odbcdebugFlag 143" >> $TAOS_CFG +echo "httpDebugFlag 143" >> $TAOS_CFG +echo "monitorDebugFlag 143" >> $TAOS_CFG +echo "mqttDebugFlag 143" >> $TAOS_CFG +echo "qdebugFlag 143" >> $TAOS_CFG +echo "rpcDebugFlag 143" >> $TAOS_CFG echo "tmrDebugFlag 131" >> $TAOS_CFG -echo "udebugFlag 135" >> $TAOS_CFG -echo "sdebugFlag 135" >> $TAOS_CFG -echo "wdebugFlag 135" >> $TAOS_CFG +echo "udebugFlag 143" >> $TAOS_CFG +echo "sdebugFlag 143" >> $TAOS_CFG +echo "wdebugFlag 143" >> $TAOS_CFG +echo "cqdebugFlag 143" >> $TAOS_CFG echo "monitor 0" >> $TAOS_CFG echo "monitorInterval 1" >> $TAOS_CFG echo "http 0" >> $TAOS_CFG diff --git a/tests/script/test.sh b/tests/script/test.sh index 96e4ffe689e5098b36ca9993eed66fd7ba9cacef..a68ac4736dc8e7c0fa3b458c722ea58e4c9aec8e 100755 --- a/tests/script/test.sh +++ b/tests/script/test.sh @@ -109,15 +109,10 @@ echo "dataDir $DATA_DIR" >> $TAOS_CFG echo "logDir $LOG_DIR" >> $TAOS_CFG echo "scriptDir ${CODE_DIR}/../script" >> $TAOS_CFG echo "numOfLogLines 100000000" >> $TAOS_CFG -echo "dDebugFlag 135" >> $TAOS_CFG -echo "mDebugFlag 135" >> $TAOS_CFG -echo "sdbDebugFlag 135" >> $TAOS_CFG -echo "rpcDebugFlag 135" >> $TAOS_CFG +echo "rpcDebugFlag 143" >> $TAOS_CFG echo "tmrDebugFlag 131" >> $TAOS_CFG -echo "cDebugFlag 135" >> $TAOS_CFG -echo "httpDebugFlag 135" >> $TAOS_CFG -echo "monitorDebugFlag 135" >> $TAOS_CFG -echo "udebugFlag 135" >> $TAOS_CFG +echo "cDebugFlag 143" >> $TAOS_CFG +echo "udebugFlag 143" >> $TAOS_CFG echo "tablemetakeeptimer 5" >> $TAOS_CFG echo "wal 0" >> $TAOS_CFG echo "asyncLog 0" >> $TAOS_CFG diff --git a/tests/script/tmp/prepare.sim b/tests/script/tmp/prepare.sim index 8b8f206233f9125362cb29c45817819488b67b6e..343c422e9ff772c10f22539fb012fbf38241f91d 100644 --- a/tests/script/tmp/prepare.sim +++ b/tests/script/tmp/prepare.sim @@ -34,11 +34,11 @@ system sh/cfg.sh -n dnode4 -c http -v 1 return # for crash_gen -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 10 system sh/cfg.sh -n dnode1 -c rpcMaxTime -v 101 system sh/cfg.sh -n dnode1 -c cache -v 2 system sh/cfg.sh -n dnode1 -c keep -v 36500 -system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 # for windows diff --git a/tests/script/unique/cluster/vgroup100.sim b/tests/script/unique/cluster/vgroup100.sim index cddb38cefdf9db50f6716056295f2378ecc70f3a..68a5bad6b32dc23c667900707d3e9027ac943077 100644 --- a/tests/script/unique/cluster/vgroup100.sim +++ b/tests/script/unique/cluster/vgroup100.sim @@ -27,7 +27,19 @@ system sh/exec.sh -n dnode2 -s start sql create dnode $hostname3 system sh/exec.sh -n dnode3 -s start -sleep 5000 +sleep 3000 + +$maxNum = 102 +$maxNum = 12 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + sql show mnodes $dnode1Role = $data2_1 $dnode2Role = $data2_2 @@ -37,14 +49,26 @@ print $dnode1Role print $dnode2Role print $dnode3Role +if $dnode1Role != master then + goto show2 +endi +if $dnode2Role != slave then + goto show2 +endi +if $dnode3Role != slave then + goto show2 +endi + print ============================== step3 $count = 2 -while $count < 102 +while $count < $maxNum $db = d . $count $tb = $db . .t + $tb2 = $db . .t2 sql create database $db replica 3 cache 1 blocks 3 sql create table $tb (ts timestamp, i int) sql insert into $tb values(now, 1) + sql create table $tb2 as select count(*) from $tb interval(10s) $count = $count + 1 print insert into $tb values(now, 1) ==> finished endw @@ -52,7 +76,7 @@ endw print ============================== step4 $count = 2 -while $count < 102 +while $count < $maxNum $db = d . $count $tb = $db . .t sql select * from $tb @@ -74,7 +98,7 @@ print ============================== step6 system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start -sleep 3000 +sleep 10000 print ============================== step7 @@ -110,7 +134,7 @@ show8: endi $count = 2 -while $count < 102 +while $count < $maxNum $db = d . $count $tb = $db . .t sql select * from $tb diff --git a/tests/script/unique/dnode/reason.sim b/tests/script/unique/dnode/reason.sim new file mode 100644 index 0000000000000000000000000000000000000000..ad61a81b9782cf3d52c65059100c879423ae4843 --- /dev/null +++ b/tests/script/unique/dnode/reason.sim @@ -0,0 +1,132 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect +sql create dnode $hostname2 + +sql show dnodes +print dnode1 off: $data7_1 +print dnode2 off: $data7_2 +if $data7_2 != @status not received@ then + return -1 +endi + +print ========== step2 +system sh/exec.sh -n dnode2 -s start +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode2 off: $data7_2 + +print ========== step3 +system sh/exec.sh -n dnode2 -s stop +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode2 off: $data7_2 +if $data7_2 != @status msg timeout@ then + return -1 +endi + +print ========== step4 +sql drop dnode $hostname2 +sleep 5000 +sql show dnodes +if $rows != 1 then + return -1 +endi + +print ========== step5 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname2 +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode2 off: $data7_3 +if $data7_3 != @dnodeId not match@ then + return -1 +endi + +print ========== step6 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 3 +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname4 + +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode4 off: $data7_4 +if $data7_4 != @mnEqualVn not match@ then + return -1 +endi + +print ========== step7 +system sh/deploy.sh -n dnode5 -i 5 +system sh/cfg.sh -n dnode5 -c statusInterval -v 3 +system sh/exec.sh -n dnode5 -s start +sql create dnode $hostname5 + +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode5 off: $data7_5 +if $data7_5 != @interval not match@ then + return -1 +endi + +print ========== step8 +system sh/deploy.sh -n dnode6 -i 6 +system sh/cfg.sh -n dnode6 -c balance -v 0 +system sh/exec.sh -n dnode6 -s start +sql create dnode $hostname6 + +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode6 off: $data7_6 +if $data7_6 != @balance not match@ then + return -1 +endi + +print ========== step9 +system sh/deploy.sh -n dnode7 -i 7 +system sh/cfg.sh -n dnode7 -c maxTablesPerVnode -v 3000 +system sh/exec.sh -n dnode7 -s start +sql create dnode $hostname7 + +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode7 off: $data7_7 +if $data7_7 != @maxTabPerVn not match@ then + return -1 +endi + +print ========== step10 +system sh/deploy.sh -n dnode8 -i 8 +system sh/cfg.sh -n dnode8 -c maxVgroupsPerDb -v 3 +system sh/exec.sh -n dnode8 -s start +sql create dnode $hostname8 + +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode8 off: $data7_8 +if $data7_8 != @maxVgPerDb not match@ then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/simple.sim b/tests/script/unique/dnode/simple.sim new file mode 100644 index 0000000000000000000000000000000000000000..014e2dd04f4e221dd036830eca95c50af03bd77e --- /dev/null +++ b/tests/script/unique/dnode/simple.sim @@ -0,0 +1,147 @@ +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 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +sql create database d1 replica 2 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 1 then + return -1 +endi +if $data2_3 != 1 then + return -1 +endi +if $data2_4 != null then + return -1 +endi + +print ========== step2 +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start +sleep 3000 + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 1 then + return -1 +endi +if $data2_3 != 1 then + return -1 +endi +if $data2_4 != 0 then + return -1 +endi + +print ========== step3 +sql drop dnode $hostname2 + +$x = 0 +show3: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + goto show3 +endi +if $data2_2 != null then + goto show3 +endi +if $data2_3 != 1 then + goto show3 +endi +if $data2_4 != 1 then + goto show3 +endi + +print ========== step4 +sql drop dnode $hostname3 + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 1 then + goto show4 +endi +if $data2_2 != null then + goto show4 +endi +if $data2_3 != null then + goto show4 +endi +if $data2_4 != 1 then + goto show4 +endi + +print ========== step5 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT diff --git a/tests/script/unique/mnode/mgmt21.sim b/tests/script/unique/mnode/mgmt21.sim index 53ad0eebe7cc1798647226452479db47d1476528..8409383309dbde5500b9719cd64fd74ca5e384b2 100644 --- a/tests/script/unique/mnode/mgmt21.sim +++ b/tests/script/unique/mnode/mgmt21.sim @@ -26,11 +26,11 @@ $x = 0 show2: $x = $x + 1 sleep 2000 - if $x == 10 then + if $x == 5 then return -1 endi -sql show mnodes +sql show mnodes -x show2 print dnode1 ==> $data2_1 print dnode2 ==> $data2_2 if $data2_1 != master then diff --git a/tests/script/unique/mnode/mgmt23.sim b/tests/script/unique/mnode/mgmt23.sim index 7e60ab908b81dd0ad88e550b4b487123e8204b2d..d1820ef8c6a886fdbc55bda6d7b9e79a0ea51e1b 100644 --- a/tests/script/unique/mnode/mgmt23.sim +++ b/tests/script/unique/mnode/mgmt23.sim @@ -65,7 +65,7 @@ endi print ============== step4 sql drop dnode $hostname2 -sleep 8000 +sleep 10000 sql show mnodes $dnode1Role = $data2_1 diff --git a/tests/test-all.sh b/tests/test-all.sh index 275c6b16773bb3df00271ea1628dad706a1f4252..e45dd15fedc999c08037544254f13f78607ee638 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -9,8 +9,9 @@ NC='\033[0m' function runSimCaseOneByOne { while read -r line; do - if [[ $line =~ ^run.* ]]; then - case=`echo $line | awk '{print $NF}'` + if [[ $line =~ ^./test.sh* ]]; then + case=`echo $line | grep sim$ |awk '{print $NF}'` + start_time=`date +%s` ./test.sh -f $case > /dev/null 2>&1 && \ echo -e "${GREEN}$case success${NC}" | tee -a out.log || \ @@ -54,7 +55,16 @@ if [ "$2" != "python" ]; then runSimCaseOneByOne regressionSuite.sim elif [ "$1" == "full" ]; then echo "### run TSIM full test ###" - runSimCaseOneByOne fullGeneralSuite.sim + runSimCaseOneByOne jenkins/basic.txt + elif [ "$1" == "b1" ]; then + echo "### run TSIM b1 test ###" + runSimCaseOneByOne jenkins/basic_1.txt + elif [ "$1" == "b2" ]; then + echo "### run TSIM b2 test ###" + runSimCaseOneByOne jenkins/basic_2.txt + elif [ "$1" == "b3" ]; then + echo "### run TSIM b3 test ###" + runSimCaseOneByOne jenkins/basic_3.txt elif [ "$1" == "smoke" ] || [ -z "$1" ]; then echo "### run TSIM smoke test ###" runSimCaseOneByOne basicSuite.sim @@ -111,6 +121,11 @@ if [ "$2" != "sim" ]; then elif [ "$1" == "full" ]; then echo "### run Python full test ###" runPyCaseOneByOne fulltest.sh + elif [ "$1" == "pytest" ]; then + echo "### run Python full test ###" + runPyCaseOneByOne fulltest.sh + elif [ "$1" == "b2" ] || [ "$1" == "b3" ]; then + exit $(($totalFailed + $totalPyFailed)) elif [ "$1" == "smoke" ] || [ -z "$1" ]; then echo "### run Python smoke test ###" runPyCaseOneByOne smoketest.sh diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt index ffab39d41c0170074687684c23dfdc9f57322d44..26aa20e647cc166ac991e64bc18511e9b504b335 100644 --- a/tests/test/c/CMakeLists.txt +++ b/tests/test/c/CMakeLists.txt @@ -37,10 +37,13 @@ IF (TD_LINUX) #add_executable(queryPerformance queryPerformance.c) #target_link_libraries(queryPerformance taos_static tutil common pthread) - add_executable(httpTest httpTest.c) - target_link_libraries(httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) + #add_executable(httpTest httpTest.c) + #target_link_libraries(httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) - add_executable(cacheTest cacheTest.c) - target_link_libraries(cacheTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) + #add_executable(cacheTest cacheTest.c) + #target_link_libraries(cacheTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) + + #add_executable(invalidTableId invalidTableId.c) + #target_link_libraries(invalidTableId taos_static tutil common pthread) ENDIF() diff --git a/tests/test/c/createNormalTable.c b/tests/test/c/createNormalTable.c index 18a648b9e18a9bcc76a273aea4059fb2ce9f7364..60253e2add1ebaa1e6c2c00b073cf13672789346 100644 --- a/tests/test/c/createNormalTable.c +++ b/tests/test/c/createNormalTable.c @@ -50,7 +50,9 @@ void createDbAndSTable(); int main(int argc, char *argv[]) { shellParseArgument(argc, argv); taos_init(); - createDbAndSTable(); + if (replica != 0) { + createDbAndSTable(); + } pPrint("%d threads are spawned to create table", numOfThreads); @@ -134,14 +136,31 @@ void *threadFunc(void *param) { int64_t startMs = taosGetTimestampMs(); - for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { - sprintf(qstr, "create table %s%d (ts timestamp, i int)", stableName, t); - TAOS_RES *pSql = taos_query(con, qstr); - code = taos_errno(pSql); - if (code != 0) { - pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + if (replica != 0) { + for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { + sprintf(qstr, "create table %s%d (ts timestamp, i int)", stableName, t); + TAOS_RES *pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + } + taos_free_result(pSql); + } + } else { + for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { + sprintf(qstr, "insert into %s%d values(now, 1)", stableName, t); + TAOS_RES *pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + if (code != TSDB_CODE_MND_INVALID_TABLE_NAME) { + pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + } + if (code == TSDB_CODE_VND_INVALID_VGROUP_ID) { + exit(0); + } + } + taos_free_result(pSql); } - taos_free_result(pSql); } float createTableSpeed = 0; diff --git a/tests/test/c/importPerTable.c b/tests/test/c/importPerTable.c index b4e8b6870342845ddcc75c2703fbe54119c423f8..68f78980509d5956f6fc177d7e940af5345b68a7 100644 --- a/tests/test/c/importPerTable.c +++ b/tests/test/c/importPerTable.c @@ -20,6 +20,7 @@ #include "ttimer.h" #include "tutil.h" #include "tglobal.h" +#include "osTime.h" #define MAX_RANDOM_POINTS 20000 #define GREEN "\033[1;32m" @@ -43,14 +44,16 @@ void createDbAndTable(); void insertData(); int32_t randomData[MAX_RANDOM_POINTS]; -int64_t rowsPerTable = 10000; +int64_t rowsPerTable = 1000000; int64_t pointsPerTable = 1; -int64_t numOfThreads = 1; -int64_t numOfTablesPerThread = 1; +int64_t numOfThreads = 10; +int64_t numOfTablesPerThread = 100; char dbName[32] = "db"; char stableName[64] = "st"; -int32_t cache = 16384; -int32_t tables = 1000; +int64_t totalUs = 0; +int64_t reqNum = 0; +int64_t maxUs = 0; +int64_t minUs = 100000000; int main(int argc, char *argv[]) { shellParseArgument(argc, argv); @@ -58,6 +61,38 @@ int main(int argc, char *argv[]) { taos_init(); createDbAndTable(); insertData(); + int64_t avgUs = totalUs / reqNum; + pError("%s totalUs:%ld, avgUs:%ld maxUs:%ld minUs:%ld reqNum:%ld %s\n", GREEN, totalUs, avgUs, maxUs, minUs, reqNum, NC); +} + +int32_t query(void *con, char *qstr) { + int64_t begin = taosGetTimestampUs(); + + TAOS_RES *pSql = taos_query(con, qstr); + int32_t code = taos_errno(pSql); + if (code != 0) { + pError("failed to exec sql:%s, code:%d reason:%s", qstr, taos_errno(con), taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + + int64_t us = taosGetTimestampUs() - begin; + maxUs = MAX(us, maxUs); + minUs = MIN(us, minUs); + atomic_add_fetch_64(&totalUs, us); + atomic_add_fetch_64(&reqNum, 1); + if (reqNum > 100000) { + int64_t avgUs = totalUs / reqNum; + if (us > avgUs * 100) { + pError("sql:%s", qstr); + pError("%s totalUs:%ld, avgUs:%ld maxUs:%ld minUs:%ld reqNum:%ld %s\n", GREEN, totalUs, avgUs, maxUs, minUs, + reqNum, NC); + taosMsleep(1000); + exit(0); + } + } + + return code; } void createDbAndTable() { @@ -79,14 +114,14 @@ void createDbAndTable() { exit(1); } - sprintf(qstr, "create database if not exists %s cache %d tables %d", dbName, cache, tables); - if (taos_query(con, qstr)) { + sprintf(qstr, "create database if not exists %s", dbName); + if (query(con, qstr)) { pError("failed to create database:%s, code:%d reason:%s", dbName, taos_errno(con), taos_errstr(con)); exit(0); } sprintf(qstr, "use %s", dbName); - if (taos_query(con, qstr)) { + if (query(con, qstr)) { pError("failed to use db, code:%d reason:%s", taos_errno(con), taos_errstr(con)); exit(0); } @@ -102,14 +137,14 @@ void createDbAndTable() { } sprintf(qstr + len, ") tags(t int)"); - if (taos_query(con, qstr)) { + if (query(con, qstr)) { pError("failed to create stable, code:%d reason:%s", taos_errno(con), taos_errstr(con)); exit(0); } for (int64_t t = 0; t < totalTables; ++t) { sprintf(qstr, "create table if not exists %s%ld using %s tags(%ld)", stableName, t, stableName, t); - if (taos_query(con, qstr)) { + if (query(con, qstr)) { pError("failed to create table %s%" PRId64 ", reason:%s", stableName, t, taos_errstr(con)); exit(0); } @@ -122,7 +157,7 @@ void createDbAndTable() { } sprintf(qstr + len, ")"); - if (taos_query(con, qstr)) { + if (query(con, qstr)) { pError("failed to create table %s%ld, reason:%s", stableName, t, taos_errstr(con)); exit(0); } @@ -207,7 +242,7 @@ void *syncTest(void *param) { } sprintf(qstr, "use %s", pInfo->dbName); - taos_query(con, qstr); + query(con, qstr); gettimeofday(&systemTime, NULL); st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; @@ -229,7 +264,7 @@ void *syncTest(void *param) { } len += sprintf(sql + len, ")"); if (len > maxBytes) { - if (taos_query(con, qstr)) { + if (query(con, qstr)) { pError("thread:%d, failed to import table:%s%ld row:%ld, reason:%s", pInfo->threadIndex, pInfo->stableName, table, row, taos_errstr(con)); } @@ -246,7 +281,7 @@ void *syncTest(void *param) { } if (len != strlen(inserStr)) { - taos_query(con, qstr); + query(con, qstr); } gettimeofday(&systemTime, NULL); @@ -284,10 +319,6 @@ void printHelp() { printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of threads to be used, default is ", numOfThreads); printf("%s%s\n", indent, "-n"); printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of tables per thread, default is ", numOfTablesPerThread); - printf("%s%s\n", indent, "-tables"); - printf("%s%s%s%d\n", indent, indent, "Database parameters tables, default is ", tables); - printf("%s%s\n", indent, "-cache"); - printf("%s%s%s%d\n", indent, indent, "Database parameters cache, default is ", cache); exit(EXIT_SUCCESS); } @@ -311,10 +342,6 @@ void shellParseArgument(int argc, char *argv[]) { numOfThreads = atoi(argv[++i]); } else if (strcmp(argv[i], "-n") == 0) { numOfTablesPerThread = atoi(argv[++i]); - } else if (strcmp(argv[i], "-tables") == 0) { - tables = atoi(argv[++i]); - } else if (strcmp(argv[i], "-cache") == 0) { - cache = atoi(argv[++i]); } else { } } @@ -323,8 +350,6 @@ void shellParseArgument(int argc, char *argv[]) { pPrint("%spointsPerTable:%" PRId64 "%s", GREEN, pointsPerTable, NC); pPrint("%snumOfThreads:%" PRId64 "%s", GREEN, numOfThreads, NC); pPrint("%snumOfTablesPerThread:%" PRId64 "%s", GREEN, numOfTablesPerThread, NC); - pPrint("%scache:%d%s", GREEN, cache, NC); - pPrint("%stables:%d%s", GREEN, tables, NC); pPrint("%sdbName:%s%s", GREEN, dbName, NC); pPrint("%stableName:%s%s", GREEN, stableName, NC); pPrint("%sstart to run%s", GREEN, NC); diff --git a/tests/test/c/invalidTableId.c b/tests/test/c/invalidTableId.c new file mode 100644 index 0000000000000000000000000000000000000000..581387a4ee9dc8d72538e175d674bd0fbe83072c --- /dev/null +++ b/tests/test/c/invalidTableId.c @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "taoserror.h" +#include "taos.h" +#include "tulog.h" +#include "tutil.h" +#include "tglobal.h" +#include "hash.h" + +#define MAX_RANDOM_POINTS 20000 +#define GREEN "\033[1;32m" +#define NC "\033[0m" + +#define MAX_DB_NUM 100 +void * con; +char dbNames[MAX_DB_NUM][48]; +int32_t dbNum = 0; +void parseArgument(int argc, char *argv[]); +void connDb(); +void getDbNames(); +void printDbNames(); +void queryTables(char *dbName); +void checkTables(char *dbName); + +int main(int argc, char *argv[]) { + parseArgument(argc, argv); + taos_init(); + connDb(); + getDbNames(); + printDbNames(); + for (int dbIndex = 0; dbIndex < dbNum; ++dbIndex) { + queryTables((char*)(dbNames[dbIndex])); + checkTables((char*)(dbNames[dbIndex])); + } + + pPrint("all %d database is checked", dbNum); +} + +void connDb() { + con = taos_connect(NULL, "root", "taosdata", NULL, 0); + if (con == NULL) { + pError("failed to connect to DB, reason:%s", taos_errstr(con)); + exit(0); + } +} + +void getDbNames() { + if (dbNum != 0) return; + + char * qstr = "show databases"; + TAOS_RES *result = taos_query(con, qstr); + int32_t code = taos_errno(result); + if (result == NULL || code != 0) { + pError("failed to exec sql:%s, code:0x%x reason:%s", qstr, code & 0XFFFF, tstrerror(code)); + exit(0); + } + + TAOS_ROW row; + int num_fields = taos_num_fields(result); + if (num_fields <= 0) return; + while ((row = taos_fetch_row(result))) { + char * dbName = (char*)dbNames[dbNum]; + int32_t *length = taos_fetch_lengths(result); + int len = length[0]; + memcpy(dbName, (char *)row[0], len); + dbName[len] = 0; + dbNum++; + } + + taos_free_result(result); +} + +void printDbNames() { + for (int dbIndex = 0; dbIndex < dbNum; ++dbIndex) { + pPrint("db:%d %s", dbIndex, dbNames[dbIndex]); + } +} + +void queryTables(char *dbName) { + char qstr[1024]; + char fileName[1024]; + char ts[35] = {0}; + int32_t precision = 1000; + + sprintf(qstr, "show %s.tables", dbName); + sprintf(fileName, "%s_tables.txt", dbName); + + TAOS_RES *result = taos_query(con, qstr); + int32_t code = taos_errno(result); + if (result == NULL || code != 0) { + pError("failed to exec sql:%s, code:0x%x reason:%s", qstr, code & 0XFFFF, tstrerror(code)); + exit(0); + } + + FILE *fp = fopen(fileName, "w"); + if (!fp) return; + + TAOS_ROW row; + int32_t rows = 0; + while ((row = taos_fetch_row(result))) { + char tableName[256] = {0}; + int32_t *length = taos_fetch_lengths(result); + int len = length[0]; + memcpy(tableName, (char *)row[0], len); + tableName[len] = 0; + + int64_t t = *((int64_t *)row[1]); + time_t tt = t / 1000; + struct tm *ptm = localtime(&tt); + int32_t tl = (int32_t)strftime(ts, 35, "%Y-%m-%d %H:%M:%S", ptm); + snprintf(ts + tl, 5, ".%03ld", t % precision); + + // fprintf(fp, "%s %s\n", tableName, ts); + fprintf(fp, "%s.%s\n", dbName, tableName); + rows++; + } + + taos_free_result(result); + fclose(fp); + pPrint("db:%s has %d tables, write to %s", dbName, rows, fileName); +} + +void checkTables(char *dbName) { + char qstr[1024]; + char fileName1[1024]; + char fileName2[1024]; + + sprintf(qstr, "show %s.tables", dbName); + sprintf(fileName1, "%s_tables.txt", dbName); + sprintf(fileName2, "%s_count.txt", dbName); + + FILE *fp1 = fopen(fileName1, "r"); + if (!fp1) return; + + FILE *fp2 = fopen(fileName2, "w"); + if (!fp2) return; + + int32_t successRows = 0; + int32_t failedRows = 0; + char tbName[256]; + while (!feof(fp1)) { + int size = fscanf(fp1, "%s", tbName); + if (size <= 0) { + break; + } + + sprintf(qstr, "select count(*) from %s", tbName); + TAOS_RES *result = taos_query(con, qstr); + int32_t code = taos_errno(result); + if (result == NULL || code != 0) { + pError("failed to exec sql:%s, code:0x%x reason:%s", qstr, code & 0XFFFF, tstrerror(code)); + fprintf(fp2, "%s failed to exec sql:%s, code:0x%x reason:%s", tbName, qstr, code & 0XFFFF, tstrerror(code)); + taos_free_result(result); + failedRows++; + continue; + } + + TAOS_ROW row; + int64_t count = 0; + while ((row = taos_fetch_row(result))) { + count = *((int64_t *)row[0]); + } + fprintf(fp2, "%s %" PRId64 "\n", tbName, count); + + successRows++; + if (successRows % 1000 == 0) { + pPrint("query %d tables", successRows); + } + taos_free_result(result); + } + + fclose(fp1); + fclose(fp2); + pPrint("db:%s query tables, success:%d failed:%d write to %s", dbName, successRows, failedRows, fileName2); +} + +void printHelp() { + char indent[10] = " "; + printf("Used to checkTables\n"); + + printf("%s%s\n", indent, "-c"); + printf("%s%s%s%s\n", indent, indent, "Configuration directory, default is ", configDir); + printf("%s%s\n", indent, "-d"); + printf("%s%s%s%s\n", indent, indent, "The name of the database to be checked, default is ", "all"); + + exit(EXIT_SUCCESS); +} + +void parseArgument(int argc, char *argv[]) { + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + printHelp(); + exit(0); + } else if (strcmp(argv[i], "-d") == 0) { + strcpy(dbNames[0], argv[++i]); + dbNum++; + } else if (strcmp(argv[i], "-c") == 0) { + strcpy(configDir, argv[++i]); + } else { + } + } + + pPrint("%s configDir:%s %s", GREEN, configDir, NC); + pPrint("%s start to checkTables %s", GREEN, NC); +} diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index 463dc33c7cc4f73e888fe5583b8311102fdd41b1..7f786dfaa9de5f6a93d3a181ddd53e37e8694310 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -739,36 +739,22 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) { ((((int)(*((char *)row[i]))) == 1) ? "1" : "0")); break; case TSDB_DATA_TYPE_TINYINT: - sprintf(value, "%d", (int)(*((char *)row[i]))); + sprintf(value, "%d", *((int8_t *)row[i])); break; case TSDB_DATA_TYPE_SMALLINT: - sprintf(value, "%d", (int)(*((short *)row[i]))); + sprintf(value, "%d", *((int16_t *)row[i])); break; case TSDB_DATA_TYPE_INT: - sprintf(value, "%d", *((int *)row[i])); + sprintf(value, "%d", *((int32_t *)row[i])); break; case TSDB_DATA_TYPE_BIGINT: sprintf(value, "%" PRId64, *((int64_t *)row[i])); break; - case TSDB_DATA_TYPE_FLOAT:{ -#ifdef _TD_ARM_32_ - float fv = 0; - *(int32_t*)(&fv) = *(int32_t*)row[i]; - sprintf(value, "%.5f", fv); -#else - sprintf(value, "%.5f", *((float *)row[i])); -#endif - } + case TSDB_DATA_TYPE_FLOAT: + sprintf(value, "%.5f", GET_FLOAT_VAL(row[i])); break; - case TSDB_DATA_TYPE_DOUBLE: { -#ifdef _TD_ARM_32_ - double dv = 0; - *(int64_t*)(&dv) = *(int64_t*)row[i]; - sprintf(value, "%.9lf", dv); -#else - sprintf(value, "%.9lf", *((double *)row[i])); -#endif - } + case TSDB_DATA_TYPE_DOUBLE: + sprintf(value, "%.9lf", GET_DOUBLE_VAL(row[i])); break; case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: