Merge branch 'main' into fix/liaohj_main
This commit is contained in:
commit
465c595c3a
|
@ -2,7 +2,7 @@
|
|||
IF (DEFINED VERNUMBER)
|
||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||
ELSE ()
|
||||
SET(TD_VER_NUMBER "3.0.4.0")
|
||||
SET(TD_VER_NUMBER "3.0.4.1")
|
||||
ENDIF ()
|
||||
|
||||
IF (DEFINED VERCOMPATIBLE)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taosadapter
|
||||
ExternalProject_Add(taosadapter
|
||||
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
||||
GIT_TAG e02ddb2
|
||||
GIT_TAG ae8d51c
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* 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_SYSTABLE_H
|
||||
#define TDENGINE_SYSTABLE_H
|
||||
|
||||
|
|
|
@ -689,6 +689,7 @@ typedef struct {
|
|||
|
||||
int32_t tSerializeSAlterUserReq(void* buf, int32_t bufLen, SAlterUserReq* pReq);
|
||||
int32_t tDeserializeSAlterUserReq(void* buf, int32_t bufLen, SAlterUserReq* pReq);
|
||||
void tFreeSAlterUserReq(SAlterUserReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
char user[TSDB_USER_LEN];
|
||||
|
|
|
@ -82,6 +82,7 @@ typedef struct SCatalogReq {
|
|||
SArray* pUser; // element is SUserAuthInfo
|
||||
SArray* pTableIndex; // element is SNAME
|
||||
SArray* pTableCfg; // element is SNAME
|
||||
SArray* pTableTag; // element is SNAME
|
||||
bool qNodeRequired; // valid qnode
|
||||
bool dNodeRequired; // valid dnode
|
||||
bool svrVerRequired;
|
||||
|
@ -105,6 +106,7 @@ typedef struct SMetaData {
|
|||
SArray* pUser; // pRes = SUserAuthRes*
|
||||
SArray* pQnodeList; // pRes = SArray<SQueryNodeLoad>*
|
||||
SArray* pTableCfg; // pRes = STableCfg*
|
||||
SArray* pTableTag; // pRes = SArray<STagVal>*
|
||||
SArray* pDnodeList; // pRes = SArray<SEpSet>*
|
||||
SMetaRes* pSvrVer; // pRes = char*
|
||||
} SMetaData;
|
||||
|
@ -122,8 +124,8 @@ typedef struct SSTableVersion {
|
|||
char stbName[TSDB_TABLE_NAME_LEN];
|
||||
uint64_t dbId;
|
||||
uint64_t suid;
|
||||
int16_t sversion;
|
||||
int16_t tversion;
|
||||
int32_t sversion;
|
||||
int32_t tversion;
|
||||
int32_t smaVer;
|
||||
} SSTableVersion;
|
||||
|
||||
|
@ -312,6 +314,8 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const char*
|
|||
|
||||
int32_t catalogGetTableIndex(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes);
|
||||
|
||||
int32_t catalogGetTableTag(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes);
|
||||
|
||||
int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableCfg** pCfg);
|
||||
|
||||
int32_t catalogUpdateTableIndex(SCatalog* pCtg, STableIndexRsp* pRsp);
|
||||
|
|
|
@ -379,6 +379,8 @@ typedef struct SVnodeModifyOpStmt {
|
|||
SName usingTableName;
|
||||
const char* pBoundCols;
|
||||
struct STableMeta* pTableMeta;
|
||||
SNode* pTagCond;
|
||||
SArray* pTableTag;
|
||||
SHashObj* pVgroupsHashObj;
|
||||
SHashObj* pTableBlockHashObj; // SHashObj<tuid, STableDataCxt*>
|
||||
SHashObj* pSubTableHashObj;
|
||||
|
|
|
@ -116,8 +116,8 @@ typedef struct STableMeta {
|
|||
|
||||
// if the table is TSDB_CHILD_TABLE, the following information is acquired from the corresponding super table meta
|
||||
// info
|
||||
int16_t sversion;
|
||||
int16_t tversion;
|
||||
int32_t sversion;
|
||||
int32_t tversion;
|
||||
STableComInfo tableInfo;
|
||||
SSchema schema[];
|
||||
} STableMeta;
|
||||
|
|
|
@ -26,6 +26,38 @@ if pidof taosd &> /dev/null; then
|
|||
sleep 1
|
||||
fi
|
||||
|
||||
# Stop adapter service if running
|
||||
if pidof taosadapter &> /dev/null; then
|
||||
if pidof systemd &> /dev/null; then
|
||||
${csudo}systemctl stop taosadapter || :
|
||||
elif $(which service &> /dev/null); then
|
||||
${csudo}service taosadapter stop || :
|
||||
else
|
||||
pid=$(ps -ef | grep "taosadapter" | grep -v "grep" | awk '{print $2}')
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo}kill -9 $pid || :
|
||||
fi
|
||||
fi
|
||||
echo "Stop taosadapter service success!"
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
# Stop keeper service if running
|
||||
if pidof taoskeeper &> /dev/null; then
|
||||
if pidof systemd &> /dev/null; then
|
||||
${csudo}systemctl stop taoskeeper || :
|
||||
elif $(which service &> /dev/null); then
|
||||
${csudo}service taoskeeper stop || :
|
||||
else
|
||||
pid=$(ps -ef | grep "taoskeeper" | grep -v "grep" | awk '{print $2}')
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo}kill -9 $pid || :
|
||||
fi
|
||||
fi
|
||||
echo "Stop taoskeeper service success!"
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
# if taos.cfg already softlink, remove it
|
||||
cfg_install_dir="/etc/taos"
|
||||
install_main_dir="/usr/local/taos"
|
||||
|
@ -41,6 +73,11 @@ if [ -f "${install_main_dir}/taosadapter.service" ]; then
|
|||
${csudo}rm -f ${install_main_dir}/cfg/taosadapter.service || :
|
||||
fi
|
||||
|
||||
if [ -f "${install_main_dir}/taoskeeper.toml" ]; then
|
||||
${csudo}rm -f ${install_main_dir}/cfg/taoskeeper.toml || :
|
||||
fi
|
||||
|
||||
|
||||
# there can not libtaos.so*, otherwise ln -s error
|
||||
${csudo}rm -f ${install_main_dir}/driver/libtaos.* || :
|
||||
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}rm -f ${install_main_dir}/driver/libtaosws.so || :
|
||||
|
|
|
@ -32,6 +32,7 @@ else
|
|||
${csudo}rm -f ${bin_link_dir}/udfd || :
|
||||
${csudo}rm -f ${bin_link_dir}/taosadapter || :
|
||||
${csudo}rm -f ${bin_link_dir}/taosdemo || :
|
||||
${csudo}rm -f ${bin_link_dir}/taoskeeper || :
|
||||
${csudo}rm -f ${cfg_link_dir}/* || :
|
||||
${csudo}rm -f ${inc_link_dir}/taos.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosdef.h || :
|
||||
|
|
|
@ -44,8 +44,31 @@ mkdir -p ${pkg_dir}${install_home_path}/include
|
|||
#mkdir -p ${pkg_dir}${install_home_path}/init.d
|
||||
mkdir -p ${pkg_dir}${install_home_path}/script
|
||||
|
||||
# download taoskeeper and build
|
||||
if [ "$cpuType" = "x64" ] || [ "$cpuType" = "x86_64" ] || [ "$cpuType" = "amd64" ]; then
|
||||
arch=amd64
|
||||
elif [ "$cpuType" = "x32" ] || [ "$cpuType" = "i386" ] || [ "$cpuType" = "i686" ]; then
|
||||
arch=386
|
||||
elif [ "$cpuType" = "arm" ] || [ "$cpuType" = "aarch32" ]; then
|
||||
arch=arm
|
||||
elif [ "$cpuType" = "arm64" ] || [ "$cpuType" = "aarch64" ]; then
|
||||
arch=arm64
|
||||
else
|
||||
arch=$cpuType
|
||||
fi
|
||||
|
||||
echo "${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r ${arch} -e taoskeeper"
|
||||
echo "$top_dir=${top_dir}"
|
||||
taoskeeper_binary=`${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r $arch -e taoskeeper`
|
||||
echo "taoskeeper_binary: ${taoskeeper_binary}"
|
||||
|
||||
# copy config files
|
||||
cp $(dirname ${taoskeeper_binary})/config/taoskeeper.toml ${pkg_dir}${install_home_path}/cfg
|
||||
cp $(dirname ${taoskeeper_binary})/taoskeeper.service ${pkg_dir}${install_home_path}/cfg
|
||||
|
||||
cp ${compile_dir}/../packaging/cfg/taos.cfg ${pkg_dir}${install_home_path}/cfg
|
||||
cp ${compile_dir}/../packaging/cfg/taosd.service ${pkg_dir}${install_home_path}/cfg
|
||||
|
||||
if [ -f "${compile_dir}/test/cfg/taosadapter.toml" ]; then
|
||||
cp ${compile_dir}/test/cfg/taosadapter.toml ${pkg_dir}${install_home_path}/cfg || :
|
||||
fi
|
||||
|
@ -53,6 +76,7 @@ if [ -f "${compile_dir}/test/cfg/taosadapter.service" ]; then
|
|||
cp ${compile_dir}/test/cfg/taosadapter.service ${pkg_dir}${install_home_path}/cfg || :
|
||||
fi
|
||||
|
||||
cp ${taoskeeper_binary} ${pkg_dir}${install_home_path}/bin
|
||||
#cp ${compile_dir}/../packaging/deb/taosd ${pkg_dir}${install_home_path}/init.d
|
||||
cp ${compile_dir}/../packaging/tools/post.sh ${pkg_dir}${install_home_path}/script
|
||||
cp ${compile_dir}/../packaging/tools/preun.sh ${pkg_dir}${install_home_path}/script
|
||||
|
@ -143,6 +167,7 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf ${pkg_dir}/build-taoskeeper
|
||||
# make deb package
|
||||
dpkg -b ${pkg_dir} $debname
|
||||
echo "make deb package success!"
|
||||
|
@ -150,4 +175,5 @@ echo "make deb package success!"
|
|||
cp ${pkg_dir}/*.deb ${output_dir}
|
||||
|
||||
# clean temp dir
|
||||
|
||||
rm -rf ${pkg_dir}
|
||||
|
|
|
@ -35,14 +35,16 @@ function cp_rpm_package() {
|
|||
local cur_dir
|
||||
cd $1
|
||||
cur_dir=$(pwd)
|
||||
|
||||
echo "cp_rpm_package cd: ${cur_dir}"
|
||||
for dirlist in "$(ls ${cur_dir})"; do
|
||||
if test -d ${dirlist}; then
|
||||
cd ${dirlist}
|
||||
echo 'cp_rpm_package ${cur_dir}/${dirlist}'
|
||||
cp_rpm_package ${cur_dir}/${dirlist}
|
||||
cd ..
|
||||
fi
|
||||
if test -e ${dirlist}; then
|
||||
echo "${cur_dir}/${dirlist} ${output_dir}/TDengine-${tdengine_ver}.rpm"
|
||||
cp ${cur_dir}/${dirlist} ${output_dir}/TDengine-${tdengine_ver}.rpm
|
||||
fi
|
||||
done
|
||||
|
@ -54,6 +56,25 @@ fi
|
|||
${csudo}mkdir -p ${pkg_dir}
|
||||
cd ${pkg_dir}
|
||||
|
||||
# download taoskeeper and build
|
||||
if [ "$cpuType" = "x64" ] || [ "$cpuType" = "x86_64" ] || [ "$cpuType" = "amd64" ]; then
|
||||
arch=amd64
|
||||
elif [ "$cpuType" = "x32" ] || [ "$cpuType" = "i386" ] || [ "$cpuType" = "i686" ]; then
|
||||
arch=386
|
||||
elif [ "$cpuType" = "arm" ] || [ "$cpuType" = "aarch32" ]; then
|
||||
arch=arm
|
||||
elif [ "$cpuType" = "arm64" ] || [ "$cpuType" = "aarch64" ]; then
|
||||
arch=arm64
|
||||
else
|
||||
arch=$cpuType
|
||||
fi
|
||||
|
||||
cd ${top_dir}
|
||||
echo "${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r ${arch} -e taoskeeper"
|
||||
taoskeeper_binary=`${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r $arch -e taoskeeper`
|
||||
echo "taoskeeper_binary: ${taoskeeper_binary}"
|
||||
cd ${package_dir}
|
||||
|
||||
${csudo}mkdir -p BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
|
||||
|
||||
${csudo}rpmbuild --define="_version ${tdengine_ver}" --define="_topdir ${pkg_dir}" --define="_compiledir ${compile_dir}" -bb ${spec_file}
|
||||
|
@ -85,3 +106,4 @@ mv ${output_dir}/TDengine-${tdengine_ver}.rpm ${output_dir}/${rpmname}
|
|||
|
||||
cd ..
|
||||
${csudo}rm -rf ${pkg_dir}
|
||||
rm -rf ${top_dir}/build-taoskeeper
|
|
@ -3,6 +3,7 @@
|
|||
%define cfg_install_dir /etc/taos
|
||||
%define __strip /bin/true
|
||||
%global __python /usr/bin/python3
|
||||
%global _build_id_links none
|
||||
|
||||
Name: tdengine
|
||||
Version: %{_version}
|
||||
|
@ -62,6 +63,15 @@ fi
|
|||
if [ -f %{_compiledir}/test/cfg/taosadapter.service ]; then
|
||||
cp %{_compiledir}/test/cfg/taosadapter.service %{buildroot}%{homepath}/cfg
|
||||
fi
|
||||
|
||||
if [ -f %{_compiledir}/../build-taoskeeper/config/taoskeeper.toml ]; then
|
||||
cp %{_compiledir}/../build-taoskeeper/config/taoskeeper.toml %{buildroot}%{homepath}/cfg ||:
|
||||
fi
|
||||
|
||||
if [ -f %{_compiledir}/../build-taoskeeper/taoskeeper.service ]; then
|
||||
cp %{_compiledir}/../build-taoskeeper/taoskeeper.service %{buildroot}%{homepath}/cfg ||:
|
||||
fi
|
||||
|
||||
#cp %{_compiledir}/../packaging/rpm/taosd %{buildroot}%{homepath}/init.d
|
||||
cp %{_compiledir}/../packaging/tools/post.sh %{buildroot}%{homepath}/script
|
||||
cp %{_compiledir}/../packaging/tools/preun.sh %{buildroot}%{homepath}/script
|
||||
|
@ -73,8 +83,12 @@ cp %{_compiledir}/build/bin/taosd %{buildroot}%{homepath}/bin
|
|||
cp %{_compiledir}/build/bin/udfd %{buildroot}%{homepath}/bin
|
||||
cp %{_compiledir}/build/bin/taosBenchmark %{buildroot}%{homepath}/bin
|
||||
|
||||
if [ -f %{_compiledir}/../build-taoskeeper/taoskeeper ]; then
|
||||
cp %{_compiledir}/../build-taoskeeper/taoskeeper %{buildroot}%{homepath}/bin
|
||||
fi
|
||||
|
||||
if [ -f %{_compiledir}/build/bin/taosadapter ]; then
|
||||
cp %{_compiledir}/build/bin/taosadapter %{buildroot}%{homepath}/bin ||:
|
||||
cp %{_compiledir}/build/bin/taosadapter %{buildroot}%{homepath}/bin
|
||||
fi
|
||||
cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver
|
||||
[ -f %{_compiledir}/build/lib/${wslibfile} ] && cp %{_compiledir}/build/lib/${wslibfile} %{buildroot}%{homepath}/driver ||:
|
||||
|
@ -119,7 +133,9 @@ if [ -f %{_compiledir}/build/bin/jemalloc-config ]; then
|
|||
cp %{_compiledir}/build/lib/pkgconfig/jemalloc.pc %{buildroot}%{homepath}/jemalloc/lib/pkgconfig
|
||||
fi
|
||||
fi
|
||||
|
||||
ls -al %{buildroot}%{homepath}/bin
|
||||
tree -L 5
|
||||
echo "==============================copying files done"
|
||||
#Scripts executed before installation
|
||||
%pre
|
||||
if [ -f /var/lib/taos/dnode/dnodeCfg.json ]; then
|
||||
|
@ -196,6 +212,7 @@ if [ $1 -eq 0 ];then
|
|||
${csudo}rm -f ${bin_link_dir}/taosd || :
|
||||
${csudo}rm -f ${bin_link_dir}/udfd || :
|
||||
${csudo}rm -f ${bin_link_dir}/taosadapter || :
|
||||
${csudo}rm -f ${bin_link_dir}/taoskeeper || :
|
||||
${csudo}rm -f ${cfg_link_dir}/* || :
|
||||
${csudo}rm -f ${inc_link_dir}/taos.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosdef.h || :
|
||||
|
|
|
@ -341,7 +341,7 @@ if [ "$verMode" == "cluster" ] || [ "$verMode" == "cloud" ]; then
|
|||
tmp_pwd=`pwd`
|
||||
cd ${install_dir}/connector
|
||||
if [ ! -d taos-connector-jdbc ];then
|
||||
git clone -b main --depth=1 https://github.com/taosdata/taos-connector-jdbc.git ||:
|
||||
git clone -b 3.1.0 --depth=1 https://github.com/taosdata/taos-connector-jdbc.git ||:
|
||||
fi
|
||||
cd taos-connector-jdbc
|
||||
mvn clean package -Dmaven.test.skip=true
|
||||
|
|
|
@ -436,7 +436,7 @@ function local_fqdn_check() {
|
|||
|
||||
function install_taosadapter_config() {
|
||||
if [ ! -f "${cfg_install_dir}/taosadapter.toml" ]; then
|
||||
[ ! -d %{cfg_install_dir} ] &&
|
||||
[ ! -d ${cfg_install_dir} ] &&
|
||||
${csudo}${csudo}mkdir -p ${cfg_install_dir}
|
||||
[ -f ${cfg_dir}/taosadapter.toml ] && ${csudo}cp ${cfg_dir}/taosadapter.toml ${cfg_install_dir}
|
||||
[ -f ${cfg_install_dir}/taosadapter.toml ] &&
|
||||
|
@ -451,19 +451,26 @@ function install_taosadapter_config() {
|
|||
}
|
||||
|
||||
function install_taoskeeper_config() {
|
||||
if [ ! -f "${cfg_install_dir}/keeper.toml" ]; then
|
||||
[ ! -d %{cfg_install_dir} ] &&
|
||||
${csudo}${csudo}mkdir -p ${cfg_install_dir}
|
||||
[ -f ${cfg_dir}/keeper.toml ] && ${csudo}cp ${cfg_dir}/keeper.toml ${cfg_install_dir}
|
||||
[ -f ${cfg_install_dir}/keeper.toml ] &&
|
||||
${csudo}chmod 644 ${cfg_install_dir}/keeper.toml
|
||||
# if new environment without taoskeeper
|
||||
if [[ ! -f "${cfg_install_dir}/keeper.toml" ]] && [[ ! -f "${cfg_install_dir}/taoskeeper.toml" ]]; then
|
||||
[ ! -d ${cfg_install_dir} ] && ${csudo}${csudo}mkdir -p ${cfg_install_dir}
|
||||
[ -f ${cfg_dir}/taoskeeper.toml ] && ${csudo}cp ${cfg_dir}/taoskeeper.toml ${cfg_install_dir}
|
||||
[ -f ${cfg_install_dir}/taoskeeper.toml ] &&
|
||||
${csudo}chmod 644 ${cfg_install_dir}/taoskeeper.toml
|
||||
fi
|
||||
# if old machine with taoskeeper.toml file
|
||||
if [ -f ${cfg_install_dir}/taoskeeper.toml ]; then
|
||||
${csudo}mv ${cfg_dir}/taoskeeper.toml ${cfg_dir}/taoskeeper.toml.new
|
||||
fi
|
||||
|
||||
[ -f ${cfg_dir}/keeper.toml ] &&
|
||||
${csudo}mv ${cfg_dir}/keeper.toml ${cfg_dir}/keeper.toml.new
|
||||
if [ -f ${cfg_install_dir}/keeper.toml ]; then
|
||||
echo "The file keeper.toml will be renamed to taoskeeper.toml"
|
||||
${csudo}mv ${cfg_install_dir}/keeper.toml ${cfg_install_dir}/taoskeeper.toml
|
||||
${csudo}mv ${cfg_dir}/taoskeeper.toml ${cfg_dir}/taoskeeper.toml.new
|
||||
fi
|
||||
|
||||
[ -f ${cfg_install_dir}/keeper.toml ] &&
|
||||
${csudo}ln -s ${cfg_install_dir}/keeper.toml ${cfg_dir}
|
||||
[ -f ${cfg_install_dir}/taoskeeper.toml ] &&
|
||||
${csudo}ln -s ${cfg_install_dir}/taoskeeper.toml ${cfg_dir}
|
||||
}
|
||||
|
||||
function install_config() {
|
||||
|
@ -655,6 +662,15 @@ function install_taosadapter_service() {
|
|||
fi
|
||||
}
|
||||
|
||||
function install_taoskeeper_service() {
|
||||
if ((${service_mod}==0)); then
|
||||
[ -f ${script_dir}/../cfg/taoskeeper.service ] &&\
|
||||
${csudo}cp ${script_dir}/../cfg/taoskeeper.service \
|
||||
${service_config_dir}/ || :
|
||||
${csudo}systemctl daemon-reload
|
||||
fi
|
||||
}
|
||||
|
||||
function install_service() {
|
||||
log_print "start install service"
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
|
@ -732,6 +748,7 @@ function install_TDengine() {
|
|||
install_taosadapter_config
|
||||
install_taoskeeper_config
|
||||
install_taosadapter_service
|
||||
install_taoskeeper_service
|
||||
install_service
|
||||
install_app
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ cfg_link_dir="/usr/local/taos/cfg"
|
|||
|
||||
service_config_dir="/etc/systemd/system"
|
||||
taos_service_name="taosd"
|
||||
|
||||
taoskeeper_service_name="taoskeeper"
|
||||
csudo=""
|
||||
if command -v sudo > /dev/null; then
|
||||
csudo="sudo "
|
||||
|
@ -57,6 +57,13 @@ function kill_taosd() {
|
|||
fi
|
||||
}
|
||||
|
||||
function kill_taoskeeper() {
|
||||
pid=$(ps -ef | grep "taoskeeper" | grep -v "grep" | awk '{print $2}')
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo}kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
|
||||
function clean_service_on_systemd() {
|
||||
taosadapter_service_config="${service_config_dir}/taosadapter.service"
|
||||
if systemctl is-active --quiet taosadapter; then
|
||||
|
@ -76,6 +83,12 @@ function clean_service_on_systemd() {
|
|||
|
||||
[ -f ${taosadapter_service_config} ] && ${csudo}rm -f ${taosadapter_service_config}
|
||||
|
||||
taoskeeper_service_config="${service_config_dir}/${taoskeeper_service_name}.service"
|
||||
if systemctl is-active --quiet ${taoskeeper_service_name}; then
|
||||
echo "TDengine taoskeeper is running, stopping it..."
|
||||
${csudo}systemctl stop ${taoskeeper_service_name} &> /dev/null || echo &> /dev/null
|
||||
fi
|
||||
[ -f ${taoskeeper_service_config} ] && ${csudo}rm -f ${taoskeeper_service_config}
|
||||
}
|
||||
|
||||
function clean_service_on_sysvinit() {
|
||||
|
@ -111,6 +124,7 @@ function clean_service() {
|
|||
# must manual stop taosd
|
||||
kill_taosadapter
|
||||
kill_taosd
|
||||
kill_taoskeeper
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -124,6 +138,7 @@ ${csudo}rm -f ${bin_link_dir}/taosadapter || :
|
|||
${csudo}rm -f ${bin_link_dir}/taosBenchmark || :
|
||||
${csudo}rm -f ${bin_link_dir}/taosdemo || :
|
||||
${csudo}rm -f ${bin_link_dir}/set_core || :
|
||||
${csudo}rm -f ${bin_link_dir}/taoskeeper || :
|
||||
${csudo}rm -f ${cfg_link_dir}/*.new || :
|
||||
${csudo}rm -f ${inc_link_dir}/taos.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosdef.h || :
|
||||
|
|
|
@ -108,7 +108,7 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
|
|||
if (pass == NULL) {
|
||||
pass = TSDB_DEFAULT_PASS;
|
||||
}
|
||||
|
||||
|
||||
STscObj *pObj = taos_connect_internal(ip, user, pass, NULL, db, port, CONN_TYPE__QUERY);
|
||||
if (pObj) {
|
||||
int64_t *rid = taosMemoryCalloc(1, sizeof(int64_t));
|
||||
|
@ -359,11 +359,11 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
|
|||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
int32_t charLen = varDataLen((char *)row[i] - VARSTR_HEADER_SIZE);
|
||||
if (fields[i].type == TSDB_DATA_TYPE_BINARY) {
|
||||
if(ASSERT(charLen <= fields[i].bytes && charLen >= 0)){
|
||||
if (ASSERT(charLen <= fields[i].bytes && charLen >= 0)) {
|
||||
tscError("taos_print_row error binary. charLen:%d, fields[i].bytes:%d", charLen, fields[i].bytes);
|
||||
}
|
||||
} else {
|
||||
if(ASSERT(charLen <= fields[i].bytes * TSDB_NCHAR_SIZE && charLen >= 0)){
|
||||
if (ASSERT(charLen <= fields[i].bytes * TSDB_NCHAR_SIZE && charLen >= 0)) {
|
||||
tscError("taos_print_row error. charLen:%d, fields[i].bytes:%d", charLen, fields[i].bytes);
|
||||
}
|
||||
}
|
||||
|
@ -705,16 +705,16 @@ int taos_get_current_db(TAOS *taos, char *database, int len, int *required) {
|
|||
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
taosThreadMutexLock(&pTscObj->mutex);
|
||||
if(database == NULL || len <= 0){
|
||||
if(required != NULL) *required = strlen(pTscObj->db) + 1;
|
||||
if (database == NULL || len <= 0) {
|
||||
if (required != NULL) *required = strlen(pTscObj->db) + 1;
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
code = -1;
|
||||
}else if(len < strlen(pTscObj->db) + 1){
|
||||
} else if (len < strlen(pTscObj->db) + 1) {
|
||||
tstrncpy(database, pTscObj->db, len);
|
||||
if(required) *required = strlen(pTscObj->db) + 1;
|
||||
if (required) *required = strlen(pTscObj->db) + 1;
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
code = -1;
|
||||
}else{
|
||||
} else {
|
||||
strcpy(database, pTscObj->db);
|
||||
code = 0;
|
||||
}
|
||||
|
@ -741,6 +741,7 @@ static void destoryCatalogReq(SCatalogReq *pCatalogReq) {
|
|||
taosArrayDestroy(pCatalogReq->pUser);
|
||||
taosArrayDestroy(pCatalogReq->pTableIndex);
|
||||
taosArrayDestroy(pCatalogReq->pTableCfg);
|
||||
taosArrayDestroy(pCatalogReq->pTableTag);
|
||||
taosMemoryFree(pCatalogReq);
|
||||
}
|
||||
|
||||
|
@ -975,8 +976,10 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
|||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pRequest->stmtType = pRequest->pQuery->pRoot->type;
|
||||
phaseAsyncQuery(pWrapper);
|
||||
} else {
|
||||
code = phaseAsyncQuery(pWrapper);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("0x%" PRIx64 " error happens, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
destorySqlCallbackWrapper(pWrapper);
|
||||
|
@ -1042,11 +1045,11 @@ static void fetchCallback(void *pResult, void *param, int32_t code) {
|
|||
}
|
||||
|
||||
void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||
if(ASSERT(res != NULL && fp != NULL)){
|
||||
if (ASSERT(res != NULL && fp != NULL)) {
|
||||
tscError("taos_fetch_rows_a invalid paras");
|
||||
return;
|
||||
}
|
||||
if(ASSERT(TD_RES_QUERY(res))){
|
||||
if (ASSERT(TD_RES_QUERY(res))) {
|
||||
tscError("taos_fetch_rows_a res is NULL");
|
||||
return;
|
||||
}
|
||||
|
@ -1092,11 +1095,11 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
|||
}
|
||||
|
||||
void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||
if(ASSERT(res != NULL && fp != NULL)){
|
||||
if (ASSERT(res != NULL && fp != NULL)) {
|
||||
tscError("taos_fetch_rows_a invalid paras");
|
||||
return;
|
||||
}
|
||||
if(ASSERT(TD_RES_QUERY(res))){
|
||||
if (ASSERT(TD_RES_QUERY(res))) {
|
||||
tscError("taos_fetch_rows_a res is NULL");
|
||||
return;
|
||||
}
|
||||
|
@ -1111,11 +1114,11 @@ void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
|||
}
|
||||
|
||||
const void *taos_get_raw_block(TAOS_RES *res) {
|
||||
if(ASSERT(res != NULL)){
|
||||
if (ASSERT(res != NULL)) {
|
||||
tscError("taos_fetch_rows_a invalid paras");
|
||||
return NULL;
|
||||
}
|
||||
if(ASSERT(TD_RES_QUERY(res))){
|
||||
if (ASSERT(TD_RES_QUERY(res))) {
|
||||
tscError("taos_fetch_rows_a res is NULL");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1273,7 +1276,6 @@ _return:
|
|||
return code;
|
||||
}
|
||||
|
||||
|
||||
int taos_load_table_info(TAOS *taos, const char *tableNameList) {
|
||||
if (NULL == taos) {
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
|
|
|
@ -649,6 +649,17 @@ static int32_t smlBuildFieldsList(SSmlHandle *info, SSchema *schemaField, SHashO
|
|||
field->bytes = getBytes(kv->type, kv->length);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t maxLen = isTag ? TSDB_MAX_TAGS_LEN : TSDB_MAX_BYTES_PER_ROW;
|
||||
int32_t len = 0;
|
||||
for (int j = 0; j < taosArrayGetSize(results); ++j) {
|
||||
SField *field = taosArrayGet(results, j);
|
||||
len += field->bytes;
|
||||
}
|
||||
if(len > maxLen){
|
||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -781,11 +792,15 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
code = smlBuildFieldsList(info, NULL, NULL, sTableData->tags, pTags, 0, true);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList tag1 failed. %s", info->id, pName.tname);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
code = smlBuildFieldsList(info, NULL, NULL, sTableData->cols, pColumns, 0, false);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList col1 failed. %s", info->id, pName.tname);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, NULL, SCHEMA_ACTION_CREATE_STABLE);
|
||||
|
@ -837,6 +852,23 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
pTableMeta->tableInfo.numOfColumns, true);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList tag2 failed. %s", info->id, pName.tname);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (taosArrayGetSize(pTags) + pTableMeta->tableInfo.numOfColumns > TSDB_MAX_COLUMNS) {
|
||||
uError("SML:0x%" PRIx64 " too many columns than 4096", info->id);
|
||||
code = TSDB_CODE_PAR_TOO_MANY_COLUMNS;
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
if (taosArrayGetSize(pTags) > TSDB_MAX_TAGS) {
|
||||
uError("SML:0x%" PRIx64 " too many tags than 128", info->id);
|
||||
code = TSDB_CODE_PAR_INVALID_TAGS_NUM;
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -891,6 +923,16 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
pTableMeta->tableInfo.numOfColumns, false);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList col2 failed. %s", info->id, pName.tname);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (taosArrayGetSize(pColumns) + pTableMeta->tableInfo.numOfTags > TSDB_MAX_COLUMNS) {
|
||||
uError("SML:0x%" PRIx64 " too many columns than 4096", info->id);
|
||||
code = TSDB_CODE_PAR_TOO_MANY_COLUMNS;
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1514,7 +1556,8 @@ static int smlProcess(SSmlHandle *info, char *lines[], char *rawLine, char *rawL
|
|||
|
||||
do {
|
||||
code = smlModifyDBSchemas(info);
|
||||
if (code == 0 || code == TSDB_CODE_SML_INVALID_DATA) break;
|
||||
if (code == 0 || code == TSDB_CODE_SML_INVALID_DATA || code == TSDB_CODE_PAR_TOO_MANY_COLUMNS
|
||||
|| code == TSDB_CODE_PAR_INVALID_TAGS_NUM) break;
|
||||
taosMsleep(100);
|
||||
uInfo("SML:0x%" PRIx64 " smlModifyDBSchemas retry code:%s, times:%d", info->id, tstrerror(code), retryNum);
|
||||
} while (retryNum++ < taosHashGetSize(info->superTables) * MAX_RETRY_TIMES);
|
||||
|
|
|
@ -575,7 +575,7 @@ static int32_t smlConvertJSONString(SSmlKv *pVal, char *typeStr, cJSON *value) {
|
|||
uError("OTD:invalid type(%s) for JSON String", typeStr);
|
||||
return TSDB_CODE_TSC_INVALID_JSON_TYPE;
|
||||
}
|
||||
pVal->length = (int16_t)strlen(value->valuestring);
|
||||
pVal->length = strlen(value->valuestring);
|
||||
|
||||
if (pVal->type == TSDB_DATA_TYPE_BINARY && pVal->length > TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) {
|
||||
return TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN;
|
||||
|
|
|
@ -1409,6 +1409,8 @@ int32_t tDeserializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq
|
|||
return 0;
|
||||
}
|
||||
|
||||
void tFreeSAlterUserReq(SAlterUserReq *pReq) { taosMemoryFreeClear(pReq->tagCond); }
|
||||
|
||||
int32_t tSerializeSGetUserAuthReq(void *buf, int32_t bufLen, SGetUserAuthReq *pReq) {
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
|
@ -1635,6 +1637,7 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs
|
|||
int32_t ref = 0;
|
||||
if (tDecodeI32(pDecoder, &ref) < 0) return -1;
|
||||
taosHashPut(pRsp->useDbs, key, strlen(key), &ref, sizeof(ref));
|
||||
taosMemoryFree(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1831,7 +1834,6 @@ int32_t tSerializeSCreateFuncReq(void *buf, int32_t bufLen, SCreateFuncReq *pReq
|
|||
if (tEncodeCStr(&encoder, pReq->pComment) < 0) return -1;
|
||||
}
|
||||
|
||||
|
||||
if (tEncodeI8(&encoder, pReq->orReplace) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
@ -1876,7 +1878,6 @@ int32_t tDeserializeSCreateFuncReq(void *buf, int32_t bufLen, SCreateFuncReq *pR
|
|||
if (tDecodeCStrTo(&decoder, pReq->pComment) < 0) return -1;
|
||||
}
|
||||
|
||||
|
||||
if (!tDecodeIsEnd(&decoder)) {
|
||||
if (tDecodeI8(&decoder, &pReq->orReplace) < 0) return -1;
|
||||
} else {
|
||||
|
@ -2053,12 +2054,12 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp
|
|||
if (pRsp->pFuncExtraInfos == NULL) return -1;
|
||||
if (tDecodeIsEnd(&decoder)) {
|
||||
for (int32_t i = 0; i < pRsp->numOfFuncs; ++i) {
|
||||
SFuncExtraInfo extraInfo = { 0 };
|
||||
SFuncExtraInfo extraInfo = {0};
|
||||
taosArrayPush(pRsp->pFuncExtraInfos, &extraInfo);
|
||||
}
|
||||
} else {
|
||||
for (int32_t i = 0; i < pRsp->numOfFuncs; ++i) {
|
||||
SFuncExtraInfo extraInfo = { 0 };
|
||||
SFuncExtraInfo extraInfo = {0};
|
||||
if (tDecodeI32(&decoder, &extraInfo.funcVersion) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &extraInfo.funcCreatedTime) < 0) return -1;
|
||||
taosArrayPush(pRsp->pFuncExtraInfos, &extraInfo);
|
||||
|
|
|
@ -390,6 +390,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_INT32(pRaw, dataPos, &ref, _OVER);
|
||||
|
||||
taosHashPut(pUser->useDbs, key, keyLen, &ref, sizeof(ref));
|
||||
taosMemoryFree(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -956,6 +957,7 @@ _OVER:
|
|||
mError("user:%s, failed to alter since %s", alterReq.user, terrstr());
|
||||
}
|
||||
|
||||
tFreeSAlterUserReq(&alterReq);
|
||||
mndReleaseUser(pMnode, pOperUser);
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
mndUserFreeObj(&newUser);
|
||||
|
|
|
@ -323,8 +323,9 @@ int32_t tGnrtDiskData(SDiskDataBuilder *pBuilder, const SDiskData **ppDiskData,
|
|||
#define TSDB_STT_FILE_DATA_ITER 2
|
||||
#define TSDB_TOMB_FILE_DATA_ITER 3
|
||||
|
||||
#define TSDB_FILTER_FLAG_BY_VERSION 0x1
|
||||
#define TSDB_FILTER_FLAG_BY_TABLEID 0x2
|
||||
#define TSDB_FILTER_FLAG_BY_VERSION 0x1
|
||||
#define TSDB_FILTER_FLAG_BY_TABLEID 0x2
|
||||
#define TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE 0x4
|
||||
|
||||
#define TSDB_RBTN_TO_DATA_ITER(pNode) ((STsdbDataIter2 *)(((char *)pNode) - offsetof(STsdbDataIter2, rbtn)))
|
||||
/* open */
|
||||
|
|
|
@ -936,8 +936,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
|||
int tLen = 0;
|
||||
|
||||
if (tdbTbGet(pMeta->pUidIdx, &e.ctbEntry.suid, sizeof(tb_uid_t), &tData, &tLen) == 0) {
|
||||
version = ((SUidIdxVal *)tData)[0].version;
|
||||
STbDbKey tbDbKey = {.uid = e.ctbEntry.suid, .version = version};
|
||||
STbDbKey tbDbKey = {.uid = e.ctbEntry.suid, .version = ((SUidIdxVal *)tData)[0].version};
|
||||
if (tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &tData, &tLen) == 0) {
|
||||
SDecoder tdc = {0};
|
||||
SMetaEntry stbEntry = {0};
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "tsdb.h"
|
||||
#include "vnodeInt.h"
|
||||
|
||||
// STsdbDataIter2
|
||||
/* open */
|
||||
|
@ -202,13 +203,6 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
|
|||
for (;;) {
|
||||
while (pIter->dIter.iRow < pIter->dIter.bData.nRow) {
|
||||
if (pFilterInfo) {
|
||||
if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_TABLEID) {
|
||||
if (pFilterInfo->tbid.uid == pIter->dIter.bData.uid) {
|
||||
pIter->dIter.iRow = pIter->dIter.bData.nRow;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) {
|
||||
if (pIter->dIter.bData.aVersion[pIter->dIter.iRow] < pFilterInfo->sver ||
|
||||
pIter->dIter.bData.aVersion[pIter->dIter.iRow] > pFilterInfo->ever) {
|
||||
|
@ -232,13 +226,6 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
|
|||
|
||||
// filter
|
||||
if (pFilterInfo) {
|
||||
if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_TABLEID) {
|
||||
if (tTABLEIDCmprFn(&pFilterInfo->tbid, &pIter->rowInfo) == 0) {
|
||||
pIter->dIter.iDataBlk = pIter->dIter.mDataBlk.nItem;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) {
|
||||
if (pFilterInfo->sver > dataBlk.maxVer || pFilterInfo->ever < dataBlk.minVer) {
|
||||
pIter->dIter.iDataBlk++;
|
||||
|
@ -262,13 +249,23 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
|
|||
if (pIter->dIter.iBlockIdx < taosArrayGetSize(pIter->dIter.aBlockIdx)) {
|
||||
SBlockIdx* pBlockIdx = taosArrayGet(pIter->dIter.aBlockIdx, pIter->dIter.iBlockIdx);
|
||||
|
||||
if (pFilterInfo && (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_TABLEID)) {
|
||||
int32_t c = tTABLEIDCmprFn(pBlockIdx, &pFilterInfo->tbid);
|
||||
if (c == 0) {
|
||||
pIter->dIter.iBlockIdx++;
|
||||
continue;
|
||||
} else if (c < 0) {
|
||||
ASSERT(0);
|
||||
if (pFilterInfo) {
|
||||
if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_TABLEID) {
|
||||
int32_t c = tTABLEIDCmprFn(pBlockIdx, &pFilterInfo->tbid);
|
||||
if (c == 0) {
|
||||
pIter->dIter.iBlockIdx++;
|
||||
continue;
|
||||
} else if (c < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (pFilterInfo->flag & TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE) {
|
||||
SMetaInfo info;
|
||||
if (metaGetInfo(pIter->dIter.pReader->pTsdb->pVnode->pMeta, pBlockIdx->uid, &info, NULL)) {
|
||||
pIter->dIter.iBlockIdx++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,14 +301,24 @@ static int32_t tsdbSttFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* p
|
|||
for (;;) {
|
||||
while (pIter->sIter.iRow < pIter->sIter.bData.nRow) {
|
||||
if (pFilterInfo) {
|
||||
int64_t uid = pIter->sIter.bData.uid ? pIter->sIter.bData.uid : pIter->sIter.bData.aUid[pIter->sIter.iRow];
|
||||
if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_TABLEID) {
|
||||
int64_t uid = pIter->sIter.bData.uid ? pIter->sIter.bData.uid : pIter->sIter.bData.aUid[pIter->sIter.iRow];
|
||||
if (pFilterInfo->tbid.uid == uid) {
|
||||
pIter->sIter.iRow++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (pFilterInfo->flag & TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE) {
|
||||
if (pIter->rowInfo.uid != uid) {
|
||||
SMetaInfo info;
|
||||
if (metaGetInfo(pIter->sIter.pReader->pTsdb->pVnode->pMeta, uid, &info, NULL)) {
|
||||
pIter->sIter.iRow++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) {
|
||||
if (pFilterInfo->sver > pIter->sIter.bData.aVersion[pIter->sIter.iRow] ||
|
||||
pFilterInfo->ever < pIter->sIter.bData.aVersion[pIter->sIter.iRow]) {
|
||||
|
@ -395,6 +402,16 @@ static int32_t tsdbTombFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
|
|||
if (pIter->tIter.iDelIdx < taosArrayGetSize(pIter->tIter.aDelIdx)) {
|
||||
SDelIdx* pDelIdx = taosArrayGet(pIter->tIter.aDelIdx, pIter->tIter.iDelIdx);
|
||||
|
||||
if (pFilterInfo) {
|
||||
if (pFilterInfo->flag & TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE) {
|
||||
SMetaInfo info;
|
||||
if (metaGetInfo(pIter->dIter.pReader->pTsdb->pVnode->pMeta, pDelIdx->uid, &info, NULL)) {
|
||||
pIter->tIter.iDelIdx++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
code = tsdbReadDelData(pIter->tIter.pReader, pDelIdx, pIter->tIter.aDelData);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
|
|
|
@ -70,10 +70,11 @@ static int32_t tsdbSnapReadFileDataStart(STsdbSnapReader* pReader) {
|
|||
|
||||
if (pReader->pIter) {
|
||||
// iter to next with filter info (sver, ever)
|
||||
code = tsdbDataIterNext2(pReader->pIter,
|
||||
&(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION, // flag
|
||||
.sver = pReader->sver,
|
||||
.ever = pReader->ever});
|
||||
code = tsdbDataIterNext2(
|
||||
pReader->pIter,
|
||||
&(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION | TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE, // flag
|
||||
.sver = pReader->sver,
|
||||
.ever = pReader->ever});
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
if (pReader->pIter->rowInfo.suid || pReader->pIter->rowInfo.uid) {
|
||||
|
@ -94,10 +95,11 @@ static int32_t tsdbSnapReadFileDataStart(STsdbSnapReader* pReader) {
|
|||
|
||||
if (pReader->pIter) {
|
||||
// iter to valid row
|
||||
code = tsdbDataIterNext2(pReader->pIter,
|
||||
&(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION, // flag
|
||||
.sver = pReader->sver,
|
||||
.ever = pReader->ever});
|
||||
code = tsdbDataIterNext2(
|
||||
pReader->pIter,
|
||||
&(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION | TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE, // flag
|
||||
.sver = pReader->sver,
|
||||
.ever = pReader->ever});
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
if (pReader->pIter->rowInfo.suid || pReader->pIter->rowInfo.uid) {
|
||||
|
@ -139,7 +141,8 @@ static int32_t tsdbSnapReadNextRow(STsdbSnapReader* pReader, SRowInfo** ppRowInf
|
|||
int32_t lino = 0;
|
||||
|
||||
if (pReader->pIter) {
|
||||
code = tsdbDataIterNext2(pReader->pIter, &(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION, // flag
|
||||
code = tsdbDataIterNext2(pReader->pIter, &(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION |
|
||||
TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE, // flag
|
||||
.sver = pReader->sver,
|
||||
.ever = pReader->ever});
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
@ -346,8 +349,9 @@ static int32_t tsdbSnapReadNextTombData(STsdbSnapReader* pReader, SDelInfo** ppD
|
|||
int32_t lino = 0;
|
||||
|
||||
code = tsdbDataIterNext2(
|
||||
pReader->pTIter,
|
||||
&(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION, .sver = pReader->sver, .ever = pReader->ever});
|
||||
pReader->pTIter, &(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION | TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE,
|
||||
.sver = pReader->sver,
|
||||
.ever = pReader->ever});
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
if (ppDelInfo) {
|
||||
|
|
|
@ -1107,9 +1107,10 @@ int32_t tBlockDataInit(SBlockData *pBlockData, TABLEID *pId, STSchema *pTSchema,
|
|||
int32_t iColumn = 1;
|
||||
STColumn *pTColumn = &pTSchema->columns[iColumn];
|
||||
for (int32_t iCid = 0; iCid < nCid; iCid++) {
|
||||
if (ASSERTS(pTColumn != NULL, "invalid input param")) {
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
goto _exit;
|
||||
|
||||
// aCid array (from taos client catalog) contains columns that does not exist in the pTSchema. the pTSchema is newer
|
||||
if (pTColumn == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
while (pTColumn->colId < aCid[iCid]) {
|
||||
|
@ -1118,9 +1119,8 @@ int32_t tBlockDataInit(SBlockData *pBlockData, TABLEID *pId, STSchema *pTSchema,
|
|||
pTColumn = &pTSchema->columns[iColumn];
|
||||
}
|
||||
|
||||
if (ASSERTS(pTColumn->colId == aCid[iCid], "invalid input param")) {
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
goto _exit;
|
||||
if (pTColumn->colId != aCid[iCid]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tColDataInit(&pBlockData->aColData[iCid], pTColumn->colId, pTColumn->type,
|
||||
|
|
|
@ -58,6 +58,7 @@ typedef enum {
|
|||
CTG_CI_OTHERTABLE_META,
|
||||
CTG_CI_TBL_SMA,
|
||||
CTG_CI_TBL_CFG,
|
||||
CTG_CI_TBL_TAG,
|
||||
CTG_CI_INDEX_INFO,
|
||||
CTG_CI_USER,
|
||||
CTG_CI_UDF,
|
||||
|
@ -110,6 +111,7 @@ typedef enum {
|
|||
CTG_TASK_GET_SVR_VER,
|
||||
CTG_TASK_GET_TB_META_BATCH,
|
||||
CTG_TASK_GET_TB_HASH_BATCH,
|
||||
CTG_TASK_GET_TB_TAG,
|
||||
} CTG_TASK_TYPE;
|
||||
|
||||
typedef enum {
|
||||
|
@ -152,6 +154,11 @@ typedef struct SCtgTbCacheInfo {
|
|||
int32_t tbType;
|
||||
} SCtgTbCacheInfo;
|
||||
|
||||
typedef struct SCtgTbMetaParam {
|
||||
SName* pName;
|
||||
int32_t flag;
|
||||
} SCtgTbMetaParam;
|
||||
|
||||
typedef struct SCtgTbMetaCtx {
|
||||
SCtgTbCacheInfo tbInfo;
|
||||
int32_t vgId;
|
||||
|
@ -186,6 +193,11 @@ typedef struct SCtgTbCfgCtx {
|
|||
SVgroupInfo* pVgInfo;
|
||||
} SCtgTbCfgCtx;
|
||||
|
||||
typedef struct SCtgTbTagCtx {
|
||||
SName* pName;
|
||||
SVgroupInfo* pVgInfo;
|
||||
} SCtgTbTagCtx;
|
||||
|
||||
typedef struct SCtgDbVgCtx {
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
} SCtgDbVgCtx;
|
||||
|
@ -304,6 +316,7 @@ typedef struct SCtgJob {
|
|||
catalogCallback userFp;
|
||||
int32_t tbMetaNum;
|
||||
int32_t tbHashNum;
|
||||
int32_t tbTagNum;
|
||||
int32_t dbVgNum;
|
||||
int32_t udfNum;
|
||||
int32_t qnodeNum;
|
||||
|
@ -346,6 +359,7 @@ typedef struct SCtgSubRes {
|
|||
|
||||
struct SCtgTask {
|
||||
CTG_TASK_TYPE type;
|
||||
bool subTask;
|
||||
int32_t taskId;
|
||||
SCtgJob* pJob;
|
||||
void* taskCtx;
|
||||
|
@ -623,6 +637,7 @@ typedef struct SCtgCacheItemInfo {
|
|||
#define CTG_FLAG_SYS_DB 0x8
|
||||
#define CTG_FLAG_FORCE_UPDATE 0x10
|
||||
#define CTG_FLAG_ONLY_CACHE 0x20
|
||||
#define CTG_FLAG_SYNC_OP 0x40
|
||||
|
||||
#define CTG_FLAG_SET(_flag, _v) ((_flag) |= (_v))
|
||||
|
||||
|
@ -925,6 +940,10 @@ void ctgReleaseVgMetaToCache(SCatalog* pCtg, SCtgDBCache* dbCache, SCtgTbCach
|
|||
void ctgReleaseTbMetaToCache(SCatalog* pCtg, SCtgDBCache* dbCache, SCtgTbCache* pCache);
|
||||
void ctgGetGlobalCacheStat(SCtgCacheStat* pStat);
|
||||
int32_t ctgChkSetAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res);
|
||||
int32_t ctgGetTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta);
|
||||
int32_t ctgGetCachedStbNameFromSuid(SCatalog* pCtg, char* dbFName, uint64_t suid, char **stbName);
|
||||
int32_t ctgGetTbTagCb(SCtgTask* pTask);
|
||||
int32_t ctgGetUserCb(SCtgTask* pTask);
|
||||
|
||||
extern SCatalogMgmt gCtgMgmt;
|
||||
extern SCtgDebug gCTGDebug;
|
||||
|
|
|
@ -208,7 +208,7 @@ int32_t ctgGetTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx
|
|||
}
|
||||
|
||||
while (true) {
|
||||
CTG_ERR_JRET(ctgRefreshTbMeta(pCtg, pConn, ctx, &output, false));
|
||||
CTG_ERR_JRET(ctgRefreshTbMeta(pCtg, pConn, ctx, &output, ctx->flag & CTG_FLAG_SYNC_OP));
|
||||
|
||||
if (CTG_IS_META_TABLE(output->metaType)) {
|
||||
*pTableMeta = output->tbMeta;
|
||||
|
@ -429,6 +429,48 @@ int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName,
|
|||
CTG_RET(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t ctgGetTbTag(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, SArray** pRes) {
|
||||
SVgroupInfo vgroupInfo = {0};
|
||||
STableCfg* pCfg = NULL;
|
||||
int32_t code = 0;
|
||||
|
||||
CTG_ERR_RET(ctgGetTbHashVgroup(pCtg, pConn, pTableName, &vgroupInfo, NULL));
|
||||
CTG_ERR_RET(ctgGetTableCfgFromVnode(pCtg, pConn, pTableName, &vgroupInfo, &pCfg, NULL));
|
||||
|
||||
if (NULL == pCfg->pTags || pCfg->tagsLen <= 0) {
|
||||
ctgError("invalid tag in tbCfg rsp, pTags:%p, len:%d", pCfg->pTags, pCfg->tagsLen);
|
||||
CTG_ERR_JRET(TSDB_CODE_INVALID_MSG);
|
||||
}
|
||||
|
||||
SArray* pTagVals = NULL;
|
||||
STag* pTag = (STag*)pCfg->pTags;
|
||||
|
||||
if (tTagIsJson(pTag)) {
|
||||
pTagVals = taosArrayInit(1, sizeof(STagVal));
|
||||
if (NULL == pTagVals) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
char* pJson = parseTagDatatoJson(pTag);
|
||||
STagVal tagVal;
|
||||
tagVal.cid = 0;
|
||||
tagVal.type = TSDB_DATA_TYPE_JSON;
|
||||
tagVal.pData = pJson;
|
||||
tagVal.nData = strlen(pJson);
|
||||
taosArrayPush(pTagVals, &tagVal);
|
||||
} else {
|
||||
CTG_ERR_JRET(tTagToValArray((const STag*)pCfg->pTags, &pTagVals));
|
||||
}
|
||||
|
||||
*pRes = pTagVals;
|
||||
|
||||
_return:
|
||||
|
||||
tFreeSTableCfgRsp((STableCfgRsp*)pCfg);
|
||||
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, SArray** pVgList) {
|
||||
STableMeta* tbMeta = NULL;
|
||||
int32_t code = 0;
|
||||
|
@ -1414,6 +1456,21 @@ _return:
|
|||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
int32_t catalogGetTableTag(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
if (NULL == pCtg || NULL == pConn || NULL == pTableName || NULL == pRes) {
|
||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||
}
|
||||
|
||||
int32_t code = 0;
|
||||
CTG_ERR_JRET(ctgGetTbTag(pCtg, pConn, (SName*)pTableName, pRes));
|
||||
|
||||
_return:
|
||||
|
||||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableCfg** pCfg) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
#include "trpc.h"
|
||||
|
||||
int32_t ctgInitGetTbMetaTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
|
||||
SName* name = (SName*)param;
|
||||
SCtgTbMetaParam* pParam = (SCtgTbMetaParam*)param;
|
||||
SName* name = pParam->pName;
|
||||
SCtgTask task = {0};
|
||||
|
||||
task.type = CTG_TASK_GET_TB_META;
|
||||
|
@ -41,7 +42,7 @@ int32_t ctgInitGetTbMetaTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
|
|||
}
|
||||
|
||||
memcpy(ctx->pName, name, sizeof(*name));
|
||||
ctx->flag = CTG_FLAG_UNKNOWN_STB;
|
||||
ctx->flag = pParam->flag | CTG_FLAG_UNKNOWN_STB;
|
||||
|
||||
taosArrayPush(pJob->pTasks, &task);
|
||||
|
||||
|
@ -386,6 +387,37 @@ int32_t ctgInitGetTbCfgTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgInitGetTbTagTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
|
||||
SName* name = (SName*)param;
|
||||
SCtgTask task = {0};
|
||||
|
||||
task.type = CTG_TASK_GET_TB_TAG;
|
||||
task.taskId = taskIdx;
|
||||
task.pJob = pJob;
|
||||
|
||||
task.taskCtx = taosMemoryCalloc(1, sizeof(SCtgTbTagCtx));
|
||||
if (NULL == task.taskCtx) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
SCtgTbTagCtx* ctx = task.taskCtx;
|
||||
ctx->pName = taosMemoryMalloc(sizeof(*name));
|
||||
if (NULL == ctx->pName) {
|
||||
taosMemoryFree(task.taskCtx);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
memcpy(ctx->pName, name, sizeof(*name));
|
||||
|
||||
taosArrayPush(pJob->pTasks, &task);
|
||||
|
||||
qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, tbName:%s", pJob->queryId, taskIdx,
|
||||
ctgTaskTypeStr(task.type), name->tname);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, const SCatalogReq* pReq) {
|
||||
SHashObj* pDb = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||
SHashObj* pTb = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||
|
@ -437,6 +469,15 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, con
|
|||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(name, dbFName);
|
||||
taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN);
|
||||
taosHashPut(pTb, name, sizeof(SName), name, sizeof(SName));
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < pJob->tbTagNum; ++i) {
|
||||
SName* name = taosArrayGet(pReq->pTableTag, i);
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(name, dbFName);
|
||||
taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN);
|
||||
taosHashPut(pTb, name, sizeof(SName), name, sizeof(SName));
|
||||
}
|
||||
|
||||
char* dbFName = taosHashIterate(pDb, NULL);
|
||||
|
@ -505,9 +546,10 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
|
|||
int32_t dbInfoNum = (int32_t)taosArrayGetSize(pReq->pDbInfo);
|
||||
int32_t tbIndexNum = (int32_t)taosArrayGetSize(pReq->pTableIndex);
|
||||
int32_t tbCfgNum = (int32_t)taosArrayGetSize(pReq->pTableCfg);
|
||||
int32_t tbTagNum = (int32_t)taosArrayGetSize(pReq->pTableTag);
|
||||
|
||||
int32_t taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dnodeNum + svrVerNum + dbCfgNum + indexNum +
|
||||
userNum + dbInfoNum + tbIndexNum + tbCfgNum;
|
||||
userNum + dbInfoNum + tbIndexNum + tbCfgNum + tbTagNum;
|
||||
|
||||
*job = taosMemoryCalloc(1, sizeof(SCtgJob));
|
||||
if (NULL == *job) {
|
||||
|
@ -537,6 +579,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
|
|||
pJob->tbIndexNum = tbIndexNum;
|
||||
pJob->tbCfgNum = tbCfgNum;
|
||||
pJob->svrVerNum = svrVerNum;
|
||||
pJob->tbTagNum = tbTagNum;
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
pJob->pBatchs =
|
||||
|
@ -604,6 +647,12 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
|
|||
CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TB_CFG, name, NULL));
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < tbTagNum; ++i) {
|
||||
SName* name = taosArrayGet(pReq->pTableTag, i);
|
||||
CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TB_TAG, name, NULL));
|
||||
}
|
||||
|
||||
|
||||
for (int32_t i = 0; i < indexNum; ++i) {
|
||||
char* indexName = taosArrayGet(pReq->pIndex, i);
|
||||
CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_INDEX_INFO, indexName, NULL));
|
||||
|
@ -650,6 +699,10 @@ _return:
|
|||
}
|
||||
|
||||
int32_t ctgDumpTbMetaRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pTableMeta) {
|
||||
pJob->jobRes.pTableMeta = taosArrayInit(pJob->tbMetaNum, sizeof(SMetaRes));
|
||||
|
@ -665,6 +718,10 @@ int32_t ctgDumpTbMetaRes(SCtgTask* pTask) {
|
|||
}
|
||||
|
||||
int32_t ctgDumpTbMetasRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
|
||||
pJob->jobRes.pTableMeta = pTask->res;
|
||||
|
@ -673,6 +730,10 @@ int32_t ctgDumpTbMetasRes(SCtgTask* pTask) {
|
|||
}
|
||||
|
||||
int32_t ctgDumpDbVgRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pDbVgroup) {
|
||||
pJob->jobRes.pDbVgroup = taosArrayInit(pJob->dbVgNum, sizeof(SMetaRes));
|
||||
|
@ -688,6 +749,10 @@ int32_t ctgDumpDbVgRes(SCtgTask* pTask) {
|
|||
}
|
||||
|
||||
int32_t ctgDumpTbHashRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pTableHash) {
|
||||
pJob->jobRes.pTableHash = taosArrayInit(pJob->tbHashNum, sizeof(SMetaRes));
|
||||
|
@ -703,6 +768,10 @@ int32_t ctgDumpTbHashRes(SCtgTask* pTask) {
|
|||
}
|
||||
|
||||
int32_t ctgDumpTbHashsRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
|
||||
pJob->jobRes.pTableHash = pTask->res;
|
||||
|
@ -711,9 +780,17 @@ int32_t ctgDumpTbHashsRes(SCtgTask* pTask) {
|
|||
}
|
||||
|
||||
int32_t ctgDumpTbIndexRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pTableIndex) {
|
||||
pJob->jobRes.pTableIndex = taosArrayInit(pJob->tbIndexNum, sizeof(SMetaRes));
|
||||
SArray* pRes = taosArrayInit(pJob->tbIndexNum, sizeof(SMetaRes));
|
||||
if (atomic_val_compare_exchange_ptr(&pJob->jobRes.pTableIndex, NULL, pRes)) {
|
||||
taosArrayDestroy(pRes);
|
||||
}
|
||||
|
||||
if (NULL == pJob->jobRes.pTableIndex) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -726,9 +803,17 @@ int32_t ctgDumpTbIndexRes(SCtgTask* pTask) {
|
|||
}
|
||||
|
||||
int32_t ctgDumpTbCfgRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pTableCfg) {
|
||||
pJob->jobRes.pTableCfg = taosArrayInit(pJob->tbCfgNum, sizeof(SMetaRes));
|
||||
SArray* pRes = taosArrayInit(pJob->tbCfgNum, sizeof(SMetaRes));
|
||||
if (atomic_val_compare_exchange_ptr(&pJob->jobRes.pTableCfg, NULL, pRes)) {
|
||||
taosArrayDestroy(pRes);
|
||||
}
|
||||
|
||||
if (NULL == pJob->jobRes.pTableCfg) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -740,7 +825,35 @@ int32_t ctgDumpTbCfgRes(SCtgTask* pTask) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgDumpTbTagRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pTableTag) {
|
||||
SArray* pRes = taosArrayInit(pJob->tbTagNum, sizeof(SMetaRes));
|
||||
if (atomic_val_compare_exchange_ptr(&pJob->jobRes.pTableTag, NULL, pRes)) {
|
||||
taosArrayDestroy(pRes);
|
||||
}
|
||||
|
||||
if (NULL == pJob->jobRes.pTableTag) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
SMetaRes res = {.code = pTask->code, .pRes = pTask->res};
|
||||
taosArrayPush(pJob->jobRes.pTableTag, &res);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgDumpIndexRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pIndex) {
|
||||
pJob->jobRes.pIndex = taosArrayInit(pJob->indexNum, sizeof(SMetaRes));
|
||||
|
@ -756,6 +869,10 @@ int32_t ctgDumpIndexRes(SCtgTask* pTask) {
|
|||
}
|
||||
|
||||
int32_t ctgDumpQnodeRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pQnodeList) {
|
||||
pJob->jobRes.pQnodeList = taosArrayInit(1, sizeof(SMetaRes));
|
||||
|
@ -771,6 +888,10 @@ int32_t ctgDumpQnodeRes(SCtgTask* pTask) {
|
|||
}
|
||||
|
||||
int32_t ctgDumpDnodeRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pDnodeList) {
|
||||
pJob->jobRes.pDnodeList = taosArrayInit(1, sizeof(SMetaRes));
|
||||
|
@ -786,6 +907,10 @@ int32_t ctgDumpDnodeRes(SCtgTask* pTask) {
|
|||
}
|
||||
|
||||
int32_t ctgDumpDbCfgRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pDbCfg) {
|
||||
pJob->jobRes.pDbCfg = taosArrayInit(pJob->dbCfgNum, sizeof(SMetaRes));
|
||||
|
@ -801,6 +926,10 @@ int32_t ctgDumpDbCfgRes(SCtgTask* pTask) {
|
|||
}
|
||||
|
||||
int32_t ctgDumpDbInfoRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pDbInfo) {
|
||||
pJob->jobRes.pDbInfo = taosArrayInit(pJob->dbInfoNum, sizeof(SMetaRes));
|
||||
|
@ -816,6 +945,10 @@ int32_t ctgDumpDbInfoRes(SCtgTask* pTask) {
|
|||
}
|
||||
|
||||
int32_t ctgDumpUdfRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pUdfList) {
|
||||
pJob->jobRes.pUdfList = taosArrayInit(pJob->udfNum, sizeof(SMetaRes));
|
||||
|
@ -831,6 +964,10 @@ int32_t ctgDumpUdfRes(SCtgTask* pTask) {
|
|||
}
|
||||
|
||||
int32_t ctgDumpUserRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pUser) {
|
||||
pJob->jobRes.pUser = taosArrayInit(pJob->userNum, sizeof(SMetaRes));
|
||||
|
@ -846,6 +983,10 @@ int32_t ctgDumpUserRes(SCtgTask* pTask) {
|
|||
}
|
||||
|
||||
int32_t ctgDumpSvrVer(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pSvrVer) {
|
||||
pJob->jobRes.pSvrVer = taosMemoryCalloc(1, sizeof(SMetaRes));
|
||||
|
@ -1075,7 +1216,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf
|
|||
|
||||
STableMetaOutput* pOut = (STableMetaOutput*)pMsgCtx->out;
|
||||
|
||||
ctgUpdateTbMetaToCache(pCtg, pOut, false);
|
||||
ctgUpdateTbMetaToCache(pCtg, pOut, flag & CTG_FLAG_SYNC_OP);
|
||||
|
||||
if (CTG_IS_META_BOTH(pOut->metaType)) {
|
||||
memcpy(pOut->tbMeta, &pOut->ctbMeta, sizeof(pOut->ctbMeta));
|
||||
|
@ -1473,6 +1614,49 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgHandleGetTbTagRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) {
|
||||
int32_t code = 0;
|
||||
SCtgTask* pTask = tReq->pTask;
|
||||
SCatalog* pCtg = pTask->pJob->pCtg;
|
||||
CTG_ERR_JRET(ctgProcessRspMsg(&pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target));
|
||||
|
||||
STableCfgRsp* pRsp = (STableCfgRsp*)pTask->msgCtx.out;
|
||||
if (NULL == pRsp->pTags || pRsp->tagsLen <= 0) {
|
||||
ctgError("invalid tag in tbCfg rsp, pTags:%p, len:%d", pRsp->pTags, pRsp->tagsLen);
|
||||
CTG_ERR_JRET(TSDB_CODE_INVALID_MSG);
|
||||
}
|
||||
|
||||
SArray* pTagVals = NULL;
|
||||
STag* pTag = (STag*)pRsp->pTags;
|
||||
|
||||
if (tTagIsJson(pTag)) {
|
||||
pTagVals = taosArrayInit(1, sizeof(STagVal));
|
||||
if (NULL == pTagVals) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
char* pJson = parseTagDatatoJson(pTag);
|
||||
STagVal tagVal;
|
||||
tagVal.cid = 0;
|
||||
tagVal.type = TSDB_DATA_TYPE_JSON;
|
||||
tagVal.pData = pJson;
|
||||
tagVal.nData = strlen(pJson);
|
||||
taosArrayPush(pTagVals, &tagVal);
|
||||
} else {
|
||||
CTG_ERR_JRET(tTagToValArray((const STag*)pRsp->pTags, &pTagVals));
|
||||
}
|
||||
|
||||
pTask->res = pTagVals;
|
||||
|
||||
_return:
|
||||
|
||||
ctgHandleTaskEnd(pTask, code);
|
||||
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgHandleGetDbCfgRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) {
|
||||
int32_t code = 0;
|
||||
SCtgTask* pTask = tReq->pTask;
|
||||
|
@ -1905,7 +2089,10 @@ int32_t ctgLaunchGetTbCfgTask(SCtgTask* pTask) {
|
|||
if (pCtx->tbType <= 0) {
|
||||
CTG_ERR_JRET(ctgReadTbTypeFromCache(pCtg, dbFName, pCtx->pName->tname, &pCtx->tbType));
|
||||
if (pCtx->tbType <= 0) {
|
||||
CTG_ERR_JRET(ctgLaunchSubTask(pTask, CTG_TASK_GET_TB_META, ctgGetTbCfgCb, pCtx->pName));
|
||||
SCtgTbMetaParam param;
|
||||
param.pName = pCtx->pName;
|
||||
param.flag = 0;
|
||||
CTG_ERR_JRET(ctgLaunchSubTask(pTask, CTG_TASK_GET_TB_META, ctgGetTbCfgCb, ¶m));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -1935,6 +2122,45 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgLaunchGetTbTagTask(SCtgTask* pTask) {
|
||||
int32_t code = 0;
|
||||
SCatalog* pCtg = pTask->pJob->pCtg;
|
||||
SRequestConnInfo* pConn = &pTask->pJob->conn;
|
||||
SCtgTbTagCtx* pCtx = (SCtgTbTagCtx*)pTask->taskCtx;
|
||||
SArray* pRes = NULL;
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(pCtx->pName, dbFName);
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1);
|
||||
if (NULL == pMsgCtx->pBatchs) {
|
||||
pMsgCtx->pBatchs = pJob->pBatchs;
|
||||
}
|
||||
|
||||
if (NULL == pCtx->pVgInfo) {
|
||||
CTG_ERR_JRET(ctgGetTbHashVgroupFromCache(pCtg, pCtx->pName, &pCtx->pVgInfo));
|
||||
if (NULL == pCtx->pVgInfo) {
|
||||
CTG_ERR_JRET(ctgLaunchSubTask(pTask, CTG_TASK_GET_DB_VGROUP, ctgGetTbTagCb, dbFName));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
CTG_CACHE_NHIT_INC(CTG_CI_TBL_TAG, 1);
|
||||
|
||||
CTG_ERR_JRET(ctgGetTableCfgFromVnode(pCtg, pConn, pCtx->pName, pCtx->pVgInfo, NULL, pTask));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_return:
|
||||
|
||||
if (CTG_TASK_LAUNCHED == pTask->status) {
|
||||
ctgHandleTaskEnd(pTask, code);
|
||||
}
|
||||
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgLaunchGetQnodeTask(SCtgTask* pTask) {
|
||||
SCatalog* pCtg = pTask->pJob->pCtg;
|
||||
SRequestConnInfo* pConn = &pTask->pJob->conn;
|
||||
|
@ -2077,6 +2303,8 @@ int32_t ctgLaunchGetUserTask(SCtgTask* pTask) {
|
|||
if (inCache) {
|
||||
pTask->res = rsp.pRawRes;
|
||||
|
||||
ctgTaskDebug("Final res got, pass:%d, pCond:%p", rsp.pRawRes->pass, rsp.pRawRes->pCond);
|
||||
|
||||
CTG_ERR_RET(ctgHandleTaskEnd(pTask, 0));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -2084,7 +2312,10 @@ int32_t ctgLaunchGetUserTask(SCtgTask* pTask) {
|
|||
taosMemoryFreeClear(rsp.pRawRes);
|
||||
|
||||
if (rsp.metaNotExists) {
|
||||
CTG_ERR_RET(ctgLaunchSubTask(pTask, CTG_TASK_GET_TB_META, ctgGetTbCfgCb, &pCtx->user.tbName));
|
||||
SCtgTbMetaParam param;
|
||||
param.pName = &pCtx->user.tbName;
|
||||
param.flag = CTG_FLAG_SYNC_OP;
|
||||
CTG_ERR_RET(ctgLaunchSubTask(pTask, CTG_TASK_GET_TB_META, ctgGetUserCb, ¶m));
|
||||
} else {
|
||||
CTG_ERR_RET(ctgGetUserDbAuthFromMnode(pCtg, pConn, pCtx->user.user, NULL, pTask));
|
||||
}
|
||||
|
@ -2138,6 +2369,27 @@ _return:
|
|||
CTG_RET(ctgHandleTaskEnd(pTask, pTask->subRes.code));
|
||||
}
|
||||
|
||||
int32_t ctgGetTbTagCb(SCtgTask* pTask) {
|
||||
int32_t code = 0;
|
||||
|
||||
CTG_ERR_JRET(pTask->subRes.code);
|
||||
|
||||
SCtgTbTagCtx* pCtx = (SCtgTbTagCtx*)pTask->taskCtx;
|
||||
SDBVgInfo* pDb = (SDBVgInfo*)pTask->subRes.res;
|
||||
|
||||
if (NULL == pCtx->pVgInfo) {
|
||||
pCtx->pVgInfo = taosMemoryCalloc(1, sizeof(SVgroupInfo));
|
||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pTask->pJob->pCtg, pDb, pCtx->pName, pCtx->pVgInfo));
|
||||
}
|
||||
|
||||
CTG_RET(ctgLaunchGetTbTagTask(pTask));
|
||||
|
||||
_return:
|
||||
|
||||
CTG_RET(ctgHandleTaskEnd(pTask, pTask->subRes.code));
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t ctgGetUserCb(SCtgTask* pTask) {
|
||||
int32_t code = 0;
|
||||
|
@ -2162,8 +2414,12 @@ int32_t ctgCompDbVgTasks(SCtgTask* pTask, void* param, bool* equal) {
|
|||
|
||||
int32_t ctgCompTbMetaTasks(SCtgTask* pTask, void* param, bool* equal) {
|
||||
SCtgTbMetaCtx* ctx = pTask->taskCtx;
|
||||
SCtgTbMetaParam* pParam = (SCtgTbMetaParam*)param;
|
||||
|
||||
*equal = tNameTbNameEqual(ctx->pName, (SName*)param);
|
||||
*equal = tNameTbNameEqual(ctx->pName, (SName*)pParam->pName);
|
||||
if (*equal) {
|
||||
ctx->flag |= pParam->flag;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -2197,6 +2453,7 @@ SCtgAsyncFps gCtgAsyncFps[] = {
|
|||
{ctgInitGetSvrVerTask, ctgLaunchGetSvrVerTask, ctgHandleGetSvrVerRsp, ctgDumpSvrVer, NULL, NULL},
|
||||
{ctgInitGetTbMetasTask, ctgLaunchGetTbMetasTask, ctgHandleGetTbMetasRsp, ctgDumpTbMetasRes, NULL, NULL},
|
||||
{ctgInitGetTbHashsTask, ctgLaunchGetTbHashsTask, ctgHandleGetTbHashsRsp, ctgDumpTbHashsRes, NULL, NULL},
|
||||
{ctgInitGetTbTagTask, ctgLaunchGetTbTagTask, ctgHandleGetTbTagRsp, ctgDumpTbTagRes, NULL, NULL},
|
||||
};
|
||||
|
||||
int32_t ctgMakeAsyncRes(SCtgJob* pJob) {
|
||||
|
@ -2284,6 +2541,9 @@ int32_t ctgLaunchSubTask(SCtgTask* pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp,
|
|||
}
|
||||
|
||||
SCtgTask* pSub = taosArrayGet(pJob->pTasks, subTaskId);
|
||||
if (newTask) {
|
||||
pSub->subTask = true;
|
||||
}
|
||||
|
||||
CTG_ERR_RET(ctgSetSubTaskCb(pSub, pTask));
|
||||
|
||||
|
|
|
@ -703,7 +703,31 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgGetCachedStbNameFromSuid(SCatalog* pCtg, char* dbFName, uint64_t suid, char **stbName) {
|
||||
*stbName = NULL;
|
||||
|
||||
SCtgDBCache *dbCache = NULL;
|
||||
ctgAcquireDBCache(pCtg, dbFName, &dbCache);
|
||||
if (NULL == dbCache) {
|
||||
ctgDebug("db %s not in cache", dbFName);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
char *stb = taosHashAcquire(dbCache->stbCache, &suid, sizeof(suid));
|
||||
if (NULL == stb) {
|
||||
ctgDebug("stb 0x%" PRIx64 " not in cache, dbFName:%s", suid, dbFName);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
*stbName = taosStrdup(stb);
|
||||
|
||||
taosHashRelease(dbCache->stbCache, stb);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgChkAuthFromCache(SCatalog *pCtg, SUserAuthInfo *pReq, bool *inCache, SCtgAuthRsp *pRes) {
|
||||
int32_t code = 0;
|
||||
if (IS_SYS_DBNAME(pReq->tbName.dbname)) {
|
||||
*inCache = true;
|
||||
pRes->pRawRes->pass = true;
|
||||
|
@ -728,7 +752,7 @@ int32_t ctgChkAuthFromCache(SCatalog *pCtg, SUserAuthInfo *pReq, bool *inCache,
|
|||
|
||||
CTG_LOCK(CTG_READ, &pUser->lock);
|
||||
memcpy(&req.authInfo, &pUser->userAuth, sizeof(pUser->userAuth));
|
||||
int32_t code = ctgChkSetAuthRes(pCtg, &req, pRes);
|
||||
code = ctgChkSetAuthRes(pCtg, &req, pRes);
|
||||
CTG_UNLOCK(CTG_READ, &pUser->lock);
|
||||
CTG_ERR_JRET(code);
|
||||
|
||||
|
@ -742,8 +766,9 @@ _return:
|
|||
|
||||
*inCache = false;
|
||||
CTG_CACHE_NHIT_INC(CTG_CI_USER, 1);
|
||||
ctgDebug("Get user from cache failed, user:%s, metaNotExists:%d, code:%d", pReq->user, pRes->metaNotExists, code);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
void ctgDequeue(SCtgCacheOperation **op) {
|
||||
|
|
|
@ -170,6 +170,9 @@ void ctgFreeSMetaData(SMetaData* pData) {
|
|||
taosArrayDestroy(pData->pTableCfg);
|
||||
pData->pTableCfg = NULL;
|
||||
|
||||
taosArrayDestroy(pData->pTableTag);
|
||||
pData->pTableTag = NULL;
|
||||
|
||||
taosMemoryFreeClear(pData->pSvrVer);
|
||||
}
|
||||
|
||||
|
@ -486,6 +489,18 @@ void ctgFreeBatchHash(void* hash) {
|
|||
taosMemoryFreeClear(pRes->pRes);
|
||||
}
|
||||
|
||||
void ctgFreeJsonTagVal(void* val) {
|
||||
if (NULL == val) {
|
||||
return;
|
||||
}
|
||||
|
||||
STagVal* pVal = (STagVal*)val;
|
||||
|
||||
if (TSDB_DATA_TYPE_JSON == pVal->type) {
|
||||
taosMemoryFree(pVal->pData);
|
||||
}
|
||||
}
|
||||
|
||||
void ctgFreeTaskRes(CTG_TASK_TYPE type, void** pRes) {
|
||||
switch (type) {
|
||||
case CTG_TASK_GET_QNODE:
|
||||
|
@ -516,16 +531,32 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void** pRes) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case CTG_TASK_GET_USER: {
|
||||
if (*pRes) {
|
||||
SUserAuthRes* pAuth = (SUserAuthRes*)*pRes;
|
||||
nodesDestroyNode(pAuth->pCond);
|
||||
taosMemoryFreeClear(*pRes);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CTG_TASK_GET_TB_HASH:
|
||||
case CTG_TASK_GET_DB_INFO:
|
||||
case CTG_TASK_GET_INDEX_INFO:
|
||||
case CTG_TASK_GET_UDF:
|
||||
case CTG_TASK_GET_USER:
|
||||
case CTG_TASK_GET_SVR_VER:
|
||||
case CTG_TASK_GET_TB_META: {
|
||||
taosMemoryFreeClear(*pRes);
|
||||
break;
|
||||
}
|
||||
case CTG_TASK_GET_TB_TAG: {
|
||||
if (1 == taosArrayGetSize(*pRes)) {
|
||||
taosArrayDestroyEx(*pRes, ctgFreeJsonTagVal);
|
||||
} else {
|
||||
taosArrayDestroy(*pRes);
|
||||
}
|
||||
*pRes = NULL;
|
||||
break;
|
||||
}
|
||||
case CTG_TASK_GET_TB_META_BATCH: {
|
||||
SArray* pArray = (SArray*)*pRes;
|
||||
int32_t num = taosArrayGetSize(pArray);
|
||||
|
@ -679,6 +710,13 @@ void ctgFreeTaskCtx(SCtgTask* pTask) {
|
|||
taosMemoryFreeClear(pTask->taskCtx);
|
||||
break;
|
||||
}
|
||||
case CTG_TASK_GET_TB_TAG: {
|
||||
SCtgTbTagCtx* taskCtx = (SCtgTbTagCtx*)pTask->taskCtx;
|
||||
taosMemoryFreeClear(taskCtx->pName);
|
||||
taosMemoryFreeClear(taskCtx->pVgInfo);
|
||||
taosMemoryFreeClear(taskCtx);
|
||||
break;
|
||||
}
|
||||
case CTG_TASK_GET_DB_VGROUP:
|
||||
case CTG_TASK_GET_DB_CFG:
|
||||
case CTG_TASK_GET_DB_INFO:
|
||||
|
@ -1336,57 +1374,75 @@ int32_t ctgChkSetTbAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) {
|
|||
STableMeta* pMeta = NULL;
|
||||
SGetUserAuthRsp* pInfo = &req->authInfo;
|
||||
SHashObj* pTbs = (AUTH_TYPE_READ == req->singleType) ? pInfo->readTbs : pInfo->writeTbs;
|
||||
char* stbName = NULL;
|
||||
|
||||
char tbFullName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(&req->pRawReq->tbName, tbFullName);
|
||||
char* pCond = taosHashGet(pTbs, tbFullName, strlen(tbFullName));
|
||||
if (pCond) {
|
||||
if (strlen(pCond) > 1) {
|
||||
CTG_ERR_RET(nodesStringToNode(pCond, &res->pRawRes->pCond));
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameExtractFullName(&req->pRawReq->tbName, tbFName);
|
||||
tNameGetFullDbName(&req->pRawReq->tbName, dbFName);
|
||||
|
||||
while (true) {
|
||||
taosMemoryFreeClear(pMeta);
|
||||
|
||||
char* pCond = taosHashGet(pTbs, tbFName, strlen(tbFName));
|
||||
if (pCond) {
|
||||
if (strlen(pCond) > 1) {
|
||||
CTG_ERR_JRET(nodesStringToNode(pCond, &res->pRawRes->pCond));
|
||||
}
|
||||
|
||||
res->pRawRes->pass = true;
|
||||
goto _return;
|
||||
}
|
||||
|
||||
res->pRawRes->pass = true;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
if (stbName) {
|
||||
res->pRawRes->pass = false;
|
||||
goto _return;
|
||||
}
|
||||
|
||||
CTG_ERR_JRET(catalogGetCachedTableMeta(pCtg, &req->pRawReq->tbName, &pMeta));
|
||||
if (NULL == pMeta) {
|
||||
if (req->onlyCache) {
|
||||
res->metaNotExists = true;
|
||||
ctgDebug("db %s tb %s meta not in cache for auth", req->pRawReq->tbName.dbname, req->pRawReq->tbName.tname);
|
||||
goto _return;
|
||||
}
|
||||
|
||||
SCtgTbMetaCtx ctx = {0};
|
||||
ctx.pName = (SName*)&req->pRawReq->tbName;
|
||||
ctx.flag = CTG_FLAG_UNKNOWN_STB | CTG_FLAG_SYNC_OP;
|
||||
|
||||
CTG_ERR_JRET(ctgGetTbMeta(pCtg, req->pConn, &ctx, &pMeta));
|
||||
}
|
||||
|
||||
if (TSDB_SUPER_TABLE == pMeta->tableType || TSDB_NORMAL_TABLE == pMeta->tableType) {
|
||||
res->pRawRes->pass = false;
|
||||
goto _return;
|
||||
}
|
||||
|
||||
if (TSDB_CHILD_TABLE == pMeta->tableType) {
|
||||
CTG_ERR_JRET(ctgGetCachedStbNameFromSuid(pCtg, dbFName, pMeta->suid, &stbName));
|
||||
if (NULL == stbName) {
|
||||
if (req->onlyCache) {
|
||||
res->metaNotExists = true;
|
||||
ctgDebug("suid %" PRIu64 " name not in cache for auth", pMeta->suid);
|
||||
goto _return;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
sprintf(tbFName, "%s.%s", dbFName, stbName);
|
||||
continue;
|
||||
}
|
||||
|
||||
ctgError("Invalid table type %d for %s", pMeta->tableType, tbFName);
|
||||
CTG_ERR_JRET(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
res->pRawRes->pass = false;
|
||||
|
||||
// CTG_ERR_RET(catalogGetCachedTableMeta(pCtg, &req->pRawReq->tbName, &pMeta));
|
||||
// if (NULL == pMeta) {
|
||||
// if (req->onlyCache) {
|
||||
// res->metaNotExists = true;
|
||||
// ctgDebug("db %s tb %s meta not in cache for auth", req->pRawReq->tbName.dbname, req->pRawReq->tbName.tname);
|
||||
// return TSDB_CODE_SUCCESS;
|
||||
// }
|
||||
|
||||
// CTG_ERR_RET(catalogGetTableMeta(pCtg, req->pConn, &req->pRawReq->tbName, &pMeta));
|
||||
// }
|
||||
|
||||
// if (TSDB_SUPER_TABLE == pMeta->tableType || TSDB_NORMAL_TABLE == pMeta->tableType) {
|
||||
// res->pRawRes->pass = false;
|
||||
// goto _return;
|
||||
// }
|
||||
|
||||
// if (TSDB_CHILD_TABLE == pMeta->tableType) {
|
||||
// res->pRawRes->pass = true;
|
||||
|
||||
// /*
|
||||
// char stbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
// CTG_ERR_JRET(ctgGetCachedStbNameFromSuid(pCtg, pMeta->suid, stbName));
|
||||
// if (0 == stbName[0]) {
|
||||
// if (req->onlyCache) {
|
||||
// res->notExists = true;
|
||||
// return TSDB_CODE_SUCCESS;
|
||||
// }
|
||||
|
||||
// CTG_ERR_RET(catalogRefreshTableMeta(pCtg, req->pConn, &req->pRawReq->tbName, 0));
|
||||
// }
|
||||
// */
|
||||
// }
|
||||
|
||||
_return:
|
||||
|
||||
taosMemoryFree(pMeta);
|
||||
taosMemoryFree(stbName);
|
||||
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
@ -1423,7 +1479,7 @@ int32_t ctgChkSetAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) {
|
|||
if (pInfo->readTbs && taosHashGetSize(pInfo->readTbs) > 0) {
|
||||
req->singleType = AUTH_TYPE_READ;
|
||||
CTG_ERR_RET(ctgChkSetTbAuthRes(pCtg, req, res));
|
||||
if (pRes->pass) {
|
||||
if (pRes->pass || res->metaNotExists) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -1439,7 +1495,7 @@ int32_t ctgChkSetAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) {
|
|||
if (pInfo->writeTbs && taosHashGetSize(pInfo->writeTbs) > 0) {
|
||||
req->singleType = AUTH_TYPE_WRITE;
|
||||
CTG_ERR_RET(ctgChkSetTbAuthRes(pCtg, req, res));
|
||||
if (pRes->pass) {
|
||||
if (pRes->pass || res->metaNotExists) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) {
|
|||
|
||||
int64_t fetchUs = 0, fetchNum = 0;
|
||||
tsortClearOrderdSource(pSortHandle->pOrderedSource, &fetchUs, &fetchNum);
|
||||
qError("all source fetch time: %" PRId64 "us num:%" PRId64 " %s", fetchUs, fetchNum, pSortHandle->idStr);
|
||||
qDebug("all source fetch time: %" PRId64 "us num:%" PRId64 " %s", fetchUs, fetchNum, pSortHandle->idStr);
|
||||
|
||||
taosArrayDestroy(pSortHandle->pOrderedSource);
|
||||
taosMemoryFreeClear(pSortHandle);
|
||||
|
@ -316,7 +316,7 @@ static int32_t sortComparInit(SMsortComparParam* pParam, SArray* pSources, int32
|
|||
}
|
||||
|
||||
int64_t et = taosGetTimestampUs();
|
||||
qError("init for merge sort completed, elapsed time:%.2f ms, %s", (et - st) / 1000.0, pHandle->idStr);
|
||||
qDebug("init for merge sort completed, elapsed time:%.2f ms, %s", (et - st) / 1000.0, pHandle->idStr);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
|
|
@ -827,6 +827,8 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)pNode;
|
||||
destroyVgDataBlockArray(pStmt->pDataBlocks);
|
||||
taosMemoryFreeClear(pStmt->pTableMeta);
|
||||
nodesDestroyNode(pStmt->pTagCond);
|
||||
taosArrayDestroy(pStmt->pTableTag);
|
||||
taosHashCleanup(pStmt->pVgroupsHashObj);
|
||||
taosHashCleanup(pStmt->pSubTableHashObj);
|
||||
taosHashCleanup(pStmt->pTableNameHashObj);
|
||||
|
@ -953,8 +955,12 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
break;
|
||||
case QUERY_NODE_SPLIT_VGROUP_STMT: // no pointer field
|
||||
case QUERY_NODE_SYNCDB_STMT: // no pointer field
|
||||
case QUERY_NODE_GRANT_STMT: // no pointer field
|
||||
case QUERY_NODE_REVOKE_STMT: // no pointer field
|
||||
break;
|
||||
case QUERY_NODE_GRANT_STMT:
|
||||
nodesDestroyNode(((SGrantStmt*)pNode)->pTagCond);
|
||||
break;
|
||||
case QUERY_NODE_REVOKE_STMT:
|
||||
nodesDestroyNode(((SRevokeStmt*)pNode)->pTagCond);
|
||||
break;
|
||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
|
|
|
@ -70,7 +70,7 @@ static EDealRes authSubquery(SAuthCxt* pCxt, SNode* pStmt) {
|
|||
return TSDB_CODE_SUCCESS == authQuery(pCxt, pStmt) ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
static int32_t mergeStableTagCond(SNode** pWhere, SNode** pTagCond) {
|
||||
static int32_t mergeStableTagCond(SNode** pWhere, SNode* pTagCond) {
|
||||
SLogicConditionNode* pLogicCond = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
if (NULL == pLogicCond) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -78,7 +78,7 @@ static int32_t mergeStableTagCond(SNode** pWhere, SNode** pTagCond) {
|
|||
pLogicCond->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
pLogicCond->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
||||
pLogicCond->condType = LOGIC_COND_TYPE_AND;
|
||||
int32_t code = nodesListMakeStrictAppend(&pLogicCond->pParameterList, *pTagCond);
|
||||
int32_t code = nodesListMakeStrictAppend(&pLogicCond->pParameterList, pTagCond);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeAppend(&pLogicCond->pParameterList, *pWhere);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ static int32_t appendStableTagCond(SNode** pWhere, SNode* pTagCond) {
|
|||
return nodesListStrictAppend(((SLogicConditionNode*)*pWhere)->pParameterList, pTagCondCopy);
|
||||
}
|
||||
|
||||
return mergeStableTagCond(pWhere, &pTagCondCopy);
|
||||
return mergeStableTagCond(pWhere, pTagCondCopy);
|
||||
}
|
||||
|
||||
static EDealRes authSelectImpl(SNode* pNode, void* pContext) {
|
||||
|
|
|
@ -53,6 +53,7 @@ typedef struct SInsertParseContext {
|
|||
bool missCache;
|
||||
bool usingDuplicateTable;
|
||||
bool forceUpdate;
|
||||
bool needTableTagVal;
|
||||
} SInsertParseContext;
|
||||
|
||||
typedef int32_t (*_row_append_fn_t)(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param);
|
||||
|
@ -577,28 +578,39 @@ static int32_t rewriteTagCondColumnImpl(STagVal* pVal, SNode** pNode) {
|
|||
if (NULL == pValue) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pValue->node.resType.type = pVal->type;
|
||||
|
||||
pValue->node.resType = ((SColumnNode*)*pNode)->node.resType;
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = (SNode*)pValue;
|
||||
|
||||
switch (pVal->type) {
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
pValue->datum.b = *(int8_t*)(&pVal->i64);
|
||||
*(bool*)&pValue->typeData = pValue->datum.b;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
pValue->datum.i = *(int8_t*)(&pVal->i64);
|
||||
*(int8_t*)&pValue->typeData = pValue->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
pValue->datum.i = *(int16_t*)(&pVal->i64);
|
||||
*(int16_t*)&pValue->typeData = pValue->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
pValue->datum.i = *(int32_t*)(&pVal->i64);
|
||||
*(int32_t*)&pValue->typeData = pValue->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
pValue->datum.i = pVal->i64;
|
||||
pValue->typeData = pValue->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
pValue->datum.d = *(float*)(&pVal->i64);
|
||||
*(float*)&pValue->typeData = pValue->datum.d;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
pValue->datum.d = *(double*)(&pVal->i64);
|
||||
*(double*)&pValue->typeData = pValue->datum.d;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_VARCHAR:
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
|
@ -611,18 +623,23 @@ static int32_t rewriteTagCondColumnImpl(STagVal* pVal, SNode** pNode) {
|
|||
break;
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
pValue->datum.i = pVal->i64;
|
||||
pValue->typeData = pValue->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
pValue->datum.i = *(uint8_t*)(&pVal->i64);
|
||||
*(uint8_t*)&pValue->typeData = pValue->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
pValue->datum.i = *(uint16_t*)(&pVal->i64);
|
||||
*(uint16_t*)&pValue->typeData = pValue->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
pValue->datum.i = *(uint32_t*)(&pVal->i64);
|
||||
*(uint32_t*)&pValue->typeData = pValue->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
pValue->datum.i = *(uint64_t*)(&pVal->i64);
|
||||
*(uint64_t*)&pValue->typeData = pValue->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_JSON:
|
||||
case TSDB_DATA_TYPE_VARBINARY:
|
||||
|
@ -667,16 +684,15 @@ static int32_t checkTagCondResult(SNode* pResult) {
|
|||
: TSDB_CODE_PAR_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
int32_t checkSubtablePrivilege(SArray* pTagVals, SArray* pTagName, SNode* pCond) {
|
||||
int32_t code = setTagVal(pTagVals, pTagName, pCond);
|
||||
SNode* pNew = NULL;
|
||||
static int32_t checkSubtablePrivilege(SArray* pTagVals, SArray* pTagName, SNode** pCond) {
|
||||
int32_t code = setTagVal(pTagVals, pTagName, *pCond);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = scalarCalculateConstants(pCond, &pNew);
|
||||
code = scalarCalculateConstants(*pCond, pCond);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkTagCondResult(pNew);
|
||||
code = checkTagCondResult(*pCond);
|
||||
}
|
||||
nodesDestroyNode(pNew);
|
||||
NODES_DESTORY_NODE(*pCond);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -716,6 +732,10 @@ static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt
|
|||
}
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pTagCond) {
|
||||
code = checkSubtablePrivilege(pTagVals, pTagName, &pStmt->pTagCond);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code && !isParseBindParam && !isJson) {
|
||||
code = tTagNew(pTagVals, 1, false, &pTag);
|
||||
}
|
||||
|
@ -843,7 +863,7 @@ static void setUserAuthInfo(SParseContext* pCxt, SName* pTbName, SUserAuthInfo*
|
|||
pInfo->type = AUTH_TYPE_WRITE;
|
||||
}
|
||||
|
||||
static int32_t checkAuth(SParseContext* pCxt, SName* pTbName, bool* pMissCache) {
|
||||
static int32_t checkAuth(SParseContext* pCxt, SName* pTbName, bool* pMissCache, SNode** pTagCond) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SUserAuthInfo authInfo = {0};
|
||||
setUserAuthInfo(pCxt, pTbName, &authInfo);
|
||||
|
@ -863,11 +883,28 @@ static int32_t checkAuth(SParseContext* pCxt, SName* pTbName, bool* pMissCache)
|
|||
*pMissCache = true;
|
||||
} else if (!authRes.pass) {
|
||||
code = TSDB_CODE_PAR_PERMISSION_DENIED;
|
||||
} else if (NULL != authRes.pCond) {
|
||||
*pTagCond = authRes.pCond;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t checkAuthForTable(SParseContext* pCxt, SName* pTbName, bool* pMissCache, bool* pNeedTableTagVal) {
|
||||
SNode* pTagCond = NULL;
|
||||
int32_t code = checkAuth(pCxt, pTbName, pMissCache, &pTagCond);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pNeedTableTagVal = ((*pMissCache) || (NULL != pTagCond));
|
||||
*pMissCache = (NULL != pTagCond);
|
||||
}
|
||||
nodesDestroyNode(pTagCond);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t checkAuthForStable(SParseContext* pCxt, SName* pTbName, bool* pMissCache, SNode** pTagCond) {
|
||||
return checkAuth(pCxt, pTbName, pMissCache, pTagCond);
|
||||
}
|
||||
|
||||
static int32_t getTableMeta(SInsertParseContext* pCxt, SName* pTbName, bool isStb, STableMeta** pTableMeta,
|
||||
bool* pMissCache) {
|
||||
SParseContext* pComCxt = pCxt->pComCxt;
|
||||
|
@ -970,7 +1007,7 @@ static int32_t getTargetTableSchema(SInsertParseContext* pCxt, SVnodeModifyOpStm
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t code = checkAuth(pCxt->pComCxt, &pStmt->targetTableName, &pCxt->missCache);
|
||||
int32_t code = checkAuthForTable(pCxt->pComCxt, &pStmt->targetTableName, &pCxt->missCache, &pCxt->needTableTagVal);
|
||||
if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) {
|
||||
code = getTableMetaAndVgroup(pCxt, pStmt, &pCxt->missCache);
|
||||
}
|
||||
|
@ -993,7 +1030,7 @@ static int32_t getUsingTableSchema(SInsertParseContext* pCxt, SVnodeModifyOpStmt
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t code = checkAuth(pCxt->pComCxt, &pStmt->targetTableName, &pCxt->missCache);
|
||||
int32_t code = checkAuthForStable(pCxt->pComCxt, &pStmt->usingTableName, &pCxt->missCache, &pStmt->pTagCond);
|
||||
if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) {
|
||||
code = getTableMeta(pCxt, &pStmt->usingTableName, true, &pStmt->pTableMeta, &pCxt->missCache);
|
||||
}
|
||||
|
@ -1606,6 +1643,8 @@ static int32_t parseInsertTableClauseBottom(SInsertParseContext* pCxt, SVnodeMod
|
|||
static void resetEnvPreTable(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) {
|
||||
insDestroyBoundColInfo(&pCxt->tags);
|
||||
taosMemoryFreeClear(pStmt->pTableMeta);
|
||||
nodesDestroyNode(pStmt->pTagCond);
|
||||
taosArrayDestroy(pStmt->pTableTag);
|
||||
tdDestroySVCreateTbReq(pStmt->pCreateTblReq);
|
||||
taosMemoryFreeClear(pStmt->pCreateTblReq);
|
||||
pCxt->missCache = false;
|
||||
|
@ -1780,14 +1819,18 @@ static int32_t createInsertQuery(SInsertParseContext* pCxt, SQuery** pOutput) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t checkAuthFromMetaData(const SArray* pUsers) {
|
||||
static int32_t checkAuthFromMetaData(const SArray* pUsers, SNode** pTagCond) {
|
||||
if (1 != taosArrayGetSize(pUsers)) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SMetaRes* pRes = taosArrayGet(pUsers, 0);
|
||||
if (TSDB_CODE_SUCCESS == pRes->code) {
|
||||
return (*(bool*)pRes->pRes) ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED;
|
||||
SUserAuthRes* pAuth = pRes->pRes;
|
||||
if (NULL != pAuth->pCond) {
|
||||
*pTagCond = nodesCloneNode(pAuth->pCond);
|
||||
}
|
||||
return pAuth->pass ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED;
|
||||
}
|
||||
return pRes->code;
|
||||
}
|
||||
|
@ -1826,9 +1869,40 @@ static int32_t getTableVgroupFromMetaData(const SArray* pTables, SVnodeModifyOpS
|
|||
sizeof(SVgroupInfo));
|
||||
}
|
||||
|
||||
static int32_t buildTagNameFromMeta(STableMeta* pMeta, SArray** pTagName) {
|
||||
*pTagName = taosArrayInit(pMeta->tableInfo.numOfTags, TSDB_COL_NAME_LEN);
|
||||
if (NULL == *pTagName) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
SSchema* pSchema = getTableTagSchema(pMeta);
|
||||
for (int32_t i = 0; i < pMeta->tableInfo.numOfTags; ++i) {
|
||||
taosArrayPush(*pTagName, pSchema[i].name);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t checkSubtablePrivilegeForTable(const SArray* pTables, SVnodeModifyOpStmt* pStmt) {
|
||||
if (1 != taosArrayGetSize(pTables)) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SMetaRes* pRes = taosArrayGet(pTables, 0);
|
||||
if (TSDB_CODE_SUCCESS != pRes->code) {
|
||||
return pRes->code;
|
||||
}
|
||||
|
||||
SArray* pTagName = NULL;
|
||||
int32_t code = buildTagNameFromMeta(pStmt->pTableMeta, &pTagName);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkSubtablePrivilege((SArray*)pRes->pRes, pTagName, &pStmt->pTagCond);
|
||||
}
|
||||
taosArrayDestroy(pTagName);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t getTableSchemaFromMetaData(SInsertParseContext* pCxt, const SMetaData* pMetaData,
|
||||
SVnodeModifyOpStmt* pStmt, bool isStb) {
|
||||
int32_t code = checkAuthFromMetaData(pMetaData->pUser);
|
||||
int32_t code = checkAuthFromMetaData(pMetaData->pUser, &pStmt->pTagCond);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = getTableMetaFromMetaData(pMetaData->pTableMeta, &pStmt->pTableMeta);
|
||||
}
|
||||
|
@ -1841,6 +1915,9 @@ static int32_t getTableSchemaFromMetaData(SInsertParseContext* pCxt, const SMeta
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = getTableVgroupFromMetaData(pMetaData->pTableHash, pStmt, isStb);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && !isStb && NULL != pStmt->pTagCond) {
|
||||
code = checkSubtablePrivilegeForTable(pMetaData->pTableTag, pStmt);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -1860,6 +1937,8 @@ static void clearCatalogReq(SCatalogReq* pCatalogReq) {
|
|||
pCatalogReq->pTableHash = NULL;
|
||||
taosArrayDestroy(pCatalogReq->pUser);
|
||||
pCatalogReq->pUser = NULL;
|
||||
taosArrayDestroy(pCatalogReq->pTableTag);
|
||||
pCatalogReq->pTableTag = NULL;
|
||||
}
|
||||
|
||||
static int32_t setVnodeModifOpStmt(SInsertParseContext* pCxt, SCatalogReq* pCatalogReq, const SMetaData* pMetaData,
|
||||
|
@ -2033,8 +2112,15 @@ static int32_t buildInsertUserAuthReq(const char* pUser, SName* pName, SArray**
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t buildInsertTableTagReq(SName* pName, SArray** pTables) { return buildInsertTableReq(pName, pTables); }
|
||||
|
||||
static int32_t buildInsertCatalogReq(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, SCatalogReq* pCatalogReq) {
|
||||
int32_t code = buildInsertUserAuthReq(pCxt->pComCxt->pUser, &pStmt->targetTableName, &pCatalogReq->pUser);
|
||||
int32_t code = buildInsertUserAuthReq(
|
||||
pCxt->pComCxt->pUser, (0 == pStmt->usingTableName.type ? &pStmt->targetTableName : &pStmt->usingTableName),
|
||||
&pCatalogReq->pUser);
|
||||
if (TSDB_CODE_SUCCESS == code && pCxt->needTableTagVal) {
|
||||
code = buildInsertTableTagReq(&pStmt->targetTableName, &pCatalogReq->pTableTag);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (0 == pStmt->usingTableName.type) {
|
||||
code = buildInsertDbReq(&pStmt->targetTableName, &pCatalogReq->pTableMeta);
|
||||
|
|
|
@ -1310,7 +1310,8 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
|||
}
|
||||
|
||||
static EDealRes haveVectorFunction(SNode* pNode, void* pContext) {
|
||||
if (isAggFunc(pNode) || isIndefiniteRowsFunc(pNode) || isWindowPseudoColumnFunc(pNode) || isInterpPseudoColumnFunc(pNode)) {
|
||||
if (isAggFunc(pNode) || isIndefiniteRowsFunc(pNode) || isWindowPseudoColumnFunc(pNode) ||
|
||||
isInterpPseudoColumnFunc(pNode)) {
|
||||
*((bool*)pContext) = true;
|
||||
return DEAL_RES_END;
|
||||
}
|
||||
|
@ -2577,8 +2578,13 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
|
|||
if (TSDB_SUPER_TABLE == pRealTable->pMeta->tableType) {
|
||||
pCxt->stableQuery = true;
|
||||
}
|
||||
if (TSDB_SYSTEM_TABLE == pRealTable->pMeta->tableType && isSelectStmt(pCxt->pCurrStmt)) {
|
||||
((SSelectStmt*)pCxt->pCurrStmt)->isTimeLineResult = false;
|
||||
if (TSDB_SYSTEM_TABLE == pRealTable->pMeta->tableType) {
|
||||
if (isSelectStmt(pCxt->pCurrStmt)) {
|
||||
((SSelectStmt*)pCxt->pCurrStmt)->isTimeLineResult = false;
|
||||
} else if (isDeleteStmt(pCxt->pCurrStmt)) {
|
||||
code = TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
break;
|
||||
}
|
||||
}
|
||||
code = addNamespace(pCxt, pRealTable);
|
||||
}
|
||||
|
@ -6642,6 +6648,7 @@ static int32_t translateGrant(STranslateContext* pCxt, SGrantStmt* pStmt) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &req);
|
||||
}
|
||||
tFreeSAlterUserReq(&req);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -1443,7 +1443,7 @@ static int32_t createDeleteRootLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p
|
|||
|
||||
static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
||||
SScanLogicNode* pScan = NULL;
|
||||
int32_t code = makeScanLogicNode(pCxt, (SRealTableNode*)pDelete->pFromTable, false, (SLogicNode**)&pScan);
|
||||
int32_t code = makeScanLogicNode(pCxt, (SRealTableNode*)pDelete->pFromTable, false, (SLogicNode**)&pScan);
|
||||
|
||||
// set columns to scan
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
|
|
@ -407,7 +407,7 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta *
|
|||
pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
|
||||
}
|
||||
|
||||
qDebug("table %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s stb %s suid %" PRIx64 " sver %d tver %d" PRIx64
|
||||
qDebug("table %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s stb %s suid %" PRIx64 " sver %d tver %d"
|
||||
" tagNum %d colNum %d precision %d rowSize %d",
|
||||
msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName,
|
||||
pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags,
|
||||
|
|
|
@ -53,6 +53,7 @@ int32_t sclCreateColumnInfoData(SDataType *pType, int32_t numOfRows, SScalarPara
|
|||
int32_t code = colInfoDataEnsureCapacity(pColumnData, numOfRows, true);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
colDataDestroy(pColumnData);
|
||||
taosMemoryFree(pColumnData);
|
||||
return terrno;
|
||||
}
|
||||
|
@ -1061,17 +1062,20 @@ int32_t sclConvertOpValueNodeTs(SOperatorNode *node, SScalarCtx *ctx) {
|
|||
|
||||
if (node->pLeft && SCL_IS_VAR_VALUE_NODE(node->pLeft)) {
|
||||
if (node->pRight && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pRight)->resType.type)) {
|
||||
SCL_ERR_JRET(sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, node->pRight), (SValueNode*)node->pLeft));
|
||||
SCL_ERR_JRET(
|
||||
sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, node->pRight), (SValueNode *)node->pLeft));
|
||||
}
|
||||
} else if (node->pRight && SCL_IS_NOTNULL_CONST_NODE(node->pRight)) {
|
||||
if (node->pLeft && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pLeft)->resType.type)) {
|
||||
if (SCL_IS_VAR_VALUE_NODE(node->pRight)) {
|
||||
SCL_ERR_JRET(sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, node->pRight), (SValueNode*)node->pRight));
|
||||
SCL_ERR_JRET(sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, node->pRight),
|
||||
(SValueNode *)node->pRight));
|
||||
} else if (QUERY_NODE_NODE_LIST == node->pRight->type) {
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, ((SNodeListNode*)node->pRight)->pNodeList) {
|
||||
SNode *pNode;
|
||||
FOREACH(pNode, ((SNodeListNode *)node->pRight)->pNodeList) {
|
||||
if (SCL_IS_VAR_VALUE_NODE(pNode)) {
|
||||
SCL_ERR_JRET(sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, pNode), (SValueNode*)pNode));
|
||||
SCL_ERR_JRET(
|
||||
sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, pNode), (SValueNode *)pNode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1086,8 +1090,6 @@ _return:
|
|||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t sclConvertCaseWhenValueNodeTs(SCaseWhenNode *node, SScalarCtx *ctx) {
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -1096,19 +1098,20 @@ int32_t sclConvertCaseWhenValueNodeTs(SCaseWhenNode *node, SScalarCtx *ctx) {
|
|||
}
|
||||
|
||||
if (SCL_IS_VAR_VALUE_NODE(node->pCase)) {
|
||||
SNode* pNode;
|
||||
SNode *pNode;
|
||||
FOREACH(pNode, node->pWhenThenList) {
|
||||
SExprNode *pExpr = (SExprNode *)((SWhenThenNode *)pNode)->pWhen;
|
||||
if (TSDB_DATA_TYPE_TIMESTAMP == pExpr->resType.type) {
|
||||
SCL_ERR_JRET(sclConvertToTsValueNode(pExpr->resType.precision, (SValueNode*)node->pCase));
|
||||
SCL_ERR_JRET(sclConvertToTsValueNode(pExpr->resType.precision, (SValueNode *)node->pCase));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pCase)->resType.type) {
|
||||
SNode* pNode;
|
||||
SNode *pNode;
|
||||
FOREACH(pNode, node->pWhenThenList) {
|
||||
if (SCL_IS_VAR_VALUE_NODE(((SWhenThenNode *)pNode)->pWhen)) {
|
||||
SCL_ERR_JRET(sclConvertToTsValueNode(((SExprNode *)node->pCase)->resType.precision, (SValueNode*)((SWhenThenNode *)pNode)->pWhen));
|
||||
SCL_ERR_JRET(sclConvertToTsValueNode(((SExprNode *)node->pCase)->resType.precision,
|
||||
(SValueNode *)((SWhenThenNode *)pNode)->pWhen));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1271,7 +1274,6 @@ EDealRes sclRewriteLogic(SNode **pNode, SScalarCtx *ctx) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
|
||||
SOperatorNode *node = (SOperatorNode *)*pNode;
|
||||
|
||||
|
|
|
@ -538,10 +538,11 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
struct stat fileStat;
|
||||
#ifdef WINDOWS
|
||||
int32_t code = _fstat(pFile->fd, &fileStat);
|
||||
struct __stat64 fileStat;
|
||||
int32_t code = _fstat64(pFile->fd, &fileStat);
|
||||
#else
|
||||
struct stat fileStat;
|
||||
int32_t code = fstat(pFile->fd, &fileStat);
|
||||
#endif
|
||||
if (code < 0) {
|
||||
|
|
|
@ -347,7 +347,6 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
|
|||
|
||||
char name[LOG_FILE_NAME_LEN + 50] = "\0";
|
||||
int32_t logstat0_mtime, logstat1_mtime;
|
||||
int32_t size;
|
||||
|
||||
tsLogObj.maxLines = maxLines;
|
||||
tsLogObj.fileNum = maxFileNum;
|
||||
|
@ -395,8 +394,7 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
|
|||
printf("\nfailed to fstat log file:%s, reason:%s\n", fileName, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
size = (int32_t)filesize;
|
||||
tsLogObj.lines = size / 60;
|
||||
tsLogObj.lines = (int32_t)(filesize / 60);
|
||||
|
||||
taosLSeekFile(tsLogObj.logHandle->pFile, 0, SEEK_END);
|
||||
|
||||
|
|
|
@ -51,6 +51,16 @@
|
|||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_26.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/select_null.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/select_null.py -R
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/select_null.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/select_null.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/select_null.py -Q 4
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/slimit.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/slimit.py -R
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/slimit.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/slimit.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/slimit.py -Q 4
|
||||
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/create_wrong_topic.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3
|
||||
|
@ -127,11 +137,13 @@
|
|||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_control.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_manage.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/fsync.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/multilevel.py
|
||||
,,n,system-test,python3 ./test.py -f 0-others/compatibility.py
|
||||
,,n,system-test,python3 ./test.py -f 0-others/tag_index_basic.py
|
||||
,,n,system-test,python3 ./test.py -f 0-others/udfpy_main.py
|
||||
,,n,system-test,python3 ./test.py -N 3 -f 0-others/walRetention.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_database.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_replica.py -N 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/influxdb_line_taosc_insert.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_telnet_line_taosc_insert.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_json_taosc_insert.py
|
||||
|
@ -337,6 +349,7 @@
|
|||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/tb_100w_data_order.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_childtable.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_normaltable.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_systable.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/keep_expired.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/drop.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/drop.py -N 3 -M 3 -i False -n 3
|
||||
|
@ -722,6 +735,7 @@
|
|||
,,y,script,./test.sh -f tsim/user/privilege_db.sim
|
||||
,,y,script,./test.sh -f tsim/user/privilege_sysinfo.sim
|
||||
,,y,script,./test.sh -f tsim/user/privilege_topic.sim
|
||||
,,y,script,./test.sh -f tsim/user/privilege_table.sim
|
||||
,,y,script,./test.sh -f tsim/db/alter_option.sim
|
||||
,,y,script,./test.sh -f tsim/db/alter_replica_31.sim
|
||||
,,y,script,./test.sh -f tsim/db/basic1.sim
|
||||
|
|
|
@ -303,7 +303,7 @@ function run_thread() {
|
|||
if [ ! -z "$corefile" ]; then
|
||||
echo -e "\e[34m corefiles: $corefile \e[0m"
|
||||
local build_dir=$log_dir/build_${hosts[index]}
|
||||
local remote_build_dir="${workdirs[index]}/{DEBUGPATH}/build"
|
||||
local remote_build_dir="${workdirs[index]}/${DEBUGPATH}/build"
|
||||
# if [ $ent -ne 0 ]; then
|
||||
# remote_build_dir="${workdirs[index]}/{DEBUGPATH}/build"
|
||||
# fi
|
||||
|
|
|
@ -0,0 +1,302 @@
|
|||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
sql connect
|
||||
|
||||
print =============== init env
|
||||
sql drop database if exists test;
|
||||
sql create database test vgroups 1;
|
||||
sql use test;
|
||||
sql create stable st1(ts timestamp, i int) tags(id int, loc varchar(20));
|
||||
sql create table st1s1 using st1 tags(1, 'beijing');
|
||||
sql create table st1s2 using st1 tags(2, 'shanghai');
|
||||
sql insert into st1s1 values(now, 1) st1s2 values(now, 2);
|
||||
sql create stable st2(ts timestamp, i int) tags(id int, loc varchar(20));
|
||||
sql create table st2s1 using st2 tags(1, 'beijing');
|
||||
sql create table st2s2 using st2 tags(2, 'shanghai');
|
||||
sql insert into st2s1 values(now, 1) st2s2 values(now, 2);
|
||||
sql create user wxy pass 'taosdata';
|
||||
|
||||
print =============== case 1: database unauthorized and table unauthorized
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql_error select * from test.st1;
|
||||
sql_error insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
|
||||
sql_error select * from test.st2;
|
||||
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
|
||||
print =============== case 2: database unauthorized and table read privilege
|
||||
sql close
|
||||
sql connect
|
||||
|
||||
sql grant read on test.st1 to wxy;
|
||||
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql select * from test.st1;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
sql_error insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
|
||||
sql_error select * from test.st2;
|
||||
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
print =============== case 3: database unauthorized and table read privilege with condition
|
||||
sql close
|
||||
sql connect
|
||||
|
||||
sql revoke read on test.st1 from wxy;
|
||||
sql grant read on test.st1 with id = 1 to wxy;
|
||||
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql select * from test.st1;
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql_error insert into test.st1s1 values(now, 10);
|
||||
sql_error insert into test.st1s2 values(now, 20);
|
||||
sql_error select * from test.st2;
|
||||
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
print =============== case 4: database unauthorized and table write privilege
|
||||
sql close
|
||||
sql connect
|
||||
|
||||
sql revoke read on test.st1 with id = 1 from wxy;
|
||||
sql grant write on test.st1 to wxy;
|
||||
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql_error select tbname, * from test.st1;
|
||||
sql insert into test.st1s1 values(now, 10);
|
||||
sql insert into test.st1s2 values(now, 20);
|
||||
sql_error select * from test.st2;
|
||||
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
print =============== case 5: database unauthorized and table write privilege with condition
|
||||
sql close
|
||||
sql connect
|
||||
|
||||
sql revoke write on test.st1 from wxy;
|
||||
sql grant write on test.st1 with id = 1 to wxy;
|
||||
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql_error select tbname, * from test.st1;
|
||||
sql insert into test.st1s1 values(now, 10);
|
||||
sql insert into test.st1s3 using test.st1 tags(1, 'dachang') values(now, 100);
|
||||
sql_error insert into test.st1s2 values(now, 20);
|
||||
sql_error insert into test.st1s4 using test.st1 tags(3, 'dachang') values(now, 300);
|
||||
sql_error select * from test.st2;
|
||||
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
print =============== case 6: database read privilege and table unauthorized
|
||||
sql close
|
||||
sql connect
|
||||
|
||||
sql revoke write on test.st1 with id = 1 from wxy;
|
||||
sql grant read on test.* to wxy;
|
||||
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql select * from test.st1;
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
sql_error insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
|
||||
sql select * from test.st2;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
print =============== case 7: database read privilege and table read privilege
|
||||
sql close
|
||||
sql connect
|
||||
|
||||
sql grant read on test.st1 to wxy;
|
||||
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql select * from test.st1;
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
sql_error insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
|
||||
sql select * from test.st2;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
print =============== case 8: database read privilege and table read privilege with condition
|
||||
sql close
|
||||
sql connect
|
||||
|
||||
sql revoke read on test.st1 from wxy;
|
||||
sql grant read on test.st1 with id = 1 to wxy;
|
||||
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql select * from test.st1;
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
sql_error insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
|
||||
sql select * from test.st2;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
print =============== case 9: database read privilege and table write privilege
|
||||
sql close
|
||||
sql connect
|
||||
|
||||
sql revoke read on test.st1 with id = 1 from wxy;
|
||||
sql grant write on test.st1 to wxy;
|
||||
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql select * from test.st1;
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
|
||||
sql select * from test.st2;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
print =============== case 10: database read privilege and table write privilege with condition
|
||||
sql close
|
||||
sql connect
|
||||
|
||||
sql revoke write on test.st1 from wxy;
|
||||
sql grant write on test.st1 with id = 1 to wxy;
|
||||
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql select * from test.st1;
|
||||
if $rows != 8 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into test.st1s1 values(now, 10);
|
||||
sql_error insert into test.st1s2 values(now, 20);
|
||||
sql select * from test.st2;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
print =============== case 11: database write privilege and table unauthorized
|
||||
sql close
|
||||
sql connect
|
||||
|
||||
sql revoke read on test.* from wxy;
|
||||
sql revoke write on test.st1 with id = 1 from wxy;
|
||||
sql grant write on test.* to wxy;
|
||||
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql_error select * from test.st1;
|
||||
sql insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
|
||||
sql_error select * from test.st2;
|
||||
sql insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
print =============== case 12: database write privilege and table read privilege
|
||||
sql close
|
||||
sql connect
|
||||
|
||||
sql grant read on test.st1 to wxy;
|
||||
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql select * from test.st1;
|
||||
if $rows != 11 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
|
||||
sql_error select * from test.st2;
|
||||
sql insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
print =============== case 13: database write privilege and table read privilege with condition
|
||||
sql close
|
||||
sql connect
|
||||
|
||||
sql revoke read on test.st1 from wxy;
|
||||
sql grant read on test.st1 with id = 1 to wxy;
|
||||
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql select * from test.st1;
|
||||
if $rows != 8 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
|
||||
sql_error select * from test.st2;
|
||||
sql insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
print =============== case 14: database write privilege and table write privilege
|
||||
sql close
|
||||
sql connect
|
||||
|
||||
sql revoke read on test.st1 with id = 1 from wxy;
|
||||
sql grant write on test.st1 to wxy;
|
||||
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql_error select * from test.st1;
|
||||
sql insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
|
||||
sql_error select * from test.st2;
|
||||
sql insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
print =============== case 15: database write privilege and table write privilege with condition
|
||||
sql close
|
||||
sql connect
|
||||
|
||||
sql revoke write on test.st1 from wxy;
|
||||
sql grant write on test.st1 with id = 1 to wxy;
|
||||
|
||||
sql close
|
||||
sql connect wxy
|
||||
|
||||
sql reset query cache;
|
||||
sql_error select * from test.st1;
|
||||
sql insert into test.st1s1 values(now, 10);
|
||||
sql_error insert into test.st1s2 values(now, 20);
|
||||
sql_error select * from test.st2;
|
||||
sql insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -3,6 +3,7 @@
|
|||
./test.sh -f tsim/user/privilege_db.sim
|
||||
./test.sh -f tsim/user/privilege_sysinfo.sim
|
||||
./test.sh -f tsim/user/privilege_topic.sim
|
||||
./test.sh -f tsim/user/privilege_table.sim
|
||||
./test.sh -f tsim/db/alter_option.sim
|
||||
rem ./test.sh -f tsim/db/alter_replica_13.sim
|
||||
./test.sh -f tsim/db/alter_replica_31.sim
|
||||
|
|
|
@ -17,12 +17,12 @@ from util.dnodes import TDDnode
|
|||
from util.cluster import *
|
||||
import subprocess
|
||||
|
||||
BASEVERSION = "3.0.1.8"
|
||||
BASEVERSION = "3.0.2.3"
|
||||
class TDTestCase:
|
||||
def caseDescription(self):
|
||||
'''
|
||||
f'''
|
||||
3.0 data compatibility test
|
||||
case1: basedata version is 3.0.1.8
|
||||
case1: basedata version is {BASEVERSION}
|
||||
'''
|
||||
return
|
||||
|
||||
|
|
|
@ -0,0 +1,263 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.common import *
|
||||
from util.sqlset import *
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
|
||||
self.replicaVar = int(replicaVar)
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor())
|
||||
self.setsql = TDSetSql()
|
||||
|
||||
def basic(self):
|
||||
tdLog.info("============== basic test ===============")
|
||||
cfg={
|
||||
'/mnt/data1' : 'dataDir',
|
||||
'/mnt/data2 0 0' : 'dataDir'
|
||||
}
|
||||
tdSql.createDir('/mnt/data1')
|
||||
tdSql.createDir('/mnt/data2')
|
||||
|
||||
tdLog.info("================= step1")
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.deploy(1,cfg)
|
||||
tdDnodes.start(1)
|
||||
|
||||
tdLog.info("================= step2")
|
||||
tdSql.haveFile('/mnt/data1/',1)
|
||||
tdSql.haveFile('/mnt/data2/',0)
|
||||
tdDnodes.stop(1)
|
||||
def dir_not_exist(self):
|
||||
tdLog.info("============== dir_not_exist test ===============")
|
||||
cfg={
|
||||
'/mnt/data1 0 0' : 'dataDir',
|
||||
'/mnt/data2 0 0' : 'dataDir'
|
||||
}
|
||||
tdSql.createDir('/mnt/data1')
|
||||
os.system('rm -rf /mnt/data2')
|
||||
|
||||
|
||||
tdLog.info("================= step1")
|
||||
tdDnodes.deploy(1,cfg)
|
||||
tdDnodes.startWithoutSleep(1)
|
||||
|
||||
tdLog.info("================= step2")
|
||||
tdSql.taosdStatus(0)
|
||||
|
||||
def dir_permission_denied(self):
|
||||
tdDnodes.stop(1)
|
||||
tdLog.info("============== dir_permission_denied test ===============")
|
||||
cfg={
|
||||
'/mnt/data1 0 0' : 'dataDir',
|
||||
'/mnt/data2 0 0' : 'dataDir'
|
||||
}
|
||||
tdSql.createDir('/mnt/data1')
|
||||
tdSql.createDir('/mnt/data2')
|
||||
os.system('chmod 111 /mnt/data2')
|
||||
|
||||
tdLog.info("================= step1")
|
||||
tdDnodes.deploy(1,cfg)
|
||||
tdDnodes.startWithoutSleep(1)
|
||||
|
||||
tdLog.info("================= step2")
|
||||
tdSql.taosdStatus(0)
|
||||
|
||||
def file_distribution_same_level(self):
|
||||
tdLog.info("============== file_distribution_same_level test ===============")
|
||||
dataDir = ['data00','data01','data02','data03','data04']
|
||||
dataDict = {'data00':0,'data01':0,'data02':0,'data03':0,'data04':0}
|
||||
tdDnodes.stop(1)
|
||||
self.ntables = 1000
|
||||
self.ts = 1520000010000
|
||||
tdLog.info("================= step1")
|
||||
cfg={
|
||||
'/mnt/data00 0 1' : 'dataDir',
|
||||
'/mnt/data01 0 0' : 'dataDir',
|
||||
'/mnt/data02 0 0' : 'dataDir',
|
||||
'/mnt/data03 0 0' : 'dataDir',
|
||||
'/mnt/data04 0 0' : 'dataDir'
|
||||
}
|
||||
dir_list = ['/mnt/data00','/mnt/data01','/mnt/data02','/mnt/data03','/mnt/data04']
|
||||
for i in dir_list:
|
||||
tdSql.createDir(i)
|
||||
tdDnodes.deploy(1,cfg)
|
||||
tdDnodes.start(1)
|
||||
|
||||
tdSql.execute("create database test duration 1")
|
||||
tdSql.execute("use test")
|
||||
|
||||
tdSql.execute("create table stb(ts timestamp, c int) tags(t int)")
|
||||
|
||||
for i in range(self.ntables):
|
||||
tdSql.execute("create table tb%d using stb tags(%d)" %(i, i))
|
||||
tdSql.execute("insert into tb%d values(%d, 1)" % (i,self.ts + int (i / 100) * 86400000))
|
||||
|
||||
tdLog.info("================= step2")
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from test.stb")
|
||||
tdSql.checkRows(1000)
|
||||
tdLog.info("================= step3")
|
||||
tdSql.execute('drop database test')
|
||||
for i in range(50):
|
||||
tdSql.execute("create database test%d duration 1" %(i))
|
||||
tdSql.execute("use test%d" %(i))
|
||||
tdSql.execute("create table tb (ts timestamp,i int)")
|
||||
for j in range(10):
|
||||
tdSql.execute("insert into tb values(%d, 1)" % (self.ts + int (i / 100) * 86400000))
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
flag = True
|
||||
for i in range(4):
|
||||
if dataDict[dataDir[i]] == dataDict[dataDir[i+1]]:
|
||||
flag = flag & True
|
||||
else:
|
||||
flag = flag & False
|
||||
break
|
||||
if not flag : tdLog.exit("%s failed, expect not occured" % (sys.argv[0]))
|
||||
|
||||
def three_level_basic(self):
|
||||
tdLog.info("============== three_level_basic test ===============")
|
||||
tdDnodes.stop(1)
|
||||
# Test1 1 dataDir
|
||||
cfg={
|
||||
'/mnt/data000 0 1' : 'dataDir',
|
||||
'/mnt/data001 0 0' : 'dataDir',
|
||||
'/mnt/data002 0 0' : 'dataDir',
|
||||
'/mnt/data010 1 0' : 'dataDir',
|
||||
'/mnt/data011 1 0' : 'dataDir',
|
||||
'/mnt/data012 1 0' : 'dataDir',
|
||||
'/mnt/data020 2 0' : 'dataDir',
|
||||
'/mnt/data021 2 0' : 'dataDir',
|
||||
'/mnt/data022 2 0' : 'dataDir'
|
||||
}
|
||||
dir_list = ['/mnt/data000','/mnt/data001','/mnt/data002','/mnt/data010','/mnt/data011','/mnt/data012','/mnt/data020','/mnt/data021''/mnt/data022']
|
||||
for i in dir_list:
|
||||
tdSql.createDir(i)
|
||||
|
||||
tdDnodes.deploy(1,cfg)
|
||||
tdDnodes.start(1)
|
||||
for i in dir_list:
|
||||
if i == '/mnt/data000':
|
||||
tdSql.haveFile(i,1)
|
||||
else:
|
||||
tdSql.haveFile(i,0)
|
||||
|
||||
def more_than_16_disks(self):
|
||||
tdLog.info("============== more_than_16_disks test ===============")
|
||||
cfg={}
|
||||
for i in range(17):
|
||||
if i == 0 :
|
||||
datadir = '/mnt/data%d 0 1' % (i+1)
|
||||
else:
|
||||
datadir = '/mnt/data%d 0 0' % (i+1)
|
||||
cfg.update({ datadir : 'dataDir' })
|
||||
tdSql.createDir('/mnt/data%d' % (i+1))
|
||||
|
||||
tdLog.info("================= step1")
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.deploy(1,cfg)
|
||||
tdDnodes.startWithoutSleep(1)
|
||||
|
||||
tdLog.info("================= step2")
|
||||
tdSql.taosdStatus(0)
|
||||
|
||||
def missing_middle_level(self):
|
||||
tdLog.info("============== missing_middle_level test ===============")
|
||||
tdDnodes.stop(1)
|
||||
# Test1 1 dataDir
|
||||
cfg={
|
||||
'/mnt/data1 1 0' : 'dataDir'
|
||||
}
|
||||
tdSql.createDir('/mnt/data1')
|
||||
|
||||
tdDnodes.deploy(1,cfg)
|
||||
tdDnodes.startWithoutSleep(1)
|
||||
|
||||
tdSql.taosdStatus(0)
|
||||
tdDnodes.stop(1)
|
||||
# Test2 2 dataDir
|
||||
cfg = {
|
||||
'/mnt/data1 0 1' : 'dataDir',
|
||||
'/mnt/data1 2 0' : 'dataDir'
|
||||
}
|
||||
tdSql.createDir('/mnt/data1')
|
||||
|
||||
tdDnodes.deploy(1,cfg)
|
||||
tdDnodes.startWithoutSleep(1)
|
||||
|
||||
tdSql.taosdStatus(0)
|
||||
|
||||
def trim_database(self):
|
||||
tdLog.info("============== trim_database test ===============")
|
||||
tdDnodes.stop(1)
|
||||
cfg = {
|
||||
'/mnt/data1 0 1' : 'dataDir'
|
||||
|
||||
}
|
||||
tdSql.createDir('/mnt/data1')
|
||||
tdDnodes.deploy(1,cfg)
|
||||
tdDnodes.start(1)
|
||||
|
||||
tdSql.execute('create database dbtest')
|
||||
tdSql.execute('use dbtest')
|
||||
tdSql.execute('create table stb (ts timestamp,c0 int) tags(t0 int)')
|
||||
tdSql.execute('create table tb1 using stb tags(1)')
|
||||
for i in range(10,30):
|
||||
tdSql.execute(f'insert into tb1 values(now-{i}d,10)')
|
||||
tdSql.execute('flush database dbtest')
|
||||
tdSql.haveFile('/mnt/data1/',1)
|
||||
tdDnodes.stop(1)
|
||||
cfg={
|
||||
'/mnt/data1 0 1' : 'dataDir',
|
||||
'/mnt/data2 1 0' : 'dataDir',
|
||||
'/mnt/data3 2 0' : 'dataDir',
|
||||
}
|
||||
tdSql.createDir('/mnt/data2')
|
||||
tdSql.createDir('/mnt/data3')
|
||||
tdDnodes.deploy(1,cfg)
|
||||
tdDnodes.start(1)
|
||||
tdSql.haveFile('/mnt/data1/',1)
|
||||
tdSql.haveFile('/mnt/data2/',0)
|
||||
tdSql.haveFile('/mnt/data3/',0)
|
||||
tdSql.execute('alter database dbtest keep 10d,365d,3650d')
|
||||
tdSql.execute('trim database dbtest')
|
||||
time.sleep(3)
|
||||
tdSql.haveFile('/mnt/data1/',1)
|
||||
tdSql.haveFile('/mnt/data2/',1)
|
||||
|
||||
def run(self):
|
||||
self.basic()
|
||||
self.dir_not_exist()
|
||||
self.dir_permission_denied()
|
||||
self.file_distribution_same_level()
|
||||
self.three_level_basic()
|
||||
self.more_than_16_disks()
|
||||
self.trim_database()
|
||||
self.missing_middle_level()
|
||||
|
||||
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,114 @@
|
|||
import taos
|
||||
import sys
|
||||
import time
|
||||
import socket
|
||||
import os
|
||||
import threading
|
||||
import datetime
|
||||
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
from util.cases import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
self.replicaVar = int(replicaVar)
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def checkVgroups(self, dbName, vgNum):
|
||||
sleepNum = vgNum * 60
|
||||
flag = 0
|
||||
while (sleepNum > 0):
|
||||
sql = f'show {dbName}.vgroups'
|
||||
tdSql.query(sql)
|
||||
flag = 0
|
||||
for vgid in range (vgNum) :
|
||||
v1_status = tdSql.queryResult[vgid][4]
|
||||
v2_status = tdSql.queryResult[vgid][6]
|
||||
v3_status = tdSql.queryResult[vgid][8]
|
||||
if ((v1_status == 'leader') and (v2_status == 'follower') and (v3_status == 'follower')) \
|
||||
or ((v2_status == 'leader') and (v1_status == 'follower') and (v3_status == 'follower')) \
|
||||
or ((v3_status == 'leader') and (v2_status == 'follower') and (v1_status == 'follower')):
|
||||
continue
|
||||
else:
|
||||
sleepNum = sleepNum - 1
|
||||
time.sleep(1)
|
||||
flag = 1
|
||||
break
|
||||
if (0 == flag):
|
||||
return 0
|
||||
tdLog.debug("vgroup[%d] status: %s, %s, %s" %(vgid,v1_status,v2_status,v3_status))
|
||||
return -1
|
||||
|
||||
def alter_replica(self):
|
||||
# create db and alter replica
|
||||
tdLog.debug("====alter db repica 1====")
|
||||
vgNum = 3
|
||||
dbName = 'db1'
|
||||
sql = f'create database {dbName} vgroups {vgNum}'
|
||||
tdSql.execute(sql)
|
||||
sql = f'alter database {dbName} replica 3'
|
||||
tdSql.execute(sql)
|
||||
tdLog.debug("start check time: %s"%(str(datetime.datetime.now())))
|
||||
res = self.checkVgroups(dbName, vgNum)
|
||||
tdLog.debug("end check time: %s"%(str(datetime.datetime.now())))
|
||||
if (0 != res):
|
||||
tdLog.exit(f'fail: alter database {dbName} replica 3')
|
||||
|
||||
# create db, stable, child tables, and insert data, then alter replica
|
||||
tdLog.debug("====alter db repica 2====")
|
||||
dbName = 'db2'
|
||||
sql = f'create database {dbName} vgroups {vgNum}'
|
||||
tdSql.execute(sql)
|
||||
sql = f'use {dbName}'
|
||||
tdSql.execute(sql)
|
||||
sql = f'create stable stb (ts timestamp, c int) tags (t int)'
|
||||
tdSql.execute(sql)
|
||||
sql = f'create table ctb using stb tags (1)'
|
||||
tdSql.execute(sql)
|
||||
sql = f'insert into ctb values (now, 1) (now+1s, 2) (now+2s, 3)'
|
||||
tdSql.execute(sql)
|
||||
sql = f'alter database {dbName} replica 3'
|
||||
tdSql.execute(sql)
|
||||
tdLog.debug("start check time: %s"%(str(datetime.datetime.now())))
|
||||
res = self.checkVgroups(dbName, vgNum)
|
||||
tdLog.debug("end check time: %s"%(str(datetime.datetime.now())))
|
||||
if (0 != res):
|
||||
tdLog.exit(f'fail: alter database {dbName} replica 3')
|
||||
|
||||
# firstly create db, stable, child tables, and insert data, then drop stable, and then alter replica
|
||||
tdLog.debug("====alter db repica 3====")
|
||||
dbName = 'db3'
|
||||
sql = f'create database {dbName} vgroups {vgNum}'
|
||||
tdSql.execute(sql)
|
||||
sql = f'use {dbName}'
|
||||
tdSql.execute(sql)
|
||||
sql = f'create stable stb (ts timestamp, c int) tags (t int)'
|
||||
tdSql.execute(sql)
|
||||
sql = f'create table ctb using stb tags (1)'
|
||||
tdSql.execute(sql)
|
||||
sql = f'insert into ctb values (now, 1) (now+1s, 2) (now+2s, 3)'
|
||||
tdSql.execute(sql)
|
||||
sql = f'drop table stb'
|
||||
tdSql.execute(sql)
|
||||
sql = f'alter database {dbName} replica 3'
|
||||
tdSql.execute(sql)
|
||||
tdLog.debug("start check time: %s"%(str(datetime.datetime.now())))
|
||||
res = self.checkVgroups(dbName, vgNum)
|
||||
tdLog.debug("end check time: %s"%(str(datetime.datetime.now())))
|
||||
if (0 != res):
|
||||
tdLog.exit(f'fail: alter database {dbName} replica 3')
|
||||
|
||||
def run(self):
|
||||
self.alter_replica()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -24,9 +24,7 @@ from util.dnodes import tdDnodes
|
|||
from util.dnodes import *
|
||||
|
||||
class TDTestCase:
|
||||
updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
|
||||
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
|
||||
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143}
|
||||
updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 135}
|
||||
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
self.replicaVar = int(replicaVar)
|
||||
|
@ -39,7 +37,9 @@ class TDTestCase:
|
|||
|
||||
self.db = "pre_suf"
|
||||
|
||||
def dropandcreateDB_random(self,database,n,vgroups,table_prefix,table_suffix,check_result):
|
||||
def dropandcreateDB_random(self,database,n,vgroups,table_prefix,table_suffix,check_result_positive,check_result_negative):
|
||||
#check_result_positive 检查前缀后缀是正数的,check_result_negative 检查前缀后缀是负数的(TS-3249)
|
||||
tdLog.info(f"create start:n:{n},vgroups:{vgroups},table_prefix:{table_prefix},table_suffix:{table_suffix},check_result_positive:{check_result_positive},check_result_negative:{check_result_negative}")
|
||||
ts = 1630000000000
|
||||
num_random = 100
|
||||
fake = Faker('zh_CN')
|
||||
|
@ -56,6 +56,7 @@ class TDTestCase:
|
|||
q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \
|
||||
tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''')
|
||||
|
||||
#positive
|
||||
for i in range(10*n):
|
||||
tdSql.execute('''create table bj_%d (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp ) ;'''%i)
|
||||
tdSql.execute('''create table sh_%d (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp ) ;'''%i)
|
||||
|
@ -106,11 +107,60 @@ class TDTestCase:
|
|||
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
|
||||
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
|
||||
|
||||
|
||||
#negative
|
||||
for i in range(10*n):
|
||||
tdSql.execute('''create table bj_table_%d_r_negative (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp ) ;'''%i)
|
||||
tdSql.execute('''create table sh_table_%d_r_negative (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp ) ;'''%i)
|
||||
tdSql.execute('''create table hn_table_%d_r_negative \
|
||||
(ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \
|
||||
q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\
|
||||
q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\
|
||||
q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;'''%i)
|
||||
|
||||
tdSql.execute('''create table bj_stable_1_%d_negative using stable_1 tags('bj_stable_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;'''
|
||||
%(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
|
||||
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
|
||||
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
|
||||
tdSql.execute('''create table sh_table_%d_a_negative using stable_1 tags('sh_a_table_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;'''
|
||||
%(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
|
||||
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
|
||||
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
|
||||
tdSql.execute('''create table sh_table_%d_b_negative using stable_1 tags('sh_b_table_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;'''
|
||||
%(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
|
||||
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
|
||||
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
|
||||
tdSql.execute('''create table sh_table_%d_c_negative using stable_1 tags('sh_c_table_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;'''
|
||||
%(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
|
||||
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
|
||||
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
|
||||
|
||||
tdSql.execute('''create table bj_table_%d_a_negative using stable_1 tags('bj_a_table_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;'''
|
||||
%(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
|
||||
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
|
||||
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
|
||||
tdSql.execute('''create table bj_table_%d_b_negative using stable_1 tags('bj_b_table_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;'''
|
||||
%(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
|
||||
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
|
||||
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
|
||||
tdSql.execute('''create table bj_table_%d_c_negative using stable_1 tags('bj_c_table_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;'''
|
||||
%(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
|
||||
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
|
||||
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
|
||||
|
||||
|
||||
tdSql.execute('''create table tj_table_%d_a_negative using stable_2 tags('tj_a_table_2_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;'''
|
||||
%(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
|
||||
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
|
||||
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
|
||||
tdSql.execute('''create table tj_table_%d_b_negative using stable_2 tags('tj_b_table_2_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;'''
|
||||
%(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
|
||||
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
|
||||
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
|
||||
|
||||
# create stream
|
||||
tdSql.execute('''create stream current_stream trigger at_once IGNORE EXPIRED 0 into stream_max_stable_1 as select _wstart as startts, _wend as wend, max(q_int) as max_int, min(q_bigint) as min_int from stable_1 where ts is not null interval (5s);''')
|
||||
|
||||
# insert data
|
||||
# insert data positive
|
||||
for i in range(num_random*n):
|
||||
tdSql.execute('''insert into bj_stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts,\
|
||||
q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \
|
||||
|
@ -180,8 +230,60 @@ class TDTestCase:
|
|||
fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() ,
|
||||
fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr()))
|
||||
|
||||
# insert data negative
|
||||
for i in range(num_random*n):
|
||||
tdSql.execute('''insert into bj_stable_1_1_negative (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts,\
|
||||
q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \
|
||||
values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \
|
||||
'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;'''
|
||||
% (ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1),
|
||||
fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
|
||||
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
|
||||
fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() ,
|
||||
fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr()))
|
||||
|
||||
tdSql.execute('''insert into bj_stable_1_2_negative (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\
|
||||
q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8)\
|
||||
values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \
|
||||
'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;'''
|
||||
% (ts + i*1000, fake.random_int(min=0, max=2147483647, step=1),
|
||||
fake.random_int(min=0, max=9223372036854775807, step=1),
|
||||
fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) ,
|
||||
fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() ,
|
||||
fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr()))
|
||||
|
||||
tdSql.execute('''insert into bj_stable_1_3_negative (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\
|
||||
q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \
|
||||
values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \
|
||||
'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;'''
|
||||
% (ts + i*1000, fake.random_int(min=-0, max=2147483647, step=1),
|
||||
fake.random_int(min=-0, max=9223372036854775807, step=1),
|
||||
fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) ,
|
||||
fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() ,
|
||||
fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr()))
|
||||
|
||||
tdSql.execute('''insert into bj_stable_1_4_negative (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\
|
||||
q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \
|
||||
values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \
|
||||
'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;'''
|
||||
% (ts + i*1000 +1, fake.random_int(min=-0, max=2147483647, step=1),
|
||||
fake.random_int(min=-0, max=9223372036854775807, step=1),
|
||||
fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) ,
|
||||
fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() ,
|
||||
fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr()))
|
||||
|
||||
tdSql.execute('''insert into bj_stable_1_5_negative (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\
|
||||
q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \
|
||||
values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \
|
||||
'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;'''
|
||||
% (ts + i*1000 +10, fake.random_int(min=-0, max=2147483647, step=1),
|
||||
fake.random_int(min=-0, max=9223372036854775807, step=1),
|
||||
fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) ,
|
||||
fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() ,
|
||||
fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr()))
|
||||
|
||||
tdSql.query("select count(*) from stable_1;")
|
||||
tdSql.checkData(0,0,5*num_random*n)
|
||||
tdSql.checkData(0,0,10*num_random*n)
|
||||
tdSql.query("select count(*) from hn_table_1_r;")
|
||||
tdSql.checkData(0,0,num_random*n)
|
||||
|
||||
|
@ -220,39 +322,28 @@ class TDTestCase:
|
|||
|
||||
|
||||
tdSql.query(" select * from information_schema.ins_databases where name = '%s';" %database)
|
||||
print(tdSql.queryResult)
|
||||
tdLog.info(tdSql.queryResult)
|
||||
|
||||
# tdSql.query(" select table_prefix,table_suffix from information_schema.ins_databases where name = '%s';" %database)
|
||||
# print(tdSql.queryResult)
|
||||
#TD-19082
|
||||
|
||||
#tdSql.query(" select * from information_schema.ins_tables where db_name = '%s';" %database)
|
||||
#print(tdSql.queryResult)
|
||||
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s';" %database)
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' limit 3;" %database)
|
||||
queryRows = len(tdSql.queryResult)
|
||||
for i in range(queryRows):
|
||||
print("row=%d, vgroup_id=%s, tbname=%s " %(i,tdSql.queryResult[i][1],tdSql.queryResult[i][0]))
|
||||
tdLog.info("row=%d, vgroup_id=%s, tbname=%s " %(i,tdSql.queryResult[i][1],tdSql.queryResult[i][0]))
|
||||
|
||||
tdLog.info("\n=============flush database ====================\n")
|
||||
|
||||
tdSql.execute(" flush database %s;" %database)
|
||||
|
||||
tdSql.query(" select * from information_schema.ins_databases where name = '%s';" %database)
|
||||
print(tdSql.queryResult)
|
||||
|
||||
# tdSql.query(" select table_prefix,table_suffix from information_schema.ins_databases where name = '%s';" %database)
|
||||
# print(tdSql.queryResult)
|
||||
#TD-19082
|
||||
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s';" %database)
|
||||
tdLog.info(tdSql.queryResult)
|
||||
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' limit 3;" %database)
|
||||
queryRows = len(tdSql.queryResult)
|
||||
for i in range(queryRows):
|
||||
print("row=%d, vgroup_id=%s, tbname=%s " %(i,tdSql.queryResult[i][1],tdSql.queryResult[i][0]))
|
||||
tdLog.info("row=%d, vgroup_id=%s, tbname=%s " %(i,tdSql.queryResult[i][1],tdSql.queryResult[i][0]))
|
||||
|
||||
|
||||
# check in one vgroup
|
||||
if check_result == 'Y':
|
||||
if check_result_positive == 'Y':
|
||||
#base table : sh_table_0_a
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='sh_table_0_a';" %(database))
|
||||
base_value_table_name = tdSql.queryResult[0][0]
|
||||
|
@ -324,8 +415,100 @@ class TDTestCase:
|
|||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='tj_table_%d_b';" %(database,i))
|
||||
self.value_check(base_value_table_name,base_value_table_vgroup)
|
||||
|
||||
elif check_result_negative == 'Y':
|
||||
#base table : sh_table_0_a
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='sh_table_0_a_negative';" %(database))
|
||||
base_value_table_name = tdSql.queryResult[0][0]
|
||||
base_value_table_vgroup = tdSql.queryResult[0][1]
|
||||
|
||||
#check table :sh_table_i_a
|
||||
check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'sh_table_%%_a_negative';" %(database))
|
||||
for i in range(check_rows):
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='sh_table_%d_a_negative';" %(database,i))
|
||||
self.value_check(base_value_table_name,base_value_table_vgroup)
|
||||
|
||||
#check table :sh_table_i_b
|
||||
check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'sh_table_%%_b_negative';" %(database))
|
||||
for i in range(check_rows):
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='sh_table_%d_b_negative';" %(database,i))
|
||||
self.value_check(base_value_table_name,base_value_table_vgroup)
|
||||
|
||||
#check table :sh_table_i_c
|
||||
check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'sh_table_%%_c_negative';" %(database))
|
||||
for i in range(check_rows):
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='sh_table_%d_c_negative';" %(database,i))
|
||||
self.value_check(base_value_table_name,base_value_table_vgroup)
|
||||
|
||||
#check table :sh_table_i_r
|
||||
check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'sh_table_%%_r_negative';" %(database))
|
||||
for i in range(check_rows):
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='sh_table_%d_r_negative';" %(database,i))
|
||||
self.value_check(base_value_table_name,base_value_table_vgroup)
|
||||
|
||||
#base table : bj_table_0_a
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='bj_table_0_a_negative';" %(database))
|
||||
base_value_table_name = tdSql.queryResult[0][0]
|
||||
base_value_table_vgroup = tdSql.queryResult[0][1]
|
||||
|
||||
#check table :bj_table_i_a
|
||||
check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'bj_table_%%_a_negative';" %(database))
|
||||
for i in range(check_rows):
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='bj_table_%d_a_negative';" %(database,i))
|
||||
self.value_check(base_value_table_name,base_value_table_vgroup)
|
||||
|
||||
#check table :bj_table_i_b
|
||||
check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'bj_table_%%_b_negative';" %(database))
|
||||
for i in range(check_rows):
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='bj_table_%d_b_negative';" %(database,i))
|
||||
self.value_check(base_value_table_name,base_value_table_vgroup)
|
||||
|
||||
#check table :bj_table_i_c
|
||||
check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'bj_table_%%_c_negative';" %(database))
|
||||
for i in range(check_rows):
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='bj_table_%d_c_negative';" %(database,i))
|
||||
self.value_check(base_value_table_name,base_value_table_vgroup)
|
||||
|
||||
#check table :bj_table_i_r
|
||||
check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'bj_table_%%_r_negative';" %(database))
|
||||
for i in range(check_rows):
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='bj_table_%d_r_negative';" %(database,i))
|
||||
self.value_check(base_value_table_name,base_value_table_vgroup)
|
||||
|
||||
#base table : hn_table_0_r
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='hn_table_0_r_negative';" %(database))
|
||||
base_value_table_name = tdSql.queryResult[0][0]
|
||||
base_value_table_vgroup = tdSql.queryResult[0][1]
|
||||
|
||||
#check table :hn_table_i_r
|
||||
check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'hn_table_%%_r_negative';" %(database))
|
||||
for i in range(check_rows):
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='hn_table_%d_r_negative';" %(database,i))
|
||||
self.value_check(base_value_table_name,base_value_table_vgroup)
|
||||
|
||||
|
||||
#base table : tj_table_0_r
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='tj_table_0_a_negative';" %(database))
|
||||
base_value_table_name = tdSql.queryResult[0][0]
|
||||
base_value_table_vgroup = tdSql.queryResult[0][1]
|
||||
|
||||
#check table :tj_table_i_a
|
||||
check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'tj_table_%%_a_negative';" %(database))
|
||||
for i in range(check_rows):
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='tj_table_%d_a_negative';" %(database,i))
|
||||
self.value_check(base_value_table_name,base_value_table_vgroup)
|
||||
|
||||
#check table :tj_table_i_b
|
||||
check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'tj_table_%%_b_negative';" %(database))
|
||||
for i in range(check_rows):
|
||||
tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='tj_table_%d_b_negative';" %(database,i))
|
||||
self.value_check(base_value_table_name,base_value_table_vgroup)
|
||||
|
||||
|
||||
else:
|
||||
pass
|
||||
|
||||
tdLog.info(f"create end:n:{n},vgroups:{vgroups},table_prefix:{table_prefix},table_suffix:{table_suffix},check_result_positive:{check_result_positive},check_result_negative:{check_result_negative}")
|
||||
|
||||
|
||||
def value_check(self,base_value_table_name,base_value_table_vgroup):
|
||||
check_value_table_name = tdSql.queryResult[0][0]
|
||||
|
@ -348,17 +531,28 @@ class TDTestCase:
|
|||
|
||||
os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))
|
||||
|
||||
#(self,database,n,vgroups,table_prefix,table_suffix)
|
||||
self.dropandcreateDB_random("%s" %self.db, 1,2,0,0,'N')
|
||||
self.dropandcreateDB_random("%s" %self.db, 1,2,0,2,'N')
|
||||
self.dropandcreateDB_random("%s" %self.db, 1,2,2,0,'N')
|
||||
self.dropandcreateDB_random("%s" %self.db, 1,2,3,3,'Y')
|
||||
self.dropandcreateDB_random("%s" %self.db, 1,3,3,3,'Y')
|
||||
self.dropandcreateDB_random("%s" %self.db, 1,4,4,4,'Y')
|
||||
self.dropandcreateDB_random("%s" %self.db, 1,5,5,5,'Y')
|
||||
#(self,database,n,vgroups,table_prefix,table_suffix,check_result_positive,check_result_negative):
|
||||
#check_result_positive 检查前缀后缀是正数的,check_result_negative 检查前缀后缀是负数的(TS-3249)
|
||||
# self.dropandcreateDB_random("%s" %self.db, 1,2,0,0,'N','N')
|
||||
# self.dropandcreateDB_random("%s" %self.db, 1,2,0,2,'N','N')
|
||||
# self.dropandcreateDB_random("%s" %self.db, 1,2,2,0,'N','N')
|
||||
|
||||
self.dropandcreateDB_random("%s" %self.db, 1,random.randint(1,5),random.randint(0,3),random.randint(0,3),'N','N')
|
||||
self.dropandcreateDB_random("%s" %self.db, 1,random.randint(1,5),random.randint(-10,0),random.randint(-10,0),'N','N')
|
||||
self.dropandcreateDB_random("%s" %self.db, 1,random.randint(1,5),random.randint(-191,0),random.randint(-191,0),'N','N')
|
||||
self.dropandcreateDB_random("%s" %self.db, 1,random.randint(1,5),random.randint(0,100),random.randint(0,91),'N','N')
|
||||
|
||||
# self.dropandcreateDB_random("%s" %self.db, 1,2,3,3,'Y','N')
|
||||
# self.dropandcreateDB_random("%s" %self.db, 1,3,3,3,'Y','N')
|
||||
# self.dropandcreateDB_random("%s" %self.db, 1,4,4,4,'Y','N')
|
||||
# self.dropandcreateDB_random("%s" %self.db, 1,5,5,5,'Y','N')
|
||||
self.dropandcreateDB_random("%s" %self.db, 1,random.randint(1,5),random.randint(3,5),random.randint(3,5),'Y','N')
|
||||
|
||||
self.dropandcreateDB_random("%s" %self.db, 1,random.randint(1,5),random.randint(-5,-1),0,'N','Y')
|
||||
self.dropandcreateDB_random("%s" %self.db, 1,random.randint(1,5),random.randint(-5,-1),random.randint(-9,-0),'N','Y')
|
||||
|
||||
|
||||
#taos -f sql
|
||||
# #taos -f sql
|
||||
print("taos -f sql start!")
|
||||
taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename)
|
||||
_ = subprocess.check_output(taos_cmd1, shell=True)
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
|
||||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import random
|
||||
import string
|
||||
|
||||
from numpy import logspace
|
||||
from util import constant
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.common import *
|
||||
from util.sqlset import TDSetSql
|
||||
|
||||
info_schema_db = "information_schema"
|
||||
perf_schema_db = "performance_schema"
|
||||
|
||||
info_schema_tables = [
|
||||
"ins_dnodes",
|
||||
"ins_mnodes",
|
||||
"ins_modules",
|
||||
"ins_qnodes",
|
||||
"ins_snodes",
|
||||
"ins_cluster",
|
||||
"ins_databases",
|
||||
"ins_functions",
|
||||
"ins_indexes",
|
||||
"ins_stables",
|
||||
"ins_tables",
|
||||
"ins_tags",
|
||||
"ins_columns",
|
||||
"ins_users",
|
||||
"ins_grants",
|
||||
"ins_vgroups",
|
||||
"ins_configs",
|
||||
"ins_dnode_variables",
|
||||
"ins_topics",
|
||||
"ins_subscriptions",
|
||||
"ins_streams",
|
||||
"ins_streams_tasks",
|
||||
"ins_vnodes",
|
||||
"ins_user_privileges"
|
||||
]
|
||||
|
||||
perf_schema_tables = [
|
||||
"perf_connections",
|
||||
"perf_queries",
|
||||
"perf_consumers",
|
||||
"perf_trans",
|
||||
"perf_apps"
|
||||
]
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
self.replicaVar = int(replicaVar)
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor())
|
||||
|
||||
def delete_systb(self):
|
||||
tdSql.execute(f'use {info_schema_db}')
|
||||
for i in info_schema_tables:
|
||||
tdSql.error(f'delete from {i}')
|
||||
tdSql.error(f'delete from {info_schema_db}.{i}')
|
||||
tdSql.error(f'delete from {i} where ts >= 0')
|
||||
tdSql.error(f'delete from {info_schema_db}.{i} where ts >= 0')
|
||||
|
||||
tdSql.execute(f'use {perf_schema_db}')
|
||||
for i in perf_schema_tables:
|
||||
tdSql.error(f'delete from {i}')
|
||||
tdSql.error(f'delete from {perf_schema_db}.{i}')
|
||||
tdSql.error(f'delete from {i} where ts >= 0')
|
||||
tdSql.error(f'delete from {perf_schema_db}.{i} where ts >= 0')
|
||||
|
||||
def drop_systb(self):
|
||||
tdSql.execute(f'use {info_schema_db}')
|
||||
for i in info_schema_tables:
|
||||
tdSql.error(f'drop table {i}')
|
||||
tdSql.error(f'drop {info_schema_db}.{i}')
|
||||
tdSql.error(f'drop database {info_schema_db}')
|
||||
|
||||
tdSql.execute(f'use {perf_schema_db}')
|
||||
for i in perf_schema_tables:
|
||||
tdSql.error(f'drop table {i}')
|
||||
tdSql.error(f'drop table {perf_schema_db}.{i}')
|
||||
tdSql.error(f'drop database {perf_schema_db}')
|
||||
|
||||
def delete_from_systb(self):
|
||||
self.delete_systb()
|
||||
self.drop_systb()
|
||||
def run(self):
|
||||
self.delete_from_systb()
|
||||
tdDnodes.stoptaosd(1)
|
||||
tdDnodes.starttaosd(1)
|
||||
self.delete_from_systb()
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,446 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import random
|
||||
import os
|
||||
import time
|
||||
import taos
|
||||
import subprocess
|
||||
from faker import Faker
|
||||
from util.log import tdLog
|
||||
from util.cases import tdCases
|
||||
from util.sql import tdSql
|
||||
from util.dnodes import tdDnodes
|
||||
from util.dnodes import *
|
||||
|
||||
class TDTestCase:
|
||||
|
||||
def init(self, conn, logSql, replicaVar):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
self.testcasePath = os.path.split(__file__)[0]
|
||||
self.testcaseFilename = os.path.split(__file__)[-1]
|
||||
os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))
|
||||
|
||||
self.db = "sel_null"
|
||||
|
||||
def insert_data(self,database,vgroups):
|
||||
num_random = 10
|
||||
tdSql.execute('''drop database if exists %s ;''' %database)
|
||||
tdSql.execute('''create database %s keep 36500 vgroups %d PRECISION 'us';'''%(database,vgroups))
|
||||
tdSql.execute('''use %s;'''%database)
|
||||
|
||||
tdSql.execute('''create stable %s.stb0 (ts timestamp , c0 int , c1 double , c0null int , c1null double ) tags( t0 tinyint , t1 varchar(16) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint , t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);'''%database)
|
||||
|
||||
for i in range(5):
|
||||
tdSql.execute('''create table %s.stb0_%d using %s.stb0 tags(%d,'varchar%d',%d,%d, %d, %d,%d,'binary%d','nchar%d',%d,%d,%d ) ;'''%(database,i,database,i,i,i,i,i,i,i,i,i,i,i,i))
|
||||
|
||||
# insert data
|
||||
for i in range(num_random):
|
||||
for j in range(50):
|
||||
tdSql.execute('''insert into %s.stb0_0 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j))
|
||||
tdSql.execute('''insert into %s.stb0_1 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j))
|
||||
tdSql.execute('''insert into %s.stb0_2 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j))
|
||||
tdSql.execute('''insert into %s.stb0_3 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j))
|
||||
tdSql.execute('''insert into %s.stb0_4 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j))
|
||||
|
||||
tdSql.query("select count(*) from %s.stb0;" %database)
|
||||
tdSql.checkData(0,0,5*num_random*50)
|
||||
tdSql.query("select count(*) from %s.stb0_0;"%database)
|
||||
tdSql.checkData(0,0,num_random*50)
|
||||
|
||||
def ts_3085(self,database):
|
||||
sql = "select count(c0null) from(select * from %s.stb0 limit 20,4) "%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
|
||||
offset = random.randint(10,100)
|
||||
for i in range(offset):
|
||||
sql = "select count(c0null) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select count(c1null) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select count(c0) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,i)
|
||||
sql = "select count(c1) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,i)
|
||||
sql = "select count(t0) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,i)
|
||||
sql = "select count(t1) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,i)
|
||||
|
||||
|
||||
def ts_2974_max(self,database):
|
||||
sql = "select max(c0) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,49)
|
||||
sql = "select max(c0),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,49)
|
||||
sql = "select max(c1) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,49)
|
||||
sql = "select max(c1),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,49)
|
||||
|
||||
sql = "select max(c0null) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,"None")
|
||||
sql = "select max(c0null),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,"None")
|
||||
sql = "select max(c1null) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,"None")
|
||||
sql = "select max(c1null),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,"None")
|
||||
|
||||
sql = "select max(t0) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t0),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t1) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select max(t1),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select max(t_bool) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select max(t_bool),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select max(t_binary) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select max(t_binary),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select max(t_nchar) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select max(t_nchar),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select max(t_int) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_int),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_int) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_int),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_int) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_int),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_bigint) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_bigint),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_smallint) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_smallint),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_tinyint) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_tinyint),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_float) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_float),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_double) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
sql = "select max(t_double),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,4)
|
||||
|
||||
def ts_2974_min(self,database):
|
||||
sql = "select min(c0) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(c0),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(c1) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(c1),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
|
||||
sql = "select min(c0null) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,"None")
|
||||
sql = "select min(c0null),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,"None")
|
||||
sql = "select min(c1null) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,"None")
|
||||
sql = "select min(c1null),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,"None")
|
||||
|
||||
sql = "select min(t0) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t0),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t1) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select min(t1),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select min(t_bool) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select min(t_bool),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select min(t_binary) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select min(t_binary),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select min(t_nchar) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select min(t_nchar),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select min(t_int) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_int),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_int) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_int),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_int) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_int),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_bigint) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_bigint),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_smallint) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_smallint),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_tinyint) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_tinyint),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_float) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_float),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_double) from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
sql = "select min(t_double),ts from %s.stb0 where ts<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,0)
|
||||
|
||||
def ts_2601(self,database):
|
||||
|
||||
tdSql.query("alter local 'keepcolumnname' '0';")
|
||||
sql = "select ts,c0 from (select last(*) from %s.stb0 where ts<now);"%(database)
|
||||
tdSql.error(sql)
|
||||
sql = "select ts,c0 from (select last(*) from %s.stb0 where ts<now order by ts );"%(database)
|
||||
tdSql.error(sql)
|
||||
|
||||
tdSql.query("alter local 'keepcolumnname' '1';")
|
||||
sql = "select ts,c0 from (select last(*) from %s.stb0 where ts<now);"%(database)
|
||||
tdSql.query(sql)
|
||||
sql = "select ts,c0 from (select last(*) from %s.stb0 where ts<now order by ts );"%(database)
|
||||
tdSql.query(sql)
|
||||
|
||||
def ts_3108(self,database):
|
||||
|
||||
sql = "select count(*) from %s.stb0 where to_unixtimestamp('2023-01-01 00:00:00.000')<now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,2500)
|
||||
sql = "select count(*) from %s.stb0 where to_unixtimestamp('2023-01-01 00:00:00.000')>now;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkRows(0)
|
||||
|
||||
sql = "select count(*) from %s.stb0 where to_unixtimestamp('2024-01-01 00:00:00.000')<now+1y;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,0,2500)
|
||||
sql = "select count(*) from %s.stb0 where to_unixtimestamp('2024-01-01 00:00:00.000')>now+1y;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkRows(0)
|
||||
|
||||
def ts_3110(self,database):
|
||||
|
||||
sql1 = "select * from %s.stb0 order by ts desc limit 2;"%(database)
|
||||
tdSql.query(sql1)
|
||||
data1_0_0 = tdSql.getData(0,0)
|
||||
data1_1_0 = tdSql.getData(1,0)
|
||||
|
||||
sql2 = "select * from (select * from %s.stb0 order by ts desc limit 2) order by ts;"%(database)
|
||||
tdSql.query(sql2)
|
||||
data2_0_0 = tdSql.getData(0,0)
|
||||
data2_1_0 = tdSql.getData(1,0)
|
||||
|
||||
if (data1_0_0 == data2_1_0) and (data1_1_0 == data2_0_0):
|
||||
tdLog.info("ts_3110: success")
|
||||
else:
|
||||
tdLog.exit("ts_3110: sql1 result:'%s' not equal sql2 result:'%s'" % (sql1,sql2))
|
||||
|
||||
def ts_3036(self,database):
|
||||
|
||||
sql1 = "select ts , c0 , c1 , c0null , c1null from (select ts , c0 , c1 , c0null , c1null from %s.stb0_0 where ts between now -1d and now +1d \
|
||||
union all select ts , c0 , c1 , c0null , c1null from %s.stb0_1 where ts between now -1d and now +1d \
|
||||
union all select ts , c0 , c1 , c0null , c1null from %s.stb0_2 where ts between now -1d and now +1d ) tt \
|
||||
where ts < now order by tt.ts desc limit 2;"%(database,database,database)
|
||||
tdSql.query(sql1)
|
||||
data1_0_0 = tdSql.getData(0,0)
|
||||
data1_1_0 = tdSql.getData(1,0)
|
||||
|
||||
sql2 = "select ts , c0 , c1 , c0null , c1null from (select tbname as tb, ts , c0 , c1 , c0null , c1null from %s.stb0 where ts > now \
|
||||
union all select tbname as tb, ts , c0 , c1 , c0null , c1null from %s.stb0 where ts = now \
|
||||
union all select tbname as tb, ts , c0 , c1 , c0null , c1null from %s.stb0 where ts < now ) tt \
|
||||
where tt.ts between now -1d and now +1d and tt.tb in ('stb0_0','stb0_1','stb0_2') order by tt.ts desc limit 2;"%(database,database,database)
|
||||
tdSql.query(sql2)
|
||||
data2_0_0 = tdSql.getData(0,0)
|
||||
data2_1_0 = tdSql.getData(1,0)
|
||||
|
||||
sql3 = "select ts , c0 , c1 , c0null , c1null from %s.stb0 \
|
||||
where ts between now -1d and now +1d and tbname in ('stb0_0','stb0_1','stb0_2') order by ts desc limit 2;"%(database)
|
||||
tdSql.query(sql3)
|
||||
data3_0_0 = tdSql.getData(0,0)
|
||||
data3_1_0 = tdSql.getData(1,0)
|
||||
|
||||
if (data1_0_0 == data2_0_0 == data3_0_0) and (data1_1_0 == data2_1_0 == data3_1_0):
|
||||
tdLog.info("ts_3036: success")
|
||||
else:
|
||||
tdLog.exit("ts_3036: sql1 result:'%s' not equal sql2 result:'%s' or not equal sql3 result:'%s'" % (sql1,sql2,sql3))
|
||||
|
||||
|
||||
def ts_23569(self,database):
|
||||
|
||||
tdSql.query("alter local 'keepcolumnname' '0';")
|
||||
sql = "alter table %s.stb0 drop tag t10;"%(database)
|
||||
tdSql.error(sql)
|
||||
error_msg = tdSql.error(sql)
|
||||
include_msg = 'Invalid tag name'
|
||||
if include_msg in error_msg:
|
||||
tdLog.info("ts_23569: success")
|
||||
else:
|
||||
tdLog.exit("ts_23569: include_msg:'%s' not in error_msg:'%s'" % (include_msg,error_msg))
|
||||
|
||||
tdSql.query("alter local 'keepcolumnname' '1';")
|
||||
sql = "alter table %s.stb0 drop tag t10;"%(database)
|
||||
tdSql.error(sql)
|
||||
error_msg = tdSql.error(sql)
|
||||
include_msg = 'Invalid tag name'
|
||||
if include_msg in error_msg:
|
||||
tdLog.info("ts_23569: success")
|
||||
else:
|
||||
tdLog.exit("ts_23569: include_msg:'%s' not in error_msg:'%s'" % (include_msg,error_msg))
|
||||
|
||||
def ts_23505(self,database):
|
||||
|
||||
sql = "create table %s.`12345` (`567` timestamp,num int);"%(database)
|
||||
tdSql.execute(sql)
|
||||
|
||||
sql = "insert into %s.12345 values (now,1);"%(database)
|
||||
tdSql.error(sql)
|
||||
|
||||
sql = "insert into %s.`12345` values (now,1);"%(database)
|
||||
tdSql.execute(sql)
|
||||
|
||||
sql = "select * from %s.`12345` order by `567` desc limit 2;"%(database)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkData(0,1,1)
|
||||
|
||||
sql = "drop table %s.`12345` ;"%(database)
|
||||
tdSql.execute(sql)
|
||||
sql = "select * from %s.`12345` order by `567` desc limit 2;"%(database)
|
||||
tdSql.error(sql)
|
||||
|
||||
def run(self):
|
||||
startTime = time.time()
|
||||
|
||||
os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))
|
||||
|
||||
self.insert_data("%s" %self.db,2)
|
||||
|
||||
self.ts_3085("%s" %self.db)
|
||||
self.ts_2974_max("%s" %self.db)
|
||||
self.ts_2974_min("%s" %self.db)
|
||||
self.ts_2601("%s" %self.db)
|
||||
self.ts_23569("%s" %self.db)
|
||||
self.ts_3108("%s" %self.db)
|
||||
self.ts_3110("%s" %self.db)
|
||||
self.ts_23505("%s" %self.db)
|
||||
self.ts_3036("%s" %self.db)
|
||||
|
||||
tdSql.query("flush database %s" %self.db)
|
||||
|
||||
self.ts_2974_max("%s" %self.db)
|
||||
self.ts_2974_min("%s" %self.db)
|
||||
self.ts_3085("%s" %self.db)
|
||||
self.ts_2601("%s" %self.db)
|
||||
self.ts_23569("%s" %self.db)
|
||||
self.ts_3108("%s" %self.db)
|
||||
self.ts_3110("%s" %self.db)
|
||||
self.ts_23505("%s" %self.db)
|
||||
self.ts_3036("%s" %self.db)
|
||||
|
||||
|
||||
endTime = time.time()
|
||||
print("total time %ds" % (endTime - startTime))
|
||||
|
||||
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
File diff suppressed because it is too large
Load Diff
|
@ -94,26 +94,26 @@ class ClusterComCreate:
|
|||
tdLog.info(shellCmd)
|
||||
os.system(shellCmd)
|
||||
|
||||
def getStartConsumeNotifyFromTmqsim(self,cdbName='cdb'):
|
||||
while 1:
|
||||
tdSql.query("select * from %s.notifyinfo"%cdbName)
|
||||
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||
if (tdSql.getRows() == 1) and (tdSql.getData(0, 1) == 0):
|
||||
break
|
||||
else:
|
||||
time.sleep(0.1)
|
||||
return
|
||||
|
||||
def getStartCommitNotifyFromTmqsim(self,cdbName='cdb'):
|
||||
while 1:
|
||||
tdSql.query("select * from %s.notifyinfo"%cdbName)
|
||||
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||
if tdSql.getRows() == 2 :
|
||||
print(tdSql.getData(0, 1), tdSql.getData(1, 1))
|
||||
if tdSql.getData(1, 1) == 1:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
return
|
||||
# def getStartConsumeNotifyFromTmqsim(self,cdbName='cdb'):
|
||||
# while 1:
|
||||
# tdSql.query("select * from %s.notifyinfo"%cdbName)
|
||||
# #tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||
# if (tdSql.getRows() == 1) and (tdSql.getData(0, 1) == 0):
|
||||
# break
|
||||
# else:
|
||||
# time.sleep(0.1)
|
||||
# return
|
||||
#
|
||||
# def getStartCommitNotifyFromTmqsim(self,cdbName='cdb'):
|
||||
# while 1:
|
||||
# tdSql.query("select * from %s.notifyinfo"%cdbName)
|
||||
# #tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||
# if tdSql.getRows() == 2 :
|
||||
# print(tdSql.getData(0, 1), tdSql.getData(1, 1))
|
||||
# if tdSql.getData(1, 1) == 1:
|
||||
# break
|
||||
# time.sleep(0.1)
|
||||
# return
|
||||
|
||||
def create_database(self,tsql, dbName,dropFlag=1,vgroups=4,replica=1):
|
||||
if dropFlag == 1:
|
||||
|
|
|
@ -10,6 +10,8 @@ from util.log import *
|
|||
from util.sql import *
|
||||
from util.cases import *
|
||||
from util.dnodes import *
|
||||
sys.path.append("./7-tmq")
|
||||
from tmqCommon import *
|
||||
|
||||
class TDTestCase:
|
||||
hostname = socket.gethostname()
|
||||
|
@ -67,26 +69,26 @@ class TDTestCase:
|
|||
tdLog.info("consume info sql: %s"%sql)
|
||||
tdSql.query(sql)
|
||||
|
||||
def getStartConsumeNotifyFromTmqsim(self,cdbName='cdb'):
|
||||
while 1:
|
||||
tdSql.query("select * from %s.notifyinfo"%cdbName)
|
||||
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||
if (tdSql.getRows() == 1) and (tdSql.getData(0, 1) == 0):
|
||||
break
|
||||
else:
|
||||
time.sleep(0.1)
|
||||
return
|
||||
|
||||
def getStartCommitNotifyFromTmqsim(self,cdbName='cdb'):
|
||||
while 1:
|
||||
tdSql.query("select * from %s.notifyinfo"%cdbName)
|
||||
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||
if tdSql.getRows() == 2 :
|
||||
tdLog.info("row[0][1]: %d, row[1][1]: %d"%(tdSql.getData(0, 1), tdSql.getData(1, 1)))
|
||||
if tdSql.getData(1, 1) == 1:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
return
|
||||
# def getStartConsumeNotifyFromTmqsim(self,cdbName='cdb'):
|
||||
# while 1:
|
||||
# tdSql.query("select * from %s.notifyinfo"%cdbName)
|
||||
# #tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||
# if (tdSql.getRows() == 1) and (tdSql.getData(0, 1) == 0):
|
||||
# break
|
||||
# else:
|
||||
# time.sleep(0.1)
|
||||
# return
|
||||
#
|
||||
# def getStartCommitNotifyFromTmqsim(self,cdbName='cdb'):
|
||||
# while 1:
|
||||
# tdSql.query("select * from %s.notifyinfo"%cdbName)
|
||||
# #tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||
# if tdSql.getRows() == 2 :
|
||||
# tdLog.info("row[0][1]: %d, row[1][1]: %d"%(tdSql.getData(0, 1), tdSql.getData(1, 1)))
|
||||
# if tdSql.getData(1, 1) == 1:
|
||||
# break
|
||||
# time.sleep(0.1)
|
||||
# return
|
||||
|
||||
def selectConsumeResult(self,expectRows,cdbName='cdb'):
|
||||
resultList=[]
|
||||
|
@ -233,7 +235,7 @@ class TDTestCase:
|
|||
self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow)
|
||||
|
||||
tdLog.info("wait the notify info of start consume")
|
||||
self.getStartConsumeNotifyFromTmqsim()
|
||||
tmqCom.getStartConsumeNotifyFromTmqsim()
|
||||
|
||||
tdLog.info("pkill consume processor")
|
||||
if (platform.system().lower() == 'windows'):
|
||||
|
@ -311,7 +313,7 @@ class TDTestCase:
|
|||
|
||||
# time.sleep(6)
|
||||
tdLog.info("start to wait commit notify")
|
||||
self.getStartCommitNotifyFromTmqsim()
|
||||
tmqCom.getStartCommitNotifyFromTmqsim()
|
||||
|
||||
tdLog.info("pkill consume processor")
|
||||
if (platform.system().lower() == 'windows'):
|
||||
|
|
|
@ -145,32 +145,30 @@ class TMQCom:
|
|||
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8")
|
||||
tdLog.debug("%s is stopped by kill -INT" % (processorName))
|
||||
|
||||
def getStartConsumeNotifyFromTmqsim(self,cdbName='cdb',rows=1):
|
||||
def getStartConsumeNotifyFromTmqsim(self,cdbName='cdb'):
|
||||
loopFlag = 1
|
||||
while loopFlag:
|
||||
tdSql.query("select * from %s.notifyinfo"%cdbName)
|
||||
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||
actRows = tdSql.getRows()
|
||||
if (actRows >= rows):
|
||||
for i in range(actRows):
|
||||
if tdSql.getData(i, 1) == 0:
|
||||
loopFlag = 0
|
||||
break
|
||||
for i in range(actRows):
|
||||
if tdSql.getData(i, 1) == 0:
|
||||
loopFlag = 0
|
||||
break
|
||||
time.sleep(0.02)
|
||||
return
|
||||
|
||||
def getStartCommitNotifyFromTmqsim(self,cdbName='cdb',rows=2):
|
||||
def getStartCommitNotifyFromTmqsim(self,cdbName='cdb'):
|
||||
loopFlag = 1
|
||||
while loopFlag:
|
||||
tdSql.query("select * from %s.notifyinfo"%cdbName)
|
||||
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||
actRows = tdSql.getRows()
|
||||
if (actRows >= rows):
|
||||
for i in range(actRows):
|
||||
if tdSql.getData(i, 1) == 1:
|
||||
loopFlag = 0
|
||||
break
|
||||
time.sleep(0.10)
|
||||
for i in range(actRows):
|
||||
if tdSql.getData(i, 1) == 1:
|
||||
loopFlag = 0
|
||||
break
|
||||
time.sleep(0.02)
|
||||
return
|
||||
|
||||
def create_database(self,tsql, dbName,dropFlag=1,vgroups=4,replica=1):
|
||||
|
|
|
@ -100,7 +100,7 @@ class TDTestCase:
|
|||
|
||||
tdLog.info("wait consumer commit notify")
|
||||
# tmqCom.getStartCommitNotifyFromTmqsim(rows=4)
|
||||
tmqCom.getStartConsumeNotifyFromTmqsim(rows=2)
|
||||
tmqCom.getStartConsumeNotifyFromTmqsim()
|
||||
|
||||
tdLog.info("pkill one consume processor")
|
||||
tmqCom.stopTmqSimProcess('tmq_sim_new')
|
||||
|
|
|
@ -121,7 +121,7 @@ class TDTestCase:
|
|||
tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot'])
|
||||
|
||||
# time.sleep(3)
|
||||
tmqCom.getStartCommitNotifyFromTmqsim('cdb',1)
|
||||
tmqCom.getStartCommitNotifyFromTmqsim()
|
||||
|
||||
tdLog.info("create some new child table and insert data for latest mode")
|
||||
paraDict["batchNum"] = 100
|
||||
|
@ -205,7 +205,7 @@ class TDTestCase:
|
|||
tdLog.info("start consume processor")
|
||||
tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot'])
|
||||
|
||||
tmqCom.getStartCommitNotifyFromTmqsim('cdb',1)
|
||||
tmqCom.getStartCommitNotifyFromTmqsim()
|
||||
|
||||
tdLog.info("create some new child table and insert data for latest mode")
|
||||
paraDict["batchNum"] = 10
|
||||
|
|
|
@ -1132,6 +1132,33 @@ int sml_td22900_Test() {
|
|||
return code;
|
||||
}
|
||||
|
||||
int sml_td23881_Test() {
|
||||
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
|
||||
TAOS_RES *pRes =
|
||||
taos_query(taos, "CREATE DATABASE IF NOT EXISTS line_23881 PRECISION 'ns'");
|
||||
taos_free_result(pRes);
|
||||
|
||||
char tmp[16375] = {0};
|
||||
memset(tmp, 'a', 16374);
|
||||
char sql[102400] = {0};
|
||||
sprintf(sql,"lujixfvqor,t0=t c0=f,c1=\"%s\",c2=\"%s\",c3=\"%s\",c4=\"wthvqxcsrlps\" 1626006833639000000", tmp, tmp, tmp);
|
||||
|
||||
pRes = taos_query(taos, "use line_23881");
|
||||
taos_free_result(pRes);
|
||||
|
||||
int totalRows = 0;
|
||||
pRes = taos_schemaless_insert_raw(taos, sql, strlen(sql), &totalRows, TSDB_SML_LINE_PROTOCOL,
|
||||
TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
||||
|
||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||
int code = taos_errno(pRes);
|
||||
taos_free_result(pRes);
|
||||
taos_close(taos);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int sml_ttl_Test() {
|
||||
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
|
||||
|
@ -1301,6 +1328,8 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
int ret = 0;
|
||||
ret = sml_td23881_Test();
|
||||
ASSERT(ret);
|
||||
ret = sml_escape_Test();
|
||||
ASSERT(!ret);
|
||||
ret = sml_ts3116_Test();
|
||||
|
|
Loading…
Reference in New Issue