Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f9893f92
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
f9893f92
编写于
11月 13, 2021
作者:
Z
zhaoyanggh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change calloc error msg
上级
0eb724fc
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
126 addition
and
121 deletion
+126
-121
src/kit/taosdemo/src/demoCommandOpt.c
src/kit/taosdemo/src/demoCommandOpt.c
+14
-6
src/kit/taosdemo/src/demoData.c
src/kit/taosdemo/src/demoData.c
+20
-40
src/kit/taosdemo/src/demoInsert.c
src/kit/taosdemo/src/demoInsert.c
+52
-64
src/kit/taosdemo/src/demoMain.c
src/kit/taosdemo/src/demoMain.c
+8
-2
src/kit/taosdemo/src/demoOutput.c
src/kit/taosdemo/src/demoOutput.c
+5
-2
src/kit/taosdemo/src/demoQuery.c
src/kit/taosdemo/src/demoQuery.c
+4
-1
src/kit/taosdemo/src/demoSubscribe.c
src/kit/taosdemo/src/demoSubscribe.c
+20
-5
src/kit/taosdemo/src/demoUtil.c
src/kit/taosdemo/src/demoUtil.c
+3
-1
未找到文件。
src/kit/taosdemo/src/demoCommandOpt.c
浏览文件 @
f9893f92
...
...
@@ -29,7 +29,7 @@ char *g_aggreFunc[] = {"*", "count(*)", "avg(C0)", "sum(C0)",
int
parse_args
(
int
argc
,
char
*
argv
[],
SArguments
*
arguments
)
{
int32_t
code
=
-
1
;
char
*
g_dupstr
;
char
*
g_dupstr
=
NULL
;
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
if
((
0
==
strncmp
(
argv
[
i
],
"-f"
,
strlen
(
"-f"
)))
||
(
0
==
strncmp
(
argv
[
i
],
"--file"
,
strlen
(
"--file"
))))
{
...
...
@@ -1501,8 +1501,12 @@ void querySqlFile(TAOS *taos, char *sqlFile) {
return
;
}
int
read_len
=
0
;
char
*
cmd
=
calloc
(
1
,
TSDB_MAX_BYTES_PER_ROW
);
int
read_len
=
0
;
char
*
cmd
=
calloc
(
1
,
TSDB_MAX_BYTES_PER_ROW
);
if
(
cmd
==
NULL
)
{
errorPrint
(
"%s"
,
"failde to allocate memory
\n
"
);
return
;
}
size_t
cmd_len
=
0
;
char
*
line
=
NULL
;
size_t
line_len
=
0
;
...
...
@@ -1551,7 +1555,7 @@ void *queryStableAggrFunc(void *sarg) {
setThreadName
(
"queryStableAggrFunc"
);
char
*
command
=
calloc
(
1
,
BUFFER_SIZE
);
if
(
NULL
==
command
)
{
errorPrint
(
"
failed to allocate %d size memory
\n
"
,
BUFFER_SIZE
);
errorPrint
(
"
%s"
,
"failed to allocate memory
\n
"
);
return
NULL
;
}
...
...
@@ -1662,7 +1666,7 @@ void *queryNtableAggrFunc(void *sarg) {
setThreadName
(
"queryNtableAggrFunc"
);
char
*
command
=
calloc
(
1
,
BUFFER_SIZE
);
if
(
NULL
==
command
)
{
errorPrint
(
"
failed to allocate %d size memory
\n
"
,
BUFFER_SIZE
);
errorPrint
(
"
%s"
,
"failed to allocate memory
\n
"
);
return
NULL
;
}
...
...
@@ -1761,7 +1765,11 @@ void queryAggrFunc() {
pthread_t
read_id
;
threadInfo
*
pThreadInfo
=
calloc
(
1
,
sizeof
(
threadInfo
));
assert
(
pThreadInfo
);
if
(
pThreadInfo
==
NULL
)
{
errorPrint
(
"%s"
,
"failde to allocate memory
\n
"
);
return
;
}
pThreadInfo
->
start_time
=
DEFAULT_START_TIME
;
// 2017-07-14 10:40:00.000
pThreadInfo
->
start_table_from
=
0
;
...
...
src/kit/taosdemo/src/demoData.c
浏览文件 @
f9893f92
...
...
@@ -269,122 +269,102 @@ int init_rand_data() {
int32_t
code
=
-
1
;
g_randint_buff
=
calloc
(
1
,
INT_BUFF_LEN
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randint_buff
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
INT_BUFF_LEN
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_rand_voltage_buff
=
calloc
(
1
,
INT_BUFF_LEN
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randint_buff
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
INT_BUFF_LEN
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randbigint_buff
=
calloc
(
1
,
BIGINT_BUFF_LEN
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randbigint_buff
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
BIGINT_BUFF_LEN
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randsmallint_buff
=
calloc
(
1
,
SMALLINT_BUFF_LEN
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randsmallint_buff
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
SMALLINT_BUFF_LEN
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randtinyint_buff
=
calloc
(
1
,
TINYINT_BUFF_LEN
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randtinyint_buff
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
TINYINT_BUFF_LEN
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randbool_buff
=
calloc
(
1
,
BOOL_BUFF_LEN
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randbool_buff
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
BOOL_BUFF_LEN
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randfloat_buff
=
calloc
(
1
,
FLOAT_BUFF_LEN
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randfloat_buff
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
FLOAT_BUFF_LEN
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_rand_current_buff
=
calloc
(
1
,
FLOAT_BUFF_LEN
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_rand_current_buff
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
FLOAT_BUFF_LEN
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_rand_phase_buff
=
calloc
(
1
,
FLOAT_BUFF_LEN
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_rand_phase_buff
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
FLOAT_BUFF_LEN
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randdouble_buff
=
calloc
(
1
,
DOUBLE_BUFF_LEN
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randdouble_buff
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
DOUBLE_BUFF_LEN
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randuint_buff
=
calloc
(
1
,
INT_BUFF_LEN
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randuint_buff
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
INT_BUFF_LEN
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randutinyint_buff
=
calloc
(
1
,
TINYINT_BUFF_LEN
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randutinyint_buff
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
TINYINT_BUFF_LEN
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randusmallint_buff
=
calloc
(
1
,
SMALLINT_BUFF_LEN
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randusmallint_buff
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
SMALLINT_BUFF_LEN
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randubigint_buff
=
calloc
(
1
,
BIGINT_BUFF_LEN
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randubigint_buff
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
BIGINT_BUFF_LEN
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randint
=
calloc
(
1
,
sizeof
(
int32_t
)
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randint
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
sizeof
(
int32_t
)
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randuint
=
calloc
(
1
,
sizeof
(
uint32_t
)
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randuint
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
sizeof
(
uint32_t
)
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randbigint
=
calloc
(
1
,
sizeof
(
int64_t
)
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randbigint
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
sizeof
(
int64_t
)
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randubigint
=
calloc
(
1
,
sizeof
(
uint64_t
)
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randubigint
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
sizeof
(
uint64_t
)
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randfloat
=
calloc
(
1
,
sizeof
(
float
)
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randfloat
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
sizeof
(
float
)
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
g_randdouble
=
calloc
(
1
,
sizeof
(
double
)
*
g_args
.
prepared_rand
);
if
(
NULL
==
g_randdouble
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
sizeof
(
double
)
*
g_args
.
prepared_rand
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
goto
end_init_rand_data
;
}
...
...
src/kit/taosdemo/src/demoInsert.c
浏览文件 @
f9893f92
...
...
@@ -44,7 +44,7 @@ static int generateTagValuesForStb(SSuperTable *stbInfo, int64_t tableSeq,
int32_t
tagBufLen
=
stbInfo
->
tags
[
i
].
dataLen
+
1
;
char
*
buf
=
(
char
*
)
calloc
(
1
,
tagBufLen
);
if
(
NULL
==
buf
)
{
errorPrint
(
"
failed to allocate %d size memory
\n
"
,
tagBufLen
);
errorPrint
(
"
%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
generateBinaryNCharTagValues
(
tableSeq
,
tagBufLen
,
buf
);
...
...
@@ -625,7 +625,7 @@ static int createSuperTable(TAOS *taos, char *dbName, SSuperTable *superTbl,
(
char
*
)
calloc
(
len
+
TIMESTAMP_BUFF_LEN
,
1
);
if
(
NULL
==
superTbl
->
colsOfCreateChildTable
)
{
taos_close
(
taos
);
errorPrint
(
"
Failed when calloc, size:%d"
,
len
+
1
);
errorPrint
(
"
%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
...
...
@@ -869,8 +869,7 @@ int createDatabasesAndStables(char *command) {
if
((
ret
!=
0
)
||
(
g_Dbs
.
db
[
i
].
drop
))
{
char
*
cmd
=
calloc
(
1
,
BUFFER_SIZE
);
if
(
NULL
==
cmd
)
{
errorPrint
(
"failed to allocate %d size memory
\n
"
,
BUFFER_SIZE
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
...
...
@@ -914,7 +913,7 @@ static void *createTable(void *sarg) {
pThreadInfo
->
buffer
=
calloc
(
1
,
buff_len
);
if
(
NULL
==
pThreadInfo
->
buffer
)
{
errorPrint
(
"
failed to allocate %d size memory
\n
"
,
buff_len
);
errorPrint
(
"
%s"
,
"failed to allocate memory
\n
"
);
return
NULL
;
}
...
...
@@ -952,8 +951,7 @@ static void *createTable(void *sarg) {
char
*
tagsValBuf
=
(
char
*
)
calloc
(
TSDB_MAX_SQL_LEN
+
1
,
1
);
if
(
NULL
==
tagsValBuf
)
{
errorPrint
(
"failed to allocate %d size memory
\n
"
,
TSDB_MAX_SQL_LEN
+
1
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
NULL
;
}
...
...
@@ -1023,14 +1021,12 @@ int startMultiThreadCreateChildTable(char *cols, int threads,
char
*
db_name
,
SSuperTable
*
stbInfo
)
{
pthread_t
*
pids
=
calloc
(
1
,
threads
*
sizeof
(
pthread_t
));
if
(
NULL
==
pids
)
{
errorPrint
(
"failed to allocate %"
PRIu64
" size memory
\n
"
,
threads
*
sizeof
(
pthread_t
));
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
threadInfo
*
infos
=
calloc
(
1
,
threads
*
sizeof
(
threadInfo
));
if
(
NULL
==
infos
)
{
errorPrint
(
"failed to allocate %"
PRIu64
" size memory
\n
"
,
threads
*
sizeof
(
threadInfo
));
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
tmfree
(
pids
);
return
-
1
;
}
...
...
@@ -1271,9 +1267,14 @@ static void getAndSetRowsFromCsvFile(SSuperTable *stbInfo) {
if
(
fp
==
NULL
)
{
errorPrint
(
"Failed to open sample file: %s, reason:%s
\n
"
,
stbInfo
->
sampleFile
,
strerror
(
errno
));
exit
(
EXIT_FAILURE
)
;
return
;
}
char
*
buf
=
calloc
(
1
,
stbInfo
->
maxSqlLen
);
if
(
buf
==
NULL
)
{
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
;
}
while
(
fgets
(
buf
,
stbInfo
->
maxSqlLen
,
fp
))
{
line_count
++
;
}
...
...
@@ -1466,8 +1467,7 @@ static int64_t generateStbRowData(SSuperTable *stbInfo, char *recBuf,
}
char
*
buf
=
(
char
*
)
calloc
(
stbInfo
->
columns
[
i
].
dataLen
+
1
,
1
);
if
(
NULL
==
buf
)
{
errorPrint
(
"calloc failed! size:%d
\n
"
,
stbInfo
->
columns
[
i
].
dataLen
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
rand_string
(
buf
,
stbInfo
->
columns
[
i
].
dataLen
);
...
...
@@ -1648,8 +1648,7 @@ static int64_t generateData(char *recBuf, char *data_type, int64_t timestamp,
case
TSDB_DATA_TYPE_NCHAR
:
s
=
calloc
(
1
,
lenOfBinary
+
1
);
if
(
NULL
==
s
)
{
errorPrint
(
"failed to allocate %d size memory
\n
"
,
lenOfBinary
+
1
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
...
...
@@ -1702,7 +1701,7 @@ static int generateSampleFromRand(char *sampleDataBuf, uint64_t lenOfOneRow,
char
*
buff
=
calloc
(
lenOfOneRow
,
1
);
if
(
NULL
==
buff
)
{
errorPrint
(
"
failed to allocate %"
PRIu64
" size memory
\n
"
,
lenOfOneRow
);
errorPrint
(
"
%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
...
...
@@ -1824,8 +1823,7 @@ static int generateSampleFromRandForStb(SSuperTable *stbInfo) {
static
int
prepareSampleForNtb
()
{
g_sampleDataBuf
=
calloc
(
g_args
.
lenOfOneRow
*
MAX_SAMPLES
,
1
);
if
(
NULL
==
g_sampleDataBuf
)
{
errorPrint
(
"failed to allocate %"
PRIu64
" size memory
\n
"
,
g_args
.
lenOfOneRow
*
MAX_SAMPLES
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
...
...
@@ -1835,8 +1833,7 @@ static int prepareSampleForNtb() {
static
int
prepareSampleForStb
(
SSuperTable
*
stbInfo
)
{
stbInfo
->
sampleDataBuf
=
calloc
(
stbInfo
->
lenOfOneRow
*
MAX_SAMPLES
,
1
);
if
(
NULL
==
stbInfo
->
sampleDataBuf
)
{
errorPrint
(
"failed to allocate %"
PRIu64
" size memory
\n
"
,
stbInfo
->
lenOfOneRow
*
MAX_SAMPLES
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
...
...
@@ -2137,8 +2134,7 @@ static int generateStbSQLHead(SSuperTable *stbInfo, char *tableName,
if
(
AUTO_CREATE_SUBTBL
==
stbInfo
->
autoCreateTable
)
{
char
*
tagsValBuf
=
(
char
*
)
calloc
(
TSDB_MAX_SQL_LEN
+
1
,
1
);
if
(
NULL
==
tagsValBuf
)
{
errorPrint
(
"failed to allocate %d size memory
\n
"
,
TSDB_MAX_SQL_LEN
+
1
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
...
...
@@ -2811,7 +2807,7 @@ static int execStbBindParamBatch(threadInfo *pThreadInfo, char *tableName,
param
->
buffer_type
=
data_type
;
param
->
length
=
calloc
(
1
,
sizeof
(
int32_t
)
*
thisBatch
);
if
(
param
->
length
)
{
if
(
param
->
length
==
NULL
)
{
errorPrint
(
"failed to allocate %"
PRIu64
" size memory
\n
"
,
sizeof
(
int32_t
)
*
thisBatch
);
return
-
1
;
...
...
@@ -2993,7 +2989,7 @@ static int parseSamplefileToStmtBatch(SSuperTable *stbInfo) {
char
*
tmpStr
=
calloc
(
1
,
index
+
1
);
if
(
NULL
==
tmpStr
)
{
errorPrint
(
"
failed to allocate %d size memory
\n
"
,
index
+
1
);
errorPrint
(
"
%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
...
...
@@ -3090,22 +3086,20 @@ static int parseSampleToStmtBatchForThread(threadInfo * pThreadInfo,
pThreadInfo
->
bind_ts_array
=
calloc
(
1
,
sizeof
(
int64_t
)
*
batch
);
if
(
NULL
==
pThreadInfo
->
bind_ts_array
)
{
errorPrint
(
"failed to allocate %"
PRIu64
" size memory
\n
"
,
sizeof
(
int64_t
)
*
batch
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
pThreadInfo
->
bindParams
=
calloc
(
1
,
sizeof
(
TAOS_MULTI_BIND
)
*
(
columnCount
+
1
));
if
(
NULL
==
pThreadInfo
->
bindParams
)
{
errorPrint
(
"failed to allocate %"
PRIu64
" size memory
\n
"
,
sizeof
(
TAOS_MULTI_BIND
)
*
(
columnCount
+
1
));
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
pThreadInfo
->
is_null
=
calloc
(
1
,
batch
);
if
(
NULL
==
pThreadInfo
->
is_null
)
{
errorPrint
(
"
failed to allocate %d size memory
\n
"
,
batch
);
errorPrint
(
"
%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
...
...
@@ -3135,8 +3129,7 @@ int32_t prepareStbStmt(threadInfo *pThreadInfo, char *tableName,
char
*
tagsArray
=
calloc
(
1
,
sizeof
(
TAOS_BIND
)
*
stbInfo
->
tagCount
);
if
(
NULL
==
tagsArray
)
{
errorPrint
(
"failed to allocate %"
PRIu64
" size memory
\n
"
,
sizeof
(
TAOS_BIND
)
*
stbInfo
->
tagCount
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
char
*
tagsValBuf
=
(
char
*
)
calloc
(
TSDB_MAX_SQL_LEN
+
1
,
1
);
...
...
@@ -3167,8 +3160,7 @@ int32_t prepareStbStmt(threadInfo *pThreadInfo, char *tableName,
taos_stmt_errstr
(
stmt
));
return
-
1
;
}
tmfree
(
tagsValBuf
);
tmfree
(
tagsArray
);
}
else
{
if
(
taos_stmt_set_tbname
(
stmt
,
tableName
))
{
errorPrint
(
"taos_stmt_set_tbname() failed! reason: %s
\n
"
,
...
...
@@ -3176,7 +3168,8 @@ int32_t prepareStbStmt(threadInfo *pThreadInfo, char *tableName,
return
-
1
;
}
}
tmfree
(
tagsValBuf
);
tmfree
(
tagsArray
);
return
execStbBindParamBatch
(
pThreadInfo
,
tableName
,
tableSeq
,
batch
,
insertRows
,
recordFrom
,
startTime
,
pSamplePos
);
}
...
...
@@ -3468,7 +3461,7 @@ void *syncWriteInterlace(threadInfo *pThreadInfo, uint32_t interlaceRows) {
" insertRows=%"
PRIu64
"
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
pThreadInfo
->
start_table_from
,
pThreadInfo
->
ntables
,
insertRows
);
#if 1
if
(
interlaceRows
>
g_args
.
reqPerReq
)
interlaceRows
=
g_args
.
reqPerReq
;
uint32_t
batchPerTbl
=
interlaceRows
;
...
...
@@ -3479,24 +3472,9 @@ void *syncWriteInterlace(threadInfo *pThreadInfo, uint32_t interlaceRows) {
}
else
{
batchPerTblTimes
=
1
;
}
#else
uint32_t
batchPerTbl
;
if
(
interlaceRows
>
g_args
.
reqPerReq
)
batchPerTbl
=
g_args
.
reqPerReq
;
else
batchPerTbl
=
interlaceRows
;
uint32_t
batchPerTblTimes
;
if
((
interlaceRows
>
0
)
&&
(
pThreadInfo
->
ntables
>
1
))
{
batchPerTblTimes
=
interlaceRows
/
batchPerTbl
;
}
else
{
batchPerTblTimes
=
1
;
}
#endif
pThreadInfo
->
buffer
=
calloc
(
maxSqlLen
,
1
);
if
(
NULL
==
pThreadInfo
->
buffer
)
{
errorPrint
(
"
failed to allocate %"
PRIu64
" size memory
\n
"
,
maxSqlLen
);
errorPrint
(
"
%s"
,
"failed to allocate memory
\n
"
);
return
NULL
;
}
...
...
@@ -3837,8 +3815,7 @@ void *syncWriteProgressive(threadInfo *pThreadInfo) {
pThreadInfo
->
buffer
=
calloc
(
maxSqlLen
,
1
);
if
(
NULL
==
pThreadInfo
->
buffer
)
{
errorPrint
(
"Failed to alloc %"
PRIu64
" bytes, reason:%s
\n
"
,
maxSqlLen
,
strerror
(
errno
));
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
NULL
;
}
...
...
@@ -4223,8 +4200,7 @@ int startMultiThreadInsertData(int threads, char *db_name, char *precision,
stbInfo
->
childTblName
=
(
char
*
)
calloc
(
1
,
limit
*
TSDB_TABLE_NAME_LEN
);
if
(
NULL
==
stbInfo
->
childTblName
)
{
errorPrint
(
"failed to allocate %"
PRId64
" size memory
\n
"
,
limit
*
TSDB_TABLE_NAME_LEN
);
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
...
...
@@ -4263,13 +4239,25 @@ int startMultiThreadInsertData(int threads, char *db_name, char *precision,
}
}
pthread_t
*
pids
=
calloc
(
1
,
threads
*
sizeof
(
pthread_t
));
pthread_t
*
pids
=
calloc
(
1
,
threads
*
sizeof
(
pthread_t
));
if
(
pids
==
NULL
)
{
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
-
1
;
}
threadInfo
*
infos
=
calloc
(
1
,
threads
*
sizeof
(
threadInfo
));
assert
(
pids
!=
NULL
);
assert
(
infos
!=
NULL
);
if
(
infos
==
NULL
)
{
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
tmfree
(
pids
);
return
-
1
;
}
char
*
stmtBuffer
=
calloc
(
1
,
BUFFER_SIZE
);
assert
(
stmtBuffer
);
if
(
stmtBuffer
==
NULL
)
{
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
tmfree
(
pids
);
tmfree
(
infos
);
return
-
1
;
}
uint32_t
interlaceRows
=
0
;
uint32_t
batch
;
...
...
@@ -4333,9 +4321,9 @@ int startMultiThreadInsertData(int threads, char *db_name, char *precision,
if
(
NULL
==
pThreadInfo
->
taos
)
{
free
(
infos
);
errorPrint
(
"
%s() LN%d, connect to server fail from insert sub thread,
"
"
reason: %s
\n
"
,
__func__
,
__LINE__
,
taos_errstr
(
NULL
));
"
connect to server fail from insert sub
"
"
thread,reason:%s
\n
"
,
taos_errstr
(
NULL
));
return
-
1
;
}
...
...
@@ -4578,7 +4566,7 @@ int insertTestProcess() {
// create database and super tables
char
*
cmdBuffer
=
calloc
(
1
,
BUFFER_SIZE
);
if
(
NULL
==
cmdBuffer
)
{
errorPrint
(
"
failed to allocate %d size memory
\n
"
,
BUFFER_SIZE
);
errorPrint
(
"
%s"
,
"failed to allocate memory
\n
"
);
goto
end_insert_process
;
}
if
(
createDatabasesAndStables
(
cmdBuffer
))
{
...
...
src/kit/taosdemo/src/demoMain.c
浏览文件 @
f9893f92
...
...
@@ -82,9 +82,15 @@ int main(int argc, char *argv[]) {
}
else
{
memset
(
&
g_Dbs
,
0
,
sizeof
(
SDbs
));
g_Dbs
.
db
=
calloc
(
1
,
sizeof
(
SDataBase
));
assert
(
g_Dbs
.
db
);
if
(
NULL
==
g_Dbs
.
db
)
{
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
}
g_Dbs
.
db
[
0
].
superTbls
=
calloc
(
1
,
sizeof
(
SSuperTable
));
assert
(
g_Dbs
.
db
[
0
].
superTbls
);
if
(
NULL
==
g_Dbs
.
db
[
0
].
superTbls
)
{
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
}
setParaFromArg
();
if
(
NULL
!=
g_args
.
sqlFile
)
{
...
...
src/kit/taosdemo/src/demoOutput.c
浏览文件 @
f9893f92
...
...
@@ -982,10 +982,13 @@ void printfQuerySystemInfo(TAOS *taos) {
res
=
taos_query
(
taos
,
"show databases;"
);
SDbInfo
**
dbInfos
=
(
SDbInfo
**
)
calloc
(
MAX_DATABASE_COUNT
,
sizeof
(
SDbInfo
*
));
assert
(
dbInfos
);
if
(
dbInfos
==
NULL
)
{
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
;
}
int
dbCount
=
getDbFromServer
(
taos
,
dbInfos
);
if
(
dbCount
<=
0
)
{
free
(
dbInfos
);
tm
free
(
dbInfos
);
return
;
}
...
...
src/kit/taosdemo/src/demoQuery.c
浏览文件 @
f9893f92
...
...
@@ -123,7 +123,10 @@ void *specifiedTableQuery(void *sarg) {
void
*
superTableQuery
(
void
*
sarg
)
{
char
*
sqlstr
=
calloc
(
1
,
BUFFER_SIZE
);
assert
(
sqlstr
);
if
(
NULL
==
sqlstr
)
{
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
return
NULL
;
}
threadInfo
*
pThreadInfo
=
(
threadInfo
*
)
sarg
;
...
...
src/kit/taosdemo/src/demoSubscribe.c
浏览文件 @
f9893f92
...
...
@@ -184,7 +184,9 @@ void *specifiedSubscribe(void *sarg) {
static
void
*
superSubscribe
(
void
*
sarg
)
{
threadInfo
*
pThreadInfo
=
(
threadInfo
*
)
sarg
;
char
*
subSqlStr
=
calloc
(
1
,
BUFFER_SIZE
);
assert
(
subSqlStr
);
if
(
NULL
==
subSqlStr
)
{
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
}
TAOS_SUB
*
tsub
[
MAX_QUERY_SQL_COUNT
]
=
{
0
};
uint64_t
tsubSeq
;
...
...
@@ -388,11 +390,17 @@ int subscribeTestProcess() {
pids
=
calloc
(
1
,
g_queryInfo
.
specifiedQueryInfo
.
sqlCount
*
g_queryInfo
.
specifiedQueryInfo
.
concurrent
*
sizeof
(
pthread_t
));
assert
(
pids
);
if
(
pids
==
NULL
)
{
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
}
infos
=
calloc
(
1
,
g_queryInfo
.
specifiedQueryInfo
.
sqlCount
*
g_queryInfo
.
specifiedQueryInfo
.
concurrent
*
sizeof
(
threadInfo
));
assert
(
infos
);
if
(
infos
==
NULL
)
{
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
}
for
(
int
i
=
0
;
i
<
g_queryInfo
.
specifiedQueryInfo
.
sqlCount
;
i
++
)
{
for
(
int
j
=
0
;
j
<
g_queryInfo
.
specifiedQueryInfo
.
concurrent
;
...
...
@@ -420,11 +428,18 @@ int subscribeTestProcess() {
pidsOfStable
=
calloc
(
1
,
g_queryInfo
.
superQueryInfo
.
sqlCount
*
g_queryInfo
.
superQueryInfo
.
threadCnt
*
sizeof
(
pthread_t
));
assert
(
pidsOfStable
);
if
(
pidsOfStable
)
{
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
}
infosOfStable
=
calloc
(
1
,
g_queryInfo
.
superQueryInfo
.
sqlCount
*
g_queryInfo
.
superQueryInfo
.
threadCnt
*
sizeof
(
threadInfo
));
assert
(
infosOfStable
);
if
(
infosOfStable
)
{
errorPrint
(
"%s"
,
"failed to allocate memmory
\n
"
);
}
int64_t
ntables
=
g_queryInfo
.
superQueryInfo
.
childTblCount
;
int
threads
=
g_queryInfo
.
superQueryInfo
.
threadCnt
;
...
...
src/kit/taosdemo/src/demoUtil.c
浏览文件 @
f9893f92
...
...
@@ -208,7 +208,9 @@ int getChildNameOfSuperTableWithLimitAndOffset(TAOS *taos, char *dbName,
char
*
pTblName
=
childTblName
;
if
(
childTblName
==
NULL
)
{
childTblName
=
(
char
*
)
calloc
(
1
,
childTblCount
*
TSDB_TABLE_NAME_LEN
);
assert
(
childTblName
);
if
(
childTblName
==
NULL
)
{
errorPrint
(
"%s"
,
"failed to allocate memory
\n
"
);
}
}
snprintf
(
limitBuf
,
100
,
" limit %"
PRId64
" offset %"
PRIu64
""
,
limit
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录