未验证 提交 cce17fa9 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #2917 from taosdata/hotfix/lihui

Hotfix/lihui
...@@ -47,7 +47,6 @@ cp ${compile_dir}/../packaging/cfg/taos.cfg ${pkg_dir}${install_home_pat ...@@ -47,7 +47,6 @@ cp ${compile_dir}/../packaging/cfg/taos.cfg ${pkg_dir}${install_home_pat
cp ${compile_dir}/../packaging/deb/taosd ${pkg_dir}${install_home_path}/init.d 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/post.sh ${pkg_dir}${install_home_path}/script
cp ${compile_dir}/../packaging/tools/preun.sh ${pkg_dir}${install_home_path}/script cp ${compile_dir}/../packaging/tools/preun.sh ${pkg_dir}${install_home_path}/script
cp ${compile_dir}/build/bin/taosdump ${pkg_dir}${install_home_path}/bin
cp ${compile_dir}/build/bin/taosdemo ${pkg_dir}${install_home_path}/bin cp ${compile_dir}/build/bin/taosdemo ${pkg_dir}${install_home_path}/bin
cp ${compile_dir}/build/bin/taosd ${pkg_dir}${install_home_path}/bin cp ${compile_dir}/build/bin/taosd ${pkg_dir}${install_home_path}/bin
cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin
......
...@@ -58,7 +58,6 @@ cp %{_compiledir}/../packaging/tools/preun.sh %{buildroot}%{homepath}/scri ...@@ -58,7 +58,6 @@ cp %{_compiledir}/../packaging/tools/preun.sh %{buildroot}%{homepath}/scri
cp %{_compiledir}/build/bin/taos %{buildroot}%{homepath}/bin cp %{_compiledir}/build/bin/taos %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/taosd %{buildroot}%{homepath}/bin cp %{_compiledir}/build/bin/taosd %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/taosdemo %{buildroot}%{homepath}/bin cp %{_compiledir}/build/bin/taosdemo %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/taosdump %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver
cp %{_compiledir}/../src/inc/taos.h %{buildroot}%{homepath}/include cp %{_compiledir}/../src/inc/taos.h %{buildroot}%{homepath}/include
cp %{_compiledir}/../src/inc/taoserror.h %{buildroot}%{homepath}/include cp %{_compiledir}/../src/inc/taoserror.h %{buildroot}%{homepath}/include
...@@ -134,7 +133,6 @@ if [ $1 -eq 0 ];then ...@@ -134,7 +133,6 @@ if [ $1 -eq 0 ];then
${csudo} rm -f ${bin_link_dir}/taos || : ${csudo} rm -f ${bin_link_dir}/taos || :
${csudo} rm -f ${bin_link_dir}/taosd || : ${csudo} rm -f ${bin_link_dir}/taosd || :
${csudo} rm -f ${bin_link_dir}/taosdemo || : ${csudo} rm -f ${bin_link_dir}/taosdemo || :
${csudo} rm -f ${bin_link_dir}/taosdump || :
${csudo} rm -f ${cfg_link_dir}/* || : ${csudo} rm -f ${cfg_link_dir}/* || :
${csudo} rm -f ${inc_link_dir}/taos.h || : ${csudo} rm -f ${inc_link_dir}/taos.h || :
${csudo} rm -f ${inc_link_dir}/taoserror.h || : ${csudo} rm -f ${inc_link_dir}/taoserror.h || :
......
...@@ -22,6 +22,7 @@ cfg_install_dir="/etc/taos" ...@@ -22,6 +22,7 @@ cfg_install_dir="/etc/taos"
bin_link_dir="/usr/bin" bin_link_dir="/usr/bin"
lib_link_dir="/usr/lib" lib_link_dir="/usr/lib"
lib64_link_dir="/usr/lib64"
inc_link_dir="/usr/include" inc_link_dir="/usr/include"
#install main path #install main path
...@@ -165,7 +166,6 @@ function install_bin() { ...@@ -165,7 +166,6 @@ function install_bin() {
${csudo} rm -f ${bin_link_dir}/taos || : ${csudo} rm -f ${bin_link_dir}/taos || :
${csudo} rm -f ${bin_link_dir}/taosd || : ${csudo} rm -f ${bin_link_dir}/taosd || :
${csudo} rm -f ${bin_link_dir}/taosdemo || : ${csudo} rm -f ${bin_link_dir}/taosdemo || :
${csudo} rm -f ${bin_link_dir}/taosdump || :
${csudo} rm -f ${bin_link_dir}/rmtaos || : ${csudo} rm -f ${bin_link_dir}/rmtaos || :
${csudo} rm -f ${bin_link_dir}/tarbitrator || : ${csudo} rm -f ${bin_link_dir}/tarbitrator || :
...@@ -174,7 +174,6 @@ function install_bin() { ...@@ -174,7 +174,6 @@ function install_bin() {
#Make link #Make link
[ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || : [ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || :
[ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || : [ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || :
[ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
[ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || :
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || :
[ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || :
...@@ -189,6 +188,7 @@ function install_bin() { ...@@ -189,6 +188,7 @@ function install_bin() {
function install_lib() { function install_lib() {
# Remove links # Remove links
${csudo} rm -f ${lib_link_dir}/libtaos.* || : ${csudo} rm -f ${lib_link_dir}/libtaos.* || :
${csudo} rm -f ${lib64_link_dir}/libtaos.* || :
#${csudo} rm -rf ${v15_java_app_dir} || : #${csudo} rm -rf ${v15_java_app_dir} || :
${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
...@@ -196,6 +196,9 @@ function install_lib() { ...@@ -196,6 +196,9 @@ function install_lib() {
${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
#if [ "$verMode" == "cluster" ]; then #if [ "$verMode" == "cluster" ]; then
# # Compatible with version 1.5 # # Compatible with version 1.5
# ${csudo} mkdir -p ${v15_java_app_dir} # ${csudo} mkdir -p ${v15_java_app_dir}
......
...@@ -36,7 +36,7 @@ if [ "$pagMode" == "lite" ]; then ...@@ -36,7 +36,7 @@ if [ "$pagMode" == "lite" ]; then
strip ${build_dir}/bin/taos strip ${build_dir}/bin/taos
bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${script_dir}/remove.sh" bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${script_dir}/remove.sh"
else else
bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${build_dir}/bin/taosdump ${build_dir}/bin/tarbitrator ${script_dir}/remove.sh" bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${build_dir}/bin/tarbitrator ${script_dir}/remove.sh"
fi fi
lib_files="${build_dir}/lib/libtaos.so.${version}" lib_files="${build_dir}/lib/libtaos.so.${version}"
......
...@@ -21,6 +21,7 @@ inc_dir="/usr/local/taos/include" ...@@ -21,6 +21,7 @@ inc_dir="/usr/local/taos/include"
cfg_install_dir="/etc/taos" cfg_install_dir="/etc/taos"
bin_link_dir="/usr/bin" bin_link_dir="/usr/bin"
lib_link_dir="/usr/lib" lib_link_dir="/usr/lib"
lib64_link_dir="/usr/lib64"
inc_link_dir="/usr/include" inc_link_dir="/usr/include"
service_config_dir="/etc/systemd/system" service_config_dir="/etc/systemd/system"
...@@ -74,16 +75,19 @@ function install_include() { ...@@ -74,16 +75,19 @@ function install_include() {
function install_lib() { function install_lib() {
${csudo} rm -f ${lib_link_dir}/libtaos* || : ${csudo} rm -f ${lib_link_dir}/libtaos* || :
${csudo} rm -f ${lib64_link_dir}/libtaos* || :
${csudo} ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.so.1 ${csudo} ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.so.1
${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
${csudo} ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
} }
function install_bin() { function install_bin() {
# Remove links # Remove links
${csudo} rm -f ${bin_link_dir}/taos || : ${csudo} rm -f ${bin_link_dir}/taos || :
${csudo} rm -f ${bin_link_dir}/taosd || : ${csudo} rm -f ${bin_link_dir}/taosd || :
${csudo} rm -f ${bin_link_dir}/taosdump || :
${csudo} rm -f ${bin_link_dir}/taosdemo || : ${csudo} rm -f ${bin_link_dir}/taosdemo || :
${csudo} rm -f ${bin_link_dir}/rmtaos || : ${csudo} rm -f ${bin_link_dir}/rmtaos || :
...@@ -92,7 +96,6 @@ function install_bin() { ...@@ -92,7 +96,6 @@ function install_bin() {
#Make link #Make link
[ -x ${bin_dir}/taos ] && ${csudo} ln -s ${bin_dir}/taos ${bin_link_dir}/taos || : [ -x ${bin_dir}/taos ] && ${csudo} ln -s ${bin_dir}/taos ${bin_link_dir}/taos || :
[ -x ${bin_dir}/taosd ] && ${csudo} ln -s ${bin_dir}/taosd ${bin_link_dir}/taosd || : [ -x ${bin_dir}/taosd ] && ${csudo} ln -s ${bin_dir}/taosd ${bin_link_dir}/taosd || :
[ -x ${bin_dir}/taosdump ] && ${csudo} ln -s ${bin_dir}/taosdump ${bin_link_dir}/taosdump || :
[ -x ${bin_dir}/taosdemo ] && ${csudo} ln -s ${bin_dir}/taosdemo ${bin_link_dir}/taosdemo || : [ -x ${bin_dir}/taosdemo ] && ${csudo} ln -s ${bin_dir}/taosdemo ${bin_link_dir}/taosdemo || :
# [ -x ${bin_dir}/remove.sh ] && ${csudo} ln -s ${bin_dir}/remove.sh ${bin_link_dir}/rmtaos || : # [ -x ${bin_dir}/remove.sh ] && ${csudo} ln -s ${bin_dir}/remove.sh ${bin_link_dir}/rmtaos || :
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <iconv.h> #include <iconv.h>
#include <time.h> #include <time.h>
#include "os.h"
#include "taos.h" #include "taos.h"
#include "taosdef.h" #include "taosdef.h"
#include "taosmsg.h" #include "taosmsg.h"
...@@ -191,7 +192,7 @@ struct arguments { ...@@ -191,7 +192,7 @@ struct arguments {
char *user; char *user;
char *password; char *password;
uint16_t port; uint16_t port;
char cversion[TSDB_FILENAME_LEN+1]; char cversion[12];
uint16_t mysqlFlag; uint16_t mysqlFlag;
// output file // output file
char outpath[TSDB_FILENAME_LEN+1]; char outpath[TSDB_FILENAME_LEN+1];
...@@ -248,7 +249,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { ...@@ -248,7 +249,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
fprintf(stderr, "Invalid client vesion %s\n", arg); fprintf(stderr, "Invalid client vesion %s\n", arg);
return -1; return -1;
} }
strcpy(arguments->cversion, full_path.we_wordv[0]); tstrncpy(arguments->cversion, full_path.we_wordv[0], 11);
wordfree(&full_path); wordfree(&full_path);
break; break;
// output file path // output file path
...@@ -257,7 +258,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { ...@@ -257,7 +258,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
fprintf(stderr, "Invalid path %s\n", arg); fprintf(stderr, "Invalid path %s\n", arg);
return -1; return -1;
} }
strcpy(arguments->outpath, full_path.we_wordv[0]); tstrncpy(arguments->outpath, full_path.we_wordv[0], TSDB_FILENAME_LEN);
wordfree(&full_path); wordfree(&full_path);
break; break;
case 'i': case 'i':
...@@ -266,7 +267,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { ...@@ -266,7 +267,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
fprintf(stderr, "Invalid path %s\n", arg); fprintf(stderr, "Invalid path %s\n", arg);
return -1; return -1;
} }
strcpy(arguments->inpath, full_path.we_wordv[0]); tstrncpy(arguments->inpath, full_path.we_wordv[0], TSDB_FILENAME_LEN);
wordfree(&full_path); wordfree(&full_path);
break; break;
case 'c': case 'c':
...@@ -430,7 +431,7 @@ int main(int argc, char *argv[]) { ...@@ -430,7 +431,7 @@ int main(int argc, char *argv[]) {
printf("==============================\n"); printf("==============================\n");
if (tsArguments.cversion[0] != 0){ if (tsArguments.cversion[0] != 0){
strcpy(version, tsArguments.cversion); tstrncpy(version, tsArguments.cversion, 11);
} }
if (taosCheckParam(&tsArguments) < 0) { if (taosCheckParam(&tsArguments) < 0) {
...@@ -513,7 +514,7 @@ int taosGetTableRecordInfo(char *table, STableRecordInfo *pTableRecordInfo, TAOS ...@@ -513,7 +514,7 @@ int taosGetTableRecordInfo(char *table, STableRecordInfo *pTableRecordInfo, TAOS
while ((row = taos_fetch_row(result)) != NULL) { while ((row = taos_fetch_row(result)) != NULL) {
isSet = true; isSet = true;
pTableRecordInfo->isMetric = true; pTableRecordInfo->isMetric = true;
strcpy(pTableRecordInfo->tableRecord.metric, table); tstrncpy(pTableRecordInfo->tableRecord.metric, table, TSDB_TABLE_NAME_LEN);
break; break;
} }
...@@ -541,9 +542,9 @@ int32_t taosSaveAllNormalTableToTempFile(TAOS *taosCon, char*meter, char* metric ...@@ -541,9 +542,9 @@ int32_t taosSaveAllNormalTableToTempFile(TAOS *taosCon, char*meter, char* metric
} }
} }
memset(tableRecord.name, 0, sizeof(STableRecord)); memset(&tableRecord, 0, sizeof(STableRecord));
strcpy(tableRecord.name, meter); tstrncpy(tableRecord.name, meter, TSDB_TABLE_NAME_LEN);
strcpy(tableRecord.metric, metric); tstrncpy(tableRecord.metric, metric, TSDB_TABLE_NAME_LEN);
taosTWrite(*fd, &tableRecord, sizeof(STableRecord)); taosTWrite(*fd, &tableRecord, sizeof(STableRecord));
return 0; return 0;
...@@ -587,7 +588,7 @@ int32_t taosSaveTableOfMetricToTempFile(TAOS *taosCon, char* metric, struct argu ...@@ -587,7 +588,7 @@ int32_t taosSaveTableOfMetricToTempFile(TAOS *taosCon, char* metric, struct argu
taos_free_result(result); taos_free_result(result);
for (int32_t loopCnt = 0; loopCnt < numOfThread; loopCnt++) { for (int32_t loopCnt = 0; loopCnt < numOfThread; loopCnt++) {
sprintf(tmpFileName, ".tables.tmp.%d", loopCnt); sprintf(tmpFileName, ".tables.tmp.%d", loopCnt);
remove(tmpFileName); (void)remove(tmpFileName);
} }
free(tmpCommand); free(tmpCommand);
return -1; return -1;
...@@ -597,8 +598,8 @@ int32_t taosSaveTableOfMetricToTempFile(TAOS *taosCon, char* metric, struct argu ...@@ -597,8 +598,8 @@ int32_t taosSaveTableOfMetricToTempFile(TAOS *taosCon, char* metric, struct argu
} }
memset(tableRecord.name, 0, sizeof(STableRecord)); memset(tableRecord.name, 0, sizeof(STableRecord));
strncpy(tableRecord.name, (char *)row[0], fields[0].bytes); tstrncpy(tableRecord.name, (char *)row[0], fields[0].bytes);
strcpy(tableRecord.metric, metric); tstrncpy(tableRecord.metric, metric, TSDB_TABLE_NAME_LEN);
taosTWrite(fd, &tableRecord, sizeof(STableRecord)); taosTWrite(fd, &tableRecord, sizeof(STableRecord));
...@@ -606,12 +607,16 @@ int32_t taosSaveTableOfMetricToTempFile(TAOS *taosCon, char* metric, struct argu ...@@ -606,12 +607,16 @@ int32_t taosSaveTableOfMetricToTempFile(TAOS *taosCon, char* metric, struct argu
if (numOfTable >= arguments->table_batch) { if (numOfTable >= arguments->table_batch) {
numOfTable = 0; numOfTable = 0;
taosClose(fd); close(fd);
fd = -1; fd = -1;
} }
} }
taosClose(fd);
if (fd >= 0) {
close(fd);
fd = -1; fd = -1;
}
taos_free_result(result); taos_free_result(result);
*totalNumOfThread = numOfThread; *totalNumOfThread = numOfThread;
...@@ -852,7 +857,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe ...@@ -852,7 +857,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe
TAOS_FIELD *fields = taos_fetch_fields(tmpResult); TAOS_FIELD *fields = taos_fetch_fields(tmpResult);
strcpy(tableDes->name, table); tstrncpy(tableDes->name, table, TSDB_COL_NAME_LEN);
while ((row = taos_fetch_row(tmpResult)) != NULL) { while ((row = taos_fetch_row(tmpResult)) != NULL) {
strncpy(tableDes->cols[count].field, (char *)row[TSDB_DESCRIBE_METRIC_FIELD_INDEX], strncpy(tableDes->cols[count].field, (char *)row[TSDB_DESCRIBE_METRIC_FIELD_INDEX],
...@@ -1056,6 +1061,7 @@ void* taosDumpOutWorkThreadFp(void *arg) ...@@ -1056,6 +1061,7 @@ void* taosDumpOutWorkThreadFp(void *arg)
fp = fopen(tmpFileName, "w"); fp = fopen(tmpFileName, "w");
if (fp == NULL) { if (fp == NULL) {
fprintf(stderr, "failed to open file %s\n", tmpFileName); fprintf(stderr, "failed to open file %s\n", tmpFileName);
close(fd);
return NULL; return NULL;
} }
...@@ -1067,16 +1073,20 @@ void* taosDumpOutWorkThreadFp(void *arg) ...@@ -1067,16 +1073,20 @@ void* taosDumpOutWorkThreadFp(void *arg)
if (code != 0) { if (code != 0) {
fprintf(stderr, "invalid database %s\n", pThread->dbName); fprintf(stderr, "invalid database %s\n", pThread->dbName);
taos_free_result(tmpResult); taos_free_result(tmpResult);
fclose(fp);
close(fd);
return NULL; return NULL;
} }
fprintf(fp, "USE %s\n\n", pThread->dbName); fprintf(fp, "USE %s\n\n", pThread->dbName);
while (read(fd, &tableRecord, sizeof(STableRecord)) > 0) { while (1) {
ssize_t readLen = read(fd, &tableRecord, sizeof(STableRecord));
if (readLen <= 0) break;
taosDumpTable(tableRecord.name, tableRecord.metric, &tsArguments, fp, pThread->taosCon); taosDumpTable(tableRecord.name, tableRecord.metric, &tsArguments, fp, pThread->taosCon);
} }
taos_free_result(tmpResult); taos_free_result(tmpResult);
taosClose(fd); close(fd);
fclose(fp); fclose(fp);
return NULL; return NULL;
...@@ -1090,7 +1100,7 @@ static void taosStartDumpOutWorkThreads(struct arguments* args, int32_t numOfTh ...@@ -1090,7 +1100,7 @@ static void taosStartDumpOutWorkThreads(struct arguments* args, int32_t numOfTh
SThreadParaObj *pThread = threadObj + t; SThreadParaObj *pThread = threadObj + t;
pThread->threadIndex = t; pThread->threadIndex = t;
pThread->totalThreads = numOfThread; pThread->totalThreads = numOfThread;
strcpy(pThread->dbName, dbName); tstrncpy(pThread->dbName, dbName, TSDB_TABLE_NAME_LEN);
pThread->taosCon = taos_connect(args->host, args->user, args->password, NULL, args->port); pThread->taosCon = taos_connect(args->host, args->user, args->password, NULL, args->port);
if (pThread->taosCon == NULL) { if (pThread->taosCon == NULL) {
...@@ -1189,7 +1199,7 @@ int32_t taosDumpCreateSuperTableClause(TAOS* taosCon, char* dbName, FILE *fp) ...@@ -1189,7 +1199,7 @@ int32_t taosDumpCreateSuperTableClause(TAOS* taosCon, char* dbName, FILE *fp)
fprintf(stderr, "failed to open temp file: %s\n", tmpFileName); fprintf(stderr, "failed to open temp file: %s\n", tmpFileName);
taos_free_result(tmpResult); taos_free_result(tmpResult);
free(tmpCommand); free(tmpCommand);
remove(".stables.tmp"); (void)remove(".stables.tmp");
exit(-1); exit(-1);
} }
...@@ -1200,14 +1210,17 @@ int32_t taosDumpCreateSuperTableClause(TAOS* taosCon, char* dbName, FILE *fp) ...@@ -1200,14 +1210,17 @@ int32_t taosDumpCreateSuperTableClause(TAOS* taosCon, char* dbName, FILE *fp)
} }
taos_free_result(tmpResult); taos_free_result(tmpResult);
lseek(fd, 0, SEEK_SET); (void)lseek(fd, 0, SEEK_SET);
while (1) {
ssize_t readLen = read(fd, &tableRecord, sizeof(STableRecord));
if (readLen <= 0) break;
while (read(fd, &tableRecord, sizeof(STableRecord)) > 0) {
(void)taosDumpStable(tableRecord.name, fp, taosCon); (void)taosDumpStable(tableRecord.name, fp, taosCon);
} }
taosClose(fd); close(fd);
remove(".stables.tmp"); (void)remove(".stables.tmp");
free(tmpCommand); free(tmpCommand);
return 0; return 0;
...@@ -1269,7 +1282,7 @@ int taosDumpDb(SDbInfo *dbInfo, struct arguments *arguments, FILE *fp, TAOS *tao ...@@ -1269,7 +1282,7 @@ int taosDumpDb(SDbInfo *dbInfo, struct arguments *arguments, FILE *fp, TAOS *tao
taos_free_result(tmpResult); taos_free_result(tmpResult);
for (int32_t loopCnt = 0; loopCnt < numOfThread; loopCnt++) { for (int32_t loopCnt = 0; loopCnt < numOfThread; loopCnt++) {
sprintf(tmpFileName, ".tables.tmp.%d", loopCnt); sprintf(tmpFileName, ".tables.tmp.%d", loopCnt);
remove(tmpFileName); (void)remove(tmpFileName);
} }
free(tmpCommand); free(tmpCommand);
return -1; return -1;
...@@ -1279,8 +1292,8 @@ int taosDumpDb(SDbInfo *dbInfo, struct arguments *arguments, FILE *fp, TAOS *tao ...@@ -1279,8 +1292,8 @@ int taosDumpDb(SDbInfo *dbInfo, struct arguments *arguments, FILE *fp, TAOS *tao
} }
memset(&tableRecord, 0, sizeof(STableRecord)); memset(&tableRecord, 0, sizeof(STableRecord));
strncpy(tableRecord.name, (char *)row[TSDB_SHOW_TABLES_NAME_INDEX], fields[TSDB_SHOW_TABLES_NAME_INDEX].bytes); tstrncpy(tableRecord.name, (char *)row[TSDB_SHOW_TABLES_NAME_INDEX], fields[TSDB_SHOW_TABLES_NAME_INDEX].bytes);
strncpy(tableRecord.metric, (char *)row[TSDB_SHOW_TABLES_METRIC_INDEX], fields[TSDB_SHOW_TABLES_METRIC_INDEX].bytes); tstrncpy(tableRecord.metric, (char *)row[TSDB_SHOW_TABLES_METRIC_INDEX], fields[TSDB_SHOW_TABLES_METRIC_INDEX].bytes);
taosTWrite(fd, &tableRecord, sizeof(STableRecord)); taosTWrite(fd, &tableRecord, sizeof(STableRecord));
...@@ -1288,19 +1301,23 @@ int taosDumpDb(SDbInfo *dbInfo, struct arguments *arguments, FILE *fp, TAOS *tao ...@@ -1288,19 +1301,23 @@ int taosDumpDb(SDbInfo *dbInfo, struct arguments *arguments, FILE *fp, TAOS *tao
if (numOfTable >= arguments->table_batch) { if (numOfTable >= arguments->table_batch) {
numOfTable = 0; numOfTable = 0;
taosClose(fd); close(fd);
fd = -1; fd = -1;
} }
} }
taosClose(fd);
if (fd >= 0) {
close(fd);
fd = -1; fd = -1;
}
taos_free_result(tmpResult); taos_free_result(tmpResult);
// start multi threads to dumpout // start multi threads to dumpout
taosStartDumpOutWorkThreads(arguments, numOfThread, dbInfo->name); taosStartDumpOutWorkThreads(arguments, numOfThread, dbInfo->name);
for (int loopCnt = 0; loopCnt < numOfThread; loopCnt++) { for (int loopCnt = 0; loopCnt < numOfThread; loopCnt++) {
sprintf(tmpFileName, ".tables.tmp.%d", loopCnt); sprintf(tmpFileName, ".tables.tmp.%d", loopCnt);
remove(tmpFileName); (void)remove(tmpFileName);
} }
free(tmpCommand); free(tmpCommand);
...@@ -1718,6 +1735,10 @@ int convertNCharToReadable(char *str, int size, char *buf, int bufsize) { ...@@ -1718,6 +1735,10 @@ int convertNCharToReadable(char *str, int size, char *buf, int bufsize) {
while (size > 0) { while (size > 0) {
if (*pstr == '\0') break; if (*pstr == '\0') break;
int byte_width = mbtowc(&wc, pstr, MB_CUR_MAX); int byte_width = mbtowc(&wc, pstr, MB_CUR_MAX);
if (byte_width < 0) {
fprintf(stderr, "mbtowc() return fail.\n");
exit(-1);
}
if ((int)wc < 256) { if ((int)wc < 256) {
pbuf = stpcpy(pbuf, ascii_literal_list[(int)wc]); pbuf = stpcpy(pbuf, ascii_literal_list[(int)wc]);
...@@ -1736,16 +1757,16 @@ int convertNCharToReadable(char *str, int size, char *buf, int bufsize) { ...@@ -1736,16 +1757,16 @@ int convertNCharToReadable(char *str, int size, char *buf, int bufsize) {
void taosDumpCharset(FILE *fp) { void taosDumpCharset(FILE *fp) {
char charsetline[256]; char charsetline[256];
fseek(fp, 0, SEEK_SET); (void)fseek(fp, 0, SEEK_SET);
sprintf(charsetline, "#!%s\n", tsCharset); sprintf(charsetline, "#!%s\n", tsCharset);
fwrite(charsetline, strlen(charsetline), 1, fp); (void)fwrite(charsetline, strlen(charsetline), 1, fp);
} }
void taosLoadFileCharset(FILE *fp, char *fcharset) { void taosLoadFileCharset(FILE *fp, char *fcharset) {
char * line = NULL; char * line = NULL;
size_t line_size = 0; size_t line_size = 0;
fseek(fp, 0, SEEK_SET); (void)fseek(fp, 0, SEEK_SET);
ssize_t size = getline(&line, &line_size, fp); ssize_t size = getline(&line, &line_size, fp);
if (size <= 2) { if (size <= 2) {
goto _exit_no_charset; goto _exit_no_charset;
...@@ -1764,7 +1785,7 @@ void taosLoadFileCharset(FILE *fp, char *fcharset) { ...@@ -1764,7 +1785,7 @@ void taosLoadFileCharset(FILE *fp, char *fcharset) {
return; return;
_exit_no_charset: _exit_no_charset:
fseek(fp, 0, SEEK_SET); (void)fseek(fp, 0, SEEK_SET);
*fcharset = '\0'; *fcharset = '\0';
taosTFree(line); taosTFree(line);
return; return;
...@@ -1825,6 +1846,7 @@ static void taosParseDirectory(const char *directoryName, const char *prefix, ch ...@@ -1825,6 +1846,7 @@ static void taosParseDirectory(const char *directoryName, const char *prefix, ch
if (fileNum != totalFiles) { if (fileNum != totalFiles) {
fprintf(stderr, "ERROR: directory:%s changed while read\n", directoryName); fprintf(stderr, "ERROR: directory:%s changed while read\n", directoryName);
pclose(fp);
exit(0); exit(0);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册