Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ba090e22
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ba090e22
编写于
7月 12, 2021
作者:
haoranc
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of github.com:taosdata/TDengine into dev/chr
上级
0ef4ef05
4486cae1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
1742 addition
and
1664 deletion
+1742
-1664
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+1739
-1661
tests/pytest/tools/taosdemoTest.py
tests/pytest/tools/taosdemoTest.py
+1
-1
tests/pytest/tools/taosdemoTestTblAlt.py
tests/pytest/tools/taosdemoTestTblAlt.py
+1
-1
tests/pytest/tools/taosdemoTestWithoutMetric.py
tests/pytest/tools/taosdemoTestWithoutMetric.py
+1
-1
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
ba090e22
...
@@ -198,44 +198,45 @@ enum _describe_table_index {
...
@@ -198,44 +198,45 @@ enum _describe_table_index {
static
char
*
g_dupstr
=
NULL
;
static
char
*
g_dupstr
=
NULL
;
typedef
struct
SArguments_S
{
typedef
struct
SArguments_S
{
char
*
metaFile
;
char
*
metaFile
;
uint32_t
test_mode
;
uint32_t
test_mode
;
char
*
host
;
char
*
host
;
uint16_t
port
;
uint16_t
port
;
uint16_t
iface
;
uint16_t
iface
;
char
*
user
;
char
*
user
;
char
*
password
;
char
*
password
;
char
*
database
;
char
*
database
;
int
replica
;
int
replica
;
char
*
tb_prefix
;
char
*
tb_prefix
;
char
*
sqlFile
;
char
*
sqlFile
;
bool
use_metric
;
bool
use_metric
;
bool
drop_database
;
bool
drop_database
;
bool
insert_only
;
bool
insert_only
;
bool
answer_yes
;
bool
answer_yes
;
bool
debug_print
;
bool
debug_print
;
bool
verbose_print
;
bool
verbose_print
;
bool
performance_print
;
bool
performance_print
;
char
*
output_file
;
char
*
output_file
;
bool
async_mode
;
bool
async_mode
;
char
*
datatype
[
MAX_NUM_DATATYPE
+
1
];
char
*
datatype
[
MAX_NUM_DATATYPE
+
1
];
uint32_t
len_of_binary
;
uint32_t
len_of_binary
;
uint32_t
num_of_CPR
;
uint32_t
num_of_CPR
;
uint32_t
num_of_threads
;
uint32_t
num_of_threads
;
uint64_t
insert_interval
;
uint64_t
insert_interval
;
int64_t
query_times
;
int64_t
query_times
;
uint32_t
interlace_rows
;
uint32_t
interlace_rows
;
uint32_t
num_of_RPR
;
// num_of_records_per_req
uint32_t
num_of_RPR
;
// num_of_records_per_req
uint64_t
max_sql_len
;
uint64_t
max_sql_len
;
int64_t
num_of_tables
;
int64_t
num_of_tables
;
int64_t
num_of_DPT
;
int64_t
num_of_DPT
;
int
abort
;
int
abort
;
uint32_t
disorderRatio
;
// 0: no disorder, >0: x%
uint32_t
disorderRatio
;
// 0: no disorder, >0: x%
int
disorderRange
;
// ms or us by database precision
int
disorderRange
;
// ms or us by database precision
uint32_t
method_of_delete
;
uint32_t
method_of_delete
;
char
**
arg_list
;
char
**
arg_list
;
uint64_t
totalInsertRows
;
uint64_t
totalInsertRows
;
uint64_t
totalAffectedRows
;
uint64_t
totalAffectedRows
;
bool
demo_mode
;
// use default column name and semi-random data
}
SArguments
;
}
SArguments
;
typedef
struct
SColumn_S
{
typedef
struct
SColumn_S
{
...
@@ -427,47 +428,47 @@ typedef struct SQueryMetaInfo_S {
...
@@ -427,47 +428,47 @@ typedef struct SQueryMetaInfo_S {
}
SQueryMetaInfo
;
}
SQueryMetaInfo
;
typedef
struct
SThreadInfo_S
{
typedef
struct
SThreadInfo_S
{
TAOS
*
taos
;
TAOS
*
taos
;
TAOS_STMT
*
stmt
;
TAOS_STMT
*
stmt
;
int
threadID
;
int
threadID
;
char
db_name
[
TSDB_DB_NAME_LEN
];
char
db_name
[
TSDB_DB_NAME_LEN
];
uint32_t
time_precision
;
uint32_t
time_precision
;
char
filePath
[
4096
];
char
filePath
[
4096
];
FILE
*
fp
;
FILE
*
fp
;
char
tb_prefix
[
TSDB_TABLE_NAME_LEN
];
char
tb_prefix
[
TSDB_TABLE_NAME_LEN
];
uint64_t
start_table_from
;
uint64_t
start_table_from
;
uint64_t
end_table_to
;
uint64_t
end_table_to
;
int64_t
ntables
;
int64_t
ntables
;
uint64_t
data_of_rate
;
uint64_t
data_of_rate
;
int64_t
start_time
;
int64_t
start_time
;
char
*
cols
;
char
*
cols
;
bool
use_metric
;
bool
use_metric
;
SSuperTable
*
superTblInfo
;
SSuperTable
*
superTblInfo
;
char
*
buffer
;
// sql cmd buffer
char
*
buffer
;
// sql cmd buffer
// for async insert
// for async insert
tsem_t
lock_sem
;
tsem_t
lock_sem
;
int64_t
counter
;
int64_t
counter
;
uint64_t
st
;
uint64_t
st
;
uint64_t
et
;
uint64_t
et
;
uint64_t
lastTs
;
uint64_t
lastTs
;
// sample data
// sample data
int64_t
samplePos
;
int64_t
samplePos
;
// statistics
// statistics
uint64_t
totalInsertRows
;
uint64_t
totalInsertRows
;
uint64_t
totalAffectedRows
;
uint64_t
totalAffectedRows
;
// insert delay statistics
// insert delay statistics
uint64_t
cntDelay
;
uint64_t
cntDelay
;
uint64_t
totalDelay
;
uint64_t
totalDelay
;
uint64_t
avgDelay
;
uint64_t
avgDelay
;
uint64_t
maxDelay
;
uint64_t
maxDelay
;
uint64_t
minDelay
;
uint64_t
minDelay
;
// seq of query or subscribe
// seq of query or subscribe
uint64_t
querySeq
;
// sequence number of sql command
uint64_t
querySeq
;
// sequence number of sql command
TAOS_SUB
*
tsub
;
TAOS_SUB
*
tsub
;
}
threadInfo
;
}
threadInfo
;
...
@@ -552,6 +553,8 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr,
...
@@ -552,6 +553,8 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr,
uint16_t
port
,
char
*
sqlstr
,
threadInfo
*
pThreadInfo
);
uint16_t
port
,
char
*
sqlstr
,
threadInfo
*
pThreadInfo
);
static
int64_t
getTSRandTail
(
int64_t
timeStampStep
,
int32_t
seq
,
static
int64_t
getTSRandTail
(
int64_t
timeStampStep
,
int32_t
seq
,
int
disorderRatio
,
int
disorderRange
);
int
disorderRatio
,
int
disorderRange
);
static
bool
getInfoFromJsonFile
(
char
*
file
);
static
void
init_rand_data
();
/* ************ Global variables ************ */
/* ************ Global variables ************ */
...
@@ -563,53 +566,55 @@ char *aggreFunc[] = {"*", "count(*)", "avg(col0)", "sum(col0)",
...
@@ -563,53 +566,55 @@ char *aggreFunc[] = {"*", "count(*)", "avg(col0)", "sum(col0)",
"max(col0)"
,
"min(col0)"
,
"first(col0)"
,
"last(col0)"
};
"max(col0)"
,
"min(col0)"
,
"first(col0)"
,
"last(col0)"
};
SArguments
g_args
=
{
SArguments
g_args
=
{
NULL
,
// metaFile
NULL
,
// metaFile
0
,
// test_mode
0
,
// test_mode
"127.0.0.1"
,
// host
"127.0.0.1"
,
// host
6030
,
// port
6030
,
// port
TAOSC_IFACE
,
// iface
TAOSC_IFACE
,
// iface
"root"
,
// user
"root"
,
// user
#ifdef _TD_POWER_
#ifdef _TD_POWER_
"powerdb"
,
// password
"powerdb"
,
// password
#elif (_TD_TQ_ == true)
#elif (_TD_TQ_ == true)
"tqueue"
,
// password
"tqueue"
,
// password
#else
#else
"taosdata"
,
// password
"taosdata"
,
// password
#endif
#endif
"test"
,
// database
"test"
,
// database
1
,
// replica
1
,
// replica
"t"
,
// tb_prefix
"d"
,
// tb_prefix
NULL
,
// sqlFile
NULL
,
// sqlFile
true
,
// use_metric
true
,
// use_metric
true
,
// drop_database
true
,
// drop_database
true
,
// insert_only
true
,
// insert_only
false
,
// debug_print
false
,
// debug_print
false
,
// verbose_print
false
,
// verbose_print
false
,
// performance statistic print
false
,
// performance statistic print
false
,
// answer_yes;
false
,
// answer_yes;
"./output.txt"
,
// output_file
"./output.txt"
,
// output_file
0
,
// mode : sync or async
0
,
// mode : sync or async
{
{
"INT"
,
// datatype
"FLOAT"
,
// datatype
"INT"
,
// datatype
"INT"
,
// datatype
"INT"
,
// datatype
"FLOAT"
,
// datatype
"INT"
,
// datatype
},
},
16
,
// len_of_binary
16
,
// len_of_binary
4
,
// num_of_CPR
4
,
// num_of_CPR
10
,
// num_of_connections/thread
10
,
// num_of_connections/thread
0
,
// insert_interval
0
,
// insert_interval
1
,
// query_times
1
,
// query_times
0
,
// interlace_rows;
0
,
// interlace_rows;
30000
,
// num_of_RPR
30000
,
// num_of_RPR
(
1024
*
1024
),
// max_sql_len
(
1024
*
1024
),
// max_sql_len
10000
,
// num_of_tables
10000
,
// num_of_tables
10000
,
// num_of_DPT
10000
,
// num_of_DPT
0
,
// abort
0
,
// abort
0
,
// disorderRatio
0
,
// disorderRatio
1000
,
// disorderRange
1000
,
// disorderRange
1
,
// method_of_delete
1
,
// method_of_delete
NULL
,
// arg_list
NULL
// arg_list
0
,
// totalInsertRows;
0
,
// totalAffectedRows;
true
,
// demo_mode;
};
};
...
@@ -673,645 +678,674 @@ static void printVersion() {
...
@@ -673,645 +678,674 @@ static void printVersion() {
}
}
static
void
printHelp
()
{
static
void
printHelp
()
{
char
indent
[
10
]
=
" "
;
char
indent
[
10
]
=
" "
;
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-f"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-f"
,
indent
,
"The meta file to the execution procedure. Default is './meta.json'."
);
"The meta file to the execution procedure. Default is './meta.json'."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-u"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-u"
,
indent
,
"The TDengine user name to use when connecting to the server. Default is 'root'."
);
"The TDengine user name to use when connecting to the server. Default is 'root'."
);
#ifdef _TD_POWER_
#ifdef _TD_POWER_
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-P"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-P"
,
indent
,
"The password to use when connecting to the server. Default is 'powerdb'."
);
"The password to use when connecting to the server. Default is 'powerdb'."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-c"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-c"
,
indent
,
"Configuration directory. Default is '/etc/power/'."
);
"Configuration directory. Default is '/etc/power/'."
);
#elif (_TD_TQ_ == true)
#elif (_TD_TQ_ == true)
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-P"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-P"
,
indent
,
"The password to use when connecting to the server. Default is 'tqueue'."
);
"The password to use when connecting to the server. Default is 'tqueue'."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-c"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-c"
,
indent
,
"Configuration directory. Default is '/etc/tq/'."
);
"Configuration directory. Default is '/etc/tq/'."
);
#else
#else
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-P"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-P"
,
indent
,
"The password to use when connecting to the server. Default is 'taosdata'."
);
"The password to use when connecting to the server. Default is 'taosdata'."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-c"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-c"
,
indent
,
"Configuration directory. Default is '/etc/taos/'."
);
"Configuration directory. Default is '/etc/taos/'."
);
#endif
#endif
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-h"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-h"
,
indent
,
"The host to connect to TDengine. Default is localhost."
);
"The host to connect to TDengine. Default is localhost."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-p"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-p"
,
indent
,
"The TCP/IP port number to use for the connection. Default is 0."
);
"The TCP/IP port number to use for the connection. Default is 0."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-I"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-I"
,
indent
,
#if STMT_IFACE_ENABLED == 1
#if STMT_IFACE_ENABLED == 1
"The interface (taosc, rest, and stmt) taosdemo uses. Default is 'taosc'."
);
"The interface (taosc, rest, and stmt) taosdemo uses. Default is 'taosc'."
);
#else
#else
"The interface (taosc, rest) taosdemo uses. Default is 'taosc'."
);
"The interface (taosc, rest) taosdemo uses. Default is 'taosc'."
);
#endif
#endif
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-d"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-d"
,
indent
,
"Destination database. Default is 'test'."
);
"Destination database. Default is 'test'."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-a"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-a"
,
indent
,
"Set the replica parameters of the database, Default 1, min: 1, max: 3."
);
"Set the replica parameters of the database, Default 1, min: 1, max: 3."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-m"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-m"
,
indent
,
"Table prefix name. Default is 't'."
);
"Table prefix name. Default is 'd'."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-s"
,
indent
,
"The select sql file."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-s"
,
indent
,
"The select sql file."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-N"
,
indent
,
"Use normal table flag."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-N"
,
indent
,
"Use normal table flag."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-o"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-o"
,
indent
,
"Direct output to the named file. Default is './output.txt'."
);
"Direct output to the named file. Default is './output.txt'."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-q"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-q"
,
indent
,
"Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC."
);
"Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-b"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-b"
,
indent
,
"The data_type of columns, default: INT,INT,INT,INT."
);
"The data_type of columns, default: FLOAT, INT, FLOAT."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-w"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-w"
,
indent
,
"The length of data_type 'BINARY' or 'NCHAR'. Default is 16"
);
"The length of data_type 'BINARY' or 'NCHAR'. Default is 16"
);
printf
(
"%s%s%s%s%d
\n
"
,
indent
,
"-l"
,
indent
,
printf
(
"%s%s%s%s%d
\n
"
,
indent
,
"-l"
,
indent
,
"The number of columns per record. Default is 4. Max values is "
,
"The number of columns per record. Default is 3. Max values is "
,
MAX_NUM_DATATYPE
);
MAX_NUM_DATATYPE
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-T"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-T"
,
indent
,
"The number of threads. Default is 10."
);
"The number of threads. Default is 10."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-i"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-i"
,
indent
,
"The sleep time (ms) between insertion. Default is 0."
);
"The sleep time (ms) between insertion. Default is 0."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-r"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-r"
,
indent
,
"The number of records per request. Default is 30000."
);
"The number of records per request. Default is 30000."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-t"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-t"
,
indent
,
"The number of tables. Default is 10000."
);
"The number of tables. Default is 10000."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-n"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-n"
,
indent
,
"The number of records per table. Default is 10000."
);
"The number of records per table. Default is 10000."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-x"
,
indent
,
"Not insert only flag."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-M"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-y"
,
indent
,
"Default input yes for prompt."
);
"The value of records generated are totally random."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-O"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
indent
,
indent
,
"Insert mode--0: In order, 1 ~ 50: disorder ratio. Default is in order."
);
" The default is to simulate power equipment senario."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-R"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-x"
,
indent
,
"Not insert only flag."
);
"Out of order data's range, ms, default is 1000."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-y"
,
indent
,
"Default input yes for prompt."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-g"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-O"
,
indent
,
"Print debug info."
);
"Insert mode--0: In order, 1 ~ 50: disorder ratio. Default is in order."
);
printf
(
"%s%s%s
\n
"
,
indent
,
"-V, --version
\t
"
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-R"
,
indent
,
"Print version info."
);
"Out of order data's range, ms, default is 1000."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"--help
\t
"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-g"
,
indent
,
"Print command line arguments list info."
);
"Print debug info."
);
/* printf("%s%s%s%s\n", indent, "-D", indent,
printf
(
"%s%s%s
\n
"
,
indent
,
"-V, --version
\t
"
,
"if elete database if exists. 0: no, 1: yes, default is 1");
"Print version info."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"--help
\t
"
,
indent
,
"Print command line arguments list info."
);
/* printf("%s%s%s%s\n", indent, "-D", indent,
"Delete database if exists. 0: no, 1: yes, default is 1");
*/
*/
}
}
static
bool
isStringNumber
(
char
*
input
)
static
bool
isStringNumber
(
char
*
input
)
{
{
int
len
=
strlen
(
input
);
int
len
=
strlen
(
input
);
if
(
0
==
len
)
{
if
(
0
==
len
)
{
return
false
;
return
false
;
}
}
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
if
(
!
isdigit
(
input
[
i
]))
if
(
!
isdigit
(
input
[
i
]))
return
false
;
return
false
;
}
}
return
true
;
return
true
;
}
}
static
void
parse_args
(
int
argc
,
char
*
argv
[],
SArguments
*
arguments
)
{
static
void
parse_args
(
int
argc
,
char
*
argv
[],
SArguments
*
arguments
)
{
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
strcmp
(
argv
[
i
],
"-f"
)
==
0
)
{
if
(
strcmp
(
argv
[
i
],
"-f"
)
==
0
)
{
arguments
->
metaFile
=
argv
[
++
i
];
arguments
->
demo_mode
=
false
;
}
else
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
arguments
->
metaFile
=
argv
[
++
i
];
if
(
argc
==
i
+
1
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
printHelp
();
if
(
argc
==
i
+
1
)
{
errorPrint
(
"%s"
,
"
\n\t
-c need a valid path following!
\n
"
);
printHelp
();
exit
(
EXIT_FAILURE
);
errorPrint
(
"%s"
,
"
\n\t
-c need a valid path following!
\n
"
);
}
exit
(
EXIT_FAILURE
);
tstrncpy
(
configDir
,
argv
[
++
i
],
TSDB_FILENAME_LEN
);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-h"
)
==
0
)
{
tstrncpy
(
configDir
,
argv
[
++
i
],
TSDB_FILENAME_LEN
);
if
(
argc
==
i
+
1
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-h"
)
==
0
)
{
printHelp
();
if
(
argc
==
i
+
1
)
{
errorPrint
(
"%s"
,
"
\n\t
-h need a valid string following!
\n
"
);
printHelp
();
exit
(
EXIT_FAILURE
);
errorPrint
(
"%s"
,
"
\n\t
-h need a valid string following!
\n
"
);
}
exit
(
EXIT_FAILURE
);
arguments
->
host
=
argv
[
++
i
];
}
}
else
if
(
strcmp
(
argv
[
i
],
"-p"
)
==
0
)
{
arguments
->
host
=
argv
[
++
i
];
if
((
argc
==
i
+
1
)
||
}
else
if
(
strcmp
(
argv
[
i
],
"-p"
)
==
0
)
{
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
if
((
argc
==
i
+
1
)
||
printHelp
();
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
errorPrint
(
"%s"
,
"
\n\t
-p need a number following!
\n
"
);
printHelp
();
exit
(
EXIT_FAILURE
);
errorPrint
(
"%s"
,
"
\n\t
-p need a number following!
\n
"
);
}
exit
(
EXIT_FAILURE
);
arguments
->
port
=
atoi
(
argv
[
++
i
]);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-I"
)
==
0
)
{
arguments
->
port
=
atoi
(
argv
[
++
i
]);
if
(
argc
==
i
+
1
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-I"
)
==
0
)
{
printHelp
();
if
(
argc
==
i
+
1
)
{
errorPrint
(
"%s"
,
"
\n\t
-I need a valid string following!
\n
"
);
printHelp
();
exit
(
EXIT_FAILURE
);
errorPrint
(
"%s"
,
"
\n\t
-I need a valid string following!
\n
"
);
}
exit
(
EXIT_FAILURE
);
++
i
;
}
if
(
0
==
strcasecmp
(
argv
[
i
],
"taosc"
))
{
++
i
;
arguments
->
iface
=
TAOSC_IFACE
;
if
(
0
==
strcasecmp
(
argv
[
i
],
"taosc"
))
{
}
else
if
(
0
==
strcasecmp
(
argv
[
i
],
"rest"
))
{
arguments
->
iface
=
TAOSC_IFACE
;
arguments
->
iface
=
REST_IFACE
;
}
else
if
(
0
==
strcasecmp
(
argv
[
i
],
"rest"
))
{
arguments
->
iface
=
REST_IFACE
;
#if STMT_IFACE_ENABLED == 1
#if STMT_IFACE_ENABLED == 1
}
else
if
(
0
==
strcasecmp
(
argv
[
i
],
"stmt"
))
{
}
else
if
(
0
==
strcasecmp
(
argv
[
i
],
"stmt"
))
{
arguments
->
iface
=
STMT_IFACE
;
arguments
->
iface
=
STMT_IFACE
;
#endif
#endif
}
else
{
}
else
{
errorPrint
(
"%s"
,
"
\n\t
-I need a valid string following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-I need a valid string following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
else
if
(
strcmp
(
argv
[
i
],
"-u"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-u"
)
==
0
)
{
if
(
argc
==
i
+
1
)
{
if
(
argc
==
i
+
1
)
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-u need a valid string following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-u need a valid string following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
user
=
argv
[
++
i
];
arguments
->
user
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-P"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-P"
)
==
0
)
{
if
(
argc
==
i
+
1
)
{
if
(
argc
==
i
+
1
)
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-P need a valid string following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-P need a valid string following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
password
=
argv
[
++
i
];
arguments
->
password
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-o"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-o"
)
==
0
)
{
if
(
argc
==
i
+
1
)
{
if
(
argc
==
i
+
1
)
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-o need a valid string following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-o need a valid string following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
output_file
=
argv
[
++
i
];
arguments
->
output_file
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-s"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-s"
)
==
0
)
{
if
(
argc
==
i
+
1
)
{
if
(
argc
==
i
+
1
)
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-s need a valid string following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-s need a valid string following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
sqlFile
=
argv
[
++
i
];
arguments
->
sqlFile
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-q"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-q"
)
==
0
)
{
if
((
argc
==
i
+
1
)
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-q need a number following!
\n
Query mode -- 0: SYNC, not-0: ASYNC. Default is SYNC.
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-q need a number following!
\n
Query mode -- 0: SYNC, not-0: ASYNC. Default is SYNC.
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
async_mode
=
atoi
(
argv
[
++
i
]);
arguments
->
async_mode
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-T"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-T"
)
==
0
)
{
if
((
argc
==
i
+
1
)
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-T need a number following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-T need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
num_of_threads
=
atoi
(
argv
[
++
i
]);
arguments
->
num_of_threads
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-i"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-i"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-i need a number following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-i need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
insert_interval
=
atoi
(
argv
[
++
i
]);
arguments
->
insert_interval
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-qt"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-qt"
)
==
0
)
{
if
((
argc
==
i
+
1
)
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-qt need a number following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-qt need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
query_times
=
atoi
(
argv
[
++
i
]);
arguments
->
query_times
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-B"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-B"
)
==
0
)
{
if
((
argc
==
i
+
1
)
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-B need a number following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-B need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
interlace_rows
=
atoi
(
argv
[
++
i
]);
arguments
->
interlace_rows
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-r"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-r"
)
==
0
)
{
if
((
argc
==
i
+
1
)
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-r need a number following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-r need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
num_of_RPR
=
atoi
(
argv
[
++
i
]);
arguments
->
num_of_RPR
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-t"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-t"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-t need a number following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-t need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
num_of_tables
=
atoi
(
argv
[
++
i
]);
arguments
->
num_of_tables
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-n"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-n"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-n need a number following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-n need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
num_of_DPT
=
atoi
(
argv
[
++
i
]);
arguments
->
num_of_DPT
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-d"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-d"
)
==
0
)
{
if
(
argc
==
i
+
1
)
{
if
(
argc
==
i
+
1
)
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-d need a valid string following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-d need a valid string following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
database
=
argv
[
++
i
];
arguments
->
database
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-l"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-l"
)
==
0
)
{
if
(
argc
==
i
+
1
)
{
arguments
->
demo_mode
=
false
;
if
(
!
isStringNumber
(
argv
[
i
+
1
]))
{
if
(
argc
==
i
+
1
)
{
printHelp
();
if
(
!
isStringNumber
(
argv
[
i
+
1
]))
{
errorPrint
(
"%s"
,
"
\n\t
-l need a number following!
\n
"
);
printHelp
();
exit
(
EXIT_FAILURE
);
errorPrint
(
"%s"
,
"
\n\t
-l need a number following!
\n
"
);
}
exit
(
EXIT_FAILURE
);
}
}
arguments
->
num_of_CPR
=
atoi
(
argv
[
++
i
]);
}
arguments
->
num_of_CPR
=
atoi
(
argv
[
++
i
]);
if
(
arguments
->
num_of_CPR
>
MAX_NUM_DATATYPE
)
{
if
(
arguments
->
num_of_CPR
>
MAX_NUM_DATATYPE
)
{
printf
(
"WARNING: max acceptible columns count is %d
\n
"
,
MAX_NUM_DATATYPE
);
printf
(
"WARNING: max acceptible columns count is %d
\n
"
,
MAX_NUM_DATATYPE
);
prompt
();
prompt
();
arguments
->
num_of_CPR
=
MAX_NUM_DATATYPE
;
arguments
->
num_of_CPR
=
MAX_NUM_DATATYPE
;
}
}
for
(
int
col
=
arguments
->
num_of_CPR
;
col
<
MAX_NUM_DATATYPE
;
col
++
)
{
for
(
int
col
=
arguments
->
num_of_CPR
;
col
<
MAX_NUM_DATATYPE
;
col
++
)
{
arguments
->
datatype
[
col
]
=
NULL
;
arguments
->
datatype
[
col
]
=
NULL
;
}
}
}
else
if
(
strcmp
(
argv
[
i
],
"-b"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-b"
)
==
0
)
{
if
(
argc
==
i
+
1
)
{
arguments
->
demo_mode
=
false
;
printHelp
();
if
(
argc
==
i
+
1
)
{
errorPrint
(
"%s"
,
"
\n\t
-b need valid string following!
\n
"
);
printHelp
();
exit
(
EXIT_FAILURE
);
errorPrint
(
"%s"
,
"
\n\t
-b need valid string following!
\n
"
);
}
exit
(
EXIT_FAILURE
);
++
i
;
}
if
(
strstr
(
argv
[
i
],
","
)
==
NULL
)
{
++
i
;
// only one col
if
(
strstr
(
argv
[
i
],
","
)
==
NULL
)
{
if
(
strcasecmp
(
argv
[
i
],
"INT"
)
// only one col
&&
strcasecmp
(
argv
[
i
],
"FLOAT"
)
if
(
strcasecmp
(
argv
[
i
],
"INT"
)
&&
strcasecmp
(
argv
[
i
],
"TINYINT"
)
&&
strcasecmp
(
argv
[
i
],
"FLOAT"
)
&&
strcasecmp
(
argv
[
i
],
"BOOL"
)
&&
strcasecmp
(
argv
[
i
],
"TINYINT"
)
&&
strcasecmp
(
argv
[
i
],
"SMALLINT"
)
&&
strcasecmp
(
argv
[
i
],
"BOOL"
)
&&
strcasecmp
(
argv
[
i
],
"BIGINT"
)
&&
strcasecmp
(
argv
[
i
],
"SMALLINT"
)
&&
strcasecmp
(
argv
[
i
],
"DOUBLE"
)
&&
strcasecmp
(
argv
[
i
],
"BIGINT"
)
&&
strcasecmp
(
argv
[
i
],
"BINARY"
)
&&
strcasecmp
(
argv
[
i
],
"DOUBLE"
)
&&
strcasecmp
(
argv
[
i
],
"TIMESTAMP"
)
&&
strcasecmp
(
argv
[
i
],
"BINARY"
)
&&
strcasecmp
(
argv
[
i
],
"NCHAR"
))
{
&&
strcasecmp
(
argv
[
i
],
"TIMESTAMP"
)
printHelp
();
&&
strcasecmp
(
argv
[
i
],
"NCHAR"
))
{
errorPrint
(
"%s"
,
"-b: Invalid data_type!
\n
"
);
printHelp
();
exit
(
EXIT_FAILURE
);
errorPrint
(
"%s"
,
"-b: Invalid data_type!
\n
"
);
}
exit
(
EXIT_FAILURE
);
arguments
->
datatype
[
0
]
=
argv
[
i
];
}
}
else
{
arguments
->
datatype
[
0
]
=
argv
[
i
];
// more than one col
}
else
{
int
index
=
0
;
// more than one col
g_dupstr
=
strdup
(
argv
[
i
]);
int
index
=
0
;
char
*
running
=
g_dupstr
;
g_dupstr
=
strdup
(
argv
[
i
]);
char
*
token
=
strsep
(
&
running
,
","
);
char
*
running
=
g_dupstr
;
while
(
token
!=
NULL
)
{
char
*
token
=
strsep
(
&
running
,
","
);
if
(
strcasecmp
(
token
,
"INT"
)
while
(
token
!=
NULL
)
{
&&
strcasecmp
(
token
,
"FLOAT"
)
if
(
strcasecmp
(
token
,
"INT"
)
&&
strcasecmp
(
token
,
"TINYINT"
)
&&
strcasecmp
(
token
,
"FLOAT"
)
&&
strcasecmp
(
token
,
"BOOL"
)
&&
strcasecmp
(
token
,
"TINYINT"
)
&&
strcasecmp
(
token
,
"SMALLINT"
)
&&
strcasecmp
(
token
,
"BOOL"
)
&&
strcasecmp
(
token
,
"BIGINT"
)
&&
strcasecmp
(
token
,
"SMALLINT"
)
&&
strcasecmp
(
token
,
"DOUBLE"
)
&&
strcasecmp
(
token
,
"BIGINT"
)
&&
strcasecmp
(
token
,
"BINARY"
)
&&
strcasecmp
(
token
,
"DOUBLE"
)
&&
strcasecmp
(
token
,
"TIMESTAMP"
)
&&
strcasecmp
(
token
,
"BINARY"
)
&&
strcasecmp
(
token
,
"NCHAR"
))
{
&&
strcasecmp
(
token
,
"TIMESTAMP"
)
printHelp
();
&&
strcasecmp
(
token
,
"NCHAR"
))
{
free
(
g_dupstr
);
printHelp
();
errorPrint
(
"%s"
,
"-b: Invalid data_type!
\n
"
);
free
(
g_dupstr
);
exit
(
EXIT_FAILURE
);
errorPrint
(
"%s"
,
"-b: Invalid data_type!
\n
"
);
}
exit
(
EXIT_FAILURE
);
arguments
->
datatype
[
index
++
]
=
token
;
}
token
=
strsep
(
&
running
,
","
);
arguments
->
datatype
[
index
++
]
=
token
;
if
(
index
>=
MAX_NUM_DATATYPE
)
break
;
token
=
strsep
(
&
running
,
","
);
}
if
(
index
>=
MAX_NUM_DATATYPE
)
break
;
arguments
->
datatype
[
index
]
=
NULL
;
}
}
arguments
->
datatype
[
index
]
=
NULL
;
}
else
if
(
strcmp
(
argv
[
i
],
"-w"
)
==
0
)
{
}
if
((
argc
==
i
+
1
)
||
}
else
if
(
strcmp
(
argv
[
i
],
"-w"
)
==
0
)
{
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
if
((
argc
==
i
+
1
)
||
printHelp
();
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
errorPrint
(
"%s"
,
"
\n\t
-w need a number following!
\n
"
);
printHelp
();
exit
(
EXIT_FAILURE
);
errorPrint
(
"%s"
,
"
\n\t
-w need a number following!
\n
"
);
}
exit
(
EXIT_FAILURE
);
arguments
->
len_of_binary
=
atoi
(
argv
[
++
i
]);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-m"
)
==
0
)
{
arguments
->
len_of_binary
=
atoi
(
argv
[
++
i
]);
if
((
argc
==
i
+
1
)
||
}
else
if
(
strcmp
(
argv
[
i
],
"-m"
)
==
0
)
{
(
isStringNumber
(
argv
[
i
+
1
])))
{
if
((
argc
==
i
+
1
)
||
printHelp
();
(
isStringNumber
(
argv
[
i
+
1
])))
{
errorPrint
(
"%s"
,
"
\n\t
-m need a letter-initial string following!
\n
"
);
printHelp
();
exit
(
EXIT_FAILURE
);
errorPrint
(
"%s"
,
"
\n\t
-m need a letter-initial string following!
\n
"
);
}
exit
(
EXIT_FAILURE
);
arguments
->
tb_prefix
=
argv
[
++
i
];
}
}
else
if
(
strcmp
(
argv
[
i
],
"-N"
)
==
0
)
{
arguments
->
tb_prefix
=
argv
[
++
i
];
arguments
->
use_metric
=
false
;
}
else
if
(
strcmp
(
argv
[
i
],
"-N"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-x"
)
==
0
)
{
arguments
->
use_metric
=
false
;
arguments
->
insert_only
=
false
;
}
else
if
(
strcmp
(
argv
[
i
],
"-M"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-y"
)
==
0
)
{
arguments
->
demo_mode
=
false
;
arguments
->
answer_yes
=
true
;
}
else
if
(
strcmp
(
argv
[
i
],
"-x"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-g"
)
==
0
)
{
arguments
->
insert_only
=
false
;
arguments
->
debug_print
=
true
;
}
else
if
(
strcmp
(
argv
[
i
],
"-y"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-gg"
)
==
0
)
{
arguments
->
answer_yes
=
true
;
arguments
->
verbose_print
=
true
;
}
else
if
(
strcmp
(
argv
[
i
],
"-g"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-pp"
)
==
0
)
{
arguments
->
debug_print
=
true
;
arguments
->
performance_print
=
true
;
}
else
if
(
strcmp
(
argv
[
i
],
"-gg"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-O"
)
==
0
)
{
arguments
->
verbose_print
=
true
;
if
((
argc
==
i
+
1
)
||
}
else
if
(
strcmp
(
argv
[
i
],
"-pp"
)
==
0
)
{
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
arguments
->
performance_print
=
true
;
printHelp
();
}
else
if
(
strcmp
(
argv
[
i
],
"-O"
)
==
0
)
{
errorPrint
(
"%s"
,
"
\n\t
-O need a number following!
\n
"
);
if
((
argc
==
i
+
1
)
||
exit
(
EXIT_FAILURE
);
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
}
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-O need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
disorderRatio
=
atoi
(
argv
[
++
i
]);
arguments
->
disorderRatio
=
atoi
(
argv
[
++
i
]);
if
(
arguments
->
disorderRatio
>
50
)
{
if
(
arguments
->
disorderRatio
>
50
)
{
arguments
->
disorderRatio
=
50
;
arguments
->
disorderRatio
=
50
;
}
}
if
(
arguments
->
disorderRatio
<
0
)
{
if
(
arguments
->
disorderRatio
<
0
)
{
arguments
->
disorderRatio
=
0
;
arguments
->
disorderRatio
=
0
;
}
}
}
else
if
(
strcmp
(
argv
[
i
],
"-R"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-R"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-R need a number following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-R need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
disorderRange
=
atoi
(
argv
[
++
i
]);
arguments
->
disorderRange
=
atoi
(
argv
[
++
i
]);
if
(
arguments
->
disorderRange
<
0
)
if
(
arguments
->
disorderRange
<
0
)
arguments
->
disorderRange
=
1000
;
arguments
->
disorderRange
=
1000
;
}
else
if
(
strcmp
(
argv
[
i
],
"-a"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-a"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-a need a number following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-a need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
replica
=
atoi
(
argv
[
++
i
]);
arguments
->
replica
=
atoi
(
argv
[
++
i
]);
if
(
arguments
->
replica
>
3
||
arguments
->
replica
<
1
)
{
if
(
arguments
->
replica
>
3
||
arguments
->
replica
<
1
)
{
arguments
->
replica
=
1
;
arguments
->
replica
=
1
;
}
}
}
else
if
(
strcmp
(
argv
[
i
],
"-D"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-D"
)
==
0
)
{
arguments
->
method_of_delete
=
atoi
(
argv
[
++
i
]);
arguments
->
method_of_delete
=
atoi
(
argv
[
++
i
]);
if
(
arguments
->
method_of_delete
>
3
)
{
if
(
arguments
->
method_of_delete
>
3
)
{
errorPrint
(
"%s"
,
"
\n\t
-D need a valud (0~3) number following!
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-D need a valud (0~3) number following!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
else
if
((
strcmp
(
argv
[
i
],
"--version"
)
==
0
)
||
}
else
if
((
strcmp
(
argv
[
i
],
"--version"
)
==
0
)
||
(
strcmp
(
argv
[
i
],
"-V"
)
==
0
)){
(
strcmp
(
argv
[
i
],
"-V"
)
==
0
)){
printVersion
();
printVersion
();
exit
(
0
);
exit
(
0
);
}
else
if
(
strcmp
(
argv
[
i
],
"--help"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"--help"
)
==
0
)
{
printHelp
();
printHelp
();
exit
(
0
);
exit
(
0
);
}
else
{
}
else
{
printHelp
();
printHelp
();
errorPrint
(
"%s"
,
"ERROR: wrong options
\n
"
);
errorPrint
(
"%s"
,
"ERROR: wrong options
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
}
int
columnCount
;
int
columnCount
;
for
(
columnCount
=
0
;
columnCount
<
MAX_NUM_DATATYPE
;
columnCount
++
)
{
for
(
columnCount
=
0
;
columnCount
<
MAX_NUM_DATATYPE
;
columnCount
++
)
{
if
(
g_args
.
datatype
[
columnCount
]
==
NULL
)
{
if
(
g_args
.
datatype
[
columnCount
]
==
NULL
)
{
break
;
break
;
}
}
}
}
if
(
0
==
columnCount
)
{
if
(
0
==
columnCount
)
{
perror
(
"data type error!"
);
perror
(
"data type error!"
);
exit
(
-
1
);
exit
(
-
1
);
}
}
g_args
.
num_of_CPR
=
columnCount
;
g_args
.
num_of_CPR
=
columnCount
;
if
(((
arguments
->
debug_print
)
&&
(
arguments
->
metaFile
==
NULL
))
if
(((
arguments
->
debug_print
)
&&
(
arguments
->
metaFile
==
NULL
))
||
arguments
->
verbose_print
)
{
||
arguments
->
verbose_print
)
{
printf
(
"###################################################################
\n
"
);
printf
(
"###################################################################
\n
"
);
printf
(
"# meta file: %s
\n
"
,
arguments
->
metaFile
);
printf
(
"# meta file: %s
\n
"
,
arguments
->
metaFile
);
printf
(
"# Server IP: %s:%hu
\n
"
,
printf
(
"# Server IP: %s:%hu
\n
"
,
arguments
->
host
==
NULL
?
"localhost"
:
arguments
->
host
,
arguments
->
host
==
NULL
?
"localhost"
:
arguments
->
host
,
arguments
->
port
);
arguments
->
port
);
printf
(
"# User: %s
\n
"
,
arguments
->
user
);
printf
(
"# User: %s
\n
"
,
arguments
->
user
);
printf
(
"# Password: %s
\n
"
,
arguments
->
password
);
printf
(
"# Password: %s
\n
"
,
arguments
->
password
);
printf
(
"# Use metric: %s
\n
"
,
printf
(
"# Use metric: %s
\n
"
,
arguments
->
use_metric
?
"true"
:
"false"
);
arguments
->
use_metric
?
"true"
:
"false"
);
if
(
*
(
arguments
->
datatype
))
{
if
(
*
(
arguments
->
datatype
))
{
printf
(
"# Specified data type: "
);
printf
(
"# Specified data type: "
);
for
(
int
i
=
0
;
i
<
MAX_NUM_DATATYPE
;
i
++
)
for
(
int
i
=
0
;
i
<
MAX_NUM_DATATYPE
;
i
++
)
if
(
arguments
->
datatype
[
i
])
if
(
arguments
->
datatype
[
i
])
printf
(
"%s,"
,
arguments
->
datatype
[
i
]);
printf
(
"%s,"
,
arguments
->
datatype
[
i
]);
else
else
break
;
break
;
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
printf
(
"# Insertion interval: %"
PRIu64
"
\n
"
,
arguments
->
insert_interval
);
printf
(
"# Number of records per req: %u
\n
"
,
arguments
->
num_of_RPR
);
printf
(
"# Max SQL length: %"
PRIu64
"
\n
"
,
arguments
->
max_sql_len
);
printf
(
"# Length of Binary: %d
\n
"
,
arguments
->
len_of_binary
);
printf
(
"# Number of Threads: %d
\n
"
,
arguments
->
num_of_threads
);
printf
(
"# Number of Tables: %"
PRId64
"
\n
"
,
arguments
->
num_of_tables
);
printf
(
"# Number of Data per Table: %"
PRId64
"
\n
"
,
arguments
->
num_of_DPT
);
printf
(
"# Database name: %s
\n
"
,
arguments
->
database
);
printf
(
"# Table prefix: %s
\n
"
,
arguments
->
tb_prefix
);
if
(
arguments
->
disorderRatio
)
{
printf
(
"# Data order: %d
\n
"
,
arguments
->
disorderRatio
);
printf
(
"# Data out of order rate: %d
\n
"
,
arguments
->
disorderRange
);
}
printf
(
"# Delete method: %d
\n
"
,
arguments
->
method_of_delete
);
printf
(
"# Answer yes when prompt: %d
\n
"
,
arguments
->
answer_yes
);
printf
(
"# Print debug info: %d
\n
"
,
arguments
->
debug_print
);
printf
(
"# Print verbose info: %d
\n
"
,
arguments
->
verbose_print
);
printf
(
"###################################################################
\n
"
);
prompt
();
}
}
printf
(
"# Insertion interval: %"
PRIu64
"
\n
"
,
arguments
->
insert_interval
);
printf
(
"# Number of records per req: %u
\n
"
,
arguments
->
num_of_RPR
);
printf
(
"# Max SQL length: %"
PRIu64
"
\n
"
,
arguments
->
max_sql_len
);
printf
(
"# Length of Binary: %d
\n
"
,
arguments
->
len_of_binary
);
printf
(
"# Number of Threads: %d
\n
"
,
arguments
->
num_of_threads
);
printf
(
"# Number of Tables: %"
PRId64
"
\n
"
,
arguments
->
num_of_tables
);
printf
(
"# Number of Data per Table: %"
PRId64
"
\n
"
,
arguments
->
num_of_DPT
);
printf
(
"# Database name: %s
\n
"
,
arguments
->
database
);
printf
(
"# Table prefix: %s
\n
"
,
arguments
->
tb_prefix
);
if
(
arguments
->
disorderRatio
)
{
printf
(
"# Data order: %d
\n
"
,
arguments
->
disorderRatio
);
printf
(
"# Data out of order rate: %d
\n
"
,
arguments
->
disorderRange
);
}
printf
(
"# Delete method: %d
\n
"
,
arguments
->
method_of_delete
);
printf
(
"# Answer yes when prompt: %d
\n
"
,
arguments
->
answer_yes
);
printf
(
"# Print debug info: %d
\n
"
,
arguments
->
debug_print
);
printf
(
"# Print verbose info: %d
\n
"
,
arguments
->
verbose_print
);
printf
(
"###################################################################
\n
"
);
prompt
();
}
}
}
static
bool
getInfoFromJsonFile
(
char
*
file
);
static
void
init_rand_data
();
static
void
tmfclose
(
FILE
*
fp
)
{
static
void
tmfclose
(
FILE
*
fp
)
{
if
(
NULL
!=
fp
)
{
if
(
NULL
!=
fp
)
{
fclose
(
fp
);
fclose
(
fp
);
}
}
}
}
static
void
tmfree
(
char
*
buf
)
{
static
void
tmfree
(
char
*
buf
)
{
if
(
NULL
!=
buf
)
{
if
(
NULL
!=
buf
)
{
free
(
buf
);
free
(
buf
);
}
}
}
}
static
int
queryDbExec
(
TAOS
*
taos
,
char
*
command
,
QUERY_TYPE
type
,
bool
quiet
)
{
static
int
queryDbExec
(
TAOS
*
taos
,
char
*
command
,
QUERY_TYPE
type
,
bool
quiet
)
{
int
i
;
int
i
;
TAOS_RES
*
res
=
NULL
;
TAOS_RES
*
res
=
NULL
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
for
(
i
=
0
;
i
<
5
/* retry */
;
i
++
)
{
if
(
NULL
!=
res
)
{
taos_free_result
(
res
);
res
=
NULL
;
}
for
(
i
=
0
;
i
<
5
/* retry */
;
i
++
)
{
res
=
taos_query
(
taos
,
command
);
if
(
NULL
!=
res
)
{
code
=
taos_errno
(
res
);
taos_free_result
(
res
);
if
(
0
==
code
)
{
res
=
NULL
;
break
;
}
}
}
res
=
taos_query
(
taos
,
command
);
verbosePrint
(
"%s() LN%d - command: %s
\n
"
,
__func__
,
__LINE__
,
command
);
code
=
taos_errno
(
res
);
if
(
code
!=
0
)
{
if
(
0
==
code
)
{
if
(
!
quiet
)
{
break
;
errorPrint
(
"Failed to execute %s, reason: %s
\n
"
,
command
,
taos_errstr
(
res
));
}
taos_free_result
(
res
);
//taos_close(taos);
return
-
1
;
}
}
}
verbosePrint
(
"%s() LN%d - command: %s
\n
"
,
__func__
,
__LINE__
,
command
);
if
(
INSERT_TYPE
==
type
)
{
if
(
code
!=
0
)
{
int
affectedRows
=
taos_affected_rows
(
res
);
if
(
!
quiet
)
{
taos_free_result
(
res
);
errorPrint
(
"Failed to execute %s, reason: %s
\n
"
,
return
affectedRows
;
command
,
taos_errstr
(
res
));
}
}
taos_free_result
(
res
);
//taos_close(taos);
return
-
1
;
}
if
(
INSERT_TYPE
==
type
)
{
int
affectedRows
=
taos_affected_rows
(
res
);
taos_free_result
(
res
);
taos_free_result
(
res
);
return
affectedRows
;
return
0
;
}
taos_free_result
(
res
);
return
0
;
}
}
static
void
appendResultBufToFile
(
char
*
resultBuf
,
threadInfo
*
pThreadInfo
)
static
void
appendResultBufToFile
(
char
*
resultBuf
,
threadInfo
*
pThreadInfo
)
{
{
pThreadInfo
->
fp
=
fopen
(
pThreadInfo
->
filePath
,
"at"
);
pThreadInfo
->
fp
=
fopen
(
pThreadInfo
->
filePath
,
"at"
);
if
(
pThreadInfo
->
fp
==
NULL
)
{
if
(
pThreadInfo
->
fp
==
NULL
)
{
errorPrint
(
errorPrint
(
"%s() LN%d, failed to open result file: %s, result will not save to file
\n
"
,
"%s() LN%d, failed to open result file: %s, result will not save to file
\n
"
,
__func__
,
__LINE__
,
pThreadInfo
->
filePath
);
__func__
,
__LINE__
,
pThreadInfo
->
filePath
);
return
;
return
;
}
}
fprintf
(
pThreadInfo
->
fp
,
"%s"
,
resultBuf
);
fprintf
(
pThreadInfo
->
fp
,
"%s"
,
resultBuf
);
tmfclose
(
pThreadInfo
->
fp
);
tmfclose
(
pThreadInfo
->
fp
);
pThreadInfo
->
fp
=
NULL
;
pThreadInfo
->
fp
=
NULL
;
}
}
static
void
fetchResult
(
TAOS_RES
*
res
,
threadInfo
*
pThreadInfo
)
{
static
void
fetchResult
(
TAOS_RES
*
res
,
threadInfo
*
pThreadInfo
)
{
TAOS_ROW
row
=
NULL
;
TAOS_ROW
row
=
NULL
;
int
num_rows
=
0
;
int
num_rows
=
0
;
int
num_fields
=
taos_field_count
(
res
);
int
num_fields
=
taos_field_count
(
res
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
res
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
res
);
char
*
databuf
=
(
char
*
)
calloc
(
1
,
100
*
1024
*
1024
);
char
*
databuf
=
(
char
*
)
calloc
(
1
,
100
*
1024
*
1024
);
if
(
databuf
==
NULL
)
{
if
(
databuf
==
NULL
)
{
errorPrint
(
"%s() LN%d, failed to malloc, warning: save result to file slowly!
\n
"
,
errorPrint
(
"%s() LN%d, failed to malloc, warning: save result to file slowly!
\n
"
,
__func__
,
__LINE__
);
__func__
,
__LINE__
);
return
;
return
;
}
}
int64_t
totalLen
=
0
;
int64_t
totalLen
=
0
;
// fetch the records row by row
// fetch the records row by row
while
((
row
=
taos_fetch_row
(
res
)))
{
while
((
row
=
taos_fetch_row
(
res
)))
{
if
(
totalLen
>=
100
*
1024
*
1024
-
32000
)
{
if
(
totalLen
>=
100
*
1024
*
1024
-
32000
)
{
if
(
strlen
(
pThreadInfo
->
filePath
)
>
0
)
if
(
strlen
(
pThreadInfo
->
filePath
)
>
0
)
appendResultBufToFile
(
databuf
,
pThreadInfo
);
appendResultBufToFile
(
databuf
,
pThreadInfo
);
totalLen
=
0
;
totalLen
=
0
;
memset
(
databuf
,
0
,
100
*
1024
*
1024
);
memset
(
databuf
,
0
,
100
*
1024
*
1024
);
}
num_rows
++
;
char
temp
[
16000
]
=
{
0
};
int
len
=
taos_print_row
(
temp
,
row
,
fields
,
num_fields
);
len
+=
sprintf
(
temp
+
len
,
"
\n
"
);
//printf("query result:%s\n", temp);
memcpy
(
databuf
+
totalLen
,
temp
,
len
);
totalLen
+=
len
;
verbosePrint
(
"%s() LN%d, totalLen: %"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
totalLen
);
}
verbosePrint
(
"%s() LN%d, databuf=%s resultFile=%s
\n
"
,
__func__
,
__LINE__
,
databuf
,
pThreadInfo
->
filePath
);
if
(
strlen
(
pThreadInfo
->
filePath
)
>
0
)
{
appendResultBufToFile
(
databuf
,
pThreadInfo
);
}
}
num_rows
++
;
free
(
databuf
);
char
temp
[
16000
]
=
{
0
};
int
len
=
taos_print_row
(
temp
,
row
,
fields
,
num_fields
);
len
+=
sprintf
(
temp
+
len
,
"
\n
"
);
//printf("query result:%s\n", temp);
memcpy
(
databuf
+
totalLen
,
temp
,
len
);
totalLen
+=
len
;
verbosePrint
(
"%s() LN%d, totalLen: %"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
totalLen
);
}
verbosePrint
(
"%s() LN%d, databuf=%s resultFile=%s
\n
"
,
__func__
,
__LINE__
,
databuf
,
pThreadInfo
->
filePath
);
if
(
strlen
(
pThreadInfo
->
filePath
)
>
0
)
{
appendResultBufToFile
(
databuf
,
pThreadInfo
);
}
free
(
databuf
);
}
}
static
void
selectAndGetResult
(
static
void
selectAndGetResult
(
threadInfo
*
pThreadInfo
,
char
*
command
)
threadInfo
*
pThreadInfo
,
char
*
command
)
{
{
if
(
0
==
strncasecmp
(
g_queryInfo
.
queryMode
,
"taosc"
,
strlen
(
"taosc"
)))
{
if
(
0
==
strncasecmp
(
g_queryInfo
.
queryMode
,
"taosc"
,
strlen
(
"taosc"
)))
{
TAOS_RES
*
res
=
taos_query
(
pThreadInfo
->
taos
,
command
);
TAOS_RES
*
res
=
taos_query
(
pThreadInfo
->
taos
,
command
);
if
(
res
==
NULL
||
taos_errno
(
res
)
!=
0
)
{
if
(
res
==
NULL
||
taos_errno
(
res
)
!=
0
)
{
errorPrint
(
"%s() LN%d, failed to execute sql:%s, reason:%s
\n
"
,
errorPrint
(
"%s() LN%d, failed to execute sql:%s, reason:%s
\n
"
,
__func__
,
__LINE__
,
command
,
taos_errstr
(
res
));
__func__
,
__LINE__
,
command
,
taos_errstr
(
res
));
taos_free_result
(
res
);
taos_free_result
(
res
);
return
;
return
;
}
}
fetchResult
(
res
,
pThreadInfo
);
fetchResult
(
res
,
pThreadInfo
);
taos_free_result
(
res
);
taos_free_result
(
res
);
}
else
if
(
0
==
strncasecmp
(
g_queryInfo
.
queryMode
,
"rest"
,
strlen
(
"rest"
)))
{
}
else
if
(
0
==
strncasecmp
(
g_queryInfo
.
queryMode
,
"rest"
,
strlen
(
"rest"
)))
{
int
retCode
=
postProceSql
(
int
retCode
=
postProceSql
(
g_queryInfo
.
host
,
&
(
g_queryInfo
.
serv_addr
),
g_queryInfo
.
port
,
g_queryInfo
.
host
,
&
(
g_queryInfo
.
serv_addr
),
g_queryInfo
.
port
,
command
,
command
,
pThreadInfo
);
pThreadInfo
);
if
(
0
!=
retCode
)
{
if
(
0
!=
retCode
)
{
printf
(
"====restful return fail, threadID[%d]
\n
"
,
pThreadInfo
->
threadID
);
printf
(
"====restful return fail, threadID[%d]
\n
"
,
pThreadInfo
->
threadID
);
}
}
}
else
{
}
else
{
errorPrint
(
"%s() LN%d, unknown query mode: %s
\n
"
,
errorPrint
(
"%s() LN%d, unknown query mode: %s
\n
"
,
__func__
,
__LINE__
,
g_queryInfo
.
queryMode
);
__func__
,
__LINE__
,
g_queryInfo
.
queryMode
);
}
}
}
}
static
int32_t
rand_bool
(){
static
int32_t
rand_bool
(){
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
return
randint
[
cursor
]
%
2
;
return
randint
[
cursor
]
%
2
;
}
}
static
int32_t
rand_tinyint
(){
static
int32_t
rand_tinyint
(){
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
return
randint
[
cursor
]
%
128
;
return
randint
[
cursor
]
%
128
;
}
}
static
int32_t
rand_smallint
(){
static
int32_t
rand_smallint
(){
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
return
randint
[
cursor
]
%
32767
;
return
randint
[
cursor
]
%
32767
;
}
}
static
int32_t
rand_int
(){
static
int32_t
rand_int
(){
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
return
randint
[
cursor
];
return
randint
[
cursor
];
}
}
static
int64_t
rand_bigint
(){
static
int64_t
rand_bigint
(){
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
return
randbigint
[
cursor
];
return
randbigint
[
cursor
];
}
}
static
float
rand_float
(){
static
float
rand_float
(){
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
return
randfloat
[
cursor
];
return
randfloat
[
cursor
];
}
static
float
demo_current_float
(){
static
int
cursor
;
cursor
++
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
return
(
float
)(
5
+
randfloat
[
cursor
]
/
1000000000
);
}
static
int32_t
demo_voltage_int
(){
static
int
cursor
;
cursor
++
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
return
210
+
randint
[
cursor
]
%
20
;
}
static
float
demo_phase_float
(){
static
int
cursor
;
cursor
++
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
return
(
float
)(
120
+
randfloat
[
cursor
]
/
1000000000
);
}
}
#if 0
#if 0
...
@@ -1334,33 +1368,32 @@ static void nonrand_string(char *str, int size)
...
@@ -1334,33 +1368,32 @@ static void nonrand_string(char *str, int size)
static
const
char
charset
[]
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
;
static
const
char
charset
[]
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
;
static
void
rand_string
(
char
*
str
,
int
size
)
{
static
void
rand_string
(
char
*
str
,
int
size
)
{
str
[
0
]
=
0
;
str
[
0
]
=
0
;
if
(
size
>
0
)
{
if
(
size
>
0
)
{
//--size;
//--size;
int
n
;
int
n
;
for
(
n
=
0
;
n
<
size
;
n
++
)
{
for
(
n
=
0
;
n
<
size
;
n
++
)
{
int
key
=
abs
(
rand_tinyint
())
%
(
int
)(
sizeof
(
charset
)
-
1
);
int
key
=
abs
(
rand_tinyint
())
%
(
int
)(
sizeof
(
charset
)
-
1
);
str
[
n
]
=
charset
[
key
];
str
[
n
]
=
charset
[
key
];
}
str
[
n
]
=
0
;
}
}
str
[
n
]
=
0
;
}
}
}
static
double
rand_double
()
{
static
double
rand_double
()
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
return
randdouble
[
cursor
];
return
randdouble
[
cursor
];
}
}
static
void
init_rand_data
()
{
static
void
init_rand_data
()
{
for
(
int
i
=
0
;
i
<
MAX_PREPARED_RAND
;
i
++
){
for
(
int
i
=
0
;
i
<
MAX_PREPARED_RAND
;
i
++
){
randint
[
i
]
=
(
int
)(
taosRandom
()
%
65535
);
randint
[
i
]
=
(
int
)(
taosRandom
()
%
65535
);
randbigint
[
i
]
=
(
int64_t
)(
taosRandom
()
%
2147483648
);
randbigint
[
i
]
=
(
int64_t
)(
taosRandom
()
%
2147483648
);
randfloat
[
i
]
=
(
float
)(
taosRandom
()
/
1000
.
0
);
randfloat
[
i
]
=
(
float
)(
taosRandom
()
/
1000
.
0
);
randdouble
[
i
]
=
(
double
)(
taosRandom
()
/
1000000
.
0
);
randdouble
[
i
]
=
(
double
)(
taosRandom
()
/
1000000
.
0
);
}
}
}
}
#define SHOW_PARSE_RESULT_START() \
#define SHOW_PARSE_RESULT_START() \
...
@@ -1386,759 +1419,767 @@ static void init_rand_data() {
...
@@ -1386,759 +1419,767 @@ static void init_rand_data() {
static
int
printfInsertMeta
()
{
static
int
printfInsertMeta
()
{
SHOW_PARSE_RESULT_START
();
SHOW_PARSE_RESULT_START
();
printf
(
"interface:
\033
[33m%s
\033
[0m
\n
"
,
if
(
g_args
.
demo_mode
)
(
g_args
.
iface
==
TAOSC_IFACE
)
?
"taosc"
:
(
g_args
.
iface
==
REST_IFACE
)
?
"rest"
:
"stmt"
);
printf
(
"
\n
taosdemo is simulating data generated by power equipments monitoring...
\n\n
"
);
printf
(
"host:
\033
[33m%s:%u
\033
[0m
\n
"
,
else
g_Dbs
.
host
,
g_Dbs
.
port
);
printf
(
"
\n
taosdemo is simulating random data as you request..
\n\n
"
);
printf
(
"user:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
user
);
printf
(
"password:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
password
);
printf
(
"interface:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
"configDir:
\033
[33m%s
\033
[0m
\n
"
,
configDir
);
(
g_args
.
iface
==
TAOSC_IFACE
)
?
"taosc"
:
(
g_args
.
iface
==
REST_IFACE
)
?
"rest"
:
"stmt"
);
printf
(
"resultFile:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
resultFile
);
printf
(
"host:
\033
[33m%s:%u
\033
[0m
\n
"
,
printf
(
"thread num of insert data:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
threadCount
);
g_Dbs
.
host
,
g_Dbs
.
port
);
printf
(
"thread num of create table:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"user:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
user
);
g_Dbs
.
threadCountByCreateTbl
);
printf
(
"password:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
password
);
printf
(
"top insert interval:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
printf
(
"configDir:
\033
[33m%s
\033
[0m
\n
"
,
configDir
);
g_args
.
insert_interval
);
printf
(
"resultFile:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
resultFile
);
printf
(
"number of records per req:
\033
[33m%u
\033
[0m
\n
"
,
printf
(
"thread num of insert data:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
threadCount
);
g_args
.
num_of_RPR
);
printf
(
"thread num of create table:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"max sql length:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_Dbs
.
threadCountByCreateTbl
);
g_args
.
max_sql_len
);
printf
(
"top insert interval:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_args
.
insert_interval
);
printf
(
"database count:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
dbCount
);
printf
(
"number of records per req:
\033
[33m%u
\033
[0m
\n
"
,
g_args
.
num_of_RPR
);
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
printf
(
"max sql length:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
printf
(
"database[
\033
[33m%d
\033
[0m]:
\n
"
,
i
);
g_args
.
max_sql_len
);
printf
(
" database[%d] name:
\033
[33m%s
\033
[0m
\n
"
,
i
,
g_Dbs
.
db
[
i
].
dbName
);
printf
(
"database count:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
dbCount
);
if
(
0
==
g_Dbs
.
db
[
i
].
drop
)
{
printf
(
" drop:
\033
[33mno
\033
[0m
\n
"
);
}
else
{
printf
(
" drop:
\033
[33myes
\033
[0m
\n
"
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
blocks
>
0
)
{
printf
(
" blocks:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
blocks
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
cache
>
0
)
{
printf
(
" cache:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
cache
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
days
>
0
)
{
printf
(
" days:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
days
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
keep
>
0
)
{
printf
(
" keep:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
keep
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
replica
>
0
)
{
printf
(
" replica:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
replica
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
update
>
0
)
{
printf
(
" update:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
update
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
minRows
>
0
)
{
printf
(
" minRows:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
minRows
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
maxRows
>
0
)
{
printf
(
" maxRows:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
maxRows
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
comp
>
0
)
{
printf
(
" comp:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
comp
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
walLevel
>
0
)
{
printf
(
" walLevel:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
walLevel
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
fsync
>
0
)
{
printf
(
" fsync:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
fsync
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
quorum
>
0
)
{
printf
(
" quorum:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
quorum
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
[
0
]
!=
0
)
{
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
"ms"
,
2
))
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
"us"
,
2
)))
{
printf
(
" precision:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
precision
);
}
else
{
printf
(
"
\033
[1m
\033
[40;31m precision error: %s
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
precision
);
return
-
1
;
}
}
printf
(
" super table count:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
g_Dbs
.
db
[
i
].
superTblCount
);
printf
(
"database[
\033
[33m%d
\033
[0m]:
\n
"
,
i
);
for
(
uint64_t
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
printf
(
" database[%d] name:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
" super table[
\033
[33m%"
PRIu64
"
\033
[0m]:
\n
"
,
j
);
i
,
g_Dbs
.
db
[
i
].
dbName
);
if
(
0
==
g_Dbs
.
db
[
i
].
drop
)
{
printf
(
" drop:
\033
[33mno
\033
[0m
\n
"
);
}
else
{
printf
(
" drop:
\033
[33myes
\033
[0m
\n
"
);
}
printf
(
" stbName:
\033
[33m%s
\033
[0m
\n
"
,
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
blocks
>
0
)
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sTblName
);
printf
(
" blocks:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
blocks
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
cache
>
0
)
{
printf
(
" cache:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
cache
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
days
>
0
)
{
printf
(
" days:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
days
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
keep
>
0
)
{
printf
(
" keep:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
keep
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
replica
>
0
)
{
printf
(
" replica:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
replica
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
update
>
0
)
{
printf
(
" update:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
update
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
minRows
>
0
)
{
printf
(
" minRows:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
minRows
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
maxRows
>
0
)
{
printf
(
" maxRows:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
maxRows
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
comp
>
0
)
{
printf
(
" comp:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
comp
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
walLevel
>
0
)
{
printf
(
" walLevel:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
walLevel
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
fsync
>
0
)
{
printf
(
" fsync:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
fsync
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
quorum
>
0
)
{
printf
(
" quorum:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
quorum
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
[
0
]
!=
0
)
{
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
"ms"
,
2
))
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
"us"
,
2
)))
{
printf
(
" precision:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
precision
);
}
else
{
printf
(
"
\033
[1m
\033
[40;31m precision error: %s
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
precision
);
return
-
1
;
}
}
if
(
PRE_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
printf
(
" super table count:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
printf
(
" autoCreateTable:
\033
[33m%s
\033
[0m
\n
"
,
"no"
);
g_Dbs
.
db
[
i
].
superTblCount
);
}
else
if
(
AUTO_CREATE_SUBTBL
==
for
(
uint64_t
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
printf
(
" super table[
\033
[33m%"
PRIu64
"
\033
[0m]:
\n
"
,
j
);
printf
(
" autoCreateTable:
\033
[33m%s
\033
[0m
\n
"
,
"yes"
);
}
else
{
printf
(
" autoCreateTable:
\033
[33m%s
\033
[0m
\n
"
,
"error"
);
}
if
(
TBL_NO_EXISTS
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblExists
)
{
printf
(
" stbName:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
" childTblExists:
\033
[33m%s
\033
[0m
\n
"
,
"no"
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sTblName
);
}
else
if
(
TBL_ALREADY_EXISTS
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblExists
)
{
printf
(
" childTblExists:
\033
[33m%s
\033
[0m
\n
"
,
"yes"
);
}
else
{
printf
(
" childTblExists:
\033
[33m%s
\033
[0m
\n
"
,
"error"
);
}
printf
(
" childTblCount:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
if
(
PRE_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblCount
);
printf
(
" autoCreateTable:
\033
[33m%s
\033
[0m
\n
"
,
"no"
);
printf
(
" childTblPrefix:
\033
[33m%s
\033
[0m
\n
"
,
}
else
if
(
AUTO_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblPrefix
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
printf
(
" dataSource:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
" autoCreateTable:
\033
[33m%s
\033
[0m
\n
"
,
"yes"
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
dataSource
);
}
else
{
printf
(
" iface:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
" autoCreateTable:
\033
[33m%s
\033
[0m
\n
"
,
"error"
);
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
TAOSC_IFACE
)
?
"taosc"
:
}
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
REST_IFACE
)
?
"rest"
:
"stmt"
);
if
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblLimit
>
0
)
{
printf
(
" childTblLimit:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblLimit
);
}
if
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblOffset
>
0
)
{
printf
(
" childTblOffset:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblOffset
);
}
printf
(
" insertRows:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
insertRows
);
/*
if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) {
printf(" multiThreadWriteOneTbl: \033[33mno\033[0m\n");
}else {
printf(" multiThreadWriteOneTbl: \033[33myes\033[0m\n");
}
*/
printf
(
" interlaceRows:
\033
[33m%u
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
interlaceRows
);
if
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
interlaceRows
>
0
)
{
if
(
TBL_NO_EXISTS
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblExists
)
{
printf
(
" stable insert interval:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
printf
(
" childTblExists:
\033
[33m%s
\033
[0m
\n
"
,
"no"
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
insertInterval
);
}
else
if
(
TBL_ALREADY_EXISTS
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblExists
)
{
}
printf
(
" childTblExists:
\033
[33m%s
\033
[0m
\n
"
,
"yes"
);
}
else
{
printf
(
" childTblExists:
\033
[33m%s
\033
[0m
\n
"
,
"error"
);
}
printf
(
" disorderRange:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
" childTblCount:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
disorderRange
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblCount
);
printf
(
" disorderRatio:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
" childTblPrefix:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
disorderRatio
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblPrefix
);
printf
(
" maxSqlLen:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
printf
(
" dataSource:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
maxSqlLen
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
dataSource
);
printf
(
" timeStampStep:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
printf
(
" iface:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
timeStampStep
);
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
TAOSC_IFACE
)
?
"taosc"
:
printf
(
" startTimestamp:
\033
[33m%s
\033
[0m
\n
"
,
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
REST_IFACE
)
?
"rest"
:
"stmt"
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
startTimestamp
);
if
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblLimit
>
0
)
{
printf
(
" sampleFormat:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
" childTblLimit:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleForma
t
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblLimi
t
);
printf
(
" sampleFile:
\033
[33m%s
\033
[0m
\n
"
,
}
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleFile
);
if
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblOffset
>
0
)
{
printf
(
" tagsFile:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
" childTblOffset:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagsFile
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblOffset
);
printf
(
" columnCount:
\033
[33m%d
\033
[0m
\n
"
,
}
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columnCount
);
printf
(
" insertRows:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
for
(
int
k
=
0
;
k
<
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columnCount
;
k
++
)
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
insertRows
);
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].columns[k].dataType, g_Dbs.db[i].superTbls[j].columns[k].dataLen);
/*
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
,
if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) {
"binary"
,
6
))
printf(" multiThreadWriteOneTbl: \033[33mno\033[0m\n");
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
,
}else {
"nchar"
,
5
)))
{
printf(" multiThreadWriteOneTbl: \033[33myes\033[0m\n");
printf
(
"column[
\033
[33m%d
\033
[0m]:
\033
[33m%s(%d)
\033
[0m "
,
k
,
}
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
,
*/
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataLen
);
printf
(
" interlaceRows:
\033
[33m%u
\033
[0m
\n
"
,
}
else
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
interlaceRows
);
printf
(
"column[%d]:
\033
[33m%s
\033
[0m "
,
k
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
);
if
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
interlaceRows
>
0
)
{
}
printf
(
" stable insert interval:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
}
g_Dbs
.
db
[
i
].
superTbls
[
j
].
insertInterval
);
printf
(
"
\n
"
);
}
printf
(
" tagCount:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
" disorderRange:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagCount
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
disorderRange
);
for
(
int
k
=
0
;
k
<
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagCount
;
k
++
)
{
printf
(
" disorderRatio:
\033
[33m%d
\033
[0m
\n
"
,
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].tags[k].dataType, g_Dbs.db[i].superTbls[j].tags[k].dataLen);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
disorderRatio
);
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
,
printf
(
" maxSqlLen:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
"binary"
,
strlen
(
"binary"
)))
g_Dbs
.
db
[
i
].
superTbls
[
j
].
maxSqlLen
);
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
,
printf
(
" timeStampStep:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
"nchar"
,
strlen
(
"nchar"
))))
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
timeStampStep
);
printf
(
"tag[%d]:
\033
[33m%s(%d)
\033
[0m "
,
k
,
printf
(
" startTimestamp:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
startTimestamp
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataLen
);
printf
(
" sampleFormat:
\033
[33m%s
\033
[0m
\n
"
,
}
else
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleFormat
);
printf
(
"tag[%d]:
\033
[33m%s
\033
[0m "
,
k
,
printf
(
" sampleFile:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleFile
);
printf
(
" tagsFile:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagsFile
);
printf
(
" columnCount:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columnCount
);
for
(
int
k
=
0
;
k
<
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columnCount
;
k
++
)
{
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].columns[k].dataType, g_Dbs.db[i].superTbls[j].columns[k].dataLen);
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
,
"binary"
,
6
))
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
,
"nchar"
,
5
)))
{
printf
(
"column[
\033
[33m%d
\033
[0m]:
\033
[33m%s(%d)
\033
[0m "
,
k
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataLen
);
}
else
{
printf
(
"column[%d]:
\033
[33m%s
\033
[0m "
,
k
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
);
}
}
printf
(
"
\n
"
);
printf
(
" tagCount:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagCount
);
for
(
int
k
=
0
;
k
<
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagCount
;
k
++
)
{
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].tags[k].dataType, g_Dbs.db[i].superTbls[j].tags[k].dataLen);
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
,
"binary"
,
strlen
(
"binary"
)))
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
,
"nchar"
,
strlen
(
"nchar"
))))
{
printf
(
"tag[%d]:
\033
[33m%s(%d)
\033
[0m "
,
k
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataLen
);
}
else
{
printf
(
"tag[%d]:
\033
[33m%s
\033
[0m "
,
k
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
);
}
}
printf
(
"
\n
"
);
}
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
printf
(
"
\n
"
);
}
SHOW_PARSE_RESULT_END
();
SHOW_PARSE_RESULT_END
();
return
0
;
return
0
;
}
}
static
void
printfInsertMetaToFile
(
FILE
*
fp
)
{
static
void
printfInsertMetaToFile
(
FILE
*
fp
)
{
SHOW_PARSE_RESULT_START_TO_FILE
(
fp
);
SHOW_PARSE_RESULT_START_TO_FILE
(
fp
);
fprintf
(
fp
,
"host: %s:%u
\n
"
,
g_Dbs
.
host
,
g_Dbs
.
port
);
fprintf
(
fp
,
"host: %s:%u
\n
"
,
g_Dbs
.
host
,
g_Dbs
.
port
);
fprintf
(
fp
,
"user: %s
\n
"
,
g_Dbs
.
user
);
fprintf
(
fp
,
"user: %s
\n
"
,
g_Dbs
.
user
);
fprintf
(
fp
,
"configDir: %s
\n
"
,
configDir
);
fprintf
(
fp
,
"configDir: %s
\n
"
,
configDir
);
fprintf
(
fp
,
"resultFile: %s
\n
"
,
g_Dbs
.
resultFile
);
fprintf
(
fp
,
"resultFile: %s
\n
"
,
g_Dbs
.
resultFile
);
fprintf
(
fp
,
"thread num of insert data: %d
\n
"
,
g_Dbs
.
threadCount
);
fprintf
(
fp
,
"thread num of insert data: %d
\n
"
,
g_Dbs
.
threadCount
);
fprintf
(
fp
,
"thread num of create table: %d
\n
"
,
g_Dbs
.
threadCountByCreateTbl
);
fprintf
(
fp
,
"thread num of create table: %d
\n
"
,
g_Dbs
.
threadCountByCreateTbl
);
fprintf
(
fp
,
"number of records per req: %u
\n
"
,
g_args
.
num_of_RPR
);
fprintf
(
fp
,
"number of records per req: %u
\n
"
,
g_args
.
num_of_RPR
);
fprintf
(
fp
,
"max sql length: %"
PRIu64
"
\n
"
,
g_args
.
max_sql_len
);
fprintf
(
fp
,
"max sql length: %"
PRIu64
"
\n
"
,
g_args
.
max_sql_len
);
fprintf
(
fp
,
"database count: %d
\n
"
,
g_Dbs
.
dbCount
);
fprintf
(
fp
,
"database count: %d
\n
"
,
g_Dbs
.
dbCount
);
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
fprintf
(
fp
,
"database[%d]:
\n
"
,
i
);
fprintf
(
fp
,
"database[%d]:
\n
"
,
i
);
fprintf
(
fp
,
" database[%d] name: %s
\n
"
,
i
,
g_Dbs
.
db
[
i
].
dbName
);
fprintf
(
fp
,
" database[%d] name: %s
\n
"
,
i
,
g_Dbs
.
db
[
i
].
dbName
);
if
(
0
==
g_Dbs
.
db
[
i
].
drop
)
{
if
(
0
==
g_Dbs
.
db
[
i
].
drop
)
{
fprintf
(
fp
,
" drop: no
\n
"
);
fprintf
(
fp
,
" drop: no
\n
"
);
}
else
{
}
else
{
fprintf
(
fp
,
" drop: yes
\n
"
);
fprintf
(
fp
,
" drop: yes
\n
"
);
}
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
blocks
>
0
)
{
fprintf
(
fp
,
" blocks: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
blocks
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
cache
>
0
)
{
fprintf
(
fp
,
" cache: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
cache
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
days
>
0
)
{
fprintf
(
fp
,
" days: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
days
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
keep
>
0
)
{
fprintf
(
fp
,
" keep: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
keep
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
replica
>
0
)
{
fprintf
(
fp
,
" replica: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
replica
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
update
>
0
)
{
fprintf
(
fp
,
" update: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
update
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
minRows
>
0
)
{
fprintf
(
fp
,
" minRows: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
minRows
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
maxRows
>
0
)
{
fprintf
(
fp
,
" maxRows: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
maxRows
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
comp
>
0
)
{
fprintf
(
fp
,
" comp: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
comp
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
walLevel
>
0
)
{
fprintf
(
fp
,
" walLevel: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
walLevel
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
fsync
>
0
)
{
fprintf
(
fp
,
" fsync: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
fsync
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
quorum
>
0
)
{
fprintf
(
fp
,
" quorum: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
quorum
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
[
0
]
!=
0
)
{
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
"ms"
,
2
))
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
"us"
,
2
)))
{
fprintf
(
fp
,
" precision: %s
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
precision
);
}
else
{
fprintf
(
fp
,
" precision error: %s
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
precision
);
}
}
fprintf
(
fp
,
" super table count: %"
PRIu64
"
\n
"
,
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
blocks
>
0
)
{
g_Dbs
.
db
[
i
].
superTblCount
);
fprintf
(
fp
,
" blocks: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
blocks
);
for
(
int
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
}
fprintf
(
fp
,
" super table[%d]:
\n
"
,
j
);
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
cache
>
0
)
{
fprintf
(
fp
,
" cache: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
cache
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
days
>
0
)
{
fprintf
(
fp
,
" days: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
days
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
keep
>
0
)
{
fprintf
(
fp
,
" keep: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
keep
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
replica
>
0
)
{
fprintf
(
fp
,
" replica: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
replica
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
update
>
0
)
{
fprintf
(
fp
,
" update: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
update
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
minRows
>
0
)
{
fprintf
(
fp
,
" minRows: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
minRows
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
maxRows
>
0
)
{
fprintf
(
fp
,
" maxRows: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
maxRows
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
comp
>
0
)
{
fprintf
(
fp
,
" comp: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
comp
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
walLevel
>
0
)
{
fprintf
(
fp
,
" walLevel: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
walLevel
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
fsync
>
0
)
{
fprintf
(
fp
,
" fsync: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
fsync
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
quorum
>
0
)
{
fprintf
(
fp
,
" quorum: %d
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
quorum
);
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
[
0
]
!=
0
)
{
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
"ms"
,
2
))
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
"us"
,
2
)))
{
fprintf
(
fp
,
" precision: %s
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
precision
);
}
else
{
fprintf
(
fp
,
" precision error: %s
\n
"
,
g_Dbs
.
db
[
i
].
dbCfg
.
precision
);
}
}
fprintf
(
fp
,
" stbName: %s
\n
"
,
fprintf
(
fp
,
" super table count: %"
PRIu64
"
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sTblName
);
g_Dbs
.
db
[
i
].
superTblCount
);
for
(
int
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
fprintf
(
fp
,
" super table[%d]:
\n
"
,
j
);
if
(
PRE_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
fprintf
(
fp
,
" stbName: %s
\n
"
,
fprintf
(
fp
,
" autoCreateTable: %s
\n
"
,
"no"
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sTblName
);
}
else
if
(
AUTO_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
fprintf
(
fp
,
" autoCreateTable: %s
\n
"
,
"yes"
);
}
else
{
fprintf
(
fp
,
" autoCreateTable: %s
\n
"
,
"error"
);
}
if
(
TBL_NO_EXISTS
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblExists
)
{
if
(
PRE_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
fprintf
(
fp
,
" childTblExists:
%s
\n
"
,
"no"
);
fprintf
(
fp
,
" autoCreateTable:
%s
\n
"
,
"no"
);
}
else
if
(
TBL_ALREADY_EXISTS
}
else
if
(
AUTO_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblExists
)
{
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
fprintf
(
fp
,
" childTblExists:
%s
\n
"
,
"yes"
);
fprintf
(
fp
,
" autoCreateTable:
%s
\n
"
,
"yes"
);
}
else
{
}
else
{
fprintf
(
fp
,
" childTblExists:
%s
\n
"
,
"error"
);
fprintf
(
fp
,
" autoCreateTable:
%s
\n
"
,
"error"
);
}
}
fprintf
(
fp
,
" childTblCount: %"
PRId64
"
\n
"
,
if
(
TBL_NO_EXISTS
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblExists
)
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblCount
);
fprintf
(
fp
,
" childTblExists: %s
\n
"
,
"no"
);
fprintf
(
fp
,
" childTblPrefix: %s
\n
"
,
}
else
if
(
TBL_ALREADY_EXISTS
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblPrefix
);
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblExists
)
{
fprintf
(
fp
,
" dataSource: %s
\n
"
,
fprintf
(
fp
,
" childTblExists: %s
\n
"
,
"yes"
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
dataSource
);
}
else
{
fprintf
(
fp
,
" iface: %s
\n
"
,
fprintf
(
fp
,
" childTblExists: %s
\n
"
,
"error"
);
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
TAOSC_IFACE
)
?
"taosc"
:
}
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
REST_IFACE
)
?
"rest"
:
"stmt"
);
fprintf
(
fp
,
" insertRows: %"
PRId64
"
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
insertRows
);
fprintf
(
fp
,
" interlace rows: %u
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
interlaceRows
);
if
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
interlaceRows
>
0
)
{
fprintf
(
fp
,
" stable insert interval: %"
PRIu64
"
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
insertInterval
);
}
/*
if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) {
fprintf(fp, " multiThreadWriteOneTbl: no\n");
}else {
fprintf(fp, " multiThreadWriteOneTbl: yes\n");
}
*/
fprintf
(
fp
,
" interlaceRows: %u
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
interlaceRows
);
fprintf
(
fp
,
" disorderRange: %d
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
disorderRange
);
fprintf
(
fp
,
" disorderRatio: %d
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
disorderRatio
);
fprintf
(
fp
,
" maxSqlLen: %"
PRIu64
"
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
maxSqlLen
);
fprintf
(
fp
,
" timeStampStep: %"
PRId64
"
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
timeStampStep
);
fprintf
(
fp
,
" startTimestamp: %s
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
startTimestamp
);
fprintf
(
fp
,
" sampleFormat: %s
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleFormat
);
fprintf
(
fp
,
" sampleFile: %s
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleFile
);
fprintf
(
fp
,
" tagsFile: %s
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagsFile
);
fprintf
(
fp
,
" columnCount: %d
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columnCount
);
for
(
int
k
=
0
;
k
<
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columnCount
;
k
++
)
{
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].columns[k].dataType, g_Dbs.db[i].superTbls[j].columns[k].dataLen);
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
,
"binary"
,
strlen
(
"binary"
)))
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
,
"nchar"
,
strlen
(
"nchar"
))))
{
fprintf
(
fp
,
"column[%d]:%s(%d) "
,
k
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataLen
);
}
else
{
fprintf
(
fp
,
"column[%d]:%s "
,
k
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
);
}
}
fprintf
(
fp
,
"
\n
"
);
fprintf
(
fp
,
" tagCount: %d
\n
"
,
fprintf
(
fp
,
" childTblCount: %"
PRId64
"
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagCount
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblCount
);
for
(
int
k
=
0
;
k
<
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagCount
;
k
++
)
{
fprintf
(
fp
,
" childTblPrefix: %s
\n
"
,
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].tags[k].dataType, g_Dbs.db[i].superTbls[j].tags[k].dataLen);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblPrefix
);
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
,
fprintf
(
fp
,
" dataSource: %s
\n
"
,
"binary"
,
strlen
(
"binary"
)))
g_Dbs
.
db
[
i
].
superTbls
[
j
].
dataSource
);
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
,
fprintf
(
fp
,
" iface: %s
\n
"
,
"nchar"
,
strlen
(
"nchar"
))))
{
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
TAOSC_IFACE
)
?
"taosc"
:
fprintf
(
fp
,
"tag[%d]:%s(%d) "
,
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
REST_IFACE
)
?
"rest"
:
"stmt"
);
k
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
,
fprintf
(
fp
,
" insertRows: %"
PRId64
"
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataLen
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
insertRows
);
}
else
{
fprintf
(
fp
,
" interlace rows: %u
\n
"
,
fprintf
(
fp
,
"tag[%d]:%s "
,
k
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
interlaceRows
);
if
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
interlaceRows
>
0
)
{
fprintf
(
fp
,
" stable insert interval: %"
PRIu64
"
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
insertInterval
);
}
/*
if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) {
fprintf(fp, " multiThreadWriteOneTbl: no\n");
}else {
fprintf(fp, " multiThreadWriteOneTbl: yes\n");
}
*/
fprintf
(
fp
,
" interlaceRows: %u
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
interlaceRows
);
fprintf
(
fp
,
" disorderRange: %d
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
disorderRange
);
fprintf
(
fp
,
" disorderRatio: %d
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
disorderRatio
);
fprintf
(
fp
,
" maxSqlLen: %"
PRIu64
"
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
maxSqlLen
);
fprintf
(
fp
,
" timeStampStep: %"
PRId64
"
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
timeStampStep
);
fprintf
(
fp
,
" startTimestamp: %s
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
startTimestamp
);
fprintf
(
fp
,
" sampleFormat: %s
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleFormat
);
fprintf
(
fp
,
" sampleFile: %s
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleFile
);
fprintf
(
fp
,
" tagsFile: %s
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagsFile
);
fprintf
(
fp
,
" columnCount: %d
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columnCount
);
for
(
int
k
=
0
;
k
<
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columnCount
;
k
++
)
{
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].columns[k].dataType, g_Dbs.db[i].superTbls[j].columns[k].dataLen);
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
,
"binary"
,
strlen
(
"binary"
)))
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
,
"nchar"
,
strlen
(
"nchar"
))))
{
fprintf
(
fp
,
"column[%d]:%s(%d) "
,
k
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataLen
);
}
else
{
fprintf
(
fp
,
"column[%d]:%s "
,
k
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
);
}
}
fprintf
(
fp
,
"
\n
"
);
fprintf
(
fp
,
" tagCount: %d
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagCount
);
for
(
int
k
=
0
;
k
<
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagCount
;
k
++
)
{
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].tags[k].dataType, g_Dbs.db[i].superTbls[j].tags[k].dataLen);
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
,
"binary"
,
strlen
(
"binary"
)))
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
,
"nchar"
,
strlen
(
"nchar"
))))
{
fprintf
(
fp
,
"tag[%d]:%s(%d) "
,
k
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataLen
);
}
else
{
fprintf
(
fp
,
"tag[%d]:%s "
,
k
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tags
[
k
].
dataType
);
}
}
fprintf
(
fp
,
"
\n
"
);
}
}
}
fprintf
(
fp
,
"
\n
"
);
fprintf
(
fp
,
"
\n
"
);
}
}
fprintf
(
fp
,
"
\n
"
);
}
SHOW_PARSE_RESULT_END_TO_FILE
(
fp
);
SHOW_PARSE_RESULT_END_TO_FILE
(
fp
);
}
}
static
void
printfQueryMeta
()
{
static
void
printfQueryMeta
()
{
SHOW_PARSE_RESULT_START
();
SHOW_PARSE_RESULT_START
();
printf
(
"host:
\033
[33m%s:%u
\033
[0m
\n
"
,
printf
(
"host:
\033
[33m%s:%u
\033
[0m
\n
"
,
g_queryInfo
.
host
,
g_queryInfo
.
port
);
g_queryInfo
.
host
,
g_queryInfo
.
port
);
printf
(
"user:
\033
[33m%s
\033
[0m
\n
"
,
g_queryInfo
.
user
);
printf
(
"user:
\033
[33m%s
\033
[0m
\n
"
,
g_queryInfo
.
user
);
printf
(
"database name:
\033
[33m%s
\033
[0m
\n
"
,
g_queryInfo
.
dbName
);
printf
(
"database name:
\033
[33m%s
\033
[0m
\n
"
,
g_queryInfo
.
dbName
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
if
((
SUBSCRIBE_TEST
==
g_args
.
test_mode
)
||
(
QUERY_TEST
==
g_args
.
test_mode
))
{
if
((
SUBSCRIBE_TEST
==
g_args
.
test_mode
)
||
(
QUERY_TEST
==
g_args
.
test_mode
))
{
printf
(
"specified table query info:
\n
"
);
printf
(
"specified table query info:
\n
"
);
printf
(
"sqlCount:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"sqlCount:
\033
[33m%d
\033
[0m
\n
"
,
g_queryInfo
.
specifiedQueryInfo
.
sqlCount
);
g_queryInfo
.
specifiedQueryInfo
.
sqlCount
);
if
(
g_queryInfo
.
specifiedQueryInfo
.
sqlCount
>
0
)
{
if
(
g_queryInfo
.
specifiedQueryInfo
.
sqlCount
>
0
)
{
printf
(
"specified tbl query times:
\n
"
);
printf
(
"specified tbl query times:
\n
"
);
printf
(
"
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
printf
(
"
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_queryInfo
.
specifiedQueryInfo
.
queryTimes
);
g_queryInfo
.
specifiedQueryInfo
.
queryTimes
);
printf
(
"query interval:
\033
[33m%"
PRIu64
" ms
\033
[0m
\n
"
,
printf
(
"query interval:
\033
[33m%"
PRIu64
" ms
\033
[0m
\n
"
,
g_queryInfo
.
specifiedQueryInfo
.
queryInterval
);
g_queryInfo
.
specifiedQueryInfo
.
queryInterval
);
printf
(
"top query times:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_args
.
query_times
);
printf
(
"top query times:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_args
.
query_times
);
printf
(
"concurrent:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"concurrent:
\033
[33m%d
\033
[0m
\n
"
,
g_queryInfo
.
specifiedQueryInfo
.
concurrent
);
g_queryInfo
.
specifiedQueryInfo
.
concurrent
);
printf
(
"mod:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
"mod:
\033
[33m%s
\033
[0m
\n
"
,
(
g_queryInfo
.
specifiedQueryInfo
.
asyncMode
)
?
"async"
:
"sync"
);
(
g_queryInfo
.
specifiedQueryInfo
.
asyncMode
)
?
"async"
:
"sync"
);
printf
(
"interval:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
printf
(
"interval:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_queryInfo
.
specifiedQueryInfo
.
subscribeInterval
);
g_queryInfo
.
specifiedQueryInfo
.
subscribeInterval
);
printf
(
"restart:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"restart:
\033
[33m%d
\033
[0m
\n
"
,
g_queryInfo
.
specifiedQueryInfo
.
subscribeRestart
);
g_queryInfo
.
specifiedQueryInfo
.
subscribeRestart
);
printf
(
"keepProgress:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"keepProgress:
\033
[33m%d
\033
[0m
\n
"
,
g_queryInfo
.
specifiedQueryInfo
.
subscribeKeepProgress
);
g_queryInfo
.
specifiedQueryInfo
.
subscribeKeepProgress
);
for
(
int
i
=
0
;
i
<
g_queryInfo
.
specifiedQueryInfo
.
sqlCount
;
i
++
)
{
for
(
int
i
=
0
;
i
<
g_queryInfo
.
specifiedQueryInfo
.
sqlCount
;
i
++
)
{
printf
(
" sql[%d]:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
" sql[%d]:
\033
[33m%s
\033
[0m
\n
"
,
i
,
g_queryInfo
.
specifiedQueryInfo
.
sql
[
i
]);
i
,
g_queryInfo
.
specifiedQueryInfo
.
sql
[
i
]);
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
printf
(
"super table query info:
\n
"
);
printf
(
"super table query info:
\n
"
);
printf
(
"sqlCount:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"sqlCount:
\033
[33m%d
\033
[0m
\n
"
,
g_queryInfo
.
superQueryInfo
.
sqlCount
);
g_queryInfo
.
superQueryInfo
.
sqlCount
);
if
(
g_queryInfo
.
superQueryInfo
.
sqlCount
>
0
)
{
if
(
g_queryInfo
.
superQueryInfo
.
sqlCount
>
0
)
{
printf
(
"query interval:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
printf
(
"query interval:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_queryInfo
.
superQueryInfo
.
queryInterval
);
g_queryInfo
.
superQueryInfo
.
queryInterval
);
printf
(
"threadCnt:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"threadCnt:
\033
[33m%d
\033
[0m
\n
"
,
g_queryInfo
.
superQueryInfo
.
threadCnt
);
g_queryInfo
.
superQueryInfo
.
threadCnt
);
printf
(
"childTblCount:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
printf
(
"childTblCount:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
g_queryInfo
.
superQueryInfo
.
childTblCount
);
g_queryInfo
.
superQueryInfo
.
childTblCount
);
printf
(
"stable name:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
"stable name:
\033
[33m%s
\033
[0m
\n
"
,
g_queryInfo
.
superQueryInfo
.
sTblName
);
g_queryInfo
.
superQueryInfo
.
sTblName
);
printf
(
"stb query times:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
printf
(
"stb query times:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_queryInfo
.
superQueryInfo
.
queryTimes
);
g_queryInfo
.
superQueryInfo
.
queryTimes
);
printf
(
"mod:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
"mod:
\033
[33m%s
\033
[0m
\n
"
,
(
g_queryInfo
.
superQueryInfo
.
asyncMode
)
?
"async"
:
"sync"
);
(
g_queryInfo
.
superQueryInfo
.
asyncMode
)
?
"async"
:
"sync"
);
printf
(
"interval:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
printf
(
"interval:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_queryInfo
.
superQueryInfo
.
subscribeInterval
);
g_queryInfo
.
superQueryInfo
.
subscribeInterval
);
printf
(
"restart:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"restart:
\033
[33m%d
\033
[0m
\n
"
,
g_queryInfo
.
superQueryInfo
.
subscribeRestart
);
g_queryInfo
.
superQueryInfo
.
subscribeRestart
);
printf
(
"keepProgress:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"keepProgress:
\033
[33m%d
\033
[0m
\n
"
,
g_queryInfo
.
superQueryInfo
.
subscribeKeepProgress
);
g_queryInfo
.
superQueryInfo
.
subscribeKeepProgress
);
for
(
int
i
=
0
;
i
<
g_queryInfo
.
superQueryInfo
.
sqlCount
;
i
++
)
{
for
(
int
i
=
0
;
i
<
g_queryInfo
.
superQueryInfo
.
sqlCount
;
i
++
)
{
printf
(
" sql[%d]:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
" sql[%d]:
\033
[33m%s
\033
[0m
\n
"
,
i
,
g_queryInfo
.
superQueryInfo
.
sql
[
i
]);
i
,
g_queryInfo
.
superQueryInfo
.
sql
[
i
]);
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
}
}
SHOW_PARSE_RESULT_END
();
SHOW_PARSE_RESULT_END
();
}
}
static
char
*
formatTimestamp
(
char
*
buf
,
int64_t
val
,
int
precision
)
{
static
char
*
formatTimestamp
(
char
*
buf
,
int64_t
val
,
int
precision
)
{
time_t
tt
;
time_t
tt
;
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
tt
=
(
time_t
)(
val
/
1000000000
);
tt
=
(
time_t
)(
val
/
1000000000
);
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
tt
=
(
time_t
)(
val
/
1000000
);
tt
=
(
time_t
)(
val
/
1000000
);
}
else
{
}
else
{
tt
=
(
time_t
)(
val
/
1000
);
tt
=
(
time_t
)(
val
/
1000
);
}
}
/* comment out as it make testcases like select_with_tags.sim fail.
/* comment out as it make testcases like select_with_tags.sim fail.
but in windows, this may cause the call to localtime crash if tt < 0,
but in windows, this may cause the call to localtime crash if tt < 0,
need to find a better solution.
need to find a better solution.
if (tt < 0) {
if (tt < 0) {
tt = 0;
tt = 0;
}
}
*/
*/
#ifdef WINDOWS
#ifdef WINDOWS
if
(
tt
<
0
)
tt
=
0
;
if
(
tt
<
0
)
tt
=
0
;
#endif
#endif
struct
tm
*
ptm
=
localtime
(
&
tt
);
struct
tm
*
ptm
=
localtime
(
&
tt
);
size_t
pos
=
strftime
(
buf
,
32
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
size_t
pos
=
strftime
(
buf
,
32
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
sprintf
(
buf
+
pos
,
".%09d"
,
(
int
)(
val
%
1000000000
));
sprintf
(
buf
+
pos
,
".%09d"
,
(
int
)(
val
%
1000000000
));
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
sprintf
(
buf
+
pos
,
".%06d"
,
(
int
)(
val
%
1000000
));
sprintf
(
buf
+
pos
,
".%06d"
,
(
int
)(
val
%
1000000
));
}
else
{
}
else
{
sprintf
(
buf
+
pos
,
".%03d"
,
(
int
)(
val
%
1000
));
sprintf
(
buf
+
pos
,
".%03d"
,
(
int
)(
val
%
1000
));
}
}
return
buf
;
return
buf
;
}
}
static
void
xDumpFieldToFile
(
FILE
*
fp
,
const
char
*
val
,
static
void
xDumpFieldToFile
(
FILE
*
fp
,
const
char
*
val
,
TAOS_FIELD
*
field
,
int32_t
length
,
int
precision
)
{
TAOS_FIELD
*
field
,
int32_t
length
,
int
precision
)
{
if
(
val
==
NULL
)
{
if
(
val
==
NULL
)
{
fprintf
(
fp
,
"%s"
,
TSDB_DATA_NULL_STR
);
fprintf
(
fp
,
"%s"
,
TSDB_DATA_NULL_STR
);
return
;
return
;
}
}
char
buf
[
TSDB_MAX_BYTES_PER_ROW
];
char
buf
[
TSDB_MAX_BYTES_PER_ROW
];
switch
(
field
->
type
)
{
switch
(
field
->
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
fprintf
(
fp
,
"%d"
,
((((
int32_t
)(
*
((
char
*
)
val
)))
==
1
)
?
1
:
0
));
fprintf
(
fp
,
"%d"
,
((((
int32_t
)(
*
((
char
*
)
val
)))
==
1
)
?
1
:
0
));
break
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_TINYINT
:
fprintf
(
fp
,
"%d"
,
*
((
int8_t
*
)
val
));
fprintf
(
fp
,
"%d"
,
*
((
int8_t
*
)
val
));
break
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
fprintf
(
fp
,
"%d"
,
*
((
int16_t
*
)
val
));
fprintf
(
fp
,
"%d"
,
*
((
int16_t
*
)
val
));
break
;
break
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_INT
:
fprintf
(
fp
,
"%d"
,
*
((
int32_t
*
)
val
));
fprintf
(
fp
,
"%d"
,
*
((
int32_t
*
)
val
));
break
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_BIGINT
:
fprintf
(
fp
,
"%"
PRId64
,
*
((
int64_t
*
)
val
));
fprintf
(
fp
,
"%"
PRId64
,
*
((
int64_t
*
)
val
));
break
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_FLOAT
:
fprintf
(
fp
,
"%.5f"
,
GET_FLOAT_VAL
(
val
));
fprintf
(
fp
,
"%.5f"
,
GET_FLOAT_VAL
(
val
));
break
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_DOUBLE
:
fprintf
(
fp
,
"%.9f"
,
GET_DOUBLE_VAL
(
val
));
fprintf
(
fp
,
"%.9f"
,
GET_DOUBLE_VAL
(
val
));
break
;
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
memcpy
(
buf
,
val
,
length
);
memcpy
(
buf
,
val
,
length
);
buf
[
length
]
=
0
;
buf
[
length
]
=
0
;
fprintf
(
fp
,
"
\'
%s
\'
"
,
buf
);
fprintf
(
fp
,
"
\'
%s
\'
"
,
buf
);
break
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
formatTimestamp
(
buf
,
*
(
int64_t
*
)
val
,
precision
);
formatTimestamp
(
buf
,
*
(
int64_t
*
)
val
,
precision
);
fprintf
(
fp
,
"'%s'"
,
buf
);
fprintf
(
fp
,
"'%s'"
,
buf
);
break
;
break
;
default:
default:
break
;
break
;
}
}
}
}
static
int
xDumpResultToFile
(
const
char
*
fname
,
TAOS_RES
*
tres
)
{
static
int
xDumpResultToFile
(
const
char
*
fname
,
TAOS_RES
*
tres
)
{
TAOS_ROW
row
=
taos_fetch_row
(
tres
);
TAOS_ROW
row
=
taos_fetch_row
(
tres
);
if
(
row
==
NULL
)
{
if
(
row
==
NULL
)
{
return
0
;
return
0
;
}
}
FILE
*
fp
=
fopen
(
fname
,
"at"
);
if
(
fp
==
NULL
)
{
errorPrint
(
"%s() LN%d, failed to open file: %s
\n
"
,
__func__
,
__LINE__
,
fname
);
return
-
1
;
}
int
num_fields
=
taos_num_fields
(
tres
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
tres
);
int
precision
=
taos_result_precision
(
tres
);
for
(
int
col
=
0
;
col
<
num_fields
;
col
++
)
{
FILE
*
fp
=
fopen
(
fname
,
"at"
);
if
(
col
>
0
)
{
if
(
fp
==
NULL
)
{
fprintf
(
fp
,
","
);
errorPrint
(
"%s() LN%d, failed to open file: %s
\n
"
,
__func__
,
__LINE__
,
fname
);
return
-
1
;
}
}
fprintf
(
fp
,
"%s"
,
fields
[
col
].
name
);
}
fputc
(
'\n'
,
fp
);
int
numOfRows
=
0
;
int
num_fields
=
taos_num_fields
(
tres
);
do
{
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
tres
);
int32_t
*
length
=
taos_fetch_lengths
(
tres
);
int
precision
=
taos_result_precision
(
tres
);
for
(
int
i
=
0
;
i
<
num_fields
;
i
++
)
{
if
(
i
>
0
)
{
for
(
int
col
=
0
;
col
<
num_fields
;
col
++
)
{
fputc
(
','
,
fp
);
if
(
col
>
0
)
{
}
fprintf
(
fp
,
","
);
xDumpFieldToFile
(
fp
,
(
const
char
*
)
row
[
i
],
fields
+
i
,
length
[
i
],
precision
);
}
fprintf
(
fp
,
"%s"
,
fields
[
col
].
name
);
}
}
fputc
(
'\n'
,
fp
);
fputc
(
'\n'
,
fp
);
numOfRows
++
;
int
numOfRows
=
0
;
row
=
taos_fetch_row
(
tres
);
do
{
}
while
(
row
!=
NULL
);
int32_t
*
length
=
taos_fetch_lengths
(
tres
);
for
(
int
i
=
0
;
i
<
num_fields
;
i
++
)
{
if
(
i
>
0
)
{
fputc
(
','
,
fp
);
}
xDumpFieldToFile
(
fp
,
(
const
char
*
)
row
[
i
],
fields
+
i
,
length
[
i
],
precision
);
}
fputc
(
'\n'
,
fp
);
numOfRows
++
;
row
=
taos_fetch_row
(
tres
);
}
while
(
row
!=
NULL
);
fclose
(
fp
);
fclose
(
fp
);
return
numOfRows
;
return
numOfRows
;
}
}
static
int
getDbFromServer
(
TAOS
*
taos
,
SDbInfo
**
dbInfos
)
{
static
int
getDbFromServer
(
TAOS
*
taos
,
SDbInfo
**
dbInfos
)
{
TAOS_RES
*
res
;
TAOS_RES
*
res
;
TAOS_ROW
row
=
NULL
;
TAOS_ROW
row
=
NULL
;
int
count
=
0
;
int
count
=
0
;
res
=
taos_query
(
taos
,
"show databases;"
);
res
=
taos_query
(
taos
,
"show databases;"
);
int32_t
code
=
taos_errno
(
res
);
int32_t
code
=
taos_errno
(
res
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
errorPrint
(
"failed to run <show databases>, reason: %s
\n
"
,
taos_errstr
(
res
));
errorPrint
(
"failed to run <show databases>, reason: %s
\n
"
,
return
-
1
;
taos_errstr
(
res
));
}
return
-
1
;
}
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
res
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
res
);
while
((
row
=
taos_fetch_row
(
res
))
!=
NULL
)
{
while
((
row
=
taos_fetch_row
(
res
))
!=
NULL
)
{
// sys database name : 'log'
// sys database name : 'log'
if
(
strncasecmp
(
row
[
TSDB_SHOW_DB_NAME_INDEX
],
"log"
,
if
(
strncasecmp
(
row
[
TSDB_SHOW_DB_NAME_INDEX
],
"log"
,
fields
[
TSDB_SHOW_DB_NAME_INDEX
].
bytes
)
==
0
)
{
fields
[
TSDB_SHOW_DB_NAME_INDEX
].
bytes
)
==
0
)
{
continue
;
continue
;
}
}
dbInfos
[
count
]
=
(
SDbInfo
*
)
calloc
(
1
,
sizeof
(
SDbInfo
));
dbInfos
[
count
]
=
(
SDbInfo
*
)
calloc
(
1
,
sizeof
(
SDbInfo
));
if
(
dbInfos
[
count
]
==
NULL
)
{
if
(
dbInfos
[
count
]
==
NULL
)
{
errorPrint
(
"failed to allocate memory for some dbInfo[%d]
\n
"
,
count
);
errorPrint
(
"failed to allocate memory for some dbInfo[%d]
\n
"
,
count
);
return
-
1
;
return
-
1
;
}
}
tstrncpy
(
dbInfos
[
count
]
->
name
,
(
char
*
)
row
[
TSDB_SHOW_DB_NAME_INDEX
],
tstrncpy
(
dbInfos
[
count
]
->
name
,
(
char
*
)
row
[
TSDB_SHOW_DB_NAME_INDEX
],
fields
[
TSDB_SHOW_DB_NAME_INDEX
].
bytes
);
fields
[
TSDB_SHOW_DB_NAME_INDEX
].
bytes
);
formatTimestamp
(
dbInfos
[
count
]
->
create_time
,
formatTimestamp
(
dbInfos
[
count
]
->
create_time
,
*
(
int64_t
*
)
row
[
TSDB_SHOW_DB_CREATED_TIME_INDEX
],
*
(
int64_t
*
)
row
[
TSDB_SHOW_DB_CREATED_TIME_INDEX
],
TSDB_TIME_PRECISION_MILLI
);
TSDB_TIME_PRECISION_MILLI
);
dbInfos
[
count
]
->
ntables
=
*
((
int64_t
*
)
row
[
TSDB_SHOW_DB_NTABLES_INDEX
]);
dbInfos
[
count
]
->
ntables
=
*
((
int64_t
*
)
row
[
TSDB_SHOW_DB_NTABLES_INDEX
]);
dbInfos
[
count
]
->
vgroups
=
*
((
int32_t
*
)
row
[
TSDB_SHOW_DB_VGROUPS_INDEX
]);
dbInfos
[
count
]
->
vgroups
=
*
((
int32_t
*
)
row
[
TSDB_SHOW_DB_VGROUPS_INDEX
]);
dbInfos
[
count
]
->
replica
=
*
((
int16_t
*
)
row
[
TSDB_SHOW_DB_REPLICA_INDEX
]);
dbInfos
[
count
]
->
replica
=
*
((
int16_t
*
)
row
[
TSDB_SHOW_DB_REPLICA_INDEX
]);
dbInfos
[
count
]
->
quorum
=
*
((
int16_t
*
)
row
[
TSDB_SHOW_DB_QUORUM_INDEX
]);
dbInfos
[
count
]
->
quorum
=
*
((
int16_t
*
)
row
[
TSDB_SHOW_DB_QUORUM_INDEX
]);
dbInfos
[
count
]
->
days
=
*
((
int16_t
*
)
row
[
TSDB_SHOW_DB_DAYS_INDEX
]);
dbInfos
[
count
]
->
days
=
*
((
int16_t
*
)
row
[
TSDB_SHOW_DB_DAYS_INDEX
]);
tstrncpy
(
dbInfos
[
count
]
->
keeplist
,
(
char
*
)
row
[
TSDB_SHOW_DB_KEEP_INDEX
],
tstrncpy
(
dbInfos
[
count
]
->
keeplist
,
(
char
*
)
row
[
TSDB_SHOW_DB_KEEP_INDEX
],
fields
[
TSDB_SHOW_DB_KEEP_INDEX
].
bytes
);
fields
[
TSDB_SHOW_DB_KEEP_INDEX
].
bytes
);
dbInfos
[
count
]
->
cache
=
*
((
int32_t
*
)
row
[
TSDB_SHOW_DB_CACHE_INDEX
]);
dbInfos
[
count
]
->
cache
=
*
((
int32_t
*
)
row
[
TSDB_SHOW_DB_CACHE_INDEX
]);
dbInfos
[
count
]
->
blocks
=
*
((
int32_t
*
)
row
[
TSDB_SHOW_DB_BLOCKS_INDEX
]);
dbInfos
[
count
]
->
blocks
=
*
((
int32_t
*
)
row
[
TSDB_SHOW_DB_BLOCKS_INDEX
]);
dbInfos
[
count
]
->
minrows
=
*
((
int32_t
*
)
row
[
TSDB_SHOW_DB_MINROWS_INDEX
]);
dbInfos
[
count
]
->
minrows
=
*
((
int32_t
*
)
row
[
TSDB_SHOW_DB_MINROWS_INDEX
]);
dbInfos
[
count
]
->
maxrows
=
*
((
int32_t
*
)
row
[
TSDB_SHOW_DB_MAXROWS_INDEX
]);
dbInfos
[
count
]
->
maxrows
=
*
((
int32_t
*
)
row
[
TSDB_SHOW_DB_MAXROWS_INDEX
]);
dbInfos
[
count
]
->
wallevel
=
*
((
int8_t
*
)
row
[
TSDB_SHOW_DB_WALLEVEL_INDEX
]);
dbInfos
[
count
]
->
wallevel
=
*
((
int8_t
*
)
row
[
TSDB_SHOW_DB_WALLEVEL_INDEX
]);
dbInfos
[
count
]
->
fsync
=
*
((
int32_t
*
)
row
[
TSDB_SHOW_DB_FSYNC_INDEX
]);
dbInfos
[
count
]
->
fsync
=
*
((
int32_t
*
)
row
[
TSDB_SHOW_DB_FSYNC_INDEX
]);
dbInfos
[
count
]
->
comp
=
(
int8_t
)(
*
((
int8_t
*
)
row
[
TSDB_SHOW_DB_COMP_INDEX
]));
dbInfos
[
count
]
->
comp
=
(
int8_t
)(
*
((
int8_t
*
)
row
[
TSDB_SHOW_DB_COMP_INDEX
]));
dbInfos
[
count
]
->
cachelast
=
dbInfos
[
count
]
->
cachelast
=
(
int8_t
)(
*
((
int8_t
*
)
row
[
TSDB_SHOW_DB_CACHELAST_INDEX
]));
(
int8_t
)(
*
((
int8_t
*
)
row
[
TSDB_SHOW_DB_CACHELAST_INDEX
]));
tstrncpy
(
dbInfos
[
count
]
->
precision
,
tstrncpy
(
dbInfos
[
count
]
->
precision
,
(
char
*
)
row
[
TSDB_SHOW_DB_PRECISION_INDEX
],
(
char
*
)
row
[
TSDB_SHOW_DB_PRECISION_INDEX
],
fields
[
TSDB_SHOW_DB_PRECISION_INDEX
].
bytes
);
fields
[
TSDB_SHOW_DB_PRECISION_INDEX
].
bytes
);
dbInfos
[
count
]
->
update
=
*
((
int8_t
*
)
row
[
TSDB_SHOW_DB_UPDATE_INDEX
]);
dbInfos
[
count
]
->
update
=
*
((
int8_t
*
)
row
[
TSDB_SHOW_DB_UPDATE_INDEX
]);
tstrncpy
(
dbInfos
[
count
]
->
status
,
(
char
*
)
row
[
TSDB_SHOW_DB_STATUS_INDEX
],
tstrncpy
(
dbInfos
[
count
]
->
status
,
(
char
*
)
row
[
TSDB_SHOW_DB_STATUS_INDEX
],
fields
[
TSDB_SHOW_DB_STATUS_INDEX
].
bytes
);
fields
[
TSDB_SHOW_DB_STATUS_INDEX
].
bytes
);
count
++
;
count
++
;
if
(
count
>
MAX_DATABASE_COUNT
)
{
if
(
count
>
MAX_DATABASE_COUNT
)
{
errorPrint
(
"%s() LN%d, The database count overflow than %d
\n
"
,
errorPrint
(
"%s() LN%d, The database count overflow than %d
\n
"
,
__func__
,
__LINE__
,
MAX_DATABASE_COUNT
);
__func__
,
__LINE__
,
MAX_DATABASE_COUNT
);
break
;
break
;
}
}
}
}
return
count
;
return
count
;
}
}
static
void
printfDbInfoForQueryToFile
(
static
void
printfDbInfoForQueryToFile
(
char
*
filename
,
SDbInfo
*
dbInfos
,
int
index
)
{
char
*
filename
,
SDbInfo
*
dbInfos
,
int
index
)
{
if
(
filename
[
0
]
==
0
)
if
(
filename
[
0
]
==
0
)
return
;
return
;
FILE
*
fp
=
fopen
(
filename
,
"at"
);
FILE
*
fp
=
fopen
(
filename
,
"at"
);
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
errorPrint
(
"failed to open file: %s
\n
"
,
filename
);
errorPrint
(
"failed to open file: %s
\n
"
,
filename
);
return
;
return
;
}
}
fprintf
(
fp
,
"================ database[%d] ================
\n
"
,
index
);
fprintf
(
fp
,
"================ database[%d] ================
\n
"
,
index
);
fprintf
(
fp
,
"name: %s
\n
"
,
dbInfos
->
name
);
fprintf
(
fp
,
"name: %s
\n
"
,
dbInfos
->
name
);
fprintf
(
fp
,
"created_time: %s
\n
"
,
dbInfos
->
create_time
);
fprintf
(
fp
,
"created_time: %s
\n
"
,
dbInfos
->
create_time
);
fprintf
(
fp
,
"ntables: %"
PRId64
"
\n
"
,
dbInfos
->
ntables
);
fprintf
(
fp
,
"ntables: %"
PRId64
"
\n
"
,
dbInfos
->
ntables
);
fprintf
(
fp
,
"vgroups: %d
\n
"
,
dbInfos
->
vgroups
);
fprintf
(
fp
,
"vgroups: %d
\n
"
,
dbInfos
->
vgroups
);
fprintf
(
fp
,
"replica: %d
\n
"
,
dbInfos
->
replica
);
fprintf
(
fp
,
"replica: %d
\n
"
,
dbInfos
->
replica
);
fprintf
(
fp
,
"quorum: %d
\n
"
,
dbInfos
->
quorum
);
fprintf
(
fp
,
"quorum: %d
\n
"
,
dbInfos
->
quorum
);
fprintf
(
fp
,
"days: %d
\n
"
,
dbInfos
->
days
);
fprintf
(
fp
,
"days: %d
\n
"
,
dbInfos
->
days
);
fprintf
(
fp
,
"keep0,keep1,keep(D): %s
\n
"
,
dbInfos
->
keeplist
);
fprintf
(
fp
,
"keep0,keep1,keep(D): %s
\n
"
,
dbInfos
->
keeplist
);
fprintf
(
fp
,
"cache(MB): %d
\n
"
,
dbInfos
->
cache
);
fprintf
(
fp
,
"cache(MB): %d
\n
"
,
dbInfos
->
cache
);
fprintf
(
fp
,
"blocks: %d
\n
"
,
dbInfos
->
blocks
);
fprintf
(
fp
,
"blocks: %d
\n
"
,
dbInfos
->
blocks
);
fprintf
(
fp
,
"minrows: %d
\n
"
,
dbInfos
->
minrows
);
fprintf
(
fp
,
"minrows: %d
\n
"
,
dbInfos
->
minrows
);
fprintf
(
fp
,
"maxrows: %d
\n
"
,
dbInfos
->
maxrows
);
fprintf
(
fp
,
"maxrows: %d
\n
"
,
dbInfos
->
maxrows
);
fprintf
(
fp
,
"wallevel: %d
\n
"
,
dbInfos
->
wallevel
);
fprintf
(
fp
,
"wallevel: %d
\n
"
,
dbInfos
->
wallevel
);
fprintf
(
fp
,
"fsync: %d
\n
"
,
dbInfos
->
fsync
);
fprintf
(
fp
,
"fsync: %d
\n
"
,
dbInfos
->
fsync
);
fprintf
(
fp
,
"comp: %d
\n
"
,
dbInfos
->
comp
);
fprintf
(
fp
,
"comp: %d
\n
"
,
dbInfos
->
comp
);
fprintf
(
fp
,
"cachelast: %d
\n
"
,
dbInfos
->
cachelast
);
fprintf
(
fp
,
"cachelast: %d
\n
"
,
dbInfos
->
cachelast
);
fprintf
(
fp
,
"precision: %s
\n
"
,
dbInfos
->
precision
);
fprintf
(
fp
,
"precision: %s
\n
"
,
dbInfos
->
precision
);
fprintf
(
fp
,
"update: %d
\n
"
,
dbInfos
->
update
);
fprintf
(
fp
,
"update: %d
\n
"
,
dbInfos
->
update
);
fprintf
(
fp
,
"status: %s
\n
"
,
dbInfos
->
status
);
fprintf
(
fp
,
"status: %s
\n
"
,
dbInfos
->
status
);
fprintf
(
fp
,
"
\n
"
);
fprintf
(
fp
,
"
\n
"
);
fclose
(
fp
);
fclose
(
fp
);
}
}
static
void
printfQuerySystemInfo
(
TAOS
*
taos
)
{
static
void
printfQuerySystemInfo
(
TAOS
*
taos
)
{
char
filename
[
MAX_QUERY_SQL_LENGTH
+
1
]
=
{
0
};
char
filename
[
MAX_QUERY_SQL_LENGTH
+
1
]
=
{
0
};
char
buffer
[
MAX_QUERY_SQL_LENGTH
+
1
]
=
{
0
};
char
buffer
[
MAX_QUERY_SQL_LENGTH
+
1
]
=
{
0
};
TAOS_RES
*
res
;
TAOS_RES
*
res
;
time_t
t
;
time_t
t
;
struct
tm
*
lt
;
struct
tm
*
lt
;
time
(
&
t
);
time
(
&
t
);
lt
=
localtime
(
&
t
);
lt
=
localtime
(
&
t
);
snprintf
(
filename
,
MAX_QUERY_SQL_LENGTH
,
"querySystemInfo-%d-%d-%d %d:%d:%d"
,
snprintf
(
filename
,
MAX_QUERY_SQL_LENGTH
,
"querySystemInfo-%d-%d-%d %d:%d:%d"
,
lt
->
tm_year
+
1900
,
lt
->
tm_mon
,
lt
->
tm_mday
,
lt
->
tm_hour
,
lt
->
tm_min
,
lt
->
tm_year
+
1900
,
lt
->
tm_mon
,
lt
->
tm_mday
,
lt
->
tm_hour
,
lt
->
tm_min
,
lt
->
tm_sec
);
lt
->
tm_sec
);
// show variables
// show variables
res
=
taos_query
(
taos
,
"show variables;"
);
res
=
taos_query
(
taos
,
"show variables;"
);
//fetchResult(res, filename);
//fetchResult(res, filename);
xDumpResultToFile
(
filename
,
res
);
// show dnodes
res
=
taos_query
(
taos
,
"show dnodes;"
);
xDumpResultToFile
(
filename
,
res
);
//fetchResult(res, filename);
// show databases
res
=
taos_query
(
taos
,
"show databases;"
);
SDbInfo
**
dbInfos
=
(
SDbInfo
**
)
calloc
(
MAX_DATABASE_COUNT
,
sizeof
(
SDbInfo
*
));
if
(
dbInfos
==
NULL
)
{
errorPrint
(
"%s() LN%d, failed to allocate memory
\n
"
,
__func__
,
__LINE__
);
return
;
}
int
dbCount
=
getDbFromServer
(
taos
,
dbInfos
);
if
(
dbCount
<=
0
)
{
free
(
dbInfos
);
return
;
}
for
(
int
i
=
0
;
i
<
dbCount
;
i
++
)
{
// printf database info
printfDbInfoForQueryToFile
(
filename
,
dbInfos
[
i
],
i
);
// show db.vgroups
snprintf
(
buffer
,
MAX_QUERY_SQL_LENGTH
,
"show %s.vgroups;"
,
dbInfos
[
i
]
->
name
);
res
=
taos_query
(
taos
,
buffer
);
xDumpResultToFile
(
filename
,
res
);
xDumpResultToFile
(
filename
,
res
);
// show db.stables
// show dnodes
snprintf
(
buffer
,
MAX_QUERY_SQL_LENGTH
,
"show %s.stables;"
,
dbInfos
[
i
]
->
name
);
res
=
taos_query
(
taos
,
"show dnodes;"
);
res
=
taos_query
(
taos
,
buffer
);
xDumpResultToFile
(
filename
,
res
);
xDumpResultToFile
(
filename
,
res
);
//fetchResult(res, filename);
free
(
dbInfos
[
i
]);
// show databases
}
res
=
taos_query
(
taos
,
"show databases;"
);
SDbInfo
**
dbInfos
=
(
SDbInfo
**
)
calloc
(
MAX_DATABASE_COUNT
,
sizeof
(
SDbInfo
*
));
if
(
dbInfos
==
NULL
)
{
errorPrint
(
"%s() LN%d, failed to allocate memory
\n
"
,
__func__
,
__LINE__
);
return
;
}
int
dbCount
=
getDbFromServer
(
taos
,
dbInfos
);
if
(
dbCount
<=
0
)
{
free
(
dbInfos
);
return
;
}
for
(
int
i
=
0
;
i
<
dbCount
;
i
++
)
{
// printf database info
printfDbInfoForQueryToFile
(
filename
,
dbInfos
[
i
],
i
);
free
(
dbInfos
);
// show db.vgroups
snprintf
(
buffer
,
MAX_QUERY_SQL_LENGTH
,
"show %s.vgroups;"
,
dbInfos
[
i
]
->
name
);
res
=
taos_query
(
taos
,
buffer
);
xDumpResultToFile
(
filename
,
res
);
// show db.stables
snprintf
(
buffer
,
MAX_QUERY_SQL_LENGTH
,
"show %s.stables;"
,
dbInfos
[
i
]
->
name
);
res
=
taos_query
(
taos
,
buffer
);
xDumpResultToFile
(
filename
,
res
);
free
(
dbInfos
[
i
]);
}
free
(
dbInfos
);
}
}
static
int
postProceSql
(
char
*
host
,
struct
sockaddr_in
*
pServAddr
,
uint16_t
port
,
static
int
postProceSql
(
char
*
host
,
struct
sockaddr_in
*
pServAddr
,
uint16_t
port
,
...
@@ -2294,98 +2335,100 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port
...
@@ -2294,98 +2335,100 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port
}
}
static
char
*
getTagValueFromTagSample
(
SSuperTable
*
stbInfo
,
int
tagUsePos
)
{
static
char
*
getTagValueFromTagSample
(
SSuperTable
*
stbInfo
,
int
tagUsePos
)
{
char
*
dataBuf
=
(
char
*
)
calloc
(
TSDB_MAX_SQL_LEN
+
1
,
1
);
char
*
dataBuf
=
(
char
*
)
calloc
(
TSDB_MAX_SQL_LEN
+
1
,
1
);
if
(
NULL
==
dataBuf
)
{
if
(
NULL
==
dataBuf
)
{
errorPrint
(
"%s() LN%d, calloc failed! size:%d
\n
"
,
errorPrint
(
"%s() LN%d, calloc failed! size:%d
\n
"
,
__func__
,
__LINE__
,
TSDB_MAX_SQL_LEN
+
1
);
__func__
,
__LINE__
,
TSDB_MAX_SQL_LEN
+
1
);
return
NULL
;
return
NULL
;
}
}
int
dataLen
=
0
;
int
dataLen
=
0
;
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
"(%s)"
,
stbInfo
->
tagDataBuf
+
stbInfo
->
lenOfTagOfOneRow
*
tagUsePos
);
"(%s)"
,
stbInfo
->
tagDataBuf
+
stbInfo
->
lenOfTagOfOneRow
*
tagUsePos
);
return
dataBuf
;
return
dataBuf
;
}
}
static
char
*
generateTagVaulesForStb
(
SSuperTable
*
stbInfo
,
int32_t
tableSeq
)
{
static
char
*
generateTagVaulesForStb
(
SSuperTable
*
stbInfo
,
int32_t
tableSeq
)
{
char
*
dataBuf
=
(
char
*
)
calloc
(
TSDB_MAX_SQL_LEN
+
1
,
1
);
char
*
dataBuf
=
(
char
*
)
calloc
(
TSDB_MAX_SQL_LEN
+
1
,
1
);
if
(
NULL
==
dataBuf
)
{
if
(
NULL
==
dataBuf
)
{
printf
(
"calloc failed! size:%d
\n
"
,
TSDB_MAX_SQL_LEN
+
1
);
printf
(
"calloc failed! size:%d
\n
"
,
TSDB_MAX_SQL_LEN
+
1
);
return
NULL
;
}
int
dataLen
=
0
;
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
"("
);
for
(
int
i
=
0
;
i
<
stbInfo
->
tagCount
;
i
++
)
{
if
((
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
"binary"
,
strlen
(
"binary"
)))
||
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
"nchar"
,
strlen
(
"nchar"
))))
{
if
(
stbInfo
->
tags
[
i
].
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
printf
(
"binary or nchar length overflow, max size:%u
\n
"
,
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
tmfree
(
dataBuf
);
return
NULL
;
return
NULL
;
}
}
int
tagBufLen
=
stbInfo
->
tags
[
i
].
dataLen
+
1
;
int
dataLen
=
0
;
char
*
buf
=
(
char
*
)
calloc
(
tagBufLen
,
1
);
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
"("
);
if
(
NULL
==
buf
)
{
for
(
int
i
=
0
;
i
<
stbInfo
->
tagCount
;
i
++
)
{
printf
(
"calloc failed! size:%d
\n
"
,
stbInfo
->
tags
[
i
].
dataLen
);
if
((
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
tmfree
(
dataBuf
);
"binary"
,
strlen
(
"binary"
)))
return
NULL
;
||
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
}
"nchar"
,
strlen
(
"nchar"
))))
{
if
(
stbInfo
->
tags
[
i
].
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
printf
(
"binary or nchar length overflow, max size:%u
\n
"
,
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
tmfree
(
dataBuf
);
return
NULL
;
}
if
(
tableSeq
%
2
)
{
int
tagBufLen
=
stbInfo
->
tags
[
i
].
dataLen
+
1
;
tstrncpy
(
buf
,
"beijing"
,
tagBufLen
);
char
*
buf
=
(
char
*
)
calloc
(
tagBufLen
,
1
);
}
else
{
if
(
NULL
==
buf
)
{
tstrncpy
(
buf
,
"shanghai"
,
tagBufLen
);
printf
(
"calloc failed! size:%d
\n
"
,
stbInfo
->
tags
[
i
].
dataLen
);
}
tmfree
(
dataBuf
);
//rand_string(buf, stbInfo->tags[i].dataLen);
return
NULL
;
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
}
"
\'
%s
\'
, "
,
buf
);
tmfree
(
buf
);
if
(
tableSeq
%
2
)
{
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
tstrncpy
(
buf
,
"beijing"
,
tagBufLen
);
"int"
,
strlen
(
"int"
)))
{
}
else
{
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
tstrncpy
(
buf
,
"shanghai"
,
tagBufLen
);
"%d, "
,
tableSeq
);
}
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
//rand_string(buf, stbInfo->tags[i].dataLen);
"bigint"
,
strlen
(
"bigint"
)))
{
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
"
\'
%s
\'
, "
,
buf
);
"%"
PRId64
", "
,
rand_bigint
());
tmfree
(
buf
);
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
"float"
,
strlen
(
"float"
)))
{
"int"
,
strlen
(
"int"
)))
{
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
"%f, "
,
rand_float
());
"%d, "
,
tableSeq
);
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
"double"
,
strlen
(
"double"
)))
{
"bigint"
,
strlen
(
"bigint"
)))
{
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
"%f, "
,
rand_double
());
"%"
PRId64
", "
,
rand_bigint
());
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
"smallint"
,
strlen
(
"smallint"
)))
{
"float"
,
strlen
(
"float"
)))
{
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
"%d, "
,
rand_smallint
());
"%f, "
,
rand_float
());
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
"tinyint"
,
strlen
(
"tinyint"
)))
{
"double"
,
strlen
(
"double"
)))
{
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
"%d, "
,
rand_tinyint
());
"%f, "
,
rand_double
());
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
"bool"
,
strlen
(
"bool"
)))
{
"smallint"
,
strlen
(
"smallint"
)))
{
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
"%d, "
,
rand_bool
());
"%d, "
,
rand_smallint
());
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
"timestamp"
,
strlen
(
"timestamp"
)))
{
"tinyint"
,
strlen
(
"tinyint"
)))
{
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
"%"
PRId64
", "
,
rand_bigint
());
"%d, "
,
rand_tinyint
());
}
else
{
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
printf
(
"No support data type: %s
\n
"
,
stbInfo
->
tags
[
i
].
dataType
);
"bool"
,
strlen
(
"bool"
)))
{
tmfree
(
dataBuf
);
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
return
NULL
;
"%d, "
,
rand_bool
());
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
tags
[
i
].
dataType
,
"timestamp"
,
strlen
(
"timestamp"
)))
{
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
"%"
PRId64
", "
,
rand_bigint
());
}
else
{
printf
(
"No support data type: %s
\n
"
,
stbInfo
->
tags
[
i
].
dataType
);
tmfree
(
dataBuf
);
return
NULL
;
}
}
}
}
dataLen
-=
2
;
dataLen
-=
2
;
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
")"
);
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
TSDB_MAX_SQL_LEN
-
dataLen
,
")"
);
return
dataBuf
;
return
dataBuf
;
}
}
static
int
calcRowLen
(
SSuperTable
*
superTbls
)
{
static
int
calcRowLen
(
SSuperTable
*
superTbls
)
{
...
@@ -2636,155 +2679,172 @@ static int createSuperTable(
...
@@ -2636,155 +2679,172 @@ static int createSuperTable(
TAOS
*
taos
,
char
*
dbName
,
TAOS
*
taos
,
char
*
dbName
,
SSuperTable
*
superTbl
)
{
SSuperTable
*
superTbl
)
{
char
command
[
BUFFER_SIZE
]
=
"
\0
"
;
char
command
[
BUFFER_SIZE
]
=
"
\0
"
;
char
cols
[
STRING_LEN
]
=
"
\0
"
;
char
cols
[
STRING_LEN
]
=
"
\0
"
;
int
colIndex
;
int
colIndex
;
int
len
=
0
;
int
len
=
0
;
int
lenOfOneRow
=
0
;
int
lenOfOneRow
=
0
;
if
(
superTbl
->
columnCount
==
0
)
{
if
(
superTbl
->
columnCount
==
0
)
{
errorPrint
(
"%s() LN%d, super table column count is %d
\n
"
,
errorPrint
(
"%s() LN%d, super table column count is %d
\n
"
,
__func__
,
__LINE__
,
superTbl
->
columnCount
);
__func__
,
__LINE__
,
superTbl
->
columnCount
);
return
-
1
;
return
-
1
;
}
}
for
(
colIndex
=
0
;
colIndex
<
superTbl
->
columnCount
;
colIndex
++
)
{
for
(
colIndex
=
0
;
colIndex
<
superTbl
->
columnCount
;
colIndex
++
)
{
char
*
dataType
=
superTbl
->
columns
[
colIndex
].
dataType
;
char
*
dataType
=
superTbl
->
columns
[
colIndex
].
dataType
;
if
(
strcasecmp
(
dataType
,
"BINARY"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s(%d)"
,
colIndex
,
"BINARY"
,
superTbl
->
columns
[
colIndex
].
dataLen
);
lenOfOneRow
+=
superTbl
->
columns
[
colIndex
].
dataLen
+
3
;
}
else
if
(
strcasecmp
(
dataType
,
"NCHAR"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s(%d)"
,
colIndex
,
"NCHAR"
,
superTbl
->
columns
[
colIndex
].
dataLen
);
lenOfOneRow
+=
superTbl
->
columns
[
colIndex
].
dataLen
+
3
;
}
else
if
(
strcasecmp
(
dataType
,
"INT"
)
==
0
)
{
if
((
g_args
.
demo_mode
)
&&
(
colIndex
==
1
))
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", VOLTAGE INT"
);
}
else
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
colIndex
,
"INT"
);
}
lenOfOneRow
+=
11
;
}
else
if
(
strcasecmp
(
dataType
,
"BIGINT"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
colIndex
,
"BIGINT"
);
lenOfOneRow
+=
21
;
}
else
if
(
strcasecmp
(
dataType
,
"SMALLINT"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
colIndex
,
"SMALLINT"
);
lenOfOneRow
+=
6
;
}
else
if
(
strcasecmp
(
dataType
,
"TINYINT"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
colIndex
,
"TINYINT"
);
lenOfOneRow
+=
4
;
}
else
if
(
strcasecmp
(
dataType
,
"BOOL"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
colIndex
,
"BOOL"
);
lenOfOneRow
+=
6
;
}
else
if
(
strcasecmp
(
dataType
,
"FLOAT"
)
==
0
)
{
if
(
g_args
.
demo_mode
)
{
if
(
colIndex
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", CURRENT FLOAT"
);
}
else
if
(
colIndex
==
2
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", PHASE FLOAT"
);
}
}
else
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
colIndex
,
"FLOAT"
);
}
if
(
strcasecmp
(
dataType
,
"BINARY"
)
==
0
)
{
lenOfOneRow
+=
22
;
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
}
else
if
(
strcasecmp
(
dataType
,
"DOUBLE"
)
==
0
)
{
", col%d %s(%d)"
,
colIndex
,
"BINARY"
,
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
superTbl
->
columns
[
colIndex
].
dataLen
);
colIndex
,
"DOUBLE"
);
lenOfOneRow
+=
superTbl
->
columns
[
colIndex
].
dataLen
+
3
;
lenOfOneRow
+=
42
;
}
else
if
(
strcasecmp
(
dataType
,
"NCHAR"
)
==
0
)
{
}
else
if
(
strcasecmp
(
dataType
,
"TIMESTAMP"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
", col%d %s(%d)"
,
colIndex
,
"NCHAR"
,
colIndex
,
"TIMESTAMP"
);
superTbl
->
columns
[
colIndex
].
dataLen
);
lenOfOneRow
+=
21
;
lenOfOneRow
+=
superTbl
->
columns
[
colIndex
].
dataLen
+
3
;
}
else
{
}
else
if
(
strcasecmp
(
dataType
,
"INT"
)
==
0
)
{
taos_close
(
taos
);
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
colIndex
,
"INT"
);
errorPrint
(
"%s() LN%d, config error data type : %s
\n
"
,
lenOfOneRow
+=
11
;
__func__
,
__LINE__
,
dataType
);
}
else
if
(
strcasecmp
(
dataType
,
"BIGINT"
)
==
0
)
{
exit
(
-
1
);
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
colIndex
,
"BIGINT"
);
}
lenOfOneRow
+=
21
;
}
else
if
(
strcasecmp
(
dataType
,
"SMALLINT"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
colIndex
,
"SMALLINT"
);
lenOfOneRow
+=
6
;
}
else
if
(
strcasecmp
(
dataType
,
"TINYINT"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
colIndex
,
"TINYINT"
);
lenOfOneRow
+=
4
;
}
else
if
(
strcasecmp
(
dataType
,
"BOOL"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
colIndex
,
"BOOL"
);
lenOfOneRow
+=
6
;
}
else
if
(
strcasecmp
(
dataType
,
"FLOAT"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
colIndex
,
"FLOAT"
);
lenOfOneRow
+=
22
;
}
else
if
(
strcasecmp
(
dataType
,
"DOUBLE"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
colIndex
,
"DOUBLE"
);
lenOfOneRow
+=
42
;
}
else
if
(
strcasecmp
(
dataType
,
"TIMESTAMP"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
", col%d %s"
,
colIndex
,
"TIMESTAMP"
);
lenOfOneRow
+=
21
;
}
else
{
taos_close
(
taos
);
errorPrint
(
"%s() LN%d, config error data type : %s
\n
"
,
__func__
,
__LINE__
,
dataType
);
exit
(
-
1
);
}
}
}
superTbl
->
lenOfOneRow
=
lenOfOneRow
+
20
;
// timestamp
superTbl
->
lenOfOneRow
=
lenOfOneRow
+
20
;
// timestamp
//printf("%s.%s column count:%d, column length:%d\n\n", g_Dbs.db[i].dbName, g_Dbs.db[i].superTbl[j].sTblName, g_Dbs.db[i].superTbl[j].columnCount, lenOfOneRow);
// save for creating child table
superTbl
->
colsOfCreateChildTable
=
(
char
*
)
calloc
(
len
+
20
,
1
);
if
(
NULL
==
superTbl
->
colsOfCreateChildTable
)
{
errorPrint
(
"%s() LN%d, Failed when calloc, size:%d"
,
__func__
,
__LINE__
,
len
+
1
);
taos_close
(
taos
);
exit
(
-
1
);
}
snprintf
(
superTbl
->
colsOfCreateChildTable
,
len
+
20
,
"(ts timestamp%s)"
,
cols
);
// save for creating child table
verbosePrint
(
"%s() LN%d: %s
\n
"
,
superTbl
->
colsOfCreateChildTable
=
(
char
*
)
calloc
(
len
+
20
,
1
);
__func__
,
__LINE__
,
superTbl
->
colsOfCreateChildTable
);
if
(
NULL
==
superTbl
->
colsOfCreateChildTable
)
{
errorPrint
(
"%s() LN%d, Failed when calloc, size:%d"
,
__func__
,
__LINE__
,
len
+
1
);
taos_close
(
taos
);
exit
(
-
1
);
}
if
(
superTbl
->
tagCount
==
0
)
{
snprintf
(
superTbl
->
colsOfCreateChildTable
,
len
+
20
,
"(ts timestamp%s)"
,
cols
);
errorPrint
(
"%s() LN%d, super table tag count is %d
\n
"
,
verbosePrint
(
"%s() LN%d: %s
\n
"
,
__func__
,
__LINE__
,
superTbl
->
tagCount
);
__func__
,
__LINE__
,
superTbl
->
colsOfCreateChildTable
);
return
-
1
;
}
char
tags
[
STRING_LEN
]
=
"
\0
"
;
if
(
superTbl
->
tagCount
==
0
)
{
int
tagIndex
;
errorPrint
(
"%s() LN%d, super table tag count is %d
\n
"
,
len
=
0
;
__func__
,
__LINE__
,
superTbl
->
tagCount
);
return
-
1
;
}
int
lenOfTagOfOneRow
=
0
;
char
tags
[
STRING_LEN
]
=
"
\0
"
;
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"("
);
int
tagIndex
;
for
(
tagIndex
=
0
;
tagIndex
<
superTbl
->
tagCount
;
tagIndex
++
)
{
len
=
0
;
char
*
dataType
=
superTbl
->
tags
[
tagIndex
].
dataType
;
if
(
strcasecmp
(
dataType
,
"BINARY"
)
==
0
)
{
int
lenOfTagOfOneRow
=
0
;
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s(%d), "
,
tagIndex
,
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"("
);
"BINARY"
,
superTbl
->
tags
[
tagIndex
].
dataLen
);
for
(
tagIndex
=
0
;
tagIndex
<
superTbl
->
tagCount
;
tagIndex
++
)
{
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
3
;
char
*
dataType
=
superTbl
->
tags
[
tagIndex
].
dataType
;
}
else
if
(
strcasecmp
(
dataType
,
"NCHAR"
)
==
0
)
{
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s(%d), "
,
tagIndex
,
if
(
strcasecmp
(
dataType
,
"BINARY"
)
==
0
)
{
"NCHAR"
,
superTbl
->
tags
[
tagIndex
].
dataLen
);
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s(%d), "
,
tagIndex
,
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
3
;
"BINARY"
,
superTbl
->
tags
[
tagIndex
].
dataLen
);
}
else
if
(
strcasecmp
(
dataType
,
"INT"
)
==
0
)
{
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
3
;
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s, "
,
tagIndex
,
}
else
if
(
strcasecmp
(
dataType
,
"NCHAR"
)
==
0
)
{
"INT"
);
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s(%d), "
,
tagIndex
,
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
11
;
"NCHAR"
,
superTbl
->
tags
[
tagIndex
].
dataLen
);
}
else
if
(
strcasecmp
(
dataType
,
"BIGINT"
)
==
0
)
{
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
3
;
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s, "
,
tagIndex
,
}
else
if
(
strcasecmp
(
dataType
,
"INT"
)
==
0
)
{
"BIGINT"
);
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s, "
,
tagIndex
,
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
21
;
"INT"
);
}
else
if
(
strcasecmp
(
dataType
,
"SMALLINT"
)
==
0
)
{
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
11
;
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s, "
,
tagIndex
,
}
else
if
(
strcasecmp
(
dataType
,
"BIGINT"
)
==
0
)
{
"SMALLINT"
);
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s, "
,
tagIndex
,
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
6
;
"BIGINT"
);
}
else
if
(
strcasecmp
(
dataType
,
"TINYINT"
)
==
0
)
{
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
21
;
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s, "
,
tagIndex
,
}
else
if
(
strcasecmp
(
dataType
,
"SMALLINT"
)
==
0
)
{
"TINYINT"
);
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s, "
,
tagIndex
,
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
4
;
"SMALLINT"
);
}
else
if
(
strcasecmp
(
dataType
,
"BOOL"
)
==
0
)
{
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
6
;
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s, "
,
tagIndex
,
}
else
if
(
strcasecmp
(
dataType
,
"TINYINT"
)
==
0
)
{
"BOOL"
);
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s, "
,
tagIndex
,
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
6
;
"TINYINT"
);
}
else
if
(
strcasecmp
(
dataType
,
"FLOAT"
)
==
0
)
{
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
4
;
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s, "
,
tagIndex
,
}
else
if
(
strcasecmp
(
dataType
,
"BOOL"
)
==
0
)
{
"FLOAT"
);
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s, "
,
tagIndex
,
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
22
;
"BOOL"
);
}
else
if
(
strcasecmp
(
dataType
,
"DOUBLE"
)
==
0
)
{
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
6
;
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s, "
,
tagIndex
,
}
else
if
(
strcasecmp
(
dataType
,
"FLOAT"
)
==
0
)
{
"DOUBLE"
);
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s, "
,
tagIndex
,
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
42
;
"FLOAT"
);
}
else
{
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
22
;
taos_close
(
taos
);
}
else
if
(
strcasecmp
(
dataType
,
"DOUBLE"
)
==
0
)
{
errorPrint
(
"%s() LN%d, config error tag type : %s
\n
"
,
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
"t%d %s, "
,
tagIndex
,
__func__
,
__LINE__
,
dataType
);
"DOUBLE"
);
exit
(
-
1
);
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
42
;
}
else
{
taos_close
(
taos
);
errorPrint
(
"%s() LN%d, config error tag type : %s
\n
"
,
__func__
,
__LINE__
,
dataType
);
exit
(
-
1
);
}
}
}
}
len
-=
2
;
len
-=
2
;
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
")"
);
len
+=
snprintf
(
tags
+
len
,
STRING_LEN
-
len
,
")"
);
superTbl
->
lenOfTagOfOneRow
=
lenOfTagOfOneRow
;
superTbl
->
lenOfTagOfOneRow
=
lenOfTagOfOneRow
;
snprintf
(
command
,
BUFFER_SIZE
,
snprintf
(
command
,
BUFFER_SIZE
,
"create table if not exists %s.%s (ts timestamp%s) tags %s"
,
"create table if not exists %s.%s (ts timestamp%s) tags %s"
,
dbName
,
superTbl
->
sTblName
,
cols
,
tags
);
dbName
,
superTbl
->
sTblName
,
cols
,
tags
);
if
(
0
!=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
,
false
))
{
if
(
0
!=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
,
false
))
{
errorPrint
(
"create supertable %s failed!
\n\n
"
,
errorPrint
(
"create supertable %s failed!
\n\n
"
,
superTbl
->
sTblName
);
superTbl
->
sTblName
);
return
-
1
;
return
-
1
;
}
}
debugPrint
(
"create supertable %s success!
\n\n
"
,
superTbl
->
sTblName
);
debugPrint
(
"create supertable %s success!
\n\n
"
,
superTbl
->
sTblName
);
return
0
;
return
0
;
}
}
static
int
createDatabasesAndStables
()
{
static
int
createDatabasesAndStables
()
{
...
@@ -4746,106 +4806,124 @@ static void postFreeResource() {
...
@@ -4746,106 +4806,124 @@ static void postFreeResource() {
static
int
getRowDataFromSample
(
static
int
getRowDataFromSample
(
char
*
dataBuf
,
int64_t
maxLen
,
int64_t
timestamp
,
char
*
dataBuf
,
int64_t
maxLen
,
int64_t
timestamp
,
SSuperTable
*
superTblInfo
,
int64_t
*
sampleUsePos
)
{
SSuperTable
*
superTblInfo
,
int64_t
*
sampleUsePos
)
if
((
*
sampleUsePos
)
==
MAX_SAMPLES_ONCE_FROM_FILE
)
{
{
/* int ret = readSampleFromCsvFileToMem(superTblInfo);
if
((
*
sampleUsePos
)
==
MAX_SAMPLES_ONCE_FROM_FILE
)
{
if (0 != ret) {
/* int ret = readSampleFromCsvFileToMem(superTblInfo);
tmfree(superTblInfo->sampleDataBuf);
if (0 != ret) {
superTblInfo->sampleDataBuf = NULL;
tmfree(superTblInfo->sampleDataBuf);
return -1;
superTblInfo->sampleDataBuf = NULL;
return -1;
}
*/
*
sampleUsePos
=
0
;
}
}
*/
*
sampleUsePos
=
0
;
}
int
dataLen
=
0
;
int
dataLen
=
0
;
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
maxLen
-
dataLen
,
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
maxLen
-
dataLen
,
"(%"
PRId64
", "
,
timestamp
);
"(%"
PRId64
", "
,
timestamp
);
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
maxLen
-
dataLen
,
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
maxLen
-
dataLen
,
"%s"
,
superTblInfo
->
sampleDataBuf
+
superTblInfo
->
lenOfOneRow
*
(
*
sampleUsePos
));
"%s"
,
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
maxLen
-
dataLen
,
")"
);
superTblInfo
->
sampleDataBuf
+
superTblInfo
->
lenOfOneRow
*
(
*
sampleUsePos
));
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
maxLen
-
dataLen
,
")"
);
(
*
sampleUsePos
)
++
;
(
*
sampleUsePos
)
++
;
return
dataLen
;
return
dataLen
;
}
}
static
int64_t
generateStbRowData
(
static
int64_t
generateStbRowData
(
SSuperTable
*
stbInfo
,
SSuperTable
*
stbInfo
,
char
*
recBuf
,
int64_t
timestamp
)
char
*
recBuf
,
int64_t
timestamp
)
{
{
int64_t
dataLen
=
0
;
int64_t
dataLen
=
0
;
char
*
pstr
=
recBuf
;
char
*
pstr
=
recBuf
;
int64_t
maxLen
=
MAX_DATA_SIZE
;
int64_t
maxLen
=
MAX_DATA_SIZE
;
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"(%"
PRId64
","
,
timestamp
);
"(%"
PRId64
","
,
timestamp
);
for
(
int
i
=
0
;
i
<
stbInfo
->
columnCount
;
i
++
)
{
for
(
int
i
=
0
;
i
<
stbInfo
->
columnCount
;
i
++
)
{
if
((
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
if
((
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"BINARY"
,
strlen
(
"BINARY"
)))
"BINARY"
,
strlen
(
"BINARY"
)))
||
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
||
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"NCHAR"
,
strlen
(
"NCHAR"
))))
{
"NCHAR"
,
strlen
(
"NCHAR"
))))
{
if
(
stbInfo
->
columns
[
i
].
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
if
(
stbInfo
->
columns
[
i
].
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
errorPrint
(
"binary or nchar length overflow, max size:%u
\n
"
,
errorPrint
(
"binary or nchar length overflow, max size:%u
\n
"
,
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
return
-
1
;
return
-
1
;
}
}
char
*
buf
=
(
char
*
)
calloc
(
stbInfo
->
columns
[
i
].
dataLen
+
1
,
1
);
char
*
buf
=
(
char
*
)
calloc
(
stbInfo
->
columns
[
i
].
dataLen
+
1
,
1
);
if
(
NULL
==
buf
)
{
if
(
NULL
==
buf
)
{
errorPrint
(
"calloc failed! size:%d
\n
"
,
stbInfo
->
columns
[
i
].
dataLen
);
errorPrint
(
"calloc failed! size:%d
\n
"
,
stbInfo
->
columns
[
i
].
dataLen
);
return
-
1
;
return
-
1
;
}
}
rand_string
(
buf
,
stbInfo
->
columns
[
i
].
dataLen
);
rand_string
(
buf
,
stbInfo
->
columns
[
i
].
dataLen
);
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"
\'
%s
\'
,"
,
buf
);
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"
\'
%s
\'
,"
,
buf
);
tmfree
(
buf
);
tmfree
(
buf
);
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"INT"
,
strlen
(
"INT"
)))
{
"INT"
,
strlen
(
"INT"
)))
{
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
if
((
g_args
.
demo_mode
)
&&
(
i
==
1
))
{
"%d,"
,
rand_int
());
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"%d,"
,
demo_voltage_int
());
"BIGINT"
,
strlen
(
"BIGINT"
)))
{
}
else
{
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"%"
PRId64
","
,
rand_bigint
());
"%d,"
,
rand_int
());
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
}
"FLOAT"
,
strlen
(
"FLOAT"
)))
{
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"BIGINT"
,
strlen
(
"BIGINT"
)))
{
"%f,"
,
rand_float
());
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"%"
PRId64
","
,
rand_bigint
());
"DOUBLE"
,
strlen
(
"DOUBLE"
)))
{
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"FLOAT"
,
strlen
(
"FLOAT"
)))
{
"%f,"
,
rand_double
());
if
(
g_args
.
demo_mode
)
{
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
if
(
i
==
0
)
{
"SMALLINT"
,
strlen
(
"SMALLINT"
)))
{
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"%f,"
,
demo_current_float
());
"%d,"
,
rand_smallint
());
}
else
{
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"TINYINT"
,
strlen
(
"TINYINT"
)))
{
"%f,"
,
demo_phase_float
());
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
}
"%d,"
,
rand_tinyint
());
}
else
{
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"BOOL"
,
strlen
(
"BOOL"
)))
{
"%f,"
,
rand_float
());
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
}
"%d,"
,
rand_bool
());
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"DOUBLE"
,
strlen
(
"DOUBLE"
)))
{
"TIMESTAMP"
,
strlen
(
"TIMESTAMP"
)))
{
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"%f,"
,
rand_double
());
"%"
PRId64
","
,
rand_bigint
());
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
}
else
{
"SMALLINT"
,
strlen
(
"SMALLINT"
)))
{
errorPrint
(
"Not support data type: %s
\n
"
,
stbInfo
->
columns
[
i
].
dataType
);
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
return
-
1
;
"%d,"
,
rand_smallint
());
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"TINYINT"
,
strlen
(
"TINYINT"
)))
{
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"%d,"
,
rand_tinyint
());
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"BOOL"
,
strlen
(
"BOOL"
)))
{
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"%d,"
,
rand_bool
());
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"TIMESTAMP"
,
strlen
(
"TIMESTAMP"
)))
{
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"%"
PRId64
","
,
rand_bigint
());
}
else
{
errorPrint
(
"Not support data type: %s
\n
"
,
stbInfo
->
columns
[
i
].
dataType
);
return
-
1
;
}
}
}
}
dataLen
-=
1
;
dataLen
-=
1
;
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
")"
);
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
")"
);
verbosePrint
(
"%s() LN%d, dataLen:%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
dataLen
);
verbosePrint
(
"%s() LN%d, dataLen:%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
dataLen
);
verbosePrint
(
"%s() LN%d, recBuf:
\n\t
%s
\n
"
,
__func__
,
__LINE__
,
recBuf
);
verbosePrint
(
"%s() LN%d, recBuf:
\n\t
%s
\n
"
,
__func__
,
__LINE__
,
recBuf
);
return
strlen
(
recBuf
);
return
strlen
(
recBuf
);
}
}
static
int64_t
generateData
(
char
*
recBuf
,
char
**
data_type
,
static
int64_t
generateData
(
char
*
recBuf
,
char
**
data_type
,
...
...
tests/pytest/tools/taosdemoTest.py
浏览文件 @
ba090e22
...
@@ -51,7 +51,7 @@ class TDTestCase:
...
@@ -51,7 +51,7 @@ class TDTestCase:
else
:
else
:
tdLog
.
info
(
"taosdemo found in %s"
%
buildPath
)
tdLog
.
info
(
"taosdemo found in %s"
%
buildPath
)
binPath
=
buildPath
+
"/build/bin/"
binPath
=
buildPath
+
"/build/bin/"
os
.
system
(
"%staosdemo -y -t %d -n %d"
%
os
.
system
(
"%staosdemo -y -t %d -n %d
-b INT,INT,INT,INT
"
%
(
binPath
,
self
.
numberOfTables
,
self
.
numberOfRecords
))
(
binPath
,
self
.
numberOfTables
,
self
.
numberOfRecords
))
tdSql
.
execute
(
"use test"
)
tdSql
.
execute
(
"use test"
)
...
...
tests/pytest/tools/taosdemoTestTblAlt.py
浏览文件 @
ba090e22
...
@@ -54,7 +54,7 @@ class TDTestCase:
...
@@ -54,7 +54,7 @@ class TDTestCase:
binPath
=
buildPath
+
"/build/bin/"
binPath
=
buildPath
+
"/build/bin/"
if
(
threadID
==
0
):
if
(
threadID
==
0
):
os
.
system
(
"%staosdemo -y -t %d -n %d"
%
os
.
system
(
"%staosdemo -y -t %d -n %d
-b INT,INT,INT,INT -m t
"
%
(
binPath
,
self
.
numberOfTables
,
self
.
numberOfRecords
))
(
binPath
,
self
.
numberOfTables
,
self
.
numberOfRecords
))
if
(
threadID
==
1
):
if
(
threadID
==
1
):
time
.
sleep
(
2
)
time
.
sleep
(
2
)
...
...
tests/pytest/tools/taosdemoTestWithoutMetric.py
浏览文件 @
ba090e22
...
@@ -60,7 +60,7 @@ class TDTestCase:
...
@@ -60,7 +60,7 @@ class TDTestCase:
tdSql
.
execute
(
"use test"
)
tdSql
.
execute
(
"use test"
)
tdSql
.
query
(
tdSql
.
query
(
"select count(*) from test.
t
%d"
%
(
self
.
numberOfTables
-
1
))
"select count(*) from test.
d
%d"
%
(
self
.
numberOfTables
-
1
))
tdSql
.
checkData
(
0
,
0
,
self
.
numberOfRecords
)
tdSql
.
checkData
(
0
,
0
,
self
.
numberOfRecords
)
def
stop
(
self
):
def
stop
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录