提交 104455dc 编写于 作者: S slguan

Merge remote-tracking branch 'origin/develop' into feature/slguan

...@@ -359,9 +359,9 @@ SELECT function_list FROM tb_name ...@@ -359,9 +359,9 @@ SELECT function_list FROM tb_name
SELECT function_list FROM stb_name SELECT function_list FROM stb_name
[WHERE where_condition] [WHERE where_condition]
[GROUP BY tags] [FILL ({ VALUE | PREV | NULL | LINEAR})]
INTERVAL (interval) INTERVAL (interval)
[FILL ({ VALUE | PREV | NULL | LINEAR})]</code></pre> [GROUP BY tags]</code></pre>
<ul> <ul>
<li>聚合时间段的长度由关键词INTERVAL指定,最短时间间隔10毫秒(10a)。聚合查询中,能够同时执行的聚合和选择函数仅限于单个输出的函数:count、avg、sum 、stddev、leastsquares、percentile、min、max、first、last,不能使用具有多行输出结果的函数(例如:top、bottom、diff以及四则运算)。</li> <li>聚合时间段的长度由关键词INTERVAL指定,最短时间间隔10毫秒(10a)。聚合查询中,能够同时执行的聚合和选择函数仅限于单个输出的函数:count、avg、sum 、stddev、leastsquares、percentile、min、max、first、last,不能使用具有多行输出结果的函数(例如:top、bottom、diff以及四则运算)。</li>
<li>WHERE语句可以指定查询的起止时间和其他过滤条件 </li> <li>WHERE语句可以指定查询的起止时间和其他过滤条件 </li>
......
...@@ -54,7 +54,7 @@ STable从属于库,一个STable只属于一个库,但一个库可以有一 ...@@ -54,7 +54,7 @@ STable从属于库,一个STable只属于一个库,但一个库可以有一
说明: 说明:
1. TAGS列总长度不能超过512 bytes; 1. TAGS列总长度不能超过512 bytes;
2. TAGS列的数据类型不能是timestamp和nchar类型 2. TAGS列的数据类型不能是timestamp;
3. TAGS列名不能与其他列名相同; 3. TAGS列名不能与其他列名相同;
4. TAGS列名不能为预留关键字. 4. TAGS列名不能为预留关键字.
...@@ -218,7 +218,7 @@ GROUP BY location, type ...@@ -218,7 +218,7 @@ GROUP BY location, type
```mysql ```mysql
SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree) SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree)
FROM thermometer FROM thermometer
WHERE name<>'beijing' and ts>=now-1d WHERE location<>'beijing' and ts>=now-1d
INTERVAL(10M) INTERVAL(10M)
GROUP BY location, type GROUP BY location, type
``` ```
...@@ -23,7 +23,7 @@ New keyword "tags" is introduced, where tag_name is the tag name, and tag_type i ...@@ -23,7 +23,7 @@ New keyword "tags" is introduced, where tag_name is the tag name, and tag_type i
Note: Note:
1. The bytes of all tags together shall be less than 512 1. The bytes of all tags together shall be less than 512
2. Tag's data type can not be time stamp or nchar 2. Tag's data type can not be time stamp
3. Tag name shall be different from the field name 3. Tag name shall be different from the field name
4. Tag name shall not be the same as system keywords 4. Tag name shall not be the same as system keywords
5. Maximum number of tags is 6 5. Maximum number of tags is 6
...@@ -102,7 +102,7 @@ List the number of records, average, maximum, and minimum temperature every 10 m ...@@ -102,7 +102,7 @@ List the number of records, average, maximum, and minimum temperature every 10 m
```mysql ```mysql
SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree) SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree)
FROM thermometer FROM thermometer
WHERE name='beijing' and type=10 and ts>=now-1d WHERE location='beijing' and type=10 and ts>=now-1d
INTERVAL(10M) INTERVAL(10M)
``` ```
......
...@@ -424,9 +424,9 @@ SELECT function_list FROM tb_name ...@@ -424,9 +424,9 @@ SELECT function_list FROM tb_name
SELECT function_list FROM stb_name SELECT function_list FROM stb_name
[WHERE where_condition] [WHERE where_condition]
[GROUP BY tags]
INTERVAL (interval) INTERVAL (interval)
[FILL ({ VALUE | PREV | NULL | LINEAR})] [FILL ({ VALUE | PREV | NULL | LINEAR})]
[GROUP BY tags]
``` ```
- 聚合时间段的长度由关键词INTERVAL指定,最短时间间隔10毫秒(10a)。聚合查询中,能够同时执行的聚合和选择函数仅限于单个输出的函数:count、avg、sum 、stddev、leastsquares、percentile、min、max、first、last,不能使用具有多行输出结果的函数(例如:top、bottom、diff以及四则运算)。 - 聚合时间段的长度由关键词INTERVAL指定,最短时间间隔10毫秒(10a)。聚合查询中,能够同时执行的聚合和选择函数仅限于单个输出的函数:count、avg、sum 、stddev、leastsquares、percentile、min、max、first、last,不能使用具有多行输出结果的函数(例如:top、bottom、diff以及四则运算)。
......
...@@ -474,9 +474,9 @@ SELECT function_list FROM tb_name ...@@ -474,9 +474,9 @@ SELECT function_list FROM tb_name
SELECT function_list FROM stb_name SELECT function_list FROM stb_name
[WHERE where_condition] [WHERE where_condition]
[GROUP BY tags]
INTERVAL (interval) INTERVAL (interval)
[FILL ({ VALUE | PREV | NULL | LINEAR})] [FILL ({ VALUE | PREV | NULL | LINEAR})]
[GROUP BY tags]
``` ```
The downsampling time window is defined by `interval`, which is at least 10 milliseconds. The query returns a new series of downsampled data that has a series of fixed timestamps with an increment of `interval`. The downsampling time window is defined by `interval`, which is at least 10 milliseconds. The query returns a new series of downsampled data that has a series of fixed timestamps with an increment of `interval`.
......
...@@ -9,13 +9,13 @@ fi ...@@ -9,13 +9,13 @@ fi
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
if pidof systemd &> /dev/null; then if pidof systemd &> /dev/null; then
${csudo} systemctl stop taosd || : ${csudo} systemctl stop taosd || :
elif $(which insserv &> /dev/null); then elif $(which service &> /dev/null); then
${csudo} service taosd stop || :
elif $(which update-rc.d &> /dev/null); then
${csudo} service taosd stop || : ${csudo} service taosd stop || :
else else
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
fi fi
echo "Stop taosd service success!" echo "Stop taosd service success!"
sleep 1 sleep 1
......
...@@ -35,6 +35,8 @@ else ...@@ -35,6 +35,8 @@ else
${csudo} rm -f ${data_link_dir} || : ${csudo} rm -f ${data_link_dir} || :
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
fi fi
...@@ -24,8 +24,7 @@ fi ...@@ -24,8 +24,7 @@ fi
mkdir -p ${pkg_dir} mkdir -p ${pkg_dir}
cd ${pkg_dir} cd ${pkg_dir}
versioninfo=$(${script_dir}/../tools/get_version.sh ${script_dir}/../../src/util/src/version.c) libfile="libtaos.so.${tdengine_ver}"
libfile="libtaos.so.${versioninfo}"
# create install dir # create install dir
install_home_path="/usr/local/taos" install_home_path="/usr/local/taos"
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
# Generate the deb package for ubunt, or rpm package for centos, or tar.gz package for other linux os # Generate the deb package for ubunt, or rpm package for centos, or tar.gz package for other linux os
set -e set -e
#set -x # set -x
armver=$1
curr_dir=$(pwd) curr_dir=$(pwd)
script_dir="$(dirname $(readlink -f $0))" script_dir="$(dirname $(readlink -f $0))"
...@@ -110,21 +112,28 @@ echo "char gitinfo[128] = \"$(git rev-parse --verify HEAD)\";" >> ${versioninfo ...@@ -110,21 +112,28 @@ echo "char gitinfo[128] = \"$(git rev-parse --verify HEAD)\";" >> ${versioninfo
echo "char buildinfo[512] = \"Built by ${USER} at ${build_time}\";" >> ${versioninfo} echo "char buildinfo[512] = \"Built by ${USER} at ${build_time}\";" >> ${versioninfo}
# 2. cmake executable file # 2. cmake executable file
#default use debug mode
compile_mode="debug"
if [[ $1 == "Release" ]] || [[ $1 == "release" ]]; then
compile_mode="Release"
fi
compile_dir="${top_dir}/${compile_mode}" compile_dir="${top_dir}/debug"
if [ -d ${compile_dir} ]; then if [ -d ${compile_dir} ]; then
${csudo} rm -rf ${compile_dir} ${csudo} rm -rf ${compile_dir}
fi fi
${csudo} mkdir -p ${compile_dir} ${csudo} mkdir -p ${compile_dir}
cd ${compile_dir} cd ${compile_dir}
${csudo} cmake -DCMAKE_BUILD_TYPE=${compile_mode} ${top_dir}
${csudo} make # arm only support lite ver
if [ -z "$armver" ]; then
cmake ${top_dir}/../
elif [ "$armver" == "arm64" ]; then
cmake ${top_dir}/../ -DVERSION=lite -DARMVER=arm64
elif [ "$armver" == "arm32" ]; then
cmake ${top_dir}/../ -DVERSION=lite -DARMVER=arm32
else
echo "input parameter error!!!"
return
fi
make
cd ${curr_dir} cd ${curr_dir}
...@@ -153,7 +162,8 @@ ${csudo} ./makerpm.sh ${compile_dir} ${output_dir} ${version} ...@@ -153,7 +162,8 @@ ${csudo} ./makerpm.sh ${compile_dir} ${output_dir} ${version}
echo "do tar.gz package for all systems" echo "do tar.gz package for all systems"
cd ${script_dir}/tools cd ${script_dir}/tools
${csudo} ./makepkg.sh ${compile_dir} ${version} "${build_time}" ${csudo} ./makepkg.sh ${compile_dir} ${version} "${build_time}" ${armver}
${csudo} ./makeclient.sh ${compile_dir} ${version} "${build_time}" ${armver}
# 4. Clean up temporary compile directories # 4. Clean up temporary compile directories
#${csudo} rm -rf ${compile_dir} #${csudo} rm -rf ${compile_dir}
......
...@@ -39,8 +39,7 @@ echo topdir: %{_topdir} ...@@ -39,8 +39,7 @@ echo topdir: %{_topdir}
echo version: %{_version} echo version: %{_version}
echo buildroot: %{buildroot} echo buildroot: %{buildroot}
versioninfo=$(%{_compiledir}/../packaging/tools/get_version.sh ../../src/util/src/version.c) libfile="libtaos.so.%{_version}"
libfile="libtaos.so.${versioninfo}"
# create install path, and cp file # create install path, and cp file
mkdir -p %{buildroot}%{homepath}/bin mkdir -p %{buildroot}%{homepath}/bin
...@@ -80,18 +79,17 @@ fi ...@@ -80,18 +79,17 @@ fi
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
if pidof systemd &> /dev/null; then if pidof systemd &> /dev/null; then
${csudo} systemctl stop taosd || : ${csudo} systemctl stop taosd || :
elif $(which insserv &> /dev/null); then elif $(which service &> /dev/null); then
${csudo} service taosd stop || :
elif $(which update-rc.d &> /dev/null); then
${csudo} service taosd stop || : ${csudo} service taosd stop || :
else else
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
fi fi
echo "Stop taosd service success!" echo "Stop taosd service success!"
sleep 1 sleep 1
fi fi
# if taos.cfg already softlink, remove it # if taos.cfg already softlink, remove it
if [ -f %{cfg_install_dir}/taos.cfg ]; then if [ -f %{cfg_install_dir}/taos.cfg ]; then
${csudo} rm -f %{homepath}/cfg/taos.cfg || : ${csudo} rm -f %{homepath}/cfg/taos.cfg || :
...@@ -146,7 +144,9 @@ if [ $1 -eq 0 ];then ...@@ -146,7 +144,9 @@ if [ $1 -eq 0 ];then
${csudo} rm -f ${data_link_dir} || : ${csudo} rm -f ${data_link_dir} || :
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
fi fi
fi fi
......
#!/bin/bash #!/bin/bash
# #
# This file is used to install TAOS time-series database on linux systems. The operating system # This file is used to install database on linux systems. The operating system
# is required to use systemd to manage services at boot # is required to use systemd to manage services at boot
set -e set -e
...@@ -41,19 +41,58 @@ if command -v sudo > /dev/null; then ...@@ -41,19 +41,58 @@ if command -v sudo > /dev/null; then
csudo="sudo" csudo="sudo"
fi fi
initd_mod=0
service_mod=2 service_mod=2
if pidof systemd &> /dev/null; then if pidof systemd &> /dev/null; then
service_mod=0 service_mod=0
elif $(which update-rc.d &> /dev/null); then elif $(which service &> /dev/null); then
service_mod=1 service_mod=1
service_config_dir="/etc/init.d" service_config_dir="/etc/init.d"
if $(which chkconfig &> /dev/null); then
initd_mod=1
elif $(which insserv &> /dev/null); then
initd_mod=2
elif $(which update-rc.d &> /dev/null); then
initd_mod=3
else
service_mod=2
fi
else else
service_mod=2 service_mod=2
fi fi
# get the operating system type for using the corresponding init file
# ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification
#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2)
#echo "osinfo: ${osinfo}"
os_type=0
if echo $osinfo | grep -qwi "ubuntu" ; then
echo "this is ubuntu system"
os_type=1
elif echo $osinfo | grep -qwi "debian" ; then
echo "this is debian system"
os_type=1
elif echo $osinfo | grep -qwi "Kylin" ; then
echo "this is Kylin system"
os_type=1
elif echo $osinfo | grep -qwi "centos" ; then
echo "this is centos system"
os_type=2
elif echo $osinfo | grep -qwi "fedora" ; then
echo "this is fedora system"
os_type=2
else
echo "this is other linux system"
os_type=0
fi
function kill_taosd() { function kill_taosd() {
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 pid || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
} }
function install_main_path() { function install_main_path() {
...@@ -81,7 +120,7 @@ function install_bin() { ...@@ -81,7 +120,7 @@ function install_bin() {
#Make link #Make link
[ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || : [ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || :
[ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || : [ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || :
[ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : [ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
[ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || :
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || :
...@@ -89,7 +128,7 @@ function install_bin() { ...@@ -89,7 +128,7 @@ function install_bin() {
function install_lib() { function install_lib() {
# Remove links # Remove links
${csudo} rm -f ${lib_link_dir}/libtaos.* || : ${csudo} rm -f ${lib_link_dir}/libtaos.* || :
${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
...@@ -98,7 +137,7 @@ function install_lib() { ...@@ -98,7 +137,7 @@ function install_lib() {
} }
function install_header() { function install_header() {
${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || :
${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/*
${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
...@@ -107,16 +146,17 @@ function install_header() { ...@@ -107,16 +146,17 @@ function install_header() {
function install_config() { function install_config() {
#${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || : #${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || :
if [ ! -f ${cfg_install_dir}/taos.cfg ]; then if [ ! -f ${cfg_install_dir}/taos.cfg ]; then
${csudo} mkdir -p ${cfg_install_dir} ${csudo} mkdir -p ${cfg_install_dir}
[ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir} [ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir}
${csudo} chmod 644 ${cfg_install_dir}/* ${csudo} chmod 644 ${cfg_install_dir}/*
fi fi
${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org ${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org
${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg
} }
function install_log() { function install_log() {
${csudo} rm -rf ${log_dir} || : ${csudo} rm -rf ${log_dir} || :
${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir}
...@@ -139,14 +179,26 @@ function install_examples() { ...@@ -139,14 +179,26 @@ function install_examples() {
} }
function clean_service_on_sysvinit() { function clean_service_on_sysvinit() {
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
#${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
${csudo} service taosd stop || : ${csudo} service taosd stop || :
fi fi
${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
if ((${initd_mod}==1)); then
${csudo} chkconfig --del taosd || :
elif ((${initd_mod}==2)); then
${csudo} insserv -r taosd || :
elif ((${initd_mod}==3)); then
${csudo} update-rc.d -f taosd remove || :
fi
${csudo} rm -f ${service_config_dir}/taosd || : ${csudo} rm -f ${service_config_dir}/taosd || :
${csudo} update-rc.d -f taosd remove || :
${csudo} init q || : if $(which init &> /dev/null); then
${csudo} init q || :
fi
} }
function install_service_on_sysvinit() { function install_service_on_sysvinit() {
...@@ -155,14 +207,27 @@ function install_service_on_sysvinit() { ...@@ -155,14 +207,27 @@ function install_service_on_sysvinit() {
sleep 1 sleep 1
# Install taosd service # Install taosd service
${csudo} cp -f ${script_dir}/init.d/taosd ${install_main_dir}/init.d
${csudo} cp ${script_dir}/init.d/taosd ${service_config_dir} && ${csudo} chmod a+x ${service_config_dir}/taosd if ((${os_type}==1)); then
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" ${csudo} cp -f ${script_dir}/init.d/taosd.deb ${install_main_dir}/init.d/taosd
${csudo} cp ${script_dir}/init.d/taosd.deb ${service_config_dir}/taosd && ${csudo} chmod a+x ${service_config_dir}/taosd
${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab" elif ((${os_type}==2)); then
# TODO: for centos, change here ${csudo} cp -f ${script_dir}/init.d/taosd.rpm ${install_main_dir}/init.d/taosd
${csudo} update-rc.d taosd defaults ${csudo} cp ${script_dir}/init.d/taosd.rpm ${service_config_dir}/taosd && ${csudo} chmod a+x ${service_config_dir}/taosd
# chkconfig mysqld on fi
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
#${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab"
if ((${initd_mod}==1)); then
${csudo} chkconfig --add taosd || :
${csudo} chkconfig --level 2345 taosd on || :
elif ((${initd_mod}==2)); then
${csudo} insserv taosd || :
${csudo} insserv -d taosd || :
elif ((${initd_mod}==3)); then
${csudo} update-rc.d taosd defaults || :
fi
} }
function clean_service_on_systemd() { function clean_service_on_systemd() {
...@@ -212,7 +277,7 @@ function install_service() { ...@@ -212,7 +277,7 @@ function install_service() {
elif ((${service_mod}==1)); then elif ((${service_mod}==1)); then
install_service_on_sysvinit install_service_on_sysvinit
else else
# must manual start taosd # must manual stop taosd
kill_taosd kill_taosd
fi fi
} }
...@@ -266,7 +331,7 @@ function update_TDengine() { ...@@ -266,7 +331,7 @@ function update_TDengine() {
echo "File taos.tar.gz does not exist" echo "File taos.tar.gz does not exist"
exit 1 exit 1
fi fi
tar -zxf taos.tar.gz tar -zxf taos.tar.gz
# Check if version compatible # Check if version compatible
if ! is_version_compatible; then if ! is_version_compatible; then
...@@ -274,7 +339,7 @@ function update_TDengine() { ...@@ -274,7 +339,7 @@ function update_TDengine() {
return 1 return 1
fi fi
echo -e "${GREEN}Start to update TDEngine...${NC}" echo -e "${GREEN}Start to update TDengine...${NC}"
# Stop the service if running # Stop the service if running
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
if ((${service_mod}==0)); then if ((${service_mod}==0)); then
...@@ -306,8 +371,7 @@ function update_TDengine() { ...@@ -306,8 +371,7 @@ function update_TDengine() {
if ((${service_mod}==0)); then if ((${service_mod}==0)); then
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}"
elif ((${service_mod}==1)); then elif ((${service_mod}==1)); then
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} update-rc.d taosd default ${RED} for the first time${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} service taosd start${NC}"
echo -e " : ${csudo} service taosd start ${RED} after${NC}"
else else
echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}"
fi fi
...@@ -316,7 +380,7 @@ function update_TDengine() { ...@@ -316,7 +380,7 @@ function update_TDengine() {
echo echo
echo -e "\033[44;32;1mTDengine is updated successfully!${NC}" echo -e "\033[44;32;1mTDengine is updated successfully!${NC}"
else else
install_bin $1 install_bin
install_config install_config
echo echo
...@@ -332,9 +396,9 @@ function install_TDengine() { ...@@ -332,9 +396,9 @@ function install_TDengine() {
echo "File taos.tar.gz does not exist" echo "File taos.tar.gz does not exist"
exit 1 exit 1
fi fi
tar -zxf taos.tar.gz tar -zxf taos.tar.gz
echo -e "${GREEN}Start to install TDEngine...${NC}" echo -e "${GREEN}Start to install TDengine...${NC}"
install_main_path install_main_path
...@@ -362,10 +426,9 @@ function install_TDengine() { ...@@ -362,10 +426,9 @@ function install_TDengine() {
if ((${service_mod}==0)); then if ((${service_mod}==0)); then
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}"
elif ((${service_mod}==1)); then elif ((${service_mod}==1)); then
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} update-rc.d taosd default ${RED} for the first time${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} service taosd start${NC}"
echo -e " : ${csudo} service taosd start ${RED} after${NC}"
else else
echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: taosd${NC}"
fi fi
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}" echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}"
......
#!/bin/bash #!/bin/bash
#
# This file is used to install TDengine client on linux systems. The operating system
# is required to use systemd to manage services at boot
set -e
#set -x
# -----------------------Variables definition---------------------
script_dir=$(dirname $(readlink -m "$0")) script_dir=$(dirname $(readlink -m "$0"))
${script_dir}/install.sh client # Dynamic directory
data_dir="/var/lib/taos"
log_dir="/var/log/taos"
log_link_dir="/usr/local/taos/log"
cfg_install_dir="/etc/taos"
bin_link_dir="/usr/bin"
lib_link_dir="/usr/lib"
inc_link_dir="/usr/include"
#install main path
install_main_dir="/usr/local/taos"
# old bin dir
bin_dir="/usr/local/taos/bin"
# Color setting
RED='\033[0;31m'
GREEN='\033[1;32m'
GREEN_DARK='\033[0;32m'
GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m'
csudo=""
if command -v sudo > /dev/null; then
csudo="sudo"
fi
update_flag=0
function kill_client() {
pid=$(ps -ef | grep "taos" | grep -v "grep" | awk '{print $2}')
if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
}
function install_main_path() {
#create install main dir and all sub dir
${csudo} rm -rf ${install_main_dir} || :
${csudo} mkdir -p ${install_main_dir}
${csudo} mkdir -p ${install_main_dir}/cfg
${csudo} mkdir -p ${install_main_dir}/bin
${csudo} mkdir -p ${install_main_dir}/connector
${csudo} mkdir -p ${install_main_dir}/driver
${csudo} mkdir -p ${install_main_dir}/examples
${csudo} mkdir -p ${install_main_dir}/include
}
function install_bin() {
# Remove links
${csudo} rm -f ${bin_link_dir}/taos || :
${csudo} rm -f ${bin_link_dir}/taosdump || :
${csudo} rm -f ${bin_link_dir}/rmtaos || :
${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/*
#Make link
[ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || :
[ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
[ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/rmtaos || :
}
function clean_lib() {
sudo rm -f /usr/lib/libtaos.so || :
sudo rm -rf ${lib_dir} || :
}
function install_lib() {
# Remove links
${csudo} rm -f ${lib_link_dir}/libtaos.* || :
${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
}
function install_header() {
${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || :
${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/*
${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
}
function install_config() {
#${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || :
if [ ! -f ${cfg_install_dir}/taos.cfg ]; then
${csudo} mkdir -p ${cfg_install_dir}
[ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir}
${csudo} chmod 644 ${cfg_install_dir}/*
fi
${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org
${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg
}
function install_log() {
${csudo} rm -rf ${log_dir} || :
${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir}
${csudo} ln -s ${log_dir} ${install_main_dir}/log
}
function install_connector() {
${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector
}
function install_examples() {
if [ -d ${script_dir}/examples ]; then
${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples
fi
}
function update_TDengine() {
# Start to update
if [ ! -e taos.tar.gz ]; then
echo "File taos.tar.gz does not exist"
exit 1
fi
tar -zxf taos.tar.gz
echo -e "${GREEN}Start to update TDengine client...${NC}"
# Stop the client shell if running
if pidof taos &> /dev/null; then
kill_client
sleep 1
fi
install_main_path
install_log
install_header
install_lib
install_connector
install_examples
install_bin
install_config
echo
echo -e "\033[44;32;1mTDengine client is updated successfully!${NC}"
rm -rf $(tar -tf taos.tar.gz)
}
function install_TDengine() {
# Start to install
if [ ! -e taos.tar.gz ]; then
echo "File taos.tar.gz does not exist"
exit 1
fi
tar -zxf taos.tar.gz
echo -e "${GREEN}Start to install TDengine client...${NC}"
install_main_path
install_log
install_header
install_lib
install_connector
install_examples
install_bin
install_config
echo
echo -e "\033[44;32;1mTDengine client is installed successfully!${NC}"
rm -rf $(tar -tf taos.tar.gz)
}
## ==============================Main program starts from here============================
# Install or updata client and client
# if server is already install, don't install client
if [ -e ${bin_dir}/taosd ]; then
echo -e "\033[44;32;1mThere are already installed TDengine server, so don't need install client!${NC}"
exit 0
fi
if [ -x ${bin_dir}/taos ]; then
update_flag=1
update_TDengine
else
install_TDengine
fi
#!/bin/bash
#
# Generate tar.gz package for linux client
set -e
set -x
curr_dir=$(pwd)
compile_dir=$1
version=$2
build_time=$3
armver=$4
script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -m ${script_dir}/../..)"
# create compressed install file.
build_dir="${compile_dir}/build"
code_dir="${top_dir}/src"
release_dir="${top_dir}/release"
community_dir="${script_dir}/../../../community/src"
package_name='linux'
install_dir="${release_dir}/TDengine-client-enterprise-${version}-${package_name}-$(echo ${build_time}| tr ': ' -)"
# Directories and files.
bin_files="${build_dir}/bin/taos ${build_dir}/bin/taosdump ${script_dir}/remove_client.sh"
lib_files="${build_dir}/lib/libtaos.so.${version}"
header_files="${community_dir}/inc/taos.h ${community_dir}/inc/taoserror.h"
cfg_dir="${top_dir}/packaging/cfg"
install_files="${script_dir}/install_client.sh"
# make directories.
mkdir -p ${install_dir}
mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc
mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/taos.cfg ${install_dir}/cfg/taos.cfg
mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/*
cd ${install_dir}
tar -zcv -f taos.tar.gz * --remove-files || :
cd ${curr_dir}
cp ${install_files} ${install_dir} && chmod a+x ${install_dir}/install*
# Copy example code
mkdir -p ${install_dir}/examples
cp -r ${top_dir}/tests/examples/c ${install_dir}/examples
cp -r ${top_dir}/tests/examples/JDBC ${install_dir}/examples
cp -r ${top_dir}/tests/examples/matlab ${install_dir}/examples
cp -r ${top_dir}/tests/examples/python ${install_dir}/examples
cp -r ${top_dir}/tests/examples/R ${install_dir}/examples
cp -r ${top_dir}/tests/examples/go ${install_dir}/examples
# Copy driver
mkdir -p ${install_dir}/driver
cp ${lib_files} ${install_dir}/driver
# Copy connector
connector_dir="${community_dir}/connector"
mkdir -p ${install_dir}/connector
cp ${build_dir}/lib/*.jar ${install_dir}/connector
cp -r ${connector_dir}/grafana ${install_dir}/connector/
cp -r ${connector_dir}/python ${install_dir}/connector/
cp -r ${connector_dir}/go ${install_dir}/connector
# Copy release note
# cp ${script_dir}/release_note ${install_dir}
# exit 1
cd ${release_dir}
if [ -z "$armver" ]; then
tar -zcv -f "$(basename ${install_dir}).tar.gz" $(basename ${install_dir}) --remove-files
elif [ "$armver" == "arm64" ]; then
tar -zcv -f "$(basename ${install_dir})-arm64.tar.gz" $(basename ${install_dir}) --remove-files
elif [ "$armver" == "arm32" ]; then
tar -zcv -f "$(basename ${install_dir})-arm32.tar.gz" $(basename ${install_dir}) --remove-files
fi
cd ${curr_dir}
...@@ -6,6 +6,7 @@ curr_dir=$(pwd) ...@@ -6,6 +6,7 @@ curr_dir=$(pwd)
compile_dir=$1 compile_dir=$1
version=$2 version=$2
build_time=$3 build_time=$3
armver=$4
script_dir="$(dirname $(readlink -f $0))" script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -m ${script_dir}/../..)" top_dir="$(readlink -m ${script_dir}/../..)"
...@@ -20,11 +21,10 @@ install_dir="${release_dir}/taos-${version}-${package_name}-$(echo ${build_time} ...@@ -20,11 +21,10 @@ install_dir="${release_dir}/taos-${version}-${package_name}-$(echo ${build_time}
# Directories and files. # Directories and files.
bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${build_dir}/bin/taosdump ${script_dir}/remove.sh" bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${build_dir}/bin/taosdump ${script_dir}/remove.sh"
versioninfo=$(${script_dir}/get_version.sh ${code_dir}/util/src/version.c) lib_files="${build_dir}/lib/libtaos.so.${version}"
lib_files="${build_dir}/lib/libtaos.so.${versioninfo}"
header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taoserror.h" header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taoserror.h"
cfg_files="${top_dir}/packaging/cfg/*.cfg" cfg_dir="${top_dir}/packaging/cfg"
install_files="${script_dir}/install.sh ${script_dir}/install_client.sh" install_files="${script_dir}/install.sh"
# Init file # Init file
#init_dir=${script_dir}/deb #init_dir=${script_dir}/deb
...@@ -33,29 +33,32 @@ install_files="${script_dir}/install.sh ${script_dir}/install_client.sh" ...@@ -33,29 +33,32 @@ install_files="${script_dir}/install.sh ${script_dir}/install_client.sh"
#fi #fi
#init_files=${init_dir}/taosd #init_files=${init_dir}/taosd
# temp use rpm's taosd. TODO: later modify according to os type # temp use rpm's taosd. TODO: later modify according to os type
init_files=${script_dir}/../rpm/taosd init_file_deb=${script_dir}/../deb/taosd
init_file_rpm=${script_dir}/../rpm/taosd
# make directories. # make directories.
mkdir -p ${install_dir} mkdir -p ${install_dir}
mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc
mkdir -p ${install_dir}/cfg && cp ${cfg_files} ${install_dir}/cfg mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/taos.cfg ${install_dir}/cfg/taos.cfg
mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/* mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/*
mkdir -p ${install_dir}/init.d && cp ${init_files} ${install_dir}/init.d mkdir -p ${install_dir}/init.d && cp ${init_file_deb} ${install_dir}/init.d/taosd.deb
mkdir -p ${install_dir}/init.d && cp ${init_file_rpm} ${install_dir}/init.d/taosd.rpm
cd ${install_dir} cd ${install_dir}
tar -zcv -f taos.tar.gz * --remove-files || : tar -zcv -f taos.tar.gz * --remove-files || :
cd ${curr_dir} cd ${curr_dir}
cp ${install_files} ${install_dir} && chmod a+x ${install_dir}/install* cp ${install_files} ${install_dir} && chmod a+x ${install_dir}/install*
# Copy example code # Copy example code
mkdir -p ${install_dir}/examples mkdir -p ${install_dir}/examples
cp -r ${top_dir}/tests/examples/c ${install_dir}/examples examples_dir="${top_dir}/tests/examples"
cp -r ${top_dir}/tests/examples/JDBC ${install_dir}/examples cp -r ${examples_dir}/c ${install_dir}/examples
cp -r ${top_dir}/tests/examples/matlab ${install_dir}/examples cp -r ${examples_dir}/JDBC ${install_dir}/examples
cp -r ${top_dir}/tests/examples/python ${install_dir}/examples cp -r ${examples_dir}/matlab ${install_dir}/examples
cp -r ${top_dir}/tests/examples/R ${install_dir}/examples cp -r ${examples_dir}/python ${install_dir}/examples
cp -r ${top_dir}/tests/examples/go ${install_dir}/examples cp -r ${examples_dir}/R ${install_dir}/examples
cp -r ${examples_dir}/go ${install_dir}/examples
# Copy driver # Copy driver
mkdir -p ${install_dir}/driver mkdir -p ${install_dir}/driver
...@@ -64,18 +67,23 @@ cp ${lib_files} ${install_dir}/driver ...@@ -64,18 +67,23 @@ cp ${lib_files} ${install_dir}/driver
# Copy connector # Copy connector
connector_dir="${code_dir}/connector" connector_dir="${code_dir}/connector"
mkdir -p ${install_dir}/connector mkdir -p ${install_dir}/connector
cp ${build_dir}/lib/*.jar ${install_dir}/connector
cp -r ${connector_dir}/grafana ${install_dir}/connector/ cp -r ${connector_dir}/grafana ${install_dir}/connector/
cp -r ${connector_dir}/python ${install_dir}/connector/ cp -r ${connector_dir}/python ${install_dir}/connector/
cp -r ${connector_dir}/go ${install_dir}/connector cp -r ${connector_dir}/go ${install_dir}/connector
cp ${build_dir}/lib/*.jar ${install_dir}/connector
# Copy release note # Copy release note
cp ${script_dir}/release_note ${install_dir} # cp ${script_dir}/release_note ${install_dir}
# exit 1 # exit 1
cd ${release_dir} cd ${release_dir}
tar -zcv -f "$(basename ${install_dir}).tar.gz" $(basename ${install_dir}) --remove-files if [ -z "$armver" ]; then
tar -zcv -f "$(basename ${install_dir}).tar.gz" $(basename ${install_dir}) --remove-files
elif [ "$armver" == "arm64" ]; then
tar -zcv -f "$(basename ${install_dir})-arm64.tar.gz" $(basename ${install_dir}) --remove-files
elif [ "$armver" == "arm32" ]; then
tar -zcv -f "$(basename ${install_dir})-arm32.tar.gz" $(basename ${install_dir}) --remove-files
fi
cd ${curr_dir} cd ${curr_dir}
...@@ -42,14 +42,18 @@ initd_mod=0 ...@@ -42,14 +42,18 @@ initd_mod=0
service_mod=2 service_mod=2
if pidof systemd &> /dev/null; then if pidof systemd &> /dev/null; then
service_mod=0 service_mod=0
elif $(which insserv &> /dev/null); then elif $(which service &> /dev/null); then
service_mod=1 service_mod=1
initd_mod=1 service_config_dir="/etc/init.d"
service_config_dir="/etc/init.d" if $(which chkconfig &> /dev/null); then
elif $(which update-rc.d &> /dev/null); then initd_mod=1
service_mod=1 elif $(which insserv &> /dev/null); then
initd_mod=2 initd_mod=2
service_config_dir="/etc/init.d" elif $(which update-rc.d &> /dev/null); then
initd_mod=3
else
service_mod=2
fi
else else
service_mod=2 service_mod=2
fi fi
...@@ -57,7 +61,9 @@ fi ...@@ -57,7 +61,9 @@ fi
function kill_taosd() { function kill_taosd() {
# ${csudo} pkill -f taosd || : # ${csudo} pkill -f taosd || :
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
} }
function install_include() { function install_include() {
...@@ -103,20 +109,26 @@ function install_config() { ...@@ -103,20 +109,26 @@ function install_config() {
} }
function clean_service_on_sysvinit() { function clean_service_on_sysvinit() {
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
#${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
${csudo} service taosd stop || : ${csudo} service taosd stop || :
fi fi
${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
${csudo} rm -f ${service_config_dir}/taosd || :
if ((${initd_mod}==1)); then if ((${initd_mod}==1)); then
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} insserv -r taosd || : ${csudo} chkconfig --del taosd || :
elif ((${initd_mod}==2)); then elif ((${initd_mod}==2)); then
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} update-rc.d -f taosd remove || : ${csudo} insserv -r taosd || :
elif ((${initd_mod}==3)); then
${csudo} update-rc.d -f taosd remove || :
fi
${csudo} rm -f ${service_config_dir}/taosd || :
if $(which init &> /dev/null); then
${csudo} init q || :
fi fi
# ${csudo} update-rc.d -f taosd remove || :
${csudo} init q || :
} }
function install_service_on_sysvinit() { function install_service_on_sysvinit() {
...@@ -127,18 +139,24 @@ function install_service_on_sysvinit() { ...@@ -127,18 +139,24 @@ function install_service_on_sysvinit() {
# Install taosd service # Install taosd service
${csudo} cp %{init_d_dir}/taosd ${service_config_dir} && ${csudo} chmod a+x ${service_config_dir}/taosd ${csudo} cp %{init_d_dir}/taosd ${service_config_dir} && ${csudo} chmod a+x ${service_config_dir}/taosd
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
#${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab"
${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab"
# TODO: for centos, change here if ((${initd_mod}==1)); then
${csudo} update-rc.d taosd defaults ${csudo} chkconfig --add taosd || :
# chkconfig mysqld on ${csudo} chkconfig --level 2345 taosd on || :
elif ((${initd_mod}==2)); then
${csudo} insserv taosd || :
${csudo} insserv -d taosd || :
elif ((${initd_mod}==3)); then
${csudo} update-rc.d taosd defaults || :
fi
} }
function clean_service_on_systemd() { function clean_service_on_systemd() {
taosd_service_config="${service_config_dir}/taosd.service" taosd_service_config="${service_config_dir}/taosd.service"
# taosd service already is stoped before install # taosd service already is stoped before install in preinst script
#if systemctl is-active --quiet taosd; then #if systemctl is-active --quiet taosd; then
# echo "TDengine is running, stopping it..." # echo "TDengine is running, stopping it..."
# ${csudo} systemctl stop taosd &> /dev/null || echo &> /dev/null # ${csudo} systemctl stop taosd &> /dev/null || echo &> /dev/null
......
...@@ -26,22 +26,27 @@ initd_mod=0 ...@@ -26,22 +26,27 @@ initd_mod=0
service_mod=2 service_mod=2
if pidof systemd &> /dev/null; then if pidof systemd &> /dev/null; then
service_mod=0 service_mod=0
elif $(which insserv &> /dev/null); then elif $(which service &> /dev/null); then
service_mod=1 service_mod=1
initd_mod=1 service_config_dir="/etc/init.d"
service_config_dir="/etc/init.d" if $(which chkconfig &> /dev/null); then
elif $(which update-rc.d &> /dev/null); then initd_mod=1
service_mod=1 elif $(which insserv &> /dev/null); then
initd_mod=2 initd_mod=2
service_config_dir="/etc/init.d" elif $(which update-rc.d &> /dev/null); then
initd_mod=3
else
service_mod=2
fi
else else
service_mod=2 service_mod=2
fi fi
function kill_taosd() { function kill_taosd() {
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
} }
function clean_service_on_systemd() { function clean_service_on_systemd() {
...@@ -57,20 +62,27 @@ function clean_service_on_systemd() { ...@@ -57,20 +62,27 @@ function clean_service_on_systemd() {
} }
function clean_service_on_sysvinit() { function clean_service_on_sysvinit() {
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
#${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
echo "TDengine taosd is running, stopping it..."
${csudo} service taosd stop || : ${csudo} service taosd stop || :
fi fi
${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
${csudo} rm -f ${service_config_dir}/taosd || :
if ((${initd_mod}==1)); then if ((${initd_mod}==1)); then
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} insserv -r taosd || : ${csudo} chkconfig --del taosd || :
elif ((${initd_mod}==2)); then elif ((${initd_mod}==2)); then
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} update-rc.d -f taosd remove || : ${csudo} insserv -r taosd || :
elif ((${initd_mod}==3)); then
${csudo} update-rc.d -f taosd remove || :
fi
${csudo} rm -f ${service_config_dir}/taosd || :
if $(which init &> /dev/null); then
${csudo} init q || :
fi fi
# ${csudo} update-rc.d -f taosd remove || :
${csudo} init q || :
} }
function clean_service() { function clean_service() {
...@@ -79,7 +91,7 @@ function clean_service() { ...@@ -79,7 +91,7 @@ function clean_service() {
elif ((${service_mod}==1)); then elif ((${service_mod}==1)); then
clean_service_on_sysvinit clean_service_on_sysvinit
else else
# must manual start taosd # must manual stop taosd
kill_taosd kill_taosd
fi fi
} }
......
#!/bin/bash #!/bin/bash
# #
# Script to stop the service and uninstall tdengine, but retain the config, data and log files. # Script to stop the service and uninstall TDengine, but retain the config, data and log files.
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[1;32m' GREEN='\033[1;32m'
...@@ -27,21 +27,27 @@ initd_mod=0 ...@@ -27,21 +27,27 @@ initd_mod=0
service_mod=2 service_mod=2
if pidof systemd &> /dev/null; then if pidof systemd &> /dev/null; then
service_mod=0 service_mod=0
elif $(which insserv &> /dev/null); then elif $(which service &> /dev/null); then
service_mod=1 service_mod=1
initd_mod=1 service_config_dir="/etc/init.d"
service_config_dir="/etc/init.d" if $(which chkconfig &> /dev/null); then
elif $(which update-rc.d &> /dev/null); then initd_mod=1
service_mod=1 elif $(which insserv &> /dev/null); then
initd_mod=2 initd_mod=2
service_config_dir="/etc/init.d" elif $(which update-rc.d &> /dev/null); then
initd_mod=3
else
service_mod=2
fi
else else
service_mod=2 service_mod=2
fi fi
function kill_taosd() { function kill_taosd() {
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
} }
function clean_bin() { function clean_bin() {
...@@ -87,20 +93,27 @@ function clean_service_on_systemd() { ...@@ -87,20 +93,27 @@ function clean_service_on_systemd() {
} }
function clean_service_on_sysvinit() { function clean_service_on_sysvinit() {
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
#${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
echo "TDengine taosd is running, stopping it..."
${csudo} service taosd stop || : ${csudo} service taosd stop || :
fi fi
${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
${csudo} rm -f ${service_config_dir}/taosd || :
if ((${initd_mod}==1)); then if ((${initd_mod}==1)); then
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} insserv -r taosd || : ${csudo} chkconfig --del taosd || :
elif ((${initd_mod}==2)); then elif ((${initd_mod}==2)); then
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} update-rc.d -f taosd remove || : ${csudo} insserv -r taosd || :
elif ((${initd_mod}==3)); then
${csudo} update-rc.d -f taosd remove || :
fi
${csudo} rm -f ${service_config_dir}/taosd || :
if $(which init &> /dev/null); then
${csudo} init q || :
fi fi
# ${csudo} update-rc.d -f taosd remove || :
${csudo} init q || :
} }
function clean_service() { function clean_service() {
...@@ -109,7 +122,7 @@ function clean_service() { ...@@ -109,7 +122,7 @@ function clean_service() {
elif ((${service_mod}==1)); then elif ((${service_mod}==1)); then
clean_service_on_sysvinit clean_service_on_sysvinit
else else
# must manual start taosd # must manual stop taosd
kill_taosd kill_taosd
fi fi
} }
...@@ -140,4 +153,4 @@ elif echo $osinfo | grep -qwi "centos" ; then ...@@ -140,4 +153,4 @@ elif echo $osinfo | grep -qwi "centos" ; then
${csudo} rpm -e --noscripts tdengine || : ${csudo} rpm -e --noscripts tdengine || :
fi fi
echo -e "${GREEN}TDEngine is removed successfully!${NC}" echo -e "${GREEN}TDengine is removed successfully!${NC}"
#!/bin/bash
#
# Script to stop the client and uninstall database, but retain the config and log files.
set -e
# set -x
RED='\033[0;31m'
GREEN='\033[1;32m'
NC='\033[0m'
#install main path
install_main_dir="/usr/local/taos"
log_link_dir="/usr/local/taos/log"
cfg_link_dir="/usr/local/taos/cfg"
bin_link_dir="/usr/bin"
lib_link_dir="/usr/lib"
inc_link_dir="/usr/include"
csudo=""
if command -v sudo > /dev/null; then
csudo="sudo"
fi
function kill_client() {
#pid=$(ps -ef | grep "taos" | grep -v "grep" | awk '{print $2}')
if [ -n "$(pidof taos)" ]; then
${csudo} kill -9 $pid || :
fi
}
function clean_bin() {
# Remove link
${csudo} rm -f ${bin_link_dir}/taos || :
${csudo} rm -f ${bin_link_dir}/taosump || :
${csudo} rm -f ${bin_link_dir}/rmtaos || :
}
function clean_lib() {
# Remove link
${csudo} rm -f ${lib_link_dir}/libtaos.* || :
}
function clean_header() {
# Remove link
${csudo} rm -f ${inc_link_dir}/taos.h || :
${csudo} rm -f ${inc_link_dir}/taoserror.h || :
}
function clean_config() {
# Remove link
${csudo} rm -f ${cfg_link_dir}/* || :
}
function clean_log() {
# Remove link
${csudo} rm -rf ${log_link_dir} || :
}
# Stop client.
kill_client
# Remove binary file and links
clean_bin
# Remove header file.
clean_header
# Remove lib file
clean_lib
# Remove link log directory
clean_log
# Remove link configuration file
clean_config
${csudo} rm -rf ${install_main_dir}
echo -e "${GREEN}TDengine client is removed successfully!${NC}"
...@@ -24,9 +24,9 @@ void *taosOpenConnCache(int maxSessions, void (*cleanFp)(void *), void *tmrCtrl, ...@@ -24,9 +24,9 @@ void *taosOpenConnCache(int maxSessions, void (*cleanFp)(void *), void *tmrCtrl,
void taosCloseConnCache(void *handle); void taosCloseConnCache(void *handle);
void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, char *user); void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, uint16_t port, char *user);
void *taosGetConnFromCache(void *handle, uint32_t ip, short port, char *user); void *taosGetConnFromCache(void *handle, uint32_t ip, uint16_t port, char *user);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -106,6 +106,8 @@ void tscAddSpecialColumnForSelect(SSqlCmd* pCmd, int32_t outputColIndex, int16_t ...@@ -106,6 +106,8 @@ void tscAddSpecialColumnForSelect(SSqlCmd* pCmd, int32_t outputColIndex, int16_t
SSchema* pColSchema, int16_t isTag); SSchema* pColSchema, int16_t isTag);
void addRequiredTagColumn(SSqlCmd* pCmd, int32_t tagColIndex, int32_t tableIndex); void addRequiredTagColumn(SSqlCmd* pCmd, int32_t tagColIndex, int32_t tableIndex);
//TODO refactor, remove
void SStringFree(SString* str); void SStringFree(SString* str);
void SStringCopy(SString* pDest, const SString* pSrc); void SStringCopy(SString* pDest, const SString* pSrc);
SString SStringCreate(const char* str); SString SStringCreate(const char* str);
...@@ -125,7 +127,7 @@ int tscAllocPayload(SSqlCmd* pCmd, int size); ...@@ -125,7 +127,7 @@ int tscAllocPayload(SSqlCmd* pCmd, int size);
void tscFieldInfoSetValFromSchema(SFieldInfo* pFieldInfo, int32_t index, SSchema* pSchema); void tscFieldInfoSetValFromSchema(SFieldInfo* pFieldInfo, int32_t index, SSchema* pSchema);
void tscFieldInfoSetValFromField(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* pField); void tscFieldInfoSetValFromField(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* pField);
void tscFieldInfoSetValue(SFieldInfo* pFieldInfo, int32_t index, int8_t type, char* name, int16_t bytes); void tscFieldInfoSetValue(SFieldInfo* pFieldInfo, int32_t index, int8_t type, const char* name, int16_t bytes);
void tscFieldInfoUpdateVisible(SFieldInfo* pFieldInfo, int32_t index, bool visible); void tscFieldInfoUpdateVisible(SFieldInfo* pFieldInfo, int32_t index, bool visible);
void tscFieldInfoCalOffset(SSqlCmd* pCmd); void tscFieldInfoCalOffset(SSqlCmd* pCmd);
...@@ -141,7 +143,9 @@ void tscClearFieldInfo(SFieldInfo* pFieldInfo); ...@@ -141,7 +143,9 @@ void tscClearFieldInfo(SFieldInfo* pFieldInfo);
void addExprParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t bytes, int16_t tableIndex); void addExprParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t bytes, int16_t tableIndex);
SSqlExpr* tscSqlExprInsert(SSqlCmd* pCmd, int32_t index, int16_t functionId, SColumnIndex* pColIndex, int16_t type, SSqlExpr* tscSqlExprInsert(SSqlCmd* pCmd, int32_t index, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
int16_t size, /*int16_t colId,*/ int16_t interSize); int16_t size, int16_t interSize);
SSqlExpr* tscSqlExprInsertEmpty(SSqlCmd* pCmd, int32_t index, int16_t functionId);
SSqlExpr* tscSqlExprUpdate(SSqlCmd* pCmd, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type, SSqlExpr* tscSqlExprUpdate(SSqlCmd* pCmd, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type,
int16_t size); int16_t size);
...@@ -224,7 +228,7 @@ void doAddGroupColumnForSubquery(SSqlCmd* pCmd, int32_t tagIndex); ...@@ -224,7 +228,7 @@ void doAddGroupColumnForSubquery(SSqlCmd* pCmd, int32_t tagIndex);
int16_t tscGetJoinTagColIndexByUid(SSqlCmd* pCmd, uint64_t uid); int16_t tscGetJoinTagColIndexByUid(SSqlCmd* pCmd, uint64_t uid);
TAOS* taos_connect_a(char* ip, char* user, char* pass, char* db, int port, void (*fp)(void*, TAOS_RES*, int), 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* param, void** taos);
void sortRemoveDuplicates(STableDataBlocks* dataBuf); void sortRemoveDuplicates(STableDataBlocks* dataBuf);
......
...@@ -92,7 +92,12 @@ enum _sql_cmd { ...@@ -92,7 +92,12 @@ enum _sql_cmd {
*/ */
TSDB_SQL_RETRIEVE_EMPTY_RESULT, TSDB_SQL_RETRIEVE_EMPTY_RESULT,
TSDB_SQL_RESET_CACHE, TSDB_SQL_RESET_CACHE, // 40
TSDB_SQL_SERV_STATUS,
TSDB_SQL_CURRENT_DB,
TSDB_SQL_SERV_VERSION,
TSDB_SQL_CLI_VERSION,
TSDB_SQL_CURRENT_USER,
TSDB_SQL_CFG_LOCAL, TSDB_SQL_CFG_LOCAL,
TSDB_SQL_MAX TSDB_SQL_MAX
...@@ -342,11 +347,11 @@ typedef struct _tsc_obj { ...@@ -342,11 +347,11 @@ typedef struct _tsc_obj {
void * signature; void * signature;
void * pTimer; void * pTimer;
char mgmtIp[TSDB_USER_LEN]; char mgmtIp[TSDB_USER_LEN];
short mgmtPort; uint16_t mgmtPort;
char user[TSDB_USER_LEN]; char user[TSDB_USER_LEN];
char pass[TSDB_KEY_LEN]; char pass[TSDB_KEY_LEN];
char acctId[TSDB_DB_NAME_LEN]; char acctId[TSDB_DB_NAME_LEN];
char db[TSDB_DB_NAME_LEN]; char db[TSDB_METER_ID_LEN];
char sversion[TSDB_VERSION_LEN]; char sversion[TSDB_VERSION_LEN];
char writeAuth : 1; char writeAuth : 1;
char superAuth : 1; char superAuth : 1;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "tsocket.h" #include "tsocket.h"
#include "tsql.h" #include "tsql.h"
#include "tutil.h" #include "tutil.h"
#include "tnote.h"
void tscProcessFetchRow(SSchedMsg *pMsg); void tscProcessFetchRow(SSchedMsg *pMsg);
void tscProcessAsyncRetrieve(void *param, TAOS_RES *tres, int numOfRows); void tscProcessAsyncRetrieve(void *param, TAOS_RES *tres, int numOfRows);
...@@ -53,7 +54,9 @@ void taos_query_a(TAOS *taos, const char *sqlstr, void (*fp)(void *, TAOS_RES *, ...@@ -53,7 +54,9 @@ void taos_query_a(TAOS *taos, const char *sqlstr, void (*fp)(void *, TAOS_RES *,
tscError("sql string too long"); tscError("sql string too long");
tscQueueAsyncError(fp, param); tscQueueAsyncError(fp, param);
return; return;
} }
taosNotePrintTsc(sqlstr);
SSqlObj *pSql = (SSqlObj *)malloc(sizeof(SSqlObj)); SSqlObj *pSql = (SSqlObj *)malloc(sizeof(SSqlObj));
if (pSql == NULL) { if (pSql == NULL) {
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
typedef struct _c_hash_t { typedef struct _c_hash_t {
uint32_t ip; uint32_t ip;
short port; uint16_t port;
struct _c_hash_t *prev; struct _c_hash_t *prev;
struct _c_hash_t *next; struct _c_hash_t *next;
void * data; void * data;
...@@ -45,14 +45,14 @@ typedef struct { ...@@ -45,14 +45,14 @@ typedef struct {
void *pTimer; void *pTimer;
} SConnCache; } SConnCache;
int taosHashConn(void *handle, uint32_t ip, short port, char *user) { int taosHashConn(void *handle, uint32_t ip, uint16_t port, char *user) {
SConnCache *pObj = (SConnCache *)handle; SConnCache *pObj = (SConnCache *)handle;
int hash = 0; int hash = 0;
// size_t user_len = strlen(user); // size_t user_len = strlen(user);
hash = ip >> 16; hash = ip >> 16;
hash += (unsigned short)(ip & 0xFFFF); hash += (unsigned short)(ip & 0xFFFF);
hash += (unsigned short)port; hash += port;
while (*user != '\0') { while (*user != '\0') {
hash += *user; hash += *user;
user++; user++;
...@@ -74,7 +74,7 @@ void taosRemoveExpiredNodes(SConnCache *pObj, SConnHash *pNode, int hash, uint64 ...@@ -74,7 +74,7 @@ void taosRemoveExpiredNodes(SConnCache *pObj, SConnHash *pNode, int hash, uint64
pNext = pNode->next; pNext = pNode->next;
pObj->total--; pObj->total--;
pObj->count[hash]--; pObj->count[hash]--;
tscTrace("%p ip:0x%x:%d:%d:%p removed, connections in cache:%d", pNode->data, pNode->ip, pNode->port, hash, pNode, tscTrace("%p ip:0x%x:%hu:%d:%p removed, connections in cache:%d", pNode->data, pNode->ip, pNode->port, hash, pNode,
pObj->count[hash]); pObj->count[hash]);
taosMemPoolFree(pObj->connHashMemPool, (char *)pNode); taosMemPoolFree(pObj->connHashMemPool, (char *)pNode);
pNode = pNext; pNode = pNext;
...@@ -86,7 +86,7 @@ void taosRemoveExpiredNodes(SConnCache *pObj, SConnHash *pNode, int hash, uint64 ...@@ -86,7 +86,7 @@ void taosRemoveExpiredNodes(SConnCache *pObj, SConnHash *pNode, int hash, uint64
pObj->connHashList[hash] = NULL; pObj->connHashList[hash] = NULL;
} }
void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, char *user) { void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, uint16_t port, char *user) {
int hash; int hash;
SConnHash * pNode; SConnHash * pNode;
SConnCache *pObj; SConnCache *pObj;
...@@ -125,7 +125,7 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, ch ...@@ -125,7 +125,7 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, ch
pthread_mutex_unlock(&pObj->mutex); pthread_mutex_unlock(&pObj->mutex);
tscTrace("%p ip:0x%x:%d:%d:%p added, connections in cache:%d", data, ip, port, hash, pNode, pObj->count[hash]); tscTrace("%p ip:0x%x:%hu:%d:%p added, connections in cache:%d", data, ip, port, hash, pNode, pObj->count[hash]);
return pObj; return pObj;
} }
...@@ -152,7 +152,7 @@ void taosCleanConnCache(void *handle, void *tmrId) { ...@@ -152,7 +152,7 @@ void taosCleanConnCache(void *handle, void *tmrId) {
taosTmrReset(taosCleanConnCache, pObj->keepTimer * 2, pObj, pObj->tmrCtrl, &pObj->pTimer); taosTmrReset(taosCleanConnCache, pObj->keepTimer * 2, pObj, pObj->tmrCtrl, &pObj->pTimer);
} }
void *taosGetConnFromCache(void *handle, uint32_t ip, short port, char *user) { void *taosGetConnFromCache(void *handle, uint32_t ip, uint16_t port, char *user) {
int hash; int hash;
SConnHash * pNode; SConnHash * pNode;
SConnCache *pObj; SConnCache *pObj;
...@@ -201,7 +201,7 @@ void *taosGetConnFromCache(void *handle, uint32_t ip, short port, char *user) { ...@@ -201,7 +201,7 @@ void *taosGetConnFromCache(void *handle, uint32_t ip, short port, char *user) {
pthread_mutex_unlock(&pObj->mutex); pthread_mutex_unlock(&pObj->mutex);
if (pData) { if (pData) {
tscTrace("%p ip:0x%x:%d:%d:%p retrieved, connections in cache:%d", pData, ip, port, hash, pNode, pObj->count[hash]); tscTrace("%p ip:0x%x:%hu:%d:%p retrieved, connections in cache:%d", pData, ip, port, hash, pNode, pObj->count[hash]);
} }
return pData; return pData;
......
...@@ -26,7 +26,9 @@ ...@@ -26,7 +26,9 @@
#include "tschemautil.h" #include "tschemautil.h"
#include "tsocket.h" #include "tsocket.h"
static int32_t getToStringLength(char *pData, int32_t length, int32_t type) { static void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnName, size_t valueLength);
static int32_t getToStringLength(const char *pData, int32_t length, int32_t type) {
char buf[512] = {0}; char buf[512] = {0};
int32_t len = 0; int32_t len = 0;
...@@ -39,7 +41,7 @@ static int32_t getToStringLength(char *pData, int32_t length, int32_t type) { ...@@ -39,7 +41,7 @@ static int32_t getToStringLength(char *pData, int32_t length, int32_t type) {
case TSDB_DATA_TYPE_DOUBLE: { case TSDB_DATA_TYPE_DOUBLE: {
#ifdef _TD_ARM_32_ #ifdef _TD_ARM_32_
double dv = 0; double dv = 0;
*(int64_t*)(&dv) = *(int64_t*)pData; *(int64_t *)(&dv) = *(int64_t *)pData;
len = sprintf(buf, "%f", dv); len = sprintf(buf, "%f", dv);
#else #else
len = sprintf(buf, "%lf", *(double *)pData); len = sprintf(buf, "%lf", *(double *)pData);
...@@ -47,12 +49,11 @@ static int32_t getToStringLength(char *pData, int32_t length, int32_t type) { ...@@ -47,12 +49,11 @@ static int32_t getToStringLength(char *pData, int32_t length, int32_t type) {
if (strncasecmp("nan", buf, 3) == 0) { if (strncasecmp("nan", buf, 3) == 0) {
len = 4; len = 4;
} }
} } break;
break;
case TSDB_DATA_TYPE_FLOAT: { case TSDB_DATA_TYPE_FLOAT: {
#ifdef _TD_ARM_32_ #ifdef _TD_ARM_32_
float fv = 0; float fv = 0;
*(int32_t*)(&fv) = *(int32_t*)pData; *(int32_t *)(&fv) = *(int32_t *)pData;
len = sprintf(buf, "%f", fv); len = sprintf(buf, "%f", fv);
#else #else
len = sprintf(buf, "%f", *(float *)pData); len = sprintf(buf, "%f", *(float *)pData);
...@@ -60,8 +61,7 @@ static int32_t getToStringLength(char *pData, int32_t length, int32_t type) { ...@@ -60,8 +61,7 @@ static int32_t getToStringLength(char *pData, int32_t length, int32_t type) {
if (strncasecmp("nan", buf, 3) == 0) { if (strncasecmp("nan", buf, 3) == 0) {
len = 4; len = 4;
} }
} } break;
break;
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
len = sprintf(buf, "%lld", *(int64_t *)pData); len = sprintf(buf, "%lld", *(int64_t *)pData);
...@@ -203,23 +203,21 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) { ...@@ -203,23 +203,21 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
case TSDB_DATA_TYPE_FLOAT: { case TSDB_DATA_TYPE_FLOAT: {
#ifdef _TD_ARM_32_ #ifdef _TD_ARM_32_
float fv = 0; float fv = 0;
*(int32_t*)(&fv) = *(int32_t*)pTagValue; *(int32_t *)(&fv) = *(int32_t *)pTagValue;
sprintf(target, "%f", fv); sprintf(target, "%f", fv);
#else #else
sprintf(target, "%f", *(float *)pTagValue); sprintf(target, "%f", *(float *)pTagValue);
#endif #endif
} } break;
break;
case TSDB_DATA_TYPE_DOUBLE: { case TSDB_DATA_TYPE_DOUBLE: {
#ifdef _TD_ARM_32_ #ifdef _TD_ARM_32_
double dv = 0; double dv = 0;
*(int64_t*)(&dv) = *(int64_t*)pTagValue; *(int64_t *)(&dv) = *(int64_t *)pTagValue;
sprintf(target, "%lf", dv); sprintf(target, "%lf", dv);
#else #else
sprintf(target, "%lf", *(double *)pTagValue); sprintf(target, "%lf", *(double *)pTagValue);
#endif #endif
} } break;
break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
sprintf(target, "%d", *(int8_t *)pTagValue); sprintf(target, "%d", *(int8_t *)pTagValue);
break; break;
...@@ -391,6 +389,68 @@ static int tscProcessQueryTags(SSqlObj *pSql) { ...@@ -391,6 +389,68 @@ static int tscProcessQueryTags(SSqlObj *pSql) {
} }
} }
static void tscProcessCurrentUser(SSqlObj *pSql) {
SSqlExpr* pExpr = tscSqlExprGet(&pSql->cmd, 0);
tscSetLocalQueryResult(pSql, pSql->pTscObj->user, pExpr->aliasName, TSDB_USER_LEN);
}
static void tscProcessCurrentDB(SSqlObj *pSql) {
char db[TSDB_DB_NAME_LEN + 1] = {0};
extractDBName(pSql->pTscObj->db, db);
// no use db is invoked before.
if (strlen(db) == 0) {
setNull(db, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
}
SSqlExpr* pExpr = tscSqlExprGet(&pSql->cmd, 0);
tscSetLocalQueryResult(pSql, db, pExpr->aliasName, TSDB_DB_NAME_LEN);
}
static void tscProcessServerVer(SSqlObj *pSql) {
const char* v = pSql->pTscObj->sversion;
SSqlExpr* pExpr = tscSqlExprGet(&pSql->cmd, 0);
tscSetLocalQueryResult(pSql, v, pExpr->aliasName, tListLen(pSql->pTscObj->sversion));
}
static void tscProcessClientVer(SSqlObj *pSql) {
SSqlExpr* pExpr = tscSqlExprGet(&pSql->cmd, 0);
tscSetLocalQueryResult(pSql, version, pExpr->aliasName, strlen(version));
}
static void tscProcessServStatus(SSqlObj *pSql) {
STscObj* pObj = pSql->pTscObj;
if (pObj->pHb != NULL) {
if (pObj->pHb->res.code == TSDB_CODE_NETWORK_UNAVAIL) {
pSql->res.code = TSDB_CODE_NETWORK_UNAVAIL;
return;
}
} else {
if (pSql->res.code == TSDB_CODE_NETWORK_UNAVAIL) {
return;
}
}
SSqlExpr* pExpr = tscSqlExprGet(&pSql->cmd, 0);
tscSetLocalQueryResult(pSql, "1", pExpr->aliasName, 2);
}
void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnName, size_t valueLength) {
SSqlCmd *pCmd = &pSql->cmd;
SSqlRes *pRes = &pSql->res;
pCmd->numOfCols = 1;
pCmd->order.order = TSQL_SO_ASC;
tscFieldInfoSetValue(&pCmd->fieldsInfo, 0, TSDB_DATA_TYPE_BINARY, columnName, valueLength);
tscInitResObjForLocalQuery(pSql, 1, valueLength);
TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, 0);
strncpy(pRes->data, val, pField->bytes);
}
int tscProcessLocalCmd(SSqlObj *pSql) { int tscProcessLocalCmd(SSqlObj *pSql) {
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
...@@ -402,13 +462,23 @@ int tscProcessLocalCmd(SSqlObj *pSql) { ...@@ -402,13 +462,23 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
pSql->res.code = (uint8_t)tscProcessQueryTags(pSql); pSql->res.code = (uint8_t)tscProcessQueryTags(pSql);
} else if (pCmd->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT) { } else if (pCmd->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT) {
/* /*
* pass the qhandle check, in order to call partial release function to * set the qhandle to be 1 in order to pass the qhandle check, and to call partial release function to
* free allocated resources and remove the SqlObj from linked list * free allocated resources and remove the SqlObj from sql query linked list
*/ */
pSql->res.qhandle = 0x1; // pass the qhandle check pSql->res.qhandle = 0x1;
pSql->res.numOfRows = 0; pSql->res.numOfRows = 0;
} else if (pCmd->command == TSDB_SQL_RESET_CACHE) { } else if (pCmd->command == TSDB_SQL_RESET_CACHE) {
taosClearDataCache(tscCacheHandle); taosClearDataCache(tscCacheHandle);
} else if (pCmd->command == TSDB_SQL_SERV_VERSION) {
tscProcessServerVer(pSql);
} else if (pCmd->command == TSDB_SQL_CLI_VERSION) {
tscProcessClientVer(pSql);
} else if (pCmd->command == TSDB_SQL_CURRENT_USER) {
tscProcessCurrentUser(pSql);
} else if (pCmd->command == TSDB_SQL_CURRENT_DB) {
tscProcessCurrentDB(pSql);
} else if (pCmd->command == TSDB_SQL_SERV_STATUS) {
tscProcessServStatus(pSql);
} else { } else {
pSql->res.code = TSDB_CODE_INVALID_SQL; pSql->res.code = TSDB_CODE_INVALID_SQL;
tscError("%p not support command:%d", pSql, pCmd->command); tscError("%p not support command:%d", pSql, pCmd->command);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
void tscSaveSlowQueryFp(void *handle, void *tmrId); void tscSaveSlowQueryFp(void *handle, void *tmrId);
void *tscSlowQueryConn = NULL; void *tscSlowQueryConn = NULL;
bool tscSlowQueryConnInitialized = false; bool tscSlowQueryConnInitialized = false;
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, int port, void (*fp)(void *, TAOS_RES *, int), 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 *param, void **taos);
void tscInitConnCb(void *param, TAOS_RES *result, int code) { void tscInitConnCb(void *param, TAOS_RES *result, int code) {
......
...@@ -117,7 +117,8 @@ static int32_t optrToString(tSQLExpr* pExpr, char** exprString); ...@@ -117,7 +117,8 @@ static int32_t optrToString(tSQLExpr* pExpr, char** exprString);
static SColumnList getColumnList(int32_t num, int16_t tableIndex, int32_t columnIndex); static SColumnList getColumnList(int32_t num, int16_t tableIndex, int32_t columnIndex);
static int32_t getMeterIndex(SSQLToken* pTableToken, SSqlCmd* pCmd, SColumnIndex* pIndex); static int32_t getMeterIndex(SSQLToken* pTableToken, SSqlCmd* pCmd, SColumnIndex* pIndex);
static int32_t doFunctionsCompatibleCheck(SSqlObj* pSql); static int32_t doFunctionsCompatibleCheck(SSqlObj* pSql);
static int32_t doLocalQueryProcess(SQuerySQL* pQuerySql, SSqlCmd* pCmd);
static int32_t tscQueryOnlyMetricTags(SSqlCmd* pCmd, bool* queryOnMetricTags) { static int32_t tscQueryOnlyMetricTags(SSqlCmd* pCmd, bool* queryOnMetricTags) {
assert(QUERY_IS_STABLE_QUERY(pCmd->type)); assert(QUERY_IS_STABLE_QUERY(pCmd->type));
...@@ -877,7 +878,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -877,7 +878,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case TSQL_QUERY_METER: { case TSQL_QUERY_METER: {
SQuerySQL* pQuerySql = pInfo->pQueryInfo; SQuerySQL* pQuerySql = pInfo->pQueryInfo;
assert(pQuerySql != NULL && pQuerySql->from->nExpr > 0); assert(pQuerySql != NULL && (pQuerySql->from == NULL || pQuerySql->from->nExpr > 0));
const char* msg0 = "invalid table name"; const char* msg0 = "invalid table name";
const char* msg1 = "table name too long"; const char* msg1 = "table name too long";
...@@ -895,6 +896,19 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -895,6 +896,19 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
setErrMsg(pCmd, msg8); setErrMsg(pCmd, msg8);
return TSDB_CODE_INVALID_SQL; return TSDB_CODE_INVALID_SQL;
} }
/*
* handle the sql expression without from subclause
* select current_database();
* select server_version();
* select client_version();
* select server_state();
*/
if (pQuerySql->from == NULL) {
assert(pQuerySql->fillType == NULL && pQuerySql->pGroupby == NULL && pQuerySql->pWhere == NULL &&
pQuerySql->pSortOrder == NULL);
return doLocalQueryProcess(pQuerySql, pCmd);
}
if (pQuerySql->from->nExpr > TSDB_MAX_JOIN_TABLE_NUM) { if (pQuerySql->from->nExpr > TSDB_MAX_JOIN_TABLE_NUM) {
setErrMsg(pCmd, msg7); setErrMsg(pCmd, msg7);
...@@ -1120,7 +1134,7 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql) { ...@@ -1120,7 +1134,7 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql) {
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0); SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
if (pQuerySql->interval.type == 0) { if (pQuerySql->interval.type == 0 || pQuerySql->interval.n == 0) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -2669,7 +2683,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -2669,7 +2683,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return TSDB_CODE_INVALID_SQL; return TSDB_CODE_INVALID_SQL;
} }
int32_t port = strtol(portStr, NULL, 10); uint16_t port = (uint16_t)strtol(portStr, NULL, 10);
if (port <= 0 || port > 65535) { if (port <= 0 || port > 65535) {
memset(pCmd->payload, 0, tListLen(pCmd->payload)); memset(pCmd->payload, 0, tListLen(pCmd->payload));
...@@ -4971,8 +4985,8 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd) { ...@@ -4971,8 +4985,8 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd) {
} }
typedef struct SDNodeDynConfOption { typedef struct SDNodeDynConfOption {
char* name; char* name; // command name
int32_t len; int32_t len; // name string length
} SDNodeDynConfOption; } SDNodeDynConfOption;
int32_t validateDNodeConfig(tDCLSQL* pOptions) { int32_t validateDNodeConfig(tDCLSQL* pOptions) {
...@@ -4980,7 +4994,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) { ...@@ -4980,7 +4994,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) {
return TSDB_CODE_INVALID_SQL; return TSDB_CODE_INVALID_SQL;
} }
SDNodeDynConfOption DNODE_DYNAMIC_CFG_OPTIONS[14] = { const SDNodeDynConfOption DNODE_DYNAMIC_CFG_OPTIONS[14] = {
{"resetLog", 8}, {"resetQueryCache", 15}, {"dDebugFlag", 10}, {"rpcDebugFlag", 12}, {"resetLog", 8}, {"resetQueryCache", 15}, {"dDebugFlag", 10}, {"rpcDebugFlag", 12},
{"tmrDebugFlag", 12}, {"cDebugFlag", 10}, {"uDebugFlag", 10}, {"mDebugFlag", 10}, {"tmrDebugFlag", 12}, {"cDebugFlag", 10}, {"uDebugFlag", 10}, {"mDebugFlag", 10},
{"sdbDebugFlag", 12}, {"httpDebugFlag", 13}, {"monitorDebugFlag", 16}, {"qDebugflag", 10}, {"sdbDebugFlag", 12}, {"httpDebugFlag", 13}, {"monitorDebugFlag", 16}, {"qDebugflag", 10},
...@@ -4991,7 +5005,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) { ...@@ -4991,7 +5005,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) {
if (pOptions->nTokens == 2) { if (pOptions->nTokens == 2) {
// reset log and reset query cache does not need value // reset log and reset query cache does not need value
for (int32_t i = 0; i < 2; ++i) { for (int32_t i = 0; i < 2; ++i) {
SDNodeDynConfOption* pOption = &DNODE_DYNAMIC_CFG_OPTIONS[i]; const SDNodeDynConfOption* pOption = &DNODE_DYNAMIC_CFG_OPTIONS[i];
if ((strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0) && (pOption->len == pOptionToken->n)) { if ((strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0) && (pOption->len == pOptionToken->n)) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -5014,7 +5028,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) { ...@@ -5014,7 +5028,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) {
} }
for (int32_t i = 2; i < tListLen(DNODE_DYNAMIC_CFG_OPTIONS) - 1; ++i) { for (int32_t i = 2; i < tListLen(DNODE_DYNAMIC_CFG_OPTIONS) - 1; ++i) {
SDNodeDynConfOption* pOption = &DNODE_DYNAMIC_CFG_OPTIONS[i]; const SDNodeDynConfOption* pOption = &DNODE_DYNAMIC_CFG_OPTIONS[i];
if ((strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0) && (pOption->len == pOptionToken->n)) { if ((strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0) && (pOption->len == pOptionToken->n)) {
/* options is valid */ /* options is valid */
...@@ -5031,8 +5045,10 @@ int32_t validateLocalConfig(tDCLSQL* pOptions) { ...@@ -5031,8 +5045,10 @@ int32_t validateLocalConfig(tDCLSQL* pOptions) {
return TSDB_CODE_INVALID_SQL; return TSDB_CODE_INVALID_SQL;
} }
SDNodeDynConfOption LOCAL_DYNAMIC_CFG_OPTIONS[6] = {{"resetLog", 8}, {"rpcDebugFlag", 12}, {"tmrDebugFlag", 12}, SDNodeDynConfOption LOCAL_DYNAMIC_CFG_OPTIONS[6] = {
{"cDebugFlag", 10}, {"uDebugFlag", 10}, {"debugFlag", 9}}; {"resetLog", 8}, {"rpcDebugFlag", 12}, {"tmrDebugFlag", 12},
{"cDebugFlag", 10}, {"uDebugFlag", 10}, {"debugFlag", 9}
};
SSQLToken* pOptionToken = &pOptions->a[0]; SSQLToken* pOptionToken = &pOptions->a[0];
...@@ -5686,3 +5702,53 @@ int32_t doFunctionsCompatibleCheck(SSqlObj* pSql) { ...@@ -5686,3 +5702,53 @@ int32_t doFunctionsCompatibleCheck(SSqlObj* pSql) {
return checkUpdateTagPrjFunctions(pCmd); return checkUpdateTagPrjFunctions(pCmd);
} }
} }
int32_t doLocalQueryProcess(SQuerySQL* pQuerySql, SSqlCmd* pCmd) {
const char* msg1 = "only one expression allowed";
const char* msg2 = "invalid expression in select clause";
const char* msg3 = "invalid function";
tSQLExprList* pExprList = pQuerySql->pSelection;
if (pExprList->nExpr != 1) {
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
tSQLExpr* pExpr = pExprList->a[0].pNode;
if (pExpr->operand.z == NULL) {
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
SDNodeDynConfOption functionsInfo[5] = {
{"database()", 10}, {"server_version()", 16}, {"server_status()", 15}, {"client_version()", 16}, {"current_user()", 14}
};
int32_t index = -1;
for(int32_t i = 0; i < tListLen(functionsInfo); ++i) {
if (strncasecmp(functionsInfo[i].name, pExpr->operand.z, functionsInfo[i].len) == 0 &&
functionsInfo[i].len == pExpr->operand.n) {
index = i;
break;
}
}
SSqlExpr* pExpr1 = tscSqlExprInsertEmpty(pCmd, 0, TSDB_FUNC_TAG_DUMMY);
if (pExprList->a[0].aliasName != NULL) {
strncpy(pExpr1->aliasName, pExprList->a[0].aliasName, tListLen(pExpr1->aliasName));
} else {
strncpy(pExpr1->aliasName, functionsInfo[index].name, tListLen(pExpr1->aliasName));
}
switch(index) {
case 0: pCmd->command = TSDB_SQL_CURRENT_DB;return TSDB_CODE_SUCCESS;
case 1: pCmd->command = TSDB_SQL_SERV_VERSION;return TSDB_CODE_SUCCESS;
case 2: pCmd->command = TSDB_SQL_SERV_STATUS;return TSDB_CODE_SUCCESS;
case 3: pCmd->command = TSDB_SQL_CLI_VERSION;return TSDB_CODE_SUCCESS;
case 4: pCmd->command = TSDB_SQL_CURRENT_USER;return TSDB_CODE_SUCCESS;
default: {
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
}
}
}
...@@ -500,7 +500,7 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SSQLToken *type) { ...@@ -500,7 +500,7 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SSQLToken *type) {
SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection, tVariantList *pFrom, tSQLExpr *pWhere, SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection, tVariantList *pFrom, tSQLExpr *pWhere,
tVariantList *pGroupby, tVariantList *pSortOrder, SSQLToken *pInterval, tVariantList *pGroupby, tVariantList *pSortOrder, SSQLToken *pInterval,
SSQLToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit) { SSQLToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit) {
assert(pSelection != NULL && pFrom != NULL && pInterval != NULL && pLimit != NULL && pGLimit != NULL); assert(pSelection != NULL);
SQuerySQL *pQuery = calloc(1, sizeof(SQuerySQL)); SQuerySQL *pQuery = calloc(1, sizeof(SQuerySQL));
pQuery->selectToken = *pSelectToken; pQuery->selectToken = *pSelectToken;
...@@ -512,13 +512,23 @@ SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection, ...@@ -512,13 +512,23 @@ SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection,
pQuery->pSortOrder = pSortOrder; pQuery->pSortOrder = pSortOrder;
pQuery->pWhere = pWhere; pQuery->pWhere = pWhere;
pQuery->limit = *pLimit; if (pLimit != NULL) {
pQuery->slimit = *pGLimit; pQuery->limit = *pLimit;
}
if (pGLimit != NULL) {
pQuery->slimit = *pGLimit;
}
pQuery->interval = *pInterval; if (pInterval != NULL) {
pQuery->sliding = *pSliding; pQuery->interval = *pInterval;
}
if (pSliding != NULL) {
pQuery->sliding = *pSliding;
}
pQuery->fillType = pFill; pQuery->fillType = pFill;
return pQuery; return pQuery;
} }
......
...@@ -184,6 +184,15 @@ void tscGetConnToMgmt(SSqlObj *pSql, uint8_t *pCode) { ...@@ -184,6 +184,15 @@ void tscGetConnToMgmt(SSqlObj *pSql, uint8_t *pCode) {
pSql->vnode = TSC_MGMT_VNODE; pSql->vnode = TSC_MGMT_VNODE;
#endif #endif
} }
// the pSql->res.code is the previous error(status) code.
if (pSql->thandle == NULL && pSql->retry >= pSql->maxRetry) {
if (pSql->res.code != TSDB_CODE_SUCCESS && pSql->res.code != TSDB_CODE_ACTION_IN_PROGRESS) {
*pCode = pSql->res.code;
}
tscError("%p reach the max retry:%d, code:%d", pSql, pSql->retry, *pCode);
}
} }
void tscGetConnToVnode(SSqlObj *pSql, uint8_t *pCode) { void tscGetConnToVnode(SSqlObj *pSql, uint8_t *pCode) {
...@@ -442,6 +451,9 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) { ...@@ -442,6 +451,9 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
tscTrace("%p it shall be redirected!", pSql); tscTrace("%p it shall be redirected!", pSql);
taosAddConnIntoCache(tscConnCache, thandle, pSql->ip, pSql->vnode, pObj->user); taosAddConnIntoCache(tscConnCache, thandle, pSql->ip, pSql->vnode, pObj->user);
pSql->thandle = NULL; pSql->thandle = NULL;
// reset the retry times for a new mgmt node
pSql->retry = 0;
if (pCmd->command > TSDB_SQL_MGMT) { if (pCmd->command > TSDB_SQL_MGMT) {
tscProcessMgmtRedirect(pSql, pMsg->content + 1); tscProcessMgmtRedirect(pSql, pMsg->content + 1);
...@@ -1795,7 +1807,7 @@ int tscBuildCreateDbMsg(SSqlObj *pSql) { ...@@ -1795,7 +1807,7 @@ int tscBuildCreateDbMsg(SSqlObj *pSql) {
pMsg += sizeof(SMgmtHead); pMsg += sizeof(SMgmtHead);
pCreateDbMsg = (SCreateDbMsg *)pMsg; pCreateDbMsg = (SCreateDbMsg *)pMsg;
strcpy(pCreateDbMsg->db, pMeterMetaInfo->name); strncpy(pCreateDbMsg->db, pMeterMetaInfo->name, tListLen(pCreateDbMsg->db));
pMsg += sizeof(SCreateDbMsg); pMsg += sizeof(SCreateDbMsg);
msgLen = pMsg - pStart; msgLen = pMsg - pStart;
...@@ -2017,7 +2029,7 @@ int tscBuildDropDbMsg(SSqlObj *pSql) { ...@@ -2017,7 +2029,7 @@ int tscBuildDropDbMsg(SSqlObj *pSql) {
pMsg += sizeof(SMgmtHead); pMsg += sizeof(SMgmtHead);
pDropDbMsg = (SDropDbMsg *)pMsg; pDropDbMsg = (SDropDbMsg *)pMsg;
strcpy(pDropDbMsg->db, pMeterMetaInfo->name); strncpy(pDropDbMsg->db, pMeterMetaInfo->name, tListLen(pDropDbMsg->db));
pDropDbMsg->ignoreNotExists = htons(pCmd->existsCheck ? 1 : 0); pDropDbMsg->ignoreNotExists = htons(pCmd->existsCheck ? 1 : 0);
...@@ -3795,7 +3807,14 @@ void tscInitMsgs() { ...@@ -3795,7 +3807,14 @@ void tscInitMsgs() {
tscProcessMsgRsp[TSDB_SQL_SHOW] = tscProcessShowRsp; tscProcessMsgRsp[TSDB_SQL_SHOW] = tscProcessShowRsp;
tscProcessMsgRsp[TSDB_SQL_RETRIEVE] = tscProcessRetrieveRspFromVnode; // rsp handled by same function. tscProcessMsgRsp[TSDB_SQL_RETRIEVE] = tscProcessRetrieveRspFromVnode; // rsp handled by same function.
tscProcessMsgRsp[TSDB_SQL_DESCRIBE_TABLE] = tscProcessDescribeTableRsp; tscProcessMsgRsp[TSDB_SQL_DESCRIBE_TABLE] = tscProcessDescribeTableRsp;
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_TAGS] = tscProcessTagRetrieveRsp; tscProcessMsgRsp[TSDB_SQL_RETRIEVE_TAGS] = tscProcessTagRetrieveRsp;
tscProcessMsgRsp[TSDB_SQL_CURRENT_DB] = tscProcessTagRetrieveRsp;
tscProcessMsgRsp[TSDB_SQL_CURRENT_USER] = tscProcessTagRetrieveRsp;
tscProcessMsgRsp[TSDB_SQL_SERV_VERSION] = tscProcessTagRetrieveRsp;
tscProcessMsgRsp[TSDB_SQL_CLI_VERSION] = tscProcessTagRetrieveRsp;
tscProcessMsgRsp[TSDB_SQL_SERV_STATUS] = tscProcessTagRetrieveRsp;
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_EMPTY_RESULT] = tscProcessEmptyResultRsp; tscProcessMsgRsp[TSDB_SQL_RETRIEVE_EMPTY_RESULT] = tscProcessEmptyResultRsp;
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_METRIC] = tscProcessRetrieveMetricRsp; tscProcessMsgRsp[TSDB_SQL_RETRIEVE_METRIC] = tscProcessRetrieveMetricRsp;
......
...@@ -27,8 +27,9 @@ ...@@ -27,8 +27,9 @@
#include "tsql.h" #include "tsql.h"
#include "ttimer.h" #include "ttimer.h"
#include "tutil.h" #include "tutil.h"
#include "tnote.h"
TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const char *db, int port, void (*fp)(void *, TAOS_RES *, int), TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int),
void *param, void **taos) { void *param, void **taos) {
STscObj *pObj; STscObj *pObj;
...@@ -149,7 +150,7 @@ TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const ...@@ -149,7 +150,7 @@ TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const
return pObj; return pObj;
} }
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, int port) { TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
if (ip == NULL || (ip != NULL && (strcmp("127.0.0.1", ip) == 0 || strcasecmp("localhost", ip) == 0))) { if (ip == NULL || (ip != NULL && (strcmp("127.0.0.1", ip) == 0 || strcasecmp("localhost", ip) == 0))) {
#ifdef CLUSTER #ifdef CLUSTER
ip = tsMasterIp; ip = tsMasterIp;
...@@ -201,7 +202,7 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha ...@@ -201,7 +202,7 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
return taos; return taos;
} }
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, int port, void (*fp)(void *, TAOS_RES *, int), 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 *param, void **taos) {
#ifndef CLUSTER #ifndef CLUSTER
if (ip == NULL) { if (ip == NULL) {
...@@ -241,9 +242,9 @@ int taos_query_imp(STscObj* pObj, SSqlObj* pSql) { ...@@ -241,9 +242,9 @@ int taos_query_imp(STscObj* pObj, SSqlObj* pSql) {
pRes->qhandle = 0; pRes->qhandle = 0;
pSql->thandle = NULL; pSql->thandle = NULL;
if (pRes->code != TSDB_CODE_SUCCESS) return pRes->code; if (pRes->code == TSDB_CODE_SUCCESS) {
tscDoQuery(pSql);
tscDoQuery(pSql); }
tscTrace("%p SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(pObj), pObj); tscTrace("%p SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(pObj), pObj);
if (pRes->code != TSDB_CODE_SUCCESS) { if (pRes->code != TSDB_CODE_SUCCESS) {
...@@ -270,6 +271,8 @@ int taos_query(TAOS *taos, const char *sqlstr) { ...@@ -270,6 +271,8 @@ int taos_query(TAOS *taos, const char *sqlstr) {
return pRes->code; return pRes->code;
} }
taosNotePrintTsc(sqlstr);
void *sql = realloc(pSql->sqlstr, sqlLen + 1); void *sql = realloc(pSql->sqlstr, sqlLen + 1);
if (sql == NULL) { if (sql == NULL) {
pRes->code = TSDB_CODE_CLI_OUT_OF_MEMORY; pRes->code = TSDB_CODE_CLI_OUT_OF_MEMORY;
......
...@@ -45,6 +45,10 @@ extern int tscEmbedded; ...@@ -45,6 +45,10 @@ extern int tscEmbedded;
int tscNumOfThreads; int tscNumOfThreads;
static pthread_once_t tscinit = PTHREAD_ONCE_INIT; static pthread_once_t tscinit = PTHREAD_ONCE_INIT;
extern int tsTscEnableRecordSql;
extern int tsNumOfLogLines;
void taosInitNote(int numOfNoteLines, int maxNotes, char* lable);
void tscCheckDiskUsage(void *para, void *unused) { void tscCheckDiskUsage(void *para, void *unused) {
taosGetDisk(); taosGetDisk();
taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr); taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr);
...@@ -85,6 +89,10 @@ void taos_init_imp() { ...@@ -85,6 +89,10 @@ void taos_init_imp() {
taosSetCoreDump(); taosSetCoreDump();
if (tsTscEnableRecordSql != 0) {
taosInitNote(tsNumOfLogLines / 10, 1, (char*)"tsc_note");
}
#ifdef CLUSTER #ifdef CLUSTER
tscMgmtIpList.numOfIps = 2; tscMgmtIpList.numOfIps = 2;
strcpy(tscMgmtIpList.ipstr[0], tsMasterIp); strcpy(tscMgmtIpList.ipstr[0], tsMasterIp);
...@@ -354,4 +362,4 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) { ...@@ -354,4 +362,4 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
atomic_store_32(&lock, 0); atomic_store_32(&lock, 0);
return ret; return ret;
} }
\ No newline at end of file
...@@ -720,7 +720,7 @@ static void evic(SFieldInfo* pFieldInfo, int32_t index) { ...@@ -720,7 +720,7 @@ static void evic(SFieldInfo* pFieldInfo, int32_t index) {
} }
} }
static void setValueImpl(TAOS_FIELD* pField, int8_t type, char* name, int16_t bytes) { static void setValueImpl(TAOS_FIELD* pField, int8_t type, const char* name, int16_t bytes) {
pField->type = type; pField->type = type;
strncpy(pField->name, name, TSDB_COL_NAME_LEN); strncpy(pField->name, name, TSDB_COL_NAME_LEN);
pField->bytes = bytes; pField->bytes = bytes;
...@@ -764,7 +764,7 @@ void tscFieldInfoUpdateVisible(SFieldInfo* pFieldInfo, int32_t index, bool visib ...@@ -764,7 +764,7 @@ void tscFieldInfoUpdateVisible(SFieldInfo* pFieldInfo, int32_t index, bool visib
} }
} }
void tscFieldInfoSetValue(SFieldInfo* pFieldInfo, int32_t index, int8_t type, char* name, int16_t bytes) { void tscFieldInfoSetValue(SFieldInfo* pFieldInfo, int32_t index, int8_t type, const char* name, int16_t bytes) {
ensureSpace(pFieldInfo, pFieldInfo->numOfOutputCols + 1); ensureSpace(pFieldInfo, pFieldInfo->numOfOutputCols + 1);
evic(pFieldInfo, index); evic(pFieldInfo, index);
...@@ -896,6 +896,19 @@ static void _exprEvic(SSqlExprInfo* pExprInfo, int32_t index) { ...@@ -896,6 +896,19 @@ static void _exprEvic(SSqlExprInfo* pExprInfo, int32_t index) {
} }
} }
SSqlExpr* tscSqlExprInsertEmpty(SSqlCmd* pCmd, int32_t index, int16_t functionId) {
SSqlExprInfo* pExprInfo = &pCmd->exprsInfo;
_exprCheckSpace(pExprInfo, pExprInfo->numOfExprs + 1);
_exprEvic(pExprInfo, index);
SSqlExpr* pExpr = &pExprInfo->pExprs[index];
pExpr->functionId = functionId;
pExprInfo->numOfExprs++;
return pExpr;
}
SSqlExpr* tscSqlExprInsert(SSqlCmd* pCmd, int32_t index, int16_t functionId, SColumnIndex* pColIndex, int16_t type, SSqlExpr* tscSqlExprInsert(SSqlCmd* pCmd, int32_t index, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
int16_t size, int16_t interSize) { int16_t size, int16_t interSize) {
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pColIndex->tableIndex); SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pColIndex->tableIndex);
...@@ -1643,7 +1656,7 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) { ...@@ -1643,7 +1656,7 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) {
} }
// remain space is insufficient, allocate more spaces // remain space is insufficient, allocate more spaces
int32_t inc = (size < MIN_ALLOC_SIZE) ? size : MIN_ALLOC_SIZE; int32_t inc = (size >= MIN_ALLOC_SIZE) ? size : MIN_ALLOC_SIZE;
if (inc < (pStr->alloc >> 1)) { if (inc < (pStr->alloc >> 1)) {
inc = (pStr->alloc >> 1); inc = (pStr->alloc >> 1);
} }
...@@ -1670,6 +1683,7 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) { ...@@ -1670,6 +1683,7 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) {
} }
memset(tmp + pStr->n, 0, inc); memset(tmp + pStr->n, 0, inc);
pStr->alloc = newsize;
pStr->z = tmp; pStr->z = tmp;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
......
...@@ -273,6 +273,9 @@ public class TSDBDriver implements java.sql.Driver { ...@@ -273,6 +273,9 @@ public class TSDBDriver implements java.sql.Driver {
String user = ""; String user = "";
for (String queryStr : queryStrings) { for (String queryStr : queryStrings) {
String[] kvPair = queryStr.trim().split("="); String[] kvPair = queryStr.trim().split("=");
if (kvPair.length < 2){
continue;
}
switch (kvPair[0].toLowerCase()) { switch (kvPair[0].toLowerCase()) {
case PROPERTY_KEY_USER: case PROPERTY_KEY_USER:
urlProps.setProperty(PROPERTY_KEY_USER, kvPair[1]); urlProps.setProperty(PROPERTY_KEY_USER, kvPair[1]);
......
...@@ -23,8 +23,8 @@ extern "C" { ...@@ -23,8 +23,8 @@ extern "C" {
#include "taosmsg.h" #include "taosmsg.h"
#include "tsdb.h" #include "tsdb.h"
extern short tsMgmtMgmtPort; extern uint16_t tsMgmtMgmtPort;
extern short tsMgmtSyncPort; extern uint16_t tsMgmtSyncPort;
extern int sdbMaxNodes; extern int sdbMaxNodes;
extern int tsMgmtPeerHBTimer; // seconds extern int tsMgmtPeerHBTimer; // seconds
extern char sdbZone[]; extern char sdbZone[];
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
#include "tsql.h" #include "tsql.h"
#include "tutil.h" #include "tutil.h"
} }
...@@ -113,7 +112,7 @@ cmd ::= DROP TABLE ifexists(Y) ids(X) cpxName(Z). { ...@@ -113,7 +112,7 @@ cmd ::= DROP TABLE ifexists(Y) ids(X) cpxName(Z). {
} }
cmd ::= DROP DATABASE ifexists(Y) ids(X). { setDCLSQLElems(pInfo, DROP_DATABASE, 2, &X, &Y); } cmd ::= DROP DATABASE ifexists(Y) ids(X). { setDCLSQLElems(pInfo, DROP_DATABASE, 2, &X, &Y); }
cmd ::= DROP DNODE IP(X). { setDCLSQLElems(pInfo, DROP_DNODE, 1, &X); } cmd ::= DROP DNODE IPTOKEN(X). { setDCLSQLElems(pInfo, DROP_DNODE, 1, &X); }
cmd ::= DROP USER ids(X). { setDCLSQLElems(pInfo, DROP_USER, 1, &X); } cmd ::= DROP USER ids(X). { setDCLSQLElems(pInfo, DROP_USER, 1, &X); }
cmd ::= DROP ACCOUNT ids(X). { setDCLSQLElems(pInfo, DROP_ACCOUNT, 1, &X); } cmd ::= DROP ACCOUNT ids(X). { setDCLSQLElems(pInfo, DROP_ACCOUNT, 1, &X); }
...@@ -129,8 +128,8 @@ cmd ::= DESCRIBE ids(X) cpxName(Y). { ...@@ -129,8 +128,8 @@ cmd ::= DESCRIBE ids(X) cpxName(Y). {
/////////////////////////////////THE ALTER STATEMENT//////////////////////////////////////// /////////////////////////////////THE ALTER STATEMENT////////////////////////////////////////
cmd ::= ALTER USER ids(X) PASS ids(Y). { setDCLSQLElems(pInfo, ALTER_USER_PASSWD, 2, &X, &Y); } cmd ::= ALTER USER ids(X) PASS ids(Y). { setDCLSQLElems(pInfo, ALTER_USER_PASSWD, 2, &X, &Y); }
cmd ::= ALTER USER ids(X) PRIVILEGE ids(Y). { setDCLSQLElems(pInfo, ALTER_USER_PRIVILEGES, 2, &X, &Y);} cmd ::= ALTER USER ids(X) PRIVILEGE ids(Y). { setDCLSQLElems(pInfo, ALTER_USER_PRIVILEGES, 2, &X, &Y);}
cmd ::= ALTER DNODE IP(X) ids(Y). { setDCLSQLElems(pInfo, ALTER_DNODE, 2, &X, &Y); } cmd ::= ALTER DNODE IPTOKEN(X) ids(Y). { setDCLSQLElems(pInfo, ALTER_DNODE, 2, &X, &Y); }
cmd ::= ALTER DNODE IP(X) ids(Y) ids(Z). { setDCLSQLElems(pInfo, ALTER_DNODE, 3, &X, &Y, &Z); } cmd ::= ALTER DNODE IPTOKEN(X) ids(Y) ids(Z). { setDCLSQLElems(pInfo, ALTER_DNODE, 3, &X, &Y, &Z); }
cmd ::= ALTER LOCAL ids(X). { setDCLSQLElems(pInfo, ALTER_LOCAL, 1, &X); } cmd ::= ALTER LOCAL ids(X). { setDCLSQLElems(pInfo, ALTER_LOCAL, 1, &X); }
cmd ::= ALTER LOCAL ids(X) ids(Y). { setDCLSQLElems(pInfo, ALTER_LOCAL, 2, &X, &Y); } cmd ::= ALTER LOCAL ids(X) ids(Y). { setDCLSQLElems(pInfo, ALTER_LOCAL, 2, &X, &Y); }
cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SSQLToken t = {0}; setCreateDBSQL(pInfo, ALTER_DATABASE, &X, &Y, &t);} cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SSQLToken t = {0}; setCreateDBSQL(pInfo, ALTER_DATABASE, &X, &Y, &t);}
...@@ -155,7 +154,7 @@ ifnotexists(X) ::= . {X.n = 0;} ...@@ -155,7 +154,7 @@ ifnotexists(X) ::= . {X.n = 0;}
/////////////////////////////////THE CREATE STATEMENT/////////////////////////////////////// /////////////////////////////////THE CREATE STATEMENT///////////////////////////////////////
//create option for dnode/db/user/account //create option for dnode/db/user/account
cmd ::= CREATE DNODE IP(X). { setDCLSQLElems(pInfo, CREATE_DNODE, 1, &X);} cmd ::= CREATE DNODE IPTOKEN(X). { setDCLSQLElems(pInfo, CREATE_DNODE, 1, &X);}
cmd ::= CREATE ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). cmd ::= CREATE ACCOUNT ids(X) PASS ids(Y) acct_optr(Z).
{ setCreateAcctSQL(pInfo, CREATE_ACCOUNT, &X, &Y, &Z);} { setCreateAcctSQL(pInfo, CREATE_ACCOUNT, &X, &Y, &Z);}
cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDBSQL(pInfo, CREATE_DATABASE, &X, &Y, &Z);} cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDBSQL(pInfo, CREATE_DATABASE, &X, &Y, &Z);}
...@@ -219,7 +218,7 @@ comp(Y) ::= COMP INTEGER(X). { Y = X; } ...@@ -219,7 +218,7 @@ comp(Y) ::= COMP INTEGER(X). { Y = X; }
prec(Y) ::= PRECISION STRING(X). { Y = X; } prec(Y) ::= PRECISION STRING(X). { Y = X; }
%type db_optr {SCreateDBInfo} %type db_optr {SCreateDBInfo}
db_optr ::= . {} db_optr(Y) ::= . {memset(&Y, 0, sizeof(SCreateDBInfo));}
db_optr(Y) ::= db_optr(Z) tables(X). { Y = Z; Y.tablesPerVnode = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) tables(X). { Y = Z; Y.tablesPerVnode = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) cache(X). { Y = Z; Y.cacheBlockSize = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) cache(X). { Y = Z; Y.cacheBlockSize = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); }
...@@ -350,6 +349,14 @@ select(A) ::= SELECT(T) selcollist(W) from(X) where_opt(Y) interval_opt(K) fill_ ...@@ -350,6 +349,14 @@ select(A) ::= SELECT(T) selcollist(W) from(X) where_opt(Y) interval_opt(K) fill_
A = tSetQuerySQLElems(&T, W, X, Y, P, Z, &K, &S, F, &L, &G); A = tSetQuerySQLElems(&T, W, X, Y, P, Z, &K, &S, F, &L, &G);
} }
// Support for the SQL exprssion without from & where subclauses, e.g.,
// select current_database(),
// select server_version(), select client_version(),
// select server_state();
select(A) ::= SELECT(T) selcollist(W). {
A = tSetQuerySQLElems(&T, W, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
// selcollist is a list of expressions that are to become the return // selcollist is a list of expressions that are to become the return
// values of the SELECT statement. The "*" in statements like // values of the SELECT statement. The "*" in statements like
// "SELECT * FROM ..." is encoded as a special expression with an opcode of TK_ALL. // "SELECT * FROM ..." is encoded as a special expression with an opcode of TK_ALL.
...@@ -392,7 +399,7 @@ tmvar(A) ::= VARIABLE(X). {A = X;} ...@@ -392,7 +399,7 @@ tmvar(A) ::= VARIABLE(X). {A = X;}
%type interval_opt {SSQLToken} %type interval_opt {SSQLToken}
interval_opt(N) ::= INTERVAL LP tmvar(E) RP. {N = E; } interval_opt(N) ::= INTERVAL LP tmvar(E) RP. {N = E; }
interval_opt(N) ::= . {N.n = 0; } interval_opt(N) ::= . {N.n = 0; N.z = NULL; N.type = 0; }
%type fill_opt {tVariantList*} %type fill_opt {tVariantList*}
%destructor fill_opt {tVariantListDestroy($$);} %destructor fill_opt {tVariantListDestroy($$);}
...@@ -413,7 +420,7 @@ fill_opt(N) ::= FILL LP ID(Y) RP. { ...@@ -413,7 +420,7 @@ fill_opt(N) ::= FILL LP ID(Y) RP. {
%type sliding_opt {SSQLToken} %type sliding_opt {SSQLToken}
sliding_opt(K) ::= SLIDING LP tmvar(E) RP. {K = E; } sliding_opt(K) ::= SLIDING LP tmvar(E) RP. {K = E; }
sliding_opt(K) ::= . {K.n = 0; } sliding_opt(K) ::= . {K.n = 0; K.z = NULL; K.type = 0; }
%type orderby_opt {tVariantList*} %type orderby_opt {tVariantList*}
%destructor orderby_opt {tVariantListDestroy($$);} %destructor orderby_opt {tVariantListDestroy($$);}
...@@ -642,12 +649,12 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). { ...@@ -642,12 +649,12 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
} }
////////////////////////////////////////kill statement/////////////////////////////////////// ////////////////////////////////////////kill statement///////////////////////////////////////
cmd ::= KILL CONNECTION IP(X) COLON(Z) INTEGER(Y). {X.n += (Z.n + Y.n); setDCLSQLElems(pInfo, KILL_CONNECTION, 1, &X);} cmd ::= KILL CONNECTION IPTOKEN(X) COLON(Z) INTEGER(Y). {X.n += (Z.n + Y.n); setDCLSQLElems(pInfo, KILL_CONNECTION, 1, &X);}
cmd ::= KILL STREAM IP(X) COLON(Z) INTEGER(Y) COLON(K) INTEGER(F). {X.n += (Z.n + Y.n + K.n + F.n); setDCLSQLElems(pInfo, KILL_STREAM, 1, &X);} cmd ::= KILL STREAM IPTOKEN(X) COLON(Z) INTEGER(Y) COLON(K) INTEGER(F). {X.n += (Z.n + Y.n + K.n + F.n); setDCLSQLElems(pInfo, KILL_STREAM, 1, &X);}
cmd ::= KILL QUERY IP(X) COLON(Z) INTEGER(Y) COLON(K) INTEGER(F). {X.n += (Z.n + Y.n + K.n + F.n); setDCLSQLElems(pInfo, KILL_QUERY, 1, &X);} cmd ::= KILL QUERY IPTOKEN(X) COLON(Z) INTEGER(Y) COLON(K) INTEGER(F). {X.n += (Z.n + Y.n + K.n + F.n); setDCLSQLElems(pInfo, KILL_QUERY, 1, &X);}
%fallback ID ABORT AFTER ASC ATTACH BEFORE BEGIN CASCADE CLUSTER CONFLICT COPY DATABASE DEFERRED %fallback ID ABORT AFTER ASC ATTACH BEFORE BEGIN CASCADE CLUSTER CONFLICT COPY DATABASE DEFERRED
DELIMITERS DESC DETACH EACH END EXPLAIN FAIL FOR GLOB IGNORE IMMEDIATE INITIALLY INSTEAD DELIMITERS DESC DETACH EACH END EXPLAIN FAIL FOR GLOB IGNORE IMMEDIATE INITIALLY INSTEAD
LIKE MATCH KEY OF OFFSET RAISE REPLACE RESTRICT ROW STATEMENT TRIGGER VIEW ALL LIKE MATCH KEY OF OFFSET RAISE REPLACE RESTRICT ROW STATEMENT TRIGGER VIEW ALL
COUNT SUM AVG MIN MAX FIRST LAST TOP BOTTOM STDDEV PERCENTILE APERCENTILE LEASTSQUARES HISTOGRAM DIFF COUNT SUM AVG MIN MAX FIRST LAST TOP BOTTOM STDDEV PERCENTILE APERCENTILE LEASTSQUARES HISTOGRAM DIFF
SPREAD TWA INTERP LAST_ROW NOW IP SEMI NONE PREV LINEAR IMPORT METRIC TBNAME JOIN METRICS STABLE. SPREAD TWA INTERP LAST_ROW NOW IPTOKEN SEMI NONE PREV LINEAR IMPORT METRIC TBNAME JOIN METRICS STABLE NULL.
\ No newline at end of file \ No newline at end of file
...@@ -59,7 +59,7 @@ typedef struct taosField { ...@@ -59,7 +59,7 @@ typedef struct taosField {
void taos_init(); void taos_init();
int taos_options(TSDB_OPTION option, const void *arg, ...); int taos_options(TSDB_OPTION option, const void *arg, ...);
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, int port); TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port);
void taos_close(TAOS *taos); void taos_close(TAOS *taos);
typedef struct TAOS_BIND { typedef struct TAOS_BIND {
......
...@@ -222,7 +222,7 @@ typedef struct { ...@@ -222,7 +222,7 @@ typedef struct {
// internal part // internal part
uint32_t destId; uint32_t destId;
char meterId[TSDB_UNI_LEN]; char meterId[TSDB_UNI_LEN];
short port; // for UDP only uint16_t port; // for UDP only
char empty[1]; char empty[1];
char msgType; char msgType;
int32_t msgLen; int32_t msgLen;
...@@ -309,7 +309,7 @@ typedef struct { ...@@ -309,7 +309,7 @@ typedef struct {
} SCreateMsg; } SCreateMsg;
typedef struct { typedef struct {
char db[TSDB_DB_NAME_LEN]; char db[TSDB_METER_ID_LEN];
short ignoreNotExists; short ignoreNotExists;
} SDropDbMsg, SUseDbMsg; } SDropDbMsg, SUseDbMsg;
...@@ -594,7 +594,7 @@ typedef struct { ...@@ -594,7 +594,7 @@ typedef struct {
// NOTE: sizeof(SVnodeCfg) < TSDB_FILE_HEADER_LEN/4 // NOTE: sizeof(SVnodeCfg) < TSDB_FILE_HEADER_LEN/4
typedef struct { typedef struct {
char acct[TSDB_USER_LEN]; char acct[TSDB_USER_LEN];
char db[TSDB_DB_NAME_LEN]; char db[TSDB_METER_ID_LEN+2]; // 8bytes align
uint32_t vgId; uint32_t vgId;
int32_t maxSessions; int32_t maxSessions;
int32_t cacheBlockSize; int32_t cacheBlockSize;
......
...@@ -57,12 +57,12 @@ extern char scriptDir[]; ...@@ -57,12 +57,12 @@ extern char scriptDir[];
extern char tsMasterIp[]; extern char tsMasterIp[];
extern char tsSecondIp[]; extern char tsSecondIp[];
extern short tsMgmtVnodePort; extern uint16_t tsMgmtVnodePort;
extern short tsMgmtShellPort; extern uint16_t tsMgmtShellPort;
extern short tsVnodeShellPort; extern uint16_t tsVnodeShellPort;
extern short tsVnodeVnodePort; extern uint16_t tsVnodeVnodePort;
extern short tsMgmtMgmtPort; extern uint16_t tsMgmtMgmtPort;
extern short tsMgmtSyncPort; extern uint16_t tsMgmtSyncPort;
extern int tsStatusInterval; extern int tsStatusInterval;
extern int tsShellActivityTimer; extern int tsShellActivityTimer;
...@@ -141,7 +141,7 @@ extern int tsProjectExecInterval; ...@@ -141,7 +141,7 @@ extern int tsProjectExecInterval;
extern int64_t tsMaxRetentWindow; extern int64_t tsMaxRetentWindow;
extern char tsHttpIp[]; extern char tsHttpIp[];
extern short tsHttpPort; extern uint16_t tsHttpPort;
extern int tsHttpCacheSessions; extern int tsHttpCacheSessions;
extern int tsHttpSessionExpire; extern int tsHttpSessionExpire;
extern int tsHttpMaxThreads; extern int tsHttpMaxThreads;
...@@ -150,6 +150,8 @@ extern int tsHttpEnableRecordSql; ...@@ -150,6 +150,8 @@ extern int tsHttpEnableRecordSql;
extern int tsTelegrafUseFieldNum; extern int tsTelegrafUseFieldNum;
extern int tsAdminRowLimit; extern int tsAdminRowLimit;
extern int tsTscEnableRecordSql;
extern char tsMonitorDbName[]; extern char tsMonitorDbName[];
extern char tsInternalPass[]; extern char tsInternalPass[];
extern int tsMonitorInterval; extern int tsMonitorInterval;
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_TNOTE_H
#define TDENGINE_TNOTE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "unistd.h"
#include "os.h"
#include "tutil.h"
#include "tglobalcfg.h"
#define MAX_NOTE_LINE_SIZE 66000
#define NOTE_FILE_NAME_LEN 300
typedef struct _taosNoteInfo {
int taosNoteFileNum ;
int taosNoteMaxLines;
int taosNoteLines;
char taosNoteName[NOTE_FILE_NAME_LEN];
int taosNoteFlag;
int taosNoteFd;
int taosNoteOpenInProgress;
pthread_mutex_t taosNoteMutex;
}taosNoteInfo;
void taosNotePrint(taosNoteInfo * pNote, const char * const format, ...);
extern taosNoteInfo m_HttpNote;
extern taosNoteInfo m_TscNote;
extern int tsHttpEnableRecordSql;
extern int tsTscEnableRecordSql;
#define taosNotePrintHttp(...) \
if (tsHttpEnableRecordSql) { \
taosNotePrint(&m_HttpNote, __VA_ARGS__); \
}
#define taosNotePrintTsc(...) \
if (tsTscEnableRecordSql) { \
taosNotePrint(&m_TscNote, __VA_ARGS__); \
}
#ifdef __cplusplus
}
#endif
#endif
...@@ -47,7 +47,7 @@ extern "C" { ...@@ -47,7 +47,7 @@ extern "C" {
typedef struct { typedef struct {
char *localIp; // local IP used char *localIp; // local IP used
short localPort; // local port uint16_t localPort; // local port
char *label; // for debug purpose char *label; // for debug purpose
int numOfThreads; // number of threads to handle connections int numOfThreads; // number of threads to handle connections
void *(*fp)(char *, void *, void *); // function to process the incoming msg void *(*fp)(char *, void *, void *); // function to process the incoming msg
...@@ -72,7 +72,7 @@ typedef struct { ...@@ -72,7 +72,7 @@ typedef struct {
void * shandle; // pointer returned by taosOpenRpc void * shandle; // pointer returned by taosOpenRpc
void * ahandle; // handle provided by app void * ahandle; // handle provided by app
char * peerIp; // peer IP string char * peerIp; // peer IP string
short peerPort; // peer port uint16_t peerPort; // peer port
char spi; // security parameter index char spi; // security parameter index
char encrypt; // encrypt algorithm char encrypt; // encrypt algorithm
char * secret; // key for authentication char * secret; // key for authentication
...@@ -107,7 +107,7 @@ int taosSendSimpleRsp(void *thandle, char rsptype, char code); ...@@ -107,7 +107,7 @@ int taosSendSimpleRsp(void *thandle, char rsptype, char code);
int taosSetSecurityInfo(int cid, int sid, char *id, int spi, int encrypt, char *secret, char *ckey); int taosSetSecurityInfo(int cid, int sid, char *id, int spi, int encrypt, char *secret, char *ckey);
void taosGetRpcConnInfo(void *thandle, uint32_t *peerId, uint32_t *peerIp, short *peerPort, int *cid, int *sid); void taosGetRpcConnInfo(void *thandle, uint32_t *peerId, uint32_t *peerIp, uint16_t *peerPort, int *cid, int *sid);
int taosGetOutType(void *thandle); int taosGetOutType(void *thandle);
......
...@@ -33,19 +33,19 @@ int taosWriteMsg(int fd, void *ptr, int nbytes); ...@@ -33,19 +33,19 @@ int taosWriteMsg(int fd, void *ptr, int nbytes);
int taosReadMsg(int fd, void *ptr, int nbytes); int taosReadMsg(int fd, void *ptr, int nbytes);
int taosOpenUdpSocket(char *ip, short port); int taosOpenUdpSocket(char *ip, uint16_t port);
int taosOpenTcpClientSocket(char *ip, short port, char *localIp); int taosOpenTcpClientSocket(char *ip, uint16_t port, char *localIp);
int taosOpenTcpServerSocket(char *ip, short port); int taosOpenTcpServerSocket(char *ip, uint16_t port);
int taosKeepTcpAlive(int sockFd); int taosKeepTcpAlive(int sockFd);
void taosCloseTcpSocket(int sockFd); void taosCloseTcpSocket(int sockFd);
int taosOpenUDServerSocket(char *ip, short port); int taosOpenUDServerSocket(char *ip, uint16_t port);
int taosOpenUDClientSocket(char *ip, short port); int taosOpenUDClientSocket(char *ip, uint16_t port);
int taosOpenRawSocket(char *ip); int taosOpenRawSocket(char *ip);
......
...@@ -31,6 +31,7 @@ extern "C" { ...@@ -31,6 +31,7 @@ extern "C" {
#define TK_OCT 204 // oct number #define TK_OCT 204 // oct number
#define TK_BIN 205 // bin format data 0b111 #define TK_BIN 205 // bin format data 0b111
#define TK_FILE 206 #define TK_FILE 206
#define TK_QUESTION 207 // denoting the placeholder of "?",when invoking statement bind query
#define TSQL_SO_ASC 1 #define TSQL_SO_ASC 1
#define TSQL_SO_DESC 0 #define TSQL_SO_DESC 0
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
#define TK_TABLE 62 #define TK_TABLE 62
#define TK_DATABASE 63 #define TK_DATABASE 63
#define TK_DNODE 64 #define TK_DNODE 64
#define TK_IP 65 #define TK_IPTOKEN 65
#define TK_USER 66 #define TK_USER 66
#define TK_ACCOUNT 67 #define TK_ACCOUNT 67
#define TK_USE 68 #define TK_USE 68
...@@ -210,7 +210,6 @@ ...@@ -210,7 +210,6 @@
#define TK_JOIN 192 #define TK_JOIN 192
#define TK_METRICS 193 #define TK_METRICS 193
#define TK_STABLE 194 #define TK_STABLE 194
#define TK_QUESTION 195
#endif #endif
......
...@@ -67,7 +67,7 @@ static struct argp_option options[] = { ...@@ -67,7 +67,7 @@ static struct argp_option options[] = {
/* Used by main to communicate with parse_opt. */ /* Used by main to communicate with parse_opt. */
struct arguments { struct arguments {
char *host; char *host;
int port; uint16_t port;
char *user; char *user;
char *password; char *password;
char *database; char *database;
...@@ -310,7 +310,7 @@ int main(int argc, char *argv[]) { ...@@ -310,7 +310,7 @@ int main(int argc, char *argv[]) {
enum MODE query_mode = arguments.mode; enum MODE query_mode = arguments.mode;
char *ip_addr = arguments.host; char *ip_addr = arguments.host;
int port = arguments.port; uint16_t port = arguments.port;
char *user = arguments.user; char *user = arguments.user;
char *pass = arguments.password; char *pass = arguments.password;
char *db_name = arguments.database; char *db_name = arguments.database;
...@@ -343,7 +343,7 @@ int main(int argc, char *argv[]) { ...@@ -343,7 +343,7 @@ int main(int argc, char *argv[]) {
struct tm tm = *localtime(&tTime); struct tm tm = *localtime(&tTime);
fprintf(fp, "###################################################################\n"); fprintf(fp, "###################################################################\n");
fprintf(fp, "# Server IP: %s:%d\n", ip_addr == NULL ? "localhost" : ip_addr, port); fprintf(fp, "# Server IP: %s:%hu\n", ip_addr == NULL ? "localhost" : ip_addr, port);
fprintf(fp, "# User: %s\n", user); fprintf(fp, "# User: %s\n", user);
fprintf(fp, "# Password: %s\n", pass); fprintf(fp, "# Password: %s\n", pass);
fprintf(fp, "# Use metric: %s\n", use_metric ? "true" : "false"); fprintf(fp, "# Use metric: %s\n", use_metric ? "true" : "false");
......
...@@ -172,7 +172,7 @@ struct arguments { ...@@ -172,7 +172,7 @@ struct arguments {
char *host; char *host;
char *user; char *user;
char *password; char *password;
int port; uint16_t port;
// output file // output file
char output[TSDB_FILENAME_LEN + 1]; char output[TSDB_FILENAME_LEN + 1];
char input[TSDB_FILENAME_LEN + 1]; char input[TSDB_FILENAME_LEN + 1];
......
...@@ -210,7 +210,7 @@ typedef struct HttpThread { ...@@ -210,7 +210,7 @@ typedef struct HttpThread {
typedef struct _http_server_obj_ { typedef struct _http_server_obj_ {
char label[HTTP_LABEL_SIZE]; char label[HTTP_LABEL_SIZE];
char serverIp[16]; char serverIp[16];
short serverPort; uint16_t serverPort;
int cacheContext; int cacheContext;
int sessionExpire; int sessionExpire;
int numOfThreads; int numOfThreads;
...@@ -233,7 +233,7 @@ bool httpCheckUsedbSql(char *sql); ...@@ -233,7 +233,7 @@ bool httpCheckUsedbSql(char *sql);
void httpTimeToString(time_t t, char *buf, int buflen); void httpTimeToString(time_t t, char *buf, int buflen);
// http init method // http init method
void *httpInitServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle); void *httpInitServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle);
void httpCleanUpServer(HttpServer *pServer); void httpCleanUpServer(HttpServer *pServer);
// http server connection // http server connection
......
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
#include "httpResp.h" #include "httpResp.h"
#include "taos.h" #include "taos.h"
#include "tsclient.h" #include "tsclient.h"
#include "tnote.h"
void *taos_connect_a(char *ip, char *user, char *pass, char *db, int port, void (*fp)(void *, TAOS_RES *, int), 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 *param, void **taos);
void httpProcessMultiSql(HttpContext *pContext); void httpProcessMultiSql(HttpContext *pContext);
void taosNotePrint(const char * const format, ...);
void httpProcessMultiSqlRetrieveCallBack(void *param, TAOS_RES *result, int numOfRows) { void httpProcessMultiSqlRetrieveCallBack(void *param, TAOS_RES *result, int numOfRows) {
HttpContext *pContext = (HttpContext *)param; HttpContext *pContext = (HttpContext *)param;
...@@ -165,7 +165,7 @@ void httpProcessMultiSql(HttpContext *pContext) { ...@@ -165,7 +165,7 @@ void httpProcessMultiSql(HttpContext *pContext) {
char *sql = httpGetCmdsString(pContext, cmd->sql); char *sql = httpGetCmdsString(pContext, cmd->sql);
httpDump("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, start query, sql:%s", pContext, pContext->fd, httpDump("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, start query, sql:%s", pContext, pContext->fd,
pContext->ipstr, pContext->user, multiCmds->pos, sql); pContext->ipstr, pContext->user, multiCmds->pos, sql);
taosNotePrint(sql); taosNotePrintHttp(sql);
taos_query_a(pContext->session->taos, sql, httpProcessMultiSqlCallBack, (void *)pContext); taos_query_a(pContext->session->taos, sql, httpProcessMultiSqlCallBack, (void *)pContext);
} }
...@@ -298,7 +298,7 @@ void httpProcessSingleSqlCmd(HttpContext *pContext) { ...@@ -298,7 +298,7 @@ void httpProcessSingleSqlCmd(HttpContext *pContext) {
httpDump("context:%p, fd:%d, ip:%s, user:%s, start query, sql:%s", pContext, pContext->fd, pContext->ipstr, httpDump("context:%p, fd:%d, ip:%s, user:%s, start query, sql:%s", pContext, pContext->fd, pContext->ipstr,
pContext->user, sql); pContext->user, sql);
taosNotePrint(sql); taosNotePrintHttp(sql);
taos_query_a(pSession->taos, sql, httpProcessSingleSqlCallBack, (void *)pContext); taos_query_a(pSession->taos, sql, httpProcessSingleSqlCallBack, (void *)pContext);
} }
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#endif #endif
static HttpServer *httpServer = NULL; static HttpServer *httpServer = NULL;
void taosInitNote(int numOfNoteLines, int maxNotes); void taosInitNote(int numOfNoteLines, int maxNotes, char* lable);
int httpInitSystem() { int httpInitSystem() {
taos_init(); taos_init();
...@@ -61,7 +61,7 @@ int httpInitSystem() { ...@@ -61,7 +61,7 @@ int httpInitSystem() {
pthread_mutex_init(&httpServer->serverMutex, NULL); pthread_mutex_init(&httpServer->serverMutex, NULL);
if (tsHttpEnableRecordSql != 0) { if (tsHttpEnableRecordSql != 0) {
taosInitNote(tsNumOfLogLines / 10, 1); taosInitNote(tsNumOfLogLines / 10, 1, (char*)"http_note");
} }
restInitHandle(httpServer); restInitHandle(httpServer);
adminInitHandle(httpServer); adminInitHandle(httpServer);
......
...@@ -61,7 +61,7 @@ typedef struct { ...@@ -61,7 +61,7 @@ typedef struct {
MonitorConn *monitor = NULL; MonitorConn *monitor = NULL;
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, int port, void (*fp)(void *, TAOS_RES *, int), 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 *param, void **taos);
void monitorInitConn(void *para, void *unused); void monitorInitConn(void *para, void *unused);
void monitorInitConnCb(void *param, TAOS_RES *result, int code); void monitorInitConnCb(void *param, TAOS_RES *result, int code);
......
...@@ -170,12 +170,12 @@ int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optle ...@@ -170,12 +170,12 @@ int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optle
return setsockopt(socketfd, level, optname, optval, (socklen_t)optlen); return setsockopt(socketfd, level, optname, optval, (socklen_t)optlen);
} }
int taosOpenUDClientSocket(char *ip, short port) { int taosOpenUDClientSocket(char *ip, uint16_t port) {
int sockFd = 0; int sockFd = 0;
struct sockaddr_un serverAddr; struct sockaddr_un serverAddr;
int ret; int ret;
char name[128]; char name[128];
sprintf(name, "%s.%d", ip, port); sprintf(name, "%s.%hu", ip, port);
sockFd = socket(AF_UNIX, SOCK_STREAM, 0); sockFd = socket(AF_UNIX, SOCK_STREAM, 0);
...@@ -198,13 +198,13 @@ int taosOpenUDClientSocket(char *ip, short port) { ...@@ -198,13 +198,13 @@ int taosOpenUDClientSocket(char *ip, short port) {
return sockFd; return sockFd;
} }
int taosOpenUDServerSocket(char *ip, short port) { int taosOpenUDServerSocket(char *ip, uint16_t port) {
struct sockaddr_un serverAdd; struct sockaddr_un serverAdd;
int sockFd; int sockFd;
char name[128]; char name[128];
pTrace("open ud socket:%s", name); pTrace("open ud socket:%s", name);
sprintf(name, "%s.%d", ip, port); sprintf(name, "%s.%hu", ip, port);
bzero((char *)&serverAdd, sizeof(serverAdd)); bzero((char *)&serverAdd, sizeof(serverAdd));
serverAdd.sun_family = AF_UNIX; serverAdd.sun_family = AF_UNIX;
...@@ -295,7 +295,7 @@ void taosGetSystemInfo() { ...@@ -295,7 +295,7 @@ void taosGetSystemInfo() {
taosGetSystemLocale(); taosGetSystemLocale();
} }
void *taosInitTcpClient(char *ip, short port, char *flabel, int num, void *fp, void *shandle) { void *taosInitTcpClient(char *ip, uint16_t port, char *flabel, int num, void *fp, void *shandle) {
tError("function taosInitTcpClient is not implemented in darwin system, exit!"); tError("function taosInitTcpClient is not implemented in darwin system, exit!");
exit(0); exit(0);
} }
...@@ -305,12 +305,12 @@ void taosCloseTcpClientConnection(void *chandle) { ...@@ -305,12 +305,12 @@ void taosCloseTcpClientConnection(void *chandle) {
exit(0); exit(0);
} }
void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short port) { void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, uint16_t port) {
tError("function taosOpenTcpClientConnection is not implemented in darwin system, exit!"); tError("function taosOpenTcpClientConnection is not implemented in darwin system, exit!");
exit(0); exit(0);
} }
int taosSendTcpClientData(unsigned int ip, short port, char *data, int len, void *chandle) { int taosSendTcpClientData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) {
tError("function taosSendTcpClientData is not implemented in darwin system, exit!"); tError("function taosSendTcpClientData is not implemented in darwin system, exit!");
exit(0); exit(0);
} }
...@@ -330,12 +330,12 @@ void taosCleanUpTcpServer(void *handle) { ...@@ -330,12 +330,12 @@ void taosCleanUpTcpServer(void *handle) {
exit(0); exit(0);
} }
void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle) { void *taosInitTcpServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle) {
tError("function taosInitTcpServer is not implemented in darwin system, exit!"); tError("function taosInitTcpServer is not implemented in darwin system, exit!");
exit(0); exit(0);
} }
int taosSendTcpServerData(unsigned int ip, short port, char *data, int len, void *chandle) { int taosSendTcpServerData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) {
tError("function taosSendTcpServerData is not implemented in darwin system, exit!"); tError("function taosSendTcpServerData is not implemented in darwin system, exit!");
exit(0); exit(0);
} }
......
...@@ -163,12 +163,12 @@ int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optle ...@@ -163,12 +163,12 @@ int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optle
return setsockopt(socketfd, level, optname, optval, (socklen_t)optlen); return setsockopt(socketfd, level, optname, optval, (socklen_t)optlen);
} }
int taosOpenUDClientSocket(char *ip, short port) { int taosOpenUDClientSocket(char *ip, uint16_t port) {
int sockFd = 0; int sockFd = 0;
struct sockaddr_un serverAddr; struct sockaddr_un serverAddr;
int ret; int ret;
char name[128]; char name[128];
sprintf(name, "%s.%d", ip, port); sprintf(name, "%s.%hu", ip, port);
sockFd = socket(AF_UNIX, SOCK_STREAM, 0); sockFd = socket(AF_UNIX, SOCK_STREAM, 0);
...@@ -191,13 +191,13 @@ int taosOpenUDClientSocket(char *ip, short port) { ...@@ -191,13 +191,13 @@ int taosOpenUDClientSocket(char *ip, short port) {
return sockFd; return sockFd;
} }
int taosOpenUDServerSocket(char *ip, short port) { int taosOpenUDServerSocket(char *ip, uint16_t port) {
struct sockaddr_un serverAdd; struct sockaddr_un serverAdd;
int sockFd; int sockFd;
char name[128]; char name[128];
pTrace("open ud socket:%s", name); pTrace("open ud socket:%s", name);
sprintf(name, "%s.%d", ip, port); sprintf(name, "%s.%hu", ip, port);
bzero((char *)&serverAdd, sizeof(serverAdd)); bzero((char *)&serverAdd, sizeof(serverAdd));
serverAdd.sun_family = AF_UNIX; serverAdd.sun_family = AF_UNIX;
......
...@@ -586,9 +586,13 @@ void taosKillSystem() { ...@@ -586,9 +586,13 @@ void taosKillSystem() {
kill(tsProcId, 2); kill(tsProcId, 2);
} }
extern int tsEnableCoreFile;
int _sysctl(struct __sysctl_args *args ); int _sysctl(struct __sysctl_args *args );
void taosSetCoreDump() { void taosSetCoreDump() {
if (0 == tsEnableCoreFile) {
return;
}
// 1. set ulimit -c unlimited // 1. set ulimit -c unlimited
struct rlimit rlim; struct rlimit rlim;
struct rlimit rlim_new; struct rlimit rlim_new;
...@@ -608,6 +612,7 @@ void taosSetCoreDump() { ...@@ -608,6 +612,7 @@ void taosSetCoreDump() {
pPrint("the new unlimited para: rlim_cur=%d, rlim_max=%d", rlim.rlim_cur, rlim.rlim_max); pPrint("the new unlimited para: rlim_cur=%d, rlim_max=%d", rlim.rlim_cur, rlim.rlim_max);
} }
#ifndef _TD_ARM_
// 2. set the path for saving core file // 2. set the path for saving core file
struct __sysctl_args args; struct __sysctl_args args;
int old_usespid = 0; int old_usespid = 0;
...@@ -649,9 +654,10 @@ void taosSetCoreDump() { ...@@ -649,9 +654,10 @@ void taosSetCoreDump() {
} }
pPrint("The new core_uses_pid[%d]: %d", old_len, old_usespid); pPrint("The new core_uses_pid[%d]: %d", old_len, old_usespid);
#endif
#if 0 #if 0
// 3. set the path for saving core file // 3. create the path for saving core file
int status; int status;
char coredump_dir[32] = "/var/log/taosdump"; char coredump_dir[32] = "/var/log/taosdump";
if (opendir(coredump_dir) == NULL) { if (opendir(coredump_dir) == NULL) {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "tlog.h" #include "tlog.h"
void *taosInitTcpClient(char *ip, short port, char *label, int num, void *fp, void *shandle) { void *taosInitTcpClient(char *ip, uint16_t port, char *label, int num, void *fp, void *shandle) {
tError("InitTcpClient not support in windows"); tError("InitTcpClient not support in windows");
return 0; return 0;
} }
...@@ -24,12 +24,12 @@ void taosCloseTcpClientConnection(void *chandle) { ...@@ -24,12 +24,12 @@ void taosCloseTcpClientConnection(void *chandle) {
tError("CloseTcpClientConnection not support in windows"); tError("CloseTcpClientConnection not support in windows");
} }
void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short port) { void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, uint16_t port) {
tError("OpenTcpClientConnection not support in windows"); tError("OpenTcpClientConnection not support in windows");
return 0; return 0;
} }
int taosSendTcpClientData(unsigned int ip, short port, char *data, int len, void *chandle) { int taosSendTcpClientData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) {
tError("SendTcpClientData not support in windows"); tError("SendTcpClientData not support in windows");
return 0; return 0;
} }
......
...@@ -23,12 +23,12 @@ void taosCleanUpTcpServer(void *handle) { ...@@ -23,12 +23,12 @@ void taosCleanUpTcpServer(void *handle) {
tError("CleanUpTcpServer not support in windows"); tError("CleanUpTcpServer not support in windows");
} }
void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle) { void *taosInitTcpServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle) {
tError("InitTcpServer not support in windows"); tError("InitTcpServer not support in windows");
return 0; return 0;
} }
int taosSendTcpServerData(unsigned int ip, short port, char *data, int len, void *chandle) { int taosSendTcpServerData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) {
tError("SendTcpServerData not support in windows"); tError("SendTcpServerData not support in windows");
return 0; return 0;
} }
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
void *taosOpenIpHash(int maxSessions); void *taosOpenIpHash(int maxSessions);
void taosCloseIpHash(void *handle); void taosCloseIpHash(void *handle);
void *taosAddIpHash(void *handle, void *pData, uint32_t ip, short port); void *taosAddIpHash(void *handle, void *pData, uint32_t ip, uint16_t port);
void taosDeleteIpHash(void *handle, uint32_t ip, short port); void taosDeleteIpHash(void *handle, uint32_t ip, uint16_t port);
void *taosGetIpHash(void *handle, uint32_t ip, short port); void *taosGetIpHash(void *handle, uint32_t ip, uint16_t port);
#endif #endif
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
#include "tsdb.h" #include "tsdb.h"
void *taosInitTcpClient(char *ip, short port, char *label, int num, void *fp, void *shandle); void *taosInitTcpClient(char *ip, uint16_t port, char *label, int num, void *fp, void *shandle);
void taosCleanUpTcpClient(void *chandle); void taosCleanUpTcpClient(void *chandle);
void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short port); void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, uint16_t port);
void taosCloseTcpClientConnection(void *chandle); void taosCloseTcpClientConnection(void *chandle);
int taosSendTcpClientData(uint32_t ip, short port, char *data, int len, void *chandle); int taosSendTcpClientData(uint32_t ip, uint16_t port, char *data, int len, void *chandle);
#endif #endif
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
#include "tsdb.h" #include "tsdb.h"
void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle); void *taosInitTcpServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle);
void taosCleanUpTcpServer(void *param); void taosCleanUpTcpServer(void *param);
void taosCloseTcpServerConnection(void *param); void taosCloseTcpServerConnection(void *param);
int taosSendTcpServerData(uint32_t ip, short port, char *data, int len, void *chandle); int taosSendTcpServerData(uint32_t ip, uint16_t port, char *data, int len, void *chandle);
#endif #endif
...@@ -18,11 +18,11 @@ ...@@ -18,11 +18,11 @@
#include "tsdb.h" #include "tsdb.h"
void *taosInitUdpServer(char *ip, short port, char *label, int, void *fp, void *shandle); void *taosInitUdpServer(char *ip, uint16_t port, char *label, int, void *fp, void *shandle);
void *taosInitUdpClient(char *ip, short port, char *label, int, void *fp, void *shandle); void *taosInitUdpClient(char *ip, uint16_t port, char *label, int, void *fp, void *shandle);
void taosCleanUpUdpConnection(void *handle); void taosCleanUpUdpConnection(void *handle);
int taosSendUdpData(uint32_t ip, short port, char *data, int dataLen, void *chandle); int taosSendUdpData(uint32_t ip, uint16_t port, char *data, int dataLen, void *chandle);
void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, short port); void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, uint16_t port);
void taosFreeMsgHdr(void *hdr); void taosFreeMsgHdr(void *hdr);
int taosMsgHdrSize(void *hdr); int taosMsgHdrSize(void *hdr);
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
typedef struct _ip_hash_t { typedef struct _ip_hash_t {
uint32_t ip; uint32_t ip;
short port; uint16_t port;
int hash; int hash;
struct _ip_hash_t *prev; struct _ip_hash_t *prev;
struct _ip_hash_t *next; struct _ip_hash_t *next;
...@@ -32,20 +32,20 @@ typedef struct { ...@@ -32,20 +32,20 @@ typedef struct {
int maxSessions; int maxSessions;
} SHashObj; } SHashObj;
int taosHashIp(void *handle, uint32_t ip, short port) { int taosHashIp(void *handle, uint32_t ip, uint16_t port) {
SHashObj *pObj = (SHashObj *)handle; SHashObj *pObj = (SHashObj *)handle;
int hash = 0; int hash = 0;
hash = (int)(ip >> 16); hash = (int)(ip >> 16);
hash += (unsigned short)(ip & 0xFFFF); hash += (unsigned short)(ip & 0xFFFF);
hash += (unsigned short)port; hash += port;
hash = hash % pObj->maxSessions; hash = hash % pObj->maxSessions;
return hash; return hash;
} }
void *taosAddIpHash(void *handle, void *data, uint32_t ip, short port) { void *taosAddIpHash(void *handle, void *data, uint32_t ip, uint16_t port) {
int hash; int hash;
SIpHash * pNode; SIpHash * pNode;
SHashObj *pObj; SHashObj *pObj;
...@@ -68,7 +68,7 @@ void *taosAddIpHash(void *handle, void *data, uint32_t ip, short port) { ...@@ -68,7 +68,7 @@ void *taosAddIpHash(void *handle, void *data, uint32_t ip, short port) {
return pObj; return pObj;
} }
void taosDeleteIpHash(void *handle, uint32_t ip, short port) { void taosDeleteIpHash(void *handle, uint32_t ip, uint16_t port) {
int hash; int hash;
SIpHash * pNode; SIpHash * pNode;
SHashObj *pObj; SHashObj *pObj;
...@@ -100,7 +100,7 @@ void taosDeleteIpHash(void *handle, uint32_t ip, short port) { ...@@ -100,7 +100,7 @@ void taosDeleteIpHash(void *handle, uint32_t ip, short port) {
} }
} }
void *taosGetIpHash(void *handle, uint32_t ip, short port) { void *taosGetIpHash(void *handle, uint32_t ip, uint16_t port) {
int hash; int hash;
SIpHash * pNode; SIpHash * pNode;
SHashObj *pObj; SHashObj *pObj;
......
...@@ -51,10 +51,10 @@ typedef struct { ...@@ -51,10 +51,10 @@ typedef struct {
uint8_t secret[TSDB_KEY_LEN]; uint8_t secret[TSDB_KEY_LEN];
uint8_t ckey[TSDB_KEY_LEN]; uint8_t ckey[TSDB_KEY_LEN];
short localPort; // for UDP only uint16_t localPort; // for UDP only
uint32_t peerUid; uint32_t peerUid;
uint32_t peerIp; // peer IP uint32_t peerIp; // peer IP
short peerPort; // peer port uint16_t peerPort; // peer port
char peerIpstr[20]; // peer IP string char peerIpstr[20]; // peer IP string
uint16_t tranId; // outgoing transcation ID, for build message uint16_t tranId; // outgoing transcation ID, for build message
uint16_t outTranId; // outgoing transcation ID uint16_t outTranId; // outgoing transcation ID
...@@ -99,7 +99,7 @@ typedef struct rpc_server { ...@@ -99,7 +99,7 @@ typedef struct rpc_server {
int idleTime; // milliseconds; int idleTime; // milliseconds;
int noFree; // do not free the request msg when rsp is received int noFree; // do not free the request msg when rsp is received
int index; // for UDP server, next thread for new connection int index; // for UDP server, next thread for new connection
short localPort; uint16_t localPort;
char label[12]; char label[12];
void *(*fp)(char *, void *ahandle, void *thandle); void *(*fp)(char *, void *ahandle, void *thandle);
void (*efp)(int); // FP to report error void (*efp)(int); // FP to report error
...@@ -114,16 +114,16 @@ int tsRpcProgressTime = 10; // milliseocnds ...@@ -114,16 +114,16 @@ int tsRpcProgressTime = 10; // milliseocnds
int tsRpcMaxRetry; int tsRpcMaxRetry;
int tsRpcHeadSize; int tsRpcHeadSize;
void *(*taosInitConn[])(char *ip, short port, char *label, int threads, void *fp, void *shandle) = { void *(*taosInitConn[])(char *ip, uint16_t port, char *label, int threads, void *fp, void *shandle) = {
taosInitUdpServer, taosInitUdpClient, taosInitTcpServer, taosInitTcpClient}; taosInitUdpServer, taosInitUdpClient, taosInitTcpServer, taosInitTcpClient};
void (*taosCleanUpConn[])(void *thandle) = {taosCleanUpUdpConnection, taosCleanUpUdpConnection, taosCleanUpTcpServer, void (*taosCleanUpConn[])(void *thandle) = {taosCleanUpUdpConnection, taosCleanUpUdpConnection, taosCleanUpTcpServer,
taosCleanUpTcpClient}; taosCleanUpTcpClient};
int (*taosSendData[])(uint32_t ip, short port, char *data, int len, void *chandle) = { int (*taosSendData[])(uint32_t ip, uint16_t port, char *data, int len, void *chandle) = {
taosSendUdpData, taosSendUdpData, taosSendTcpServerData, taosSendTcpClientData}; taosSendUdpData, taosSendUdpData, taosSendTcpServerData, taosSendTcpClientData};
void *(*taosOpenConn[])(void *shandle, void *thandle, char *ip, short port) = { void *(*taosOpenConn[])(void *shandle, void *thandle, char *ip, uint16_t port) = {
taosOpenUdpConnection, taosOpenUdpConnection,
taosOpenUdpConnection, taosOpenUdpConnection,
NULL, NULL,
...@@ -134,7 +134,7 @@ void (*taosCloseConn[])(void *chandle) = {NULL, NULL, taosCloseTcpServerConnecti ...@@ -134,7 +134,7 @@ void (*taosCloseConn[])(void *chandle) = {NULL, NULL, taosCloseTcpServerConnecti
int taosReSendRspToPeer(SRpcConn *pConn); int taosReSendRspToPeer(SRpcConn *pConn);
void taosProcessTaosTimer(void *, void *); void taosProcessTaosTimer(void *, void *);
void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, short port, void *shandle, void *thandle, void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, uint16_t port, void *shandle, void *thandle,
void *chandle); void *chandle);
int taosSendDataToPeer(SRpcConn *pConn, char *data, int dataLen); int taosSendDataToPeer(SRpcConn *pConn, char *data, int dataLen);
void taosProcessSchedMsg(SSchedMsg *pMsg); void taosProcessSchedMsg(SSchedMsg *pMsg);
...@@ -720,7 +720,7 @@ void taosProcessResponse(SRpcConn *pConn) { ...@@ -720,7 +720,7 @@ void taosProcessResponse(SRpcConn *pConn) {
} }
int taosProcessMsgHeader(STaosHeader *pHeader, SRpcConn **ppConn, STaosRpc *pServer, int dataLen, uint32_t ip, int taosProcessMsgHeader(STaosHeader *pHeader, SRpcConn **ppConn, STaosRpc *pServer, int dataLen, uint32_t ip,
short port, void *chandle) { uint16_t port, void *chandle) {
int chann, sid, code = 0; int chann, sid, code = 0;
SRpcConn * pConn = NULL; SRpcConn * pConn = NULL;
SRpcChann *pChann; SRpcChann *pChann;
...@@ -1009,7 +1009,7 @@ void taosProcessIdleTimer(void *param, void *tmrId) { ...@@ -1009,7 +1009,7 @@ void taosProcessIdleTimer(void *param, void *tmrId) {
pthread_mutex_unlock(&pChann->mutex); pthread_mutex_unlock(&pChann->mutex);
} }
void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, short port, void *shandle, void *thandle, void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, uint16_t port, void *shandle, void *thandle,
void *chandle) { void *chandle) {
STaosHeader *pHeader; STaosHeader *pHeader;
uint8_t code; uint8_t code;
...@@ -1075,6 +1075,7 @@ void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, short port, ...@@ -1075,6 +1075,7 @@ void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, short port,
// parsing error // parsing error
if (pHeader->msgType & 1) { if (pHeader->msgType & 1) {
memset(pReply, 0, sizeof(pReply));
msgLen = taosBuildErrorMsgToPeer(data, code, pReply); msgLen = taosBuildErrorMsgToPeer(data, code, pReply);
(*taosSendData[pServer->type])(ip, port, pReply, msgLen, chandle); (*taosSendData[pServer->type])(ip, port, pReply, msgLen, chandle);
tTrace("%s cid:%d sid:%d id:%s, %s is sent with error code:%u pConn:%p", pServer->label, chann, sid, tTrace("%s cid:%d sid:%d id:%s, %s is sent with error code:%u pConn:%p", pServer->label, chann, sid,
...@@ -1311,7 +1312,7 @@ void taosProcessTaosTimer(void *param, void *tmrId) { ...@@ -1311,7 +1312,7 @@ void taosProcessTaosTimer(void *param, void *tmrId) {
} }
void taosGetRpcConnInfo(void *thandle, uint32_t *peerId, uint32_t *peerIp, short *peerPort, int *cid, int *sid) { void taosGetRpcConnInfo(void *thandle, uint32_t *peerId, uint32_t *peerIp, uint16_t *peerPort, int *cid, int *sid) {
SRpcConn *pConn = (SRpcConn *)thandle; SRpcConn *pConn = (SRpcConn *)thandle;
*peerId = pConn->peerId; *peerId = pConn->peerId;
......
...@@ -30,7 +30,7 @@ typedef struct _tcp_fd { ...@@ -30,7 +30,7 @@ typedef struct _tcp_fd {
void * thandle; void * thandle;
uint32_t ip; uint32_t ip;
char ipstr[20]; char ipstr[20];
short port; uint16_t port;
struct _tcp_client *pTcp; struct _tcp_client *pTcp;
struct _tcp_fd * prev, *next; struct _tcp_fd * prev, *next;
} STcpFd; } STcpFd;
...@@ -45,7 +45,7 @@ typedef struct _tcp_client { ...@@ -45,7 +45,7 @@ typedef struct _tcp_client {
char label[12]; char label[12];
char ipstr[20]; char ipstr[20];
void * shandle; // handle passed by upper layer during server initialization void * shandle; // handle passed by upper layer during server initialization
void *(*processData)(char *data, int dataLen, unsigned int ip, short port, void *shandle, void *thandle, void *(*processData)(char *data, int dataLen, unsigned int ip, uint16_t port, void *shandle, void *thandle,
void *chandle); void *chandle);
// char buffer[128000]; // char buffer[128000];
} STcpClient; } STcpClient;
...@@ -194,7 +194,7 @@ static void *taosReadTcpData(void *param) { ...@@ -194,7 +194,7 @@ static void *taosReadTcpData(void *param) {
return NULL; return NULL;
} }
void *taosInitTcpClient(char *ip, short port, char *label, int num, void *fp, void *shandle) { void *taosInitTcpClient(char *ip, uint16_t port, char *label, int num, void *fp, void *shandle) {
STcpClient * pTcp; STcpClient * pTcp;
pthread_attr_t thattr; pthread_attr_t thattr;
...@@ -229,7 +229,7 @@ void *taosInitTcpClient(char *ip, short port, char *label, int num, void *fp, vo ...@@ -229,7 +229,7 @@ void *taosInitTcpClient(char *ip, short port, char *label, int num, void *fp, vo
return NULL; return NULL;
} }
tTrace("%s TCP client is initialized, ip:%s port:%u", label, ip, port); tTrace("%s TCP client is initialized, ip:%s port:%hu", label, ip, port);
return pTcp; return pTcp;
} }
...@@ -242,7 +242,7 @@ void taosCloseTcpClientConnection(void *chandle) { ...@@ -242,7 +242,7 @@ void taosCloseTcpClientConnection(void *chandle) {
taosCleanUpTcpFdObj(pFdObj); taosCleanUpTcpFdObj(pFdObj);
} }
void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short port) { void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, uint16_t port) {
STcpClient * pTcp = (STcpClient *)shandle; STcpClient * pTcp = (STcpClient *)shandle;
STcpFd * pFdObj; STcpFd * pFdObj;
struct epoll_event event; struct epoll_event event;
...@@ -301,12 +301,12 @@ void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short ...@@ -301,12 +301,12 @@ void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short
pthread_mutex_unlock(&(pTcp->mutex)); pthread_mutex_unlock(&(pTcp->mutex));
tTrace("%s TCP connection to ip:%s port:%u is created, numOfFds:%d", pTcp->label, ip, port, pTcp->numOfFds); tTrace("%s TCP connection to ip:%s port:%hu is created, numOfFds:%d", pTcp->label, ip, port, pTcp->numOfFds);
return pFdObj; return pFdObj;
} }
int taosSendTcpClientData(uint32_t ip, short port, char *data, int len, void *chandle) { int taosSendTcpClientData(uint32_t ip, uint16_t port, char *data, int len, void *chandle) {
STcpFd *pFdObj = (STcpFd *)chandle; STcpFd *pFdObj = (STcpFd *)chandle;
if (chandle == NULL) return -1; if (chandle == NULL) return -1;
......
...@@ -32,7 +32,7 @@ typedef struct _fd_obj { ...@@ -32,7 +32,7 @@ typedef struct _fd_obj {
void * thandle; // handle from upper layer, like TAOS void * thandle; // handle from upper layer, like TAOS
char ipstr[TAOS_IPv4ADDR_LEN]; char ipstr[TAOS_IPv4ADDR_LEN];
unsigned int ip; unsigned int ip;
unsigned short port; uint16_t port;
struct _thread_obj *pThreadObj; struct _thread_obj *pThreadObj;
struct _fd_obj * prev, *next; struct _fd_obj * prev, *next;
} SFdObj; } SFdObj;
...@@ -48,13 +48,13 @@ typedef struct _thread_obj { ...@@ -48,13 +48,13 @@ typedef struct _thread_obj {
char label[12]; char label[12];
// char buffer[128000]; // buffer to receive data // char buffer[128000]; // buffer to receive data
void *shandle; // handle passed by upper layer during server initialization void *shandle; // handle passed by upper layer during server initialization
void *(*processData)(char *data, int dataLen, unsigned int ip, short port, void *shandle, void *thandle, void *(*processData)(char *data, int dataLen, unsigned int ip, uint16_t port, void *shandle, void *thandle,
void *chandle); void *chandle);
} SThreadObj; } SThreadObj;
typedef struct { typedef struct {
char ip[40]; char ip[40];
short port; uint16_t port;
char label[12]; char label[12];
int numOfThreads; int numOfThreads;
void * shandle; void * shandle;
...@@ -209,7 +209,7 @@ static void taosProcessTcpData(void *param) { ...@@ -209,7 +209,7 @@ static void taosProcessTcpData(void *param) {
continue; continue;
} }
pFdObj->thandle = (*(pThreadObj->processData))(buffer, dataLen, pFdObj->ip, (int16_t)pFdObj->port, pFdObj->thandle = (*(pThreadObj->processData))(buffer, dataLen, pFdObj->ip, pFdObj->port,
pThreadObj->shandle, pFdObj->thandle, pFdObj); pThreadObj->shandle, pFdObj->thandle, pFdObj);
if (pFdObj->thandle == NULL) taosCleanUpFdObj(pFdObj); if (pFdObj->thandle == NULL) taosCleanUpFdObj(pFdObj);
...@@ -232,10 +232,10 @@ void taosAcceptTcpConnection(void *arg) { ...@@ -232,10 +232,10 @@ void taosAcceptTcpConnection(void *arg) {
sockFd = taosOpenTcpServerSocket(pServerObj->ip, pServerObj->port); sockFd = taosOpenTcpServerSocket(pServerObj->ip, pServerObj->port);
if (sockFd < 0) { if (sockFd < 0) {
tError("%s failed to open TCP socket, ip:%s, port:%u", pServerObj->label, pServerObj->ip, pServerObj->port); tError("%s failed to open TCP socket, ip:%s, port:%hu", pServerObj->label, pServerObj->ip, pServerObj->port);
return; return;
} else { } else {
tTrace("%s TCP server is ready, ip:%s, port:%u", pServerObj->label, pServerObj->ip, pServerObj->port); tTrace("%s TCP server is ready, ip:%s, port:%hu", pServerObj->label, pServerObj->ip, pServerObj->port);
} }
while (1) { while (1) {
...@@ -247,7 +247,7 @@ void taosAcceptTcpConnection(void *arg) { ...@@ -247,7 +247,7 @@ void taosAcceptTcpConnection(void *arg) {
continue; continue;
} }
tTrace("%s TCP connection from ip:%s port:%u", pServerObj->label, inet_ntoa(clientAddr.sin_addr), tTrace("%s TCP connection from ip:%s port:%hu", pServerObj->label, inet_ntoa(clientAddr.sin_addr),
htons(clientAddr.sin_port)); htons(clientAddr.sin_port));
taosKeepTcpAlive(connFd); taosKeepTcpAlive(connFd);
...@@ -292,7 +292,7 @@ void taosAcceptTcpConnection(void *arg) { ...@@ -292,7 +292,7 @@ void taosAcceptTcpConnection(void *arg) {
pthread_mutex_unlock(&(pThreadObj->threadMutex)); pthread_mutex_unlock(&(pThreadObj->threadMutex));
tTrace("%s TCP thread:%d, a new connection, ip:%s port:%u, numOfFds:%d", pServerObj->label, pThreadObj->threadId, tTrace("%s TCP thread:%d, a new connection, ip:%s port:%hu, numOfFds:%d", pServerObj->label, pThreadObj->threadId,
pFdObj->ipstr, pFdObj->port, pThreadObj->numOfFds); pFdObj->ipstr, pFdObj->port, pThreadObj->numOfFds);
// pick up next thread for next connection // pick up next thread for next connection
...@@ -314,10 +314,10 @@ void taosAcceptUDConnection(void *arg) { ...@@ -314,10 +314,10 @@ void taosAcceptUDConnection(void *arg) {
sockFd = taosOpenUDServerSocket(pServerObj->ip, pServerObj->port); sockFd = taosOpenUDServerSocket(pServerObj->ip, pServerObj->port);
if (sockFd < 0) { if (sockFd < 0) {
tError("%s failed to open UD socket, ip:%s, port:%u", pServerObj->label, pServerObj->ip, pServerObj->port); tError("%s failed to open UD socket, ip:%s, port:%hu", pServerObj->label, pServerObj->ip, pServerObj->port);
return; return;
} else { } else {
tTrace("%s UD server is ready, ip:%s, port:%u", pServerObj->label, pServerObj->ip, pServerObj->port); tTrace("%s UD server is ready, ip:%s, port:%hu", pServerObj->label, pServerObj->ip, pServerObj->port);
} }
while (1) { while (1) {
...@@ -374,7 +374,7 @@ void taosAcceptUDConnection(void *arg) { ...@@ -374,7 +374,7 @@ void taosAcceptUDConnection(void *arg) {
} }
} }
void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle) { void *taosInitTcpServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle) {
int i; int i;
SServerObj * pServerObj; SServerObj * pServerObj;
pthread_attr_t thattr; pthread_attr_t thattr;
...@@ -442,7 +442,7 @@ void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, voi ...@@ -442,7 +442,7 @@ void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, voi
} }
*/ */
pthread_attr_destroy(&thattr); pthread_attr_destroy(&thattr);
tTrace("%s TCP server is initialized, ip:%s port:%u numOfThreads:%d", label, ip, port, numOfThreads); tTrace("%s TCP server is initialized, ip:%s port:%hu numOfThreads:%d", label, ip, port, numOfThreads);
return (void *)pServerObj; return (void *)pServerObj;
} }
...@@ -468,7 +468,7 @@ void taosListTcpConnection(void *handle, char *buffer) { ...@@ -468,7 +468,7 @@ void taosListTcpConnection(void *handle, char *buffer) {
msg = msg + strlen(msg); msg = msg + strlen(msg);
pFdObj = pThreadObj->pHead; pFdObj = pThreadObj->pHead;
while (pFdObj) { while (pFdObj) {
sprintf(" ip:%s port:%u\n", pFdObj->ipstr, pFdObj->port); sprintf(" ip:%s port:%hu\n", pFdObj->ipstr, pFdObj->port);
msg = msg + strlen(msg); msg = msg + strlen(msg);
numOfFds++; numOfFds++;
numOfConns++; numOfConns++;
...@@ -487,7 +487,7 @@ void taosListTcpConnection(void *handle, char *buffer) { ...@@ -487,7 +487,7 @@ void taosListTcpConnection(void *handle, char *buffer) {
return; return;
} }
int taosSendTcpServerData(uint32_t ip, short port, char *data, int len, void *chandle) { int taosSendTcpServerData(uint32_t ip, uint16_t port, char *data, int len, void *chandle) {
SFdObj *pFdObj = (SFdObj *)chandle; SFdObj *pFdObj = (SFdObj *)chandle;
if (chandle == NULL) return -1; if (chandle == NULL) return -1;
......
...@@ -35,8 +35,8 @@ typedef struct { ...@@ -35,8 +35,8 @@ typedef struct {
void * signature; void * signature;
int index; int index;
int fd; int fd;
short port; // peer port uint16_t port; // peer port
short localPort; // local port uint16_t localPort; // local port
char label[12]; // copy from udpConnSet; char label[12]; // copy from udpConnSet;
pthread_t thread; pthread_t thread;
pthread_mutex_t mutex; pthread_mutex_t mutex;
...@@ -44,7 +44,7 @@ typedef struct { ...@@ -44,7 +44,7 @@ typedef struct {
void * hash; void * hash;
void * shandle; // handle passed by upper layer during server initialization void * shandle; // handle passed by upper layer during server initialization
void * pSet; void * pSet;
void *(*processData)(char *data, int dataLen, unsigned int ip, short port, void *shandle, void *thandle, void *(*processData)(char *data, int dataLen, unsigned int ip, uint16_t port, void *shandle, void *thandle,
void *chandle); void *chandle);
char buffer[RPC_MAX_UDP_SIZE]; // buffer to receive data char buffer[RPC_MAX_UDP_SIZE]; // buffer to receive data
} SUdpConn; } SUdpConn;
...@@ -53,21 +53,21 @@ typedef struct { ...@@ -53,21 +53,21 @@ typedef struct {
int index; int index;
int server; int server;
char ip[16]; // local IP char ip[16]; // local IP
short port; // local Port uint16_t port; // local Port
void * shandle; // handle passed by upper layer during server initialization void * shandle; // handle passed by upper layer during server initialization
int threads; int threads;
char label[12]; char label[12];
void * tmrCtrl; void * tmrCtrl;
pthread_t tcpThread; pthread_t tcpThread;
int tcpFd; int tcpFd;
void *(*fp)(char *data, int dataLen, uint32_t ip, short port, void *shandle, void *thandle, void *chandle); void *(*fp)(char *data, int dataLen, uint32_t ip, uint16_t port, void *shandle, void *thandle, void *chandle);
SUdpConn udpConn[]; SUdpConn udpConn[];
} SUdpConnSet; } SUdpConnSet;
typedef struct { typedef struct {
void * signature; void * signature;
uint32_t ip; // dest IP uint32_t ip; // dest IP
short port; // dest Port uint16_t port; // dest Port
SUdpConn * pConn; SUdpConn * pConn;
struct sockaddr_in destAdd; struct sockaddr_in destAdd;
void * msgHdr; void * msgHdr;
...@@ -144,12 +144,12 @@ void *taosReadTcpData(void *argv) { ...@@ -144,12 +144,12 @@ void *taosReadTcpData(void *argv) {
pInfo->msgLen = (int32_t)htonl((uint32_t)pInfo->msgLen); pInfo->msgLen = (int32_t)htonl((uint32_t)pInfo->msgLen);
tinet_ntoa(ipstr, pMonitor->ip); tinet_ntoa(ipstr, pMonitor->ip);
tTrace("%s receive packet via TCP:%s:%d, msgLen:%d, handle:0x%x, source:0x%08x dest:0x%08x tranId:%d", pSet->label, tTrace("%s receive packet via TCP:%s:%hu, msgLen:%d, handle:0x%x, source:0x%08x dest:0x%08x tranId:%d", pSet->label,
ipstr, pInfo->port, pInfo->msgLen, pInfo->handle, pHead->sourceId, pHead->destId, pHead->tranId); ipstr, pInfo->port, pInfo->msgLen, pInfo->handle, pHead->sourceId, pHead->destId, pHead->tranId);
fd = taosOpenTcpClientSocket(ipstr, (int16_t)pInfo->port, tsLocalIp); fd = taosOpenTcpClientSocket(ipstr, (int16_t)pInfo->port, tsLocalIp);
if (fd < 0) { if (fd < 0) {
tError("%s failed to open TCP client socket ip:%s:%d", pSet->label, ipstr, pInfo->port); tError("%s failed to open TCP client socket ip:%s:%hu", pSet->label, ipstr, pInfo->port);
pMonitor->pSet = NULL; pMonitor->pSet = NULL;
return NULL; return NULL;
} }
...@@ -180,7 +180,7 @@ void *taosReadTcpData(void *argv) { ...@@ -180,7 +180,7 @@ void *taosReadTcpData(void *argv) {
tError("%s failed to read data from server, msgLen:%d retLen:%d", pSet->label, pInfo->msgLen, retLen); tError("%s failed to read data from server, msgLen:%d retLen:%d", pSet->label, pInfo->msgLen, retLen);
tfree(buffer); tfree(buffer);
} else { } else {
(*pSet->fp)(buffer, pInfo->msgLen, pMonitor->ip, (int16_t)pInfo->port, pSet->shandle, NULL, pMonitor->pConn); (*pSet->fp)(buffer, pInfo->msgLen, pMonitor->ip, pInfo->port, pSet->shandle, NULL, pMonitor->pConn);
} }
} }
...@@ -224,7 +224,7 @@ void *taosRecvUdpData(void *param) { ...@@ -224,7 +224,7 @@ void *taosRecvUdpData(void *param) {
struct sockaddr_in sourceAdd; struct sockaddr_in sourceAdd;
unsigned int addLen, dataLen; unsigned int addLen, dataLen;
SUdpConn * pConn = (SUdpConn *)param; SUdpConn * pConn = (SUdpConn *)param;
short port; uint16_t port;
int minSize = sizeof(STaosHeader); int minSize = sizeof(STaosHeader);
memset(&sourceAdd, 0, sizeof(sourceAdd)); memset(&sourceAdd, 0, sizeof(sourceAdd));
...@@ -242,7 +242,7 @@ void *taosRecvUdpData(void *param) { ...@@ -242,7 +242,7 @@ void *taosRecvUdpData(void *param) {
continue; continue;
} }
port = (int16_t)ntohs(sourceAdd.sin_port); port = ntohs(sourceAdd.sin_port);
int processedLen = 0, leftLen = 0; int processedLen = 0, leftLen = 0;
int msgLen = 0; int msgLen = 0;
...@@ -307,7 +307,7 @@ void *taosTransferDataViaTcp(void *argv) { ...@@ -307,7 +307,7 @@ void *taosTransferDataViaTcp(void *argv) {
if (handle == 0) { if (handle == 0) {
// receive a packet from client // receive a packet from client
tTrace("%s data will be received via TCP from 0x%x:%d", pSet->label, pTransfer->ip, pTransfer->port); tTrace("%s data will be received via TCP from 0x%x:%hu", pSet->label, pTransfer->ip, pTransfer->port);
retLen = taosReadMsg(connFd, &head, sizeof(STaosHeader)); retLen = taosReadMsg(connFd, &head, sizeof(STaosHeader));
if (retLen != (int)sizeof(STaosHeader)) { if (retLen != (int)sizeof(STaosHeader)) {
tError("%s failed to read msg header, retLen:%d", pSet->label, retLen); tError("%s failed to read msg header, retLen:%d", pSet->label, retLen);
...@@ -345,7 +345,7 @@ void *taosTransferDataViaTcp(void *argv) { ...@@ -345,7 +345,7 @@ void *taosTransferDataViaTcp(void *argv) {
tError("%s failed to read data from client, leftLen:%d retLen:%d, error:%s", pSet->label, leftLen, retLen, tError("%s failed to read data from client, leftLen:%d retLen:%d, error:%s", pSet->label, leftLen, retLen,
strerror(errno)); strerror(errno));
} else { } else {
tTrace("%s data is received from client via TCP from 0x%x:%d, msgLen:%d", pSet->label, pTransfer->ip, tTrace("%s data is received from client via TCP from 0x%x:%hu, msgLen:%d", pSet->label, pTransfer->ip,
pTransfer->port, msgLen); pTransfer->port, msgLen);
pSet->index = (pSet->index + 1) % pSet->threads; pSet->index = (pSet->index + 1) % pSet->threads;
SUdpConn *pConn = pSet->udpConn + pSet->index; SUdpConn *pConn = pSet->udpConn + pSet->index;
...@@ -388,7 +388,7 @@ void *taosTransferDataViaTcp(void *argv) { ...@@ -388,7 +388,7 @@ void *taosTransferDataViaTcp(void *argv) {
if (retLen != msgLen) { if (retLen != msgLen) {
tError("%s failed to send data to client, msgLen:%d retLen:%d", pSet->label, msgLen, retLen); tError("%s failed to send data to client, msgLen:%d retLen:%d", pSet->label, msgLen, retLen);
} else { } else {
tTrace("%s data is sent to client successfully via TCP to 0x%x:%d, size:%d", pSet->label, pTransfer->ip, tTrace("%s data is sent to client successfully via TCP to 0x%x:%hu, size:%d", pSet->label, pTransfer->ip,
pTransfer->port, msgLen); pTransfer->port, msgLen);
} }
} }
...@@ -413,13 +413,13 @@ void *taosUdpTcpConnection(void *argv) { ...@@ -413,13 +413,13 @@ void *taosUdpTcpConnection(void *argv) {
pSet->tcpFd = taosOpenTcpServerSocket(pSet->ip, pSet->port); pSet->tcpFd = taosOpenTcpServerSocket(pSet->ip, pSet->port);
if (pSet->tcpFd < 0) { if (pSet->tcpFd < 0) {
tPrint("%s failed to create TCP socket %s:%d for UDP server, reason:%s", pSet->label, pSet->ip, pSet->port, tPrint("%s failed to create TCP socket %s:%hu for UDP server, reason:%s", pSet->label, pSet->ip, pSet->port,
strerror(errno)); strerror(errno));
taosKillSystem(); taosKillSystem();
return NULL; return NULL;
} }
tTrace("%s UDP server is created, ip:%s:%d", pSet->label, pSet->ip, pSet->port); tTrace("%s UDP server is created, ip:%s:%hu", pSet->label, pSet->ip, pSet->port);
pthread_attr_init(&thattr); pthread_attr_init(&thattr);
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_DETACHED);
...@@ -455,7 +455,7 @@ void *taosUdpTcpConnection(void *argv) { ...@@ -455,7 +455,7 @@ void *taosUdpTcpConnection(void *argv) {
return NULL; return NULL;
} }
void *taosInitUdpConnection(char *ip, short port, char *label, int threads, void *fp, void *shandle) { void *taosInitUdpConnection(char *ip, uint16_t port, char *label, int threads, void *fp, void *shandle) {
pthread_attr_t thAttr; pthread_attr_t thAttr;
SUdpConn * pConn; SUdpConn * pConn;
SUdpConnSet * pSet; SUdpConnSet * pSet;
...@@ -488,13 +488,13 @@ void *taosInitUdpConnection(char *ip, short port, char *label, int threads, void ...@@ -488,13 +488,13 @@ void *taosInitUdpConnection(char *ip, short port, char *label, int threads, void
pthread_attr_init(&thAttr); pthread_attr_init(&thAttr);
pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE); pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE);
short ownPort; uint16_t ownPort;
for (int i = 0; i < threads; ++i) { for (int i = 0; i < threads; ++i) {
pConn = pSet->udpConn + i; pConn = pSet->udpConn + i;
ownPort = (int16_t)(port ? port + i : 0); ownPort = (port ? port + i : 0);
pConn->fd = taosOpenUdpSocket(ip, ownPort); pConn->fd = taosOpenUdpSocket(ip, ownPort);
if (pConn->fd < 0) { if (pConn->fd < 0) {
tError("%s failed to open UDP socket %s:%d", label, ip, port); tError("%s failed to open UDP socket %s:%hu", label, ip, port);
taosCleanUpUdpConnection(pSet); taosCleanUpUdpConnection(pSet);
return NULL; return NULL;
} }
...@@ -529,12 +529,12 @@ void *taosInitUdpConnection(char *ip, short port, char *label, int threads, void ...@@ -529,12 +529,12 @@ void *taosInitUdpConnection(char *ip, short port, char *label, int threads, void
} }
pthread_attr_destroy(&thAttr); pthread_attr_destroy(&thAttr);
tTrace("%s UDP connection is initialized, ip:%s port:%u threads:%d", label, ip, port, threads); tTrace("%s UDP connection is initialized, ip:%s port:%hu threads:%d", label, ip, port, threads);
return pSet; return pSet;
} }
void *taosInitUdpServer(char *ip, short port, char *label, int threads, void *fp, void *shandle) { void *taosInitUdpServer(char *ip, uint16_t port, char *label, int threads, void *fp, void *shandle) {
SUdpConnSet *pSet; SUdpConnSet *pSet;
pSet = taosInitUdpConnection(ip, port, label, threads, fp, shandle); pSet = taosInitUdpConnection(ip, port, label, threads, fp, shandle);
if (pSet == NULL) return NULL; if (pSet == NULL) return NULL;
...@@ -555,7 +555,7 @@ void *taosInitUdpServer(char *ip, short port, char *label, int threads, void *fp ...@@ -555,7 +555,7 @@ void *taosInitUdpServer(char *ip, short port, char *label, int threads, void *fp
return pSet; return pSet;
} }
void *taosInitUdpClient(char *ip, short port, char *label, int threads, void *fp, void *shandle) { void *taosInitUdpClient(char *ip, uint16_t port, char *label, int threads, void *fp, void *shandle) {
return taosInitUdpConnection(ip, port, label, threads, fp, shandle); return taosInitUdpConnection(ip, port, label, threads, fp, shandle);
} }
...@@ -591,7 +591,7 @@ void taosCleanUpUdpConnection(void *handle) { ...@@ -591,7 +591,7 @@ void taosCleanUpUdpConnection(void *handle) {
tfree(pSet); tfree(pSet);
} }
void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, short port) { void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, uint16_t port) {
SUdpConnSet *pSet = (SUdpConnSet *)shandle; SUdpConnSet *pSet = (SUdpConnSet *)shandle;
pSet->index = (pSet->index + 1) % pSet->threads; pSet->index = (pSet->index + 1) % pSet->threads;
...@@ -599,7 +599,7 @@ void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, short port) ...@@ -599,7 +599,7 @@ void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, short port)
SUdpConn *pConn = pSet->udpConn + pSet->index; SUdpConn *pConn = pSet->udpConn + pSet->index;
pConn->port = port; pConn->port = port;
tTrace("%s UDP connection is setup, ip: %s:%d, local: %s:%d", pConn->label, ip, port, pSet->ip, tTrace("%s UDP connection is setup, ip: %s:%hu, local: %s:%d", pConn->label, ip, port, pSet->ip,
ntohs((uint16_t)pConn->localPort)); ntohs((uint16_t)pConn->localPort));
return pConn; return pConn;
...@@ -643,7 +643,7 @@ void taosProcessUdpBufTimer(void *param, void *tmrId) { ...@@ -643,7 +643,7 @@ void taosProcessUdpBufTimer(void *param, void *tmrId) {
if (pBuf) taosTmrReset(taosProcessUdpBufTimer, RPC_UDP_BUF_TIME, pBuf, pConn->tmrCtrl, &pBuf->timer); if (pBuf) taosTmrReset(taosProcessUdpBufTimer, RPC_UDP_BUF_TIME, pBuf, pConn->tmrCtrl, &pBuf->timer);
} }
SUdpBuf *taosCreateUdpBuf(SUdpConn *pConn, uint32_t ip, short port) { SUdpBuf *taosCreateUdpBuf(SUdpConn *pConn, uint32_t ip, uint16_t port) {
SUdpBuf *pBuf = (SUdpBuf *)malloc(sizeof(SUdpBuf)); SUdpBuf *pBuf = (SUdpBuf *)malloc(sizeof(SUdpBuf));
memset(pBuf, 0, sizeof(SUdpBuf)); memset(pBuf, 0, sizeof(SUdpBuf));
...@@ -653,7 +653,7 @@ SUdpBuf *taosCreateUdpBuf(SUdpConn *pConn, uint32_t ip, short port) { ...@@ -653,7 +653,7 @@ SUdpBuf *taosCreateUdpBuf(SUdpConn *pConn, uint32_t ip, short port) {
pBuf->destAdd.sin_family = AF_INET; pBuf->destAdd.sin_family = AF_INET;
pBuf->destAdd.sin_addr.s_addr = ip; pBuf->destAdd.sin_addr.s_addr = ip;
pBuf->destAdd.sin_port = (uint16_t)htons((uint16_t)port); pBuf->destAdd.sin_port = (uint16_t)htons(port);
taosInitMsgHdr(&(pBuf->msgHdr), &(pBuf->destAdd), RPC_MAX_UDP_PKTS); taosInitMsgHdr(&(pBuf->msgHdr), &(pBuf->destAdd), RPC_MAX_UDP_PKTS);
pBuf->signature = pBuf; pBuf->signature = pBuf;
taosTmrReset(taosProcessUdpBufTimer, RPC_UDP_BUF_TIME, pBuf, pConn->tmrCtrl, &pBuf->timer); taosTmrReset(taosProcessUdpBufTimer, RPC_UDP_BUF_TIME, pBuf, pConn->tmrCtrl, &pBuf->timer);
...@@ -664,7 +664,7 @@ SUdpBuf *taosCreateUdpBuf(SUdpConn *pConn, uint32_t ip, short port) { ...@@ -664,7 +664,7 @@ SUdpBuf *taosCreateUdpBuf(SUdpConn *pConn, uint32_t ip, short port) {
return pBuf; return pBuf;
} }
int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void *chandle) { int taosSendPacketViaTcp(uint32_t ip, uint16_t port, char *data, int dataLen, void *chandle) {
SUdpConn * pConn = (SUdpConn *)chandle; SUdpConn * pConn = (SUdpConn *)chandle;
SUdpConnSet *pSet = (SUdpConnSet *)pConn->pSet; SUdpConnSet *pSet = (SUdpConnSet *)pConn->pSet;
int code = -1, retLen, msgLen; int code = -1, retLen, msgLen;
...@@ -681,13 +681,13 @@ int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void ...@@ -681,13 +681,13 @@ int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void
SPacketInfo *pInfo = (SPacketInfo *)pHead->content; SPacketInfo *pInfo = (SPacketInfo *)pHead->content;
pInfo->handle = (uint64_t)data; pInfo->handle = (uint64_t)data;
pInfo->port = (uint16_t)pSet->port; pInfo->port = pSet->port;
pInfo->msgLen = pHead->msgLen; pInfo->msgLen = pHead->msgLen;
msgLen = sizeof(STaosHeader) + sizeof(SPacketInfo); msgLen = sizeof(STaosHeader) + sizeof(SPacketInfo);
pHead->msgLen = (int32_t)htonl((uint32_t)msgLen); pHead->msgLen = (int32_t)htonl((uint32_t)msgLen);
code = taosSendUdpData(ip, port, buffer, msgLen, chandle); code = taosSendUdpData(ip, port, buffer, msgLen, chandle);
tTrace("%s data from server will be sent via TCP:%d, msgType:%d, length:%d, handle:0x%x", pSet->label, pInfo->port, tTrace("%s data from server will be sent via TCP:%hu, msgType:%d, length:%d, handle:0x%x", pSet->label, pInfo->port,
pHead->msgType, htonl((uint32_t)pInfo->msgLen), pInfo->handle); pHead->msgType, htonl((uint32_t)pInfo->msgLen), pInfo->handle);
if (code > 0) code = dataLen; if (code > 0) code = dataLen;
} else { } else {
...@@ -707,7 +707,7 @@ int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void ...@@ -707,7 +707,7 @@ int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void
tinet_ntoa(ipstr, ip); tinet_ntoa(ipstr, ip);
int fd = taosOpenTcpClientSocket(ipstr, pConn->port, tsLocalIp); int fd = taosOpenTcpClientSocket(ipstr, pConn->port, tsLocalIp);
if (fd < 0) { if (fd < 0) {
tError("%s failed to open TCP socket to:%s:%u to send packet", pSet->label, ipstr, pConn->port); tError("%s failed to open TCP socket to:%s:%hu to send packet", pSet->label, ipstr, pConn->port);
} else { } else {
SHandleViaTcp handleViaTcp; SHandleViaTcp handleViaTcp;
taosInitHandleViaTcp(&handleViaTcp, 0); taosInitHandleViaTcp(&handleViaTcp, 0);
...@@ -735,7 +735,7 @@ int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void ...@@ -735,7 +735,7 @@ int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void
return code; return code;
} }
int taosSendUdpData(uint32_t ip, short port, char *data, int dataLen, void *chandle) { int taosSendUdpData(uint32_t ip, uint16_t port, char *data, int dataLen, void *chandle) {
SUdpConn *pConn = (SUdpConn *)chandle; SUdpConn *pConn = (SUdpConn *)chandle;
SUdpBuf * pBuf; SUdpBuf * pBuf;
...@@ -748,7 +748,7 @@ int taosSendUdpData(uint32_t ip, short port, char *data, int dataLen, void *chan ...@@ -748,7 +748,7 @@ int taosSendUdpData(uint32_t ip, short port, char *data, int dataLen, void *chan
memset(&destAdd, 0, sizeof(destAdd)); memset(&destAdd, 0, sizeof(destAdd));
destAdd.sin_family = AF_INET; destAdd.sin_family = AF_INET;
destAdd.sin_addr.s_addr = ip; destAdd.sin_addr.s_addr = ip;
destAdd.sin_port = htons((uint16_t)port); destAdd.sin_port = htons(port);
int ret = (int)sendto(pConn->fd, data, (size_t)dataLen, 0, (struct sockaddr *)&destAdd, sizeof(destAdd)); int ret = (int)sendto(pConn->fd, data, (size_t)dataLen, 0, (struct sockaddr *)&destAdd, sizeof(destAdd));
tTrace("%s msg is sent to 0x%x:%hu len:%d ret:%d localPort:%hu chandle:0x%x", pConn->label, destAdd.sin_addr.s_addr, tTrace("%s msg is sent to 0x%x:%hu len:%d ret:%d localPort:%hu chandle:0x%x", pConn->label, destAdd.sin_addr.s_addr,
......
...@@ -146,7 +146,7 @@ typedef struct _vg_obj { ...@@ -146,7 +146,7 @@ typedef struct _vg_obj {
} SVgObj; } SVgObj;
typedef struct _db_obj { typedef struct _db_obj {
char name[TSDB_DB_NAME_LEN + 1]; char name[TSDB_METER_ID_LEN + 1];
int64_t createdTime; int64_t createdTime;
SDbCfg cfg; SDbCfg cfg;
int32_t numOfVgroups; int32_t numOfVgroups;
...@@ -222,7 +222,7 @@ typedef struct _connObj { ...@@ -222,7 +222,7 @@ typedef struct _connObj {
uint32_t queryId; // query ID to be killed uint32_t queryId; // query ID to be killed
uint32_t streamId; // stream ID to be killed uint32_t streamId; // stream ID to be killed
uint32_t ip; // shell IP uint32_t ip; // shell IP
short port; // shell port uint16_t port; // shell port
void * thandle; void * thandle;
SQList * pQList; // query list SQList * pQList; // query list
SSList * pSList; // stream list SSList * pSList; // stream list
......
...@@ -26,7 +26,7 @@ typedef struct { ...@@ -26,7 +26,7 @@ typedef struct {
int sid; int sid;
int vnode; int vnode;
uint32_t ip; uint32_t ip;
short port; uint16_t port;
int count; // track the number of imports int count; // track the number of imports
int code; // track the code of imports int code; // track the code of imports
int numOfTotalPoints; // track the total number of points imported int numOfTotalPoints; // track the total number of points imported
......
...@@ -81,6 +81,8 @@ int32_t vnodeSetMeterState(SMeterObj* pMeterObj, int32_t state); ...@@ -81,6 +81,8 @@ int32_t vnodeSetMeterState(SMeterObj* pMeterObj, int32_t state);
void vnodeClearMeterState(SMeterObj* pMeterObj, int32_t state); void vnodeClearMeterState(SMeterObj* pMeterObj, int32_t state);
bool vnodeIsMeterState(SMeterObj* pMeterObj, int32_t state); bool vnodeIsMeterState(SMeterObj* pMeterObj, int32_t state);
void vnodeSetMeterDeleting(SMeterObj* pMeterObj); void vnodeSetMeterDeleting(SMeterObj* pMeterObj);
int32_t vnodeSetMeterInsertImportStateEx(SMeterObj* pObj, int32_t st);
bool vnodeIsSafeToDeleteMeter(SVnodeObj* pVnode, int32_t sid); bool vnodeIsSafeToDeleteMeter(SVnodeObj* pVnode, int32_t sid);
void vnodeFreeColumnInfo(SColumnInfo* pColumnInfo); void vnodeFreeColumnInfo(SColumnInfo* pColumnInfo);
bool isGroupbyNormalCol(SSqlGroupbyExpr* pExpr); bool isGroupbyNormalCol(SSqlGroupbyExpr* pExpr);
......
...@@ -25,7 +25,7 @@ typedef struct { ...@@ -25,7 +25,7 @@ typedef struct {
char user[TSDB_METER_ID_LEN]; char user[TSDB_METER_ID_LEN];
uint64_t stime; uint64_t stime;
uint32_t ip; uint32_t ip;
short port; uint16_t port;
} SConnInfo; } SConnInfo;
typedef struct { typedef struct {
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
typedef struct { typedef struct {
uint32_t ip; uint32_t ip;
short port; uint16_t port;
char user[TSDB_METER_ID_LEN]; char user[TSDB_METER_ID_LEN];
} SCDesc; } SCDesc;
...@@ -180,7 +180,7 @@ int mgmtKillQuery(char *qidstr, SConnObj *pConn) { ...@@ -180,7 +180,7 @@ int mgmtKillQuery(char *qidstr, SConnObj *pConn) {
chr = strchr(temp, ':'); chr = strchr(temp, ':');
if (chr == NULL) goto _error; if (chr == NULL) goto _error;
*chr = 0; *chr = 0;
short port = htons(atoi(temp)); uint16_t port = htons(atoi(temp));
temp = chr + 1; temp = chr + 1;
uint32_t queryId = atoi(temp); uint32_t queryId = atoi(temp);
...@@ -448,7 +448,7 @@ int mgmtKillStream(char *qidstr, SConnObj *pConn) { ...@@ -448,7 +448,7 @@ int mgmtKillStream(char *qidstr, SConnObj *pConn) {
chr = strchr(temp, ':'); chr = strchr(temp, ':');
if (chr == NULL) goto _error; if (chr == NULL) goto _error;
*chr = 0; *chr = 0;
short port = htons(atoi(temp)); uint16_t port = htons(atoi(temp));
temp = chr + 1; temp = chr + 1;
uint32_t streamId = atoi(temp); uint32_t streamId = atoi(temp);
......
...@@ -1280,7 +1280,7 @@ void *mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle) { ...@@ -1280,7 +1280,7 @@ void *mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle) {
if (pConn->pUser) { if (pConn->pUser) {
pConn->pAcct = mgmtGetAcct(pConn->pUser->acct); pConn->pAcct = mgmtGetAcct(pConn->pUser->acct);
mgmtEstablishConn(pConn); mgmtEstablishConn(pConn);
mTrace("login from:%x:%d", pConn->ip, htons(pConn->port)); mTrace("login from:%x:%hu", pConn->ip, htons(pConn->port));
} }
} }
......
...@@ -286,12 +286,9 @@ void vnodeProcessImportTimer(void *param, void *tmrId) { ...@@ -286,12 +286,9 @@ void vnodeProcessImportTimer(void *param, void *tmrId) {
SShellObj *pShell = pImport->pShell; SShellObj *pShell = pImport->pShell;
pImport->retry++; pImport->retry++;
//slow query will block the import operation int32_t code = vnodeSetMeterInsertImportStateEx(pObj, TSDB_METER_STATE_IMPORTING);
int32_t state = vnodeSetMeterState(pObj, TSDB_METER_STATE_IMPORTING); if (code == TSDB_CODE_NOT_ACTIVE_TABLE) {
if (state >= TSDB_METER_STATE_DELETING) {
dError("vid:%d sid:%d id:%s, meter is deleted, failed to import, state:%d",
pObj->vnode, pObj->sid, pObj->meterId, state);
return; return;
} }
...@@ -303,14 +300,14 @@ void vnodeProcessImportTimer(void *param, void *tmrId) { ...@@ -303,14 +300,14 @@ void vnodeProcessImportTimer(void *param, void *tmrId) {
//if the num == 0, it will never be increased before state is set to TSDB_METER_STATE_READY //if the num == 0, it will never be increased before state is set to TSDB_METER_STATE_READY
int32_t commitInProcess = 0; int32_t commitInProcess = 0;
pthread_mutex_lock(&pPool->vmutex); pthread_mutex_lock(&pPool->vmutex);
if (((commitInProcess = pPool->commitInProcess) == 1) || num > 0 || state != TSDB_METER_STATE_READY) { if (((commitInProcess = pPool->commitInProcess) == 1) || num > 0 || code == TSDB_CODE_ACTION_IN_PROGRESS) {
pthread_mutex_unlock(&pPool->vmutex); pthread_mutex_unlock(&pPool->vmutex);
vnodeClearMeterState(pObj, TSDB_METER_STATE_IMPORTING); vnodeClearMeterState(pObj, TSDB_METER_STATE_IMPORTING);
if (pImport->retry < 1000) { if (pImport->retry < 1000) {
dTrace("vid:%d sid:%d id:%s, import failed, retry later. commit in process or queries on it, or not ready." dTrace("vid:%d sid:%d id:%s, import failed, retry later. commit in process or queries on it, or not ready."
"commitInProcess:%d, numOfQueries:%d, state:%d", pObj->vnode, pObj->sid, pObj->meterId, "commitInProcess:%d, numOfQueries:%d, state:%d", pObj->vnode, pObj->sid, pObj->meterId,
commitInProcess, num, state); commitInProcess, num, pObj->state);
taosTmrStart(vnodeProcessImportTimer, 10, pImport, vnodeTmrCtrl); taosTmrStart(vnodeProcessImportTimer, 10, pImport, vnodeTmrCtrl);
return; return;
...@@ -320,15 +317,14 @@ void vnodeProcessImportTimer(void *param, void *tmrId) { ...@@ -320,15 +317,14 @@ void vnodeProcessImportTimer(void *param, void *tmrId) {
} else { } else {
pPool->commitInProcess = 1; pPool->commitInProcess = 1;
pthread_mutex_unlock(&pPool->vmutex); pthread_mutex_unlock(&pPool->vmutex);
int code = vnodeImportData(pObj, pImport); int32_t ret = vnodeImportData(pObj, pImport);
if (pShell) { if (pShell) {
pShell->code = code; pShell->code = ret;
pShell->numOfTotalPoints += pImport->importedRows; pShell->numOfTotalPoints += pImport->importedRows;
} }
} }
vnodeClearMeterState(pObj, TSDB_METER_STATE_IMPORTING); vnodeClearMeterState(pObj, TSDB_METER_STATE_IMPORTING);
pVnode->version++; pVnode->version++;
// send response back to shell // send response back to shell
...@@ -702,8 +698,8 @@ int vnodeFindKeyInFile(SImportInfo *pImport, int order) { ...@@ -702,8 +698,8 @@ int vnodeFindKeyInFile(SImportInfo *pImport, int order) {
if (pImport->key != key && pImport->pos > 0) { if (pImport->key != key && pImport->pos > 0) {
if ( pObj->sversion != pBlock->sversion ) { if ( pObj->sversion != pBlock->sversion ) {
dError("vid:%d sid:%d id:%s, import sversion not matached, expected:%d received:%d", pObj->vnode, pObj->sid, dError("vid:%d sid:%d id:%s, import sversion not matched, expected:%d received:%d", pObj->vnode, pObj->sid,
pBlock->sversion, pObj->sversion); pObj->meterId, pBlock->sversion, pObj->sversion);
code = TSDB_CODE_OTHERS; code = TSDB_CODE_OTHERS;
} else { } else {
pImport->offset = pBlock->offset; pImport->offset = pBlock->offset;
...@@ -912,16 +908,12 @@ int vnodeImportPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi ...@@ -912,16 +908,12 @@ int vnodeImportPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
} }
if (*((TSKEY *)(pSubmit->payLoad + (rows - 1) * pObj->bytesPerPoint)) > pObj->lastKey) { if (*((TSKEY *)(pSubmit->payLoad + (rows - 1) * pObj->bytesPerPoint)) > pObj->lastKey) {
vnodeClearMeterState(pObj, TSDB_METER_STATE_IMPORTING);
vnodeSetMeterState(pObj, TSDB_METER_STATE_INSERT);
code = vnodeInsertPoints(pObj, cont, contLen, TSDB_DATA_SOURCE_LOG, NULL, pObj->sversion, &pointsImported, now); code = vnodeInsertPoints(pObj, cont, contLen, TSDB_DATA_SOURCE_LOG, NULL, pObj->sversion, &pointsImported, now);
if (pShell) { if (pShell) {
pShell->code = code; pShell->code = code;
pShell->numOfTotalPoints += pointsImported; pShell->numOfTotalPoints += pointsImported;
} }
vnodeClearMeterState(pObj, TSDB_METER_STATE_INSERT);
} else { } else {
SImportInfo *pNew, import; SImportInfo *pNew, import;
...@@ -933,7 +925,11 @@ int vnodeImportPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi ...@@ -933,7 +925,11 @@ int vnodeImportPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
import.pShell = pShell; import.pShell = pShell;
import.payload = payload; import.payload = payload;
import.rows = rows; import.rows = rows;
if ((code = vnodeSetMeterInsertImportStateEx(pObj, TSDB_METER_STATE_IMPORTING)) != TSDB_CODE_SUCCESS) {
return code;
}
int32_t num = 0; int32_t num = 0;
pthread_mutex_lock(&pVnode->vmutex); pthread_mutex_lock(&pVnode->vmutex);
num = pObj->numOfQueries; num = pObj->numOfQueries;
...@@ -944,7 +940,8 @@ int vnodeImportPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi ...@@ -944,7 +940,8 @@ int vnodeImportPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
pthread_mutex_lock(&pPool->vmutex); pthread_mutex_lock(&pPool->vmutex);
if (((commitInProcess = pPool->commitInProcess) == 1) || num > 0) { if (((commitInProcess = pPool->commitInProcess) == 1) || num > 0) {
pthread_mutex_unlock(&pPool->vmutex); pthread_mutex_unlock(&pPool->vmutex);
vnodeClearMeterState(pObj, TSDB_METER_STATE_IMPORTING);
pNew = (SImportInfo *)malloc(sizeof(SImportInfo)); pNew = (SImportInfo *)malloc(sizeof(SImportInfo));
memcpy(pNew, &import, sizeof(SImportInfo)); memcpy(pNew, &import, sizeof(SImportInfo));
pNew->signature = pNew; pNew->signature = pNew;
...@@ -956,19 +953,25 @@ int vnodeImportPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi ...@@ -956,19 +953,25 @@ int vnodeImportPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
dTrace("vid:%d sid:%d id:%s, import later, commit in process:%d, numOfQueries:%d", pObj->vnode, pObj->sid, dTrace("vid:%d sid:%d id:%s, import later, commit in process:%d, numOfQueries:%d", pObj->vnode, pObj->sid,
pObj->meterId, commitInProcess, pObj->numOfQueries); pObj->meterId, commitInProcess, pObj->numOfQueries);
/*
* vnodeProcessImportTimer will set the import status for this table, so need to
* set the import flag here
*/
taosTmrStart(vnodeProcessImportTimer, 10, pNew, vnodeTmrCtrl); taosTmrStart(vnodeProcessImportTimer, 10, pNew, vnodeTmrCtrl);
return 0; return 0;
} else { } else {
pPool->commitInProcess = 1; pPool->commitInProcess = 1;
pthread_mutex_unlock(&pPool->vmutex); pthread_mutex_unlock(&pPool->vmutex);
int code = vnodeImportData(pObj, &import);
int ret = vnodeImportData(pObj, &import);
if (pShell) { if (pShell) {
pShell->code = code; pShell->code = ret;
pShell->numOfTotalPoints += import.importedRows; pShell->numOfTotalPoints += import.importedRows;
} }
} }
} }
vnodeClearMeterState(pObj, TSDB_METER_STATE_IMPORTING);
pVnode->version++; pVnode->version++;
if (pShell) { if (pShell) {
......
...@@ -572,7 +572,7 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi ...@@ -572,7 +572,7 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
dTrace("vid:%d sid:%d id:%s, cache is full, freePoints:%d, notFreeSlots:%d", pObj->vnode, pObj->sid, pObj->meterId, dTrace("vid:%d sid:%d id:%s, cache is full, freePoints:%d, notFreeSlots:%d", pObj->vnode, pObj->sid, pObj->meterId,
pObj->freePoints, pPool->notFreeSlots); pObj->freePoints, pPool->notFreeSlots);
vnodeProcessCommitTimer(pVnode, NULL); vnodeProcessCommitTimer(pVnode, NULL);
return TSDB_CODE_ACTION_IN_PROGRESS; return code;
} }
// FIXME: Here should be after the comparison of sversions. // FIXME: Here should be after the comparison of sversions.
...@@ -596,7 +596,7 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi ...@@ -596,7 +596,7 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
} }
pData = pSubmit->payLoad; pData = pSubmit->payLoad;
code = 0; code = TSDB_CODE_SUCCESS;
TSKEY firstKey = *((TSKEY *)pData); TSKEY firstKey = *((TSKEY *)pData);
TSKEY lastKey = *((TSKEY *)(pData + pObj->bytesPerPoint * (numOfPoints - 1))); TSKEY lastKey = *((TSKEY *)(pData + pObj->bytesPerPoint * (numOfPoints - 1)));
...@@ -608,9 +608,12 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi ...@@ -608,9 +608,12 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
pObj->vnode, pObj->sid, pObj->meterId, pVnode->lastKeyOnFile, numOfPoints,firstKey, lastKey, minAllowedKey, maxAllowedKey); pObj->vnode, pObj->sid, pObj->meterId, pVnode->lastKeyOnFile, numOfPoints,firstKey, lastKey, minAllowedKey, maxAllowedKey);
return TSDB_CODE_TIMESTAMP_OUT_OF_RANGE; return TSDB_CODE_TIMESTAMP_OUT_OF_RANGE;
} }
for (i = 0; i < numOfPoints; ++i) { if ((code = vnodeSetMeterInsertImportStateEx(pObj, TSDB_METER_STATE_INSERT)) != TSDB_CODE_SUCCESS) {
// meter will be dropped, abort current insertion goto _over;
}
for (i = 0; i < numOfPoints; ++i) { // meter will be dropped, abort current insertion
if (pObj->state >= TSDB_METER_STATE_DELETING) { if (pObj->state >= TSDB_METER_STATE_DELETING) {
dWarn("vid:%d sid:%d id:%s, meter is dropped, abort insert, state:%d", pObj->vnode, pObj->sid, pObj->meterId, dWarn("vid:%d sid:%d id:%s, meter is dropped, abort insert, state:%d", pObj->vnode, pObj->sid, pObj->meterId,
pObj->state); pObj->state);
...@@ -652,6 +655,7 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi ...@@ -652,6 +655,7 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
pVnode->version++; pVnode->version++;
pthread_mutex_unlock(&(pVnode->vmutex)); pthread_mutex_unlock(&(pVnode->vmutex));
vnodeClearMeterState(pObj, TSDB_METER_STATE_INSERT);
_over: _over:
dTrace("vid:%d sid:%d id:%s, %d out of %d points are inserted, lastKey:%ld source:%d, vnode total storage: %ld", dTrace("vid:%d sid:%d id:%s, %d out of %d points are inserted, lastKey:%ld source:%d, vnode total storage: %ld",
......
...@@ -48,7 +48,7 @@ void *vnodeProcessMsgFromShell(char *msg, void *ahandle, void *thandle) { ...@@ -48,7 +48,7 @@ void *vnodeProcessMsgFromShell(char *msg, void *ahandle, void *thandle) {
SShellObj *pObj = (SShellObj *)ahandle; SShellObj *pObj = (SShellObj *)ahandle;
SIntMsg * pMsg = (SIntMsg *)msg; SIntMsg * pMsg = (SIntMsg *)msg;
uint32_t peerId, peerIp; uint32_t peerId, peerIp;
short peerPort; uint16_t peerPort;
char ipstr[20]; char ipstr[20];
if (msg == NULL) { if (msg == NULL) {
...@@ -566,40 +566,15 @@ int vnodeProcessShellSubmitRequest(char *pMsg, int msgLen, SShellObj *pObj) { ...@@ -566,40 +566,15 @@ int vnodeProcessShellSubmitRequest(char *pMsg, int msgLen, SShellObj *pObj) {
int subMsgLen = sizeof(pBlocks->numOfRows) + htons(pBlocks->numOfRows) * pMeterObj->bytesPerPoint; int subMsgLen = sizeof(pBlocks->numOfRows) + htons(pBlocks->numOfRows) * pMeterObj->bytesPerPoint;
int sversion = htonl(pBlocks->sversion); int sversion = htonl(pBlocks->sversion);
int32_t state = TSDB_METER_STATE_READY;
if (pSubmit->import) { if (pSubmit->import) {
state = vnodeSetMeterState(pMeterObj, TSDB_METER_STATE_IMPORTING); code = vnodeImportPoints(pMeterObj, (char *) &(pBlocks->numOfRows), subMsgLen, TSDB_DATA_SOURCE_SHELL, pObj,
sversion, &numOfPoints, now);
} else { } else {
state = vnodeSetMeterState(pMeterObj, TSDB_METER_STATE_INSERT); code = vnodeInsertPoints(pMeterObj, (char *) &(pBlocks->numOfRows), subMsgLen, TSDB_DATA_SOURCE_SHELL, NULL,
sversion, &numOfPoints, now);
} }
if (state == TSDB_METER_STATE_READY) { if (code != TSDB_CODE_SUCCESS) {break;}
// meter status is ready for insert/import
if (pSubmit->import) {
code = vnodeImportPoints(pMeterObj, (char *) &(pBlocks->numOfRows), subMsgLen, TSDB_DATA_SOURCE_SHELL, pObj,
sversion, &numOfPoints, now);
vnodeClearMeterState(pMeterObj, TSDB_METER_STATE_IMPORTING);
} else {
code = vnodeInsertPoints(pMeterObj, (char *) &(pBlocks->numOfRows), subMsgLen, TSDB_DATA_SOURCE_SHELL, NULL,
sversion, &numOfPoints, now);
vnodeClearMeterState(pMeterObj, TSDB_METER_STATE_INSERT);
}
if (code != TSDB_CODE_SUCCESS) {break;}
} else {
if (vnodeIsMeterState(pMeterObj, TSDB_METER_STATE_DELETING)) {
dTrace("vid:%d sid:%d id:%s, it is removed, state:%d", pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId,
pMeterObj->state);
code = TSDB_CODE_NOT_ACTIVE_TABLE;
break;
} else {// waiting for 300ms by default and try again
dTrace("vid:%d sid:%d id:%s, try submit again since in state:%d", pMeterObj->vnode, pMeterObj->sid,
pMeterObj->meterId, pMeterObj->state);
code = TSDB_CODE_ACTION_IN_PROGRESS;
break;
}
}
numOfTotalPoints += numOfPoints; numOfTotalPoints += numOfPoints;
pBlocks = (SShellSubmitBlock *)((char *)pBlocks + sizeof(SShellSubmitBlock) + pBlocks = (SShellSubmitBlock *)((char *)pBlocks + sizeof(SShellSubmitBlock) +
......
...@@ -56,14 +56,11 @@ void vnodeProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) { ...@@ -56,14 +56,11 @@ void vnodeProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) {
contLen += sizeof(SSubmitMsg); contLen += sizeof(SSubmitMsg);
int32_t numOfPoints = 0; int32_t numOfPoints = 0;
int32_t code = vnodeInsertPoints(pObj, (char *)pMsg, contLen, TSDB_DATA_SOURCE_SHELL, NULL, pObj->sversion,
&numOfPoints, taosGetTimestamp(vnodeList[pObj->vnode].cfg.precision));
int32_t state = vnodeSetMeterState(pObj, TSDB_METER_STATE_INSERT); if (code != TSDB_CODE_SUCCESS) {
if (state == TSDB_METER_STATE_READY) { dError("vid:%d sid:%d id:%s, failed to insert continuous query results", pObj->vnode, pObj->sid, pObj->meterId);
vnodeInsertPoints(pObj, (char *)pMsg, contLen, TSDB_DATA_SOURCE_SHELL, NULL, pObj->sversion, &numOfPoints, taosGetTimestamp(vnodeList[pObj->vnode].cfg.precision));
vnodeClearMeterState(pObj, TSDB_METER_STATE_INSERT);
} else {
dError("vid:%d sid:%d id:%s, failed to insert continuous query results, state:%d", pObj->vnode, pObj->sid,
pObj->meterId, state);
} }
assert(numOfPoints >= 0 && numOfPoints <= 1); assert(numOfPoints >= 0 && numOfPoints <= 1);
......
...@@ -668,6 +668,26 @@ void vnodeSetMeterDeleting(SMeterObj* pMeterObj) { ...@@ -668,6 +668,26 @@ void vnodeSetMeterDeleting(SMeterObj* pMeterObj) {
pMeterObj->state |= TSDB_METER_STATE_DELETING; pMeterObj->state |= TSDB_METER_STATE_DELETING;
} }
int32_t vnodeSetMeterInsertImportStateEx(SMeterObj* pObj, int32_t st) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t state = vnodeSetMeterState(pObj, st);
if (state != TSDB_METER_STATE_READY) {//return to denote import is not performed
if (vnodeIsMeterState(pObj, TSDB_METER_STATE_DELETING)) {
dTrace("vid:%d sid:%d id:%s, meter is deleted, state:%d", pObj->vnode, pObj->sid, pObj->meterId,
pObj->state);
code = TSDB_CODE_NOT_ACTIVE_TABLE;
} else {// waiting for 300ms by default and try again
dTrace("vid:%d sid:%d id:%s, try submit again since in state:%d", pObj->vnode, pObj->sid,
pObj->meterId, pObj->state);
code = TSDB_CODE_ACTION_IN_PROGRESS;
}
}
return code;
}
bool vnodeIsSafeToDeleteMeter(SVnodeObj* pVnode, int32_t sid) { bool vnodeIsSafeToDeleteMeter(SVnodeObj* pVnode, int32_t sid) {
SMeterObj* pObj = pVnode->meterList[sid]; SMeterObj* pObj = pVnode->meterList[sid];
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
#include "tsql.h" #include "tsql.h"
#include "tutil.h" #include "tutil.h"
/**************** End of %include directives **********************************/ /**************** End of %include directives **********************************/
...@@ -79,13 +78,15 @@ ...@@ -79,13 +78,15 @@
** defined, then do no error processing. ** defined, then do no error processing.
** YYNSTATE the combined number of states. ** YYNSTATE the combined number of states.
** YYNRULE the number of rules in the grammar ** YYNRULE the number of rules in the grammar
** YYNTOKEN Number of terminal symbols
** YY_MAX_SHIFT Maximum value for shift actions ** YY_MAX_SHIFT Maximum value for shift actions
** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions ** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions ** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
** YY_MIN_REDUCE Maximum value for reduce actions
** YY_ERROR_ACTION The yy_action[] code for syntax error ** YY_ERROR_ACTION The yy_action[] code for syntax error
** YY_ACCEPT_ACTION The yy_action[] code for accept ** YY_ACCEPT_ACTION The yy_action[] code for accept
** YY_NO_ACTION The yy_action[] code for no-op ** YY_NO_ACTION The yy_action[] code for no-op
** YY_MIN_REDUCE Minimum value for reduce actions
** YY_MAX_REDUCE Maximum value for reduce actions
*/ */
#ifndef INTERFACE #ifndef INTERFACE
# define INTERFACE 1 # define INTERFACE 1
...@@ -122,21 +123,18 @@ typedef union { ...@@ -122,21 +123,18 @@ typedef union {
#define ParseARG_STORE yypParser->pInfo = pInfo #define ParseARG_STORE yypParser->pInfo = pInfo
#define YYFALLBACK 1 #define YYFALLBACK 1
#define YYNSTATE 251 #define YYNSTATE 251
#define YYNRULE 213 #define YYNRULE 214
#define YYNTOKEN 195
#define YY_MAX_SHIFT 250 #define YY_MAX_SHIFT 250
#define YY_MIN_SHIFTREDUCE 401 #define YY_MIN_SHIFTREDUCE 401
#define YY_MAX_SHIFTREDUCE 613 #define YY_MAX_SHIFTREDUCE 614
#define YY_MIN_REDUCE 614 #define YY_ERROR_ACTION 615
#define YY_MAX_REDUCE 826 #define YY_ACCEPT_ACTION 616
#define YY_ERROR_ACTION 827 #define YY_NO_ACTION 617
#define YY_ACCEPT_ACTION 828 #define YY_MIN_REDUCE 618
#define YY_NO_ACTION 829 #define YY_MAX_REDUCE 831
/************* End control #defines *******************************************/ /************* End control #defines *******************************************/
/* The yyzerominor constant is used to initialize instances of
** YYMINORTYPE objects to zero. */
static const YYMINORTYPE yyzerominor = { 0 };
/* Define the yytestcase() macro to be a no-op if is not already defined /* Define the yytestcase() macro to be a no-op if is not already defined
** otherwise. ** otherwise.
** **
...@@ -164,9 +162,6 @@ static const YYMINORTYPE yyzerominor = { 0 }; ...@@ -164,9 +162,6 @@ static const YYMINORTYPE yyzerominor = { 0 };
** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then ** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then
** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE. ** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE.
** **
** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE
** and YY_MAX_REDUCE
** N == YY_ERROR_ACTION A syntax error has occurred. ** N == YY_ERROR_ACTION A syntax error has occurred.
** **
** N == YY_ACCEPT_ACTION The parser accepts its input. ** N == YY_ACCEPT_ACTION The parser accepts its input.
...@@ -174,21 +169,22 @@ static const YYMINORTYPE yyzerominor = { 0 }; ...@@ -174,21 +169,22 @@ static const YYMINORTYPE yyzerominor = { 0 };
** N == YY_NO_ACTION No such action. Denotes unused ** N == YY_NO_ACTION No such action. Denotes unused
** slots in the yy_action[] table. ** slots in the yy_action[] table.
** **
** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE
** and YY_MAX_REDUCE
**
** The action table is constructed as a single large table named yy_action[]. ** The action table is constructed as a single large table named yy_action[].
** Given state S and lookahead X, the action is computed as ** Given state S and lookahead X, the action is computed as either:
** **
** yy_action[ yy_shift_ofst[S] + X ] ** (A) N = yy_action[ yy_shift_ofst[S] + X ]
** (B) N = yy_default[S]
** **
** If the index value yy_shift_ofst[S]+X is out of range or if the value ** The (A) formula is preferred. The B formula is used instead if
** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X.
** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
** and that yy_default[S] should be used instead.
** **
** The formula above is for computing the action when the lookahead is ** The formulas above are for computing the action when the lookahead is
** a terminal symbol. If the lookahead is a non-terminal (as occurs after ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
** a reduce action) then the yy_reduce_ofst[] array is used in place of ** a reduce action) then the yy_reduce_ofst[] array is used in place of
** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of ** the yy_shift_ofst[] array.
** YY_SHIFT_USE_DFLT.
** **
** The following are the tables generated in this section: ** The following are the tables generated in this section:
** **
...@@ -202,196 +198,214 @@ static const YYMINORTYPE yyzerominor = { 0 }; ...@@ -202,196 +198,214 @@ static const YYMINORTYPE yyzerominor = { 0 };
** yy_default[] Default action for each state. ** yy_default[] Default action for each state.
** **
*********** Begin parsing tables **********************************************/ *********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (529) #define YY_ACTTAB_COUNT (530)
static const YYACTIONTYPE yy_action[] = { static const YYACTIONTYPE yy_action[] = {
/* 0 */ 439, 36, 35, 153, 249, 34, 33, 32, 440, 34, /* 0 */ 97, 439, 135, 101, 101, 156, 616, 250, 135, 440,
/* 10 */ 33, 32, 43, 45, 49, 37, 38, 74, 78, 244, /* 10 */ 135, 159, 814, 43, 45, 21, 37, 38, 813, 158,
/* 20 */ 31, 85, 77, 205, 41, 39, 42, 40, 80, 133, /* 20 */ 814, 31, 439, 727, 205, 41, 39, 42, 40, 10,
/* 30 */ 101, 50, 36, 35, 527, 171, 34, 33, 32, 43, /* 30 */ 440, 153, 249, 36, 35, 745, 726, 34, 33, 32,
/* 40 */ 45, 154, 37, 38, 114, 115, 224, 31, 65, 68, /* 40 */ 43, 45, 737, 37, 38, 166, 132, 167, 31, 724,
/* 50 */ 205, 41, 39, 42, 40, 76, 133, 828, 250, 36, /* 50 */ 193, 205, 41, 39, 42, 40, 202, 769, 59, 200,
/* 60 */ 35, 241, 241, 34, 33, 32, 43, 45, 155, 37, /* 60 */ 36, 35, 21, 727, 34, 33, 32, 43, 45, 134,
/* 70 */ 38, 128, 126, 245, 31, 89, 88, 205, 41, 39, /* 70 */ 37, 38, 74, 78, 244, 31, 85, 77, 205, 41,
/* 80 */ 42, 40, 202, 524, 59, 135, 36, 35, 439, 21, /* 80 */ 39, 42, 40, 80, 742, 220, 498, 36, 35, 439,
/* 90 */ 34, 33, 32, 520, 159, 596, 440, 10, 57, 172, /* 90 */ 21, 34, 33, 32, 168, 101, 724, 440, 101, 57,
/* 100 */ 135, 135, 227, 226, 101, 45, 439, 37, 38, 158, /* 100 */ 114, 115, 224, 727, 65, 68, 45, 7, 37, 38,
/* 110 */ 596, 595, 31, 156, 440, 205, 41, 39, 42, 40, /* 110 */ 62, 111, 241, 31, 230, 229, 205, 41, 39, 42,
/* 120 */ 232, 167, 564, 507, 36, 35, 166, 21, 34, 33, /* 120 */ 40, 232, 228, 565, 724, 36, 35, 21, 139, 34,
/* 130 */ 32, 510, 402, 403, 404, 405, 406, 407, 408, 409, /* 130 */ 33, 32, 21, 402, 403, 404, 405, 406, 407, 408,
/* 140 */ 410, 411, 412, 413, 510, 37, 38, 243, 132, 508, /* 140 */ 409, 410, 411, 412, 413, 810, 37, 38, 243, 768,
/* 150 */ 31, 220, 101, 205, 41, 39, 42, 40, 551, 168, /* 150 */ 725, 31, 60, 178, 205, 41, 39, 42, 40, 233,
/* 160 */ 200, 507, 36, 35, 97, 134, 34, 33, 32, 510, /* 160 */ 186, 724, 183, 36, 35, 809, 723, 34, 33, 32,
/* 170 */ 21, 139, 101, 17, 219, 242, 218, 217, 216, 215, /* 170 */ 654, 171, 808, 124, 17, 219, 242, 218, 217, 216,
/* 180 */ 214, 213, 212, 211, 492, 21, 481, 482, 483, 484, /* 180 */ 215, 214, 213, 212, 211, 709, 151, 698, 699, 700,
/* 190 */ 485, 486, 487, 488, 489, 490, 491, 163, 577, 11, /* 190 */ 701, 702, 703, 704, 705, 706, 707, 708, 163, 578,
/* 200 */ 243, 568, 228, 571, 507, 574, 550, 163, 577, 498, /* 200 */ 11, 133, 569, 133, 572, 76, 575, 663, 163, 578,
/* 210 */ 21, 568, 509, 571, 193, 574, 148, 233, 7, 507, /* 210 */ 124, 241, 569, 154, 572, 155, 575, 148, 34, 33,
/* 220 */ 561, 62, 111, 87, 86, 142, 60, 178, 242, 160, /* 220 */ 32, 248, 247, 422, 87, 86, 142, 243, 546, 547,
/* 230 */ 161, 147, 437, 204, 186, 124, 183, 230, 229, 160, /* 230 */ 160, 161, 147, 523, 204, 172, 18, 152, 227, 226,
/* 240 */ 161, 163, 577, 525, 506, 568, 570, 571, 573, 574, /* 240 */ 160, 161, 163, 578, 526, 712, 569, 711, 572, 140,
/* 250 */ 41, 39, 42, 40, 495, 61, 494, 27, 36, 35, /* 250 */ 575, 41, 39, 42, 40, 242, 141, 61, 27, 36,
/* 260 */ 545, 546, 34, 33, 32, 514, 28, 600, 511, 162, /* 260 */ 35, 73, 72, 34, 33, 32, 514, 655, 28, 511,
/* 270 */ 512, 29, 513, 160, 161, 192, 446, 566, 188, 124, /* 270 */ 124, 512, 143, 513, 160, 161, 192, 36, 35, 188,
/* 280 */ 248, 247, 422, 438, 522, 150, 124, 18, 601, 536, /* 280 */ 601, 34, 33, 32, 29, 571, 150, 574, 567, 128,
/* 290 */ 537, 44, 29, 47, 15, 594, 169, 170, 578, 14, /* 290 */ 126, 245, 44, 89, 88, 602, 537, 169, 170, 29,
/* 300 */ 576, 44, 14, 569, 518, 572, 519, 2, 52, 516, /* 300 */ 47, 577, 44, 162, 538, 595, 579, 144, 15, 14,
/* 310 */ 576, 517, 504, 567, 503, 575, 47, 592, 22, 591, /* 310 */ 14, 577, 570, 49, 573, 504, 576, 52, 503, 47,
/* 320 */ 209, 73, 72, 53, 22, 575, 9, 8, 84, 83, /* 320 */ 145, 209, 22, 146, 568, 22, 576, 518, 828, 519,
/* 330 */ 590, 151, 152, 140, 501, 44, 610, 141, 560, 143, /* 330 */ 50, 516, 53, 517, 84, 83, 44, 9, 8, 718,
/* 340 */ 144, 145, 146, 137, 576, 131, 138, 136, 164, 557, /* 340 */ 137, 2, 131, 138, 136, 577, 779, 744, 778, 164,
/* 350 */ 556, 165, 526, 231, 110, 98, 112, 113, 448, 575, /* 350 */ 775, 774, 165, 231, 98, 761, 760, 112, 113, 665,
/* 360 */ 543, 542, 210, 129, 515, 25, 223, 225, 609, 70, /* 360 */ 576, 110, 189, 210, 129, 515, 25, 223, 91, 225,
/* 370 */ 189, 608, 606, 116, 466, 26, 23, 130, 435, 79, /* 370 */ 827, 70, 826, 824, 116, 683, 26, 23, 130, 652,
/* 380 */ 433, 81, 431, 191, 430, 173, 125, 428, 427, 426, /* 380 */ 533, 79, 650, 54, 81, 648, 647, 173, 125, 645,
/* 390 */ 424, 91, 532, 194, 198, 54, 417, 127, 51, 521, /* 390 */ 644, 643, 641, 634, 127, 638, 191, 636, 738, 194,
/* 400 */ 421, 203, 419, 46, 102, 95, 201, 530, 103, 531, /* 400 */ 198, 95, 748, 749, 762, 51, 102, 46, 203, 103,
/* 410 */ 544, 195, 199, 197, 30, 27, 222, 235, 75, 234, /* 410 */ 201, 199, 197, 195, 30, 27, 222, 75, 234, 235,
/* 420 */ 236, 207, 238, 55, 237, 239, 240, 246, 149, 613, /* 420 */ 207, 55, 236, 240, 238, 237, 239, 63, 66, 149,
/* 430 */ 63, 66, 174, 429, 175, 176, 90, 92, 177, 423, /* 430 */ 246, 614, 175, 174, 176, 646, 613, 90, 640, 119,
/* 440 */ 119, 612, 118, 467, 117, 120, 121, 179, 122, 123, /* 440 */ 123, 177, 684, 117, 118, 120, 106, 104, 722, 122,
/* 450 */ 1, 505, 108, 104, 105, 106, 107, 109, 24, 180, /* 450 */ 92, 121, 108, 105, 107, 109, 1, 24, 180, 179,
/* 460 */ 181, 182, 611, 184, 185, 604, 12, 13, 187, 190, /* 460 */ 181, 182, 612, 184, 185, 605, 58, 12, 13, 99,
/* 470 */ 96, 533, 99, 157, 58, 538, 196, 100, 19, 4, /* 470 */ 190, 187, 96, 534, 157, 539, 196, 100, 19, 64,
/* 480 */ 579, 3, 16, 20, 64, 5, 206, 6, 208, 479, /* 480 */ 479, 580, 3, 20, 4, 16, 206, 6, 208, 478,
/* 490 */ 478, 477, 476, 475, 474, 473, 472, 470, 47, 221, /* 490 */ 477, 476, 475, 5, 474, 473, 472, 470, 47, 443,
/* 500 */ 443, 67, 445, 22, 500, 48, 499, 497, 464, 56, /* 500 */ 67, 445, 22, 221, 500, 48, 499, 497, 56, 464,
/* 510 */ 462, 454, 69, 460, 456, 71, 458, 452, 450, 471, /* 510 */ 462, 454, 460, 69, 456, 71, 458, 452, 450, 471,
/* 520 */ 469, 82, 441, 425, 415, 93, 614, 616, 94, /* 520 */ 469, 82, 441, 425, 93, 415, 618, 617, 617, 94,
}; };
static const YYCODETYPE yy_lookahead[] = { static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 1, 33, 34, 198, 199, 37, 38, 39, 9, 37, /* 0 */ 199, 1, 247, 199, 199, 216, 196, 197, 247, 9,
/* 10 */ 38, 39, 13, 14, 100, 16, 17, 62, 63, 64, /* 10 */ 247, 256, 257, 13, 14, 199, 16, 17, 257, 256,
/* 20 */ 21, 66, 67, 24, 25, 26, 27, 28, 73, 247, /* 20 */ 257, 21, 1, 234, 24, 25, 26, 27, 28, 247,
/* 30 */ 199, 117, 33, 34, 199, 61, 37, 38, 39, 13, /* 30 */ 9, 198, 199, 33, 34, 199, 234, 37, 38, 39,
/* 40 */ 14, 259, 16, 17, 62, 63, 64, 21, 66, 67, /* 40 */ 13, 14, 232, 16, 17, 216, 247, 231, 21, 233,
/* 50 */ 24, 25, 26, 27, 28, 71, 247, 196, 197, 33, /* 50 */ 249, 24, 25, 26, 27, 28, 251, 253, 253, 255,
/* 60 */ 34, 77, 77, 37, 38, 39, 13, 14, 259, 16, /* 60 */ 33, 34, 199, 234, 37, 38, 39, 13, 14, 247,
/* 70 */ 17, 62, 63, 64, 21, 66, 67, 24, 25, 26, /* 70 */ 16, 17, 62, 63, 64, 21, 66, 67, 24, 25,
/* 80 */ 27, 28, 251, 248, 253, 247, 33, 34, 1, 199, /* 80 */ 26, 27, 28, 73, 248, 216, 5, 33, 34, 1,
/* 90 */ 37, 38, 39, 232, 256, 257, 9, 247, 99, 125, /* 90 */ 199, 37, 38, 39, 231, 199, 233, 9, 199, 99,
/* 100 */ 247, 247, 128, 129, 199, 14, 1, 16, 17, 256, /* 100 */ 62, 63, 64, 234, 66, 67, 14, 95, 16, 17,
/* 110 */ 257, 257, 21, 216, 9, 24, 25, 26, 27, 28, /* 110 */ 98, 99, 77, 21, 33, 34, 24, 25, 26, 27,
/* 120 */ 199, 231, 96, 233, 33, 34, 216, 199, 37, 38, /* 120 */ 28, 199, 231, 96, 233, 33, 34, 199, 247, 37,
/* 130 */ 39, 234, 45, 46, 47, 48, 49, 50, 51, 52, /* 130 */ 38, 39, 199, 45, 46, 47, 48, 49, 50, 51,
/* 140 */ 53, 54, 55, 56, 234, 16, 17, 58, 247, 228, /* 140 */ 52, 53, 54, 55, 56, 247, 16, 17, 58, 253,
/* 150 */ 21, 216, 199, 24, 25, 26, 27, 28, 253, 231, /* 150 */ 228, 21, 253, 124, 24, 25, 26, 27, 28, 231,
/* 160 */ 255, 233, 33, 34, 199, 247, 37, 38, 39, 234, /* 160 */ 131, 233, 133, 33, 34, 247, 233, 37, 38, 39,
/* 170 */ 199, 247, 199, 84, 85, 86, 87, 88, 89, 90, /* 170 */ 203, 61, 247, 206, 84, 85, 86, 87, 88, 89,
/* 180 */ 91, 92, 93, 94, 215, 199, 217, 218, 219, 220, /* 180 */ 90, 91, 92, 93, 94, 215, 247, 217, 218, 219,
/* 190 */ 221, 222, 223, 224, 225, 226, 227, 1, 2, 44, /* 190 */ 220, 221, 222, 223, 224, 225, 226, 227, 1, 2,
/* 200 */ 58, 5, 231, 7, 233, 9, 253, 1, 2, 5, /* 200 */ 44, 247, 5, 247, 7, 71, 9, 203, 1, 2,
/* 210 */ 199, 5, 234, 7, 249, 9, 61, 231, 95, 233, /* 210 */ 206, 77, 5, 259, 7, 259, 9, 61, 37, 38,
/* 220 */ 229, 98, 99, 68, 69, 70, 253, 124, 86, 33, /* 220 */ 39, 58, 59, 60, 68, 69, 70, 58, 110, 111,
/* 230 */ 34, 76, 203, 37, 131, 206, 133, 33, 34, 33, /* 230 */ 33, 34, 76, 100, 37, 125, 103, 247, 128, 129,
/* 240 */ 34, 1, 2, 37, 233, 5, 5, 7, 7, 9, /* 240 */ 33, 34, 1, 2, 37, 217, 5, 219, 7, 247,
/* 250 */ 25, 26, 27, 28, 217, 235, 219, 102, 33, 34, /* 250 */ 9, 25, 26, 27, 28, 86, 247, 235, 102, 33,
/* 260 */ 110, 111, 37, 38, 39, 2, 246, 96, 5, 57, /* 260 */ 34, 126, 127, 37, 38, 39, 2, 203, 246, 5,
/* 270 */ 7, 100, 9, 33, 34, 120, 203, 1, 123, 206, /* 270 */ 206, 7, 247, 9, 33, 34, 120, 33, 34, 123,
/* 280 */ 58, 59, 60, 203, 100, 130, 206, 103, 96, 96, /* 280 */ 96, 37, 38, 39, 100, 5, 130, 7, 1, 62,
/* 290 */ 96, 95, 100, 100, 100, 96, 33, 34, 96, 100, /* 290 */ 63, 64, 95, 66, 67, 96, 96, 33, 34, 100,
/* 300 */ 104, 95, 100, 5, 5, 7, 7, 95, 100, 5, /* 300 */ 100, 104, 95, 57, 96, 96, 96, 247, 100, 100,
/* 310 */ 104, 7, 96, 37, 96, 119, 100, 247, 100, 247, /* 310 */ 100, 104, 5, 100, 7, 96, 119, 100, 96, 100,
/* 320 */ 96, 126, 127, 115, 100, 119, 126, 127, 71, 72, /* 320 */ 247, 96, 100, 247, 37, 100, 119, 5, 234, 7,
/* 330 */ 247, 247, 247, 247, 230, 95, 234, 247, 229, 247, /* 330 */ 117, 5, 115, 7, 71, 72, 95, 126, 127, 230,
/* 340 */ 247, 247, 247, 247, 104, 247, 247, 247, 229, 229, /* 340 */ 247, 95, 247, 247, 247, 104, 229, 199, 229, 229,
/* 350 */ 229, 229, 199, 229, 236, 199, 199, 199, 199, 119, /* 350 */ 229, 229, 229, 229, 199, 254, 254, 199, 199, 199,
/* 360 */ 254, 254, 199, 199, 101, 199, 199, 199, 199, 199, /* 360 */ 119, 236, 122, 199, 199, 101, 199, 199, 57, 199,
/* 370 */ 122, 199, 199, 199, 199, 199, 199, 199, 199, 199, /* 370 */ 199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
/* 380 */ 199, 199, 199, 258, 199, 199, 199, 199, 199, 199, /* 380 */ 104, 199, 199, 114, 199, 199, 199, 199, 199, 199,
/* 390 */ 199, 57, 104, 250, 250, 114, 199, 199, 116, 245, /* 390 */ 199, 199, 199, 199, 199, 199, 258, 199, 245, 250,
/* 400 */ 199, 108, 199, 113, 244, 200, 112, 200, 243, 200, /* 400 */ 250, 200, 200, 200, 200, 116, 244, 113, 108, 243,
/* 410 */ 200, 105, 107, 106, 118, 102, 74, 49, 83, 82, /* 410 */ 112, 107, 106, 105, 118, 102, 74, 83, 82, 49,
/* 420 */ 79, 200, 53, 200, 81, 80, 78, 74, 200, 5, /* 420 */ 200, 200, 79, 78, 53, 81, 80, 204, 204, 200,
/* 430 */ 204, 204, 132, 200, 5, 132, 201, 201, 65, 200, /* 430 */ 74, 5, 5, 132, 132, 200, 5, 201, 200, 208,
/* 440 */ 208, 5, 212, 214, 213, 211, 209, 132, 210, 207, /* 440 */ 207, 65, 214, 213, 212, 211, 240, 242, 232, 210,
/* 450 */ 205, 232, 238, 242, 241, 240, 239, 237, 202, 5, /* 450 */ 201, 209, 238, 241, 239, 237, 205, 202, 5, 132,
/* 460 */ 132, 65, 5, 132, 65, 85, 95, 95, 124, 122, /* 460 */ 132, 65, 5, 132, 65, 85, 100, 95, 95, 95,
/* 470 */ 121, 96, 95, 1, 100, 96, 95, 95, 100, 109, /* 470 */ 122, 124, 121, 96, 1, 96, 95, 95, 100, 71,
/* 480 */ 96, 95, 95, 100, 71, 109, 97, 95, 97, 9, /* 480 */ 9, 96, 95, 100, 109, 95, 97, 95, 97, 5,
/* 490 */ 5, 5, 5, 5, 1, 5, 5, 5, 100, 15, /* 490 */ 5, 5, 5, 109, 1, 5, 5, 5, 100, 75,
/* 500 */ 75, 71, 65, 100, 5, 16, 5, 96, 5, 95, /* 500 */ 71, 65, 100, 15, 5, 16, 5, 96, 95, 5,
/* 510 */ 5, 5, 127, 5, 5, 127, 5, 5, 5, 5, /* 510 */ 5, 5, 5, 127, 5, 127, 5, 5, 5, 5,
/* 520 */ 5, 65, 75, 65, 57, 21, 0, 260, 21, /* 520 */ 5, 65, 75, 65, 21, 57, 0, 260, 260, 21,
/* 530 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 540 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 550 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 560 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 570 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 580 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 590 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 600 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 610 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 620 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 630 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 640 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 650 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 660 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 670 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 680 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 690 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 700 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 710 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
/* 720 */ 260, 260, 260, 260, 260,
}; };
#define YY_SHIFT_USE_DFLT (-87) #define YY_SHIFT_COUNT (250)
#define YY_SHIFT_COUNT (250) #define YY_SHIFT_MIN (0)
#define YY_SHIFT_MIN (-86) #define YY_SHIFT_MAX (526)
#define YY_SHIFT_MAX (526) static const unsigned short int yy_shift_ofst[] = {
static const short yy_shift_ofst[] = { /* 0 */ 156, 90, 197, 241, 21, 21, 21, 21, 21, 21,
/* 0 */ 155, 89, 196, 240, 105, 105, 105, 105, 105, 105, /* 10 */ 0, 88, 241, 241, 241, 264, 264, 264, 21, 21,
/* 10 */ -1, 87, 240, 240, 240, 263, 263, 263, 105, 105, /* 20 */ 21, 21, 21, 134, 169, 35, 35, 530, 207, 241,
/* 20 */ 105, 105, 105, -16, 142, -15, -15, -87, 206, 240, /* 30 */ 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
/* 30 */ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, /* 40 */ 241, 241, 241, 241, 241, 241, 241, 264, 264, 81,
/* 40 */ 240, 240, 240, 240, 240, 240, 240, 263, 263, 204, /* 50 */ 81, 81, 81, 81, 81, 12, 81, 21, 21, 118,
/* 50 */ 204, 204, 204, 204, 204, 123, 204, 105, 105, 150, /* 60 */ 118, 133, 21, 21, 21, 21, 21, 21, 21, 21,
/* 60 */ 150, 184, 105, 105, 105, 105, 105, 105, 105, 105, /* 70 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
/* 70 */ 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, /* 80 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
/* 80 */ 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, /* 90 */ 21, 21, 21, 21, 21, 240, 311, 311, 311, 276,
/* 90 */ 105, 105, 105, 105, 105, 248, 334, 334, 334, 288, /* 100 */ 276, 311, 269, 289, 294, 300, 298, 304, 306, 308,
/* 100 */ 288, 334, 281, 282, 290, 293, 294, 305, 307, 306, /* 110 */ 296, 313, 311, 311, 342, 342, 311, 334, 336, 370,
/* 110 */ 296, 313, 334, 334, 342, 342, 334, 335, 337, 368, /* 120 */ 343, 344, 371, 346, 345, 311, 356, 311, 356, 530,
/* 120 */ 341, 343, 369, 345, 348, 334, 353, 334, 353, -87, /* 130 */ 530, 27, 54, 54, 54, 54, 54, 92, 130, 226,
/* 130 */ -87, 26, 53, 53, 53, 53, 53, 91, 129, 225, /* 140 */ 226, 226, 10, 244, 244, 244, 244, 38, 227, 110,
/* 140 */ 225, 225, -45, -32, -32, -32, -32, -18, 9, -26, /* 150 */ 29, 181, 181, 163, 184, 199, 200, 208, 209, 210,
/* 150 */ 103, -28, -28, 222, 171, 192, 193, 194, 199, 202, /* 160 */ 280, 307, 287, 246, 213, 217, 219, 222, 225, 322,
/* 160 */ 241, 298, 276, 212, -86, 208, 216, 218, 224, 299, /* 170 */ 326, 135, 211, 263, 426, 301, 427, 302, 376, 431,
/* 170 */ 304, 195, 200, 257, 424, 300, 429, 303, 373, 436, /* 180 */ 327, 453, 328, 396, 457, 331, 399, 380, 347, 372,
/* 180 */ 315, 454, 328, 396, 457, 331, 399, 380, 344, 371, /* 190 */ 373, 348, 351, 366, 377, 374, 473, 381, 379, 382,
/* 190 */ 372, 347, 349, 374, 375, 377, 472, 381, 379, 382, /* 200 */ 378, 375, 383, 384, 385, 387, 390, 389, 392, 391,
/* 200 */ 378, 370, 383, 376, 384, 386, 387, 389, 392, 391, /* 210 */ 408, 471, 484, 485, 486, 487, 493, 490, 491, 492,
/* 210 */ 413, 480, 485, 486, 487, 488, 493, 490, 491, 492, /* 220 */ 398, 424, 488, 429, 436, 489, 386, 388, 402, 499,
/* 220 */ 398, 425, 484, 430, 437, 489, 385, 388, 403, 499, /* 230 */ 501, 411, 413, 402, 504, 505, 506, 507, 509, 511,
/* 230 */ 501, 411, 414, 403, 503, 505, 506, 508, 509, 511, /* 240 */ 512, 513, 514, 515, 456, 458, 447, 503, 508, 468,
/* 240 */ 512, 513, 514, 515, 456, 458, 447, 504, 507, 467,
/* 250 */ 526, /* 250 */ 526,
}; };
#define YY_REDUCE_USE_DFLT (-219)
#define YY_REDUCE_COUNT (130) #define YY_REDUCE_COUNT (130)
#define YY_REDUCE_MIN (-218) #define YY_REDUCE_MIN (-245)
#define YY_REDUCE_MAX (256) #define YY_REDUCE_MAX (255)
static const short yy_reduce_ofst[] = { static const short yy_reduce_ofst[] = {
/* 0 */ -139, -31, -162, -147, -95, -169, -110, -72, -29, -14, /* 0 */ -190, -30, -245, -237, -196, -195, -184, -137, -109, -72,
/* 10 */ -165, -195, -218, -191, -146, -103, -90, -65, -35, -47, /* 10 */ -164, -167, -46, -44, -239, -211, -171, -131, -199, -104,
/* 20 */ -27, -79, 11, 29, 37, 73, 80, 20, -150, -99, /* 20 */ -101, -78, -67, -33, 28, 4, 64, 22, -218, -201,
/* 30 */ -82, -76, 70, 72, 83, 84, 85, 86, 90, 92, /* 30 */ -178, -119, -102, -82, -75, -61, -10, 2, 9, 25,
/* 40 */ 93, 94, 95, 96, 98, 99, 100, -22, 102, -9, /* 40 */ 60, 73, 76, 93, 95, 96, 97, -198, 94, 117,
/* 50 */ 109, 119, 120, 121, 122, 104, 124, 153, 156, 106, /* 50 */ 119, 120, 121, 122, 123, 109, 124, 148, 155, 101,
/* 60 */ 107, 118, 157, 158, 159, 163, 164, 166, 167, 168, /* 60 */ 102, 125, 158, 159, 160, 164, 165, 167, 168, 170,
/* 70 */ 169, 170, 172, 173, 174, 175, 176, 177, 178, 179, /* 70 */ 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
/* 80 */ 180, 181, 182, 183, 185, 186, 187, 188, 189, 190, /* 80 */ 182, 183, 185, 186, 187, 188, 189, 190, 191, 192,
/* 90 */ 191, 197, 198, 201, 203, 125, 205, 207, 209, 143, /* 90 */ 193, 194, 195, 196, 198, 138, 201, 202, 203, 149,
/* 100 */ 144, 210, 154, 160, 165, 211, 213, 215, 217, 214, /* 100 */ 150, 204, 153, 162, 166, 205, 212, 206, 215, 214,
/* 110 */ 220, 219, 221, 223, 226, 227, 228, 229, 231, 230, /* 110 */ 218, 216, 220, 221, 223, 224, 229, 228, 230, 232,
/* 120 */ 232, 234, 237, 238, 242, 233, 235, 239, 236, 245, /* 120 */ 231, 234, 242, 239, 233, 235, 236, 238, 249, 251,
/* 130 */ 256, /* 130 */ 255,
}; };
static const YYACTIONTYPE yy_default[] = { static const YYACTIONTYPE yy_default[] = {
/* 0 */ 827, 660, 811, 811, 827, 827, 827, 827, 827, 827, /* 0 */ 615, 664, 816, 816, 615, 615, 615, 615, 615, 615,
/* 10 */ 741, 627, 827, 827, 811, 827, 827, 827, 827, 827, /* 10 */ 746, 631, 615, 615, 816, 615, 615, 615, 615, 615,
/* 20 */ 827, 827, 827, 662, 649, 662, 662, 736, 827, 827, /* 20 */ 615, 615, 615, 666, 653, 666, 666, 741, 615, 615,
/* 30 */ 827, 827, 827, 827, 827, 827, 827, 827, 827, 827, /* 30 */ 615, 615, 615, 615, 615, 615, 615, 615, 615, 615,
/* 40 */ 827, 827, 827, 827, 827, 827, 827, 827, 827, 827, /* 40 */ 615, 615, 615, 615, 615, 615, 615, 615, 615, 615,
/* 50 */ 827, 827, 827, 827, 827, 827, 827, 827, 827, 760, /* 50 */ 615, 615, 615, 615, 615, 615, 615, 615, 615, 765,
/* 60 */ 760, 827, 827, 827, 827, 827, 827, 827, 827, 827, /* 60 */ 765, 739, 615, 615, 615, 615, 615, 615, 615, 615,
/* 70 */ 827, 827, 827, 827, 827, 827, 827, 827, 827, 647, /* 70 */ 615, 615, 615, 615, 615, 615, 615, 615, 615, 651,
/* 80 */ 827, 645, 827, 827, 827, 827, 827, 827, 827, 827, /* 80 */ 615, 649, 615, 615, 615, 615, 615, 615, 615, 615,
/* 90 */ 827, 827, 827, 827, 827, 827, 629, 629, 629, 827, /* 90 */ 615, 615, 615, 615, 615, 615, 633, 633, 633, 615,
/* 100 */ 827, 629, 767, 771, 765, 753, 761, 752, 748, 747, /* 100 */ 615, 633, 772, 776, 770, 758, 766, 757, 753, 752,
/* 110 */ 775, 827, 629, 629, 657, 657, 629, 678, 676, 674, /* 110 */ 780, 615, 633, 633, 661, 661, 633, 682, 680, 678,
/* 120 */ 666, 672, 668, 670, 664, 629, 655, 629, 655, 693, /* 120 */ 670, 676, 672, 674, 668, 633, 659, 633, 659, 697,
/* 130 */ 706, 827, 815, 816, 776, 810, 766, 794, 793, 806, /* 130 */ 710, 615, 820, 821, 781, 815, 771, 799, 798, 811,
/* 140 */ 800, 799, 827, 798, 797, 796, 795, 827, 827, 827, /* 140 */ 805, 804, 615, 803, 802, 801, 800, 615, 615, 615,
/* 150 */ 827, 802, 801, 827, 827, 827, 827, 827, 827, 827, /* 150 */ 615, 807, 806, 615, 615, 615, 615, 615, 615, 615,
/* 160 */ 827, 827, 827, 778, 772, 768, 827, 827, 827, 827, /* 160 */ 615, 615, 615, 783, 777, 773, 615, 615, 615, 615,
/* 170 */ 827, 827, 827, 827, 827, 827, 827, 827, 827, 827, /* 170 */ 615, 615, 615, 615, 615, 615, 615, 615, 615, 615,
/* 180 */ 827, 827, 827, 827, 827, 827, 827, 827, 827, 827, /* 180 */ 615, 615, 615, 615, 615, 615, 615, 615, 615, 615,
/* 190 */ 827, 812, 827, 742, 827, 827, 827, 827, 827, 827, /* 190 */ 615, 817, 615, 747, 615, 615, 615, 615, 615, 615,
/* 200 */ 762, 827, 754, 827, 827, 827, 827, 827, 827, 715, /* 200 */ 767, 615, 759, 615, 615, 615, 615, 615, 615, 719,
/* 210 */ 827, 827, 827, 827, 827, 827, 827, 827, 827, 827, /* 210 */ 615, 615, 615, 615, 615, 615, 615, 615, 615, 615,
/* 220 */ 681, 827, 827, 827, 827, 827, 827, 827, 820, 827, /* 220 */ 685, 615, 615, 615, 615, 615, 615, 615, 825, 615,
/* 230 */ 827, 827, 709, 818, 827, 827, 827, 827, 827, 827, /* 230 */ 615, 615, 713, 823, 615, 615, 615, 615, 615, 615,
/* 240 */ 827, 827, 827, 827, 827, 827, 827, 633, 631, 827, /* 240 */ 615, 615, 615, 615, 615, 615, 615, 637, 635, 615,
/* 250 */ 827, /* 250 */ 615,
}; };
/********** End of lemon-generated parsing tables *****************************/ /********** End of lemon-generated parsing tables *****************************/
...@@ -476,7 +490,7 @@ static const YYCODETYPE yyFallback[] = { ...@@ -476,7 +490,7 @@ static const YYCODETYPE yyFallback[] = {
0, /* TABLE => nothing */ 0, /* TABLE => nothing */
1, /* DATABASE => ID */ 1, /* DATABASE => ID */
0, /* DNODE => nothing */ 0, /* DNODE => nothing */
1, /* IP => ID */ 1, /* IPTOKEN => ID */
0, /* USER => nothing */ 0, /* USER => nothing */
0, /* ACCOUNT => nothing */ 0, /* ACCOUNT => nothing */
0, /* USE => nothing */ 0, /* USE => nothing */
...@@ -512,7 +526,7 @@ static const YYCODETYPE yyFallback[] = { ...@@ -512,7 +526,7 @@ static const YYCODETYPE yyFallback[] = {
0, /* USING => nothing */ 0, /* USING => nothing */
0, /* AS => nothing */ 0, /* AS => nothing */
0, /* COMMA => nothing */ 0, /* COMMA => nothing */
0, /* NULL => nothing */ 1, /* NULL => ID */
0, /* SELECT => nothing */ 0, /* SELECT => nothing */
0, /* FROM => nothing */ 0, /* FROM => nothing */
0, /* VARIABLE => nothing */ 0, /* VARIABLE => nothing */
...@@ -637,17 +651,21 @@ typedef struct yyStackEntry yyStackEntry; ...@@ -637,17 +651,21 @@ typedef struct yyStackEntry yyStackEntry;
/* The state of the parser is completely contained in an instance of /* The state of the parser is completely contained in an instance of
** the following structure */ ** the following structure */
struct yyParser { struct yyParser {
int yyidx; /* Index of top element in stack */ yyStackEntry *yytos; /* Pointer to top element of the stack */
#ifdef YYTRACKMAXSTACKDEPTH #ifdef YYTRACKMAXSTACKDEPTH
int yyidxMax; /* Maximum value of yyidx */ int yyhwm; /* High-water mark of the stack */
#endif #endif
#ifndef YYNOERRORRECOVERY
int yyerrcnt; /* Shifts left before out of the error */ int yyerrcnt; /* Shifts left before out of the error */
#endif
ParseARG_SDECL /* A place to hold %extra_argument */ ParseARG_SDECL /* A place to hold %extra_argument */
#if YYSTACKDEPTH<=0 #if YYSTACKDEPTH<=0
int yystksz; /* Current side of the stack */ int yystksz; /* Current side of the stack */
yyStackEntry *yystack; /* The parser's stack */ yyStackEntry *yystack; /* The parser's stack */
yyStackEntry yystk0; /* First stack entry */
#else #else
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
yyStackEntry *yystackEnd; /* Last entry in the stack */
#endif #endif
}; };
typedef struct yyParser yyParser; typedef struct yyParser yyParser;
...@@ -684,77 +702,272 @@ void ParseTrace(FILE *TraceFILE, char *zTracePrompt){ ...@@ -684,77 +702,272 @@ void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
} }
#endif /* NDEBUG */ #endif /* NDEBUG */
#ifndef NDEBUG #if defined(YYCOVERAGE) || !defined(NDEBUG)
/* For tracing shifts, the names of all terminals and nonterminals /* For tracing shifts, the names of all terminals and nonterminals
** are required. The following table supplies these names */ ** are required. The following table supplies these names */
static const char *const yyTokenName[] = { static const char *const yyTokenName[] = {
"$", "ID", "BOOL", "TINYINT", /* 0 */ "$",
"SMALLINT", "INTEGER", "BIGINT", "FLOAT", /* 1 */ "ID",
"DOUBLE", "STRING", "TIMESTAMP", "BINARY", /* 2 */ "BOOL",
"NCHAR", "OR", "AND", "NOT", /* 3 */ "TINYINT",
"EQ", "NE", "ISNULL", "NOTNULL", /* 4 */ "SMALLINT",
"IS", "LIKE", "GLOB", "BETWEEN", /* 5 */ "INTEGER",
"IN", "GT", "GE", "LT", /* 6 */ "BIGINT",
"LE", "BITAND", "BITOR", "LSHIFT", /* 7 */ "FLOAT",
"RSHIFT", "PLUS", "MINUS", "DIVIDE", /* 8 */ "DOUBLE",
"TIMES", "STAR", "SLASH", "REM", /* 9 */ "STRING",
"CONCAT", "UMINUS", "UPLUS", "BITNOT", /* 10 */ "TIMESTAMP",
"SHOW", "DATABASES", "MNODES", "DNODES", /* 11 */ "BINARY",
"ACCOUNTS", "USERS", "MODULES", "QUERIES", /* 12 */ "NCHAR",
"CONNECTIONS", "STREAMS", "CONFIGS", "SCORES", /* 13 */ "OR",
"GRANTS", "DOT", "TABLES", "STABLES", /* 14 */ "AND",
"VGROUPS", "DROP", "TABLE", "DATABASE", /* 15 */ "NOT",
"DNODE", "IP", "USER", "ACCOUNT", /* 16 */ "EQ",
"USE", "DESCRIBE", "ALTER", "PASS", /* 17 */ "NE",
"PRIVILEGE", "LOCAL", "IF", "EXISTS", /* 18 */ "ISNULL",
"CREATE", "PPS", "TSERIES", "DBS", /* 19 */ "NOTNULL",
"STORAGE", "QTIME", "CONNS", "STATE", /* 20 */ "IS",
"KEEP", "CACHE", "REPLICA", "DAYS", /* 21 */ "LIKE",
"ROWS", "ABLOCKS", "TBLOCKS", "CTIME", /* 22 */ "GLOB",
"CLOG", "COMP", "PRECISION", "LP", /* 23 */ "BETWEEN",
"RP", "TAGS", "USING", "AS", /* 24 */ "IN",
"COMMA", "NULL", "SELECT", "FROM", /* 25 */ "GT",
"VARIABLE", "INTERVAL", "FILL", "SLIDING", /* 26 */ "GE",
"ORDER", "BY", "ASC", "DESC", /* 27 */ "LT",
"GROUP", "HAVING", "LIMIT", "OFFSET", /* 28 */ "LE",
"SLIMIT", "SOFFSET", "WHERE", "NOW", /* 29 */ "BITAND",
"INSERT", "INTO", "VALUES", "RESET", /* 30 */ "BITOR",
"QUERY", "ADD", "COLUMN", "TAG", /* 31 */ "LSHIFT",
"CHANGE", "SET", "KILL", "CONNECTION", /* 32 */ "RSHIFT",
"COLON", "STREAM", "ABORT", "AFTER", /* 33 */ "PLUS",
"ATTACH", "BEFORE", "BEGIN", "CASCADE", /* 34 */ "MINUS",
"CLUSTER", "CONFLICT", "COPY", "DEFERRED", /* 35 */ "DIVIDE",
"DELIMITERS", "DETACH", "EACH", "END", /* 36 */ "TIMES",
"EXPLAIN", "FAIL", "FOR", "IGNORE", /* 37 */ "STAR",
"IMMEDIATE", "INITIALLY", "INSTEAD", "MATCH", /* 38 */ "SLASH",
"KEY", "OF", "RAISE", "REPLACE", /* 39 */ "REM",
"RESTRICT", "ROW", "STATEMENT", "TRIGGER", /* 40 */ "CONCAT",
"VIEW", "ALL", "COUNT", "SUM", /* 41 */ "UMINUS",
"AVG", "MIN", "MAX", "FIRST", /* 42 */ "UPLUS",
"LAST", "TOP", "BOTTOM", "STDDEV", /* 43 */ "BITNOT",
"PERCENTILE", "APERCENTILE", "LEASTSQUARES", "HISTOGRAM", /* 44 */ "SHOW",
"DIFF", "SPREAD", "TWA", "INTERP", /* 45 */ "DATABASES",
"LAST_ROW", "SEMI", "NONE", "PREV", /* 46 */ "MNODES",
"LINEAR", "IMPORT", "METRIC", "TBNAME", /* 47 */ "DNODES",
"JOIN", "METRICS", "STABLE", "error", /* 48 */ "ACCOUNTS",
"program", "cmd", "dbPrefix", "ids", /* 49 */ "USERS",
"cpxName", "ifexists", "alter_db_optr", "acct_optr", /* 50 */ "MODULES",
"ifnotexists", "db_optr", "pps", "tseries", /* 51 */ "QUERIES",
"dbs", "streams", "storage", "qtime", /* 52 */ "CONNECTIONS",
"users", "conns", "state", "keep", /* 53 */ "STREAMS",
"tagitemlist", "tables", "cache", "replica", /* 54 */ "CONFIGS",
"days", "rows", "ablocks", "tblocks", /* 55 */ "SCORES",
"ctime", "clog", "comp", "prec", /* 56 */ "GRANTS",
"typename", "signed", "create_table_args", "columnlist", /* 57 */ "DOT",
"select", "column", "tagitem", "selcollist", /* 58 */ "TABLES",
"from", "where_opt", "interval_opt", "fill_opt", /* 59 */ "STABLES",
"sliding_opt", "groupby_opt", "orderby_opt", "having_opt", /* 60 */ "VGROUPS",
"slimit_opt", "limit_opt", "sclp", "expr", /* 61 */ "DROP",
"as", "tablelist", "tmvar", "sortlist", /* 62 */ "TABLE",
"sortitem", "item", "sortorder", "grouplist", /* 63 */ "DATABASE",
"exprlist", "expritem", "insert_value_list", "itemlist", /* 64 */ "DNODE",
/* 65 */ "IPTOKEN",
/* 66 */ "USER",
/* 67 */ "ACCOUNT",
/* 68 */ "USE",
/* 69 */ "DESCRIBE",
/* 70 */ "ALTER",
/* 71 */ "PASS",
/* 72 */ "PRIVILEGE",
/* 73 */ "LOCAL",
/* 74 */ "IF",
/* 75 */ "EXISTS",
/* 76 */ "CREATE",
/* 77 */ "PPS",
/* 78 */ "TSERIES",
/* 79 */ "DBS",
/* 80 */ "STORAGE",
/* 81 */ "QTIME",
/* 82 */ "CONNS",
/* 83 */ "STATE",
/* 84 */ "KEEP",
/* 85 */ "CACHE",
/* 86 */ "REPLICA",
/* 87 */ "DAYS",
/* 88 */ "ROWS",
/* 89 */ "ABLOCKS",
/* 90 */ "TBLOCKS",
/* 91 */ "CTIME",
/* 92 */ "CLOG",
/* 93 */ "COMP",
/* 94 */ "PRECISION",
/* 95 */ "LP",
/* 96 */ "RP",
/* 97 */ "TAGS",
/* 98 */ "USING",
/* 99 */ "AS",
/* 100 */ "COMMA",
/* 101 */ "NULL",
/* 102 */ "SELECT",
/* 103 */ "FROM",
/* 104 */ "VARIABLE",
/* 105 */ "INTERVAL",
/* 106 */ "FILL",
/* 107 */ "SLIDING",
/* 108 */ "ORDER",
/* 109 */ "BY",
/* 110 */ "ASC",
/* 111 */ "DESC",
/* 112 */ "GROUP",
/* 113 */ "HAVING",
/* 114 */ "LIMIT",
/* 115 */ "OFFSET",
/* 116 */ "SLIMIT",
/* 117 */ "SOFFSET",
/* 118 */ "WHERE",
/* 119 */ "NOW",
/* 120 */ "INSERT",
/* 121 */ "INTO",
/* 122 */ "VALUES",
/* 123 */ "RESET",
/* 124 */ "QUERY",
/* 125 */ "ADD",
/* 126 */ "COLUMN",
/* 127 */ "TAG",
/* 128 */ "CHANGE",
/* 129 */ "SET",
/* 130 */ "KILL",
/* 131 */ "CONNECTION",
/* 132 */ "COLON",
/* 133 */ "STREAM",
/* 134 */ "ABORT",
/* 135 */ "AFTER",
/* 136 */ "ATTACH",
/* 137 */ "BEFORE",
/* 138 */ "BEGIN",
/* 139 */ "CASCADE",
/* 140 */ "CLUSTER",
/* 141 */ "CONFLICT",
/* 142 */ "COPY",
/* 143 */ "DEFERRED",
/* 144 */ "DELIMITERS",
/* 145 */ "DETACH",
/* 146 */ "EACH",
/* 147 */ "END",
/* 148 */ "EXPLAIN",
/* 149 */ "FAIL",
/* 150 */ "FOR",
/* 151 */ "IGNORE",
/* 152 */ "IMMEDIATE",
/* 153 */ "INITIALLY",
/* 154 */ "INSTEAD",
/* 155 */ "MATCH",
/* 156 */ "KEY",
/* 157 */ "OF",
/* 158 */ "RAISE",
/* 159 */ "REPLACE",
/* 160 */ "RESTRICT",
/* 161 */ "ROW",
/* 162 */ "STATEMENT",
/* 163 */ "TRIGGER",
/* 164 */ "VIEW",
/* 165 */ "ALL",
/* 166 */ "COUNT",
/* 167 */ "SUM",
/* 168 */ "AVG",
/* 169 */ "MIN",
/* 170 */ "MAX",
/* 171 */ "FIRST",
/* 172 */ "LAST",
/* 173 */ "TOP",
/* 174 */ "BOTTOM",
/* 175 */ "STDDEV",
/* 176 */ "PERCENTILE",
/* 177 */ "APERCENTILE",
/* 178 */ "LEASTSQUARES",
/* 179 */ "HISTOGRAM",
/* 180 */ "DIFF",
/* 181 */ "SPREAD",
/* 182 */ "TWA",
/* 183 */ "INTERP",
/* 184 */ "LAST_ROW",
/* 185 */ "SEMI",
/* 186 */ "NONE",
/* 187 */ "PREV",
/* 188 */ "LINEAR",
/* 189 */ "IMPORT",
/* 190 */ "METRIC",
/* 191 */ "TBNAME",
/* 192 */ "JOIN",
/* 193 */ "METRICS",
/* 194 */ "STABLE",
/* 195 */ "error",
/* 196 */ "program",
/* 197 */ "cmd",
/* 198 */ "dbPrefix",
/* 199 */ "ids",
/* 200 */ "cpxName",
/* 201 */ "ifexists",
/* 202 */ "alter_db_optr",
/* 203 */ "acct_optr",
/* 204 */ "ifnotexists",
/* 205 */ "db_optr",
/* 206 */ "pps",
/* 207 */ "tseries",
/* 208 */ "dbs",
/* 209 */ "streams",
/* 210 */ "storage",
/* 211 */ "qtime",
/* 212 */ "users",
/* 213 */ "conns",
/* 214 */ "state",
/* 215 */ "keep",
/* 216 */ "tagitemlist",
/* 217 */ "tables",
/* 218 */ "cache",
/* 219 */ "replica",
/* 220 */ "days",
/* 221 */ "rows",
/* 222 */ "ablocks",
/* 223 */ "tblocks",
/* 224 */ "ctime",
/* 225 */ "clog",
/* 226 */ "comp",
/* 227 */ "prec",
/* 228 */ "typename",
/* 229 */ "signed",
/* 230 */ "create_table_args",
/* 231 */ "columnlist",
/* 232 */ "select",
/* 233 */ "column",
/* 234 */ "tagitem",
/* 235 */ "selcollist",
/* 236 */ "from",
/* 237 */ "where_opt",
/* 238 */ "interval_opt",
/* 239 */ "fill_opt",
/* 240 */ "sliding_opt",
/* 241 */ "groupby_opt",
/* 242 */ "orderby_opt",
/* 243 */ "having_opt",
/* 244 */ "slimit_opt",
/* 245 */ "limit_opt",
/* 246 */ "sclp",
/* 247 */ "expr",
/* 248 */ "as",
/* 249 */ "tablelist",
/* 250 */ "tmvar",
/* 251 */ "sortlist",
/* 252 */ "sortitem",
/* 253 */ "item",
/* 254 */ "sortorder",
/* 255 */ "grouplist",
/* 256 */ "exprlist",
/* 257 */ "expritem",
/* 258 */ "insert_value_list",
/* 259 */ "itemlist",
}; };
#endif /* NDEBUG */ #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
#ifndef NDEBUG #ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required. /* For tracing reduce actions, the names of all rules are required.
...@@ -784,15 +997,15 @@ static const char *const yyRuleName[] = { ...@@ -784,15 +997,15 @@ static const char *const yyRuleName[] = {
/* 21 */ "cmd ::= SHOW dbPrefix VGROUPS", /* 21 */ "cmd ::= SHOW dbPrefix VGROUPS",
/* 22 */ "cmd ::= DROP TABLE ifexists ids cpxName", /* 22 */ "cmd ::= DROP TABLE ifexists ids cpxName",
/* 23 */ "cmd ::= DROP DATABASE ifexists ids", /* 23 */ "cmd ::= DROP DATABASE ifexists ids",
/* 24 */ "cmd ::= DROP DNODE IP", /* 24 */ "cmd ::= DROP DNODE IPTOKEN",
/* 25 */ "cmd ::= DROP USER ids", /* 25 */ "cmd ::= DROP USER ids",
/* 26 */ "cmd ::= DROP ACCOUNT ids", /* 26 */ "cmd ::= DROP ACCOUNT ids",
/* 27 */ "cmd ::= USE ids", /* 27 */ "cmd ::= USE ids",
/* 28 */ "cmd ::= DESCRIBE ids cpxName", /* 28 */ "cmd ::= DESCRIBE ids cpxName",
/* 29 */ "cmd ::= ALTER USER ids PASS ids", /* 29 */ "cmd ::= ALTER USER ids PASS ids",
/* 30 */ "cmd ::= ALTER USER ids PRIVILEGE ids", /* 30 */ "cmd ::= ALTER USER ids PRIVILEGE ids",
/* 31 */ "cmd ::= ALTER DNODE IP ids", /* 31 */ "cmd ::= ALTER DNODE IPTOKEN ids",
/* 32 */ "cmd ::= ALTER DNODE IP ids ids", /* 32 */ "cmd ::= ALTER DNODE IPTOKEN ids ids",
/* 33 */ "cmd ::= ALTER LOCAL ids", /* 33 */ "cmd ::= ALTER LOCAL ids",
/* 34 */ "cmd ::= ALTER LOCAL ids ids", /* 34 */ "cmd ::= ALTER LOCAL ids ids",
/* 35 */ "cmd ::= ALTER DATABASE ids alter_db_optr", /* 35 */ "cmd ::= ALTER DATABASE ids alter_db_optr",
...@@ -804,7 +1017,7 @@ static const char *const yyRuleName[] = { ...@@ -804,7 +1017,7 @@ static const char *const yyRuleName[] = {
/* 41 */ "ifexists ::=", /* 41 */ "ifexists ::=",
/* 42 */ "ifnotexists ::= IF NOT EXISTS", /* 42 */ "ifnotexists ::= IF NOT EXISTS",
/* 43 */ "ifnotexists ::=", /* 43 */ "ifnotexists ::=",
/* 44 */ "cmd ::= CREATE DNODE IP", /* 44 */ "cmd ::= CREATE DNODE IPTOKEN",
/* 45 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", /* 45 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr",
/* 46 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", /* 46 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr",
/* 47 */ "cmd ::= CREATE USER ids PASS ids", /* 47 */ "cmd ::= CREATE USER ids PASS ids",
...@@ -881,122 +1094,133 @@ static const char *const yyRuleName[] = { ...@@ -881,122 +1094,133 @@ static const char *const yyRuleName[] = {
/* 118 */ "tagitem ::= PLUS FLOAT", /* 118 */ "tagitem ::= PLUS FLOAT",
/* 119 */ "cmd ::= select", /* 119 */ "cmd ::= select",
/* 120 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", /* 120 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt",
/* 121 */ "sclp ::= selcollist COMMA", /* 121 */ "select ::= SELECT selcollist",
/* 122 */ "sclp ::=", /* 122 */ "sclp ::= selcollist COMMA",
/* 123 */ "selcollist ::= sclp expr as", /* 123 */ "sclp ::=",
/* 124 */ "selcollist ::= sclp STAR", /* 124 */ "selcollist ::= sclp expr as",
/* 125 */ "as ::= AS ids", /* 125 */ "selcollist ::= sclp STAR",
/* 126 */ "as ::= ids", /* 126 */ "as ::= AS ids",
/* 127 */ "as ::=", /* 127 */ "as ::= ids",
/* 128 */ "from ::= FROM tablelist", /* 128 */ "as ::=",
/* 129 */ "tablelist ::= ids cpxName", /* 129 */ "from ::= FROM tablelist",
/* 130 */ "tablelist ::= tablelist COMMA ids cpxName", /* 130 */ "tablelist ::= ids cpxName",
/* 131 */ "tmvar ::= VARIABLE", /* 131 */ "tablelist ::= tablelist COMMA ids cpxName",
/* 132 */ "interval_opt ::= INTERVAL LP tmvar RP", /* 132 */ "tmvar ::= VARIABLE",
/* 133 */ "interval_opt ::=", /* 133 */ "interval_opt ::= INTERVAL LP tmvar RP",
/* 134 */ "fill_opt ::=", /* 134 */ "interval_opt ::=",
/* 135 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", /* 135 */ "fill_opt ::=",
/* 136 */ "fill_opt ::= FILL LP ID RP", /* 136 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP",
/* 137 */ "sliding_opt ::= SLIDING LP tmvar RP", /* 137 */ "fill_opt ::= FILL LP ID RP",
/* 138 */ "sliding_opt ::=", /* 138 */ "sliding_opt ::= SLIDING LP tmvar RP",
/* 139 */ "orderby_opt ::=", /* 139 */ "sliding_opt ::=",
/* 140 */ "orderby_opt ::= ORDER BY sortlist", /* 140 */ "orderby_opt ::=",
/* 141 */ "sortlist ::= sortlist COMMA item sortorder", /* 141 */ "orderby_opt ::= ORDER BY sortlist",
/* 142 */ "sortlist ::= item sortorder", /* 142 */ "sortlist ::= sortlist COMMA item sortorder",
/* 143 */ "item ::= ids cpxName", /* 143 */ "sortlist ::= item sortorder",
/* 144 */ "sortorder ::= ASC", /* 144 */ "item ::= ids cpxName",
/* 145 */ "sortorder ::= DESC", /* 145 */ "sortorder ::= ASC",
/* 146 */ "sortorder ::=", /* 146 */ "sortorder ::= DESC",
/* 147 */ "groupby_opt ::=", /* 147 */ "sortorder ::=",
/* 148 */ "groupby_opt ::= GROUP BY grouplist", /* 148 */ "groupby_opt ::=",
/* 149 */ "grouplist ::= grouplist COMMA item", /* 149 */ "groupby_opt ::= GROUP BY grouplist",
/* 150 */ "grouplist ::= item", /* 150 */ "grouplist ::= grouplist COMMA item",
/* 151 */ "having_opt ::=", /* 151 */ "grouplist ::= item",
/* 152 */ "having_opt ::= HAVING expr", /* 152 */ "having_opt ::=",
/* 153 */ "limit_opt ::=", /* 153 */ "having_opt ::= HAVING expr",
/* 154 */ "limit_opt ::= LIMIT signed", /* 154 */ "limit_opt ::=",
/* 155 */ "limit_opt ::= LIMIT signed OFFSET signed", /* 155 */ "limit_opt ::= LIMIT signed",
/* 156 */ "limit_opt ::= LIMIT signed COMMA signed", /* 156 */ "limit_opt ::= LIMIT signed OFFSET signed",
/* 157 */ "slimit_opt ::=", /* 157 */ "limit_opt ::= LIMIT signed COMMA signed",
/* 158 */ "slimit_opt ::= SLIMIT signed", /* 158 */ "slimit_opt ::=",
/* 159 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", /* 159 */ "slimit_opt ::= SLIMIT signed",
/* 160 */ "slimit_opt ::= SLIMIT signed COMMA signed", /* 160 */ "slimit_opt ::= SLIMIT signed SOFFSET signed",
/* 161 */ "where_opt ::=", /* 161 */ "slimit_opt ::= SLIMIT signed COMMA signed",
/* 162 */ "where_opt ::= WHERE expr", /* 162 */ "where_opt ::=",
/* 163 */ "expr ::= LP expr RP", /* 163 */ "where_opt ::= WHERE expr",
/* 164 */ "expr ::= ID", /* 164 */ "expr ::= LP expr RP",
/* 165 */ "expr ::= ID DOT ID", /* 165 */ "expr ::= ID",
/* 166 */ "expr ::= ID DOT STAR", /* 166 */ "expr ::= ID DOT ID",
/* 167 */ "expr ::= INTEGER", /* 167 */ "expr ::= ID DOT STAR",
/* 168 */ "expr ::= MINUS INTEGER", /* 168 */ "expr ::= INTEGER",
/* 169 */ "expr ::= PLUS INTEGER", /* 169 */ "expr ::= MINUS INTEGER",
/* 170 */ "expr ::= FLOAT", /* 170 */ "expr ::= PLUS INTEGER",
/* 171 */ "expr ::= MINUS FLOAT", /* 171 */ "expr ::= FLOAT",
/* 172 */ "expr ::= PLUS FLOAT", /* 172 */ "expr ::= MINUS FLOAT",
/* 173 */ "expr ::= STRING", /* 173 */ "expr ::= PLUS FLOAT",
/* 174 */ "expr ::= NOW", /* 174 */ "expr ::= STRING",
/* 175 */ "expr ::= VARIABLE", /* 175 */ "expr ::= NOW",
/* 176 */ "expr ::= BOOL", /* 176 */ "expr ::= VARIABLE",
/* 177 */ "expr ::= ID LP exprlist RP", /* 177 */ "expr ::= BOOL",
/* 178 */ "expr ::= ID LP STAR RP", /* 178 */ "expr ::= ID LP exprlist RP",
/* 179 */ "expr ::= expr AND expr", /* 179 */ "expr ::= ID LP STAR RP",
/* 180 */ "expr ::= expr OR expr", /* 180 */ "expr ::= expr AND expr",
/* 181 */ "expr ::= expr LT expr", /* 181 */ "expr ::= expr OR expr",
/* 182 */ "expr ::= expr GT expr", /* 182 */ "expr ::= expr LT expr",
/* 183 */ "expr ::= expr LE expr", /* 183 */ "expr ::= expr GT expr",
/* 184 */ "expr ::= expr GE expr", /* 184 */ "expr ::= expr LE expr",
/* 185 */ "expr ::= expr NE expr", /* 185 */ "expr ::= expr GE expr",
/* 186 */ "expr ::= expr EQ expr", /* 186 */ "expr ::= expr NE expr",
/* 187 */ "expr ::= expr PLUS expr", /* 187 */ "expr ::= expr EQ expr",
/* 188 */ "expr ::= expr MINUS expr", /* 188 */ "expr ::= expr PLUS expr",
/* 189 */ "expr ::= expr STAR expr", /* 189 */ "expr ::= expr MINUS expr",
/* 190 */ "expr ::= expr SLASH expr", /* 190 */ "expr ::= expr STAR expr",
/* 191 */ "expr ::= expr REM expr", /* 191 */ "expr ::= expr SLASH expr",
/* 192 */ "expr ::= expr LIKE expr", /* 192 */ "expr ::= expr REM expr",
/* 193 */ "expr ::= expr IN LP exprlist RP", /* 193 */ "expr ::= expr LIKE expr",
/* 194 */ "exprlist ::= exprlist COMMA expritem", /* 194 */ "expr ::= expr IN LP exprlist RP",
/* 195 */ "exprlist ::= expritem", /* 195 */ "exprlist ::= exprlist COMMA expritem",
/* 196 */ "expritem ::= expr", /* 196 */ "exprlist ::= expritem",
/* 197 */ "expritem ::=", /* 197 */ "expritem ::= expr",
/* 198 */ "cmd ::= INSERT INTO cpxName insert_value_list", /* 198 */ "expritem ::=",
/* 199 */ "insert_value_list ::= VALUES LP itemlist RP", /* 199 */ "cmd ::= INSERT INTO cpxName insert_value_list",
/* 200 */ "insert_value_list ::= insert_value_list VALUES LP itemlist RP", /* 200 */ "insert_value_list ::= VALUES LP itemlist RP",
/* 201 */ "itemlist ::= itemlist COMMA expr", /* 201 */ "insert_value_list ::= insert_value_list VALUES LP itemlist RP",
/* 202 */ "itemlist ::= expr", /* 202 */ "itemlist ::= itemlist COMMA expr",
/* 203 */ "cmd ::= RESET QUERY CACHE", /* 203 */ "itemlist ::= expr",
/* 204 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", /* 204 */ "cmd ::= RESET QUERY CACHE",
/* 205 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", /* 205 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist",
/* 206 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", /* 206 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids",
/* 207 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", /* 207 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist",
/* 208 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", /* 208 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids",
/* 209 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", /* 209 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids",
/* 210 */ "cmd ::= KILL CONNECTION IP COLON INTEGER", /* 210 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem",
/* 211 */ "cmd ::= KILL STREAM IP COLON INTEGER COLON INTEGER", /* 211 */ "cmd ::= KILL CONNECTION IPTOKEN COLON INTEGER",
/* 212 */ "cmd ::= KILL QUERY IP COLON INTEGER COLON INTEGER", /* 212 */ "cmd ::= KILL STREAM IPTOKEN COLON INTEGER COLON INTEGER",
/* 213 */ "cmd ::= KILL QUERY IPTOKEN COLON INTEGER COLON INTEGER",
}; };
#endif /* NDEBUG */ #endif /* NDEBUG */
#if YYSTACKDEPTH<=0 #if YYSTACKDEPTH<=0
/* /*
** Try to increase the size of the parser stack. ** Try to increase the size of the parser stack. Return the number
** of errors. Return 0 on success.
*/ */
static void yyGrowStack(yyParser *p){ static int yyGrowStack(yyParser *p){
int newSize; int newSize;
int idx;
yyStackEntry *pNew; yyStackEntry *pNew;
newSize = p->yystksz*2 + 100; newSize = p->yystksz*2 + 100;
pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
if( p->yystack==&p->yystk0 ){
pNew = malloc(newSize*sizeof(pNew[0]));
if( pNew ) pNew[0] = p->yystk0;
}else{
pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
}
if( pNew ){ if( pNew ){
p->yystack = pNew; p->yystack = pNew;
p->yystksz = newSize; p->yytos = &p->yystack[idx];
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sStack grows to %d entries!\n", fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
yyTracePrompt, p->yystksz); yyTracePrompt, p->yystksz, newSize);
} }
#endif #endif
p->yystksz = newSize;
} }
return pNew==0;
} }
#endif #endif
...@@ -1009,6 +1233,34 @@ static void yyGrowStack(yyParser *p){ ...@@ -1009,6 +1233,34 @@ static void yyGrowStack(yyParser *p){
# define YYMALLOCARGTYPE size_t # define YYMALLOCARGTYPE size_t
#endif #endif
/* Initialize a new parser that has already been allocated.
*/
void ParseInit(void *yypParser){
yyParser *pParser = (yyParser*)yypParser;
#ifdef YYTRACKMAXSTACKDEPTH
pParser->yyhwm = 0;
#endif
#if YYSTACKDEPTH<=0
pParser->yytos = NULL;
pParser->yystack = NULL;
pParser->yystksz = 0;
if( yyGrowStack(pParser) ){
pParser->yystack = &pParser->yystk0;
pParser->yystksz = 1;
}
#endif
#ifndef YYNOERRORRECOVERY
pParser->yyerrcnt = -1;
#endif
pParser->yytos = pParser->yystack;
pParser->yystack[0].stateno = 0;
pParser->yystack[0].major = 0;
#if YYSTACKDEPTH>0
pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1];
#endif
}
#ifndef Parse_ENGINEALWAYSONSTACK
/* /*
** This function allocates a new parser. ** This function allocates a new parser.
** The only argument is a pointer to a function which works like ** The only argument is a pointer to a function which works like
...@@ -1024,19 +1276,11 @@ static void yyGrowStack(yyParser *p){ ...@@ -1024,19 +1276,11 @@ static void yyGrowStack(yyParser *p){
void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){ void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
yyParser *pParser; yyParser *pParser;
pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
if( pParser ){ if( pParser ) ParseInit(pParser);
pParser->yyidx = -1;
#ifdef YYTRACKMAXSTACKDEPTH
pParser->yyidxMax = 0;
#endif
#if YYSTACKDEPTH<=0
pParser->yystack = NULL;
pParser->yystksz = 0;
yyGrowStack(pParser);
#endif
}
return pParser; return pParser;
} }
#endif /* Parse_ENGINEALWAYSONSTACK */
/* The following function deletes the "minor type" or semantic value /* The following function deletes the "minor type" or semantic value
** associated with a symbol. The symbol can be either a terminal ** associated with a symbol. The symbol can be either a terminal
...@@ -1118,8 +1362,9 @@ tVariantDestroy(&(yypminor->yy186)); ...@@ -1118,8 +1362,9 @@ tVariantDestroy(&(yypminor->yy186));
*/ */
static void yy_pop_parser_stack(yyParser *pParser){ static void yy_pop_parser_stack(yyParser *pParser){
yyStackEntry *yytos; yyStackEntry *yytos;
assert( pParser->yyidx>=0 ); assert( pParser->yytos!=0 );
yytos = &pParser->yystack[pParser->yyidx--]; assert( pParser->yytos > pParser->yystack );
yytos = pParser->yytos--;
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sPopping %s\n", fprintf(yyTraceFILE,"%sPopping %s\n",
...@@ -1130,6 +1375,18 @@ static void yy_pop_parser_stack(yyParser *pParser){ ...@@ -1130,6 +1375,18 @@ static void yy_pop_parser_stack(yyParser *pParser){
yy_destructor(pParser, yytos->major, &yytos->minor); yy_destructor(pParser, yytos->major, &yytos->minor);
} }
/*
** Clear all secondary memory allocations from the parser
*/
void ParseFinalize(void *p){
yyParser *pParser = (yyParser*)p;
while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
#if YYSTACKDEPTH<=0
if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);
#endif
}
#ifndef Parse_ENGINEALWAYSONSTACK
/* /*
** Deallocate and destroy a parser. Destructors are called for ** Deallocate and destroy a parser. Destructors are called for
** all stack elements before shutting the parser down. ** all stack elements before shutting the parser down.
...@@ -1142,16 +1399,13 @@ void ParseFree( ...@@ -1142,16 +1399,13 @@ void ParseFree(
void *p, /* The parser to be deleted */ void *p, /* The parser to be deleted */
void (*freeProc)(void*) /* Function used to reclaim memory */ void (*freeProc)(void*) /* Function used to reclaim memory */
){ ){
yyParser *pParser = (yyParser*)p;
#ifndef YYPARSEFREENEVERNULL #ifndef YYPARSEFREENEVERNULL
if( pParser==0 ) return; if( p==0 ) return;
#endif
while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
#if YYSTACKDEPTH<=0
free(pParser->yystack);
#endif #endif
(*freeProc)((void*)pParser); ParseFinalize(p);
(*freeProc)(p);
} }
#endif /* Parse_ENGINEALWAYSONSTACK */
/* /*
** Return the peak depth of the stack for a parser. ** Return the peak depth of the stack for a parser.
...@@ -1159,7 +1413,44 @@ void ParseFree( ...@@ -1159,7 +1413,44 @@ void ParseFree(
#ifdef YYTRACKMAXSTACKDEPTH #ifdef YYTRACKMAXSTACKDEPTH
int ParseStackPeak(void *p){ int ParseStackPeak(void *p){
yyParser *pParser = (yyParser*)p; yyParser *pParser = (yyParser*)p;
return pParser->yyidxMax; return pParser->yyhwm;
}
#endif
/* This array of booleans keeps track of the parser statement
** coverage. The element yycoverage[X][Y] is set when the parser
** is in state X and has a lookahead token Y. In a well-tested
** systems, every element of this matrix should end up being set.
*/
#if defined(YYCOVERAGE)
static unsigned char yycoverage[YYNSTATE][YYNTOKEN];
#endif
/*
** Write into out a description of every state/lookahead combination that
**
** (1) has not been used by the parser, and
** (2) is not a syntax error.
**
** Return the number of missed state/lookahead combinations.
*/
#if defined(YYCOVERAGE)
int ParseCoverage(FILE *out){
int stateno, iLookAhead, i;
int nMissed = 0;
for(stateno=0; stateno<YYNSTATE; stateno++){
i = yy_shift_ofst[stateno];
for(iLookAhead=0; iLookAhead<YYNTOKEN; iLookAhead++){
if( yy_lookahead[i+iLookAhead]!=iLookAhead ) continue;
if( yycoverage[stateno][iLookAhead]==0 ) nMissed++;
if( out ){
fprintf(out,"State %d lookahead %s %s\n", stateno,
yyTokenName[iLookAhead],
yycoverage[stateno][iLookAhead] ? "ok" : "missed");
}
}
}
return nMissed;
} }
#endif #endif
...@@ -1167,61 +1458,63 @@ int ParseStackPeak(void *p){ ...@@ -1167,61 +1458,63 @@ int ParseStackPeak(void *p){
** Find the appropriate action for a parser given the terminal ** Find the appropriate action for a parser given the terminal
** look-ahead token iLookAhead. ** look-ahead token iLookAhead.
*/ */
static int yy_find_shift_action( static unsigned int yy_find_shift_action(
yyParser *pParser, /* The parser */ yyParser *pParser, /* The parser */
YYCODETYPE iLookAhead /* The look-ahead token */ YYCODETYPE iLookAhead /* The look-ahead token */
){ ){
int i; int i;
int stateno = pParser->yystack[pParser->yyidx].stateno; int stateno = pParser->yytos->stateno;
if( stateno>=YY_MIN_REDUCE ) return stateno; if( stateno>YY_MAX_SHIFT ) return stateno;
assert( stateno <= YY_SHIFT_COUNT ); assert( stateno <= YY_SHIFT_COUNT );
#if defined(YYCOVERAGE)
yycoverage[stateno][iLookAhead] = 1;
#endif
do{ do{
i = yy_shift_ofst[stateno]; i = yy_shift_ofst[stateno];
if( i==YY_SHIFT_USE_DFLT ) return yy_default[stateno]; assert( i>=0 && i+YYNTOKEN<=sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) );
assert( iLookAhead!=YYNOCODE ); assert( iLookAhead!=YYNOCODE );
assert( iLookAhead < YYNTOKEN );
i += iLookAhead; i += iLookAhead;
if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ if( yy_lookahead[i]!=iLookAhead ){
if( iLookAhead>0 ){
#ifdef YYFALLBACK #ifdef YYFALLBACK
YYCODETYPE iFallback; /* Fallback token */ YYCODETYPE iFallback; /* Fallback token */
if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
&& (iFallback = yyFallback[iLookAhead])!=0 ){ && (iFallback = yyFallback[iLookAhead])!=0 ){
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
}
#endif
assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
iLookAhead = iFallback;
continue;
} }
#endif
assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
iLookAhead = iFallback;
continue;
}
#endif #endif
#ifdef YYWILDCARD #ifdef YYWILDCARD
{ {
int j = i - iLookAhead + YYWILDCARD; int j = i - iLookAhead + YYWILDCARD;
if( if(
#if YY_SHIFT_MIN+YYWILDCARD<0 #if YY_SHIFT_MIN+YYWILDCARD<0
j>=0 && j>=0 &&
#endif #endif
#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
j<YY_ACTTAB_COUNT && j<YY_ACTTAB_COUNT &&
#endif #endif
yy_lookahead[j]==YYWILDCARD yy_lookahead[j]==YYWILDCARD && iLookAhead>0
){ ){
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
yyTracePrompt, yyTokenName[iLookAhead], yyTracePrompt, yyTokenName[iLookAhead],
yyTokenName[YYWILDCARD]); yyTokenName[YYWILDCARD]);
}
#endif /* NDEBUG */
return yy_action[j];
} }
#endif /* NDEBUG */
return yy_action[j];
} }
#endif /* YYWILDCARD */
} }
#endif /* YYWILDCARD */
return yy_default[stateno]; return yy_default[stateno];
}else{ }else{
return yy_action[i]; return yy_action[i];
...@@ -1246,7 +1539,6 @@ static int yy_find_reduce_action( ...@@ -1246,7 +1539,6 @@ static int yy_find_reduce_action(
assert( stateno<=YY_REDUCE_COUNT ); assert( stateno<=YY_REDUCE_COUNT );
#endif #endif
i = yy_reduce_ofst[stateno]; i = yy_reduce_ofst[stateno];
assert( i!=YY_REDUCE_USE_DFLT );
assert( iLookAhead!=YYNOCODE ); assert( iLookAhead!=YYNOCODE );
i += iLookAhead; i += iLookAhead;
#ifdef YYERRORSYMBOL #ifdef YYERRORSYMBOL
...@@ -1263,15 +1555,14 @@ static int yy_find_reduce_action( ...@@ -1263,15 +1555,14 @@ static int yy_find_reduce_action(
/* /*
** The following routine is called if the stack overflows. ** The following routine is called if the stack overflows.
*/ */
static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){ static void yyStackOverflow(yyParser *yypParser){
ParseARG_FETCH; ParseARG_FETCH;
yypParser->yyidx--;
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
} }
#endif #endif
while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
/* Here code is inserted which will execute if the parser /* Here code is inserted which will execute if the parser
** stack every overflows */ ** stack every overflows */
/******** Begin %stack_overflow code ******************************************/ /******** Begin %stack_overflow code ******************************************/
...@@ -1283,20 +1574,21 @@ static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){ ...@@ -1283,20 +1574,21 @@ static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
** Print tracing information for a SHIFT action ** Print tracing information for a SHIFT action
*/ */
#ifndef NDEBUG #ifndef NDEBUG
static void yyTraceShift(yyParser *yypParser, int yyNewState){ static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){
if( yyTraceFILE ){ if( yyTraceFILE ){
if( yyNewState<YYNSTATE ){ if( yyNewState<YYNSTATE ){
fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n", fprintf(yyTraceFILE,"%s%s '%s', go to state %d\n",
yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major], yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
yyNewState); yyNewState);
}else{ }else{
fprintf(yyTraceFILE,"%sShift '%s'\n", fprintf(yyTraceFILE,"%s%s '%s', pending reduce %d\n",
yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major]); yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
yyNewState - YY_MIN_REDUCE);
} }
} }
} }
#else #else
# define yyTraceShift(X,Y) # define yyTraceShift(X,Y,Z)
#endif #endif
/* /*
...@@ -1306,256 +1598,262 @@ static void yy_shift( ...@@ -1306,256 +1598,262 @@ static void yy_shift(
yyParser *yypParser, /* The parser to be shifted */ yyParser *yypParser, /* The parser to be shifted */
int yyNewState, /* The new state to shift in */ int yyNewState, /* The new state to shift in */
int yyMajor, /* The major token to shift in */ int yyMajor, /* The major token to shift in */
YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */ ParseTOKENTYPE yyMinor /* The minor token to shift in */
){ ){
yyStackEntry *yytos; yyStackEntry *yytos;
yypParser->yyidx++; yypParser->yytos++;
#ifdef YYTRACKMAXSTACKDEPTH #ifdef YYTRACKMAXSTACKDEPTH
if( yypParser->yyidx>yypParser->yyidxMax ){ if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
yypParser->yyidxMax = yypParser->yyidx; yypParser->yyhwm++;
assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
} }
#endif #endif
#if YYSTACKDEPTH>0 #if YYSTACKDEPTH>0
if( yypParser->yyidx>=YYSTACKDEPTH ){ if( yypParser->yytos>yypParser->yystackEnd ){
yyStackOverflow(yypParser, yypMinor); yypParser->yytos--;
yyStackOverflow(yypParser);
return; return;
} }
#else #else
if( yypParser->yyidx>=yypParser->yystksz ){ if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
yyGrowStack(yypParser); if( yyGrowStack(yypParser) ){
if( yypParser->yyidx>=yypParser->yystksz ){ yypParser->yytos--;
yyStackOverflow(yypParser, yypMinor); yyStackOverflow(yypParser);
return; return;
} }
} }
#endif #endif
yytos = &yypParser->yystack[yypParser->yyidx]; if( yyNewState > YY_MAX_SHIFT ){
yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
}
yytos = yypParser->yytos;
yytos->stateno = (YYACTIONTYPE)yyNewState; yytos->stateno = (YYACTIONTYPE)yyNewState;
yytos->major = (YYCODETYPE)yyMajor; yytos->major = (YYCODETYPE)yyMajor;
yytos->minor = *yypMinor; yytos->minor.yy0 = yyMinor;
yyTraceShift(yypParser, yyNewState); yyTraceShift(yypParser, yyNewState, "Shift");
} }
/* The following table contains information about every rule that /* The following table contains information about every rule that
** is used during the reduce. ** is used during the reduce.
*/ */
static const struct { static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
unsigned char nrhs; /* Number of right-hand side symbols in the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */
} yyRuleInfo[] = { } yyRuleInfo[] = {
{ 196, 1 }, { 196, -1 }, /* (0) program ::= cmd */
{ 197, 2 }, { 197, -2 }, /* (1) cmd ::= SHOW DATABASES */
{ 197, 2 }, { 197, -2 }, /* (2) cmd ::= SHOW MNODES */
{ 197, 2 }, { 197, -2 }, /* (3) cmd ::= SHOW DNODES */
{ 197, 2 }, { 197, -2 }, /* (4) cmd ::= SHOW ACCOUNTS */
{ 197, 2 }, { 197, -2 }, /* (5) cmd ::= SHOW USERS */
{ 197, 2 }, { 197, -2 }, /* (6) cmd ::= SHOW MODULES */
{ 197, 2 }, { 197, -2 }, /* (7) cmd ::= SHOW QUERIES */
{ 197, 2 }, { 197, -2 }, /* (8) cmd ::= SHOW CONNECTIONS */
{ 197, 2 }, { 197, -2 }, /* (9) cmd ::= SHOW STREAMS */
{ 197, 2 }, { 197, -2 }, /* (10) cmd ::= SHOW CONFIGS */
{ 197, 2 }, { 197, -2 }, /* (11) cmd ::= SHOW SCORES */
{ 197, 2 }, { 197, -2 }, /* (12) cmd ::= SHOW GRANTS */
{ 198, 0 }, { 198, 0 }, /* (13) dbPrefix ::= */
{ 198, 2 }, { 198, -2 }, /* (14) dbPrefix ::= ids DOT */
{ 200, 0 }, { 200, 0 }, /* (15) cpxName ::= */
{ 200, 2 }, { 200, -2 }, /* (16) cpxName ::= DOT ids */
{ 197, 3 }, { 197, -3 }, /* (17) cmd ::= SHOW dbPrefix TABLES */
{ 197, 5 }, { 197, -5 }, /* (18) cmd ::= SHOW dbPrefix TABLES LIKE ids */
{ 197, 3 }, { 197, -3 }, /* (19) cmd ::= SHOW dbPrefix STABLES */
{ 197, 5 }, { 197, -5 }, /* (20) cmd ::= SHOW dbPrefix STABLES LIKE ids */
{ 197, 3 }, { 197, -3 }, /* (21) cmd ::= SHOW dbPrefix VGROUPS */
{ 197, 5 }, { 197, -5 }, /* (22) cmd ::= DROP TABLE ifexists ids cpxName */
{ 197, 4 }, { 197, -4 }, /* (23) cmd ::= DROP DATABASE ifexists ids */
{ 197, 3 }, { 197, -3 }, /* (24) cmd ::= DROP DNODE IPTOKEN */
{ 197, 3 }, { 197, -3 }, /* (25) cmd ::= DROP USER ids */
{ 197, 3 }, { 197, -3 }, /* (26) cmd ::= DROP ACCOUNT ids */
{ 197, 2 }, { 197, -2 }, /* (27) cmd ::= USE ids */
{ 197, 3 }, { 197, -3 }, /* (28) cmd ::= DESCRIBE ids cpxName */
{ 197, 5 }, { 197, -5 }, /* (29) cmd ::= ALTER USER ids PASS ids */
{ 197, 5 }, { 197, -5 }, /* (30) cmd ::= ALTER USER ids PRIVILEGE ids */
{ 197, 4 }, { 197, -4 }, /* (31) cmd ::= ALTER DNODE IPTOKEN ids */
{ 197, 5 }, { 197, -5 }, /* (32) cmd ::= ALTER DNODE IPTOKEN ids ids */
{ 197, 3 }, { 197, -3 }, /* (33) cmd ::= ALTER LOCAL ids */
{ 197, 4 }, { 197, -4 }, /* (34) cmd ::= ALTER LOCAL ids ids */
{ 197, 4 }, { 197, -4 }, /* (35) cmd ::= ALTER DATABASE ids alter_db_optr */
{ 197, 4 }, { 197, -4 }, /* (36) cmd ::= ALTER ACCOUNT ids acct_optr */
{ 197, 6 }, { 197, -6 }, /* (37) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
{ 199, 1 }, { 199, -1 }, /* (38) ids ::= ID */
{ 199, 1 }, { 199, -1 }, /* (39) ids ::= STRING */
{ 201, 2 }, { 201, -2 }, /* (40) ifexists ::= IF EXISTS */
{ 201, 0 }, { 201, 0 }, /* (41) ifexists ::= */
{ 204, 3 }, { 204, -3 }, /* (42) ifnotexists ::= IF NOT EXISTS */
{ 204, 0 }, { 204, 0 }, /* (43) ifnotexists ::= */
{ 197, 3 }, { 197, -3 }, /* (44) cmd ::= CREATE DNODE IPTOKEN */
{ 197, 6 }, { 197, -6 }, /* (45) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
{ 197, 5 }, { 197, -5 }, /* (46) cmd ::= CREATE DATABASE ifnotexists ids db_optr */
{ 197, 5 }, { 197, -5 }, /* (47) cmd ::= CREATE USER ids PASS ids */
{ 206, 0 }, { 206, 0 }, /* (48) pps ::= */
{ 206, 2 }, { 206, -2 }, /* (49) pps ::= PPS INTEGER */
{ 207, 0 }, { 207, 0 }, /* (50) tseries ::= */
{ 207, 2 }, { 207, -2 }, /* (51) tseries ::= TSERIES INTEGER */
{ 208, 0 }, { 208, 0 }, /* (52) dbs ::= */
{ 208, 2 }, { 208, -2 }, /* (53) dbs ::= DBS INTEGER */
{ 209, 0 }, { 209, 0 }, /* (54) streams ::= */
{ 209, 2 }, { 209, -2 }, /* (55) streams ::= STREAMS INTEGER */
{ 210, 0 }, { 210, 0 }, /* (56) storage ::= */
{ 210, 2 }, { 210, -2 }, /* (57) storage ::= STORAGE INTEGER */
{ 211, 0 }, { 211, 0 }, /* (58) qtime ::= */
{ 211, 2 }, { 211, -2 }, /* (59) qtime ::= QTIME INTEGER */
{ 212, 0 }, { 212, 0 }, /* (60) users ::= */
{ 212, 2 }, { 212, -2 }, /* (61) users ::= USERS INTEGER */
{ 213, 0 }, { 213, 0 }, /* (62) conns ::= */
{ 213, 2 }, { 213, -2 }, /* (63) conns ::= CONNS INTEGER */
{ 214, 0 }, { 214, 0 }, /* (64) state ::= */
{ 214, 2 }, { 214, -2 }, /* (65) state ::= STATE ids */
{ 203, 9 }, { 203, -9 }, /* (66) acct_optr ::= pps tseries storage streams qtime dbs users conns state */
{ 215, 2 }, { 215, -2 }, /* (67) keep ::= KEEP tagitemlist */
{ 217, 2 }, { 217, -2 }, /* (68) tables ::= TABLES INTEGER */
{ 218, 2 }, { 218, -2 }, /* (69) cache ::= CACHE INTEGER */
{ 219, 2 }, { 219, -2 }, /* (70) replica ::= REPLICA INTEGER */
{ 220, 2 }, { 220, -2 }, /* (71) days ::= DAYS INTEGER */
{ 221, 2 }, { 221, -2 }, /* (72) rows ::= ROWS INTEGER */
{ 222, 2 }, { 222, -2 }, /* (73) ablocks ::= ABLOCKS ID */
{ 223, 2 }, { 223, -2 }, /* (74) tblocks ::= TBLOCKS INTEGER */
{ 224, 2 }, { 224, -2 }, /* (75) ctime ::= CTIME INTEGER */
{ 225, 2 }, { 225, -2 }, /* (76) clog ::= CLOG INTEGER */
{ 226, 2 }, { 226, -2 }, /* (77) comp ::= COMP INTEGER */
{ 227, 2 }, { 227, -2 }, /* (78) prec ::= PRECISION STRING */
{ 205, 0 }, { 205, 0 }, /* (79) db_optr ::= */
{ 205, 2 }, { 205, -2 }, /* (80) db_optr ::= db_optr tables */
{ 205, 2 }, { 205, -2 }, /* (81) db_optr ::= db_optr cache */
{ 205, 2 }, { 205, -2 }, /* (82) db_optr ::= db_optr replica */
{ 205, 2 }, { 205, -2 }, /* (83) db_optr ::= db_optr days */
{ 205, 2 }, { 205, -2 }, /* (84) db_optr ::= db_optr rows */
{ 205, 2 }, { 205, -2 }, /* (85) db_optr ::= db_optr ablocks */
{ 205, 2 }, { 205, -2 }, /* (86) db_optr ::= db_optr tblocks */
{ 205, 2 }, { 205, -2 }, /* (87) db_optr ::= db_optr ctime */
{ 205, 2 }, { 205, -2 }, /* (88) db_optr ::= db_optr clog */
{ 205, 2 }, { 205, -2 }, /* (89) db_optr ::= db_optr comp */
{ 205, 2 }, { 205, -2 }, /* (90) db_optr ::= db_optr prec */
{ 205, 2 }, { 205, -2 }, /* (91) db_optr ::= db_optr keep */
{ 202, 0 }, { 202, 0 }, /* (92) alter_db_optr ::= */
{ 202, 2 }, { 202, -2 }, /* (93) alter_db_optr ::= alter_db_optr replica */
{ 202, 2 }, { 202, -2 }, /* (94) alter_db_optr ::= alter_db_optr tables */
{ 228, 1 }, { 228, -1 }, /* (95) typename ::= ids */
{ 228, 4 }, { 228, -4 }, /* (96) typename ::= ids LP signed RP */
{ 229, 1 }, { 229, -1 }, /* (97) signed ::= INTEGER */
{ 229, 2 }, { 229, -2 }, /* (98) signed ::= PLUS INTEGER */
{ 229, 2 }, { 229, -2 }, /* (99) signed ::= MINUS INTEGER */
{ 197, 6 }, { 197, -6 }, /* (100) cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */
{ 230, 3 }, { 230, -3 }, /* (101) create_table_args ::= LP columnlist RP */
{ 230, 7 }, { 230, -7 }, /* (102) create_table_args ::= LP columnlist RP TAGS LP columnlist RP */
{ 230, 7 }, { 230, -7 }, /* (103) create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */
{ 230, 2 }, { 230, -2 }, /* (104) create_table_args ::= AS select */
{ 231, 3 }, { 231, -3 }, /* (105) columnlist ::= columnlist COMMA column */
{ 231, 1 }, { 231, -1 }, /* (106) columnlist ::= column */
{ 233, 2 }, { 233, -2 }, /* (107) column ::= ids typename */
{ 216, 3 }, { 216, -3 }, /* (108) tagitemlist ::= tagitemlist COMMA tagitem */
{ 216, 1 }, { 216, -1 }, /* (109) tagitemlist ::= tagitem */
{ 234, 1 }, { 234, -1 }, /* (110) tagitem ::= INTEGER */
{ 234, 1 }, { 234, -1 }, /* (111) tagitem ::= FLOAT */
{ 234, 1 }, { 234, -1 }, /* (112) tagitem ::= STRING */
{ 234, 1 }, { 234, -1 }, /* (113) tagitem ::= BOOL */
{ 234, 1 }, { 234, -1 }, /* (114) tagitem ::= NULL */
{ 234, 2 }, { 234, -2 }, /* (115) tagitem ::= MINUS INTEGER */
{ 234, 2 }, { 234, -2 }, /* (116) tagitem ::= MINUS FLOAT */
{ 234, 2 }, { 234, -2 }, /* (117) tagitem ::= PLUS INTEGER */
{ 234, 2 }, { 234, -2 }, /* (118) tagitem ::= PLUS FLOAT */
{ 197, 1 }, { 197, -1 }, /* (119) cmd ::= select */
{ 232, 12 }, { 232, -12 }, /* (120) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
{ 246, 2 }, { 232, -2 }, /* (121) select ::= SELECT selcollist */
{ 246, 0 }, { 246, -2 }, /* (122) sclp ::= selcollist COMMA */
{ 235, 3 }, { 246, 0 }, /* (123) sclp ::= */
{ 235, 2 }, { 235, -3 }, /* (124) selcollist ::= sclp expr as */
{ 248, 2 }, { 235, -2 }, /* (125) selcollist ::= sclp STAR */
{ 248, 1 }, { 248, -2 }, /* (126) as ::= AS ids */
{ 248, 0 }, { 248, -1 }, /* (127) as ::= ids */
{ 236, 2 }, { 248, 0 }, /* (128) as ::= */
{ 249, 2 }, { 236, -2 }, /* (129) from ::= FROM tablelist */
{ 249, 4 }, { 249, -2 }, /* (130) tablelist ::= ids cpxName */
{ 250, 1 }, { 249, -4 }, /* (131) tablelist ::= tablelist COMMA ids cpxName */
{ 238, 4 }, { 250, -1 }, /* (132) tmvar ::= VARIABLE */
{ 238, 0 }, { 238, -4 }, /* (133) interval_opt ::= INTERVAL LP tmvar RP */
{ 239, 0 }, { 238, 0 }, /* (134) interval_opt ::= */
{ 239, 6 }, { 239, 0 }, /* (135) fill_opt ::= */
{ 239, 4 }, { 239, -6 }, /* (136) fill_opt ::= FILL LP ID COMMA tagitemlist RP */
{ 240, 4 }, { 239, -4 }, /* (137) fill_opt ::= FILL LP ID RP */
{ 240, 0 }, { 240, -4 }, /* (138) sliding_opt ::= SLIDING LP tmvar RP */
{ 242, 0 }, { 240, 0 }, /* (139) sliding_opt ::= */
{ 242, 3 }, { 242, 0 }, /* (140) orderby_opt ::= */
{ 251, 4 }, { 242, -3 }, /* (141) orderby_opt ::= ORDER BY sortlist */
{ 251, 2 }, { 251, -4 }, /* (142) sortlist ::= sortlist COMMA item sortorder */
{ 253, 2 }, { 251, -2 }, /* (143) sortlist ::= item sortorder */
{ 254, 1 }, { 253, -2 }, /* (144) item ::= ids cpxName */
{ 254, 1 }, { 254, -1 }, /* (145) sortorder ::= ASC */
{ 254, 0 }, { 254, -1 }, /* (146) sortorder ::= DESC */
{ 241, 0 }, { 254, 0 }, /* (147) sortorder ::= */
{ 241, 3 }, { 241, 0 }, /* (148) groupby_opt ::= */
{ 255, 3 }, { 241, -3 }, /* (149) groupby_opt ::= GROUP BY grouplist */
{ 255, 1 }, { 255, -3 }, /* (150) grouplist ::= grouplist COMMA item */
{ 243, 0 }, { 255, -1 }, /* (151) grouplist ::= item */
{ 243, 2 }, { 243, 0 }, /* (152) having_opt ::= */
{ 245, 0 }, { 243, -2 }, /* (153) having_opt ::= HAVING expr */
{ 245, 2 }, { 245, 0 }, /* (154) limit_opt ::= */
{ 245, 4 }, { 245, -2 }, /* (155) limit_opt ::= LIMIT signed */
{ 245, 4 }, { 245, -4 }, /* (156) limit_opt ::= LIMIT signed OFFSET signed */
{ 244, 0 }, { 245, -4 }, /* (157) limit_opt ::= LIMIT signed COMMA signed */
{ 244, 2 }, { 244, 0 }, /* (158) slimit_opt ::= */
{ 244, 4 }, { 244, -2 }, /* (159) slimit_opt ::= SLIMIT signed */
{ 244, 4 }, { 244, -4 }, /* (160) slimit_opt ::= SLIMIT signed SOFFSET signed */
{ 237, 0 }, { 244, -4 }, /* (161) slimit_opt ::= SLIMIT signed COMMA signed */
{ 237, 2 }, { 237, 0 }, /* (162) where_opt ::= */
{ 247, 3 }, { 237, -2 }, /* (163) where_opt ::= WHERE expr */
{ 247, 1 }, { 247, -3 }, /* (164) expr ::= LP expr RP */
{ 247, 3 }, { 247, -1 }, /* (165) expr ::= ID */
{ 247, 3 }, { 247, -3 }, /* (166) expr ::= ID DOT ID */
{ 247, 1 }, { 247, -3 }, /* (167) expr ::= ID DOT STAR */
{ 247, 2 }, { 247, -1 }, /* (168) expr ::= INTEGER */
{ 247, 2 }, { 247, -2 }, /* (169) expr ::= MINUS INTEGER */
{ 247, 1 }, { 247, -2 }, /* (170) expr ::= PLUS INTEGER */
{ 247, 2 }, { 247, -1 }, /* (171) expr ::= FLOAT */
{ 247, 2 }, { 247, -2 }, /* (172) expr ::= MINUS FLOAT */
{ 247, 1 }, { 247, -2 }, /* (173) expr ::= PLUS FLOAT */
{ 247, 1 }, { 247, -1 }, /* (174) expr ::= STRING */
{ 247, 1 }, { 247, -1 }, /* (175) expr ::= NOW */
{ 247, 1 }, { 247, -1 }, /* (176) expr ::= VARIABLE */
{ 247, 4 }, { 247, -1 }, /* (177) expr ::= BOOL */
{ 247, 4 }, { 247, -4 }, /* (178) expr ::= ID LP exprlist RP */
{ 247, 3 }, { 247, -4 }, /* (179) expr ::= ID LP STAR RP */
{ 247, 3 }, { 247, -3 }, /* (180) expr ::= expr AND expr */
{ 247, 3 }, { 247, -3 }, /* (181) expr ::= expr OR expr */
{ 247, 3 }, { 247, -3 }, /* (182) expr ::= expr LT expr */
{ 247, 3 }, { 247, -3 }, /* (183) expr ::= expr GT expr */
{ 247, 3 }, { 247, -3 }, /* (184) expr ::= expr LE expr */
{ 247, 3 }, { 247, -3 }, /* (185) expr ::= expr GE expr */
{ 247, 3 }, { 247, -3 }, /* (186) expr ::= expr NE expr */
{ 247, 3 }, { 247, -3 }, /* (187) expr ::= expr EQ expr */
{ 247, 3 }, { 247, -3 }, /* (188) expr ::= expr PLUS expr */
{ 247, 3 }, { 247, -3 }, /* (189) expr ::= expr MINUS expr */
{ 247, 3 }, { 247, -3 }, /* (190) expr ::= expr STAR expr */
{ 247, 3 }, { 247, -3 }, /* (191) expr ::= expr SLASH expr */
{ 247, 3 }, { 247, -3 }, /* (192) expr ::= expr REM expr */
{ 247, 5 }, { 247, -3 }, /* (193) expr ::= expr LIKE expr */
{ 256, 3 }, { 247, -5 }, /* (194) expr ::= expr IN LP exprlist RP */
{ 256, 1 }, { 256, -3 }, /* (195) exprlist ::= exprlist COMMA expritem */
{ 257, 1 }, { 256, -1 }, /* (196) exprlist ::= expritem */
{ 257, 0 }, { 257, -1 }, /* (197) expritem ::= expr */
{ 197, 4 }, { 257, 0 }, /* (198) expritem ::= */
{ 258, 4 }, { 197, -4 }, /* (199) cmd ::= INSERT INTO cpxName insert_value_list */
{ 258, 5 }, { 258, -4 }, /* (200) insert_value_list ::= VALUES LP itemlist RP */
{ 259, 3 }, { 258, -5 }, /* (201) insert_value_list ::= insert_value_list VALUES LP itemlist RP */
{ 259, 1 }, { 259, -3 }, /* (202) itemlist ::= itemlist COMMA expr */
{ 197, 3 }, { 259, -1 }, /* (203) itemlist ::= expr */
{ 197, 7 }, { 197, -3 }, /* (204) cmd ::= RESET QUERY CACHE */
{ 197, 7 }, { 197, -7 }, /* (205) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
{ 197, 7 }, { 197, -7 }, /* (206) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
{ 197, 7 }, { 197, -7 }, /* (207) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
{ 197, 8 }, { 197, -7 }, /* (208) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
{ 197, 9 }, { 197, -8 }, /* (209) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
{ 197, 5 }, { 197, -9 }, /* (210) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
{ 197, 7 }, { 197, -5 }, /* (211) cmd ::= KILL CONNECTION IPTOKEN COLON INTEGER */
{ 197, 7 }, { 197, -7 }, /* (212) cmd ::= KILL STREAM IPTOKEN COLON INTEGER COLON INTEGER */
{ 197, -7 }, /* (213) cmd ::= KILL QUERY IPTOKEN COLON INTEGER COLON INTEGER */
}; };
static void yy_accept(yyParser*); /* Forward Declaration */ static void yy_accept(yyParser*); /* Forward Declaration */
...@@ -1563,27 +1861,66 @@ static void yy_accept(yyParser*); /* Forward Declaration */ ...@@ -1563,27 +1861,66 @@ static void yy_accept(yyParser*); /* Forward Declaration */
/* /*
** Perform a reduce action and the shift that must immediately ** Perform a reduce action and the shift that must immediately
** follow the reduce. ** follow the reduce.
**
** The yyLookahead and yyLookaheadToken parameters provide reduce actions
** access to the lookahead token (if any). The yyLookahead will be YYNOCODE
** if the lookahead token has already been consumed. As this procedure is
** only called from one place, optimizing compilers will in-line it, which
** means that the extra parameters have no performance impact.
*/ */
static void yy_reduce( static void yy_reduce(
yyParser *yypParser, /* The parser */ yyParser *yypParser, /* The parser */
int yyruleno /* Number of the rule by which to reduce */ 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 */
){ ){
int yygoto; /* The next state */ int yygoto; /* The next state */
int yyact; /* The next action */ int yyact; /* The next action */
YYMINORTYPE yygotominor; /* The LHS of the rule reduced */
yyStackEntry *yymsp; /* The top of the parser's stack */ yyStackEntry *yymsp; /* The top of the parser's stack */
int yysize; /* Amount to pop the stack */ int yysize; /* Amount to pop the stack */
ParseARG_FETCH; ParseARG_FETCH;
yymsp = &yypParser->yystack[yypParser->yyidx]; (void)yyLookahead;
(void)yyLookaheadToken;
yymsp = yypParser->yytos;
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE && yyruleno>=0 if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
&& yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
yysize = yyRuleInfo[yyruleno].nrhs; yysize = yyRuleInfo[yyruleno].nrhs;
fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt, if( yysize ){
yyRuleName[yyruleno], yymsp[-yysize].stateno); fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n",
yyTracePrompt,
yyruleno, yyRuleName[yyruleno], yymsp[yysize].stateno);
}else{
fprintf(yyTraceFILE, "%sReduce %d [%s].\n",
yyTracePrompt, yyruleno, yyRuleName[yyruleno]);
}
} }
#endif /* NDEBUG */ #endif /* NDEBUG */
yygotominor = yyzerominor;
/* Check that the stack is large enough to grow by a single entry
** if the RHS of the rule is empty. This ensures that there is room
** enough on the stack to push the LHS value */
if( yyRuleInfo[yyruleno].nrhs==0 ){
#ifdef YYTRACKMAXSTACKDEPTH
if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
yypParser->yyhwm++;
assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
}
#endif
#if YYSTACKDEPTH>0
if( yypParser->yytos>=yypParser->yystackEnd ){
yyStackOverflow(yypParser);
return;
}
#else
if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
if( yyGrowStack(yypParser) ){
yyStackOverflow(yypParser);
return;
}
yymsp = yypParser->yytos;
}
#endif
}
switch( yyruleno ){ switch( yyruleno ){
/* Beginning here are the reduction cases. A typical example /* Beginning here are the reduction cases. A typical example
...@@ -1595,6 +1932,7 @@ static void yy_reduce( ...@@ -1595,6 +1932,7 @@ static void yy_reduce(
** break; ** break;
*/ */
/********** Begin reduce actions **********************************************/ /********** Begin reduce actions **********************************************/
YYMINORTYPE yylhsminor;
case 0: /* program ::= cmd */ case 0: /* program ::= cmd */
{} {}
break; break;
...@@ -1637,16 +1975,17 @@ static void yy_reduce( ...@@ -1637,16 +1975,17 @@ static void yy_reduce(
case 13: /* dbPrefix ::= */ case 13: /* dbPrefix ::= */
case 41: /* ifexists ::= */ yytestcase(yyruleno==41); case 41: /* ifexists ::= */ yytestcase(yyruleno==41);
case 43: /* ifnotexists ::= */ yytestcase(yyruleno==43); case 43: /* ifnotexists ::= */ yytestcase(yyruleno==43);
{yygotominor.yy0.n = 0;} {yymsp[1].minor.yy0.n = 0;}
break; break;
case 14: /* dbPrefix ::= ids DOT */ case 14: /* dbPrefix ::= ids DOT */
{yygotominor.yy0 = yymsp[-1].minor.yy0; } {yylhsminor.yy0 = yymsp[-1].minor.yy0; }
yymsp[-1].minor.yy0 = yylhsminor.yy0;
break; break;
case 15: /* cpxName ::= */ case 15: /* cpxName ::= */
{yygotominor.yy0.n = 0; } {yymsp[1].minor.yy0.n = 0; }
break; break;
case 16: /* cpxName ::= DOT ids */ case 16: /* cpxName ::= DOT ids */
{yygotominor.yy0 = yymsp[0].minor.yy0; yygotominor.yy0.n += 1; } {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n += 1; }
break; break;
case 17: /* cmd ::= SHOW dbPrefix TABLES */ case 17: /* cmd ::= SHOW dbPrefix TABLES */
{ {
...@@ -1686,7 +2025,7 @@ static void yy_reduce( ...@@ -1686,7 +2025,7 @@ static void yy_reduce(
case 23: /* cmd ::= DROP DATABASE ifexists ids */ case 23: /* cmd ::= DROP DATABASE ifexists ids */
{ setDCLSQLElems(pInfo, DROP_DATABASE, 2, &yymsp[0].minor.yy0, &yymsp[-1].minor.yy0); } { setDCLSQLElems(pInfo, DROP_DATABASE, 2, &yymsp[0].minor.yy0, &yymsp[-1].minor.yy0); }
break; break;
case 24: /* cmd ::= DROP DNODE IP */ case 24: /* cmd ::= DROP DNODE IPTOKEN */
{ setDCLSQLElems(pInfo, DROP_DNODE, 1, &yymsp[0].minor.yy0); } { setDCLSQLElems(pInfo, DROP_DNODE, 1, &yymsp[0].minor.yy0); }
break; break;
case 25: /* cmd ::= DROP USER ids */ case 25: /* cmd ::= DROP USER ids */
...@@ -1710,10 +2049,10 @@ static void yy_reduce( ...@@ -1710,10 +2049,10 @@ static void yy_reduce(
case 30: /* cmd ::= ALTER USER ids PRIVILEGE ids */ case 30: /* cmd ::= ALTER USER ids PRIVILEGE ids */
{ setDCLSQLElems(pInfo, ALTER_USER_PRIVILEGES, 2, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} { setDCLSQLElems(pInfo, ALTER_USER_PRIVILEGES, 2, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);}
break; break;
case 31: /* cmd ::= ALTER DNODE IP ids */ case 31: /* cmd ::= ALTER DNODE IPTOKEN ids */
{ setDCLSQLElems(pInfo, ALTER_DNODE, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } { setDCLSQLElems(pInfo, ALTER_DNODE, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); }
break; break;
case 32: /* cmd ::= ALTER DNODE IP ids ids */ case 32: /* cmd ::= ALTER DNODE IPTOKEN ids ids */
{ setDCLSQLElems(pInfo, ALTER_DNODE, 3, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } { setDCLSQLElems(pInfo, ALTER_DNODE, 3, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); }
break; break;
case 33: /* cmd ::= ALTER LOCAL ids */ case 33: /* cmd ::= ALTER LOCAL ids */
...@@ -1733,13 +2072,16 @@ static void yy_reduce( ...@@ -1733,13 +2072,16 @@ static void yy_reduce(
break; break;
case 38: /* ids ::= ID */ case 38: /* ids ::= ID */
case 39: /* ids ::= STRING */ yytestcase(yyruleno==39); case 39: /* ids ::= STRING */ yytestcase(yyruleno==39);
{yygotominor.yy0 = yymsp[0].minor.yy0; } {yylhsminor.yy0 = yymsp[0].minor.yy0; }
yymsp[0].minor.yy0 = yylhsminor.yy0;
break; break;
case 40: /* ifexists ::= IF EXISTS */ case 40: /* ifexists ::= IF EXISTS */
case 42: /* ifnotexists ::= IF NOT EXISTS */ yytestcase(yyruleno==42); {yymsp[-1].minor.yy0.n = 1;}
{yygotominor.yy0.n = 1;}
break; break;
case 44: /* cmd ::= CREATE DNODE IP */ case 42: /* ifnotexists ::= IF NOT EXISTS */
{yymsp[-2].minor.yy0.n = 1;}
break;
case 44: /* cmd ::= CREATE DNODE IPTOKEN */
{ setDCLSQLElems(pInfo, CREATE_DNODE, 1, &yymsp[0].minor.yy0);} { setDCLSQLElems(pInfo, CREATE_DNODE, 1, &yymsp[0].minor.yy0);}
break; break;
case 45: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ case 45: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
...@@ -1760,9 +2102,7 @@ static void yy_reduce( ...@@ -1760,9 +2102,7 @@ static void yy_reduce(
case 60: /* users ::= */ yytestcase(yyruleno==60); case 60: /* users ::= */ yytestcase(yyruleno==60);
case 62: /* conns ::= */ yytestcase(yyruleno==62); case 62: /* conns ::= */ yytestcase(yyruleno==62);
case 64: /* state ::= */ yytestcase(yyruleno==64); case 64: /* state ::= */ yytestcase(yyruleno==64);
case 133: /* interval_opt ::= */ yytestcase(yyruleno==133); {yymsp[1].minor.yy0.n = 0; }
case 138: /* sliding_opt ::= */ yytestcase(yyruleno==138);
{yygotominor.yy0.n = 0; }
break; break;
case 49: /* pps ::= PPS INTEGER */ case 49: /* pps ::= PPS INTEGER */
case 51: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==51); case 51: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==51);
...@@ -1773,23 +2113,24 @@ static void yy_reduce( ...@@ -1773,23 +2113,24 @@ static void yy_reduce(
case 61: /* users ::= USERS INTEGER */ yytestcase(yyruleno==61); case 61: /* users ::= USERS INTEGER */ yytestcase(yyruleno==61);
case 63: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==63); case 63: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==63);
case 65: /* state ::= STATE ids */ yytestcase(yyruleno==65); case 65: /* state ::= STATE ids */ yytestcase(yyruleno==65);
{yygotominor.yy0 = yymsp[0].minor.yy0; } {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break; break;
case 66: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ case 66: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */
{ {
yygotominor.yy279.users = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; yylhsminor.yy279.users = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1;
yygotominor.yy279.dbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; yylhsminor.yy279.dbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1;
yygotominor.yy279.tseries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; yylhsminor.yy279.tseries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1;
yygotominor.yy279.streams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; yylhsminor.yy279.streams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1;
yygotominor.yy279.pps = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; yylhsminor.yy279.pps = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1;
yygotominor.yy279.storage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; yylhsminor.yy279.storage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1;
yygotominor.yy279.qtime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; yylhsminor.yy279.qtime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1;
yygotominor.yy279.conns = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; yylhsminor.yy279.conns = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1;
yygotominor.yy279.stat = yymsp[0].minor.yy0; yylhsminor.yy279.stat = yymsp[0].minor.yy0;
} }
yymsp[-8].minor.yy279 = yylhsminor.yy279;
break; break;
case 67: /* keep ::= KEEP tagitemlist */ case 67: /* keep ::= KEEP tagitemlist */
{ yygotominor.yy56 = yymsp[0].minor.yy56; } { yymsp[-1].minor.yy56 = yymsp[0].minor.yy56; }
break; break;
case 68: /* tables ::= TABLES INTEGER */ case 68: /* tables ::= TABLES INTEGER */
case 69: /* cache ::= CACHE INTEGER */ yytestcase(yyruleno==69); case 69: /* cache ::= CACHE INTEGER */ yytestcase(yyruleno==69);
...@@ -1802,65 +2143,84 @@ static void yy_reduce( ...@@ -1802,65 +2143,84 @@ static void yy_reduce(
case 76: /* clog ::= CLOG INTEGER */ yytestcase(yyruleno==76); case 76: /* clog ::= CLOG INTEGER */ yytestcase(yyruleno==76);
case 77: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==77); case 77: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==77);
case 78: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==78); case 78: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==78);
case 79: /* db_optr ::= */ yytestcase(yyruleno==79); { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
{ yygotominor.yy0 = yymsp[0].minor.yy0; } break;
case 79: /* db_optr ::= */
{memset(&yymsp[1].minor.yy398, 0, sizeof(SCreateDBInfo));}
break; break;
case 80: /* db_optr ::= db_optr tables */ case 80: /* db_optr ::= db_optr tables */
case 94: /* alter_db_optr ::= alter_db_optr tables */ yytestcase(yyruleno==94); case 94: /* alter_db_optr ::= alter_db_optr tables */ yytestcase(yyruleno==94);
{ yygotominor.yy398 = yymsp[-1].minor.yy398; yygotominor.yy398.tablesPerVnode = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.tablesPerVnode = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break; break;
case 81: /* db_optr ::= db_optr cache */ case 81: /* db_optr ::= db_optr cache */
{ yygotominor.yy398 = yymsp[-1].minor.yy398; yygotominor.yy398.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break; break;
case 82: /* db_optr ::= db_optr replica */ case 82: /* db_optr ::= db_optr replica */
case 93: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==93); case 93: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==93);
{ yygotominor.yy398 = yymsp[-1].minor.yy398; yygotominor.yy398.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break; break;
case 83: /* db_optr ::= db_optr days */ case 83: /* db_optr ::= db_optr days */
{ yygotominor.yy398 = yymsp[-1].minor.yy398; yygotominor.yy398.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break; break;
case 84: /* db_optr ::= db_optr rows */ case 84: /* db_optr ::= db_optr rows */
{ yygotominor.yy398 = yymsp[-1].minor.yy398; yygotominor.yy398.rowPerFileBlock = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.rowPerFileBlock = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break; break;
case 85: /* db_optr ::= db_optr ablocks */ case 85: /* db_optr ::= db_optr ablocks */
{ yygotominor.yy398 = yymsp[-1].minor.yy398; yygotominor.yy398.numOfAvgCacheBlocks = strtod(yymsp[0].minor.yy0.z, NULL); } { yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.numOfAvgCacheBlocks = strtod(yymsp[0].minor.yy0.z, NULL); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break; break;
case 86: /* db_optr ::= db_optr tblocks */ case 86: /* db_optr ::= db_optr tblocks */
{ yygotominor.yy398 = yymsp[-1].minor.yy398; yygotominor.yy398.numOfBlocksPerTable = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.numOfBlocksPerTable = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break; break;
case 87: /* db_optr ::= db_optr ctime */ case 87: /* db_optr ::= db_optr ctime */
{ yygotominor.yy398 = yymsp[-1].minor.yy398; yygotominor.yy398.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break; break;
case 88: /* db_optr ::= db_optr clog */ case 88: /* db_optr ::= db_optr clog */
{ yygotominor.yy398 = yymsp[-1].minor.yy398; yygotominor.yy398.commitLog = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.commitLog = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break; break;
case 89: /* db_optr ::= db_optr comp */ case 89: /* db_optr ::= db_optr comp */
{ yygotominor.yy398 = yymsp[-1].minor.yy398; yygotominor.yy398.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break; break;
case 90: /* db_optr ::= db_optr prec */ case 90: /* db_optr ::= db_optr prec */
{ yygotominor.yy398 = yymsp[-1].minor.yy398; yygotominor.yy398.precision = yymsp[0].minor.yy0; } { yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.precision = yymsp[0].minor.yy0; }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break; break;
case 91: /* db_optr ::= db_optr keep */ case 91: /* db_optr ::= db_optr keep */
{ yygotominor.yy398 = yymsp[-1].minor.yy398; yygotominor.yy398.keep = yymsp[0].minor.yy56; } { yylhsminor.yy398 = yymsp[-1].minor.yy398; yylhsminor.yy398.keep = yymsp[0].minor.yy56; }
yymsp[-1].minor.yy398 = yylhsminor.yy398;
break; break;
case 92: /* alter_db_optr ::= */ case 92: /* alter_db_optr ::= */
{ memset(&yygotominor.yy398, 0, sizeof(SCreateDBInfo));} { memset(&yymsp[1].minor.yy398, 0, sizeof(SCreateDBInfo));}
break; break;
case 95: /* typename ::= ids */ case 95: /* typename ::= ids */
{ tSQLSetColumnType (&yygotominor.yy223, &yymsp[0].minor.yy0); } { tSQLSetColumnType (&yylhsminor.yy223, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy223 = yylhsminor.yy223;
break; break;
case 96: /* typename ::= ids LP signed RP */ case 96: /* typename ::= ids LP signed RP */
{ {
yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy389; // negative value of name length yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy389; // negative value of name length
tSQLSetColumnType(&yygotominor.yy223, &yymsp[-3].minor.yy0); tSQLSetColumnType(&yylhsminor.yy223, &yymsp[-3].minor.yy0);
} }
yymsp[-3].minor.yy223 = yylhsminor.yy223;
break; break;
case 97: /* signed ::= INTEGER */ case 97: /* signed ::= INTEGER */
case 98: /* signed ::= PLUS INTEGER */ yytestcase(yyruleno==98); { yylhsminor.yy389 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
{ yygotominor.yy389 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[0].minor.yy389 = yylhsminor.yy389;
break;
case 98: /* signed ::= PLUS INTEGER */
{ yymsp[-1].minor.yy389 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break; break;
case 99: /* signed ::= MINUS INTEGER */ case 99: /* signed ::= MINUS INTEGER */
{ yygotominor.yy389 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} { yymsp[-1].minor.yy389 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);}
break; break;
case 100: /* cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */ case 100: /* cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */
{ {
...@@ -1870,54 +2230,61 @@ static void yy_reduce( ...@@ -1870,54 +2230,61 @@ static void yy_reduce(
break; break;
case 101: /* create_table_args ::= LP columnlist RP */ case 101: /* create_table_args ::= LP columnlist RP */
{ {
yygotominor.yy158 = tSetCreateSQLElems(yymsp[-1].minor.yy471, NULL, NULL, NULL, NULL, TSQL_CREATE_NORMAL_METER); yymsp[-2].minor.yy158 = tSetCreateSQLElems(yymsp[-1].minor.yy471, NULL, NULL, NULL, NULL, TSQL_CREATE_NORMAL_METER);
setSQLInfo(pInfo, yygotominor.yy158, NULL, TSQL_CREATE_NORMAL_METER); setSQLInfo(pInfo, yymsp[-2].minor.yy158, NULL, TSQL_CREATE_NORMAL_METER);
} }
break; break;
case 102: /* create_table_args ::= LP columnlist RP TAGS LP columnlist RP */ case 102: /* create_table_args ::= LP columnlist RP TAGS LP columnlist RP */
{ {
yygotominor.yy158 = tSetCreateSQLElems(yymsp[-5].minor.yy471, yymsp[-1].minor.yy471, NULL, NULL, NULL, TSQL_CREATE_NORMAL_METRIC); yymsp[-6].minor.yy158 = tSetCreateSQLElems(yymsp[-5].minor.yy471, yymsp[-1].minor.yy471, NULL, NULL, NULL, TSQL_CREATE_NORMAL_METRIC);
setSQLInfo(pInfo, yygotominor.yy158, NULL, TSQL_CREATE_NORMAL_METRIC); setSQLInfo(pInfo, yymsp[-6].minor.yy158, NULL, TSQL_CREATE_NORMAL_METRIC);
} }
break; break;
case 103: /* create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */ case 103: /* create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */
{ {
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
yygotominor.yy158 = tSetCreateSQLElems(NULL, NULL, &yymsp[-5].minor.yy0, yymsp[-1].minor.yy56, NULL, TSQL_CREATE_METER_FROM_METRIC); yymsp[-6].minor.yy158 = tSetCreateSQLElems(NULL, NULL, &yymsp[-5].minor.yy0, yymsp[-1].minor.yy56, NULL, TSQL_CREATE_METER_FROM_METRIC);
setSQLInfo(pInfo, yygotominor.yy158, NULL, TSQL_CREATE_METER_FROM_METRIC); setSQLInfo(pInfo, yymsp[-6].minor.yy158, NULL, TSQL_CREATE_METER_FROM_METRIC);
} }
break; break;
case 104: /* create_table_args ::= AS select */ case 104: /* create_table_args ::= AS select */
{ {
yygotominor.yy158 = tSetCreateSQLElems(NULL, NULL, NULL, NULL, yymsp[0].minor.yy24, TSQL_CREATE_STREAM); yymsp[-1].minor.yy158 = tSetCreateSQLElems(NULL, NULL, NULL, NULL, yymsp[0].minor.yy24, TSQL_CREATE_STREAM);
setSQLInfo(pInfo, yygotominor.yy158, NULL, TSQL_CREATE_STREAM); setSQLInfo(pInfo, yymsp[-1].minor.yy158, NULL, TSQL_CREATE_STREAM);
} }
break; break;
case 105: /* columnlist ::= columnlist COMMA column */ case 105: /* columnlist ::= columnlist COMMA column */
{yygotominor.yy471 = tFieldListAppend(yymsp[-2].minor.yy471, &yymsp[0].minor.yy223); } {yylhsminor.yy471 = tFieldListAppend(yymsp[-2].minor.yy471, &yymsp[0].minor.yy223); }
yymsp[-2].minor.yy471 = yylhsminor.yy471;
break; break;
case 106: /* columnlist ::= column */ case 106: /* columnlist ::= column */
{yygotominor.yy471 = tFieldListAppend(NULL, &yymsp[0].minor.yy223);} {yylhsminor.yy471 = tFieldListAppend(NULL, &yymsp[0].minor.yy223);}
yymsp[0].minor.yy471 = yylhsminor.yy471;
break; break;
case 107: /* column ::= ids typename */ case 107: /* column ::= ids typename */
{ {
tSQLSetColumnInfo(&yygotominor.yy223, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy223); tSQLSetColumnInfo(&yylhsminor.yy223, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy223);
} }
yymsp[-1].minor.yy223 = yylhsminor.yy223;
break; break;
case 108: /* tagitemlist ::= tagitemlist COMMA tagitem */ case 108: /* tagitemlist ::= tagitemlist COMMA tagitem */
{ yygotominor.yy56 = tVariantListAppend(yymsp[-2].minor.yy56, &yymsp[0].minor.yy186, -1); } { yylhsminor.yy56 = tVariantListAppend(yymsp[-2].minor.yy56, &yymsp[0].minor.yy186, -1); }
yymsp[-2].minor.yy56 = yylhsminor.yy56;
break; break;
case 109: /* tagitemlist ::= tagitem */ case 109: /* tagitemlist ::= tagitem */
{ yygotominor.yy56 = tVariantListAppend(NULL, &yymsp[0].minor.yy186, -1); } { yylhsminor.yy56 = tVariantListAppend(NULL, &yymsp[0].minor.yy186, -1); }
yymsp[0].minor.yy56 = yylhsminor.yy56;
break; break;
case 110: /* tagitem ::= INTEGER */ case 110: /* tagitem ::= INTEGER */
case 111: /* tagitem ::= FLOAT */ yytestcase(yyruleno==111); case 111: /* tagitem ::= FLOAT */ yytestcase(yyruleno==111);
case 112: /* tagitem ::= STRING */ yytestcase(yyruleno==112); case 112: /* tagitem ::= STRING */ yytestcase(yyruleno==112);
case 113: /* tagitem ::= BOOL */ yytestcase(yyruleno==113); case 113: /* tagitem ::= BOOL */ yytestcase(yyruleno==113);
{toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yygotominor.yy186, &yymsp[0].minor.yy0); } {toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy186, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy186 = yylhsminor.yy186;
break; break;
case 114: /* tagitem ::= NULL */ case 114: /* tagitem ::= NULL */
{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yygotominor.yy186, &yymsp[0].minor.yy0); } { yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy186, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy186 = yylhsminor.yy186;
break; break;
case 115: /* tagitem ::= MINUS INTEGER */ case 115: /* tagitem ::= MINUS INTEGER */
case 116: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==116); case 116: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==116);
...@@ -1927,8 +2294,9 @@ static void yy_reduce( ...@@ -1927,8 +2294,9 @@ static void yy_reduce(
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type;
toTSDBType(yymsp[-1].minor.yy0.type); toTSDBType(yymsp[-1].minor.yy0.type);
tVariantCreate(&yygotominor.yy186, &yymsp[-1].minor.yy0); tVariantCreate(&yylhsminor.yy186, &yymsp[-1].minor.yy0);
} }
yymsp[-1].minor.yy186 = yylhsminor.yy186;
break; break;
case 119: /* cmd ::= select */ case 119: /* cmd ::= select */
{ {
...@@ -1937,260 +2305,321 @@ static void yy_reduce( ...@@ -1937,260 +2305,321 @@ static void yy_reduce(
break; break;
case 120: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ case 120: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
{ {
yygotominor.yy24 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy498, yymsp[-9].minor.yy56, yymsp[-8].minor.yy90, yymsp[-4].minor.yy56, yymsp[-3].minor.yy56, &yymsp[-7].minor.yy0, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy56, &yymsp[0].minor.yy294, &yymsp[-1].minor.yy294); yylhsminor.yy24 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy498, yymsp[-9].minor.yy56, yymsp[-8].minor.yy90, yymsp[-4].minor.yy56, yymsp[-3].minor.yy56, &yymsp[-7].minor.yy0, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy56, &yymsp[0].minor.yy294, &yymsp[-1].minor.yy294);
}
yymsp[-11].minor.yy24 = yylhsminor.yy24;
break;
case 121: /* select ::= SELECT selcollist */
{
yylhsminor.yy24 = tSetQuerySQLElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy498, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
} }
yymsp[-1].minor.yy24 = yylhsminor.yy24;
break; break;
case 121: /* sclp ::= selcollist COMMA */ case 122: /* sclp ::= selcollist COMMA */
{yygotominor.yy498 = yymsp[-1].minor.yy498;} {yylhsminor.yy498 = yymsp[-1].minor.yy498;}
yymsp[-1].minor.yy498 = yylhsminor.yy498;
break; break;
case 122: /* sclp ::= */ case 123: /* sclp ::= */
{yygotominor.yy498 = 0;} {yymsp[1].minor.yy498 = 0;}
break; break;
case 123: /* selcollist ::= sclp expr as */ case 124: /* selcollist ::= sclp expr as */
{ {
yygotominor.yy498 = tSQLExprListAppend(yymsp[-2].minor.yy498, yymsp[-1].minor.yy90, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); yylhsminor.yy498 = tSQLExprListAppend(yymsp[-2].minor.yy498, yymsp[-1].minor.yy90, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
} }
yymsp[-2].minor.yy498 = yylhsminor.yy498;
break; break;
case 124: /* selcollist ::= sclp STAR */ case 125: /* selcollist ::= sclp STAR */
{ {
tSQLExpr *pNode = tSQLExprIdValueCreate(NULL, TK_ALL); tSQLExpr *pNode = tSQLExprIdValueCreate(NULL, TK_ALL);
yygotominor.yy498 = tSQLExprListAppend(yymsp[-1].minor.yy498, pNode, 0); yylhsminor.yy498 = tSQLExprListAppend(yymsp[-1].minor.yy498, pNode, 0);
} }
yymsp[-1].minor.yy498 = yylhsminor.yy498;
break;
case 126: /* as ::= AS ids */
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break;
case 127: /* as ::= ids */
{ yylhsminor.yy0 = yymsp[0].minor.yy0; }
yymsp[0].minor.yy0 = yylhsminor.yy0;
break; break;
case 125: /* as ::= AS ids */ case 128: /* as ::= */
case 126: /* as ::= ids */ yytestcase(yyruleno==126); { yymsp[1].minor.yy0.n = 0; }
{ yygotominor.yy0 = yymsp[0].minor.yy0; }
break; break;
case 127: /* as ::= */ case 129: /* from ::= FROM tablelist */
{ yygotominor.yy0.n = 0; } {yymsp[-1].minor.yy56 = yymsp[0].minor.yy56;}
break; break;
case 128: /* from ::= FROM tablelist */ case 130: /* tablelist ::= ids cpxName */
case 140: /* orderby_opt ::= ORDER BY sortlist */ yytestcase(yyruleno==140); { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yylhsminor.yy56 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);}
case 148: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==148); yymsp[-1].minor.yy56 = yylhsminor.yy56;
{yygotominor.yy56 = yymsp[0].minor.yy56;}
break; break;
case 129: /* tablelist ::= ids cpxName */ case 131: /* tablelist ::= tablelist COMMA ids cpxName */
{ toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yygotominor.yy56 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);} { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yylhsminor.yy56 = tVariantListAppendToken(yymsp[-3].minor.yy56, &yymsp[-1].minor.yy0, -1); }
yymsp[-3].minor.yy56 = yylhsminor.yy56;
break; break;
case 130: /* tablelist ::= tablelist COMMA ids cpxName */ case 132: /* tmvar ::= VARIABLE */
{ toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yygotominor.yy56 = tVariantListAppendToken(yymsp[-3].minor.yy56, &yymsp[-1].minor.yy0, -1); } {yylhsminor.yy0 = yymsp[0].minor.yy0;}
yymsp[0].minor.yy0 = yylhsminor.yy0;
break; break;
case 131: /* tmvar ::= VARIABLE */ case 133: /* interval_opt ::= INTERVAL LP tmvar RP */
{yygotominor.yy0 = yymsp[0].minor.yy0;} case 138: /* sliding_opt ::= SLIDING LP tmvar RP */ yytestcase(yyruleno==138);
{yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; }
break; break;
case 132: /* interval_opt ::= INTERVAL LP tmvar RP */ case 134: /* interval_opt ::= */
case 137: /* sliding_opt ::= SLIDING LP tmvar RP */ yytestcase(yyruleno==137); case 139: /* sliding_opt ::= */ yytestcase(yyruleno==139);
{yygotominor.yy0 = yymsp[-1].minor.yy0; } {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; }
break; break;
case 134: /* fill_opt ::= */ case 135: /* fill_opt ::= */
{yygotominor.yy56 = 0; } {yymsp[1].minor.yy56 = 0; }
break; break;
case 135: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ case 136: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */
{ {
tVariant A = {0}; tVariant A = {0};
toTSDBType(yymsp[-3].minor.yy0.type); toTSDBType(yymsp[-3].minor.yy0.type);
tVariantCreate(&A, &yymsp[-3].minor.yy0); tVariantCreate(&A, &yymsp[-3].minor.yy0);
tVariantListInsert(yymsp[-1].minor.yy56, &A, -1, 0); tVariantListInsert(yymsp[-1].minor.yy56, &A, -1, 0);
yygotominor.yy56 = yymsp[-1].minor.yy56; yymsp[-5].minor.yy56 = yymsp[-1].minor.yy56;
} }
break; break;
case 136: /* fill_opt ::= FILL LP ID RP */ case 137: /* fill_opt ::= FILL LP ID RP */
{ {
toTSDBType(yymsp[-1].minor.yy0.type); toTSDBType(yymsp[-1].minor.yy0.type);
yygotominor.yy56 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); yymsp[-3].minor.yy56 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
} }
break; break;
case 139: /* orderby_opt ::= */ case 140: /* orderby_opt ::= */
case 147: /* groupby_opt ::= */ yytestcase(yyruleno==147); case 148: /* groupby_opt ::= */ yytestcase(yyruleno==148);
{yygotominor.yy56 = 0;} {yymsp[1].minor.yy56 = 0;}
break; break;
case 141: /* sortlist ::= sortlist COMMA item sortorder */ case 141: /* orderby_opt ::= ORDER BY sortlist */
case 149: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==149);
{yymsp[-2].minor.yy56 = yymsp[0].minor.yy56;}
break;
case 142: /* sortlist ::= sortlist COMMA item sortorder */
{ {
yygotominor.yy56 = tVariantListAppend(yymsp[-3].minor.yy56, &yymsp[-1].minor.yy186, yymsp[0].minor.yy332); yylhsminor.yy56 = tVariantListAppend(yymsp[-3].minor.yy56, &yymsp[-1].minor.yy186, yymsp[0].minor.yy332);
} }
yymsp[-3].minor.yy56 = yylhsminor.yy56;
break; break;
case 142: /* sortlist ::= item sortorder */ case 143: /* sortlist ::= item sortorder */
{ {
yygotominor.yy56 = tVariantListAppend(NULL, &yymsp[-1].minor.yy186, yymsp[0].minor.yy332); yylhsminor.yy56 = tVariantListAppend(NULL, &yymsp[-1].minor.yy186, yymsp[0].minor.yy332);
} }
yymsp[-1].minor.yy56 = yylhsminor.yy56;
break; break;
case 143: /* item ::= ids cpxName */ case 144: /* item ::= ids cpxName */
{ {
toTSDBType(yymsp[-1].minor.yy0.type); toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
tVariantCreate(&yygotominor.yy186, &yymsp[-1].minor.yy0); tVariantCreate(&yylhsminor.yy186, &yymsp[-1].minor.yy0);
} }
yymsp[-1].minor.yy186 = yylhsminor.yy186;
break; break;
case 144: /* sortorder ::= ASC */ case 145: /* sortorder ::= ASC */
{yygotominor.yy332 = TSQL_SO_ASC; } {yymsp[0].minor.yy332 = TSQL_SO_ASC; }
break; break;
case 145: /* sortorder ::= DESC */ case 146: /* sortorder ::= DESC */
{yygotominor.yy332 = TSQL_SO_DESC;} {yymsp[0].minor.yy332 = TSQL_SO_DESC;}
break; break;
case 146: /* sortorder ::= */ case 147: /* sortorder ::= */
{yygotominor.yy332 = TSQL_SO_ASC;} {yymsp[1].minor.yy332 = TSQL_SO_ASC;}
break; break;
case 149: /* grouplist ::= grouplist COMMA item */ case 150: /* grouplist ::= grouplist COMMA item */
{ {
yygotominor.yy56 = tVariantListAppend(yymsp[-2].minor.yy56, &yymsp[0].minor.yy186, -1); yylhsminor.yy56 = tVariantListAppend(yymsp[-2].minor.yy56, &yymsp[0].minor.yy186, -1);
} }
yymsp[-2].minor.yy56 = yylhsminor.yy56;
break; break;
case 150: /* grouplist ::= item */ case 151: /* grouplist ::= item */
{ {
yygotominor.yy56 = tVariantListAppend(NULL, &yymsp[0].minor.yy186, -1); yylhsminor.yy56 = tVariantListAppend(NULL, &yymsp[0].minor.yy186, -1);
} }
yymsp[0].minor.yy56 = yylhsminor.yy56;
break; break;
case 151: /* having_opt ::= */ case 152: /* having_opt ::= */
case 161: /* where_opt ::= */ yytestcase(yyruleno==161); case 162: /* where_opt ::= */ yytestcase(yyruleno==162);
case 197: /* expritem ::= */ yytestcase(yyruleno==197); case 198: /* expritem ::= */ yytestcase(yyruleno==198);
{yygotominor.yy90 = 0;} {yymsp[1].minor.yy90 = 0;}
break; break;
case 152: /* having_opt ::= HAVING expr */ case 153: /* having_opt ::= HAVING expr */
case 162: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==162); case 163: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==163);
case 196: /* expritem ::= expr */ yytestcase(yyruleno==196); {yymsp[-1].minor.yy90 = yymsp[0].minor.yy90;}
{yygotominor.yy90 = yymsp[0].minor.yy90;}
break; break;
case 153: /* limit_opt ::= */ case 154: /* limit_opt ::= */
case 157: /* slimit_opt ::= */ yytestcase(yyruleno==157); case 158: /* slimit_opt ::= */ yytestcase(yyruleno==158);
{yygotominor.yy294.limit = -1; yygotominor.yy294.offset = 0;} {yymsp[1].minor.yy294.limit = -1; yymsp[1].minor.yy294.offset = 0;}
break; break;
case 154: /* limit_opt ::= LIMIT signed */ case 155: /* limit_opt ::= LIMIT signed */
case 158: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==158); case 159: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==159);
{yygotominor.yy294.limit = yymsp[0].minor.yy389; yygotominor.yy294.offset = 0;} {yymsp[-1].minor.yy294.limit = yymsp[0].minor.yy389; yymsp[-1].minor.yy294.offset = 0;}
break; break;
case 155: /* limit_opt ::= LIMIT signed OFFSET signed */ case 156: /* limit_opt ::= LIMIT signed OFFSET signed */
case 159: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==159); case 160: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==160);
{yygotominor.yy294.limit = yymsp[-2].minor.yy389; yygotominor.yy294.offset = yymsp[0].minor.yy389;} {yymsp[-3].minor.yy294.limit = yymsp[-2].minor.yy389; yymsp[-3].minor.yy294.offset = yymsp[0].minor.yy389;}
break; break;
case 156: /* limit_opt ::= LIMIT signed COMMA signed */ case 157: /* limit_opt ::= LIMIT signed COMMA signed */
case 160: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==160); case 161: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==161);
{yygotominor.yy294.limit = yymsp[0].minor.yy389; yygotominor.yy294.offset = yymsp[-2].minor.yy389;} {yymsp[-3].minor.yy294.limit = yymsp[0].minor.yy389; yymsp[-3].minor.yy294.offset = yymsp[-2].minor.yy389;}
break; break;
case 163: /* expr ::= LP expr RP */ case 164: /* expr ::= LP expr RP */
{yygotominor.yy90 = yymsp[-1].minor.yy90; } {yymsp[-2].minor.yy90 = yymsp[-1].minor.yy90; }
break; break;
case 164: /* expr ::= ID */ case 165: /* expr ::= ID */
{yygotominor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);} {yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);}
yymsp[0].minor.yy90 = yylhsminor.yy90;
break; break;
case 165: /* expr ::= ID DOT ID */ case 166: /* expr ::= ID DOT ID */
{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yygotominor.yy90 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);} {yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 166: /* expr ::= ID DOT STAR */ case 167: /* expr ::= ID DOT STAR */
{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yygotominor.yy90 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);} {yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 167: /* expr ::= INTEGER */ case 168: /* expr ::= INTEGER */
{yygotominor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);} {yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);}
yymsp[0].minor.yy90 = yylhsminor.yy90;
break; break;
case 168: /* expr ::= MINUS INTEGER */ case 169: /* expr ::= MINUS INTEGER */
case 169: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==169); case 170: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==170);
{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yygotominor.yy90 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);} {yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);}
yymsp[-1].minor.yy90 = yylhsminor.yy90;
break; break;
case 170: /* expr ::= FLOAT */ case 171: /* expr ::= FLOAT */
{yygotominor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);} {yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);}
yymsp[0].minor.yy90 = yylhsminor.yy90;
break; break;
case 171: /* expr ::= MINUS FLOAT */ case 172: /* expr ::= MINUS FLOAT */
case 172: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==172); case 173: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==173);
{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yygotominor.yy90 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);} {yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);}
yymsp[-1].minor.yy90 = yylhsminor.yy90;
break; break;
case 173: /* expr ::= STRING */ case 174: /* expr ::= STRING */
{yygotominor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);} {yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);}
yymsp[0].minor.yy90 = yylhsminor.yy90;
break; break;
case 174: /* expr ::= NOW */ case 175: /* expr ::= NOW */
{yygotominor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); } {yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); }
yymsp[0].minor.yy90 = yylhsminor.yy90;
break; break;
case 175: /* expr ::= VARIABLE */ case 176: /* expr ::= VARIABLE */
{yygotominor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);} {yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);}
yymsp[0].minor.yy90 = yylhsminor.yy90;
break; break;
case 176: /* expr ::= BOOL */ case 177: /* expr ::= BOOL */
{yygotominor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);} {yylhsminor.yy90 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);}
yymsp[0].minor.yy90 = yylhsminor.yy90;
break; break;
case 177: /* expr ::= ID LP exprlist RP */ case 178: /* expr ::= ID LP exprlist RP */
{ {
yygotominor.yy90 = tSQLExprCreateFunction(yymsp[-1].minor.yy498, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); yylhsminor.yy90 = tSQLExprCreateFunction(yymsp[-1].minor.yy498, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type);
} }
yymsp[-3].minor.yy90 = yylhsminor.yy90;
break; break;
case 178: /* expr ::= ID LP STAR RP */ case 179: /* expr ::= ID LP STAR RP */
{ {
yygotominor.yy90 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); yylhsminor.yy90 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type);
} }
yymsp[-3].minor.yy90 = yylhsminor.yy90;
break;
case 180: /* expr ::= expr AND expr */
{yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_AND);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 179: /* expr ::= expr AND expr */ case 181: /* expr ::= expr OR expr */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_AND);} {yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_OR); }
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 180: /* expr ::= expr OR expr */ case 182: /* expr ::= expr LT expr */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_OR); } {yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_LT);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 181: /* expr ::= expr LT expr */ case 183: /* expr ::= expr GT expr */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_LT);} {yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_GT);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 182: /* expr ::= expr GT expr */ case 184: /* expr ::= expr LE expr */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_GT);} {yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_LE);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 183: /* expr ::= expr LE expr */ case 185: /* expr ::= expr GE expr */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_LE);} {yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_GE);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 184: /* expr ::= expr GE expr */ case 186: /* expr ::= expr NE expr */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_GE);} {yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_NE);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 185: /* expr ::= expr NE expr */ case 187: /* expr ::= expr EQ expr */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_NE);} {yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_EQ);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 186: /* expr ::= expr EQ expr */ case 188: /* expr ::= expr PLUS expr */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_EQ);} {yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_PLUS); }
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 187: /* expr ::= expr PLUS expr */ case 189: /* expr ::= expr MINUS expr */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_PLUS); } {yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_MINUS); }
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 188: /* expr ::= expr MINUS expr */ case 190: /* expr ::= expr STAR expr */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_MINUS); } {yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_STAR); }
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 189: /* expr ::= expr STAR expr */ case 191: /* expr ::= expr SLASH expr */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_STAR); } {yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_DIVIDE);}
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 190: /* expr ::= expr SLASH expr */ case 192: /* expr ::= expr REM expr */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_DIVIDE);} {yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_REM); }
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 191: /* expr ::= expr REM expr */ case 193: /* expr ::= expr LIKE expr */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_REM); } {yylhsminor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_LIKE); }
yymsp[-2].minor.yy90 = yylhsminor.yy90;
break; break;
case 192: /* expr ::= expr LIKE expr */ case 194: /* expr ::= expr IN LP exprlist RP */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-2].minor.yy90, yymsp[0].minor.yy90, TK_LIKE); } {yylhsminor.yy90 = tSQLExprCreate(yymsp[-4].minor.yy90, (tSQLExpr*)yymsp[-1].minor.yy498, TK_IN); }
yymsp[-4].minor.yy90 = yylhsminor.yy90;
break; break;
case 193: /* expr ::= expr IN LP exprlist RP */ case 195: /* exprlist ::= exprlist COMMA expritem */
{yygotominor.yy90 = tSQLExprCreate(yymsp[-4].minor.yy90, (tSQLExpr*)yymsp[-1].minor.yy498, TK_IN); } case 202: /* itemlist ::= itemlist COMMA expr */ yytestcase(yyruleno==202);
{yylhsminor.yy498 = tSQLExprListAppend(yymsp[-2].minor.yy498,yymsp[0].minor.yy90,0);}
yymsp[-2].minor.yy498 = yylhsminor.yy498;
break; break;
case 194: /* exprlist ::= exprlist COMMA expritem */ case 196: /* exprlist ::= expritem */
case 201: /* itemlist ::= itemlist COMMA expr */ yytestcase(yyruleno==201); case 203: /* itemlist ::= expr */ yytestcase(yyruleno==203);
{yygotominor.yy498 = tSQLExprListAppend(yymsp[-2].minor.yy498,yymsp[0].minor.yy90,0);} {yylhsminor.yy498 = tSQLExprListAppend(0,yymsp[0].minor.yy90,0);}
yymsp[0].minor.yy498 = yylhsminor.yy498;
break; break;
case 195: /* exprlist ::= expritem */ case 197: /* expritem ::= expr */
case 202: /* itemlist ::= expr */ yytestcase(yyruleno==202); {yylhsminor.yy90 = yymsp[0].minor.yy90;}
{yygotominor.yy498 = tSQLExprListAppend(0,yymsp[0].minor.yy90,0);} yymsp[0].minor.yy90 = yylhsminor.yy90;
break; break;
case 198: /* cmd ::= INSERT INTO cpxName insert_value_list */ case 199: /* cmd ::= INSERT INTO cpxName insert_value_list */
{ {
tSetInsertSQLElems(pInfo, &yymsp[-1].minor.yy0, yymsp[0].minor.yy74); tSetInsertSQLElems(pInfo, &yymsp[-1].minor.yy0, yymsp[0].minor.yy74);
} }
break; break;
case 199: /* insert_value_list ::= VALUES LP itemlist RP */ case 200: /* insert_value_list ::= VALUES LP itemlist RP */
{yygotominor.yy74 = tSQLListListAppend(NULL, yymsp[-1].minor.yy498);} {yymsp[-3].minor.yy74 = tSQLListListAppend(NULL, yymsp[-1].minor.yy498);}
break; break;
case 200: /* insert_value_list ::= insert_value_list VALUES LP itemlist RP */ case 201: /* insert_value_list ::= insert_value_list VALUES LP itemlist RP */
{yygotominor.yy74 = tSQLListListAppend(yymsp[-4].minor.yy74, yymsp[-1].minor.yy498);} {yylhsminor.yy74 = tSQLListListAppend(yymsp[-4].minor.yy74, yymsp[-1].minor.yy498);}
yymsp[-4].minor.yy74 = yylhsminor.yy74;
break; break;
case 203: /* cmd ::= RESET QUERY CACHE */ case 204: /* cmd ::= RESET QUERY CACHE */
{ setDCLSQLElems(pInfo, RESET_QUERY_CACHE, 0);} { setDCLSQLElems(pInfo, RESET_QUERY_CACHE, 0);}
break; break;
case 204: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ case 205: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy471, NULL, ALTER_TABLE_ADD_COLUMN); SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy471, NULL, ALTER_TABLE_ADD_COLUMN);
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_ADD_COLUMN); setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_ADD_COLUMN);
} }
break; break;
case 205: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ case 206: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
...@@ -2201,14 +2630,14 @@ static void yy_reduce( ...@@ -2201,14 +2630,14 @@ static void yy_reduce(
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_DROP_COLUMN); setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_DROP_COLUMN);
} }
break; break;
case 206: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ case 207: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy471, NULL, ALTER_TABLE_TAGS_ADD); SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy471, NULL, ALTER_TABLE_TAGS_ADD);
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_ADD); setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_ADD);
} }
break; break;
case 207: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ case 208: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
...@@ -2219,7 +2648,7 @@ static void yy_reduce( ...@@ -2219,7 +2648,7 @@ static void yy_reduce(
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_DROP); setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_DROP);
} }
break; break;
case 208: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ case 209: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
{ {
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
...@@ -2233,7 +2662,7 @@ static void yy_reduce( ...@@ -2233,7 +2662,7 @@ static void yy_reduce(
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_CHG); setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_CHG);
} }
break; break;
case 209: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ case 210: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
{ {
yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n;
...@@ -2245,44 +2674,36 @@ static void yy_reduce( ...@@ -2245,44 +2674,36 @@ static void yy_reduce(
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_SET); setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_SET);
} }
break; break;
case 210: /* cmd ::= KILL CONNECTION IP COLON INTEGER */ case 211: /* cmd ::= KILL CONNECTION IPTOKEN COLON INTEGER */
{yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setDCLSQLElems(pInfo, KILL_CONNECTION, 1, &yymsp[-2].minor.yy0);} {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setDCLSQLElems(pInfo, KILL_CONNECTION, 1, &yymsp[-2].minor.yy0);}
break; break;
case 211: /* cmd ::= KILL STREAM IP COLON INTEGER COLON INTEGER */ case 212: /* cmd ::= KILL STREAM IPTOKEN COLON INTEGER COLON INTEGER */
{yymsp[-4].minor.yy0.n += (yymsp[-3].minor.yy0.n + yymsp[-2].minor.yy0.n + yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setDCLSQLElems(pInfo, KILL_STREAM, 1, &yymsp[-4].minor.yy0);} {yymsp[-4].minor.yy0.n += (yymsp[-3].minor.yy0.n + yymsp[-2].minor.yy0.n + yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setDCLSQLElems(pInfo, KILL_STREAM, 1, &yymsp[-4].minor.yy0);}
break; break;
case 212: /* cmd ::= KILL QUERY IP COLON INTEGER COLON INTEGER */ case 213: /* cmd ::= KILL QUERY IPTOKEN COLON INTEGER COLON INTEGER */
{yymsp[-4].minor.yy0.n += (yymsp[-3].minor.yy0.n + yymsp[-2].minor.yy0.n + yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setDCLSQLElems(pInfo, KILL_QUERY, 1, &yymsp[-4].minor.yy0);} {yymsp[-4].minor.yy0.n += (yymsp[-3].minor.yy0.n + yymsp[-2].minor.yy0.n + yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setDCLSQLElems(pInfo, KILL_QUERY, 1, &yymsp[-4].minor.yy0);}
break; break;
default: default:
break; break;
/********** End reduce actions ************************************************/ /********** End reduce actions ************************************************/
}; };
assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) ); assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
yygoto = yyRuleInfo[yyruleno].lhs; yygoto = yyRuleInfo[yyruleno].lhs;
yysize = yyRuleInfo[yyruleno].nrhs; yysize = yyRuleInfo[yyruleno].nrhs;
yypParser->yyidx -= yysize; yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
if( yyact <= YY_MAX_SHIFTREDUCE ){ /* There are no SHIFTREDUCE actions on nonterminals because the table
if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; ** generator has simplified them to pure REDUCE actions. */
/* If the reduce action popped at least assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );
** one element off the stack, then we can push the new element back
** onto the stack here, and skip the stack overflow test in yy_shift(). /* It is not possible for a REDUCE to be followed by an error */
** That gives a significant speed improvement. */ assert( yyact!=YY_ERROR_ACTION );
if( yysize ){
yypParser->yyidx++; yymsp += yysize+1;
yymsp -= yysize-1; yypParser->yytos = yymsp;
yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->stateno = (YYACTIONTYPE)yyact;
yymsp->major = (YYCODETYPE)yygoto; yymsp->major = (YYCODETYPE)yygoto;
yymsp->minor = yygotominor; yyTraceShift(yypParser, yyact, "... then shift");
yyTraceShift(yypParser, yyact);
}else{
yy_shift(yypParser,yyact,yygoto,&yygotominor);
}
}else{
assert( yyact == YY_ACCEPT_ACTION );
yy_accept(yypParser);
}
} }
/* /*
...@@ -2298,7 +2719,7 @@ static void yy_parse_failed( ...@@ -2298,7 +2719,7 @@ static void yy_parse_failed(
fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
} }
#endif #endif
while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
/* Here code is inserted which will be executed whenever the /* Here code is inserted which will be executed whenever the
** parser fails */ ** parser fails */
/************ Begin %parse_failure code ***************************************/ /************ Begin %parse_failure code ***************************************/
...@@ -2313,10 +2734,10 @@ static void yy_parse_failed( ...@@ -2313,10 +2734,10 @@ static void yy_parse_failed(
static void yy_syntax_error( static void yy_syntax_error(
yyParser *yypParser, /* The parser */ yyParser *yypParser, /* The parser */
int yymajor, /* The major type of the error token */ int yymajor, /* The major type of the error token */
YYMINORTYPE yyminor /* The minor type of the error token */ ParseTOKENTYPE yyminor /* The minor type of the error token */
){ ){
ParseARG_FETCH; ParseARG_FETCH;
#define TOKEN (yyminor.yy0) #define TOKEN yyminor
/************ Begin %syntax_error code ****************************************/ /************ Begin %syntax_error code ****************************************/
pInfo->validSql = false; pInfo->validSql = false;
...@@ -2356,7 +2777,10 @@ static void yy_accept( ...@@ -2356,7 +2777,10 @@ static void yy_accept(
fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
} }
#endif #endif
while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); #ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt = -1;
#endif
assert( yypParser->yytos==yypParser->yystack );
/* Here code is inserted which will be executed whenever the /* Here code is inserted which will be executed whenever the
** parser accepts */ ** parser accepts */
/*********** Begin %parse_accept code *****************************************/ /*********** Begin %parse_accept code *****************************************/
...@@ -2391,7 +2815,7 @@ void Parse( ...@@ -2391,7 +2815,7 @@ void Parse(
ParseARG_PDECL /* Optional %extra_argument parameter */ ParseARG_PDECL /* Optional %extra_argument parameter */
){ ){
YYMINORTYPE yyminorunion; YYMINORTYPE yyminorunion;
int yyact; /* The parser action. */ unsigned int yyact; /* The parser action. */
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
int yyendofinput; /* True if we are at the end of input */ int yyendofinput; /* True if we are at the end of input */
#endif #endif
...@@ -2400,29 +2824,8 @@ void Parse( ...@@ -2400,29 +2824,8 @@ void Parse(
#endif #endif
yyParser *yypParser; /* The parser */ yyParser *yypParser; /* The parser */
/* (re)initialize the parser, if necessary */
yypParser = (yyParser*)yyp; yypParser = (yyParser*)yyp;
if( yypParser->yyidx<0 ){ assert( yypParser->yytos!=0 );
#if YYSTACKDEPTH<=0
if( yypParser->yystksz <=0 ){
/*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
yyminorunion = yyzerominor;
yyStackOverflow(yypParser, &yyminorunion);
return;
}
#endif
yypParser->yyidx = 0;
yypParser->yyerrcnt = -1;
yypParser->yystack[0].stateno = 0;
yypParser->yystack[0].major = 0;
#ifndef NDEBUG
if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sInitialize. Empty stack. State 0\n",
yyTracePrompt);
}
#endif
}
yyminorunion.yy0 = yyminor;
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
yyendofinput = (yymajor==0); yyendofinput = (yymajor==0);
#endif #endif
...@@ -2430,21 +2833,34 @@ void Parse( ...@@ -2430,21 +2833,34 @@ void Parse(
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sInput '%s'\n",yyTracePrompt,yyTokenName[yymajor]); int stateno = yypParser->yytos->stateno;
if( stateno < YY_MIN_REDUCE ){
fprintf(yyTraceFILE,"%sInput '%s' in state %d\n",
yyTracePrompt,yyTokenName[yymajor],stateno);
}else{
fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
yyTracePrompt,yyTokenName[yymajor],stateno-YY_MIN_REDUCE);
}
} }
#endif #endif
do{ do{
yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
if( yyact <= YY_MAX_SHIFTREDUCE ){ if( yyact >= YY_MIN_REDUCE ){
if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,yyminor);
yy_shift(yypParser,yyact,yymajor,&yyminorunion); }else if( yyact <= YY_MAX_SHIFTREDUCE ){
yy_shift(yypParser,yyact,yymajor,yyminor);
#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt--; yypParser->yyerrcnt--;
#endif
yymajor = YYNOCODE; yymajor = YYNOCODE;
}else if( yyact <= YY_MAX_REDUCE ){ }else if( yyact==YY_ACCEPT_ACTION ){
yy_reduce(yypParser,yyact-YY_MIN_REDUCE); yypParser->yytos--;
yy_accept(yypParser);
return;
}else{ }else{
assert( yyact == YY_ERROR_ACTION ); assert( yyact == YY_ERROR_ACTION );
yyminorunion.yy0 = yyminor;
#ifdef YYERRORSYMBOL #ifdef YYERRORSYMBOL
int yymx; int yymx;
#endif #endif
...@@ -2474,9 +2890,9 @@ void Parse( ...@@ -2474,9 +2890,9 @@ void Parse(
** **
*/ */
if( yypParser->yyerrcnt<0 ){ if( yypParser->yyerrcnt<0 ){
yy_syntax_error(yypParser,yymajor,yyminorunion); yy_syntax_error(yypParser,yymajor,yyminor);
} }
yymx = yypParser->yystack[yypParser->yyidx].major; yymx = yypParser->yytos->major;
if( yymx==YYERRORSYMBOL || yyerrorhit ){ if( yymx==YYERRORSYMBOL || yyerrorhit ){
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
...@@ -2484,26 +2900,26 @@ void Parse( ...@@ -2484,26 +2900,26 @@ void Parse(
yyTracePrompt,yyTokenName[yymajor]); yyTracePrompt,yyTokenName[yymajor]);
} }
#endif #endif
yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion); yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
yymajor = YYNOCODE; yymajor = YYNOCODE;
}else{ }else{
while( while( yypParser->yytos >= yypParser->yystack
yypParser->yyidx >= 0 && && yymx != YYERRORSYMBOL
yymx != YYERRORSYMBOL && && (yyact = yy_find_reduce_action(
(yyact = yy_find_reduce_action( yypParser->yytos->stateno,
yypParser->yystack[yypParser->yyidx].stateno,
YYERRORSYMBOL)) >= YY_MIN_REDUCE YYERRORSYMBOL)) >= YY_MIN_REDUCE
){ ){
yy_pop_parser_stack(yypParser); yy_pop_parser_stack(yypParser);
} }
if( yypParser->yyidx < 0 || yymajor==0 ){ if( yypParser->yytos < yypParser->yystack || yymajor==0 ){
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
yy_parse_failed(yypParser); yy_parse_failed(yypParser);
#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt = -1;
#endif
yymajor = YYNOCODE; yymajor = YYNOCODE;
}else if( yymx!=YYERRORSYMBOL ){ }else if( yymx!=YYERRORSYMBOL ){
YYMINORTYPE u2; yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
u2.YYERRSYMDT = 0;
yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
} }
} }
yypParser->yyerrcnt = 3; yypParser->yyerrcnt = 3;
...@@ -2516,7 +2932,7 @@ void Parse( ...@@ -2516,7 +2932,7 @@ void Parse(
** Applications can set this macro (for example inside %include) if ** Applications can set this macro (for example inside %include) if
** they intend to abandon the parse upon the first syntax error seen. ** they intend to abandon the parse upon the first syntax error seen.
*/ */
yy_syntax_error(yypParser,yymajor,yyminorunion); yy_syntax_error(yypParser,yymajor, yyminor);
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
yymajor = YYNOCODE; yymajor = YYNOCODE;
...@@ -2531,24 +2947,29 @@ void Parse( ...@@ -2531,24 +2947,29 @@ void Parse(
** three input tokens have been successfully shifted. ** three input tokens have been successfully shifted.
*/ */
if( yypParser->yyerrcnt<=0 ){ if( yypParser->yyerrcnt<=0 ){
yy_syntax_error(yypParser,yymajor,yyminorunion); yy_syntax_error(yypParser,yymajor, yyminor);
} }
yypParser->yyerrcnt = 3; yypParser->yyerrcnt = 3;
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
if( yyendofinput ){ if( yyendofinput ){
yy_parse_failed(yypParser); yy_parse_failed(yypParser);
#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt = -1;
#endif
} }
yymajor = YYNOCODE; yymajor = YYNOCODE;
#endif #endif
} }
}while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack );
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
int i; yyStackEntry *i;
char cDiv = '[';
fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt); fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
for(i=1; i<=yypParser->yyidx; i++) for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){
fprintf(yyTraceFILE,"%c%s", i==1 ? '[' : ' ', fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]);
yyTokenName[yypParser->yystack[i].major]); cDiv = ' ';
}
fprintf(yyTraceFILE,"]\n"); fprintf(yyTraceFILE,"]\n");
} }
#endif #endif
......
...@@ -58,12 +58,12 @@ int64_t tsMsPerDay[] = {86400000L, 86400000000L}; ...@@ -58,12 +58,12 @@ int64_t tsMsPerDay[] = {86400000L, 86400000000L};
char tsMasterIp[TSDB_IPv4ADDR_LEN] = {0}; char tsMasterIp[TSDB_IPv4ADDR_LEN] = {0};
char tsSecondIp[TSDB_IPv4ADDR_LEN] = {0}; char tsSecondIp[TSDB_IPv4ADDR_LEN] = {0};
short tsMgmtShellPort = 6030; // udp[6030-6034] tcp[6030] uint16_t tsMgmtShellPort = 6030; // udp[6030-6034] tcp[6030]
short tsVnodeShellPort = 6035; // udp[6035-6039] tcp[6035] uint16_t tsVnodeShellPort = 6035; // udp[6035-6039] tcp[6035]
short tsMgmtVnodePort = 6040; // udp[6040-6044] tcp[6040] uint16_t tsMgmtVnodePort = 6040; // udp[6040-6044] tcp[6040]
short tsVnodeVnodePort = 6045; // tcp[6045] uint16_t tsVnodeVnodePort = 6045; // tcp[6045]
short tsMgmtMgmtPort = 6050; // udp, numOfVnodes fixed to 1, range udp[6050] uint16_t tsMgmtMgmtPort = 6050; // udp, numOfVnodes fixed to 1, range udp[6050]
short tsMgmtSyncPort = 6050; // tcp, range tcp[6050] uint16_t tsMgmtSyncPort = 6050; // tcp, range tcp[6050]
int tsStatusInterval = 1; // second int tsStatusInterval = 1; // second
int tsShellActivityTimer = 3; // second int tsShellActivityTimer = 3; // second
...@@ -152,8 +152,8 @@ int tsProjectExecInterval = 10000; // every 10sec, the projection will be ...@@ -152,8 +152,8 @@ int tsProjectExecInterval = 10000; // every 10sec, the projection will be
int64_t tsMaxRetentWindow = 24 * 3600L; // maximum time window tolerance int64_t tsMaxRetentWindow = 24 * 3600L; // maximum time window tolerance
char tsHttpIp[TSDB_IPv4ADDR_LEN] = "0.0.0.0"; char tsHttpIp[TSDB_IPv4ADDR_LEN] = "0.0.0.0";
short tsHttpPort = 6020; // only tcp, range tcp[6020] uint16_t tsHttpPort = 6020; // only tcp, range tcp[6020]
// short tsNginxPort = 6060; //only tcp, range tcp[6060] // uint16_t tsNginxPort = 6060; //only tcp, range tcp[6060]
int tsHttpCacheSessions = 100; int tsHttpCacheSessions = 100;
int tsHttpSessionExpire = 36000; int tsHttpSessionExpire = 36000;
int tsHttpMaxThreads = 2; int tsHttpMaxThreads = 2;
...@@ -162,6 +162,9 @@ int tsHttpEnableRecordSql = 0; ...@@ -162,6 +162,9 @@ int tsHttpEnableRecordSql = 0;
int tsTelegrafUseFieldNum = 0; int tsTelegrafUseFieldNum = 0;
int tsAdminRowLimit = 10240; int tsAdminRowLimit = 10240;
int tsTscEnableRecordSql = 0;
int tsEnableCoreFile = 0;
int tsRpcTimer = 300; int tsRpcTimer = 300;
int tsRpcMaxTime = 600; // seconds; int tsRpcMaxTime = 600; // seconds;
...@@ -767,6 +770,14 @@ static void doInitGlobalConfig() { ...@@ -767,6 +770,14 @@ static void doInitGlobalConfig() {
0, 255, 0, 0, 255, 0,
TSDB_CFG_UTYPE_NONE); TSDB_CFG_UTYPE_NONE);
tsInitConfigOption(cfg++, "tscEnableRecordSql", &tsTscEnableRecordSql, TSDB_CFG_VTYPE_INT,
TSDB_CFG_CTYPE_B_CONFIG,
1, 100000, 0, TSDB_CFG_UTYPE_NONE);
tsInitConfigOption(cfg++, "enableCoreFile", &tsEnableCoreFile, TSDB_CFG_VTYPE_INT,
TSDB_CFG_CTYPE_B_CONFIG,
1, 100000, 0, TSDB_CFG_UTYPE_NONE);
// version info // version info
tsInitConfigOption(cfg++, "gitinfo", gitinfo, TSDB_CFG_VTYPE_STRING, tsInitConfigOption(cfg++, "gitinfo", gitinfo, TSDB_CFG_VTYPE_STRING,
TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT, TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT,
...@@ -779,6 +790,7 @@ static void doInitGlobalConfig() { ...@@ -779,6 +790,7 @@ static void doInitGlobalConfig() {
0, 0, 0, TSDB_CFG_UTYPE_NONE); 0, 0, 0, TSDB_CFG_UTYPE_NONE);
tsGlobalConfigNum = (int)(cfg - tsGlobalConfig); tsGlobalConfigNum = (int)(cfg - tsGlobalConfig);
assert(tsGlobalConfigNum <= TSDB_CFG_MAX_NUM);
} }
static pthread_once_t initGlobalConfig = PTHREAD_ONCE_INIT; static pthread_once_t initGlobalConfig = PTHREAD_ONCE_INIT;
...@@ -1156,4 +1168,4 @@ void tsPrintGlobalConfigSpec() { ...@@ -1156,4 +1168,4 @@ void tsPrintGlobalConfigSpec() {
pPrint(" dataDir: %s", dataDir); pPrint(" dataDir: %s", dataDir);
} }
#endif #endif
\ No newline at end of file
...@@ -13,58 +13,50 @@ ...@@ -13,58 +13,50 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdio.h> #include "tnote.h"
#include <string.h>
#include <time.h> taosNoteInfo m_HttpNote;
#include <stdlib.h> taosNoteInfo m_TscNote;
#include <errno.h>
#include <sys/types.h> int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInfo * pNote);
#include <stdarg.h>
#include <ctype.h> void taosInitNote(int numOfNoteLines, int maxNotes, char* lable)
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
#include <semaphore.h>
#include "os.h"
#include "tutil.h"
#include "tglobalcfg.h"
#define MAX_NOTE_LINE_SIZE 66000
#define NOTE_FILE_NAME_LEN 300
static int taosNoteFileNum = 1;
static int taosNoteMaxLines = 0;
static int taosNoteLines = 0;
static char taosNoteName[NOTE_FILE_NAME_LEN];
static int taosNoteFlag = 0;
static int taosNoteFd = -1;
static int taosNoteOpenInProgress = 0;
static pthread_mutex_t taosNoteMutex;
void taosNotePrint(const char * const format, ...);
int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum);
void taosInitNote(int numOfNoteLines, int maxNotes)
{ {
taosNoteInfo * pNote = NULL;
char temp[128] = { 0 }; char temp[128] = { 0 };
sprintf(temp, "%s/taosnote", logDir);
if (taosOpenNoteWithMaxLines(temp, numOfNoteLines, maxNotes) < 0) if (strcasecmp(lable, "http_note") == 0) {
pNote = &m_HttpNote;
sprintf(temp, "%s/httpnote", logDir);
} else if (strcasecmp(lable, "tsc_note") == 0) {
pNote = &m_TscNote;
sprintf(temp, "%s/tscnote-%d", logDir, getpid());
} else {
return;
}
memset(pNote, 0, sizeof(taosNoteInfo));
pNote->taosNoteFileNum = 1;
//pNote->taosNoteMaxLines = 0;
//pNote->taosNoteLines = 0;
//pNote->taosNoteFlag = 0;
pNote->taosNoteFd = -1;
//pNote->taosNoteOpenInProgress = 0;
if (taosOpenNoteWithMaxLines(temp, numOfNoteLines, maxNotes, pNote) < 0)
fprintf(stderr, "failed to init note file\n"); fprintf(stderr, "failed to init note file\n");
taosNotePrint("=================================================="); taosNotePrint(pNote, "==================================================");
taosNotePrint("=================== new note ==================="); taosNotePrint(pNote, "=================== new note ===================");
taosNotePrint("=================================================="); taosNotePrint(pNote, "==================================================");
} }
void taosCloseNoteByFd(int oldFd); void taosCloseNoteByFd(int oldFd, taosNoteInfo * pNote);
bool taosLockNote(int fd) bool taosLockNote(int fd, taosNoteInfo * pNote)
{ {
if (fd < 0) return false; if (fd < 0) return false;
if (taosNoteFileNum > 1) { if (pNote->taosNoteFileNum > 1) {
int ret = (int)(flock(fd, LOCK_EX | LOCK_NB)); int ret = (int)(flock(fd, LOCK_EX | LOCK_NB));
if (ret == 0) { if (ret == 0) {
return true; return true;
...@@ -74,11 +66,11 @@ bool taosLockNote(int fd) ...@@ -74,11 +66,11 @@ bool taosLockNote(int fd)
return false; return false;
} }
void taosUnLockNote(int fd) void taosUnLockNote(int fd, taosNoteInfo * pNote)
{ {
if (fd < 0) return; if (fd < 0) return;
if (taosNoteFileNum > 1) { if (pNote->taosNoteFileNum > 1) {
flock(fd, LOCK_UN | LOCK_NB); flock(fd, LOCK_UN | LOCK_NB);
} }
} }
...@@ -86,50 +78,51 @@ void taosUnLockNote(int fd) ...@@ -86,50 +78,51 @@ void taosUnLockNote(int fd)
void *taosThreadToOpenNewNote(void *param) void *taosThreadToOpenNewNote(void *param)
{ {
char name[NOTE_FILE_NAME_LEN]; char name[NOTE_FILE_NAME_LEN];
taosNoteInfo * pNote = (taosNoteInfo *)param;
taosNoteFlag ^= 1; pNote->taosNoteFlag ^= 1;
taosNoteLines = 0; pNote->taosNoteLines = 0;
sprintf(name, "%s.%d", taosNoteName, taosNoteFlag); sprintf(name, "%s.%d", pNote->taosNoteName, pNote->taosNoteFlag);
umask(0); umask(0);
int fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO); int fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO);
taosLockNote(fd); taosLockNote(fd, pNote);
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);
int oldFd = taosNoteFd; int oldFd = pNote->taosNoteFd;
taosNoteFd = fd; pNote->taosNoteFd = fd;
taosNoteLines = 0; pNote->taosNoteLines = 0;
taosNoteOpenInProgress = 0; pNote->taosNoteOpenInProgress = 0;
taosNotePrint("=============== new note is opened ============="); taosNotePrint(pNote, "=============== new note is opened =============");
taosCloseNoteByFd(oldFd); taosCloseNoteByFd(oldFd, pNote);
return NULL; return NULL;
} }
int taosOpenNewNote() int taosOpenNewNote(taosNoteInfo * pNote)
{ {
pthread_mutex_lock(&taosNoteMutex); pthread_mutex_lock(&pNote->taosNoteMutex);
if (taosNoteLines > taosNoteMaxLines && taosNoteOpenInProgress == 0) { if (pNote->taosNoteLines > pNote->taosNoteMaxLines && pNote->taosNoteOpenInProgress == 0) {
taosNoteOpenInProgress = 1; pNote->taosNoteOpenInProgress = 1;
taosNotePrint("=============== open new note =================="); taosNotePrint(pNote, "=============== open new note ==================");
pthread_t pattern; pthread_t pattern;
pthread_attr_t attr; pthread_attr_t attr;
pthread_attr_init(&attr); pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_create(&pattern, &attr, taosThreadToOpenNewNote, NULL); pthread_create(&pattern, &attr, taosThreadToOpenNewNote, (void*)pNote);
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
} }
pthread_mutex_unlock(&taosNoteMutex); pthread_mutex_unlock(&pNote->taosNoteMutex);
return taosNoteFd; return pNote->taosNoteFd;
} }
bool taosCheckNoteIsOpen(char *noteName) bool taosCheckNoteIsOpen(char *noteName, taosNoteInfo * pNote)
{ {
int exist = access(noteName, F_OK); int exist = access(noteName, F_OK);
if (exist != 0) { if (exist != 0) {
...@@ -142,8 +135,8 @@ bool taosCheckNoteIsOpen(char *noteName) ...@@ -142,8 +135,8 @@ bool taosCheckNoteIsOpen(char *noteName)
return true; return true;
} }
if (taosLockNote(fd)) { if (taosLockNote(fd, pNote)) {
taosUnLockNote(fd); taosUnLockNote(fd, pNote);
close(fd); close(fd);
return false; return false;
} }
...@@ -153,80 +146,80 @@ bool taosCheckNoteIsOpen(char *noteName) ...@@ -153,80 +146,80 @@ bool taosCheckNoteIsOpen(char *noteName)
} }
} }
void taosGetNoteName(char *fn) void taosGetNoteName(char *fn, taosNoteInfo * pNote)
{ {
if (taosNoteFileNum > 1) { if (pNote->taosNoteFileNum > 1) {
for (int i = 0; i < taosNoteFileNum; i++) { for (int i = 0; i < pNote->taosNoteFileNum; i++) {
char fileName[NOTE_FILE_NAME_LEN]; char fileName[NOTE_FILE_NAME_LEN];
sprintf(fileName, "%s%d.0", fn, i); sprintf(fileName, "%s%d.0", fn, i);
bool file1open = taosCheckNoteIsOpen(fileName); bool file1open = taosCheckNoteIsOpen(fileName, pNote);
sprintf(fileName, "%s%d.1", fn, i); sprintf(fileName, "%s%d.1", fn, i);
bool file2open = taosCheckNoteIsOpen(fileName); bool file2open = taosCheckNoteIsOpen(fileName, pNote);
if (!file1open && !file2open) { if (!file1open && !file2open) {
sprintf(taosNoteName, "%s%d", fn, i); sprintf(pNote->taosNoteName, "%s%d", fn, i);
return; return;
} }
} }
} }
strcpy(taosNoteName, fn); strcpy(pNote->taosNoteName, fn);
} }
int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum) int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInfo * pNote)
{ {
char name[NOTE_FILE_NAME_LEN] = "\0"; char name[NOTE_FILE_NAME_LEN] = "\0";
struct stat notestat0, notestat1; struct stat notestat0, notestat1;
int size; int size;
taosNoteMaxLines = maxLines; pNote->taosNoteMaxLines = maxLines;
taosNoteFileNum = maxNoteNum; pNote->taosNoteFileNum = maxNoteNum;
taosGetNoteName(fn); taosGetNoteName(fn, pNote);
strcpy(name, fn); strcpy(name, fn);
strcat(name, ".0"); strcat(name, ".0");
// if none of the note files exist, open 0, if both exists, open the old one // if none of the note files exist, open 0, if both exists, open the old one
if (stat(name, &notestat0) < 0) { if (stat(name, &notestat0) < 0) {
taosNoteFlag = 0; pNote->taosNoteFlag = 0;
} }
else { else {
strcpy(name, fn); strcpy(name, fn);
strcat(name, ".1"); strcat(name, ".1");
if (stat(name, &notestat1) < 0) { if (stat(name, &notestat1) < 0) {
taosNoteFlag = 1; pNote->taosNoteFlag = 1;
} }
else { else {
taosNoteFlag = (notestat0.st_mtime > notestat1.st_mtime) ? 0 : 1; pNote->taosNoteFlag = (notestat0.st_mtime > notestat1.st_mtime) ? 0 : 1;
} }
} }
sprintf(name, "%s.%d", taosNoteName, taosNoteFlag); sprintf(name, "%s.%d", pNote->taosNoteName, pNote->taosNoteFlag);
pthread_mutex_init(&taosNoteMutex, NULL); pthread_mutex_init(&pNote->taosNoteMutex, NULL);
umask(0); umask(0);
taosNoteFd = open(name, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); pNote->taosNoteFd = open(name, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
if (taosNoteFd < 0) { if (pNote->taosNoteFd < 0) {
fprintf(stderr, "failed to open note file:%s reason:%s\n", name, strerror(errno)); fprintf(stderr, "failed to open note file:%s reason:%s\n", name, strerror(errno));
return -1; return -1;
} }
taosLockNote(taosNoteFd); taosLockNote(pNote->taosNoteFd, pNote);
// only an estimate for number of lines // only an estimate for number of lines
struct stat filestat; struct stat filestat;
fstat(taosNoteFd, &filestat); fstat(pNote->taosNoteFd, &filestat);
size = (int)filestat.st_size; size = (int)filestat.st_size;
taosNoteLines = size / 60; pNote->taosNoteLines = size / 60;
lseek(taosNoteFd, 0, SEEK_END); lseek(pNote->taosNoteFd, 0, SEEK_END);
return 0; return 0;
} }
void taosNotePrint(const char * const format, ...) void taosNotePrint(taosNoteInfo * pNote, const char * const format, ...)
{ {
va_list argpointer; va_list argpointer;
char buffer[MAX_NOTE_LINE_SIZE]; char buffer[MAX_NOTE_LINE_SIZE];
...@@ -238,7 +231,7 @@ void taosNotePrint(const char * const format, ...) ...@@ -238,7 +231,7 @@ void taosNotePrint(const char * const format, ...)
gettimeofday(&timeSecs, NULL); gettimeofday(&timeSecs, NULL);
curTime = timeSecs.tv_sec; curTime = timeSecs.tv_sec;
ptm = localtime_r(&curTime, &Tm); ptm = localtime_r(&curTime, &Tm);
len = sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d ", ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec, (int)timeSecs.tv_usec); len = sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d %lx ", ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec, (int)timeSecs.tv_usec, pthread_self());
va_start(argpointer, format); va_start(argpointer, format);
len += vsnprintf(buffer + len, MAX_NOTE_LINE_SIZE - len, format, argpointer); len += vsnprintf(buffer + len, MAX_NOTE_LINE_SIZE - len, format, argpointer);
...@@ -249,26 +242,26 @@ void taosNotePrint(const char * const format, ...) ...@@ -249,26 +242,26 @@ void taosNotePrint(const char * const format, ...)
buffer[len++] = '\n'; buffer[len++] = '\n';
buffer[len] = 0; buffer[len] = 0;
if (taosNoteFd >= 0) { if (pNote->taosNoteFd >= 0) {
twrite(taosNoteFd, buffer, (unsigned int)len); twrite(pNote->taosNoteFd, buffer, (unsigned int)len);
if (taosNoteMaxLines > 0) { if (pNote->taosNoteMaxLines > 0) {
taosNoteLines++; pNote->taosNoteLines++;
if ((taosNoteLines > taosNoteMaxLines) && (taosNoteOpenInProgress == 0)) if ((pNote->taosNoteLines > pNote->taosNoteMaxLines) && (pNote->taosNoteOpenInProgress == 0))
taosOpenNewNote(); taosOpenNewNote(pNote);
} }
} }
} }
void taosCloseNote() void taosCloseNote(taosNoteInfo * pNote)
{ {
taosCloseNoteByFd(taosNoteFd); taosCloseNoteByFd(pNote->taosNoteFd, pNote);
} }
void taosCloseNoteByFd(int fd) void taosCloseNoteByFd(int fd, taosNoteInfo * pNote)
{ {
if (fd >= 0) { if (fd >= 0) {
taosUnLockNote(fd); taosUnLockNote(fd, pNote);
close(fd); close(fd);
} }
} }
...@@ -261,19 +261,19 @@ int taosReadn(int fd, char *ptr, int nbytes) { ...@@ -261,19 +261,19 @@ int taosReadn(int fd, char *ptr, int nbytes) {
return (nbytes - nleft); return (nbytes - nleft);
} }
int taosOpenUdpSocket(char *ip, short port) { int taosOpenUdpSocket(char *ip, uint16_t port) {
struct sockaddr_in localAddr; struct sockaddr_in localAddr;
int sockFd; int sockFd;
int ttl = 128; int ttl = 128;
int reuse, nocheck; int reuse, nocheck;
int bufSize = 8192000; int bufSize = 8192000;
pTrace("open udp socket:%s:%d", ip, port); pTrace("open udp socket:%s:%hu", ip, port);
memset((char *)&localAddr, 0, sizeof(localAddr)); memset((char *)&localAddr, 0, sizeof(localAddr));
localAddr.sin_family = AF_INET; localAddr.sin_family = AF_INET;
localAddr.sin_addr.s_addr = inet_addr(ip); localAddr.sin_addr.s_addr = inet_addr(ip);
localAddr.sin_port = (uint16_t)htons((uint16_t)port); localAddr.sin_port = (uint16_t)htons(port);
if ((sockFd = (int)socket(AF_INET, SOCK_DGRAM, 0)) < 0) { if ((sockFd = (int)socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
pError("failed to open udp socket: %d (%s)", errno, strerror(errno)); pError("failed to open udp socket: %d (%s)", errno, strerror(errno));
...@@ -319,7 +319,7 @@ int taosOpenUdpSocket(char *ip, short port) { ...@@ -319,7 +319,7 @@ int taosOpenUdpSocket(char *ip, short port) {
/* bind socket to local address */ /* bind socket to local address */
if (bind(sockFd, (struct sockaddr *)&localAddr, sizeof(localAddr)) < 0) { if (bind(sockFd, (struct sockaddr *)&localAddr, sizeof(localAddr)) < 0) {
pError("failed to bind udp socket: %d (%s), %s:%d", errno, strerror(errno), ip, port); pError("failed to bind udp socket: %d (%s), %s:%hu", errno, strerror(errno), ip, port);
taosCloseSocket(sockFd); taosCloseSocket(sockFd);
return -1; return -1;
} }
...@@ -327,7 +327,7 @@ int taosOpenUdpSocket(char *ip, short port) { ...@@ -327,7 +327,7 @@ int taosOpenUdpSocket(char *ip, short port) {
return sockFd; return sockFd;
} }
int taosOpenTcpClientSocket(char *destIp, short destPort, char *clientIp) { int taosOpenTcpClientSocket(char *destIp, uint16_t destPort, char *clientIp) {
int sockFd = 0; int sockFd = 0;
struct sockaddr_in serverAddr, clientAddr; struct sockaddr_in serverAddr, clientAddr;
int ret; int ret;
...@@ -364,7 +364,7 @@ int taosOpenTcpClientSocket(char *destIp, short destPort, char *clientIp) { ...@@ -364,7 +364,7 @@ int taosOpenTcpClientSocket(char *destIp, short destPort, char *clientIp) {
ret = connect(sockFd, (struct sockaddr *)&serverAddr, sizeof(serverAddr)); ret = connect(sockFd, (struct sockaddr *)&serverAddr, sizeof(serverAddr));
if (ret != 0) { if (ret != 0) {
pError("failed to connect socket, ip:%s, port:%d, reason: %s", destIp, destPort, strerror(errno)); pError("failed to connect socket, ip:%s, port:%hu, reason: %s", destIp, destPort, strerror(errno));
taosCloseSocket(sockFd); taosCloseSocket(sockFd);
sockFd = -1; sockFd = -1;
} }
...@@ -422,17 +422,17 @@ int taosKeepTcpAlive(int sockFd) { ...@@ -422,17 +422,17 @@ int taosKeepTcpAlive(int sockFd) {
return 0; return 0;
} }
int taosOpenTcpServerSocket(char *ip, short port) { int taosOpenTcpServerSocket(char *ip, uint16_t port) {
struct sockaddr_in serverAdd; struct sockaddr_in serverAdd;
int sockFd; int sockFd;
int reuse; int reuse;
pTrace("open tcp server socket:%s:%d", ip, port); pTrace("open tcp server socket:%s:%hu", ip, port);
bzero((char *)&serverAdd, sizeof(serverAdd)); bzero((char *)&serverAdd, sizeof(serverAdd));
serverAdd.sin_family = AF_INET; serverAdd.sin_family = AF_INET;
serverAdd.sin_addr.s_addr = inet_addr(ip); serverAdd.sin_addr.s_addr = inet_addr(ip);
serverAdd.sin_port = (uint16_t)htons((uint16_t)port); serverAdd.sin_port = (uint16_t)htons(port);
if ((sockFd = (int)socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { if ((sockFd = (int)socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
pError("failed to open TCP socket: %d (%s)", errno, strerror(errno)); pError("failed to open TCP socket: %d (%s)", errno, strerror(errno));
...@@ -449,7 +449,7 @@ int taosOpenTcpServerSocket(char *ip, short port) { ...@@ -449,7 +449,7 @@ int taosOpenTcpServerSocket(char *ip, short port) {
/* bind socket to server address */ /* bind socket to server address */
if (bind(sockFd, (struct sockaddr *)&serverAdd, sizeof(serverAdd)) < 0) { if (bind(sockFd, (struct sockaddr *)&serverAdd, sizeof(serverAdd)) < 0) {
pError("bind tcp server socket failed, %s:%d, reason:%d(%s)", ip, port, errno, strerror(errno)); pError("bind tcp server socket failed, %s:%hu, reason:%d(%s)", ip, port, errno, strerror(errno));
close(sockFd); close(sockFd);
return -1; return -1;
} }
...@@ -457,7 +457,7 @@ int taosOpenTcpServerSocket(char *ip, short port) { ...@@ -457,7 +457,7 @@ int taosOpenTcpServerSocket(char *ip, short port) {
if (taosKeepTcpAlive(sockFd) < 0) return -1; if (taosKeepTcpAlive(sockFd) < 0) return -1;
if (listen(sockFd, 10) < 0) { if (listen(sockFd, 10) < 0) {
pError("listen tcp server socket failed, %s:%d, reason:%d(%s)", ip, port, errno, strerror(errno)); pError("listen tcp server socket failed, %s:%hu, reason:%d(%s)", ip, port, errno, strerror(errno));
return -1; return -1;
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
*/ */
#include "os.h" #include "os.h"
#include <inttypes.h>
#include "tlog.h" #include "tlog.h"
#include "tsched.h" #include "tsched.h"
#include "ttime.h" #include "ttime.h"
...@@ -253,13 +254,13 @@ static void processExpiredTimer(void* handle, void* arg) { ...@@ -253,13 +254,13 @@ static void processExpiredTimer(void* handle, void* arg) {
timer->executedBy = taosGetPthreadId(); timer->executedBy = taosGetPthreadId();
uint8_t state = atomic_val_compare_exchange_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_EXPIRED); uint8_t state = atomic_val_compare_exchange_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_EXPIRED);
if (state == TIMER_STATE_WAITING) { if (state == TIMER_STATE_WAITING) {
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] execution start."; const char* fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] execution start.";
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param); tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
(*timer->fp)(timer->param, (tmr_h)timer->id); (*timer->fp)(timer->param, (tmr_h)timer->id);
atomic_store_8(&timer->state, TIMER_STATE_STOPPED); atomic_store_8(&timer->state, TIMER_STATE_STOPPED);
fmt = "%s timer[id=%lld, fp=%p, param=%p] execution end."; fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] execution end.";
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param); tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
} }
removeTimer(timer->id); removeTimer(timer->id);
...@@ -267,7 +268,7 @@ static void processExpiredTimer(void* handle, void* arg) { ...@@ -267,7 +268,7 @@ static void processExpiredTimer(void* handle, void* arg) {
} }
static void addToExpired(tmr_obj_t* head) { static void addToExpired(tmr_obj_t* head) {
const char* fmt = "%s adding expired timer[id=%lld, fp=%p, param=%p] to queue."; const char* fmt = "%s adding expired timer[id=" PRIuPTR ", fp=%p, param=%p] to queue.";
while (head != NULL) { while (head != NULL) {
uintptr_t id = head->id; uintptr_t id = head->id;
...@@ -281,7 +282,7 @@ static void addToExpired(tmr_obj_t* head) { ...@@ -281,7 +282,7 @@ static void addToExpired(tmr_obj_t* head) {
schedMsg.thandle = NULL; schedMsg.thandle = NULL;
taosScheduleTask(tmrQhandle, &schedMsg); taosScheduleTask(tmrQhandle, &schedMsg);
tmrTrace("timer[id=%lld] has been added to queue.", id); tmrTrace("timer[id=" PRIuPTR "] has been added to queue.", id);
head = next; head = next;
} }
} }
...@@ -295,7 +296,7 @@ static uintptr_t doStartTimer(tmr_obj_t* timer, TAOS_TMR_CALLBACK fp, int msecon ...@@ -295,7 +296,7 @@ static uintptr_t doStartTimer(tmr_obj_t* timer, TAOS_TMR_CALLBACK fp, int msecon
timer->ctrl = ctrl; timer->ctrl = ctrl;
addTimer(timer); addTimer(timer);
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] started"; const char* fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] started";
tmrTrace(fmt, ctrl->label, timer->id, timer->fp, timer->param); tmrTrace(fmt, ctrl->label, timer->id, timer->fp, timer->param);
if (mseconds == 0) { if (mseconds == 0) {
...@@ -380,40 +381,37 @@ static void taosTimerLoopFunc(int signo) { ...@@ -380,40 +381,37 @@ static void taosTimerLoopFunc(int signo) {
} }
static bool doStopTimer(tmr_obj_t* timer, uint8_t state) { static bool doStopTimer(tmr_obj_t* timer, uint8_t state) {
bool reusable = false;
if (state == TIMER_STATE_WAITING) { if (state == TIMER_STATE_WAITING) {
bool reusable = false;
if (removeFromWheel(timer)) { if (removeFromWheel(timer)) {
removeTimer(timer->id); removeTimer(timer->id);
// only safe to reuse the timer when timer is removed from the wheel. // only safe to reuse the timer when timer is removed from the wheel.
// we cannot guarantee the thread safety of the timr in all other cases. // we cannot guarantee the thread safety of the timr in all other cases.
reusable = true; reusable = true;
} }
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] is cancelled."; const char* fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] is cancelled.";
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param); tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
} else if (state != TIMER_STATE_EXPIRED) { return reusable;
}
if (state != TIMER_STATE_EXPIRED) {
// timer already stopped or cancelled, has nothing to do in this case // timer already stopped or cancelled, has nothing to do in this case
} else if (timer->executedBy == taosGetPthreadId()) { return false;
}
if (timer->executedBy == taosGetPthreadId()) {
// taosTmrReset is called in the timer callback, should do nothing in this // taosTmrReset is called in the timer callback, should do nothing in this
// case to avoid dead lock. note taosTmrReset must be the last statement // case to avoid dead lock. note taosTmrReset must be the last statement
// of the callback funtion, will be a bug otherwise. // of the callback funtion, will be a bug otherwise.
} else { return false;
assert(timer->executedBy != taosGetPthreadId());
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] fired, waiting...";
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
for (int i = 1; atomic_load_8(&timer->state) != TIMER_STATE_STOPPED; i++) {
if (i % 1000 == 0) {
sched_yield();
}
}
fmt = "%s timer[id=%lld, fp=%p, param=%p] stopped.";
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
} }
return reusable; // timer callback is executing in another thread, we SHOULD wait it to stop,
// BUT this may result in dead lock if current thread are holding a lock which
// the timer callback need to acquire. so, we HAVE TO return directly.
const char* fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] is executing and cannot be stopped.";
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
return false;
} }
bool taosTmrStop(tmr_h timerId) { bool taosTmrStop(tmr_h timerId) {
...@@ -421,7 +419,7 @@ bool taosTmrStop(tmr_h timerId) { ...@@ -421,7 +419,7 @@ bool taosTmrStop(tmr_h timerId) {
tmr_obj_t* timer = findTimer(id); tmr_obj_t* timer = findTimer(id);
if (timer == NULL) { if (timer == NULL) {
tmrTrace("timer[id=%lld] does not exist", id); tmrTrace("timer[id=" PRIuPTR "] does not exist", id);
return false; return false;
} }
...@@ -448,7 +446,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle, ...@@ -448,7 +446,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle,
bool stopped = false; bool stopped = false;
tmr_obj_t* timer = findTimer(id); tmr_obj_t* timer = findTimer(id);
if (timer == NULL) { if (timer == NULL) {
tmrTrace("%s timer[id=%lld] does not exist", ctrl->label, id); tmrTrace("%s timer[id=" PRIuPTR "] does not exist", ctrl->label, id);
} else { } else {
uint8_t state = atomic_val_compare_exchange_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_CANCELED); uint8_t state = atomic_val_compare_exchange_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_CANCELED);
if (!doStopTimer(timer, state)) { if (!doStopTimer(timer, state)) {
...@@ -463,7 +461,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle, ...@@ -463,7 +461,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle,
return stopped; return stopped;
} }
tmrTrace("%s timer[id=%lld] is reused", ctrl->label, timer->id); tmrTrace("%s timer[id=" PRIuPTR "] is reused", ctrl->label, timer->id);
// wait until there's no other reference to this timer, // wait until there's no other reference to this timer,
// so that we can reuse this timer safely. // so that we can reuse this timer safely.
......
...@@ -96,7 +96,6 @@ static SKeyword keywordTable[] = { ...@@ -96,7 +96,6 @@ static SKeyword keywordTable[] = {
{"TABLE", TK_TABLE}, {"TABLE", TK_TABLE},
{"DATABASE", TK_DATABASE}, {"DATABASE", TK_DATABASE},
{"DNODE", TK_DNODE}, {"DNODE", TK_DNODE},
{"IP", TK_IP},
{"USER", TK_USER}, {"USER", TK_USER},
{"ACCOUNT", TK_ACCOUNT}, {"ACCOUNT", TK_ACCOUNT},
{"USE", TK_USE}, {"USE", TK_USE},
...@@ -523,7 +522,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { ...@@ -523,7 +522,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
} }
if (seg == 4) { // ip address if (seg == 4) { // ip address
*tokenType = TK_IP; *tokenType = TK_IPTOKEN;
return i; return i;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册