提交 a7ae8256 编写于 作者: wmmhello's avatar wmmhello

Merge branch 'develop' into feature/TD-11208-new

......@@ -20,3 +20,6 @@
path = tests
url = https://github.com/taosdata/tests
branch = develop
[submodule "examples/rust"]
path = examples/rust
url = https://github.com/songtianyi/tdengine-rust-bindings.git
......@@ -277,7 +277,7 @@ If TDengine shell connects the server successfully, welcome messages and version
## Install TDengine by apt-get
If you use Debian or Ubuntu system, you can use 'apt-get' command to intall TDengine from official repository. Please use following commands to setup:
If you use Debian or Ubuntu system, you can use 'apt-get' command to install TDengine from official repository. Please use following commands to setup:
```
wget -qO - http://repos.taosdata.com/tdengine.key | sudo apt-key add -
......
......@@ -2,7 +2,10 @@
## <a class="anchor" id="install"></a>快捷安装
TDengine 软件分为服务器、客户端和报警模块三部分,目前 2.0 版服务器仅能在 Linux 系统上安装和运行,后续会支持 Windows、Mac OS 等系统。客户端可以在 Windows 或 Linux 上安装和运行。任何 OS 的应用也可以选择 RESTful 接口连接服务器 taosd,其中 2.4 之后版本默认使用单独运行的独立组件 taosAdapter 提供 http 服务,之前版本使用内置 http 服务。CPU 支持 X64/ARM64/MIPS64/Alpha64,后续会支持 ARM32、RISC-V 等 CPU 架构。用户可根据需求选择通过 [源码](https://www.taosdata.com/cn/getting-started/#通过源码安装) 或者 [安装包](https://www.taosdata.com/cn/getting-started/#通过安装包安装) 来安装。
TDengine 软件分为服务器、客户端,目前 2.0 版服务器仅能在 Linux 系统上安装和运行,后续会支持 Windows、Mac OS 等系统。客户端可以在 Windows 或 Linux 上安装和运行。任何 OS 的应用也可以选择 RESTful 接口连接服务器 taosd,其中 2.4 之后版本默认使用单独运行的独立组件 taosAdapter 提供 http 服务,之前版本使用内置 http 服务。支持 X64/ARM64/MIPS64/Alpha64,后续会支持 ARM32、RISC-V 等 CPU 架构。用户可根据需求选择通过 [源码](https://www.taosdata.com/getting-started/#source-install) 或者 [安装包](https://www.taosdata.com/getting-started/#package-install) 来安装。
* 查看完整的Release notes,请点击[这里](https://github.com/taosdata/TDengine/releases)
* 下载其他组件、最新beta版及之前版本的安装包,请点击[这里](https://www.taosdata.com/cn/all-downloads/)
### <a class="anchor" id="source-install"></a>通过源码安装
......@@ -20,13 +23,38 @@ docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengin
### <a class="anchor" id="package-install"></a>通过安装包安装
TDengine 的安装非常简单,从下载到安装成功仅仅只要几秒钟。服务端安装包包含客户端和连接器,我们提供三种安装包,您可以根据需要选择
TDengine 的安装非常简单,从下载到安装成功仅仅只要几秒钟。为方便使用,标准的服务端安装包包含了客户端程序、各种编程语言的连接器和示例代码;如果您只需要用到服务端程序和客户端连接的 C/C++ 语言支持,那么也可以仅下载 lite 版本的安装包。在安装包格式上,我们提供 rpm、deb、tar.gz 三种,以方便在特定操作系统上使用。版本还分稳定版和Beta版,Beta版含有更多新功能,正式上线或测试,建议安装稳定版。您可以根据需要选择下载
安装包下载在 [这里](https://www.taosdata.com/cn/getting-started/#通过安装包安装)
<ul id="server-packageList" class="package-list"></ul>
具体的安装过程,请参见 [TDengine 多种安装包的安装和卸载](https://www.taosdata.com/blog/2019/08/09/566.html) 以及 [视频教程](https://www.taosdata.com/blog/2020/11/11/1941.html)
## <a class="anchor" id="taosBenchmark"></a> taosBenchmark 详细功能列表
taosBenchmark (曾命名 taosdemo)命令本身带有很多选项,配置表的数目、记录条数等等,请执行 `taosBenchmark --help` 详细列出。您可以设置不同参数进行体验。
taosBenchmark 详细使用方法请参照 [如何使用taosBenchmark对TDengine进行性能测试](https://www.taosdata.com/2021/10/09/3111.html)
## 客户端
如果客户端和服务端运行在不同的电脑上,可以单独安装客户端。下载时请注意,所选择的客户端版本号应该和在上面下载的服务端版本号精确匹配。Linux 和 Windows 安装包如下(其中 lite 版本的安装包仅带有 C/C++ 语言的连接支持,而标准版本的安装包还包含 Java、Python、Go、Node.js 等编程语言的连接器支持和示例代码):
<ul id="client-packagelist" class="package-list"></ul>
## taosTools
taosTools 是多个用于 TDengine 的辅助工具软件集合。
推荐下载 deb 或 rpm 安装包,方便安装依赖软件。如果使用 tar.gz 格式安装包,需要自行安装依赖包。其中:
* Debian/Ubuntu 系统需要安装 libjansson4 和 libsnappy1v5
* CentOS/RHEL 系统需要安装 jansson 和 snappy
以及 TDengine server 或 TDengine client 安装包
### 使用 apt-get 安装
<ul id="taos-tools" class="package-list"></ul>
## 使用 apt-get 安装
如果使用 Debian 或 Ubuntu 系统,也可以使用 apt-get 从官方仓库安装,设置方法为:
......@@ -181,15 +209,7 @@ taos> select avg(current), max(voltage), min(phase) from test.meters where group
```mysql
taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s);
```
## <a class="anchor" id="taosBenchmark"></a> taosBenchmark 详细功能列表
taosBenchmark (曾命名 taosdemo)命令本身带有很多选项,配置表的数目、记录条数等等,请执行 `taosBenchmark --help` 详细列出。您可以设置不同参数进行体验。
taosBenchmark 详细使用方法请参照 [如何使用taosBenchmark对TDengine进行性能测试](https://www.taosdata.com/2021/10/09/3111.html)
## 客户端
如果客户端和服务端运行在不同的电脑上,可以单独安装客户端。Linux 和 Windows 安装包可以在 [这里](https://www.taosdata.com/cn/getting-started/#客户端) 下载。
## <a class="anchor" id="platforms"></a>支持平台列表
......@@ -231,3 +251,4 @@ taosBenchmark 详细使用方法请参照 [如何使用taosBenchmark对TDengine
请跳转到 [连接器](https://www.taosdata.com/cn/documentation/connector) 查看更详细的信息。
<script src="/wp-includes/js/quick-start.js?v=1"></script>
......@@ -791,6 +791,7 @@ rmtaos
2. 数据里有转义字符
1. 遇到上面定义的转义字符会转义(%和_见下面说明),如果没有匹配的转义字符会忽略掉转义符\。
2. 对于%和_,因为在like里这两个字符是通配符,所以在模式匹配like里用`\%`%和`\_`表示字符里本身的%和_,如果在like模式匹配上下文之外使用`\%`或`\_`,则它们的计算结果为字符串`\%`和`\_`,而不是%和_。
## 诊断及其他
#### 网络连接诊断
......
# Quick Start
# Getting Started
## <a class="anchor" id="install"></a>Quick Install
TDengine software consists of 3 parts: server, client, and alarm module. At the moment, TDengine server only runs on Linux (Windows, mac OS and more OS supports will come soon), but client can run on either Windows or Linux. TDengine client can be installed and run on Windows or Linux. Applications based-on any OSes can all connect to server taosd via a RESTful interface. From 2.4 and later version, TDengine use a stand-alone software, taosAdapteer to provide http service. The early version uses the http server embedded in the taosd. About CPU, TDengine supports X64/ARM64/MIPS64/Alpha64, and ARM32、RISC-V, other more CPU architectures will be supported soon. You can set up and install TDengine server either from the [source code](https://www.taosdata.com/en/getting-started/#Install-from-Source) or the [packages](https://www.taosdata.com/en/getting-started/#Install-from-Package).
TDengine software consists of 3 parts: server, client, and alart module. At the moment, TDengine server only runs on Linux (Windows, mac OS and more OS supports will come soon), but client can run on either Windows or Linux. TDengine client can be installed and run on Windows or Linux. Applications based-on any OSes can all connect to server taosd via a RESTful interface. From 2.4 and later version, TDengine use a stand-alone software, taosAdapteer to provide http service. The early version uses the http server embedded in the taosd. About CPU, TDengine supports X64/ARM64/MIPS64/Alpha64, and ARM32、RISC-V, other more CPU architectures will be supported soon. You can set up and install TDengine server either from the [source code](https://www.taosdata.com/en/getting-started/#Install-from-Source) or the [packages](https://www.taosdata.com/en/getting-started/#Install-from-Package).
### <a class="anchor" id="source-install"></a>Install from Source
......@@ -184,23 +184,11 @@ taos> select avg(f1), max(f2), min(f3) from test.meters where areaid=10;
taos> select avg(f1), max(f2), min(f3) from test.t10 interval(10s);
```
## <a class="anchor" id="taosBenchmark"></a> Using taosBenchmark in detail
### <a class="anchor" id="taosBenchmark"></a> Using taosBenchmark in detail
you can run command `taosBenchmark` with many options, like number of tables, rows of records and so on. To know more about these options, you can execute `taosBenchmark --help` and then take a try using different options.
Please refer to [How to use taosBenchmark to test the performance of TDengine](https://tdengine.com/2021/10/09/3114.html) for detail.
## Client and Alarm Module
If your client and server running on different machines, please install the client separately. Linux and Windows packages are provided:
- TDengine-client-2.0.10.0-Linux-x64.tar.gz(3.0M)
- TDengine-client-2.0.10.0-Windows-x64.exe(2.8M)
- TDengine-client-2.0.10.0-Windows-x86.exe(2.8M)
Linux package of Alarm Module is as following (please refer [How to Use Alarm Module](https://github.com/taosdata/TDengine/blob/master/alert/README_cn.md)):
- TDengine-alert-2.0.10.0-Linux-x64.tar.gz (8.1M)
## <a class="anchor" id="platforms"></a>List of Supported Platforms
List of platforms supported by TDengine server
......
Subproject commit 1c8924dc668e6aa848214c2fc54e3ace3f5bf8df
......@@ -59,6 +59,7 @@ cp ${compile_dir}/../packaging/tools/set_core.sh ${pkg_dir}${install_home_pat
cp ${compile_dir}/../packaging/tools/taosd-dump-cfg.gdb ${pkg_dir}${install_home_path}/bin
cp ${compile_dir}/build/bin/taosd ${pkg_dir}${install_home_path}/bin
cp ${compile_dir}/build/bin/taosBenchmark ${pkg_dir}${install_home_path}/bin
if [ -f "${compile_dir}/build/bin/taosadapter" ]; then
cp ${compile_dir}/build/bin/taosadapter ${pkg_dir}${install_home_path}/bin ||:
......
......@@ -4,6 +4,7 @@ WORKDIR /root
ARG pkgFile
ARG dirName
ARG cpuType
RUN echo ${pkgFile} && echo ${dirName}
COPY ${pkgFile} /root/
......@@ -21,6 +22,11 @@ ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib" \
EXPOSE 6030-6049
EXPOSE 6030-6039/udp
COPY ./bin/* /usr/bin/
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
ENV TINI_VERSION v0.19.0
RUN bash -c 'echo -e "Downloading tini-${cpuType} ..."'
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${cpuType} /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--", "/usr/bin/entrypoint.sh"]
CMD ["taosd"]
VOLUME [ "/var/lib/taos", "/var/log/taos", "/corefile" ]
......@@ -89,7 +89,7 @@ cp -f ${comunityArchiveDir}/${pkgFile} .
echo "dirName=${dirName}"
docker build --rm -f "Dockerfile" --network=host -t tdengine/tdengine-${dockername}:${version} "." --build-arg pkgFile=${pkgFile} --build-arg dirName=${dirName}
docker build --rm -f "Dockerfile" --network=host -t tdengine/tdengine-${dockername}:${version} "." --build-arg pkgFile=${pkgFile} --build-arg dirName=${dirName} --build-arg cpuType=${cpuType}
docker login -u tdengine -p ${passWord} #replace the docker registry username and password
docker push tdengine/tdengine-${dockername}:${version}
......@@ -98,4 +98,4 @@ docker tag tdengine/tdengine-${dockername}:${version} tdengine/tdengine-${docker
docker push tdengine/tdengine-${dockername}:latest
rm -f ${pkgFile}
\ No newline at end of file
rm -f ${pkgFile}
......@@ -312,9 +312,12 @@ if [ "$osType" != "Darwin" ]; then
echo "====do tar.gz package for all systems===="
cd ${script_dir}/tools
${csudo}./makepkg.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${verNumberComp}
${csudo}./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
${csudo}./makearbi.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
if [ "$verMode" == "cluster" ]; then
${csudo}./makepkg.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${verNumberComp}
# ${csudo}./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
# ${csudo}./makearbi.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
fi
else
# only make client for Darwin
cd ${script_dir}/tools
......
......@@ -68,6 +68,8 @@ cp %{_compiledir}/../packaging/tools/set_core.sh %{buildroot}%{homepath}/bin
cp %{_compiledir}/../packaging/tools/taosd-dump-cfg.gdb %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/taos %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/taosd %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/taosBenchmark %{buildroot}%{homepath}/bin
if [ -f %{_compiledir}/build/bin/taosadapter ]; then
cp %{_compiledir}/build/bin/taosadapter %{buildroot}%{homepath}/bin ||:
fi
......
......@@ -192,6 +192,7 @@ function install_bin() {
${csudo}rm -f ${bin_link_dir}/tarbitrator || :
${csudo}rm -f ${bin_link_dir}/set_core || :
${csudo}rm -f ${bin_link_dir}/run_taosd_and_taosadapter.sh || :
${csudo}rm -f ${bin_link_dir}/TDinsight.sh || :
${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/*
......@@ -201,6 +202,7 @@ function install_bin() {
[ -x ${install_main_dir}/bin/taosadapter ] && ${csudo}ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || :
[ -x ${install_main_dir}/bin/taosBenchmark ] && ${csudo}ln -s ${install_main_dir}/bin/taosBenchmark ${bin_link_dir}/taosdemo || :
[ -x ${install_main_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
[ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -s ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || :
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || :
[ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || :
[ -x ${install_main_dir}/bin/run_taosd_and_taosadapter.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_taosd_and_taosadapter.sh ${bin_link_dir}/run_taosd_and_taosadapter.sh || :
......@@ -565,7 +567,7 @@ function install_data() {
}
function install_connector() {
${csudo}cp -rf ${script_dir}/connector/ ${install_main_dir}/
[ -d "${script_dir}/connector/" ] && ${csudo}cp -rf ${script_dir}/connector/ ${install_main_dir}/
}
function install_examples() {
......@@ -691,6 +693,10 @@ function install_service_on_systemd() {
${service_config_dir}/ || :
${csudo}systemctl daemon-reload
[ -f ${script_dir}/cfg/nginxd.service ] &&
${csudo}cp ${script_dir}/cfg/nginxd.service \
${service_config_dir}/ || :
if ! ${csudo}systemctl enable nginxd &>/dev/null; then
${csudo}systemctl daemon-reexec
${csudo}systemctl enable nginxd
......@@ -820,9 +826,9 @@ function update_TDengine() {
install_log
install_header
install_lib
if [ "$pagMode" != "lite" ]; then
install_connector
fi
# if [ "$pagMode" != "lite" ]; then
# install_connector
# fi
install_examples
if [ -z $1 ]; then
install_bin
......@@ -879,7 +885,7 @@ function update_TDengine() {
echo -e "\033[44;32;1m${productName} client is updated successfully!${NC}"
fi
rm -rf $(tar -tf ${tarName})
rm -rf $(tar -tf ${tarName} |grep -v "^\./$")
}
function install_TDengine() {
......@@ -976,7 +982,7 @@ function install_TDengine() {
fi
touch ~/.${historyFile}
rm -rf $(tar -tf ${tarName})
rm -rf $(tar -tf ${tarName} |grep -v "^\./$")
}
## ==============================Main program starts from here============================
......
......@@ -3,7 +3,7 @@
# Generate tar.gz package for all os system
set -e
#set -x
set -x
curr_dir=$(pwd)
compile_dir=$1
......@@ -54,11 +54,21 @@ if [ "$pagMode" == "lite" ]; then
strip ${build_dir}/bin/${serverName}
strip ${build_dir}/bin/${clientName}
# lite version doesn't include taosadapter, which will lead to no restful interface
bin_files="${build_dir}/bin/${serverName} ${build_dir}/bin/${clientName} ${script_dir}/remove.sh ${script_dir}/startPre.sh"
bin_files="${build_dir}/bin/${serverName} ${build_dir}/bin/${clientName} ${script_dir}/remove.sh ${script_dir}/startPre.sh ${build_dir}/bin/taosBenchmark"
taostools_bin_files=""
else
wget https://github.com/taosdata/grafanaplugin/releases/latest/download/TDinsight.sh -O ${build_dir}/bin/TDinsight.sh \
&& echo "TDinsight.sh downloaded!" \
|| echo "failed to download TDinsight.sh"
taostools_bin_files=" ${build_dir}/bin/taosdump \
${build_dir}/bin/TDinsight.sh "
bin_files="${build_dir}/bin/${serverName} \
${build_dir}/bin/${clientName} \
${build_dir}/bin/taosBenchmark \
${taostools_bin_files} \
${build_dir}/bin/taosadapter \
${build_dir}/bin/tarbitrator\
${script_dir}/remove.sh \
......@@ -66,9 +76,6 @@ else
${script_dir}/run_taosd_and_taosadapter.sh \
${script_dir}/startPre.sh \
${script_dir}/taosd-dump-cfg.gdb"
taostools_bin_files=" ${build_dir}/bin/taosdump \
${build_dir}/bin/taosBenchmark"
fi
lib_files="${build_dir}/lib/libtaos.so.${version}"
......@@ -119,36 +126,36 @@ mkdir -p ${install_dir}/init.d && cp ${init_file_rpm} ${install_dir}/init.d/${se
mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_deb} ${install_dir}/init.d/tarbitratord.deb || :
mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir}/init.d/tarbitratord.rpm || :
if [ -n "${taostools_bin_files}" ]; then
mkdir -p ${taostools_install_dir} || echo -e "failed to create ${taostools_install_dir}"
mkdir -p ${taostools_install_dir}/bin \
&& cp ${taostools_bin_files} ${taostools_install_dir}/bin \
&& chmod a+x ${taostools_install_dir}/bin/* || :
if [ -f ${top_dir}/src/kit/taos-tools/packaging/tools/install-taostools.sh ]; then
cp ${top_dir}/src/kit/taos-tools/packaging/tools/install-taostools.sh \
${taostools_install_dir}/ > /dev/null \
&& chmod a+x ${taostools_install_dir}/install-taostools.sh \
|| echo -e "failed to copy install-taostools.sh"
else
echo -e "install-taostools.sh not found"
fi
if [ -f ${top_dir}/src/kit/taos-tools/packaging/tools/uninstall-taostools.sh ]; then
cp ${top_dir}/src/kit/taos-tools/packaging/tools/uninstall-taostools.sh \
${taostools_install_dir}/ > /dev/null \
&& chmod a+x ${taostools_install_dir}/uninstall-taostools.sh \
|| echo -e "failed to copy uninstall-taostools.sh"
else
echo -e "uninstall-taostools.sh not found"
fi
if [ -f ${build_dir}/lib/libavro.so.23.0.0 ]; then
mkdir -p ${taostools_install_dir}/avro/{lib,lib/pkgconfig} || echo -e "failed to create ${taostools_install_dir}/avro"
cp ${build_dir}/lib/libavro.* ${taostools_install_dir}/avro/lib
cp ${build_dir}/lib/pkgconfig/avro-c.pc ${taostools_install_dir}/avro/lib/pkgconfig
fi
fi
#if [ -n "${taostools_bin_files}" ]; then
# mkdir -p ${taostools_install_dir} || echo -e "failed to create ${taostools_install_dir}"
# mkdir -p ${taostools_install_dir}/bin \
# && cp ${taostools_bin_files} ${taostools_install_dir}/bin \
# && chmod a+x ${taostools_install_dir}/bin/* || :
# if [ -f ${top_dir}/src/kit/taos-tools/packaging/tools/install-taostools.sh ]; then
# cp ${top_dir}/src/kit/taos-tools/packaging/tools/install-taostools.sh \
# ${taostools_install_dir}/ > /dev/null \
# && chmod a+x ${taostools_install_dir}/install-taostools.sh \
# || echo -e "failed to copy install-taostools.sh"
# else
# echo -e "install-taostools.sh not found"
# fi
# if [ -f ${top_dir}/src/kit/taos-tools/packaging/tools/uninstall-taostools.sh ]; then
# cp ${top_dir}/src/kit/taos-tools/packaging/tools/uninstall-taostools.sh \
# ${taostools_install_dir}/ > /dev/null \
# && chmod a+x ${taostools_install_dir}/uninstall-taostools.sh \
# || echo -e "failed to copy uninstall-taostools.sh"
# else
# echo -e "uninstall-taostools.sh not found"
# fi
# if [ -f ${build_dir}/lib/libavro.so.23.0.0 ]; then
# mkdir -p ${taostools_install_dir}/avro/{lib,lib/pkgconfig} || echo -e "failed to create ${taostools_install_dir}/avro"
# cp ${build_dir}/lib/libavro.* ${taostools_install_dir}/avro/lib
# cp ${build_dir}/lib/pkgconfig/avro-c.pc ${taostools_install_dir}/avro/lib/pkgconfig
# fi
#fi
if [ -f ${build_dir}/bin/jemalloc-config ]; then
mkdir -p ${install_dir}/jemalloc/{bin,lib,lib/pkgconfig,include/jemalloc,share/doc/jemalloc,share/man/man3}
......@@ -310,13 +317,14 @@ if [ "$exitcode" != "0" ]; then
exit $exitcode
fi
if [ -n "${taostools_bin_files}" ]; then
tar -zcv -f "$(basename ${taostools_pkg_name}).tar.gz" "$(basename ${taostools_install_dir})" --remove-files || :
exitcode=$?
if [ "$exitcode" != "0" ]; then
echo "tar ${taostools_pkg_name}.tar.gz error !!!"
exit $exitcode
fi
fi
#if [ -n "${taostools_bin_files}" ]; then
# wget https://github.com/taosdata/grafanaplugin/releases/latest/download/TDinsight.sh -O ${taostools_install_dir}/bin/TDinsight.sh && echo "TDinsight.sh downloaded!"|| echo "failed to download TDinsight.sh"
# tar -zcv -f "$(basename ${taostools_pkg_name}).tar.gz" "$(basename ${taostools_install_dir})" --remove-files || :
# exitcode=$?
# if [ "$exitcode" != "0" ]; then
# echo "tar ${taostools_pkg_name}.tar.gz error !!!"
# exit $exitcode
# fi
#fi
cd ${curr_dir}
......@@ -107,6 +107,7 @@ function install_bin() {
${csudo}rm -f ${bin_link_dir}/taos || :
${csudo}rm -f ${bin_link_dir}/taosd || :
${csudo}rm -f ${bin_link_dir}/taosadapter || :
${csudo}rm -f ${bin_link_dir}/taosBenchmark || :
${csudo}rm -f ${bin_link_dir}/taosdemo || :
${csudo}rm -f ${bin_link_dir}/taosdump || :
${csudo}rm -f ${bin_link_dir}/rmtaos || :
......@@ -118,7 +119,8 @@ function install_bin() {
[ -x ${bin_dir}/taos ] && ${csudo}ln -s ${bin_dir}/taos ${bin_link_dir}/taos || :
[ -x ${bin_dir}/taosd ] && ${csudo}ln -s ${bin_dir}/taosd ${bin_link_dir}/taosd || :
[ -x ${bin_dir}/taosadapter ] && ${csudo}ln -s ${bin_dir}/taosadapter ${bin_link_dir}/taosadapter || :
[ -x ${bin_dir}/taosdemo ] && ${csudo}ln -s ${bin_dir}/taosdemo ${bin_link_dir}/taosdemo || :
[ -x ${bin_dir}/taosBenchmark ] && ${csudo}ln -sf ${bin_dir}/taosBenchmark ${bin_link_dir}/taosdemo || :
[ -x ${bin_dir}/TDinsight.sh ] && ${csudo}ln -sf ${bin_dir}/TDinsight.sh ${bin_link_dir}/TDinsight.sh || :
[ -x ${bin_dir}/taosdump ] && ${csudo}ln -s ${bin_dir}/taosdump ${bin_link_dir}/taosdump || :
[ -x ${bin_dir}/set_core.sh ] && ${csudo}ln -s ${bin_dir}/set_core.sh ${bin_link_dir}/set_core || :
}
......
......@@ -121,6 +121,7 @@ clean_service
${csudo}rm -f ${bin_link_dir}/taos || :
${csudo}rm -f ${bin_link_dir}/taosd || :
${csudo}rm -f ${bin_link_dir}/taosadapter || :
${csudo}rm -f ${bin_link_dir}/taosBenchmark || :
${csudo}rm -f ${bin_link_dir}/taosdemo || :
${csudo}rm -f ${bin_link_dir}/set_core || :
${csudo}rm -f ${cfg_link_dir}/*.new || :
......
......@@ -83,12 +83,14 @@ function clean_bin() {
${csudo}rm -f ${bin_link_dir}/${clientName} || :
${csudo}rm -f ${bin_link_dir}/${serverName} || :
${csudo}rm -f ${bin_link_dir}/taosadapter || :
${csudo}rm -f ${bin_link_dir}/taosBenchmark || :
${csudo}rm -f ${bin_link_dir}/taosdemo || :
${csudo}rm -f ${bin_link_dir}/taosdump || :
${csudo}rm -f ${bin_link_dir}/${uninstallScript} || :
${csudo}rm -f ${bin_link_dir}/tarbitrator || :
${csudo}rm -f ${bin_link_dir}/set_core || :
${csudo}rm -f ${bin_link_dir}/run_taosd_and_taosadapter.sh || :
${csudo}rm -f ${bin_link_dir}/TDinsight.sh || :
}
function clean_lib() {
......
......@@ -1192,9 +1192,9 @@
}
},
"follow-redirects": {
"version": "1.14.7",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz",
"integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ=="
"version": "1.14.8",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz",
"integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA=="
},
"form-data": {
"version": "4.0.0",
......
const taos = require('../tdengine');
var conn = taos.connect({ host: "localhost" });
var cursor = conn.cursor();
function executeUpdate(updateSql) {
console.log(updateSql);
cursor.execute(updateSql);
}
function executeQuery(querySql) {
let query = cursor.query(querySql);
query.execute().then((result => {
console.log(querySql);
result.pretty();
}));
}
function stmtBindParamBatchSample() {
let db = 'node_test_db';
let table = 'stmt_taos_bind_param_batch';
let createDB = `create database if not exists ${db} keep 3650;`;
let dropDB = `drop database if exists ${db};`;
let useDB = `use ${db}`;
let createTable = `create table if not exists ${table} ` +
`(ts timestamp,` +
`bl bool,` +
`i8 tinyint,` +
`i16 smallint,` +
`i32 int,` +
`i64 bigint,` +
`f32 float,` +
`d64 double,` +
`bnr binary(20),` +
`blob nchar(20),` +
`u8 tinyint unsigned,` +
`u16 smallint unsigned,` +
`u32 int unsigned,` +
`u64 bigint unsigned` +
`)tags(` +
`t_bl bool,` +
`t_i8 tinyint,` +
`t_i16 smallint,` +
`t_i32 int,` +
`t_i64 bigint,` +
`t_f32 float,` +
`t_d64 double,` +
`t_bnr binary(20),` +
`t_blob nchar(20),` +
`t_u8 tinyint unsigned,` +
`t_u16 smallint unsigned,` +
`t_u32 int unsigned,` +
`t_u64 bigint unsigned` +
`);`;
let querySql = `select * from ${table};`;
let insertSql = `insert into ? using ${table} tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?);`;
executeUpdate(dropDB);
executeUpdate(createDB);
executeUpdate(useDB);
executeUpdate(createTable);
let mBinds = new taos.TaosMultiBindArr(14);
mBinds.multiBindTimestamp([1642435200000, 1642435300000, 1642435400000, 1642435500000, 1642435600000]);
mBinds.multiBindBool([true, false, true, undefined, null]);
mBinds.multiBindTinyInt([-127, 3, 127, null, undefined]);
mBinds.multiBindSmallInt([-256, 0, 256, null, undefined]);
mBinds.multiBindInt([-1299, 0, 1233, null, undefined]);
mBinds.multiBindBigInt([16424352000002222n, -16424354000001111n, 0, null, undefined]);
mBinds.multiBindFloat([12.33, 0, -3.1415, null, undefined]);
mBinds.multiBindDouble([3.141592653, 0, -3.141592653, null, undefined]);
mBinds.multiBindBinary(['TDengine_Binary', '', 'taosdata涛思数据', null, undefined]);
mBinds.multiBindNchar(['taos_data_nchar', 'taosdata涛思数据', '', null, undefined]);
mBinds.multiBindUTinyInt([0, 127, 254, null, undefined]);
mBinds.multiBindUSmallInt([0, 256, 512, null, undefined]);
mBinds.multiBindUInt([0, 1233, 4294967294, null, undefined]);
mBinds.multiBindUBigInt([16424352000002222n, 36424354000001111n, 0, null, undefined]);
let tags = new taos.TaosBind(13);
tags.bindBool(true);
tags.bindTinyInt(127);
tags.bindSmallInt(32767);
tags.bindInt(1234555);
tags.bindBigInt(-164243520000011111n);
tags.bindFloat(214.02);
tags.bindDouble(2.01);
tags.bindBinary('taosdata涛思数据');
tags.bindNchar('TDengine数据');
tags.bindUTinyInt(254);
tags.bindUSmallInt(65534);
tags.bindUInt(4294967290 / 2);
tags.bindUBigInt(164243520000011111n);
cursor.stmtInit();
cursor.stmtPrepare(insertSql);
cursor.stmtSetTbnameTags('s_01', tags.getBind());
cursor.stmtBindParamBatch(mBinds.getMultiBindArr());
cursor.stmtAddBatch();
cursor.stmtExecute();
cursor.stmtClose();
executeQuery(querySql);
executeUpdate(dropDB);
}
stmtBindParamBatchSample();
setTimeout(() => {
conn.close();
}, 2000);
// const TaosBind = require('../nodetaos/taosBind');
const taos = require('../tdengine');
var conn = taos.connect({ host: "localhost" });
var cursor = conn.cursor();
function executeUpdate(updateSql) {
console.log(updateSql);
cursor.execute(updateSql);
}
function executeQuery(querySql) {
let query = cursor.query(querySql);
query.execute().then((result => {
console.log(querySql);
result.pretty();
}));
}
function stmtBindParamSample() {
let db = 'node_test_db';
let table = 'stmt_taos_bind_sample';
let createDB = `create database if not exists ${db} keep 3650;`;
let dropDB = `drop database if exists ${db};`;
let useDB = `use ${db}`;
let createTable = `create table if not exists ${table} ` +
`(ts timestamp,` +
`nil int,` +
`bl bool,` +
`i8 tinyint,` +
`i16 smallint,` +
`i32 int,` +
`i64 bigint,` +
`f32 float,` +
`d64 double,` +
`bnr binary(20),` +
`blob nchar(20),` +
`u8 tinyint unsigned,` +
`u16 smallint unsigned,` +
`u32 int unsigned,` +
`u64 bigint unsigned);`;
let querySql = `select * from ${table};`;
let insertSql = `insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);`
executeUpdate(dropDB);
executeUpdate(createDB);
executeUpdate(useDB);
executeUpdate(createTable);
let binds = new taos.TaosBind(15);
binds.bindTimestamp(1642435200000);
binds.bindNil();
binds.bindBool(true);
binds.bindTinyInt(127);
binds.bindSmallInt(32767);
binds.bindInt(1234555);
binds.bindBigInt(-164243520000011111n);
binds.bindFloat(214.02);
binds.bindDouble(2.01);
binds.bindBinary('taosdata涛思数据');
binds.bindNchar('TDengine数据');
binds.bindUTinyInt(254);
binds.bindUSmallInt(65534);
binds.bindUInt(4294967294);
binds.bindUBigInt(164243520000011111n);
cursor.stmtInit();
cursor.stmtPrepare(insertSql);
cursor.stmtSetTbname(table);
cursor.stmtBindParam(binds.getBind());
cursor.stmtAddBatch();
cursor.stmtExecute();
cursor.stmtClose();
executeQuery(querySql);
executeUpdate(dropDB);
}
stmtBindParamSample();
setTimeout(() => {
conn.close();
}, 2000);
\ No newline at end of file
const taos = require('../tdengine');
var conn = taos.connect({ host: "localhost" });
var cursor = conn.cursor();
function executeUpdate(updateSql) {
console.log(updateSql);
cursor.execute(updateSql);
}
function executeQuery(querySql) {
let query = cursor.query(querySql);
query.execute().then((result => {
console.log(querySql);
result.pretty();
}));
}
function stmtSingleParaBatchSample() {
let db = 'node_test_db';
let table = 'stmt_taos_bind_single_bind_batch';
let createDB = `create database if not exists ${db} keep 3650;`;
let dropDB = `drop database if exists ${db};`;
let useDB = `use ${db}`;
let createTable = `create table if not exists ${table} ` +
`(ts timestamp,` +
`bl bool,` +
`i8 tinyint,` +
`i16 smallint,` +
`i32 int,` +
`i64 bigint,` +
`f32 float,` +
`d64 double,` +
`bnr binary(20),` +
`blob nchar(20),` +
`u8 tinyint unsigned,` +
`u16 smallint unsigned,` +
`u32 int unsigned,` +
`u64 bigint unsigned` +
`)tags(` +
`jsonTag json` +
`);`;
let querySql = `select * from ${table};`;
let insertSql = `insert into ? using ${table} tags(?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?);`
executeUpdate(dropDB);
executeUpdate(createDB);
executeUpdate(useDB);
executeUpdate(createTable);
// normal colum values.
let mbind = new taos.TaosMultiBind();
let tsMBind = mbind.multiBindTimestamp([1642435200000, 1642435300000, 1642435400000, 1642435500000, 1642435600000])
let boolMbind = mbind.multiBindBool([true, false, true, undefined, null]);
let tinyIntMbind = mbind.multiBindTinyInt([-127, 3, 127, null, undefined]);
let smallIntMbind = mbind.multiBindSmallInt([-256, 0, 256, null, undefined]);
let intMbind = mbind.multiBindInt([-1299, 0, 1233, null, undefined]);
let bigIntMbind = mbind.multiBindBigInt([16424352000002222n, -16424354000001111n, 0, null, undefined]);
let floatMbind = mbind.multiBindFloat([12.33, 0, -3.1415, null, undefined]);
let doubleMbind = mbind.multiBindDouble([3.141592653, 0, -3.141592653, null, undefined]);
let binaryMbind = mbind.multiBindBinary(['TDengine_Binary', '', 'taosdata涛思数据', null, undefined]);
let ncharMbind = mbind.multiBindNchar(['taos_data_nchar', 'taosdata涛思数据', '', null, undefined]);
let uTinyIntMbind = mbind.multiBindUTinyInt([0, 127, 254, null, undefined]);
let uSmallIntMbind = mbind.multiBindUSmallInt([0, 256, 512, null, undefined]);
let uIntMbind = mbind.multiBindUInt([0, 1233, 4294967294, null, undefined]);
let uBigIntMbind = mbind.multiBindUBigInt([16424352000002222n, 36424354000001111n, 0, null, undefined]);
// tags value.
let tags = new taos.TaosBind(1);
tags.bindJson('{\"key1\":\"taosdata\",\"key2\":null,\"key3\":\"TDengine涛思数据\",\"key4\":3.2}');
cursor.stmtInit();
cursor.stmtPrepare(insertSql);
cursor.stmtSetTbnameTags('s_01', tags.getBind());
cursor.stmtBindSingleParamBatch(tsMBind, 0);
cursor.stmtBindSingleParamBatch(boolMbind, 1);
cursor.stmtBindSingleParamBatch(tinyIntMbind, 2);
cursor.stmtBindSingleParamBatch(smallIntMbind, 3);
cursor.stmtBindSingleParamBatch(intMbind, 4);
cursor.stmtBindSingleParamBatch(bigIntMbind, 5);
cursor.stmtBindSingleParamBatch(floatMbind, 6);
cursor.stmtBindSingleParamBatch(doubleMbind, 7);
cursor.stmtBindSingleParamBatch(binaryMbind, 8);
cursor.stmtBindSingleParamBatch(ncharMbind, 9);
cursor.stmtBindSingleParamBatch(uTinyIntMbind, 10);
cursor.stmtBindSingleParamBatch(uSmallIntMbind, 11);
cursor.stmtBindSingleParamBatch(uIntMbind, 12);
cursor.stmtBindSingleParamBatch(uBigIntMbind, 13);
cursor.stmtAddBatch();
cursor.stmtExecute();
cursor.stmtClose();
executeQuery(querySql);
executeUpdate(dropDB);
}
stmtSingleParaBatchSample();
setTimeout(() => {
conn.close();
}, 2000);
const taos = require('../tdengine');
var conn = taos.connect({ host: "localhost" });
var cursor = conn.cursor();
function executeUpdate(updateSql) {
console.log(updateSql);
cursor.execute(updateSql);
}
function executeQuery(querySql) {
let query = cursor.query(querySql);
query.execute().then((result => {
console.log(querySql);
result.pretty();
}));
}
function stmtUseResultSample() {
let db = 'node_test_db';
let table = 'stmt_use_result';
let subTable = 's1_0';
let createDB = `create database if not exists ${db} keep 3650;`;
let dropDB = `drop database if exists ${db};`;
let useDB = `use ${db}`;
let createTable = `create table if not exists ${table} ` +
`(ts timestamp,` +
`bl bool,` +
`i8 tinyint,` +
`i16 smallint,` +
`i32 int,` +
`i64 bigint,` +
`f32 float,` +
`d64 double,` +
`bnr binary(20),` +
`blob nchar(20),` +
`u8 tinyint unsigned,` +
`u16 smallint unsigned,` +
`u32 int unsigned,` +
`u64 bigint unsigned` +
`)tags(` +
`jsonTag json` +
`);`;
let createSubTable = `create table if not exists ${subTable} using ${table} tags('{\"key1\":\"taosdata\",\"key2\":null,\"key3\":\"TDengine涛思数据\",\"key4\":3.2}')`;
let querySql = `select * from ${table} where i32>? and bnr = ? `;
let insertSql = `insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?);`;
let mBinds = new taos.TaosMultiBindArr(14);
mBinds.multiBindTimestamp([1642435200000,1642435300000,1642435400000,1642435500000,1642435600000]);
mBinds.multiBindBool([true,false,true,undefined,null]);
mBinds.multiBindTinyInt([-127,3,127,null,undefined]);
mBinds.multiBindSmallInt([-256,0,256,null,undefined]);
mBinds.multiBindInt([-1299,0,1233,null,undefined]);
mBinds.multiBindBigInt([16424352000002222n,-16424354000001111n,0,null,undefined]);
mBinds.multiBindFloat([12.33,0,-3.1415,null,undefined]);
mBinds.multiBindDouble([3.141592653,0,-3.141592653,null,undefined]);
mBinds.multiBindBinary(['TDengine_Binary','','taosdata涛思数据',null,undefined]);
mBinds.multiBindNchar(['taos_data_nchar','taosdata涛思数据','',null,undefined]);
mBinds.multiBindUTinyInt([0,127, 254,null,undefined]);
mBinds.multiBindUSmallInt([0,256,512,null,undefined]);
mBinds.multiBindUInt([0,1233,4294967294,null,undefined]);
mBinds.multiBindUBigInt([16424352000002222n,36424354000001111n,0,null,undefined]);
// executeUpdate(dropDB);
executeUpdate(createDB);
executeUpdate(useDB);
executeUpdate(createTable);
executeUpdate(createSubTable);
//stmt bind values
cursor.stmtInit();
cursor.stmtPrepare(insertSql);
cursor.loadTableInfo([subTable]);
cursor.stmtSetTbname(subTable);
cursor.stmtBindParamBatch(mBinds.getMultiBindArr());
cursor.stmtAddBatch();
cursor.stmtExecute();
cursor.stmtClose();
// stmt select with normal column.
let condition1 = new taos.TaosBind(2);
condition1.bindInt(0);
condition1.bindNchar('taosdata涛思数据');
cursor.stmtInit();
cursor.stmtPrepare(querySql);
cursor.stmtBindParam(condition1.getBind());
cursor.stmtExecute();
cursor.stmtUseResult();
cursor.stmtClose();
cursor.fetchall();
console.log(cursor.fields);
console.log(cursor.data);
executeUpdate(dropDB);
}
stmtUseResultSample();
setTimeout(() => {
conn.close();
}, 2000);
\ No newline at end of file
......@@ -373,7 +373,7 @@ function CTaosInterface(config = null, pass = false) {
, 'taos_stmt_execute': [ref.types.int, [ref.types.void_ptr]]
// TAOS_RES* taos_stmt_use_result(TAOS_STMT *stmt)
, 'taos_stmt_use_result': [ref.types.int, [ref.types.void_ptr]]
, 'taos_stmt_use_result': [ref.types.void_ptr, [ref.types.void_ptr]]
// int taos_stmt_close(TAOS_STMT *stmt)
, 'taos_stmt_close': [ref.types.int, [ref.types.void_ptr]]
......@@ -934,7 +934,15 @@ CTaosInterface.prototype.stmtUseResult = function stmtUseResult(stmt) {
* @returns 0 for success, non-zero for failure.
*/
CTaosInterface.prototype.loadTableInfo = function loadTableInfo(taos, tableList) {
return this.libtaos.taos_load_table_info(taos, tableList)
let _tableListBuf = Buffer.alloc(ref.sizeof.pointer);
let _listStr = tableList.toString();
if ((_.isString(tableList) )|| (_.isArray(tableList))) {
ref.set(_tableListBuf, 0, ref.allocCString(_listStr), ref.types.char_ptr);
return this.libtaos.taos_load_table_info(taos, _tableListBuf);
} else {
throw new errors.InterfaceError("Unspport tableLis input");
}
}
/**
......
......@@ -30,6 +30,7 @@ function TDengineCursor(connection = null) {
this._fields = null;
this.data = [];
this.fields = null;
this._stmt = null;
if (connection != null) {
this._connection = connection
this._chandle = connection._chandle //pass through, just need library loaded.
......@@ -488,7 +489,6 @@ TDengineCursor.prototype.schemalessInsert = function schemalessInsert(lines, pro
let errorNo = this._chandle.errno(this._result);
if (errorNo != 0) {
throw new errors.InterfaceError(errorNo + ":" + this._chandle.errStr(this._result));
this._chandle.freeResult(this._result);
}
this._chandle.freeResult(this._result);
}
......@@ -499,7 +499,7 @@ TDengineCursor.prototype.schemalessInsert = function schemalessInsert(lines, pro
* @returns Not NULL returned for success, and NULL for failure.
*
*/
TDengineCursor.prototype.stmtInit = function stmtInit() {
TDengineCursor.prototype.stmtInit = function stmtInit() {
let stmt = null
stmt = this._chandle.stmtInit(this._connection._conn);
if (stmt == null || stmt == undefined) {
......@@ -532,7 +532,7 @@ TDengineCursor.prototype.stmtPrepare = function stmtPrepare(sql) {
* @param {TaosBind} tableName target table name you want to bind
* @returns 0 for success, non-zero for failure.
*/
TDengineCursor.prototype.stmtSetTbname = function stmtSetTbname(tableName){
TDengineCursor.prototype.stmtSetTbname = function stmtSetTbname(tableName) {
if (this._stmt == null) {
throw new errors.DatabaseError("stmt is null,init stmt first");
} else {
......@@ -552,11 +552,11 @@ TDengineCursor.prototype.stmtSetTbname = function stmtSetTbname(tableName){
* @param {TaosMultiBind} tags use to set tag value for target table.
* @returns
*/
TDengineCursor.prototype.stmtSetTbnameTags = function stmtSetTbnameTags(tableName,tags){
TDengineCursor.prototype.stmtSetTbnameTags = function stmtSetTbnameTags(tableName, tags) {
if (this._stmt == null) {
throw new errors.DatabaseError("stmt is null,init stmt first");
} else {
let stmtPrepare = this._chandle.stmtSetTbnameTags(this._stmt, tableName,tags);
let stmtPrepare = this._chandle.stmtSetTbnameTags(this._stmt, tableName, tags);
if (stmtPrepare != 0) {
throw new errors.DatabaseError(this._chandle.stmtErrStr(this._stmt));
} else {
......@@ -573,7 +573,7 @@ TDengineCursor.prototype.stmtSetTbnameTags = function stmtSetTbnameTags(tableNam
* @param {*} subTableName table name which is belong to an stable
* @returns 0 for success, non-zero for failure.
*/
TDengineCursor.prototype.stmtSetSubTbname = function stmtSetSubTbname(subTableName){
TDengineCursor.prototype.stmtSetSubTbname = function stmtSetSubTbname(subTableName) {
if (this._stmt == null) {
throw new errors.DatabaseError("stmt is null,init stmt first");
} else {
......@@ -594,7 +594,7 @@ TDengineCursor.prototype.stmtSetSubTbname = function stmtSetSubTbname(subTableNa
* @param {*} binds points to an array contains the whole line data.
* @returns 0 for success, non-zero for failure.
*/
TDengineCursor.prototype.bindParam = function bindParam(binds) {
TDengineCursor.prototype.stmtBindParam = function stmtBindParam(binds) {
if (this._stmt == null) {
throw new errors.DatabaseError("stmt is null,init stmt first");
} else {
......@@ -613,11 +613,11 @@ TDengineCursor.prototype.bindParam = function bindParam(binds) {
* @param {*} colIndex the column's index in prepared sql statement, it starts from 0.
* @returns 0 for success, non-zero for failure.
*/
TDengineCursor.prototype.stmtBindSingleParamBatch = function stmtBindSingleParamBatch(mbind,colIndex){
TDengineCursor.prototype.stmtBindSingleParamBatch = function stmtBindSingleParamBatch(mbind, colIndex) {
if (this._stmt == null) {
throw new errors.DatabaseError("stmt is null,init stmt first");
} else {
let stmtPrepare = this._chandle.stmtBindSingleParamBatch(this._stmt, mbind,colIndex);
let stmtPrepare = this._chandle.stmtBindSingleParamBatch(this._stmt, mbind, colIndex);
if (stmtPrepare != 0) {
throw new errors.DatabaseError(this._chandle.stmtErrStr(this._stmt));
} else {
......@@ -634,7 +634,7 @@ TDengineCursor.prototype.stmtBindSingleParamBatch = function stmtBindSingleParam
* n sql statement.
* @returns 0 for success, non-zero for failure.
*/
TDengineCursor.prototype.stmtBindParamBatch = function stmtBindParamBatch(mbinds){
TDengineCursor.prototype.stmtBindParamBatch = function stmtBindParamBatch(mbinds) {
if (this._stmt == null) {
throw new errors.DatabaseError("stmt is null,init stmt first");
} else {
......@@ -656,7 +656,7 @@ TDengineCursor.prototype.stmtBindParamBatch = function stmtBindParamBatch(mbinds
* @param {*} stmt
* @returns 0 for success, non-zero for failure.
*/
TDengineCursor.prototype.addBatch = function addBatch() {
TDengineCursor.prototype.stmtAddBatch = function stmtAddBatch() {
if (this._stmt == null) {
throw new errors.DatabaseError("stmt is null,init stmt first");
} else {
......@@ -694,13 +694,19 @@ TDengineCursor.prototype.stmtExecute = function stmtExecute() {
* User application should free it with API 'FreeResult' at the end.
* @returns Not NULL for success, NULL for failure.
*/
TDengineCursor.prototype.stmtUseResult = function stmtUseResult(){
TDengineCursor.prototype.stmtUseResult = function stmtUseResult() {
if (this._stmt != null) {
let stmtExecRes = this._chandle.stmtUseResult(this._stmt);
if (stmtExecRes != 0) {
throw new errors.DatabaseError(this._chandle.stmtErrStr(this._stmt));
this._result = this._chandle.stmtUseResult(this._stmt);
let res = this._chandle.errno(this._result);
if (res != 0) {
throw new errors.DatabaseError(this._chandle.errStr(this._stmt));
} else {
console.log("stmtUseResult success.")
console.log("stmtUseResult success.");
let fieldCount = this._chandle.fieldsCount(this._result);
if (fieldCount != 0) {
this._fields = this._chandle.useResult(this._result);
this.fields = this._fields;
}
}
} else {
throw new errors.DatabaseError("stmt is null,init stmt first");
......@@ -713,11 +719,11 @@ TDengineCursor.prototype.stmtUseResult = function stmtUseResult(){
* @param {*} tableList tables need to load meta info are form in an array
* @returns 0 for success, non-zero for failure.
*/
TDengineCursor.prototype.loadTableInfo = function loadTableInfo(tableList){
TDengineCursor.prototype.loadTableInfo = function loadTableInfo(tableList) {
if (this._connection._conn != null) {
let stmtExecRes = this._chandle.loadTableInfo(this._connection._conn,tableList);
let stmtExecRes = this._chandle.loadTableInfo(this._connection._conn, tableList);
if (stmtExecRes != 0) {
throw new errors.DatabaseError(this._chandle.stmtErrStr(this._stmt));
throw new errors.DatabaseError(`loadTableInfo() failed,code ${stmtExecRes}`);
} else {
console.log("loadTableInfo success.")
}
......
......@@ -14,20 +14,19 @@ var u = ref.types.int64;
var allocated = ref.types.uint32;
var TAOS_BIND = StructType({
buffer_type : bufferType,
buffer : buffer,
buffer_length : bufferLength,
length : length,
is_null : isNull,
is_unsigned : is_unsigned,
error : error,
u : u,
buffer_type: bufferType,
buffer: buffer,
buffer_length: bufferLength,
length: length,
is_null: isNull,
is_unsigned: is_unsigned,
error: error,
u: u,
allocated: allocated,
});
class TaosBind {
constructor(num) {
console.log(TAOS_BIND.size);
this.buf = Buffer.alloc(TAOS_BIND.size * num);
this.num = num;
this.index = 0;
......@@ -36,15 +35,15 @@ class TaosBind {
* Used to bind null value for all data types that tdengine supports.
*/
bindNil() {
if(!this._isOutOfBound()){
if (!this._isOutOfBound()) {
let nil = new TAOS_BIND({
buffer_type : taosConst.C_NULL,
is_null : ref.alloc(ref.types.int32, 1),
buffer_type: taosConst.C_NULL,
is_null: ref.alloc(ref.types.int32, 1),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, nil);
this.index++
}else{
} else {
throw new TDError(`bindNil() failed,since index:${this.index} is out of Buffer bound ${this.num}.`);
}
}
......@@ -54,18 +53,18 @@ class TaosBind {
* @param {bool} val is not null bool value,true or false.
*/
bindBool(val) {
if(!this._isOutOfBound()){
if (!this._isOutOfBound()) {
let bl = new TAOS_BIND({
buffer_type : taosConst.C_BOOL,
buffer : ref.alloc(ref.types.bool, val),
buffer_length : ref.types.bool.size,
length : ref.alloc(ref.types.uint64, ref.types.bool.size),
is_null : ref.alloc(ref.types.int32, 0),
buffer_type: taosConst.C_BOOL,
buffer: ref.alloc(ref.types.bool, val),
buffer_length: ref.types.bool.size,
length: ref.alloc(ref.types.uint64, ref.types.bool.size),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, bl);
this.index++
}else{
} else {
throw new TDError(`bindBool() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`);
}
......@@ -75,19 +74,19 @@ class TaosBind {
*
* @param {int8} val is a not null tinyint value.
*/
bindTinyInt(val){
if(!this._isOutOfBound()){
bindTinyInt(val) {
if (!this._isOutOfBound()) {
let tinnyInt = new TAOS_BIND({
buffer_type : taosConst.C_TINYINT,
buffer : ref.alloc(ref.types.int8, val),
buffer_length : ref.types.int8.size,
length : ref.alloc(ref.types.uint64, ref.types.int8.size),
is_null : ref.alloc(ref.types.int32, 0),
buffer_type: taosConst.C_TINYINT,
buffer: ref.alloc(ref.types.int8, val),
buffer_length: ref.types.int8.size,
length: ref.alloc(ref.types.uint64, ref.types.int8.size),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, tinnyInt);
this.index++
}else{
this.index++
} else {
throw new TDError(`bindTinyInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`);
}
}
......@@ -96,39 +95,39 @@ class TaosBind {
*
* @param {short} val is a not null small int value.
*/
bindSmallInt(val){
if(!this._isOutOfBound()){
bindSmallInt(val) {
if (!this._isOutOfBound()) {
let samllint = new TAOS_BIND({
buffer_type : taosConst.C_SMALLINT,
buffer : ref.alloc(ref.types.int16, val),
buffer_length : ref.types.int16.size,
length : ref.alloc(ref.types.uint64, ref.types.int16.size),
is_null : ref.alloc(ref.types.int32, 0),
buffer_type: taosConst.C_SMALLINT,
buffer: ref.alloc(ref.types.int16, val),
buffer_length: ref.types.int16.size,
length: ref.alloc(ref.types.uint64, ref.types.int16.size),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, samllint);
this.index++
}else{
this.index++
} else {
throw new TDError(`bindSmallInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`);
}
}
/**
*
* @param {int} val is a not null int value.
*/
bindInt(val){
if(!this._isOutOfBound()){
bindInt(val) {
if (!this._isOutOfBound()) {
let int = new TAOS_BIND({
buffer_type : taosConst.C_INT,
buffer : ref.alloc(ref.types.int32, val),
buffer_length : ref.types.int32.size,
length : ref.alloc(ref.types.uint64, ref.types.int32.size),
is_null : ref.alloc(ref.types.int32, 0),
buffer_type: taosConst.C_INT,
buffer: ref.alloc(ref.types.int32, val),
buffer_length: ref.types.int32.size,
length: ref.alloc(ref.types.uint64, ref.types.int32.size),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, int);
this.index++
}else{
this.index++
} else {
throw new TDError(`bindInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`);
}
......@@ -139,37 +138,37 @@ class TaosBind {
* @param {long} val is not null big int value.
*/
bindBigInt(val) {
if(!this._isOutOfBound()){
if (!this._isOutOfBound()) {
let bigint = new TAOS_BIND({
buffer_type : taosConst.C_BIGINT,
buffer : ref.alloc(ref.types.int64, val.toString()),
buffer_length : ref.types.int64.size,
length : ref.alloc(ref.types.uint64, ref.types.int64.size),
is_null : ref.alloc(ref.types.int32, 0),
buffer_type: taosConst.C_BIGINT,
buffer: ref.alloc(ref.types.int64, val.toString()),
buffer_length: ref.types.int64.size,
length: ref.alloc(ref.types.uint64, ref.types.int64.size),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, bigint);
this.index++
}else{
} else {
throw new TDError(`bindBigInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`);
}
}
/**
*
* @param {float} val is a not null float value
*/
/**
*
* @param {float} val is a not null float value
*/
bindFloat(val) {
if(!this._isOutOfBound()){
if (!this._isOutOfBound()) {
let float = new TAOS_BIND({
buffer_type : taosConst.C_FLOAT,
buffer : ref.alloc(ref.types.float, val),
buffer_length : ref.types.float.size,
length : ref.alloc(ref.types.uint64, ref.types.float.size),
is_null : ref.alloc(ref.types.int32, 0),
buffer_type: taosConst.C_FLOAT,
buffer: ref.alloc(ref.types.float, val),
buffer_length: ref.types.float.size,
length: ref.alloc(ref.types.uint64, ref.types.float.size),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, float);
this.index++
}else{
} else {
throw new TDError(`bindFloat() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`);
}
}
......@@ -177,18 +176,18 @@ class TaosBind {
*
* @param {double} val is a not null double value
*/
bindDouble(val){
if(!this._isOutOfBound()){
bindDouble(val) {
if (!this._isOutOfBound()) {
let double = new TAOS_BIND({
buffer_type : taosConst.C_DOUBLE,
buffer : ref.alloc(ref.types.double, val),
buffer_length : ref.types.double.size,
length : ref.alloc(ref.types.uint64, ref.types.double.size),
is_null : ref.alloc(ref.types.int32, 0),
buffer_type: taosConst.C_DOUBLE,
buffer: ref.alloc(ref.types.double, val),
buffer_length: ref.types.double.size,
length: ref.alloc(ref.types.uint64, ref.types.double.size),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, double);
this.index++
}else{
} else {
throw new TDError(`bindDouble() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`);
}
}
......@@ -197,19 +196,19 @@ class TaosBind {
*
* @param {string} val is a string.
*/
bindBinary(val){
let cstringBuf = ref.allocCString(val,'utf-8');
if(!this._isOutOfBound()){
bindBinary(val) {
let cstringBuf = ref.allocCString(val, 'utf-8');
if (!this._isOutOfBound()) {
let binary = new TAOS_BIND({
buffer_type : taosConst.C_BINARY,
buffer : cstringBuf,
buffer_length : cstringBuf.length,
length : ref.alloc(ref.types.uint64, cstringBuf.length),
is_null : ref.alloc(ref.types.int32, 0),
buffer_type: taosConst.C_BINARY,
buffer: cstringBuf,
buffer_length: cstringBuf.length,
length: ref.alloc(ref.types.uint64, cstringBuf.length - 1),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, binary);
this.index++
}else{
} else {
throw new TDError(`bindBinary() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`);
}
}
......@@ -220,11 +219,11 @@ class TaosBind {
*/
bindTimestamp(val) {
let ts = new TAOS_BIND({
buffer_type : taosConst.C_TIMESTAMP,
buffer : ref.alloc(ref.types.int64, val),
buffer_length : ref.types.int64.size,
length : ref.alloc(ref.types.uint64, ref.types.int64.size),
is_null : ref.alloc(ref.types.int32, 0),
buffer_type: taosConst.C_TIMESTAMP,
buffer: ref.alloc(ref.types.int64, val),
buffer_length: ref.types.int64.size,
length: ref.alloc(ref.types.uint64, ref.types.int64.size),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, ts);
......@@ -235,61 +234,61 @@ class TaosBind {
*
* @param {string} val is a string.
*/
bindNchar(val){
let cstringBuf = ref.allocCString(val,'utf-8');
if(!this._isOutOfBound()){
bindNchar(val) {
let cstringBuf = ref.allocCString(val, 'utf-8');
if (!this._isOutOfBound()) {
let nchar = new TAOS_BIND({
buffer_type : taosConst.C_NCHAR,
buffer : cstringBuf,
buffer_length : cstringBuf.length,
length : ref.alloc(ref.types.uint64, cstringBuf.length),
is_null : ref.alloc(ref.types.int32, 0),
buffer_type: taosConst.C_NCHAR,
buffer: cstringBuf,
buffer_length: cstringBuf.length,
length: ref.alloc(ref.types.uint64, cstringBuf.length - 1),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, nchar);
this.index++
}else{
} else {
throw new TDError(`bindNchar() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`);
}
}
/**
*
* @param {uint8} val is a not null unsinged tinyint value.
*/
bindUTinyInt(val){
if(!this._isOutOfBound()){
/**
*
* @param {uint8} val is a not null unsinged tinyint value.
*/
bindUTinyInt(val) {
if (!this._isOutOfBound()) {
let uTinyInt = new TAOS_BIND({
buffer_type : taosConst.C_TINYINT_UNSIGNED,
buffer : ref.alloc(ref.types.uint8, val),
buffer_length : ref.types.uint8.size,
length : ref.alloc(ref.types.uint64, ref.types.uint8.size),
is_null : ref.alloc(ref.types.int32, 0),
buffer_type: taosConst.C_TINYINT_UNSIGNED,
buffer: ref.alloc(ref.types.uint8, val),
buffer_length: ref.types.uint8.size,
length: ref.alloc(ref.types.uint64, ref.types.uint8.size),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, uTinyInt);
this.index++
}else{
this.index++
} else {
throw new TDError(`bindUTinyInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`);
}
}
/**
*
* @param {uint16} val is a not null unsinged smallint value.
*/
bindUSmallInt(val){
if(!this._isOutOfBound()){
bindUSmallInt(val) {
if (!this._isOutOfBound()) {
let uSmallInt = new TAOS_BIND({
buffer_type : taosConst.C_SMALLINT_UNSIGNED,
buffer : ref.alloc(ref.types.uint16, val),
buffer_length : ref.types.uint16.size,
length : ref.alloc(ref.types.uint64, ref.types.uint16.size),
is_null : ref.alloc(ref.types.int32, 0),
buffer_type: taosConst.C_SMALLINT_UNSIGNED,
buffer: ref.alloc(ref.types.uint16, val),
buffer_length: ref.types.uint16.size,
length: ref.alloc(ref.types.uint64, ref.types.uint16.size),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, uSmallInt);
this.index++
}else{
this.index++
} else {
throw new TDError(`bindUSmallInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`);
}
}
......@@ -298,19 +297,19 @@ class TaosBind {
*
* @param {uint32} val is a not null unsinged int value.
*/
bindUInt(val){
if(!this._isOutOfBound()){
bindUInt(val) {
if (!this._isOutOfBound()) {
let uInt = new TAOS_BIND({
buffer_type : taosConst.C_INT_UNSIGNED,
buffer : ref.alloc(ref.types.uint32, val),
buffer_length : ref.types.uint32.size,
length : ref.alloc(ref.types.uint64, ref.types.uint32.size),
is_null : ref.alloc(ref.types.int32, 0),
buffer_type: taosConst.C_INT_UNSIGNED,
buffer: ref.alloc(ref.types.uint32, val),
buffer_length: ref.types.uint32.size,
length: ref.alloc(ref.types.uint64, ref.types.uint32.size),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, uInt);
this.index++
}else{
this.index++
} else {
throw new TDError(`bindUInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`);
}
}
......@@ -319,23 +318,46 @@ class TaosBind {
*
* @param {uint64} val is a not null unsinged bigint value.
*/
bindUBigInt(val){
if(!this._isOutOfBound()){
bindUBigInt(val) {
if (!this._isOutOfBound()) {
let uBigInt = new TAOS_BIND({
buffer_type : taosConst.C_BIGINT_UNSIGNED,
buffer : ref.alloc(ref.types.uint64, val.toString()),
buffer_length : ref.types.uint64.size,
length : ref.alloc(ref.types.uint64, ref.types.uint64.size),
is_null : ref.alloc(ref.types.int32, 0),
buffer_type: taosConst.C_BIGINT_UNSIGNED,
buffer: ref.alloc(ref.types.uint64, val.toString()),
buffer_length: ref.types.uint64.size,
length: ref.alloc(ref.types.uint64, ref.types.uint64.size),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, uBigInt);
this.index++
}else{
this.index++
} else {
throw new TDError(`bindUBigInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`);
}
}
/**
*
* @param {jsonStr} val is a json string. Such as '{\"key1\":\"taosdata\"}'
*/
bindJson(val) {
let cstringBuf = ref.allocCString(val, 'utf-8');
if (!this._isOutOfBound()) {
let jsonType = new TAOS_BIND({
buffer_type: taosConst.C_JSON_TAG,
buffer: cstringBuf,
buffer_length: cstringBuf.length,
length: ref.alloc(ref.types.uint64, cstringBuf.length - 1),
is_null: ref.alloc(ref.types.int32, 0),
});
TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, jsonType);
this.index++
} else {
throw new TDError(`bindJson() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`);
}
}
/**
*
* @returns binded buffer.
......@@ -344,10 +366,10 @@ class TaosBind {
return this.buf;
}
_isOutOfBound(){
if(this.num>this.index){
_isOutOfBound() {
if (this.num > this.index) {
return false;
}else{
} else {
return true;
}
}
......
此差异已折叠。
const ref = require('ref-napi');
const { TDError } = require('./error');
const { TAOS_MULTI_BIND, TaosMultiBind } = require('./taosMultiBind');
const TAOS_MULTI_BIND_SIZE = TAOS_MULTI_BIND.size;
class TaosMultiBindArr extends TaosMultiBind {
/**
* The constructor,initial basic parameters and alloc buffer.
* @param {*} numOfColumns the number of column that you want to bind parameters.
*/
constructor(numOfColumns) {
super();
this.taosMBindArrBuf = Buffer.alloc(numOfColumns * TAOS_MULTI_BIND_SIZE);
this.index = 0;
this.bound = numOfColumns;
}
/**
* Used to bind boolean column's values.
* @param {*} boolArray An array of bool value,
* represents the bool values you want to bind.
*/
multiBindBool(boolArray) {
if (this.bound > this.index) {
let mBindBool = super.multiBindBool(boolArray);
TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindBool);
this.index += 1;
} else {
throw new TDError(`multiBindArrBool() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`)
}
}
/**
* Used to bind tiny int column's values.
* @param {*} tinyIntArray An array of tiny int value.
* represents the tiny int values you want to bind.
*/
multiBindTinyInt(tinyIntArray) {
if (this.bound > this.index) {
let mBindTinyInt = super.multiBindTinyInt(tinyIntArray);
TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindTinyInt);
this.index += 1;
} else {
throw new TDError(`multiBindArrTinyInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`)
}
}
/**
* Used to bind small int column's value.
* @param {*} smallIntArray An array of small int values,
* represents the small int values you want to bind.
*/
multiBindSmallInt(smallIntArray) {
if (this.bound > this.index) {
let mBindSmallInt = super.multiBindSmallInt(smallIntArray);
TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindSmallInt);
this.index += 1;
} else {
throw new TDError(`multiBindSmallInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`)
}
}
/**
* Used to bind int column's value.
* @param {*} intArray An array of int values,
* represents the int values you want to bind.
*/
multiBindInt(intArray) {
if (this.bound > this.index) {
let mBindInt = super.multiBindInt(intArray);
TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindInt);
this.index += 1;
} else {
throw new TDError(`multiBindInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`)
}
}
/**
* Used to bind big int column's value.
* @param {*} bigIntArray An array of big int values,
* represents the big int values you want to bind.
*/
multiBindBigInt(bigIntArray) {
if (this.bound > this.index) {
let mBindBigInt = super.multiBindBigInt(bigIntArray);
TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindBigInt);
this.index += 1;
} else {
throw new TDError(`multiBindBigInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`)
}
}
/**
* Used to bind float column's value.
* @param {*} floatArray An array of float values,
* represents the float values you want to bind.
*/
multiBindFloat(floatArray) {
if (this.bound > this.index) {
let mBindFloat = super.multiBindFloat(floatArray);
TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindFloat);
this.index += 1;
} else {
throw new TDError(`multiBindFloat() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`)
}
}
/**
* Used to bind double column's value.
* @param {*} doubleArray An array of double values,
* represents the double values you want to bind.
*/
multiBindDouble(doubleArray) {
if (this.bound > this.index) {
let mBindDouble = super.multiBindDouble(doubleArray);
TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindDouble);
this.index += 1;
} else {
throw new TDError(`multiBindDouble() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`)
}
}
/**
* Used to bind binary column's value.
* @param {*} strArr An array of binary(string) values,
* represents the binary values you want to bind.
* Notice '' is not equal to TDengine's "null" value.
*/
multiBindBinary(strArr) {
if (this.bound > this.index) {
let mBindBinary = super.multiBindBinary(strArr);
TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindBinary);
this.index += 1;
} else {
throw new TDError(`multiBindBinary() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`)
}
}
/**
* Used to bind timestamp column's values.
* @param {*} timestampArray An array of timestamp values,
* represents the timestamp values you want to bind.
*/
multiBindTimestamp(timestampArray) {
if (this.bound > this.index) {
let mBindTimestamp = super.multiBindTimestamp(timestampArray);
TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindTimestamp);
this.index += 1;
} else {
throw new TDError(`multiBindArrTimestamp() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`)
}
}
/**
* Used to bind nchar column's value.
* @param {*} strArr An array of nchar(string) values,
* represents the nchar values you want to bind.
* Notice '' is not equal to TDengine's "null" value.
*/
multiBindNchar(strArr) {
if (this.bound > this.index) {
let mBindNchar = super.multiBindNchar(strArr);
TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindNchar);
this.index += 1;
} else {
throw new TDError(`multiBindNchar() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`)
}
}
/**
* Used to bind unsigned tiny int column's value.
* @param {*} uTinyIntArray An array of unsigned tiny int values,
* represents the unsigned tiny int values you want to bind.
*/
multiBindUTinyInt(uTinyIntArray) {
if (this.bound > this.index) {
let mBindNchar = super.multiBindUTinyInt(uTinyIntArray);
TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindNchar);
this.index += 1;
} else {
throw new TDError(`multiBindUTinyInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`)
}
}
/**
* Used to bind unsigned small int column's value.
* @param {*} uSmallIntArray An array of unsigned small int value,
* represents the unsigned small int values you want to bind.
*/
multiBindUSmallInt(uSmallIntArray) {
if (this.bound > this.index) {
let mBindUSmallInt = super.multiBindUSmallInt(uSmallIntArray);
TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindUSmallInt);
this.index += 1;
} else {
throw new TDError(`multiBindUSmallInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`)
}
}
/**
* Used to bind unsigned int column's value.
* @param {*} uIntArray An array of unsigned int column's value,
* represents the unsigned int values you want to bind.
*/
multiBindUInt(uIntArray) {
if (this.bound > this.index) {
let mBindUInt = super.multiBindUInt(uIntArray);
TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindUInt);
this.index += 1;
} else {
throw new TDError(`multiBindUInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`)
}
}
/**
* Used to bind unsigned big int column's value.
* @param {*} uBigIntArray An array of unsigned big int column's value,
* represents the unsigned big int values you want to bind.
*/
multiBindUBigInt(uBigIntArray) {
if (this.bound > this.index) {
let mBindUBigInt = super.multiBindUBigInt(uBigIntArray);
TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindUBigInt);
this.index += 1;
} else {
throw new TDError(`multiBindUBigInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`)
}
}
// multiBJson(jsonArray) no need to support.Since till now TDengine only support json tag
// and there is no need to support bind json tag in TAOS_MULTI_BIND.
/**
* After all the parameters have been prepared and stored
* in the buffer, Call this method to get the buffer.
* @returns return the buffer which stores all the parameters.
*/
getMultiBindArr() {
return this.taosMBindArrBuf;
}
}
module.exports = TaosMultiBindArr;
\ No newline at end of file
var TDengineConnection = require('./nodetaos/connection.js')
const TDengineConstant = require('./nodetaos/constants.js')
const TaosBind = require('./nodetaos/taosBind')
const { TaosMultiBind } = require('./nodetaos/taosMultiBind')
const TaosMultiBindArr = require('./nodetaos/taosMultiBindArr')
module.exports = {
connect: function (connection = {}) {
return new TDengineConnection(connection);
......@@ -8,4 +11,6 @@ module.exports = {
SCHEMALESS_PROTOCOL: TDengineConstant.SCHEMALESS_PROTOCOL,
SCHEMALESS_PRECISION: TDengineConstant.SCHEMALESS_PRECISION,
TaosBind,
TaosMultiBind,
TaosMultiBindArr,
}
\ No newline at end of file
Subproject commit 28ff2899fd0238f81c14cb76ea6dbdefa83570b3
Subproject commit ecc3f50cfb868da22c716ffbcda7b6c40c9180fa
......@@ -355,13 +355,41 @@ static int32_t mnodeGetUserMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCo
static int32_t mnodeRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
int32_t numOfRows = 0;
SUserObj *pUser = NULL;
SUserObj *userObj = NULL;
char *user = NULL;
int32_t cols = 0;
size_t len1 = 0;
size_t len2;
int32_t acctId = -1;
char *pWrite;
if (pConn) {
userObj = mnodeGetUserFromConn(pConn);
if (userObj && userObj->pAcct) {
user = userObj->pAcct->user;
if (user) {
len1 = strlen(user);
if (len1 == 0) {
user = NULL;
}
}
acctId = userObj->pAcct->acctId;
}
}
while (numOfRows < rows) {
pShow->pIter = mnodeGetNextUser(pShow->pIter, &pUser);
if (pUser == NULL) break;
if (user && pUser->pAcct) {
len2 = strlen(pUser->pAcct->user);
if ((len1 != len2 || strncmp(user, pUser->pAcct->user, len1)) && acctId != pUser->pAcct->acctId) {
continue;
}
}
cols = 0;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
......@@ -643,4 +671,4 @@ int32_t mnodeCompactUsers() {
mInfo("end to compact users table...");
return 0;
}
\ No newline at end of file
}
......@@ -807,7 +807,8 @@ int32_t filterGetFiledByData(SFilterInfo *info, int32_t type, void *v, int32_t d
return -1;
}
// In the params, we should use void *data instead of void **data, there is no need to use tfree(*data) to set *data = 0
// Besides, fields data value is a pointer, so dataLen should be POINTER_BYTES for better.
int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type, SFilterFieldId *fid, int32_t dataLen, bool freeIfExists) {
int32_t idx = -1;
uint32_t *num;
......@@ -1285,7 +1286,7 @@ int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit* u
void *data = FILTER_UNIT_VAL_DATA(src, u);
if (IS_VAR_DATA_TYPE(type)) {
if (FILTER_UNIT_OPTR(u) == TSDB_RELATION_IN) {
filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, sizeof(SHashObj), false);
filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, POINTER_BYTES, false); // POINTER_BYTES should be sizeof(SHashObj), but POINTER_BYTES is also right.
t = FILTER_GET_FIELD(dst, right);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册