Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
65b415d8
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
65b415d8
编写于
10月 21, 2021
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into feature/TS-272
上级
0d4b9df6
754f5724
变更
31
隐藏空白更改
内联
并排
Showing
31 changed file
with
1637 addition
and
446 deletion
+1637
-446
documentation20/cn/05.insert/docs.md
documentation20/cn/05.insert/docs.md
+1
-1
documentation20/cn/12.taos-sql/docs.md
documentation20/cn/12.taos-sql/docs.md
+1
-1
documentation20/cn/14.devops/02.collectd/docs.md
documentation20/cn/14.devops/02.collectd/docs.md
+1
-1
src/client/inc/tscParseLine.h
src/client/inc/tscParseLine.h
+2
-0
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+66
-14
src/client/src/tscParseOpenTSDB.c
src/client/src/tscParseOpenTSDB.c
+23
-3
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+26
-9
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatement.java
...bc/src/main/java/com/taosdata/jdbc/AbstractStatement.java
+2
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
+7
-7
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
.../src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
+5
-5
src/inc/taos.h
src/inc/taos.h
+1
-0
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+935
-296
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+7
-1
src/plugins/blm3
src/plugins/blm3
+1
-1
src/plugins/monitor/src/monMain.c
src/plugins/monitor/src/monMain.c
+5
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+2
-1
src/tsdb/src/tsdbCompact.c
src/tsdb/src/tsdbCompact.c
+1
-0
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+1
-1
tests/examples/c/prepare.c
tests/examples/c/prepare.c
+11
-0
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+1
-0
tests/pytest/insert/insertTelnetLines.py
tests/pytest/insert/insertTelnetLines.py
+2
-3
tests/pytest/insert/line_insert.py
tests/pytest/insert/line_insert.py
+2
-2
tests/pytest/table/create.py
tests/pytest/table/create.py
+4
-14
tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo.py
.../pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo.py
+185
-0
tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo_no.json
...st/tools/taosdemoAllTest/TD-10539/create_taosdemo_no.json
+63
-0
tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo_yes.json
...t/tools/taosdemoAllTest/TD-10539/create_taosdemo_yes.json
+63
-0
tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsAndTagNumLarge4096-stmt.json
...emoAllTest/stmt/insertColumnsAndTagNumLarge4096-stmt.json
+0
-0
tests/pytest/tools/taosdumpTest3.py
tests/pytest/tools/taosdumpTest3.py
+184
-83
tests/script/api/batchprepare.c
tests/script/api/batchprepare.c
+5
-1
tests/script/api/stmt.c
tests/script/api/stmt.c
+22
-1
tests/script/api/stmtTest.c
tests/script/api/stmtTest.c
+8
-0
未找到文件。
documentation20/cn/05.insert/docs.md
浏览文件 @
65b415d8
...
@@ -243,7 +243,7 @@ repeater 部分添加 { host:'<TDengine server/cluster host>', port: <port for S
...
@@ -243,7 +243,7 @@ repeater 部分添加 { host:'<TDengine server/cluster host>', port: <port for S
{
{
port: 8125
port: 8125
, backends: ["./backends/repeater"]
, backends: ["./backends/repeater"]
, repeater: [{ host: '127.0.0.1', port:
8126
}]
, repeater: [{ host: '127.0.0.1', port:
6044
}]
}
}
```
```
...
...
documentation20/cn/12.taos-sql/docs.md
浏览文件 @
65b415d8
...
@@ -1601,7 +1601,7 @@ SELECT AVG(current), MAX(current), LEASTSQUARES(current, start_val, step_val), P
...
@@ -1601,7 +1601,7 @@ SELECT AVG(current), MAX(current), LEASTSQUARES(current, start_val, step_val), P
**GROUP BY的限制**
**GROUP BY的限制**
TAOS SQL 支持对标签、TBNAME 进行 GROUP BY 操作,也支持普通列进行 GROUP BY,前提是:仅限一列且该列的唯一值小于 10 万个。
TAOS SQL 支持对标签、TBNAME 进行 GROUP BY 操作,也支持普通列进行 GROUP BY,前提是:仅限一列且该列的唯一值小于 10 万个。
注意:group by 不支持float,double 类型。
**IS NOT NULL 与不为空的表达式适用范围**
**IS NOT NULL 与不为空的表达式适用范围**
...
...
documentation20/cn/14.devops/02.collectd/docs.md
浏览文件 @
65b415d8
...
@@ -57,7 +57,7 @@ repeater 部分添加 { host:'<TDengine server/cluster host>', port: <port for S
...
@@ -57,7 +57,7 @@ repeater 部分添加 { host:'<TDengine server/cluster host>', port: <port for S
### 导入 Dashboard
### 导入 Dashboard
使用 Web 浏览器访问
IP
:3000 登录 Grafana 界面,系统初始用户名密码为 admin/admin。
使用 Web 浏览器访问
运行 Grafana 的服务器的3000端口 host
:3000 登录 Grafana 界面,系统初始用户名密码为 admin/admin。
点击左侧齿轮图标并选择 Plugins,应该可以找到 TDengine data source 插件图标。
点击左侧齿轮图标并选择 Plugins,应该可以找到 TDengine data source 插件图标。
#### 导入 collectd 仪表盘
#### 导入 collectd 仪表盘
...
...
src/client/inc/tscParseLine.h
浏览文件 @
65b415d8
...
@@ -67,6 +67,8 @@ typedef struct {
...
@@ -67,6 +67,8 @@ typedef struct {
SMLProtocolType
protocol
;
SMLProtocolType
protocol
;
SMLTimeStampType
tsType
;
SMLTimeStampType
tsType
;
SHashObj
*
smlDataToSchema
;
SHashObj
*
smlDataToSchema
;
int64_t
affectedRows
;
}
SSmlLinesInfo
;
}
SSmlLinesInfo
;
int
tscSmlInsert
(
TAOS
*
taos
,
TAOS_SML_DATA_POINT
*
points
,
int
numPoint
,
SSmlLinesInfo
*
info
);
int
tscSmlInsert
(
TAOS
*
taos
,
TAOS_SML_DATA_POINT
*
points
,
int
numPoint
,
SSmlLinesInfo
*
info
);
...
...
src/client/src/tscParseLineProtocol.c
浏览文件 @
65b415d8
...
@@ -761,7 +761,7 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
...
@@ -761,7 +761,7 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
code
=
taos_stmt_prepare
(
stmt
,
sql
,
(
unsigned
long
)
strlen
(
sql
));
code
=
taos_stmt_prepare
(
stmt
,
sql
,
(
unsigned
long
)
strlen
(
sql
));
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
tscError
(
"SML:0x%"
PRIx64
" taos_stmt_prepare return %d:%s"
,
info
->
id
,
code
,
t
strerror
(
code
));
tscError
(
"SML:0x%"
PRIx64
" taos_stmt_prepare return %d:%s"
,
info
->
id
,
code
,
t
aos_stmt_errstr
(
stmt
));
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
return
code
;
return
code
;
}
}
...
@@ -771,7 +771,11 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
...
@@ -771,7 +771,11 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
do
{
do
{
code
=
taos_stmt_set_tbname
(
stmt
,
cTableName
);
code
=
taos_stmt_set_tbname
(
stmt
,
cTableName
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
tscError
(
"SML:0x%"
PRIx64
" taos_stmt_set_tbname return %d:%s"
,
info
->
id
,
code
,
tstrerror
(
code
));
tscError
(
"SML:0x%"
PRIx64
" taos_stmt_set_tbname return %d:%s"
,
info
->
id
,
code
,
taos_stmt_errstr
(
stmt
));
int
affectedRows
=
taos_stmt_affected_rows
(
stmt
);
info
->
affectedRows
+=
affectedRows
;
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
return
code
;
return
code
;
}
}
...
@@ -781,13 +785,21 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
...
@@ -781,13 +785,21 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
TAOS_BIND
*
colsBinds
=
taosArrayGetP
(
batchBind
,
i
);
TAOS_BIND
*
colsBinds
=
taosArrayGetP
(
batchBind
,
i
);
code
=
taos_stmt_bind_param
(
stmt
,
colsBinds
);
code
=
taos_stmt_bind_param
(
stmt
,
colsBinds
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
tscError
(
"SML:0x%"
PRIx64
" taos_stmt_bind_param return %d:%s"
,
info
->
id
,
code
,
tstrerror
(
code
));
tscError
(
"SML:0x%"
PRIx64
" taos_stmt_bind_param return %d:%s"
,
info
->
id
,
code
,
taos_stmt_errstr
(
stmt
));
int
affectedRows
=
taos_stmt_affected_rows
(
stmt
);
info
->
affectedRows
+=
affectedRows
;
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
return
code
;
return
code
;
}
}
code
=
taos_stmt_add_batch
(
stmt
);
code
=
taos_stmt_add_batch
(
stmt
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
tscError
(
"SML:0x%"
PRIx64
" taos_stmt_add_batch return %d:%s"
,
info
->
id
,
code
,
tstrerror
(
code
));
tscError
(
"SML:0x%"
PRIx64
" taos_stmt_add_batch return %d:%s"
,
info
->
id
,
code
,
taos_stmt_errstr
(
stmt
));
int
affectedRows
=
taos_stmt_affected_rows
(
stmt
);
info
->
affectedRows
+=
affectedRows
;
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
return
code
;
return
code
;
}
}
...
@@ -795,9 +807,10 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
...
@@ -795,9 +807,10 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
code
=
taos_stmt_execute
(
stmt
);
code
=
taos_stmt_execute
(
stmt
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
tscError
(
"SML:0x%"
PRIx64
" taos_stmt_execute return %d:%s, try:%d"
,
info
->
id
,
code
,
t
strerror
(
code
),
try
);
tscError
(
"SML:0x%"
PRIx64
" taos_stmt_execute return %d:%s, try:%d"
,
info
->
id
,
code
,
t
aos_stmt_errstr
(
stmt
),
try
);
}
}
tscDebug
(
"SML:0x%"
PRIx64
" taos_stmt_execute inserted %d rows"
,
info
->
id
,
taos_stmt_affected_rows
(
stmt
));
tryAgain
=
false
;
tryAgain
=
false
;
if
((
code
==
TSDB_CODE_TDB_INVALID_TABLE_ID
if
((
code
==
TSDB_CODE_TDB_INVALID_TABLE_ID
||
code
==
TSDB_CODE_VND_INVALID_VGROUP_ID
||
code
==
TSDB_CODE_VND_INVALID_VGROUP_ID
...
@@ -825,6 +838,8 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
...
@@ -825,6 +838,8 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
}
}
}
while
(
tryAgain
);
}
while
(
tryAgain
);
int
affectedRows
=
taos_stmt_affected_rows
(
stmt
);
info
->
affectedRows
+=
affectedRows
;
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
return
code
;
return
code
;
...
@@ -1069,6 +1084,8 @@ int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLine
...
@@ -1069,6 +1084,8 @@ int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLine
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
info
->
affectedRows
=
0
;
tscDebug
(
"SML:0x%"
PRIx64
" build data point schemas"
,
info
->
id
);
tscDebug
(
"SML:0x%"
PRIx64
" build data point schemas"
,
info
->
id
);
SArray
*
stableSchemas
=
taosArrayInit
(
32
,
sizeof
(
SSmlSTableSchema
));
// SArray<STableColumnsSchema>
SArray
*
stableSchemas
=
taosArrayInit
(
32
,
sizeof
(
SSmlSTableSchema
));
// SArray<STableColumnsSchema>
code
=
buildDataPointSchemas
(
points
,
numPoint
,
stableSchemas
,
info
);
code
=
buildDataPointSchemas
(
points
,
numPoint
,
stableSchemas
,
info
);
...
@@ -1871,7 +1888,7 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
...
@@ -1871,7 +1888,7 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
//key field cannot start with digit
//key field cannot start with digit
if
(
isdigit
(
*
cur
))
{
if
(
isdigit
(
*
cur
))
{
tscError
(
"SML:0x%"
PRIx64
" Tag key cann
n
ot start with digit"
,
info
->
id
);
tscError
(
"SML:0x%"
PRIx64
" Tag key cannot start with digit"
,
info
->
id
);
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
}
}
while
(
*
cur
!=
'\0'
)
{
while
(
*
cur
!=
'\0'
)
{
...
@@ -1885,6 +1902,8 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
...
@@ -1885,6 +1902,8 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
}
}
//Escape special character
//Escape special character
if
(
*
cur
==
'\\'
)
{
if
(
*
cur
==
'\\'
)
{
//TODO: escape will work after column & tag
//support spcial characters
escapeSpecialCharacter
(
2
,
&
cur
);
escapeSpecialCharacter
(
2
,
&
cur
);
}
}
key
[
len
]
=
*
cur
;
key
[
len
]
=
*
cur
;
...
@@ -1911,13 +1930,42 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
...
@@ -1911,13 +1930,42 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
static
int32_t
parseSmlValue
(
TAOS_SML_KV
*
pKV
,
const
char
**
index
,
static
int32_t
parseSmlValue
(
TAOS_SML_KV
*
pKV
,
const
char
**
index
,
bool
*
is_last_kv
,
SSmlLinesInfo
*
info
,
bool
isTag
)
{
bool
*
is_last_kv
,
SSmlLinesInfo
*
info
,
bool
isTag
)
{
const
char
*
start
,
*
cur
;
const
char
*
start
,
*
cur
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
char
*
value
=
NULL
;
char
*
value
=
NULL
;
uint16_t
len
=
0
;
uint16_t
len
=
0
;
bool
searchQuote
=
false
;
start
=
cur
=
*
index
;
start
=
cur
=
*
index
;
//if field value is string
if
(
!
isTag
)
{
if
(
*
cur
==
'"'
)
{
searchQuote
=
true
;
cur
+=
1
;
len
+=
1
;
}
else
if
(
*
cur
==
'L'
&&
*
(
cur
+
1
)
==
'"'
)
{
searchQuote
=
true
;
cur
+=
2
;
len
+=
2
;
}
}
while
(
1
)
{
while
(
1
)
{
// unescaped ',' or ' ' or '\0' identifies a value
// unescaped ',' or ' ' or '\0' identifies a value
if
((
*
cur
==
','
||
*
cur
==
' '
||
*
cur
==
'\0'
)
&&
*
(
cur
-
1
)
!=
'\\'
)
{
if
(((
*
cur
==
','
||
*
cur
==
' '
)
&&
*
(
cur
-
1
)
!=
'\\'
)
||
*
cur
==
'\0'
)
{
if
(
searchQuote
==
true
)
{
//first quote ignored while searching
if
(
*
(
cur
-
1
)
==
'"'
&&
len
!=
1
&&
len
!=
2
)
{
*
is_last_kv
=
(
*
cur
==
' '
||
*
cur
==
'\0'
)
?
true
:
false
;
break
;
}
else
if
(
*
cur
==
'\0'
)
{
ret
=
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
goto
error
;
}
else
{
cur
++
;
len
++
;
continue
;
}
}
//unescaped ' ' or '\0' indicates end of value
//unescaped ' ' or '\0' indicates end of value
*
is_last_kv
=
(
*
cur
==
' '
||
*
cur
==
'\0'
)
?
true
:
false
;
*
is_last_kv
=
(
*
cur
==
' '
||
*
cur
==
'\0'
)
?
true
:
false
;
if
(
*
cur
==
' '
&&
*
(
cur
+
1
)
==
' '
)
{
if
(
*
cur
==
' '
&&
*
(
cur
+
1
)
==
' '
)
{
...
@@ -1929,7 +1977,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
...
@@ -1929,7 +1977,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
}
}
//Escape special character
//Escape special character
if
(
*
cur
==
'\\'
)
{
if
(
*
cur
==
'\\'
)
{
escapeSpecialCharacter
(
2
,
&
cur
);
escapeSpecialCharacter
(
isTag
?
2
:
3
,
&
cur
);
}
}
cur
++
;
cur
++
;
len
++
;
len
++
;
...
@@ -1946,16 +1994,20 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
...
@@ -1946,16 +1994,20 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
if
(
!
convertSmlValueType
(
pKV
,
value
,
len
,
info
,
isTag
))
{
if
(
!
convertSmlValueType
(
pKV
,
value
,
len
,
info
,
isTag
))
{
tscError
(
"SML:0x%"
PRIx64
" Failed to convert sml value string(%s) to any type"
,
tscError
(
"SML:0x%"
PRIx64
" Failed to convert sml value string(%s) to any type"
,
info
->
id
,
value
);
info
->
id
,
value
);
//free previous alocated key field
free
(
pKV
->
key
);
pKV
->
key
=
NULL
;
free
(
value
);
free
(
value
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
ret
=
TSDB_CODE_TSC_INVALID_VALUE
;
goto
error
;
}
}
free
(
value
);
free
(
value
);
*
index
=
(
*
cur
==
'\0'
)
?
cur
:
cur
+
1
;
*
index
=
(
*
cur
==
'\0'
)
?
cur
:
cur
+
1
;
return
TSDB_CODE_SUCCESS
;
return
ret
;
error:
//free previous alocated key field
free
(
pKV
->
key
);
pKV
->
key
=
NULL
;
return
ret
;
}
}
static
int32_t
parseSmlMeasurement
(
TAOS_SML_DATA_POINT
*
pSml
,
const
char
**
index
,
static
int32_t
parseSmlMeasurement
(
TAOS_SML_DATA_POINT
*
pSml
,
const
char
**
index
,
...
...
src/client/src/tscParseOpenTSDB.c
浏览文件 @
65b415d8
...
@@ -138,21 +138,41 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
...
@@ -138,21 +138,41 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
const
char
*
start
,
*
cur
;
const
char
*
start
,
*
cur
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
int
len
=
0
;
int
len
=
0
;
bool
searchQuote
=
false
;
char
key
[]
=
OTD_METRIC_VALUE_COLUMN_NAME
;
char
key
[]
=
OTD_METRIC_VALUE_COLUMN_NAME
;
char
*
value
=
NULL
;
char
*
value
=
NULL
;
start
=
cur
=
*
index
;
start
=
cur
=
*
index
;
//if metric value is string
if
(
*
cur
==
'"'
)
{
searchQuote
=
true
;
cur
+=
1
;
len
+=
1
;
}
else
if
(
*
cur
==
'L'
&&
*
(
cur
+
1
)
==
'"'
)
{
searchQuote
=
true
;
cur
+=
2
;
len
+=
2
;
}
while
(
*
cur
!=
'\0'
)
{
while
(
*
cur
!=
'\0'
)
{
if
(
*
cur
==
' '
)
{
if
(
*
cur
==
' '
)
{
if
(
*
cur
==
' '
)
{
if
(
searchQuote
==
true
)
{
if
(
*
(
cur
+
1
)
!=
' '
)
{
if
(
*
(
cur
-
1
)
==
'"'
&&
len
!=
1
&&
len
!=
2
)
{
break
;
searchQuote
=
false
;
}
else
{
}
else
{
cur
++
;
cur
++
;
len
++
;
continue
;
continue
;
}
}
}
}
if
(
*
(
cur
+
1
)
!=
' '
)
{
break
;
}
else
{
cur
++
;
continue
;
}
}
}
cur
++
;
cur
++
;
len
++
;
len
++
;
...
...
src/client/src/tscPrepare.c
浏览文件 @
65b415d8
...
@@ -78,6 +78,8 @@ typedef struct STscStmt {
...
@@ -78,6 +78,8 @@ typedef struct STscStmt {
SSqlObj
*
pSql
;
SSqlObj
*
pSql
;
SMultiTbStmt
mtb
;
SMultiTbStmt
mtb
;
SNormalStmt
normal
;
SNormalStmt
normal
;
int
numOfRows
;
}
STscStmt
;
}
STscStmt
;
#define STMT_RET(c) do { \
#define STMT_RET(c) do { \
...
@@ -1212,6 +1214,8 @@ static int insertStmtExecute(STscStmt* stmt) {
...
@@ -1212,6 +1214,8 @@ static int insertStmtExecute(STscStmt* stmt) {
// wait for the callback function to post the semaphore
// wait for the callback function to post the semaphore
tsem_wait
(
&
pSql
->
rspSem
);
tsem_wait
(
&
pSql
->
rspSem
);
stmt
->
numOfRows
+=
pSql
->
res
.
numOfRows
;
// data block reset
// data block reset
pCmd
->
batchSize
=
0
;
pCmd
->
batchSize
=
0
;
for
(
int32_t
i
=
0
;
i
<
pCmd
->
insertParam
.
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCmd
->
insertParam
.
numOfTables
;
++
i
)
{
...
@@ -1284,7 +1288,9 @@ static int insertBatchStmtExecute(STscStmt* pStmt) {
...
@@ -1284,7 +1288,9 @@ static int insertBatchStmtExecute(STscStmt* pStmt) {
tsem_wait
(
&
pStmt
->
pSql
->
rspSem
);
tsem_wait
(
&
pStmt
->
pSql
->
rspSem
);
code
=
pStmt
->
pSql
->
res
.
code
;
code
=
pStmt
->
pSql
->
res
.
code
;
pStmt
->
numOfRows
+=
pStmt
->
pSql
->
res
.
numOfRows
;
insertBatchClean
(
pStmt
);
insertBatchClean
(
pStmt
);
return
code
;
return
code
;
...
@@ -1516,11 +1522,12 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) {
...
@@ -1516,11 +1522,12 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) {
}
}
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
);
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
);
pSql
->
signature
=
pSql
;
pSql
->
signature
=
pSql
;
pSql
->
pTscObj
=
pObj
;
pSql
->
pTscObj
=
pObj
;
pSql
->
maxRetry
=
TSDB_MAX_REPLICA
;
pSql
->
maxRetry
=
TSDB_MAX_REPLICA
;
pStmt
->
pSql
=
pSql
;
pStmt
->
pSql
=
pSql
;
pStmt
->
last
=
STMT_INIT
;
pStmt
->
last
=
STMT_INIT
;
pStmt
->
numOfRows
=
0
;
registerSqlObj
(
pSql
);
registerSqlObj
(
pSql
);
return
pStmt
;
return
pStmt
;
...
@@ -1564,9 +1571,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
...
@@ -1564,9 +1571,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
}
}
pRes
->
qId
=
0
;
pRes
->
qId
=
0
;
pRes
->
numOfRows
=
1
;
pRes
->
numOfRows
=
0
;
registerSqlObj
(
pSql
);
strtolower
(
pSql
->
sqlstr
,
sql
);
strtolower
(
pSql
->
sqlstr
,
sql
);
tscDebugL
(
"0x%"
PRIx64
" SQL: %s"
,
pSql
->
self
,
pSql
->
sqlstr
);
tscDebugL
(
"0x%"
PRIx64
" SQL: %s"
,
pSql
->
self
,
pSql
->
sqlstr
);
...
@@ -1981,6 +1986,7 @@ int taos_stmt_execute(TAOS_STMT* stmt) {
...
@@ -1981,6 +1986,7 @@ int taos_stmt_execute(TAOS_STMT* stmt) {
}
else
{
}
else
{
taosReleaseRef
(
tscObjRef
,
pStmt
->
pSql
->
self
);
taosReleaseRef
(
tscObjRef
,
pStmt
->
pSql
->
self
);
pStmt
->
pSql
=
taos_query
((
TAOS
*
)
pStmt
->
taos
,
sql
);
pStmt
->
pSql
=
taos_query
((
TAOS
*
)
pStmt
->
taos
,
sql
);
pStmt
->
numOfRows
+=
taos_affected_rows
(
pStmt
->
pSql
);
ret
=
taos_errno
(
pStmt
->
pSql
);
ret
=
taos_errno
(
pStmt
->
pSql
);
free
(
sql
);
free
(
sql
);
}
}
...
@@ -1989,6 +1995,17 @@ int taos_stmt_execute(TAOS_STMT* stmt) {
...
@@ -1989,6 +1995,17 @@ int taos_stmt_execute(TAOS_STMT* stmt) {
STMT_RET
(
ret
);
STMT_RET
(
ret
);
}
}
int
taos_stmt_affected_rows
(
TAOS_STMT
*
stmt
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
if
(
pStmt
==
NULL
)
{
tscError
(
"statement is invalid"
);
return
0
;
}
return
pStmt
->
numOfRows
;
}
TAOS_RES
*
taos_stmt_use_result
(
TAOS_STMT
*
stmt
)
{
TAOS_RES
*
taos_stmt_use_result
(
TAOS_STMT
*
stmt
)
{
if
(
stmt
==
NULL
)
{
if
(
stmt
==
NULL
)
{
tscError
(
"statement is invalid."
);
tscError
(
"statement is invalid."
);
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatement.java
浏览文件 @
65b415d8
...
@@ -9,6 +9,7 @@ public abstract class AbstractStatement extends WrapperImpl implements Statement
...
@@ -9,6 +9,7 @@ public abstract class AbstractStatement extends WrapperImpl implements Statement
protected
List
<
String
>
batchedArgs
;
protected
List
<
String
>
batchedArgs
;
private
int
fetchSize
;
private
int
fetchSize
;
protected
int
affectedRows
=
-
1
;
@Override
@Override
public
abstract
ResultSet
executeQuery
(
String
sql
)
throws
SQLException
;
public
abstract
ResultSet
executeQuery
(
String
sql
)
throws
SQLException
;
...
@@ -247,6 +248,7 @@ public abstract class AbstractStatement extends WrapperImpl implements Statement
...
@@ -247,6 +248,7 @@ public abstract class AbstractStatement extends WrapperImpl implements Statement
public
boolean
getMoreResults
(
int
current
)
throws
SQLException
{
public
boolean
getMoreResults
(
int
current
)
throws
SQLException
{
if
(
isClosed
())
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
this
.
affectedRows
=
-
1
;
switch
(
current
)
{
switch
(
current
)
{
case
Statement
.
CLOSE_CURRENT_RESULT
:
case
Statement
.
CLOSE_CURRENT_RESULT
:
return
false
;
return
false
;
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
浏览文件 @
65b415d8
...
@@ -23,7 +23,6 @@ public class TSDBStatement extends AbstractStatement {
...
@@ -23,7 +23,6 @@ public class TSDBStatement extends AbstractStatement {
* Status of current statement
* Status of current statement
*/
*/
private
boolean
isClosed
;
private
boolean
isClosed
;
private
int
affectedRows
=
-
1
;
private
TSDBConnection
connection
;
private
TSDBConnection
connection
;
private
TSDBResultSet
resultSet
;
private
TSDBResultSet
resultSet
;
...
@@ -80,12 +79,13 @@ public class TSDBStatement extends AbstractStatement {
...
@@ -80,12 +79,13 @@ public class TSDBStatement extends AbstractStatement {
if
(
isClosed
())
{
if
(
isClosed
())
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
}
}
// execute query
// execute query
long
pSql
=
this
.
connection
.
getConnector
().
executeQuery
(
sql
);
long
pSql
=
this
.
connection
.
getConnector
().
executeQuery
(
sql
);
// if pSql is create/insert/update/delete/alter SQL
// if pSql is create/insert/update/delete/alter SQL
if
(
this
.
connection
.
getConnector
().
isUpdateQuery
(
pSql
))
{
if
(
this
.
connection
.
getConnector
().
isUpdateQuery
(
pSql
))
{
this
.
affectedRows
=
this
.
connection
.
getConnector
().
getAffectedRows
(
pSql
);
int
rows
=
this
.
connection
.
getConnector
().
getAffectedRows
(
pSql
);
this
.
affectedRows
=
rows
==
0
?
-
1
:
this
.
connection
.
getConnector
().
getAffectedRows
(
pSql
);
this
.
connection
.
getConnector
().
freeResultSet
(
pSql
);
this
.
connection
.
getConnector
().
freeResultSet
(
pSql
);
return
false
;
return
false
;
}
}
...
@@ -99,7 +99,7 @@ public class TSDBStatement extends AbstractStatement {
...
@@ -99,7 +99,7 @@ public class TSDBStatement extends AbstractStatement {
if
(
isClosed
())
{
if
(
isClosed
())
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
}
}
return
this
.
resultSet
;
return
this
.
resultSet
;
}
}
...
@@ -113,14 +113,14 @@ public class TSDBStatement extends AbstractStatement {
...
@@ -113,14 +113,14 @@ public class TSDBStatement extends AbstractStatement {
if
(
isClosed
())
{
if
(
isClosed
())
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
}
}
if
(
this
.
connection
.
getConnector
()
==
null
)
{
if
(
this
.
connection
.
getConnector
()
==
null
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
);
}
}
return
this
.
connection
;
return
this
.
connection
;
}
}
public
void
setConnection
(
TSDBConnection
connection
)
{
public
void
setConnection
(
TSDBConnection
connection
)
{
this
.
connection
=
connection
;
this
.
connection
=
connection
;
}
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
浏览文件 @
65b415d8
...
@@ -22,7 +22,6 @@ public class RestfulStatement extends AbstractStatement {
...
@@ -22,7 +22,6 @@ public class RestfulStatement extends AbstractStatement {
private
final
RestfulConnection
conn
;
private
final
RestfulConnection
conn
;
private
volatile
RestfulResultSet
resultSet
;
private
volatile
RestfulResultSet
resultSet
;
private
volatile
int
affectedRows
;
public
RestfulStatement
(
RestfulConnection
conn
,
String
database
)
{
public
RestfulStatement
(
RestfulConnection
conn
,
String
database
)
{
this
.
conn
=
conn
;
this
.
conn
=
conn
;
...
@@ -118,7 +117,7 @@ public class RestfulStatement extends AbstractStatement {
...
@@ -118,7 +117,7 @@ public class RestfulStatement extends AbstractStatement {
throw
TSDBError
.
createSQLException
(
resultJson
.
getInteger
(
"code"
),
resultJson
.
getString
(
"desc"
));
throw
TSDBError
.
createSQLException
(
resultJson
.
getInteger
(
"code"
),
resultJson
.
getString
(
"desc"
));
}
}
this
.
resultSet
=
new
RestfulResultSet
(
database
,
this
,
resultJson
);
this
.
resultSet
=
new
RestfulResultSet
(
database
,
this
,
resultJson
);
this
.
affectedRows
=
0
;
this
.
affectedRows
=
-
1
;
return
resultSet
;
return
resultSet
;
}
}
...
@@ -140,9 +139,10 @@ public class RestfulStatement extends AbstractStatement {
...
@@ -140,9 +139,10 @@ public class RestfulStatement extends AbstractStatement {
if
(
head
.
size
()
!=
1
||
!
"affected_rows"
.
equals
(
head
.
getString
(
0
)))
if
(
head
.
size
()
!=
1
||
!
"affected_rows"
.
equals
(
head
.
getString
(
0
)))
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
JSONArray
data
=
jsonObject
.
getJSONArray
(
"data"
);
JSONArray
data
=
jsonObject
.
getJSONArray
(
"data"
);
if
(
data
!=
null
)
if
(
data
!=
null
)
{
return
data
.
getJSONArray
(
0
).
getInteger
(
0
);
int
rows
=
data
.
getJSONArray
(
0
).
getInteger
(
0
);
return
rows
==
0
?
-
1
:
data
.
getJSONArray
(
0
).
getInteger
(
0
);
}
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
}
}
...
...
src/inc/taos.h
浏览文件 @
65b415d8
...
@@ -141,6 +141,7 @@ DLL_EXPORT int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIN
...
@@ -141,6 +141,7 @@ DLL_EXPORT int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIN
DLL_EXPORT
int
taos_stmt_bind_single_param_batch
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
,
int
colIdx
);
DLL_EXPORT
int
taos_stmt_bind_single_param_batch
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
,
int
colIdx
);
DLL_EXPORT
int
taos_stmt_add_batch
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
int
taos_stmt_add_batch
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
int
taos_stmt_execute
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
int
taos_stmt_execute
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
int
taos_stmt_affected_rows
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
TAOS_RES
*
taos_stmt_use_result
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
TAOS_RES
*
taos_stmt_use_result
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
int
taos_stmt_close
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
int
taos_stmt_close
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
char
*
taos_stmt_errstr
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
char
*
taos_stmt_errstr
(
TAOS_STMT
*
stmt
);
...
...
src/kit/taosdemo/taosdemo.c
浏览文件 @
65b415d8
...
@@ -56,6 +56,7 @@
...
@@ -56,6 +56,7 @@
#define REQ_EXTRA_BUF_LEN 1024
#define REQ_EXTRA_BUF_LEN 1024
#define RESP_BUF_LEN 4096
#define RESP_BUF_LEN 4096
#define SQL_BUFF_LEN 1024
extern
char
configDir
[];
extern
char
configDir
[];
...
@@ -66,6 +67,7 @@ extern char configDir[];
...
@@ -66,6 +67,7 @@ extern char configDir[];
#define HEAD_BUFF_LEN TSDB_MAX_COLUMNS*24 // 16*MAX_COLUMNS + (192+32)*2 + insert into ..
#define HEAD_BUFF_LEN TSDB_MAX_COLUMNS*24 // 16*MAX_COLUMNS + (192+32)*2 + insert into ..
#define BUFFER_SIZE TSDB_MAX_ALLOWED_SQL_LEN
#define BUFFER_SIZE TSDB_MAX_ALLOWED_SQL_LEN
#define FETCH_BUFFER_SIZE 100 * TSDB_MAX_ALLOWED_SQL_LEN
#define COND_BUF_LEN (BUFFER_SIZE - 30)
#define COND_BUF_LEN (BUFFER_SIZE - 30)
#define COL_BUFFER_LEN ((TSDB_COL_NAME_LEN + 15) * TSDB_MAX_COLUMNS)
#define COL_BUFFER_LEN ((TSDB_COL_NAME_LEN + 15) * TSDB_MAX_COLUMNS)
...
@@ -87,6 +89,7 @@ extern char configDir[];
...
@@ -87,6 +89,7 @@ extern char configDir[];
#define FLOAT_BUFF_LEN 22
#define FLOAT_BUFF_LEN 22
#define DOUBLE_BUFF_LEN 42
#define DOUBLE_BUFF_LEN 42
#define TIMESTAMP_BUFF_LEN 21
#define TIMESTAMP_BUFF_LEN 21
#define PRINT_STAT_INTERVAL 30*1000
#define MAX_SAMPLES 10000
#define MAX_SAMPLES 10000
#define MAX_NUM_COLUMNS (TSDB_MAX_COLUMNS - 1) // exclude first column timestamp
#define MAX_NUM_COLUMNS (TSDB_MAX_COLUMNS - 1) // exclude first column timestamp
...
@@ -97,8 +100,10 @@ extern char configDir[];
...
@@ -97,8 +100,10 @@ extern char configDir[];
#define MAX_QUERY_SQL_COUNT 100
#define MAX_QUERY_SQL_COUNT 100
#define MAX_DATABASE_COUNT 256
#define MAX_DATABASE_COUNT 256
#define
INPUT_BUF_LEN 256
#define
MAX_JSON_BUFF 6400000
#define INPUT_BUF_LEN 256
#define EXTRA_SQL_LEN 256
#define TBNAME_PREFIX_LEN (TSDB_TABLE_NAME_LEN - 20) // 20 characters reserved for seq
#define TBNAME_PREFIX_LEN (TSDB_TABLE_NAME_LEN - 20) // 20 characters reserved for seq
#define SMALL_BUFF_LEN 8
#define SMALL_BUFF_LEN 8
#define DATATYPE_BUFF_LEN (SMALL_BUFF_LEN*3)
#define DATATYPE_BUFF_LEN (SMALL_BUFF_LEN*3)
...
@@ -109,6 +114,45 @@ extern char configDir[];
...
@@ -109,6 +114,45 @@ extern char configDir[];
#define DEFAULT_INTERLACE_ROWS 0
#define DEFAULT_INTERLACE_ROWS 0
#define DEFAULT_DATATYPE_NUM 1
#define DEFAULT_DATATYPE_NUM 1
#define DEFAULT_CHILDTABLES 10000
#define DEFAULT_CHILDTABLES 10000
#define DEFAULT_TEST_MODE 0
#define DEFAULT_METAFILE NULL
#define DEFAULT_SQLFILE NULL
#define DEFAULT_HOST "localhost"
#define DEFAULT_PORT 6030
#define DEFAULT_IFACE INTERFACE_BUT
#define DEFAULT_DATABASE "test"
#define DEFAULT_REPLICA 1
#define DEFAULT_TB_PREFIX "d"
#define DEFAULT_ESCAPE_CHAR false
#define DEFAULT_USE_METRIC true
#define DEFAULT_DROP_DB true
#define DEFAULT_AGGR_FUNC false
#define DEFAULT_DEBUG false
#define DEFAULT_VERBOSE false
#define DEFAULT_PERF_STAT false
#define DEFAULT_ANS_YES false
#define DEFAULT_OUTPUT "./output.txt"
#define DEFAULT_SYNC_MODE 0
#define DEFAULT_DATA_TYPE {TSDB_DATA_TYPE_FLOAT,TSDB_DATA_TYPE_INT,TSDB_DATA_TYPE_FLOAT}
#define DEFAULT_DATATYPE {"FLOAT","INT","FLOAT"}
#define DEFAULT_BINWIDTH 64
#define DEFAULT_COL_COUNT 4
#define DEFAULT_LEN_ONE_ROW 76
#define DEFAULT_INSERT_INTERVAL 0
#define DEFAULT_QUERY_TIME 1
#define DEFAULT_PREPARED_RAND 10000
#define DEFAULT_REQ_PER_REQ 30000
#define DEFAULT_INSERT_ROWS 10000
#define DEFAULT_ABORT 0
#define DEFAULT_RATIO 0
#define DEFAULT_DISORDER_RANGE 1000
#define DEFAULT_METHOD_DEL 1
#define DEFAULT_TOTAL_INSERT 0
#define DEFAULT_TOTAL_AFFECT 0
#define DEFAULT_DEMO_MODE true
#define DEFAULT_CREATE_BATCH 10
#define DEFAULT_SUB_INTERVAL 10000
#define DEFAULT_QUERY_INTERVAL 10000
#define STMT_BIND_PARAM_BATCH 1
#define STMT_BIND_PARAM_BATCH 1
...
@@ -147,6 +191,7 @@ enum enum_TAOS_INTERFACE {
...
@@ -147,6 +191,7 @@ enum enum_TAOS_INTERFACE {
TAOSC_IFACE
,
TAOSC_IFACE
,
REST_IFACE
,
REST_IFACE
,
STMT_IFACE
,
STMT_IFACE
,
SML_IFACE
,
INTERFACE_BUT
INTERFACE_BUT
};
};
...
@@ -245,6 +290,7 @@ typedef struct SArguments_S {
...
@@ -245,6 +290,7 @@ typedef struct SArguments_S {
uint64_t
insert_interval
;
uint64_t
insert_interval
;
uint64_t
timestamp_step
;
uint64_t
timestamp_step
;
int64_t
query_times
;
int64_t
query_times
;
int64_t
prepared_rand
;
uint32_t
interlaceRows
;
uint32_t
interlaceRows
;
uint32_t
reqPerReq
;
// num_of_records_per_req
uint32_t
reqPerReq
;
// num_of_records_per_req
uint64_t
max_sql_len
;
uint64_t
max_sql_len
;
...
@@ -366,7 +412,7 @@ typedef struct SDataBase_S {
...
@@ -366,7 +412,7 @@ typedef struct SDataBase_S {
bool
drop
;
// 0: use exists, 1: if exists, drop then new create
bool
drop
;
// 0: use exists, 1: if exists, drop then new create
SDbCfg
dbCfg
;
SDbCfg
dbCfg
;
uint64_t
superTblCount
;
uint64_t
superTblCount
;
SSuperTable
superTbls
[
MAX_SUPER_TABLE_COUNT
]
;
SSuperTable
*
superTbls
;
}
SDataBase
;
}
SDataBase
;
typedef
struct
SDbs_S
{
typedef
struct
SDbs_S
{
...
@@ -385,12 +431,11 @@ typedef struct SDbs_S {
...
@@ -385,12 +431,11 @@ typedef struct SDbs_S {
uint32_t
threadCount
;
uint32_t
threadCount
;
uint32_t
threadCountForCreateTbl
;
uint32_t
threadCountForCreateTbl
;
uint32_t
dbCount
;
uint32_t
dbCount
;
SDataBase
db
[
MAX_DB_COUNT
];
// statistics
// statistics
uint64_t
totalInsertRows
;
uint64_t
totalInsertRows
;
uint64_t
totalAffectedRows
;
uint64_t
totalAffectedRows
;
SDataBase
*
db
;
}
SDbs
;
}
SDbs
;
typedef
struct
SpecifiedQueryInfo_S
{
typedef
struct
SpecifiedQueryInfo_S
{
...
@@ -466,7 +511,7 @@ typedef struct SThreadInfo_S {
...
@@ -466,7 +511,7 @@ typedef struct SThreadInfo_S {
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
[
TSDB_FILENAME_LEN
];
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
;
...
@@ -504,6 +549,7 @@ typedef struct SThreadInfo_S {
...
@@ -504,6 +549,7 @@ typedef struct SThreadInfo_S {
uint64_t
querySeq
;
// sequence number of sql command
uint64_t
querySeq
;
// sequence number of sql command
TAOS_SUB
*
tsub
;
TAOS_SUB
*
tsub
;
char
**
lines
;
int
sockfd
;
int
sockfd
;
}
threadInfo
;
}
threadInfo
;
...
@@ -593,12 +639,12 @@ static int regexMatch(const char *s, const char *reg, int cflags);
...
@@ -593,12 +639,12 @@ static int regexMatch(const char *s, const char *reg, int cflags);
/* ************ Global variables ************ */
/* ************ Global variables ************ */
int32_t
g_randint
[
MAX_PREPARED_RAND
]
;
int32_t
*
g_randint
;
uint32_t
g_randuint
[
MAX_PREPARED_RAND
]
;
uint32_t
*
g_randuint
;
int64_t
g_randbigint
[
MAX_PREPARED_RAND
]
;
int64_t
*
g_randbigint
;
uint64_t
g_randubigint
[
MAX_PREPARED_RAND
]
;
uint64_t
*
g_randubigint
;
float
g_randfloat
[
MAX_PREPARED_RAND
]
;
float
*
g_randfloat
;
double
g_randdouble
[
MAX_PREPARED_RAND
]
;
double
*
g_randdouble
;
char
*
g_randbool_buff
=
NULL
;
char
*
g_randbool_buff
=
NULL
;
char
*
g_randint_buff
=
NULL
;
char
*
g_randint_buff
=
NULL
;
...
@@ -622,62 +668,49 @@ char *g_aggreFunc[] = {"*", "count(*)", "avg(C0)", "sum(C0)",
...
@@ -622,62 +668,49 @@ char *g_aggreFunc[] = {"*", "count(*)", "avg(C0)", "sum(C0)",
"max(C0)"
,
"min(C0)"
,
"first(C0)"
,
"last(C0)"
};
"max(C0)"
,
"min(C0)"
,
"first(C0)"
,
"last(C0)"
};
SArguments
g_args
=
{
SArguments
g_args
=
{
NULL
,
// metaFile
DEFAULT_METAFILE
,
// metaFile
0
,
// test_mode
DEFAULT_TEST_MODE
,
// test_mode
"localhost"
,
// host
DEFAULT_HOST
,
// host
6030
,
// port
DEFAULT_PORT
,
// port
INTERFACE_BUT
,
// iface
DEFAULT_IFACE
,
// iface
"root"
,
// user
TSDB_DEFAULT_USER
,
// user
#ifdef _TD_POWER_
TSDB_DEFAULT_PASS
,
// password
"powerdb"
,
// password
DEFAULT_DATABASE
,
// database
#elif (_TD_TQ_ == true)
DEFAULT_REPLICA
,
// replica
"tqueue"
,
// password
DEFAULT_TB_PREFIX
,
// tb_prefix
#elif (_TD_PRO_ == true)
DEFAULT_ESCAPE_CHAR
,
// escapeChar
"prodb"
,
// password
DEFAULT_SQLFILE
,
// sqlFile
#else
DEFAULT_USE_METRIC
,
// use_metric
"taosdata"
,
// password
DEFAULT_DROP_DB
,
// drop_database
#endif
DEFAULT_AGGR_FUNC
,
// aggr_func
"test"
,
// database
DEFAULT_DEBUG
,
// debug_print
1
,
// replica
DEFAULT_VERBOSE
,
// verbose_print
"d"
,
// tb_prefix
DEFAULT_PERF_STAT
,
// performance statistic print
false
,
// escapeChar
DEFAULT_ANS_YES
,
// answer_yes;
NULL
,
// sqlFile
DEFAULT_OUTPUT
,
// output_file
true
,
// use_metric
DEFAULT_SYNC_MODE
,
// mode : sync or async
true
,
// drop_database
DEFAULT_DATA_TYPE
,
// data_type
false
,
// aggr_func
DEFAULT_DATATYPE
,
// dataType
false
,
// debug_print
DEFAULT_BINWIDTH
,
// binwidth
false
,
// verbose_print
DEFAULT_COL_COUNT
,
// columnCount, timestamp + float + int + float
false
,
// performance statistic print
DEFAULT_LEN_ONE_ROW
,
// lenOfOneRow
false
,
// answer_yes;
DEFAULT_NTHREADS
,
// nthreads
"./output.txt"
,
// output_file
DEFAULT_INSERT_INTERVAL
,
// insert_interval
0
,
// mode : sync or async
DEFAULT_TIMESTAMP_STEP
,
// timestamp_step
{
TSDB_DATA_TYPE_FLOAT
,
DEFAULT_QUERY_TIME
,
// query_times
TSDB_DATA_TYPE_INT
,
DEFAULT_PREPARED_RAND
,
// prepared_rand
TSDB_DATA_TYPE_FLOAT
},
DEFAULT_INTERLACE_ROWS
,
// interlaceRows;
{
DEFAULT_REQ_PER_REQ
,
// reqPerReq
"FLOAT"
,
// dataType
TSDB_MAX_ALLOWED_SQL_LEN
,
// max_sql_len
"INT"
,
// dataType
DEFAULT_CHILDTABLES
,
// ntables
"FLOAT"
,
// dataType. demo mode has 3 columns
DEFAULT_INSERT_ROWS
,
// insertRows
},
DEFAULT_ABORT
,
// abort
64
,
// binwidth
DEFAULT_RATIO
,
// disorderRatio
4
,
// columnCount, timestamp + float + int + float
DEFAULT_DISORDER_RANGE
,
// disorderRange
20
+
FLOAT_BUFF_LEN
+
INT_BUFF_LEN
+
FLOAT_BUFF_LEN
,
// lenOfOneRow
DEFAULT_METHOD_DEL
,
// method_of_delete
DEFAULT_NTHREADS
,
// nthreads
DEFAULT_TOTAL_INSERT
,
// totalInsertRows;
0
,
// insert_interval
DEFAULT_TOTAL_AFFECT
,
// totalAffectedRows;
DEFAULT_TIMESTAMP_STEP
,
// timestamp_step
DEFAULT_DEMO_MODE
,
// demo_mode;
1
,
// query_times
DEFAULT_INTERLACE_ROWS
,
// interlaceRows;
30000
,
// reqPerReq
(
1024
*
1024
),
// max_sql_len
DEFAULT_CHILDTABLES
,
// ntables
10000
,
// insertRows
0
,
// abort
0
,
// disorderRatio
1000
,
// disorderRange
1
,
// method_of_delete
0
,
// totalInsertRows;
0
,
// totalAffectedRows;
true
,
// demo_mode;
};
};
static
SDbs
g_Dbs
;
static
SDbs
g_Dbs
;
...
@@ -732,7 +765,7 @@ static FILE * g_fpOfInsertResult = NULL;
...
@@ -732,7 +765,7 @@ static FILE * g_fpOfInsertResult = NULL;
///////////////////////////////////////////////////
///////////////////////////////////////////////////
static
void
ERROR_EXIT
(
const
char
*
msg
)
{
errorPrint
(
"%s"
,
msg
);
exit
(
-
1
);
}
static
void
ERROR_EXIT
(
const
char
*
msg
)
{
errorPrint
(
"%s"
,
msg
);
exit
(
EXIT_FAILURE
);
}
#ifndef TAOSDEMO_COMMIT_SHA1
#ifndef TAOSDEMO_COMMIT_SHA1
#define TAOSDEMO_COMMIT_SHA1 "unknown"
#define TAOSDEMO_COMMIT_SHA1 "unknown"
...
@@ -1054,6 +1087,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1054,6 +1087,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments
->
iface
=
REST_IFACE
;
arguments
->
iface
=
REST_IFACE
;
}
else
if
(
0
==
strcasecmp
(
argv
[
i
+
1
],
"stmt"
))
{
}
else
if
(
0
==
strcasecmp
(
argv
[
i
+
1
],
"stmt"
))
{
arguments
->
iface
=
STMT_IFACE
;
arguments
->
iface
=
STMT_IFACE
;
}
else
if
(
0
==
strcasecmp
(
argv
[
i
+
1
],
"sml"
))
{
arguments
->
iface
=
SML_IFACE
;
}
else
{
}
else
{
errorWrongValue
(
argv
[
0
],
"-I"
,
argv
[
i
+
1
]);
errorWrongValue
(
argv
[
0
],
"-I"
,
argv
[
i
+
1
]);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -1066,6 +1101,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1066,6 +1101,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments
->
iface
=
REST_IFACE
;
arguments
->
iface
=
REST_IFACE
;
}
else
if
(
0
==
strcasecmp
((
char
*
)(
argv
[
i
]
+
strlen
(
"--interface="
)),
"stmt"
))
{
}
else
if
(
0
==
strcasecmp
((
char
*
)(
argv
[
i
]
+
strlen
(
"--interface="
)),
"stmt"
))
{
arguments
->
iface
=
STMT_IFACE
;
arguments
->
iface
=
STMT_IFACE
;
}
else
if
(
0
==
strcasecmp
((
char
*
)(
argv
[
i
]
+
strlen
(
"--interface="
)),
"sml"
))
{
arguments
->
iface
=
SML_IFACE
;
}
else
{
}
else
{
errorPrintReqArg3
(
argv
[
0
],
"--interface"
);
errorPrintReqArg3
(
argv
[
0
],
"--interface"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -1077,6 +1114,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1077,6 +1114,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments
->
iface
=
REST_IFACE
;
arguments
->
iface
=
REST_IFACE
;
}
else
if
(
0
==
strcasecmp
((
char
*
)(
argv
[
i
]
+
strlen
(
"-I"
)),
"stmt"
))
{
}
else
if
(
0
==
strcasecmp
((
char
*
)(
argv
[
i
]
+
strlen
(
"-I"
)),
"stmt"
))
{
arguments
->
iface
=
STMT_IFACE
;
arguments
->
iface
=
STMT_IFACE
;
}
else
if
(
0
==
strcasecmp
((
char
*
)(
argv
[
i
]
+
strlen
(
"-I"
)),
"sml"
))
{
arguments
->
iface
=
SML_IFACE
;
}
else
{
}
else
{
errorWrongValue
(
argv
[
0
],
"-I"
,
errorWrongValue
(
argv
[
0
],
"-I"
,
(
char
*
)(
argv
[
i
]
+
strlen
(
"-I"
)));
(
char
*
)(
argv
[
i
]
+
strlen
(
"-I"
)));
...
@@ -1093,6 +1132,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1093,6 +1132,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments
->
iface
=
REST_IFACE
;
arguments
->
iface
=
REST_IFACE
;
}
else
if
(
0
==
strcasecmp
(
argv
[
i
+
1
],
"stmt"
))
{
}
else
if
(
0
==
strcasecmp
(
argv
[
i
+
1
],
"stmt"
))
{
arguments
->
iface
=
STMT_IFACE
;
arguments
->
iface
=
STMT_IFACE
;
}
else
if
(
0
==
strcasecmp
(
argv
[
i
+
1
],
"sml"
))
{
arguments
->
iface
=
SML_IFACE
;
}
else
{
}
else
{
errorWrongValue
(
argv
[
0
],
"--interface"
,
argv
[
i
+
1
]);
errorWrongValue
(
argv
[
0
],
"--interface"
,
argv
[
i
+
1
]);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -1999,7 +2040,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1999,7 +2040,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
}
}
g_args
.
columnCount
=
columnCount
;
g_args
.
columnCount
=
columnCount
;
g_args
.
lenOfOneRow
=
20
;
// timestamp
g_args
.
lenOfOneRow
=
TIMESTAMP_BUFF_LEN
;
// timestamp
for
(
int
c
=
0
;
c
<
g_args
.
columnCount
;
c
++
)
{
for
(
int
c
=
0
;
c
<
g_args
.
columnCount
;
c
++
)
{
switch
(
g_args
.
data_type
[
c
])
{
switch
(
g_args
.
data_type
[
c
])
{
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
...
@@ -2106,7 +2147,7 @@ static void tmfclose(FILE *fp) {
...
@@ -2106,7 +2147,7 @@ static void tmfclose(FILE *fp) {
}
}
}
}
static
void
tmfree
(
char
*
buf
)
{
static
void
tmfree
(
void
*
buf
)
{
if
(
NULL
!=
buf
)
{
if
(
NULL
!=
buf
)
{
free
(
buf
);
free
(
buf
);
buf
=
NULL
;
buf
=
NULL
;
...
@@ -2161,7 +2202,7 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) {
...
@@ -2161,7 +2202,7 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) {
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
,
FETCH_BUFFER_SIZE
);
if
(
databuf
==
NULL
)
{
if
(
databuf
==
NULL
)
{
errorPrint2
(
"%s() LN%d, failed to malloc, warning: save result to file slowly!
\n
"
,
errorPrint2
(
"%s() LN%d, failed to malloc, warning: save result to file slowly!
\n
"
,
__func__
,
__LINE__
);
__func__
,
__LINE__
);
...
@@ -2172,11 +2213,11 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) {
...
@@ -2172,11 +2213,11 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) {
// 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
-
HEAD_BUFF_LEN
*
2
))
{
if
(
totalLen
>=
(
FETCH_BUFFER_SIZE
-
HEAD_BUFF_LEN
*
2
))
{
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
,
FETCH_BUFFER_SIZE
);
}
}
num_rows
++
;
num_rows
++
;
char
temp
[
HEAD_BUFF_LEN
]
=
{
0
};
char
temp
[
HEAD_BUFF_LEN
]
=
{
0
};
...
@@ -2230,157 +2271,157 @@ static void selectAndGetResult(
...
@@ -2230,157 +2271,157 @@ static void selectAndGetResult(
static
char
*
rand_bool_str
()
{
static
char
*
rand_bool_str
()
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randbool_buff
+
((
cursor
%
MAX_PREPARED_RAND
)
*
BOOL_BUFF_LEN
);
return
g_randbool_buff
+
((
cursor
%
g_args
.
prepared_rand
)
*
BOOL_BUFF_LEN
);
}
}
static
int32_t
rand_bool
()
{
static
int32_t
rand_bool
()
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randint
[
cursor
%
MAX_PREPARED_RAND
]
%
2
;
return
g_randint
[
cursor
%
g_args
.
prepared_rand
]
%
TSDB_DATA_BOOL_NULL
;
}
}
static
char
*
rand_tinyint_str
()
static
char
*
rand_tinyint_str
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randtinyint_buff
+
return
g_randtinyint_buff
+
((
cursor
%
MAX_PREPARED_RAND
)
*
TINYINT_BUFF_LEN
);
((
cursor
%
g_args
.
prepared_rand
)
*
TINYINT_BUFF_LEN
);
}
}
static
int32_t
rand_tinyint
()
static
int32_t
rand_tinyint
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randint
[
cursor
%
MAX_PREPARED_RAND
]
%
128
;
return
g_randint
[
cursor
%
g_args
.
prepared_rand
]
%
TSDB_DATA_TINYINT_NULL
;
}
}
static
char
*
rand_utinyint_str
()
static
char
*
rand_utinyint_str
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randutinyint_buff
+
return
g_randutinyint_buff
+
((
cursor
%
MAX_PREPARED_RAND
)
*
TINYINT_BUFF_LEN
);
((
cursor
%
g_args
.
prepared_rand
)
*
TINYINT_BUFF_LEN
);
}
}
static
int32_t
rand_utinyint
()
static
int32_t
rand_utinyint
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randuint
[
cursor
%
MAX_PREPARED_RAND
]
%
255
;
return
g_randuint
[
cursor
%
g_args
.
prepared_rand
]
%
TSDB_DATA_UTINYINT_NULL
;
}
}
static
char
*
rand_smallint_str
()
static
char
*
rand_smallint_str
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randsmallint_buff
+
return
g_randsmallint_buff
+
((
cursor
%
MAX_PREPARED_RAND
)
*
SMALLINT_BUFF_LEN
);
((
cursor
%
g_args
.
prepared_rand
)
*
SMALLINT_BUFF_LEN
);
}
}
static
int32_t
rand_smallint
()
static
int32_t
rand_smallint
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randint
[
cursor
%
MAX_PREPARED_RAND
]
%
32768
;
return
g_randint
[
cursor
%
g_args
.
prepared_rand
]
%
TSDB_DATA_SMALLINT_NULL
;
}
}
static
char
*
rand_usmallint_str
()
static
char
*
rand_usmallint_str
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randusmallint_buff
+
return
g_randusmallint_buff
+
((
cursor
%
MAX_PREPARED_RAND
)
*
SMALLINT_BUFF_LEN
);
((
cursor
%
g_args
.
prepared_rand
)
*
SMALLINT_BUFF_LEN
);
}
}
static
int32_t
rand_usmallint
()
static
int32_t
rand_usmallint
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randuint
[
cursor
%
MAX_PREPARED_RAND
]
%
65535
;
return
g_randuint
[
cursor
%
g_args
.
prepared_rand
]
%
TSDB_DATA_USMALLINT_NULL
;
}
}
static
char
*
rand_int_str
()
static
char
*
rand_int_str
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randint_buff
+
((
cursor
%
MAX_PREPARED_RAND
)
*
INT_BUFF_LEN
);
return
g_randint_buff
+
((
cursor
%
g_args
.
prepared_rand
)
*
INT_BUFF_LEN
);
}
}
static
int32_t
rand_int
()
static
int32_t
rand_int
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randint
[
cursor
%
MAX_PREPARED_RAND
];
return
g_randint
[
cursor
%
g_args
.
prepared_rand
];
}
}
static
char
*
rand_uint_str
()
static
char
*
rand_uint_str
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randuint_buff
+
((
cursor
%
MAX_PREPARED_RAND
)
*
INT_BUFF_LEN
);
return
g_randuint_buff
+
((
cursor
%
g_args
.
prepared_rand
)
*
INT_BUFF_LEN
);
}
}
static
int32_t
rand_uint
()
static
int32_t
rand_uint
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randuint
[
cursor
%
MAX_PREPARED_RAND
];
return
g_randuint
[
cursor
%
g_args
.
prepared_rand
];
}
}
static
char
*
rand_bigint_str
()
static
char
*
rand_bigint_str
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randbigint_buff
+
return
g_randbigint_buff
+
((
cursor
%
MAX_PREPARED_RAND
)
*
BIGINT_BUFF_LEN
);
((
cursor
%
g_args
.
prepared_rand
)
*
BIGINT_BUFF_LEN
);
}
}
static
int64_t
rand_bigint
()
static
int64_t
rand_bigint
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randbigint
[
cursor
%
MAX_PREPARED_RAND
];
return
g_randbigint
[
cursor
%
g_args
.
prepared_rand
];
}
}
static
char
*
rand_ubigint_str
()
static
char
*
rand_ubigint_str
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randubigint_buff
+
return
g_randubigint_buff
+
((
cursor
%
MAX_PREPARED_RAND
)
*
BIGINT_BUFF_LEN
);
((
cursor
%
g_args
.
prepared_rand
)
*
BIGINT_BUFF_LEN
);
}
}
static
int64_t
rand_ubigint
()
static
int64_t
rand_ubigint
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randubigint
[
cursor
%
MAX_PREPARED_RAND
];
return
g_randubigint
[
cursor
%
g_args
.
prepared_rand
];
}
}
static
char
*
rand_float_str
()
static
char
*
rand_float_str
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randfloat_buff
+
((
cursor
%
MAX_PREPARED_RAND
)
*
FLOAT_BUFF_LEN
);
return
g_randfloat_buff
+
((
cursor
%
g_args
.
prepared_rand
)
*
FLOAT_BUFF_LEN
);
}
}
...
@@ -2388,58 +2429,58 @@ static float rand_float()
...
@@ -2388,58 +2429,58 @@ static float rand_float()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randfloat
[
cursor
%
MAX_PREPARED_RAND
];
return
g_randfloat
[
cursor
%
g_args
.
prepared_rand
];
}
}
static
char
*
demo_current_float_str
()
static
char
*
demo_current_float_str
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_rand_current_buff
+
return
g_rand_current_buff
+
((
cursor
%
MAX_PREPARED_RAND
)
*
FLOAT_BUFF_LEN
);
((
cursor
%
g_args
.
prepared_rand
)
*
FLOAT_BUFF_LEN
);
}
}
static
float
UNUSED_FUNC
demo_current_float
()
static
float
UNUSED_FUNC
demo_current_float
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
(
float
)(
9
.
8
+
0
.
04
*
(
g_randint
[
cursor
%
MAX_PREPARED_RAND
]
%
10
)
return
(
float
)(
9
.
8
+
0
.
04
*
(
g_randint
[
cursor
%
g_args
.
prepared_rand
]
%
10
)
+
g_randfloat
[
cursor
%
MAX_PREPARED_RAND
]
/
1000000000
);
+
g_randfloat
[
cursor
%
g_args
.
prepared_rand
]
/
1000000000
);
}
}
static
char
*
demo_voltage_int_str
()
static
char
*
demo_voltage_int_str
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_rand_voltage_buff
+
return
g_rand_voltage_buff
+
((
cursor
%
MAX_PREPARED_RAND
)
*
INT_BUFF_LEN
);
((
cursor
%
g_args
.
prepared_rand
)
*
INT_BUFF_LEN
);
}
}
static
int32_t
UNUSED_FUNC
demo_voltage_int
()
static
int32_t
UNUSED_FUNC
demo_voltage_int
()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
215
+
g_randint
[
cursor
%
MAX_PREPARED_RAND
]
%
10
;
return
215
+
g_randint
[
cursor
%
g_args
.
prepared_rand
]
%
10
;
}
}
static
char
*
demo_phase_float_str
()
{
static
char
*
demo_phase_float_str
()
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_rand_phase_buff
+
((
cursor
%
MAX_PREPARED_RAND
)
*
FLOAT_BUFF_LEN
);
return
g_rand_phase_buff
+
((
cursor
%
g_args
.
prepared_rand
)
*
FLOAT_BUFF_LEN
);
}
}
static
float
UNUSED_FUNC
demo_phase_float
()
{
static
float
UNUSED_FUNC
demo_phase_float
()
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
(
float
)((
115
+
g_randint
[
cursor
%
MAX_PREPARED_RAND
]
%
10
return
(
float
)((
115
+
g_randint
[
cursor
%
g_args
.
prepared_rand
]
%
10
+
g_randfloat
[
cursor
%
MAX_PREPARED_RAND
]
/
1000000000
)
/
360
);
+
g_randfloat
[
cursor
%
g_args
.
prepared_rand
]
/
1000000000
)
/
360
);
}
}
#if 0
#if 0
...
@@ -2467,7 +2508,7 @@ static void rand_string(char *str, int size) {
...
@@ -2467,7 +2508,7 @@ static void rand_string(char *str, int size) {
//--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
(
taosRandom
())
%
(
int
)(
sizeof
(
charset
)
-
1
);
str
[
n
]
=
charset
[
key
];
str
[
n
]
=
charset
[
key
];
}
}
str
[
n
]
=
0
;
str
[
n
]
=
0
;
...
@@ -2478,7 +2519,7 @@ static char *rand_double_str()
...
@@ -2478,7 +2519,7 @@ static char *rand_double_str()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
if
(
cursor
>
(
MAX_PREPARED_RAND
-
1
))
cursor
=
0
;
if
(
cursor
>
(
g_args
.
prepared_rand
-
1
))
cursor
=
0
;
return
g_randdouble_buff
+
(
cursor
*
DOUBLE_BUFF_LEN
);
return
g_randdouble_buff
+
(
cursor
*
DOUBLE_BUFF_LEN
);
}
}
...
@@ -2486,42 +2527,54 @@ static double rand_double()
...
@@ -2486,42 +2527,54 @@ static double rand_double()
{
{
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
cursor
=
cursor
%
MAX_PREPARED_RAND
;
cursor
=
cursor
%
g_args
.
prepared_rand
;
return
g_randdouble
[
cursor
];
return
g_randdouble
[
cursor
];
}
}
static
void
init_rand_data
()
{
static
void
init_rand_data
()
{
g_randint_buff
=
calloc
(
1
,
INT_BUFF_LEN
*
MAX_PREPARED_RAND
);
g_randint_buff
=
calloc
(
1
,
INT_BUFF_LEN
*
g_args
.
prepared_rand
);
assert
(
g_randint_buff
);
assert
(
g_randint_buff
);
g_rand_voltage_buff
=
calloc
(
1
,
INT_BUFF_LEN
*
MAX_PREPARED_RAND
);
g_rand_voltage_buff
=
calloc
(
1
,
INT_BUFF_LEN
*
g_args
.
prepared_rand
);
assert
(
g_rand_voltage_buff
);
assert
(
g_rand_voltage_buff
);
g_randbigint_buff
=
calloc
(
1
,
BIGINT_BUFF_LEN
*
MAX_PREPARED_RAND
);
g_randbigint_buff
=
calloc
(
1
,
BIGINT_BUFF_LEN
*
g_args
.
prepared_rand
);
assert
(
g_randbigint_buff
);
assert
(
g_randbigint_buff
);
g_randsmallint_buff
=
calloc
(
1
,
SMALLINT_BUFF_LEN
*
MAX_PREPARED_RAND
);
g_randsmallint_buff
=
calloc
(
1
,
SMALLINT_BUFF_LEN
*
g_args
.
prepared_rand
);
assert
(
g_randsmallint_buff
);
assert
(
g_randsmallint_buff
);
g_randtinyint_buff
=
calloc
(
1
,
TINYINT_BUFF_LEN
*
MAX_PREPARED_RAND
);
g_randtinyint_buff
=
calloc
(
1
,
TINYINT_BUFF_LEN
*
g_args
.
prepared_rand
);
assert
(
g_randtinyint_buff
);
assert
(
g_randtinyint_buff
);
g_randbool_buff
=
calloc
(
1
,
BOOL_BUFF_LEN
*
MAX_PREPARED_RAND
);
g_randbool_buff
=
calloc
(
1
,
BOOL_BUFF_LEN
*
g_args
.
prepared_rand
);
assert
(
g_randbool_buff
);
assert
(
g_randbool_buff
);
g_randfloat_buff
=
calloc
(
1
,
FLOAT_BUFF_LEN
*
MAX_PREPARED_RAND
);
g_randfloat_buff
=
calloc
(
1
,
FLOAT_BUFF_LEN
*
g_args
.
prepared_rand
);
assert
(
g_randfloat_buff
);
assert
(
g_randfloat_buff
);
g_rand_current_buff
=
calloc
(
1
,
FLOAT_BUFF_LEN
*
MAX_PREPARED_RAND
);
g_rand_current_buff
=
calloc
(
1
,
FLOAT_BUFF_LEN
*
g_args
.
prepared_rand
);
assert
(
g_rand_current_buff
);
assert
(
g_rand_current_buff
);
g_rand_phase_buff
=
calloc
(
1
,
FLOAT_BUFF_LEN
*
MAX_PREPARED_RAND
);
g_rand_phase_buff
=
calloc
(
1
,
FLOAT_BUFF_LEN
*
g_args
.
prepared_rand
);
assert
(
g_rand_phase_buff
);
assert
(
g_rand_phase_buff
);
g_randdouble_buff
=
calloc
(
1
,
DOUBLE_BUFF_LEN
*
MAX_PREPARED_RAND
);
g_randdouble_buff
=
calloc
(
1
,
DOUBLE_BUFF_LEN
*
g_args
.
prepared_rand
);
assert
(
g_randdouble_buff
);
assert
(
g_randdouble_buff
);
g_randuint_buff
=
calloc
(
1
,
INT_BUFF_LEN
*
MAX_PREPARED_RAND
);
g_randuint_buff
=
calloc
(
1
,
INT_BUFF_LEN
*
g_args
.
prepared_rand
);
assert
(
g_randuint_buff
);
assert
(
g_randuint_buff
);
g_randutinyint_buff
=
calloc
(
1
,
TINYINT_BUFF_LEN
*
MAX_PREPARED_RAND
);
g_randutinyint_buff
=
calloc
(
1
,
TINYINT_BUFF_LEN
*
g_args
.
prepared_rand
);
assert
(
g_randutinyint_buff
);
assert
(
g_randutinyint_buff
);
g_randusmallint_buff
=
calloc
(
1
,
SMALLINT_BUFF_LEN
*
MAX_PREPARED_RAND
);
g_randusmallint_buff
=
calloc
(
1
,
SMALLINT_BUFF_LEN
*
g_args
.
prepared_rand
);
assert
(
g_randusmallint_buff
);
assert
(
g_randusmallint_buff
);
g_randubigint_buff
=
calloc
(
1
,
BIGINT_BUFF_LEN
*
MAX_PREPARED_RAND
);
g_randubigint_buff
=
calloc
(
1
,
BIGINT_BUFF_LEN
*
g_args
.
prepared_rand
);
assert
(
g_randubigint_buff
);
assert
(
g_randubigint_buff
);
g_randint
=
calloc
(
1
,
sizeof
(
int32_t
)
*
g_args
.
prepared_rand
);
for
(
int
i
=
0
;
i
<
MAX_PREPARED_RAND
;
i
++
)
{
assert
(
g_randint
);
g_randuint
=
calloc
(
1
,
sizeof
(
uint32_t
)
*
g_args
.
prepared_rand
);
assert
(
g_randuint
);
g_randbigint
=
calloc
(
1
,
sizeof
(
int64_t
)
*
g_args
.
prepared_rand
);
assert
(
g_randbigint
);
g_randubigint
=
calloc
(
1
,
sizeof
(
uint64_t
)
*
g_args
.
prepared_rand
);
assert
(
g_randubigint
);
g_randfloat
=
calloc
(
1
,
sizeof
(
float
)
*
g_args
.
prepared_rand
);
assert
(
g_randfloat
);
g_randdouble
=
calloc
(
1
,
sizeof
(
double
)
*
g_args
.
prepared_rand
);
assert
(
g_randdouble
);
for
(
int
i
=
0
;
i
<
g_args
.
prepared_rand
;
i
++
)
{
g_randint
[
i
]
=
(
int
)(
taosRandom
()
%
RAND_MAX
-
(
RAND_MAX
>>
1
));
g_randint
[
i
]
=
(
int
)(
taosRandom
()
%
RAND_MAX
-
(
RAND_MAX
>>
1
));
g_randuint
[
i
]
=
(
int
)(
taosRandom
());
g_randuint
[
i
]
=
(
int
)(
taosRandom
());
sprintf
(
g_randint_buff
+
i
*
INT_BUFF_LEN
,
"%d"
,
sprintf
(
g_randint_buff
+
i
*
INT_BUFF_LEN
,
"%d"
,
...
@@ -2598,7 +2651,8 @@ static int printfInsertMeta() {
...
@@ -2598,7 +2651,8 @@ static int printfInsertMeta() {
// first time if no iface specified
// first time if no iface specified
printf
(
"interface:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
"interface:
\033
[33m%s
\033
[0m
\n
"
,
(
g_args
.
iface
==
TAOSC_IFACE
)
?
"taosc"
:
(
g_args
.
iface
==
TAOSC_IFACE
)
?
"taosc"
:
(
g_args
.
iface
==
REST_IFACE
)
?
"rest"
:
"stmt"
);
(
g_args
.
iface
==
REST_IFACE
)
?
"rest"
:
(
g_args
.
iface
==
STMT_IFACE
)
?
"stmt"
:
"sml"
);
}
}
printf
(
"host:
\033
[33m%s:%u
\033
[0m
\n
"
,
printf
(
"host:
\033
[33m%s:%u
\033
[0m
\n
"
,
...
@@ -2724,7 +2778,8 @@ static int printfInsertMeta() {
...
@@ -2724,7 +2778,8 @@ static int printfInsertMeta() {
g_Dbs
.
db
[
i
].
superTbls
[
j
].
dataSource
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
dataSource
);
printf
(
" iface:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
" iface:
\033
[33m%s
\033
[0m
\n
"
,
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
TAOSC_IFACE
)
?
"taosc"
:
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
TAOSC_IFACE
)
?
"taosc"
:
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
REST_IFACE
)
?
"rest"
:
"stmt"
);
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
REST_IFACE
)
?
"rest"
:
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
STMT_IFACE
)
?
"stmt"
:
"sml"
);
if
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblLimit
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblLimit
>
0
)
{
printf
(
" childTblLimit:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
printf
(
" childTblLimit:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblLimit
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblLimit
);
...
@@ -2923,7 +2978,8 @@ static void printfInsertMetaToFile(FILE* fp) {
...
@@ -2923,7 +2978,8 @@ static void printfInsertMetaToFile(FILE* fp) {
g_Dbs
.
db
[
i
].
superTbls
[
j
].
dataSource
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
dataSource
);
fprintf
(
fp
,
" iface: %s
\n
"
,
fprintf
(
fp
,
" iface: %s
\n
"
,
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
TAOSC_IFACE
)
?
"taosc"
:
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
TAOSC_IFACE
)
?
"taosc"
:
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
REST_IFACE
)
?
"rest"
:
"stmt"
);
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
REST_IFACE
)
?
"rest"
:
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
STMT_IFACE
)
?
"stmt"
:
"sml"
);
fprintf
(
fp
,
" insertRows: %"
PRId64
"
\n
"
,
fprintf
(
fp
,
" insertRows: %"
PRId64
"
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
insertRows
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
insertRows
);
fprintf
(
fp
,
" interlace rows: %u
\n
"
,
fprintf
(
fp
,
" interlace rows: %u
\n
"
,
...
@@ -3340,7 +3396,7 @@ static void printfDbInfoForQueryToFile(
...
@@ -3340,7 +3396,7 @@ static void printfDbInfoForQueryToFile(
static
void
printfQuerySystemInfo
(
TAOS
*
taos
)
{
static
void
printfQuerySystemInfo
(
TAOS
*
taos
)
{
char
filename
[
MAX_FILE_NAME_LEN
]
=
{
0
};
char
filename
[
MAX_FILE_NAME_LEN
]
=
{
0
};
char
buffer
[
1024
]
=
{
0
};
char
buffer
[
SQL_BUFF_LEN
]
=
{
0
};
TAOS_RES
*
res
;
TAOS_RES
*
res
;
time_t
t
;
time_t
t
;
...
@@ -3379,12 +3435,12 @@ static void printfQuerySystemInfo(TAOS * taos) {
...
@@ -3379,12 +3435,12 @@ static void printfQuerySystemInfo(TAOS * taos) {
printfDbInfoForQueryToFile
(
filename
,
dbInfos
[
i
],
i
);
printfDbInfoForQueryToFile
(
filename
,
dbInfos
[
i
],
i
);
// show db.vgroups
// show db.vgroups
snprintf
(
buffer
,
1024
,
"show %s.vgroups;"
,
dbInfos
[
i
]
->
name
);
snprintf
(
buffer
,
SQL_BUFF_LEN
,
"show %s.vgroups;"
,
dbInfos
[
i
]
->
name
);
res
=
taos_query
(
taos
,
buffer
);
res
=
taos_query
(
taos
,
buffer
);
xDumpResultToFile
(
filename
,
res
);
xDumpResultToFile
(
filename
,
res
);
// show db.stables
// show db.stables
snprintf
(
buffer
,
1024
,
"show %s.stables;"
,
dbInfos
[
i
]
->
name
);
snprintf
(
buffer
,
SQL_BUFF_LEN
,
"show %s.stables;"
,
dbInfos
[
i
]
->
name
);
res
=
taos_query
(
taos
,
buffer
);
res
=
taos_query
(
taos
,
buffer
);
xDumpResultToFile
(
filename
,
res
);
xDumpResultToFile
(
filename
,
res
);
free
(
dbInfos
[
i
]);
free
(
dbInfos
[
i
]);
...
@@ -3727,7 +3783,7 @@ static int calcRowLen(SSuperTable* superTbls) {
...
@@ -3727,7 +3783,7 @@ static int calcRowLen(SSuperTable* superTbls) {
}
}
}
}
superTbls
->
lenOfOneRow
=
lenOfOneRow
+
20
;
// timestamp
superTbls
->
lenOfOneRow
=
lenOfOneRow
+
TIMESTAMP_BUFF_LEN
;
// timestamp
int
tagIndex
;
int
tagIndex
;
int
lenOfTagOfOneRow
=
0
;
int
lenOfTagOfOneRow
=
0
;
...
@@ -3781,7 +3837,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
...
@@ -3781,7 +3837,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
char
*
dbName
,
char
*
stbName
,
char
**
childTblNameOfSuperTbl
,
char
*
dbName
,
char
*
stbName
,
char
**
childTblNameOfSuperTbl
,
int64_t
*
childTblCountOfSuperTbl
,
int64_t
limit
,
uint64_t
offset
,
bool
escapChar
)
{
int64_t
*
childTblCountOfSuperTbl
,
int64_t
limit
,
uint64_t
offset
,
bool
escapChar
)
{
char
command
[
1024
]
=
"
\0
"
;
char
command
[
SQL_BUFF_LEN
]
=
"
\0
"
;
char
limitBuf
[
100
]
=
"
\0
"
;
char
limitBuf
[
100
]
=
"
\0
"
;
TAOS_RES
*
res
;
TAOS_RES
*
res
;
...
@@ -3793,7 +3849,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
...
@@ -3793,7 +3849,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
limit
,
offset
);
limit
,
offset
);
//get all child table name use cmd: select tbname from superTblName;
//get all child table name use cmd: select tbname from superTblName;
snprintf
(
command
,
1024
,
escapChar
?
"select tbname from %s.`%s` %s"
:
snprintf
(
command
,
SQL_BUFF_LEN
,
escapChar
?
"select tbname from %s.`%s` %s"
:
"select tbname from %s.%s %s"
,
dbName
,
stbName
,
limitBuf
);
"select tbname from %s.%s %s"
,
dbName
,
stbName
,
limitBuf
);
res
=
taos_query
(
taos
,
command
);
res
=
taos_query
(
taos
,
command
);
...
@@ -3801,12 +3857,12 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
...
@@ -3801,12 +3857,12 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
taos_free_result
(
res
);
taos_free_result
(
res
);
taos_close
(
taos
);
taos_close
(
taos
);
errorPrint2
(
"%s() LN%d, failed to run command %s
\n
"
,
errorPrint2
(
"%s() LN%d, failed to run command %s
, reason: %s
\n
"
,
__func__
,
__LINE__
,
command
);
__func__
,
__LINE__
,
command
,
taos_errstr
(
res
)
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
int64_t
childTblCount
=
(
limit
<
0
)
?
10000
:
limit
;
int64_t
childTblCount
=
(
limit
<
0
)
?
DEFAULT_CHILDTABLES
:
limit
;
int64_t
count
=
0
;
int64_t
count
=
0
;
if
(
childTblName
==
NULL
)
{
if
(
childTblName
==
NULL
)
{
childTblName
=
(
char
*
)
calloc
(
1
,
childTblCount
*
TSDB_TABLE_NAME_LEN
);
childTblName
=
(
char
*
)
calloc
(
1
,
childTblCount
*
TSDB_TABLE_NAME_LEN
);
...
@@ -3871,17 +3927,17 @@ static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName,
...
@@ -3871,17 +3927,17 @@ static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName,
static
int
getSuperTableFromServer
(
TAOS
*
taos
,
char
*
dbName
,
static
int
getSuperTableFromServer
(
TAOS
*
taos
,
char
*
dbName
,
SSuperTable
*
superTbls
)
{
SSuperTable
*
superTbls
)
{
char
command
[
1024
]
=
"
\0
"
;
char
command
[
SQL_BUFF_LEN
]
=
"
\0
"
;
TAOS_RES
*
res
;
TAOS_RES
*
res
;
TAOS_ROW
row
=
NULL
;
TAOS_ROW
row
=
NULL
;
int
count
=
0
;
int
count
=
0
;
//get schema use cmd: describe superTblName;
//get schema use cmd: describe superTblName;
snprintf
(
command
,
1024
,
"describe %s.%s"
,
dbName
,
superTbls
->
stbName
);
snprintf
(
command
,
SQL_BUFF_LEN
,
"describe %s.%s"
,
dbName
,
superTbls
->
stbName
);
res
=
taos_query
(
taos
,
command
);
res
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
res
);
int32_t
code
=
taos_errno
(
res
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
printf
(
"failed to run command %s
\n
"
,
command
);
printf
(
"failed to run command %s
, reason: %s
\n
"
,
command
,
taos_errstr
(
res
)
);
taos_free_result
(
res
);
taos_free_result
(
res
);
return
-
1
;
return
-
1
;
}
}
...
@@ -4207,10 +4263,10 @@ static int createSuperTable(
...
@@ -4207,10 +4263,10 @@ static int createSuperTable(
}
}
}
}
superTbl
->
lenOfOneRow
=
lenOfOneRow
+
20
;
// timestamp
superTbl
->
lenOfOneRow
=
lenOfOneRow
+
TIMESTAMP_BUFF_LEN
;
// timestamp
// save for creating child table
// save for creating child table
superTbl
->
colsOfCreateChildTable
=
(
char
*
)
calloc
(
len
+
20
,
1
);
superTbl
->
colsOfCreateChildTable
=
(
char
*
)
calloc
(
len
+
TIMESTAMP_BUFF_LEN
,
1
);
if
(
NULL
==
superTbl
->
colsOfCreateChildTable
)
{
if
(
NULL
==
superTbl
->
colsOfCreateChildTable
)
{
taos_close
(
taos
);
taos_close
(
taos
);
free
(
command
);
free
(
command
);
...
@@ -4219,7 +4275,7 @@ static int createSuperTable(
...
@@ -4219,7 +4275,7 @@ static int createSuperTable(
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
snprintf
(
superTbl
->
colsOfCreateChildTable
,
len
+
20
,
"(ts timestamp%s)"
,
cols
);
snprintf
(
superTbl
->
colsOfCreateChildTable
,
len
+
TIMESTAMP_BUFF_LEN
,
"(ts timestamp%s)"
,
cols
);
verbosePrint
(
"%s() LN%d: %s
\n
"
,
verbosePrint
(
"%s() LN%d: %s
\n
"
,
__func__
,
__LINE__
,
superTbl
->
colsOfCreateChildTable
);
__func__
,
__LINE__
,
superTbl
->
colsOfCreateChildTable
);
...
@@ -4454,6 +4510,10 @@ int createDatabasesAndStables(char *command) {
...
@@ -4454,6 +4510,10 @@ int createDatabasesAndStables(char *command) {
int
validStbCount
=
0
;
int
validStbCount
=
0
;
for
(
uint64_t
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
for
(
uint64_t
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
if
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
==
SML_IFACE
)
{
goto
skip
;
}
sprintf
(
command
,
"describe %s.%s;"
,
g_Dbs
.
db
[
i
].
dbName
,
sprintf
(
command
,
"describe %s.%s;"
,
g_Dbs
.
db
[
i
].
dbName
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
stbName
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
stbName
);
ret
=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
,
true
);
ret
=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
,
true
);
...
@@ -4475,6 +4535,7 @@ int createDatabasesAndStables(char *command) {
...
@@ -4475,6 +4535,7 @@ int createDatabasesAndStables(char *command) {
continue
;
continue
;
}
}
}
}
skip:
validStbCount
++
;
validStbCount
++
;
}
}
g_Dbs
.
db
[
i
].
superTblCount
=
validStbCount
;
g_Dbs
.
db
[
i
].
superTblCount
=
validStbCount
;
...
@@ -4561,7 +4622,7 @@ static void* createTable(void *sarg)
...
@@ -4561,7 +4622,7 @@ static void* createTable(void *sarg)
batchNum
++
;
batchNum
++
;
if
((
batchNum
<
stbInfo
->
batchCreateTableNum
)
if
((
batchNum
<
stbInfo
->
batchCreateTableNum
)
&&
((
buff_len
-
len
)
&&
((
buff_len
-
len
)
>=
(
stbInfo
->
lenOfTagOfOneRow
+
256
)))
{
>=
(
stbInfo
->
lenOfTagOfOneRow
+
EXTRA_SQL_LEN
)))
{
continue
;
continue
;
}
}
}
}
...
@@ -4577,7 +4638,7 @@ static void* createTable(void *sarg)
...
@@ -4577,7 +4638,7 @@ static void* createTable(void *sarg)
}
}
pThreadInfo
->
tables_created
+=
batchNum
;
pThreadInfo
->
tables_created
+=
batchNum
;
uint64_t
currentPrintTime
=
taosGetTimestampMs
();
uint64_t
currentPrintTime
=
taosGetTimestampMs
();
if
(
currentPrintTime
-
lastPrintTime
>
30
*
1000
)
{
if
(
currentPrintTime
-
lastPrintTime
>
PRINT_STAT_INTERVAL
)
{
printf
(
"thread[%d] already create %"
PRIu64
" - %"
PRIu64
" tables
\n
"
,
printf
(
"thread[%d] already create %"
PRIu64
" - %"
PRIu64
" tables
\n
"
,
pThreadInfo
->
threadID
,
pThreadInfo
->
start_table_from
,
i
);
pThreadInfo
->
threadID
,
pThreadInfo
->
start_table_from
,
i
);
lastPrintTime
=
currentPrintTime
;
lastPrintTime
=
currentPrintTime
;
...
@@ -4749,7 +4810,7 @@ static int readTagFromCsvFileToMem(SSuperTable * stbInfo) {
...
@@ -4749,7 +4810,7 @@ static int readTagFromCsvFileToMem(SSuperTable * stbInfo) {
stbInfo
->
tagDataBuf
=
NULL
;
stbInfo
->
tagDataBuf
=
NULL
;
}
}
int
tagCount
=
10000
;
int
tagCount
=
MAX_SAMPLES
;
int
count
=
0
;
int
count
=
0
;
char
*
tagDataBuf
=
calloc
(
1
,
stbInfo
->
lenOfTagOfOneRow
*
tagCount
);
char
*
tagDataBuf
=
calloc
(
1
,
stbInfo
->
lenOfTagOfOneRow
*
tagCount
);
if
(
tagDataBuf
==
NULL
)
{
if
(
tagDataBuf
==
NULL
)
{
...
@@ -5155,35 +5216,35 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -5155,35 +5216,35 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
if
(
port
&&
port
->
type
==
cJSON_Number
)
{
if
(
port
&&
port
->
type
==
cJSON_Number
)
{
g_Dbs
.
port
=
port
->
valueint
;
g_Dbs
.
port
=
port
->
valueint
;
}
else
if
(
!
port
)
{
}
else
if
(
!
port
)
{
g_Dbs
.
port
=
6030
;
g_Dbs
.
port
=
DEFAULT_PORT
;
}
}
cJSON
*
user
=
cJSON_GetObjectItem
(
root
,
"user"
);
cJSON
*
user
=
cJSON_GetObjectItem
(
root
,
"user"
);
if
(
user
&&
user
->
type
==
cJSON_String
&&
user
->
valuestring
!=
NULL
)
{
if
(
user
&&
user
->
type
==
cJSON_String
&&
user
->
valuestring
!=
NULL
)
{
tstrncpy
(
g_Dbs
.
user
,
user
->
valuestring
,
MAX_USERNAME_SIZE
);
tstrncpy
(
g_Dbs
.
user
,
user
->
valuestring
,
MAX_USERNAME_SIZE
);
}
else
if
(
!
user
)
{
}
else
if
(
!
user
)
{
tstrncpy
(
g_Dbs
.
user
,
"root"
,
MAX_USERNAME_SIZE
);
tstrncpy
(
g_Dbs
.
user
,
TSDB_DEFAULT_USER
,
MAX_USERNAME_SIZE
);
}
}
cJSON
*
password
=
cJSON_GetObjectItem
(
root
,
"password"
);
cJSON
*
password
=
cJSON_GetObjectItem
(
root
,
"password"
);
if
(
password
&&
password
->
type
==
cJSON_String
&&
password
->
valuestring
!=
NULL
)
{
if
(
password
&&
password
->
type
==
cJSON_String
&&
password
->
valuestring
!=
NULL
)
{
tstrncpy
(
g_Dbs
.
password
,
password
->
valuestring
,
SHELL_MAX_PASSWORD_LEN
);
tstrncpy
(
g_Dbs
.
password
,
password
->
valuestring
,
SHELL_MAX_PASSWORD_LEN
);
}
else
if
(
!
password
)
{
}
else
if
(
!
password
)
{
tstrncpy
(
g_Dbs
.
password
,
"taosdata"
,
SHELL_MAX_PASSWORD_LEN
);
tstrncpy
(
g_Dbs
.
password
,
TSDB_DEFAULT_PASS
,
SHELL_MAX_PASSWORD_LEN
);
}
}
cJSON
*
resultfile
=
cJSON_GetObjectItem
(
root
,
"result_file"
);
cJSON
*
resultfile
=
cJSON_GetObjectItem
(
root
,
"result_file"
);
if
(
resultfile
&&
resultfile
->
type
==
cJSON_String
&&
resultfile
->
valuestring
!=
NULL
)
{
if
(
resultfile
&&
resultfile
->
type
==
cJSON_String
&&
resultfile
->
valuestring
!=
NULL
)
{
tstrncpy
(
g_Dbs
.
resultFile
,
resultfile
->
valuestring
,
MAX_FILE_NAME_LEN
);
tstrncpy
(
g_Dbs
.
resultFile
,
resultfile
->
valuestring
,
MAX_FILE_NAME_LEN
);
}
else
if
(
!
resultfile
)
{
}
else
if
(
!
resultfile
)
{
tstrncpy
(
g_Dbs
.
resultFile
,
"./insert_res.txt"
,
MAX_FILE_NAME_LEN
);
tstrncpy
(
g_Dbs
.
resultFile
,
DEFAULT_OUTPUT
,
MAX_FILE_NAME_LEN
);
}
}
cJSON
*
threads
=
cJSON_GetObjectItem
(
root
,
"thread_count"
);
cJSON
*
threads
=
cJSON_GetObjectItem
(
root
,
"thread_count"
);
if
(
threads
&&
threads
->
type
==
cJSON_Number
)
{
if
(
threads
&&
threads
->
type
==
cJSON_Number
)
{
g_Dbs
.
threadCount
=
threads
->
valueint
;
g_Dbs
.
threadCount
=
threads
->
valueint
;
}
else
if
(
!
threads
)
{
}
else
if
(
!
threads
)
{
g_Dbs
.
threadCount
=
1
;
g_Dbs
.
threadCount
=
DEFAULT_NTHREADS
;
}
else
{
}
else
{
errorPrint
(
"%s"
,
"failed to read json, threads not found
\n
"
);
errorPrint
(
"%s"
,
"failed to read json, threads not found
\n
"
);
goto
PARSE_OVER
;
goto
PARSE_OVER
;
...
@@ -5193,7 +5254,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -5193,7 +5254,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
if
(
threads2
&&
threads2
->
type
==
cJSON_Number
)
{
if
(
threads2
&&
threads2
->
type
==
cJSON_Number
)
{
g_Dbs
.
threadCountForCreateTbl
=
threads2
->
valueint
;
g_Dbs
.
threadCountForCreateTbl
=
threads2
->
valueint
;
}
else
if
(
!
threads2
)
{
}
else
if
(
!
threads2
)
{
g_Dbs
.
threadCountForCreateTbl
=
1
;
g_Dbs
.
threadCountForCreateTbl
=
DEFAULT_NTHREADS
;
}
else
{
}
else
{
errorPrint
(
"%s"
,
"failed to read json, threads2 not found
\n
"
);
errorPrint
(
"%s"
,
"failed to read json, threads2 not found
\n
"
);
goto
PARSE_OVER
;
goto
PARSE_OVER
;
...
@@ -5207,7 +5268,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -5207,7 +5268,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
}
}
g_args
.
insert_interval
=
gInsertInterval
->
valueint
;
g_args
.
insert_interval
=
gInsertInterval
->
valueint
;
}
else
if
(
!
gInsertInterval
)
{
}
else
if
(
!
gInsertInterval
)
{
g_args
.
insert_interval
=
0
;
g_args
.
insert_interval
=
DEFAULT_INSERT_INTERVAL
;
}
else
{
}
else
{
errorPrint
(
"%s"
,
"failed to read json, insert_interval input mistake
\n
"
);
errorPrint
(
"%s"
,
"failed to read json, insert_interval input mistake
\n
"
);
goto
PARSE_OVER
;
goto
PARSE_OVER
;
...
@@ -5222,7 +5283,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -5222,7 +5283,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
}
}
g_args
.
interlaceRows
=
interlaceRows
->
valueint
;
g_args
.
interlaceRows
=
interlaceRows
->
valueint
;
}
else
if
(
!
interlaceRows
)
{
}
else
if
(
!
interlaceRows
)
{
g_args
.
interlaceRows
=
0
;
// 0 means progressive mode, > 0 mean interlace mode. max value is less or equ num_of_records_per_req
g_args
.
interlaceRows
=
DEFAULT_INTERLACE_ROWS
;
// 0 means progressive mode, > 0 mean interlace mode. max value is less or equ num_of_records_per_req
}
else
{
}
else
{
errorPrint
(
"%s"
,
"failed to read json, interlaceRows input mistake
\n
"
);
errorPrint
(
"%s"
,
"failed to read json, interlaceRows input mistake
\n
"
);
goto
PARSE_OVER
;
goto
PARSE_OVER
;
...
@@ -5237,7 +5298,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -5237,7 +5298,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
}
}
g_args
.
max_sql_len
=
maxSqlLen
->
valueint
;
g_args
.
max_sql_len
=
maxSqlLen
->
valueint
;
}
else
if
(
!
maxSqlLen
)
{
}
else
if
(
!
maxSqlLen
)
{
g_args
.
max_sql_len
=
(
1024
*
1024
)
;
g_args
.
max_sql_len
=
TSDB_MAX_ALLOWED_SQL_LEN
;
}
else
{
}
else
{
errorPrint
(
"%s() LN%d, failed to read json, max_sql_len input mistake
\n
"
,
errorPrint
(
"%s() LN%d, failed to read json, max_sql_len input mistake
\n
"
,
__func__
,
__LINE__
);
__func__
,
__LINE__
);
...
@@ -5267,6 +5328,22 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -5267,6 +5328,22 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
goto
PARSE_OVER
;
goto
PARSE_OVER
;
}
}
cJSON
*
prepareRand
=
cJSON_GetObjectItem
(
root
,
"prepared_rand"
);
if
(
prepareRand
&&
prepareRand
->
type
==
cJSON_Number
)
{
if
(
prepareRand
->
valueint
<=
0
)
{
errorPrint
(
"%s() LN%d, failed to read json, prepared_rand input mistake
\n
"
,
__func__
,
__LINE__
);
goto
PARSE_OVER
;
}
g_args
.
prepared_rand
=
prepareRand
->
valueint
;
}
else
if
(
!
prepareRand
)
{
g_args
.
prepared_rand
=
DEFAULT_PREPARED_RAND
;
}
else
{
errorPrint
(
"%s() LN%d, failed to read json, prepared_rand not found
\n
"
,
__func__
,
__LINE__
);
goto
PARSE_OVER
;
}
cJSON
*
answerPrompt
=
cJSON_GetObjectItem
(
root
,
"confirm_parameter_prompt"
);
// yes, no,
cJSON
*
answerPrompt
=
cJSON_GetObjectItem
(
root
,
"confirm_parameter_prompt"
);
// yes, no,
if
(
answerPrompt
if
(
answerPrompt
&&
answerPrompt
->
type
==
cJSON_String
&&
answerPrompt
->
type
==
cJSON_String
...
@@ -5276,7 +5353,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -5276,7 +5353,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
}
else
if
(
0
==
strncasecmp
(
answerPrompt
->
valuestring
,
"no"
,
2
))
{
}
else
if
(
0
==
strncasecmp
(
answerPrompt
->
valuestring
,
"no"
,
2
))
{
g_args
.
answer_yes
=
true
;
g_args
.
answer_yes
=
true
;
}
else
{
}
else
{
g_args
.
answer_yes
=
false
;
g_args
.
answer_yes
=
DEFAULT_ANS_YES
;
}
}
}
else
if
(
!
answerPrompt
)
{
}
else
if
(
!
answerPrompt
)
{
g_args
.
answer_yes
=
true
;
// default is no, mean answer_yes.
g_args
.
answer_yes
=
true
;
// default is no, mean answer_yes.
...
@@ -5308,7 +5385,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -5308,7 +5385,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
MAX_DB_COUNT
);
MAX_DB_COUNT
);
goto
PARSE_OVER
;
goto
PARSE_OVER
;
}
}
g_Dbs
.
db
=
calloc
(
1
,
sizeof
(
SDataBase
)
*
dbSize
);
assert
(
g_Dbs
.
db
);
g_Dbs
.
dbCount
=
dbSize
;
g_Dbs
.
dbCount
=
dbSize
;
for
(
int
i
=
0
;
i
<
dbSize
;
++
i
)
{
for
(
int
i
=
0
;
i
<
dbSize
;
++
i
)
{
cJSON
*
dbinfos
=
cJSON_GetArrayItem
(
dbs
,
i
);
cJSON
*
dbinfos
=
cJSON_GetArrayItem
(
dbs
,
i
);
...
@@ -5508,7 +5586,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -5508,7 +5586,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
MAX_SUPER_TABLE_COUNT
);
MAX_SUPER_TABLE_COUNT
);
goto
PARSE_OVER
;
goto
PARSE_OVER
;
}
}
g_Dbs
.
db
[
i
].
superTbls
=
calloc
(
1
,
stbSize
*
sizeof
(
SSuperTable
));
assert
(
g_Dbs
.
db
[
i
].
superTbls
);
g_Dbs
.
db
[
i
].
superTblCount
=
stbSize
;
g_Dbs
.
db
[
i
].
superTblCount
=
stbSize
;
for
(
int
j
=
0
;
j
<
stbSize
;
++
j
)
{
for
(
int
j
=
0
;
j
<
stbSize
;
++
j
)
{
cJSON
*
stbInfo
=
cJSON_GetArrayItem
(
stables
,
j
);
cJSON
*
stbInfo
=
cJSON_GetArrayItem
(
stables
,
j
);
...
@@ -5573,7 +5652,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -5573,7 +5652,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
if
(
batchCreateTbl
&&
batchCreateTbl
->
type
==
cJSON_Number
)
{
if
(
batchCreateTbl
&&
batchCreateTbl
->
type
==
cJSON_Number
)
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
batchCreateTableNum
=
batchCreateTbl
->
valueint
;
g_Dbs
.
db
[
i
].
superTbls
[
j
].
batchCreateTableNum
=
batchCreateTbl
->
valueint
;
}
else
if
(
!
batchCreateTbl
)
{
}
else
if
(
!
batchCreateTbl
)
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
batchCreateTableNum
=
10
;
g_Dbs
.
db
[
i
].
superTbls
[
j
].
batchCreateTableNum
=
DEFAULT_CREATE_BATCH
;
}
else
{
}
else
{
errorPrint
(
"%s"
,
"failed to read json, batch_create_tbl_num not found
\n
"
);
errorPrint
(
"%s"
,
"failed to read json, batch_create_tbl_num not found
\n
"
);
goto
PARSE_OVER
;
goto
PARSE_OVER
;
...
@@ -5636,6 +5715,9 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -5636,6 +5715,9 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
=
REST_IFACE
;
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
=
REST_IFACE
;
}
else
if
(
0
==
strcasecmp
(
stbIface
->
valuestring
,
"stmt"
))
{
}
else
if
(
0
==
strcasecmp
(
stbIface
->
valuestring
,
"stmt"
))
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
=
STMT_IFACE
;
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
=
STMT_IFACE
;
}
else
if
(
0
==
strcasecmp
(
stbIface
->
valuestring
,
"sml"
))
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
iface
=
SML_IFACE
;
g_args
.
iface
=
SML_IFACE
;
}
else
{
}
else
{
errorPrint
(
"failed to read json, insert_mode %s not recognized
\n
"
,
errorPrint
(
"failed to read json, insert_mode %s not recognized
\n
"
,
stbIface
->
valuestring
);
stbIface
->
valuestring
);
...
@@ -5852,7 +5934,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -5852,7 +5934,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
if
(
disorderRange
&&
disorderRange
->
type
==
cJSON_Number
)
{
if
(
disorderRange
&&
disorderRange
->
type
==
cJSON_Number
)
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
disorderRange
=
disorderRange
->
valueint
;
g_Dbs
.
db
[
i
].
superTbls
[
j
].
disorderRange
=
disorderRange
->
valueint
;
}
else
if
(
!
disorderRange
)
{
}
else
if
(
!
disorderRange
)
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
disorderRange
=
1000
;
g_Dbs
.
db
[
i
].
superTbls
[
j
].
disorderRange
=
DEFAULT_DISORDER_RANGE
;
}
else
{
}
else
{
errorPrint
(
"%s"
,
"failed to read json, disorderRange not found
\n
"
);
errorPrint
(
"%s"
,
"failed to read json, disorderRange not found
\n
"
);
goto
PARSE_OVER
;
goto
PARSE_OVER
;
...
@@ -5900,7 +5982,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
...
@@ -5900,7 +5982,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
if
(
host
&&
host
->
type
==
cJSON_String
&&
host
->
valuestring
!=
NULL
)
{
if
(
host
&&
host
->
type
==
cJSON_String
&&
host
->
valuestring
!=
NULL
)
{
tstrncpy
(
g_queryInfo
.
host
,
host
->
valuestring
,
MAX_HOSTNAME_SIZE
);
tstrncpy
(
g_queryInfo
.
host
,
host
->
valuestring
,
MAX_HOSTNAME_SIZE
);
}
else
if
(
!
host
)
{
}
else
if
(
!
host
)
{
tstrncpy
(
g_queryInfo
.
host
,
"127.0.0.1"
,
MAX_HOSTNAME_SIZE
);
tstrncpy
(
g_queryInfo
.
host
,
DEFAULT_HOST
,
MAX_HOSTNAME_SIZE
);
}
else
{
}
else
{
errorPrint
(
"%s"
,
"failed to read json, host not found
\n
"
);
errorPrint
(
"%s"
,
"failed to read json, host not found
\n
"
);
goto
PARSE_OVER
;
goto
PARSE_OVER
;
...
@@ -5910,21 +5992,21 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
...
@@ -5910,21 +5992,21 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
if
(
port
&&
port
->
type
==
cJSON_Number
)
{
if
(
port
&&
port
->
type
==
cJSON_Number
)
{
g_queryInfo
.
port
=
port
->
valueint
;
g_queryInfo
.
port
=
port
->
valueint
;
}
else
if
(
!
port
)
{
}
else
if
(
!
port
)
{
g_queryInfo
.
port
=
6030
;
g_queryInfo
.
port
=
DEFAULT_PORT
;
}
}
cJSON
*
user
=
cJSON_GetObjectItem
(
root
,
"user"
);
cJSON
*
user
=
cJSON_GetObjectItem
(
root
,
"user"
);
if
(
user
&&
user
->
type
==
cJSON_String
&&
user
->
valuestring
!=
NULL
)
{
if
(
user
&&
user
->
type
==
cJSON_String
&&
user
->
valuestring
!=
NULL
)
{
tstrncpy
(
g_queryInfo
.
user
,
user
->
valuestring
,
MAX_USERNAME_SIZE
);
tstrncpy
(
g_queryInfo
.
user
,
user
->
valuestring
,
MAX_USERNAME_SIZE
);
}
else
if
(
!
user
)
{
}
else
if
(
!
user
)
{
tstrncpy
(
g_queryInfo
.
user
,
"root"
,
MAX_USERNAME_SIZE
);
;
tstrncpy
(
g_queryInfo
.
user
,
TSDB_DEFAULT_USER
,
MAX_USERNAME_SIZE
);
;
}
}
cJSON
*
password
=
cJSON_GetObjectItem
(
root
,
"password"
);
cJSON
*
password
=
cJSON_GetObjectItem
(
root
,
"password"
);
if
(
password
&&
password
->
type
==
cJSON_String
&&
password
->
valuestring
!=
NULL
)
{
if
(
password
&&
password
->
type
==
cJSON_String
&&
password
->
valuestring
!=
NULL
)
{
tstrncpy
(
g_queryInfo
.
password
,
password
->
valuestring
,
SHELL_MAX_PASSWORD_LEN
);
tstrncpy
(
g_queryInfo
.
password
,
password
->
valuestring
,
SHELL_MAX_PASSWORD_LEN
);
}
else
if
(
!
password
)
{
}
else
if
(
!
password
)
{
tstrncpy
(
g_queryInfo
.
password
,
"taosdata"
,
SHELL_MAX_PASSWORD_LEN
);;
tstrncpy
(
g_queryInfo
.
password
,
TSDB_DEFAULT_PASS
,
SHELL_MAX_PASSWORD_LEN
);;
}
}
cJSON
*
answerPrompt
=
cJSON_GetObjectItem
(
root
,
"confirm_parameter_prompt"
);
// yes, no,
cJSON
*
answerPrompt
=
cJSON_GetObjectItem
(
root
,
"confirm_parameter_prompt"
);
// yes, no,
...
@@ -5952,7 +6034,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
...
@@ -5952,7 +6034,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
}
}
g_args
.
query_times
=
gQueryTimes
->
valueint
;
g_args
.
query_times
=
gQueryTimes
->
valueint
;
}
else
if
(
!
gQueryTimes
)
{
}
else
if
(
!
gQueryTimes
)
{
g_args
.
query_times
=
1
;
g_args
.
query_times
=
DEFAULT_QUERY_TIME
;
}
else
{
}
else
{
errorPrint
(
"%s"
,
"failed to read json, query_times input mistake
\n
"
);
errorPrint
(
"%s"
,
"failed to read json, query_times input mistake
\n
"
);
goto
PARSE_OVER
;
goto
PARSE_OVER
;
...
@@ -6050,7 +6132,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
...
@@ -6050,7 +6132,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
}
else
if
(
!
interval
)
{
}
else
if
(
!
interval
)
{
//printf("failed to read json, subscribe interval no found\n");
//printf("failed to read json, subscribe interval no found\n");
//goto PARSE_OVER;
//goto PARSE_OVER;
g_queryInfo
.
specifiedQueryInfo
.
subscribeInterval
=
10000
;
g_queryInfo
.
specifiedQueryInfo
.
subscribeInterval
=
DEFAULT_SUB_INTERVAL
;
}
}
cJSON
*
restart
=
cJSON_GetObjectItem
(
specifiedQuery
,
"restart"
);
cJSON
*
restart
=
cJSON_GetObjectItem
(
specifiedQuery
,
"restart"
);
...
@@ -6197,7 +6279,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
...
@@ -6197,7 +6279,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
}
}
g_queryInfo
.
superQueryInfo
.
threadCnt
=
threads
->
valueint
;
g_queryInfo
.
superQueryInfo
.
threadCnt
=
threads
->
valueint
;
}
else
if
(
!
threads
)
{
}
else
if
(
!
threads
)
{
g_queryInfo
.
superQueryInfo
.
threadCnt
=
1
;
g_queryInfo
.
superQueryInfo
.
threadCnt
=
DEFAULT_NTHREADS
;
}
}
//cJSON* subTblCnt = cJSON_GetObjectItem(superQuery, "childtable_count");
//cJSON* subTblCnt = cJSON_GetObjectItem(superQuery, "childtable_count");
...
@@ -6242,7 +6324,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
...
@@ -6242,7 +6324,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
}
else
if
(
!
superInterval
)
{
}
else
if
(
!
superInterval
)
{
//printf("failed to read json, subscribe interval no found\n");
//printf("failed to read json, subscribe interval no found\n");
//goto PARSE_OVER;
//goto PARSE_OVER;
g_queryInfo
.
superQueryInfo
.
subscribeInterval
=
10000
;
g_queryInfo
.
superQueryInfo
.
subscribeInterval
=
DEFAULT_QUERY_INTERVAL
;
}
}
cJSON
*
subrestart
=
cJSON_GetObjectItem
(
superQuery
,
"restart"
);
cJSON
*
subrestart
=
cJSON_GetObjectItem
(
superQuery
,
"restart"
);
...
@@ -6362,7 +6444,7 @@ static bool getInfoFromJsonFile(char* file) {
...
@@ -6362,7 +6444,7 @@ static bool getInfoFromJsonFile(char* file) {
}
}
bool
ret
=
false
;
bool
ret
=
false
;
int
maxLen
=
6400000
;
int
maxLen
=
MAX_JSON_BUFF
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
int
len
=
fread
(
content
,
1
,
maxLen
,
fp
);
int
len
=
fread
(
content
,
1
,
maxLen
,
fp
);
if
(
len
<=
0
)
{
if
(
len
<=
0
)
{
...
@@ -6399,9 +6481,12 @@ static bool getInfoFromJsonFile(char* file) {
...
@@ -6399,9 +6481,12 @@ static bool getInfoFromJsonFile(char* file) {
}
}
if
(
INSERT_TEST
==
g_args
.
test_mode
)
{
if
(
INSERT_TEST
==
g_args
.
test_mode
)
{
memset
(
&
g_Dbs
,
0
,
sizeof
(
SDbs
));
g_Dbs
.
use_metric
=
g_args
.
use_metric
;
ret
=
getMetaFromInsertJsonFile
(
root
);
ret
=
getMetaFromInsertJsonFile
(
root
);
}
else
if
((
QUERY_TEST
==
g_args
.
test_mode
)
}
else
if
((
QUERY_TEST
==
g_args
.
test_mode
)
||
(
SUBSCRIBE_TEST
==
g_args
.
test_mode
))
{
||
(
SUBSCRIBE_TEST
==
g_args
.
test_mode
))
{
memset
(
&
g_queryInfo
,
0
,
sizeof
(
SQueryMetaInfo
));
ret
=
getMetaFromQueryJsonFile
(
root
);
ret
=
getMetaFromQueryJsonFile
(
root
);
}
else
{
}
else
{
errorPrint
(
"%s"
,
errorPrint
(
"%s"
,
...
@@ -6466,8 +6551,9 @@ static void postFreeResource() {
...
@@ -6466,8 +6551,9 @@ static void postFreeResource() {
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblName
=
NULL
;
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblName
=
NULL
;
}
}
}
}
tmfree
(
g_Dbs
.
db
[
i
].
superTbls
);
}
}
tmfree
(
g_Dbs
.
db
);
tmfree
(
g_randbool_buff
);
tmfree
(
g_randbool_buff
);
tmfree
(
g_randint_buff
);
tmfree
(
g_randint_buff
);
tmfree
(
g_rand_voltage_buff
);
tmfree
(
g_rand_voltage_buff
);
...
@@ -6490,6 +6576,7 @@ static void postFreeResource() {
...
@@ -6490,6 +6576,7 @@ static void postFreeResource() {
}
}
}
}
tmfree
(
g_sampleBindBatchArray
);
tmfree
(
g_sampleBindBatchArray
);
#endif
#endif
}
}
...
@@ -6971,7 +7058,7 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k)
...
@@ -6971,7 +7058,7 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k)
{
{
int32_t
affectedRows
;
int32_t
affectedRows
;
SSuperTable
*
stbInfo
=
pThreadInfo
->
stbInfo
;
SSuperTable
*
stbInfo
=
pThreadInfo
->
stbInfo
;
int32_t
code
;
uint16_t
iface
;
uint16_t
iface
;
if
(
stbInfo
)
if
(
stbInfo
)
iface
=
stbInfo
->
iface
;
iface
=
stbInfo
->
iface
;
...
@@ -7023,7 +7110,19 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k)
...
@@ -7023,7 +7110,19 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k)
}
}
affectedRows
=
k
;
affectedRows
=
k
;
break
;
break
;
case
SML_IFACE
:
code
=
taos_schemaless_insert
(
pThreadInfo
->
taos
,
pThreadInfo
->
lines
,
k
,
0
,
pThreadInfo
->
time_precision
==
TSDB_TIME_PRECISION_MILLI
?
"ms"
:
(
pThreadInfo
->
time_precision
==
TSDB_TIME_PRECISION_MICRO
?
"us"
:
"ns"
));
if
(
code
)
{
errorPrint2
(
"%s() LN%d, failed to execute schemaless insert. reason: %s
\n
"
,
__func__
,
__LINE__
,
tstrerror
(
code
));
exit
(
EXIT_FAILURE
);
}
affectedRows
=
k
;
break
;
default:
default:
errorPrint2
(
"%s() LN%d: unknown insert mode: %d
\n
"
,
errorPrint2
(
"%s() LN%d: unknown insert mode: %d
\n
"
,
__func__
,
__LINE__
,
stbInfo
->
iface
);
__func__
,
__LINE__
,
stbInfo
->
iface
);
...
@@ -9509,6 +9608,441 @@ free_of_interlace_stmt:
...
@@ -9509,6 +9608,441 @@ free_of_interlace_stmt:
#endif
#endif
static
void
generateSmlHead
(
char
*
smlHead
,
SSuperTable
*
stbInfo
,
threadInfo
*
pThreadInfo
,
int
tbSeq
)
{
int64_t
dataLen
=
0
;
dataLen
+=
snprintf
(
smlHead
+
dataLen
,
HEAD_BUFF_LEN
-
dataLen
,
"%s,id=%s%"
PRIu64
""
,
stbInfo
->
stbName
,
stbInfo
->
childTblPrefix
,
tbSeq
+
pThreadInfo
->
start_table_from
);
for
(
int
j
=
0
;
j
<
stbInfo
->
tagCount
;
j
++
)
{
tstrncpy
(
smlHead
+
dataLen
,
","
,
2
);
dataLen
+=
1
;
switch
(
stbInfo
->
tags
[
j
].
data_type
)
{
case
TSDB_DATA_TYPE_TIMESTAMP
:
errorPrint2
(
"%s() LN%d, Does not support data type %s as tag
\n
"
,
__func__
,
__LINE__
,
stbInfo
->
tags
[
j
].
dataType
);
exit
(
EXIT_FAILURE
);
case
TSDB_DATA_TYPE_BOOL
:
dataLen
+=
snprintf
(
smlHead
+
dataLen
,
HEAD_BUFF_LEN
-
dataLen
,
"T%d=%s"
,
j
,
rand_bool_str
());
break
;
case
TSDB_DATA_TYPE_TINYINT
:
dataLen
+=
snprintf
(
smlHead
+
dataLen
,
HEAD_BUFF_LEN
-
dataLen
,
"T%d=%si8"
,
j
,
rand_tinyint_str
());
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
dataLen
+=
snprintf
(
smlHead
+
dataLen
,
HEAD_BUFF_LEN
-
dataLen
,
"T%d=%su8"
,
j
,
rand_utinyint_str
());
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
dataLen
+=
snprintf
(
smlHead
+
dataLen
,
HEAD_BUFF_LEN
-
dataLen
,
"T%d=%si16"
,
j
,
rand_smallint_str
());
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
dataLen
+=
snprintf
(
smlHead
+
dataLen
,
HEAD_BUFF_LEN
-
dataLen
,
"T%d=%su16"
,
j
,
rand_usmallint_str
());
break
;
case
TSDB_DATA_TYPE_INT
:
dataLen
+=
snprintf
(
smlHead
+
dataLen
,
HEAD_BUFF_LEN
-
dataLen
,
"T%d=%si32"
,
j
,
rand_int_str
());
break
;
case
TSDB_DATA_TYPE_UINT
:
dataLen
+=
snprintf
(
smlHead
+
dataLen
,
HEAD_BUFF_LEN
-
dataLen
,
"T%d=%su32"
,
j
,
rand_uint_str
());
break
;
case
TSDB_DATA_TYPE_BIGINT
:
dataLen
+=
snprintf
(
smlHead
+
dataLen
,
HEAD_BUFF_LEN
-
dataLen
,
"T%d=%si64"
,
j
,
rand_bigint_str
());
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
dataLen
+=
snprintf
(
smlHead
+
dataLen
,
HEAD_BUFF_LEN
-
dataLen
,
"T%d=%su64"
,
j
,
rand_ubigint_str
());
break
;
case
TSDB_DATA_TYPE_FLOAT
:
dataLen
+=
snprintf
(
smlHead
+
dataLen
,
HEAD_BUFF_LEN
-
dataLen
,
"T%d=%sf32"
,
j
,
rand_float_str
());
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
dataLen
+=
snprintf
(
smlHead
+
dataLen
,
HEAD_BUFF_LEN
-
dataLen
,
"T%d=%sf64"
,
j
,
rand_double_str
());
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
if
(
stbInfo
->
tags
[
j
].
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
errorPrint2
(
"binary or nchar length overflow, maxsize:%u
\n
"
,
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
exit
(
EXIT_FAILURE
);
}
char
*
buf
=
(
char
*
)
calloc
(
stbInfo
->
tags
[
j
].
dataLen
+
1
,
1
);
if
(
NULL
==
buf
)
{
errorPrint2
(
"calloc failed! size:%d
\n
"
,
stbInfo
->
tags
[
j
].
dataLen
);
exit
(
EXIT_FAILURE
);
}
rand_string
(
buf
,
stbInfo
->
tags
[
j
].
dataLen
);
if
(
stbInfo
->
tags
[
j
].
data_type
==
TSDB_DATA_TYPE_BINARY
)
{
dataLen
+=
snprintf
(
smlHead
+
dataLen
,
HEAD_BUFF_LEN
-
dataLen
,
"T%d=
\"
%s
\"
"
,
j
,
buf
);
}
else
{
dataLen
+=
snprintf
(
smlHead
+
dataLen
,
HEAD_BUFF_LEN
-
dataLen
,
"T%d=L
\"
%s
\"
"
,
j
,
buf
);
}
tmfree
(
buf
);
break
;
default:
errorPrint2
(
"%s() LN%d, Unknown data type %s
\n
"
,
__func__
,
__LINE__
,
stbInfo
->
tags
[
j
].
dataType
);
exit
(
EXIT_FAILURE
);
}
}
}
static
void
generateSmlTail
(
char
*
line
,
char
*
smlHead
,
SSuperTable
*
stbInfo
,
threadInfo
*
pThreadInfo
,
int64_t
timestamp
)
{
int
dataLen
=
0
;
dataLen
=
snprintf
(
line
,
BUFFER_SIZE
,
"%s "
,
smlHead
);
for
(
uint32_t
c
=
0
;
c
<
stbInfo
->
columnCount
;
c
++
)
{
if
(
c
!=
0
)
{
tstrncpy
(
line
+
dataLen
,
","
,
2
);
dataLen
+=
1
;
}
switch
(
stbInfo
->
columns
[
c
].
data_type
)
{
case
TSDB_DATA_TYPE_TIMESTAMP
:
errorPrint2
(
"%s() LN%d, Does not support data type %s as tag
\n
"
,
__func__
,
__LINE__
,
stbInfo
->
columns
[
c
].
dataType
);
exit
(
EXIT_FAILURE
);
case
TSDB_DATA_TYPE_BOOL
:
dataLen
+=
snprintf
(
line
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"c%d=%s"
,
c
,
rand_bool_str
());
break
;
case
TSDB_DATA_TYPE_TINYINT
:
dataLen
+=
snprintf
(
line
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"c%d=%si8"
,
c
,
rand_tinyint_str
());
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
dataLen
+=
snprintf
(
line
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"c%d=%su8"
,
c
,
rand_utinyint_str
());
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
dataLen
+=
snprintf
(
line
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"c%d=%si16"
,
c
,
rand_smallint_str
());
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
dataLen
+=
snprintf
(
line
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"c%d=%su16"
,
c
,
rand_usmallint_str
());
break
;
case
TSDB_DATA_TYPE_INT
:
dataLen
+=
snprintf
(
line
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"c%d=%si32"
,
c
,
rand_int_str
());
break
;
case
TSDB_DATA_TYPE_UINT
:
dataLen
+=
snprintf
(
line
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"c%d=%su32"
,
c
,
rand_uint_str
());
break
;
case
TSDB_DATA_TYPE_BIGINT
:
dataLen
+=
snprintf
(
line
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"c%d=%si64"
,
c
,
rand_bigint_str
());
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
dataLen
+=
snprintf
(
line
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"c%d=%su64"
,
c
,
rand_ubigint_str
());
break
;
case
TSDB_DATA_TYPE_FLOAT
:
dataLen
+=
snprintf
(
line
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"c%d=%sf32"
,
c
,
rand_float_str
());
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
dataLen
+=
snprintf
(
line
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"c%d=%sf64"
,
c
,
rand_double_str
());
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
if
(
stbInfo
->
columns
[
c
].
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
errorPrint2
(
"binary or nchar length overflow, maxsize:%u
\n
"
,
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
exit
(
EXIT_FAILURE
);
}
char
*
buf
=
(
char
*
)
calloc
(
stbInfo
->
columns
[
c
].
dataLen
+
1
,
1
);
if
(
NULL
==
buf
)
{
errorPrint2
(
"calloc failed! size:%d
\n
"
,
stbInfo
->
columns
[
c
].
dataLen
);
exit
(
EXIT_FAILURE
);
}
rand_string
(
buf
,
stbInfo
->
columns
[
c
].
dataLen
);
if
(
stbInfo
->
columns
[
c
].
data_type
==
TSDB_DATA_TYPE_BINARY
)
{
dataLen
+=
snprintf
(
line
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"c%d=
\"
%s
\"
"
,
c
,
buf
);
}
else
{
dataLen
+=
snprintf
(
line
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"c%d=L
\"
%s
\"
"
,
c
,
buf
);
}
tmfree
(
buf
);
break
;
default:
errorPrint2
(
"%s() LN%d, Unknown data type %s
\n
"
,
__func__
,
__LINE__
,
stbInfo
->
columns
[
c
].
dataType
);
exit
(
EXIT_FAILURE
);
}
}
dataLen
+=
snprintf
(
line
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
" %"
PRId64
""
,
timestamp
);
}
static
void
*
syncWriteInterlaceSml
(
threadInfo
*
pThreadInfo
,
uint32_t
interlaceRows
)
{
debugPrint
(
"[%d] %s() LN%d: ### interlace schemaless write
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
);
int64_t
insertRows
;
uint64_t
maxSqlLen
;
int64_t
timeStampStep
;
uint64_t
insert_interval
;
SSuperTable
*
stbInfo
=
pThreadInfo
->
stbInfo
;
if
(
stbInfo
)
{
insertRows
=
stbInfo
->
insertRows
;
maxSqlLen
=
stbInfo
->
maxSqlLen
;
timeStampStep
=
stbInfo
->
timeStampStep
;
insert_interval
=
stbInfo
->
insertInterval
;
}
else
{
insertRows
=
g_args
.
insertRows
;
maxSqlLen
=
g_args
.
max_sql_len
;
timeStampStep
=
g_args
.
timestamp_step
;
insert_interval
=
g_args
.
insert_interval
;
}
debugPrint
(
"[%d] %s() LN%d: start_table_from=%"
PRIu64
" ntables=%"
PRId64
" insertRows=%"
PRIu64
"
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
pThreadInfo
->
start_table_from
,
pThreadInfo
->
ntables
,
insertRows
);
if
(
interlaceRows
>
g_args
.
reqPerReq
)
interlaceRows
=
g_args
.
reqPerReq
;
uint32_t
batchPerTbl
=
interlaceRows
;
uint32_t
batchPerTblTimes
;
if
((
interlaceRows
>
0
)
&&
(
pThreadInfo
->
ntables
>
1
))
{
batchPerTblTimes
=
g_args
.
reqPerReq
/
interlaceRows
;
}
else
{
batchPerTblTimes
=
1
;
}
char
*
smlHead
[
pThreadInfo
->
ntables
];
for
(
int
t
=
0
;
t
<
pThreadInfo
->
ntables
;
t
++
)
{
smlHead
[
t
]
=
(
char
*
)
calloc
(
HEAD_BUFF_LEN
,
1
);
if
(
NULL
==
smlHead
[
t
])
{
errorPrint2
(
"calloc failed! size:%d
\n
"
,
HEAD_BUFF_LEN
);
exit
(
EXIT_FAILURE
);
}
generateSmlHead
(
smlHead
[
t
],
stbInfo
,
pThreadInfo
,
t
);
}
pThreadInfo
->
totalInsertRows
=
0
;
pThreadInfo
->
totalAffectedRows
=
0
;
uint64_t
st
=
0
;
uint64_t
et
=
UINT64_MAX
;
uint64_t
lastPrintTime
=
taosGetTimestampMs
();
uint64_t
startTs
=
taosGetTimestampMs
();
uint64_t
endTs
;
uint64_t
tableSeq
=
pThreadInfo
->
start_table_from
;
int64_t
startTime
=
pThreadInfo
->
start_time
;
uint64_t
generatedRecPerTbl
=
0
;
bool
flagSleep
=
true
;
uint64_t
sleepTimeTotal
=
0
;
int
percentComplete
=
0
;
int64_t
totalRows
=
insertRows
*
pThreadInfo
->
ntables
;
pThreadInfo
->
lines
=
calloc
(
g_args
.
reqPerReq
,
sizeof
(
char
*
));
if
(
NULL
==
pThreadInfo
->
lines
)
{
errorPrint2
(
"Failed to alloc %"
PRIu64
" bytes, reason:%s
\n
"
,
g_args
.
reqPerReq
*
sizeof
(
char
*
),
strerror
(
errno
));
return
NULL
;
}
while
(
pThreadInfo
->
totalInsertRows
<
pThreadInfo
->
ntables
*
insertRows
)
{
if
((
flagSleep
)
&&
(
insert_interval
))
{
st
=
taosGetTimestampMs
();
flagSleep
=
false
;
}
// generate data
uint32_t
recOfBatch
=
0
;
for
(
uint64_t
i
=
0
;
i
<
batchPerTblTimes
;
i
++
)
{
int64_t
timestamp
=
startTime
;
for
(
int
j
=
recOfBatch
;
j
<
recOfBatch
+
batchPerTbl
;
j
++
)
{
pThreadInfo
->
lines
[
j
]
=
calloc
(
BUFFER_SIZE
,
1
);
if
(
NULL
==
pThreadInfo
->
lines
[
j
])
{
errorPrint2
(
"Failed to alloc %d bytes, reason:%s
\n
"
,
BUFFER_SIZE
,
strerror
(
errno
));
}
generateSmlTail
(
pThreadInfo
->
lines
[
j
],
smlHead
[
i
],
stbInfo
,
pThreadInfo
,
timestamp
);
timestamp
+=
timeStampStep
;
}
tableSeq
++
;
recOfBatch
+=
batchPerTbl
;
pThreadInfo
->
totalInsertRows
+=
batchPerTbl
;
verbosePrint
(
"[%d] %s() LN%d batchPerTbl=%d recOfBatch=%d
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
batchPerTbl
,
recOfBatch
);
if
(
tableSeq
==
pThreadInfo
->
start_table_from
+
pThreadInfo
->
ntables
)
{
// turn to first table
tableSeq
=
pThreadInfo
->
start_table_from
;
generatedRecPerTbl
+=
batchPerTbl
;
startTime
=
pThreadInfo
->
start_time
+
generatedRecPerTbl
*
timeStampStep
;
flagSleep
=
true
;
if
(
generatedRecPerTbl
>=
insertRows
)
break
;
int64_t
remainRows
=
insertRows
-
generatedRecPerTbl
;
if
((
remainRows
>
0
)
&&
(
batchPerTbl
>
remainRows
))
batchPerTbl
=
remainRows
;
if
(
pThreadInfo
->
ntables
*
batchPerTbl
<
g_args
.
reqPerReq
)
break
;
}
verbosePrint
(
"[%d] %s() LN%d generatedRecPerTbl=%"
PRId64
" insertRows=%"
PRId64
"
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
generatedRecPerTbl
,
insertRows
);
if
((
g_args
.
reqPerReq
-
recOfBatch
)
<
batchPerTbl
)
break
;
}
verbosePrint
(
"[%d] %s() LN%d recOfBatch=%d totalInsertRows=%"
PRIu64
"
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
recOfBatch
,
pThreadInfo
->
totalInsertRows
);
verbosePrint
(
"[%d] %s() LN%d, buffer=%s
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
pThreadInfo
->
buffer
);
startTs
=
taosGetTimestampUs
();
if
(
recOfBatch
==
0
)
{
errorPrint2
(
"[%d] %s() LN%d Failed to insert records of batch %d
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
batchPerTbl
);
if
(
batchPerTbl
>
0
)
{
errorPrint
(
"
\t
If the batch is %d, the length of the SQL to insert a row must be less then %"
PRId64
"
\n
"
,
batchPerTbl
,
maxSqlLen
/
batchPerTbl
);
}
errorPrint
(
"
\t
Please check if the buffer length(%"
PRId64
") or batch(%d) is set with proper value!
\n
"
,
maxSqlLen
,
batchPerTbl
);
goto
free_of_interlace
;
}
int64_t
affectedRows
=
execInsert
(
pThreadInfo
,
recOfBatch
);
endTs
=
taosGetTimestampUs
();
uint64_t
delay
=
endTs
-
startTs
;
performancePrint
(
"%s() LN%d, insert execution time is %10.2f ms
\n
"
,
__func__
,
__LINE__
,
delay
/
1000
.
0
);
verbosePrint
(
"[%d] %s() LN%d affectedRows=%"
PRId64
"
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
affectedRows
);
if
(
delay
>
pThreadInfo
->
maxDelay
)
pThreadInfo
->
maxDelay
=
delay
;
if
(
delay
<
pThreadInfo
->
minDelay
)
pThreadInfo
->
minDelay
=
delay
;
pThreadInfo
->
cntDelay
++
;
pThreadInfo
->
totalDelay
+=
delay
;
if
(
recOfBatch
!=
affectedRows
)
{
errorPrint2
(
"[%d] %s() LN%d execInsert insert %d, affected rows: %"
PRId64
"
\n
%s
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
recOfBatch
,
affectedRows
,
pThreadInfo
->
buffer
);
goto
free_of_interlace
;
}
pThreadInfo
->
totalAffectedRows
+=
affectedRows
;
int
currentPercent
=
pThreadInfo
->
totalAffectedRows
*
100
/
totalRows
;
if
(
currentPercent
>
percentComplete
)
{
printf
(
"[%d]:%d%%
\n
"
,
pThreadInfo
->
threadID
,
currentPercent
);
percentComplete
=
currentPercent
;
}
int64_t
currentPrintTime
=
taosGetTimestampMs
();
if
(
currentPrintTime
-
lastPrintTime
>
30
*
1000
)
{
printf
(
"thread[%d] has currently inserted rows: %"
PRIu64
", affected rows: %"
PRIu64
"
\n
"
,
pThreadInfo
->
threadID
,
pThreadInfo
->
totalInsertRows
,
pThreadInfo
->
totalAffectedRows
);
lastPrintTime
=
currentPrintTime
;
}
if
((
insert_interval
)
&&
flagSleep
)
{
et
=
taosGetTimestampMs
();
if
(
insert_interval
>
(
et
-
st
)
)
{
uint64_t
sleepTime
=
insert_interval
-
(
et
-
st
);
performancePrint
(
"%s() LN%d sleep: %"
PRId64
" ms for insert interval
\n
"
,
__func__
,
__LINE__
,
sleepTime
);
taosMsleep
(
sleepTime
);
// ms
sleepTimeTotal
+=
insert_interval
;
}
}
for
(
int
index
=
0
;
index
<
g_args
.
reqPerReq
;
index
++
)
{
free
(
pThreadInfo
->
lines
[
index
]);
}
}
if
(
percentComplete
<
100
)
printf
(
"[%d]:%d%%
\n
"
,
pThreadInfo
->
threadID
,
percentComplete
);
free_of_interlace:
tmfree
(
pThreadInfo
->
lines
);
for
(
int
index
=
0
;
index
<
pThreadInfo
->
ntables
;
index
++
)
{
free
(
smlHead
[
index
]);
}
printStatPerThread
(
pThreadInfo
);
return
NULL
;
}
// sync write interlace data
// sync write interlace data
static
void
*
syncWriteInterlace
(
threadInfo
*
pThreadInfo
,
uint32_t
interlaceRows
)
{
static
void
*
syncWriteInterlace
(
threadInfo
*
pThreadInfo
,
uint32_t
interlaceRows
)
{
debugPrint
(
"[%d] %s() LN%d: ### interlace write
\n
"
,
debugPrint
(
"[%d] %s() LN%d: ### interlace write
\n
"
,
...
@@ -9911,6 +10445,120 @@ free_of_stmt_progressive:
...
@@ -9911,6 +10445,120 @@ free_of_stmt_progressive:
printStatPerThread
(
pThreadInfo
);
printStatPerThread
(
pThreadInfo
);
return
NULL
;
return
NULL
;
}
}
static
void
*
syncWriteProgressiveSml
(
threadInfo
*
pThreadInfo
)
{
debugPrint
(
"%s() LN%d: ### sml progressive write
\n
"
,
__func__
,
__LINE__
);
SSuperTable
*
stbInfo
=
pThreadInfo
->
stbInfo
;
int64_t
timeStampStep
=
stbInfo
?
stbInfo
->
timeStampStep
:
g_args
.
timestamp_step
;
int64_t
insertRows
=
(
stbInfo
)
?
stbInfo
->
insertRows
:
g_args
.
insertRows
;
verbosePrint
(
"%s() LN%d insertRows=%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
insertRows
);
uint64_t
lastPrintTime
=
taosGetTimestampMs
();
pThreadInfo
->
totalInsertRows
=
0
;
pThreadInfo
->
totalAffectedRows
=
0
;
pThreadInfo
->
samplePos
=
0
;
char
*
smlHead
[
pThreadInfo
->
ntables
];
for
(
int
t
=
0
;
t
<
pThreadInfo
->
ntables
;
t
++
)
{
smlHead
[
t
]
=
(
char
*
)
calloc
(
HEAD_BUFF_LEN
,
1
);
if
(
NULL
==
smlHead
[
t
])
{
errorPrint2
(
"calloc failed! size:%d
\n
"
,
HEAD_BUFF_LEN
);
exit
(
EXIT_FAILURE
);
}
generateSmlHead
(
smlHead
[
t
],
stbInfo
,
pThreadInfo
,
t
);
}
int
currentPercent
=
0
;
int
percentComplete
=
0
;
if
(
insertRows
<
g_args
.
reqPerReq
)
{
g_args
.
reqPerReq
=
insertRows
;
}
pThreadInfo
->
lines
=
calloc
(
g_args
.
reqPerReq
,
sizeof
(
char
*
));
if
(
NULL
==
pThreadInfo
->
lines
)
{
errorPrint2
(
"Failed to alloc %"
PRIu64
" bytes, reason:%s
\n
"
,
g_args
.
reqPerReq
*
sizeof
(
char
*
),
strerror
(
errno
));
return
NULL
;
}
for
(
uint64_t
i
=
0
;
i
<
pThreadInfo
->
ntables
;
i
++
)
{
int64_t
timestamp
=
pThreadInfo
->
start_time
;
for
(
uint64_t
j
=
0
;
j
<
insertRows
;)
{
for
(
int
k
=
0
;
k
<
g_args
.
reqPerReq
;
k
++
)
{
pThreadInfo
->
lines
[
k
]
=
calloc
(
BUFFER_SIZE
,
1
);
if
(
NULL
==
pThreadInfo
->
lines
[
k
])
{
errorPrint2
(
"Failed to alloc %d bytes, reason:%s
\n
"
,
BUFFER_SIZE
,
strerror
(
errno
));
}
generateSmlTail
(
pThreadInfo
->
lines
[
k
],
smlHead
[
i
],
stbInfo
,
pThreadInfo
,
timestamp
);
timestamp
+=
timeStampStep
;
j
++
;
if
(
j
==
insertRows
)
{
break
;
}
}
uint64_t
startTs
=
taosGetTimestampUs
();
int32_t
affectedRows
=
execInsert
(
pThreadInfo
,
g_args
.
reqPerReq
);
uint64_t
endTs
=
taosGetTimestampUs
();
uint64_t
delay
=
endTs
-
startTs
;
performancePrint
(
"%s() LN%d, insert execution time is %10.f ms
\n
"
,
__func__
,
__LINE__
,
delay
/
1000
.
0
);
verbosePrint
(
"[%d] %s() LN%d affectedRows=%d
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
affectedRows
);
if
(
delay
>
pThreadInfo
->
maxDelay
){
pThreadInfo
->
maxDelay
=
delay
;
}
if
(
delay
<
pThreadInfo
->
minDelay
){
pThreadInfo
->
minDelay
=
delay
;
}
pThreadInfo
->
cntDelay
++
;
pThreadInfo
->
totalDelay
+=
delay
;
pThreadInfo
->
totalAffectedRows
+=
affectedRows
;
pThreadInfo
->
totalInsertRows
+=
g_args
.
reqPerReq
;
currentPercent
=
pThreadInfo
->
totalAffectedRows
*
g_Dbs
.
threadCount
/
insertRows
;
if
(
currentPercent
>
percentComplete
)
{
printf
(
"[%d]:%d%%
\n
"
,
pThreadInfo
->
threadID
,
currentPercent
);
percentComplete
=
currentPercent
;
}
int64_t
currentPrintTime
=
taosGetTimestampMs
();
if
(
currentPrintTime
-
lastPrintTime
>
30
*
1000
)
{
printf
(
"thread[%d] has currently inserted rows: %"
PRId64
", affected rows: %"
PRId64
"
\n
"
,
pThreadInfo
->
threadID
,
pThreadInfo
->
totalInsertRows
,
pThreadInfo
->
totalAffectedRows
);
lastPrintTime
=
currentPrintTime
;
}
for
(
int
index
=
0
;
index
<
g_args
.
reqPerReq
;
index
++
)
{
free
(
pThreadInfo
->
lines
[
index
]);
}
if
(
j
==
insertRows
)
{
break
;
}
}
}
tmfree
(
pThreadInfo
->
lines
);
for
(
int
index
=
0
;
index
<
pThreadInfo
->
ntables
;
index
++
)
{
free
(
smlHead
[
index
]);
}
return
NULL
;
}
// sync insertion progressive data
// sync insertion progressive data
static
void
*
syncWriteProgressive
(
threadInfo
*
pThreadInfo
)
{
static
void
*
syncWriteProgressive
(
threadInfo
*
pThreadInfo
)
{
debugPrint
(
"%s() LN%d: ### progressive write
\n
"
,
__func__
,
__LINE__
);
debugPrint
(
"%s() LN%d: ### progressive write
\n
"
,
__func__
,
__LINE__
);
...
@@ -10116,6 +10764,8 @@ static void* syncWrite(void *sarg) {
...
@@ -10116,6 +10764,8 @@ static void* syncWrite(void *sarg) {
#else
#else
return
syncWriteInterlaceStmt
(
pThreadInfo
,
interlaceRows
);
return
syncWriteInterlaceStmt
(
pThreadInfo
,
interlaceRows
);
#endif
#endif
}
else
if
(
SML_IFACE
==
stbInfo
->
iface
)
{
return
syncWriteInterlaceSml
(
pThreadInfo
,
interlaceRows
);
}
else
{
}
else
{
return
syncWriteInterlace
(
pThreadInfo
,
interlaceRows
);
return
syncWriteInterlace
(
pThreadInfo
,
interlaceRows
);
}
}
...
@@ -10125,6 +10775,9 @@ static void* syncWrite(void *sarg) {
...
@@ -10125,6 +10775,9 @@ static void* syncWrite(void *sarg) {
if
(((
stbInfo
)
&&
(
STMT_IFACE
==
stbInfo
->
iface
))
if
(((
stbInfo
)
&&
(
STMT_IFACE
==
stbInfo
->
iface
))
||
(
STMT_IFACE
==
g_args
.
iface
))
{
||
(
STMT_IFACE
==
g_args
.
iface
))
{
return
syncWriteProgressiveStmt
(
pThreadInfo
);
return
syncWriteProgressiveStmt
(
pThreadInfo
);
}
else
if
(((
stbInfo
)
&&
(
SML_IFACE
==
stbInfo
->
iface
))
||
(
SML_IFACE
==
g_args
.
iface
))
{
return
syncWriteProgressiveSml
(
pThreadInfo
);
}
else
{
}
else
{
return
syncWriteProgressive
(
pThreadInfo
);
return
syncWriteProgressive
(
pThreadInfo
);
}
}
...
@@ -10282,7 +10935,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -10282,7 +10935,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
// read sample data from file first
// read sample data from file first
int
ret
;
int
ret
;
if
(
stbInfo
)
{
if
(
stbInfo
&&
stbInfo
->
iface
!=
SML_IFACE
)
{
ret
=
prepareSampleForStb
(
stbInfo
);
ret
=
prepareSampleForStb
(
stbInfo
);
}
else
{
}
else
{
ret
=
prepareSampleForNtb
();
ret
=
prepareSampleForNtb
();
...
@@ -10305,72 +10958,76 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -10305,72 +10958,76 @@ static void startMultiThreadInsertData(int threads, char* db_name,
int64_t
ntables
=
0
;
int64_t
ntables
=
0
;
uint64_t
tableFrom
;
uint64_t
tableFrom
;
if
(
stbInfo
)
{
if
(
stbInfo
)
{
int64_t
limit
;
if
(
stbInfo
->
iface
!=
SML_IFACE
)
{
uint64_t
offset
;
int64_t
limit
;
uint64_t
offset
;
if
((
NULL
!=
g_args
.
sqlFile
)
if
((
NULL
!=
g_args
.
sqlFile
)
&&
(
stbInfo
->
childTblExists
==
TBL_NO_EXISTS
)
&&
(
stbInfo
->
childTblExists
==
TBL_NO_EXISTS
)
&&
((
stbInfo
->
childTblOffset
!=
0
)
&&
((
stbInfo
->
childTblOffset
!=
0
)
||
(
stbInfo
->
childTblLimit
>=
0
)))
{
||
(
stbInfo
->
childTblLimit
>=
0
)))
{
printf
(
"WARNING: offset and limit will not be used since the child tables not exists!
\n
"
);
printf
(
"WARNING: offset and limit will not be used since the child tables not exists!
\n
"
);
}
}
if
(
stbInfo
->
childTblExists
==
TBL_ALREADY_EXISTS
)
{
if
(
stbInfo
->
childTblExists
==
TBL_ALREADY_EXISTS
)
{
if
((
stbInfo
->
childTblLimit
<
0
)
if
((
stbInfo
->
childTblLimit
<
0
)
||
((
stbInfo
->
childTblOffset
||
((
stbInfo
->
childTblOffset
+
stbInfo
->
childTblLimit
)
+
stbInfo
->
childTblLimit
)
>
(
stbInfo
->
childTblCount
)))
{
>
(
stbInfo
->
childTblCount
)))
{
if
(
stbInfo
->
childTblCount
<
stbInfo
->
childTblOffset
)
{
if
(
stbInfo
->
childTblCount
<
stbInfo
->
childTblOffset
)
{
printf
(
"WARNING: offset will not be used since the child tables count is less then offset!
\n
"
);
printf
(
"WARNING: offset will not be used since the child tables count is less then offset!
\n
"
);
stbInfo
->
childTblOffset
=
0
;
stbInfo
->
childTblOffset
=
0
;
}
stbInfo
->
childTblLimit
=
stbInfo
->
childTblCount
-
stbInfo
->
childTblOffset
;
}
}
stbInfo
->
childTblLimit
=
stbInfo
->
childTblCount
-
stbInfo
->
childTblOffset
;
offset
=
stbInfo
->
childTblOffset
;
limit
=
stbInfo
->
childTblLimit
;
}
else
{
limit
=
stbInfo
->
childTblCount
;
offset
=
0
;
}
}
offset
=
stbInfo
->
childTblOffset
;
ntables
=
limit
;
limit
=
stbInfo
->
childTblLimit
;
tableFrom
=
offset
;
}
else
{
limit
=
stbInfo
->
childTblCount
;
offset
=
0
;
}
ntables
=
limit
;
if
((
stbInfo
->
childTblExists
!=
TBL_NO_EXISTS
)
tableFrom
=
offset
;
&&
((
stbInfo
->
childTblOffset
+
stbInfo
->
childTblLimit
)
>
stbInfo
->
childTblCount
))
{
printf
(
"WARNING: specified offset + limit > child table count!
\n
"
);
prompt
();
}
if
((
stbInfo
->
childTblExists
!=
TBL_NO_EXISTS
)
if
((
stbInfo
->
childTblExists
!=
TBL_NO_EXISTS
)
&&
((
stbInfo
->
childTblOffset
+
stbInfo
->
childTblLimit
)
&&
(
0
==
stbInfo
->
childTblLimit
))
{
>
stbInfo
->
childTblCount
))
{
printf
(
"WARNING: specified limit = 0, which cannot find table name to insert or query!
\n
"
);
printf
(
"WARNING: specified offset + limit > child table count!
\n
"
);
prompt
();
prompt
();
}
}
if
((
stbInfo
->
childTblExists
!=
TBL_NO_EXISTS
)
stbInfo
->
childTblName
=
(
char
*
)
calloc
(
1
,
&&
(
0
==
stbInfo
->
childTblLimit
))
{
limit
*
TSDB_TABLE_NAME_LEN
);
printf
(
"WARNING: specified limit = 0, which cannot find table name to insert or query!
\n
"
);
if
(
stbInfo
->
childTblName
==
NULL
)
{
prompt
();
taos_close
(
taos0
);
}
errorPrint2
(
"%s() LN%d, alloc memory failed!
\n
"
,
__func__
,
__LINE__
);
exit
(
EXIT_FAILURE
);
}
stbInfo
->
childTblName
=
(
char
*
)
calloc
(
1
,
int64_t
childTblCount
;
limit
*
TSDB_TABLE_NAME_LEN
);
getChildNameOfSuperTableWithLimitAndOffset
(
if
(
stbInfo
->
childTblName
==
NULL
)
{
taos0
,
taos_close
(
taos0
);
db_name
,
stbInfo
->
stbName
,
errorPrint2
(
"%s() LN%d, alloc memory failed!
\n
"
,
__func__
,
__LINE__
);
&
stbInfo
->
childTblName
,
&
childTblCount
,
exit
(
EXIT_FAILURE
);
limit
,
offset
,
stbInfo
->
escapeChar
);
ntables
=
childTblCount
;
}
else
{
ntables
=
stbInfo
->
childTblCount
;
}
}
int64_t
childTblCount
;
getChildNameOfSuperTableWithLimitAndOffset
(
taos0
,
db_name
,
stbInfo
->
stbName
,
&
stbInfo
->
childTblName
,
&
childTblCount
,
limit
,
offset
,
stbInfo
->
escapeChar
);
ntables
=
childTblCount
;
}
else
{
}
else
{
ntables
=
g_args
.
ntables
;
ntables
=
g_args
.
ntables
;
tableFrom
=
0
;
tableFrom
=
0
;
...
@@ -10954,33 +11611,34 @@ static int insertTestProcess() {
...
@@ -10954,33 +11611,34 @@ static int insertTestProcess() {
double
start
;
double
start
;
double
end
;
double
end
;
if
(
g_totalChildTables
>
0
)
{
if
(
g_args
.
iface
!=
SML_IFACE
)
{
fprintf
(
stderr
,
if
(
g_totalChildTables
>
0
)
{
"creating %"
PRId64
" table(s) with %d thread(s)
\n\n
"
,
fprintf
(
stderr
,
g_totalChildTables
,
g_Dbs
.
threadCountForCreateTbl
);
"creating %"
PRId64
" table(s) with %d thread(s)
\n\n
"
,
if
(
g_fpOfInsertResult
)
{
g_totalChildTables
,
g_Dbs
.
threadCountForCreateTbl
);
fprintf
(
g_fpOfInsertResult
,
if
(
g_fpOfInsertResult
)
{
"creating %"
PRId64
" table(s) with %d thread(s)
\n\n
"
,
fprintf
(
g_fpOfInsertResult
,
g_totalChildTables
,
g_Dbs
.
threadCountForCreateTbl
);
"creating %"
PRId64
" table(s) with %d thread(s)
\n\n
"
,
}
g_totalChildTables
,
g_Dbs
.
threadCountForCreateTbl
);
}
// create child tables
// create child tables
start
=
taosGetTimestampMs
();
start
=
taosGetTimestampMs
();
createChildTables
();
createChildTables
();
end
=
taosGetTimestampMs
();
end
=
taosGetTimestampMs
();
fprintf
(
stderr
,
fprintf
(
stderr
,
"
\n
Spent %.4f seconds to create %"
PRId64
" table(s) with %d thread(s), actual %"
PRId64
" table(s) created
\n\n
"
,
"
\n
Spent %.4f seconds to create %"
PRId64
" table(s) with %d thread(s), actual %"
PRId64
" table(s) created
\n\n
"
,
(
end
-
start
)
/
1000
.
0
,
g_totalChildTables
,
(
end
-
start
)
/
1000
.
0
,
g_totalChildTables
,
g_Dbs
.
threadCountForCreateTbl
,
g_actualChildTables
);
g_Dbs
.
threadCountForCreateTbl
,
g_actualChildTables
);
if
(
g_fpOfInsertResult
)
{
if
(
g_fpOfInsertResult
)
{
fprintf
(
g_fpOfInsertResult
,
fprintf
(
g_fpOfInsertResult
,
"
\n
Spent %.4f seconds to create %"
PRId64
" table(s) with %d thread(s), actual %"
PRId64
" table(s) created
\n\n
"
,
"
\n
Spent %.4f seconds to create %"
PRId64
" table(s) with %d thread(s), actual %"
PRId64
" table(s) created
\n\n
"
,
(
end
-
start
)
/
1000
.
0
,
g_totalChildTables
,
(
end
-
start
)
/
1000
.
0
,
g_totalChildTables
,
g_Dbs
.
threadCountForCreateTbl
,
g_actualChildTables
);
g_Dbs
.
threadCountForCreateTbl
,
g_actualChildTables
);
}
}
}
}
}
// create sub threads for inserting data
// create sub threads for inserting data
//start = taosGetTimestampMs();
//start = taosGetTimestampMs();
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
...
@@ -11919,29 +12577,6 @@ static int subscribeTestProcess() {
...
@@ -11919,29 +12577,6 @@ static int subscribeTestProcess() {
return
0
;
return
0
;
}
}
static
void
initOfInsertMeta
()
{
memset
(
&
g_Dbs
,
0
,
sizeof
(
SDbs
));
// set default values
tstrncpy
(
g_Dbs
.
host
,
"127.0.0.1"
,
MAX_HOSTNAME_SIZE
);
g_Dbs
.
port
=
6030
;
tstrncpy
(
g_Dbs
.
user
,
TSDB_DEFAULT_USER
,
MAX_USERNAME_SIZE
);
tstrncpy
(
g_Dbs
.
password
,
TSDB_DEFAULT_PASS
,
SHELL_MAX_PASSWORD_LEN
);
g_Dbs
.
threadCount
=
2
;
g_Dbs
.
use_metric
=
g_args
.
use_metric
;
}
static
void
initOfQueryMeta
()
{
memset
(
&
g_queryInfo
,
0
,
sizeof
(
SQueryMetaInfo
));
// set default values
tstrncpy
(
g_queryInfo
.
host
,
"127.0.0.1"
,
MAX_HOSTNAME_SIZE
);
g_queryInfo
.
port
=
6030
;
tstrncpy
(
g_queryInfo
.
user
,
TSDB_DEFAULT_USER
,
MAX_USERNAME_SIZE
);
tstrncpy
(
g_queryInfo
.
password
,
TSDB_DEFAULT_PASS
,
SHELL_MAX_PASSWORD_LEN
);
}
static
void
setParaFromArg
()
{
static
void
setParaFromArg
()
{
char
type
[
20
];
char
type
[
20
];
char
length
[
20
];
char
length
[
20
];
...
@@ -11974,7 +12609,7 @@ static void setParaFromArg() {
...
@@ -11974,7 +12609,7 @@ static void setParaFromArg() {
tstrncpy
(
g_Dbs
.
resultFile
,
g_args
.
output_file
,
MAX_FILE_NAME_LEN
);
tstrncpy
(
g_Dbs
.
resultFile
,
g_args
.
output_file
,
MAX_FILE_NAME_LEN
);
g_Dbs
.
use_metric
=
g_args
.
use_metric
;
g_Dbs
.
use_metric
=
g_args
.
use_metric
;
g_args
.
prepared_rand
=
min
(
g_args
.
insertRows
,
MAX_PREPARED_RAND
);
g_Dbs
.
aggr_func
=
g_args
.
aggr_func
;
g_Dbs
.
aggr_func
=
g_args
.
aggr_func
;
char
dataString
[
TSDB_MAX_BYTES_PER_ROW
];
char
dataString
[
TSDB_MAX_BYTES_PER_ROW
];
...
@@ -12056,10 +12691,12 @@ static void setParaFromArg() {
...
@@ -12056,10 +12691,12 @@ static void setParaFromArg() {
tstrncpy
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tags
[
0
].
dataType
,
tstrncpy
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tags
[
0
].
dataType
,
"INT"
,
min
(
DATATYPE_BUFF_LEN
,
strlen
(
"INT"
)
+
1
));
"INT"
,
min
(
DATATYPE_BUFF_LEN
,
strlen
(
"INT"
)
+
1
));
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tags
[
0
].
data_type
=
TSDB_DATA_TYPE_INT
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tags
[
0
].
dataLen
=
0
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tags
[
0
].
dataLen
=
0
;
tstrncpy
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tags
[
1
].
dataType
,
tstrncpy
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tags
[
1
].
dataType
,
"BINARY"
,
min
(
DATATYPE_BUFF_LEN
,
strlen
(
"BINARY"
)
+
1
));
"BINARY"
,
min
(
DATATYPE_BUFF_LEN
,
strlen
(
"BINARY"
)
+
1
));
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tags
[
1
].
data_type
=
TSDB_DATA_TYPE_BINARY
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tags
[
1
].
dataLen
=
g_args
.
binwidth
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tags
[
1
].
dataLen
=
g_args
.
binwidth
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tagCount
=
2
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tagCount
=
2
;
}
else
{
}
else
{
...
@@ -12251,8 +12888,6 @@ int main(int argc, char *argv[]) {
...
@@ -12251,8 +12888,6 @@ int main(int argc, char *argv[]) {
if
(
g_args
.
metaFile
)
{
if
(
g_args
.
metaFile
)
{
g_totalChildTables
=
0
;
g_totalChildTables
=
0
;
initOfInsertMeta
();
initOfQueryMeta
();
if
(
false
==
getInfoFromJsonFile
(
g_args
.
metaFile
))
{
if
(
false
==
getInfoFromJsonFile
(
g_args
.
metaFile
))
{
printf
(
"Failed to read %s
\n
"
,
g_args
.
metaFile
);
printf
(
"Failed to read %s
\n
"
,
g_args
.
metaFile
);
...
@@ -12262,6 +12897,10 @@ int main(int argc, char *argv[]) {
...
@@ -12262,6 +12897,10 @@ int main(int argc, char *argv[]) {
testMetaFile
();
testMetaFile
();
}
else
{
}
else
{
memset
(
&
g_Dbs
,
0
,
sizeof
(
SDbs
));
memset
(
&
g_Dbs
,
0
,
sizeof
(
SDbs
));
g_Dbs
.
db
=
calloc
(
1
,
sizeof
(
SDataBase
));
assert
(
g_Dbs
.
db
);
g_Dbs
.
db
[
0
].
superTbls
=
calloc
(
1
,
sizeof
(
SSuperTable
));
assert
(
g_Dbs
.
db
[
0
].
superTbls
);
setParaFromArg
();
setParaFromArg
();
if
(
NULL
!=
g_args
.
sqlFile
)
{
if
(
NULL
!=
g_args
.
sqlFile
)
{
...
...
src/kit/taosdump/taosdump.c
浏览文件 @
65b415d8
...
@@ -3005,7 +3005,13 @@ int main(int argc, char *argv[]) {
...
@@ -3005,7 +3005,13 @@ int main(int argc, char *argv[]) {
printf
(
"debug_print: %d
\n
"
,
g_args
.
debug_print
);
printf
(
"debug_print: %d
\n
"
,
g_args
.
debug_print
);
for
(
int32_t
i
=
0
;
i
<
g_args
.
arg_list_len
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
g_args
.
arg_list_len
;
i
++
)
{
printf
(
"arg_list[%d]: %s
\n
"
,
i
,
g_args
.
arg_list
[
i
]);
if
(
g_args
.
databases
||
g_args
.
all_databases
)
{
errorPrint
(
"%s is an invalid input if database(s) be already specified.
\n
"
,
g_args
.
arg_list
[
i
]);
exit
(
EXIT_FAILURE
);
}
else
{
printf
(
"arg_list[%d]: %s
\n
"
,
i
,
g_args
.
arg_list
[
i
]);
}
}
}
printf
(
"==============================
\n
"
);
printf
(
"==============================
\n
"
);
...
...
blm3
@
c67fcc11
比较
4bfae86d
...
c67fcc11
Subproject commit
4bfae86dcabea0d5a40ff81a72be7c822737269b
Subproject commit
c67fcc11bc5e82e3d7aea8db855a8cbf8b109239
src/plugins/monitor/src/monMain.c
浏览文件 @
65b415d8
...
@@ -204,6 +204,7 @@ static void monBuildMonitorSql(char *sql, int32_t cmd) {
...
@@ -204,6 +204,7 @@ static void monBuildMonitorSql(char *sql, int32_t cmd) {
", disk_used float, disk_total int"
", disk_used float, disk_total int"
", band_speed float"
", band_speed float"
", io_read float, io_write float"
", io_read float, io_write float"
", io_read_rate float, io_write_rate float"
", req_http int, req_select int, req_insert int"
", req_http int, req_select int, req_insert int"
") tags (dnodeid int, fqdn binary(%d))"
,
") tags (dnodeid int, fqdn binary(%d))"
,
tsMonitorDbName
,
TSDB_FQDN_LEN
);
tsMonitorDbName
,
TSDB_FQDN_LEN
);
...
@@ -325,7 +326,10 @@ static int32_t monBuildIoSql(char *sql) {
...
@@ -325,7 +326,10 @@ static int32_t monBuildIoSql(char *sql) {
monDebug
(
"failed to get io info"
);
monDebug
(
"failed to get io info"
);
}
}
return
sprintf
(
sql
,
", %f, %f"
,
readKB
,
writeKB
);
float
readRate
=
readKB
/
tsMonitorInterval
;
float
writeRate
=
writeKB
/
tsMonitorInterval
;
return
sprintf
(
sql
,
", %f, %f, %f, %f"
,
readKB
,
writeKB
,
readRate
,
writeRate
);
}
}
static
void
monSaveSystemInfo
()
{
static
void
monSaveSystemInfo
()
{
...
...
src/query/src/qExecutor.c
浏览文件 @
65b415d8
...
@@ -365,7 +365,8 @@ int32_t getNumOfResult(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx* pCtx, int3
...
@@ -365,7 +365,8 @@ int32_t getNumOfResult(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx* pCtx, int3
* ts, tag, tagprj function can not decide the output number of current query
* ts, tag, tagprj function can not decide the output number of current query
* the number of output result is decided by main output
* the number of output result is decided by main output
*/
*/
if
(
hasMainFunction
&&
(
id
==
TSDB_FUNC_TS
||
id
==
TSDB_FUNC_TAG
||
id
==
TSDB_FUNC_TAGPRJ
))
{
if
(
hasMainFunction
&&
(
id
==
TSDB_FUNC_TS
||
id
==
TSDB_FUNC_TAG
||
id
==
TSDB_FUNC_TAGPRJ
||
id
==
TSDB_FUNC_TS_DUMMY
||
id
==
TSDB_FUNC_TAG_DUMMY
))
{
continue
;
continue
;
}
}
...
...
src/tsdb/src/tsdbCompact.c
浏览文件 @
65b415d8
...
@@ -441,6 +441,7 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) {
...
@@ -441,6 +441,7 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) {
if
((
tdInitDataCols
(
pComph
->
pDataCols
,
pSchema
)
<
0
)
||
(
tdInitDataCols
(
pReadh
->
pDCols
[
0
],
pSchema
)
<
0
)
||
if
((
tdInitDataCols
(
pComph
->
pDataCols
,
pSchema
)
<
0
)
||
(
tdInitDataCols
(
pReadh
->
pDCols
[
0
],
pSchema
)
<
0
)
||
(
tdInitDataCols
(
pReadh
->
pDCols
[
1
],
pSchema
)
<
0
))
{
(
tdInitDataCols
(
pReadh
->
pDCols
[
1
],
pSchema
)
<
0
))
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
tdFreeSchema
(
pSchema
);
return
-
1
;
return
-
1
;
}
}
tdFreeSchema
(
pSchema
);
tdFreeSchema
(
pSchema
);
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
65b415d8
...
@@ -1620,7 +1620,7 @@ static void mergeTwoRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
...
@@ -1620,7 +1620,7 @@ static void mergeTwoRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
SColIdx
*
pColIdx
=
kvRowColIdxAt
(
rowBody
,
chosen_itr
);
SColIdx
*
pColIdx
=
kvRowColIdxAt
(
rowBody
,
chosen_itr
);
colId
=
pColIdx
->
colId
;
colId
=
pColIdx
->
colId
;
offset
=
pColIdx
->
offset
;
offset
=
pColIdx
->
offset
;
value
=
tdGetKvRowDataOfCol
(
rowBody
,
pColIdx
->
offset
);
value
=
tdGetKvRowDataOfCol
(
rowBody
,
offset
);
}
}
...
...
tests/examples/c/prepare.c
浏览文件 @
65b415d8
...
@@ -184,6 +184,10 @@ void verify_prepare(TAOS* taos) {
...
@@ -184,6 +184,10 @@ void verify_prepare(TAOS* taos) {
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
int
affectedRows
=
taos_stmt_affected_rows
(
stmt
);
printf
(
"sucessfully inserted %d rows
\n
"
,
affectedRows
);
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
// query the records
// query the records
...
@@ -400,6 +404,9 @@ void verify_prepare2(TAOS* taos) {
...
@@ -400,6 +404,9 @@ void verify_prepare2(TAOS* taos) {
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
int
affectedRows
=
taos_stmt_affected_rows
(
stmt
);
printf
(
"sucessfully inserted %d rows
\n
"
,
affectedRows
);
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
// query the records
// query the records
...
@@ -784,6 +791,10 @@ void verify_prepare3(TAOS* taos) {
...
@@ -784,6 +791,10 @@ void verify_prepare3(TAOS* taos) {
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
int
affectedRows
=
taos_stmt_affected_rows
(
stmt
);
printf
(
"successfully inserted %d rows
\n
"
,
affectedRows
);
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
// query the records
// query the records
...
...
tests/pytest/fulltest.sh
浏览文件 @
65b415d8
...
@@ -391,6 +391,7 @@ python3 ./test.py -f tag_lite/alter_tag.py
...
@@ -391,6 +391,7 @@ python3 ./test.py -f tag_lite/alter_tag.py
python3 test.py
-f
tools/taosdemoAllTest/TD-4985/query-limit-offset.py
python3 test.py
-f
tools/taosdemoAllTest/TD-4985/query-limit-offset.py
python3 test.py
-f
tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py
python3 test.py
-f
tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py
python3 test.py
-f
tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py
python3 test.py
-f
tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py
python3 test.py
-f
tools/taosdemoAllTest/TD-10539/create_taosdemo.py
python3 ./test.py
-f
tag_lite/drop_auto_create.py
python3 ./test.py
-f
tag_lite/drop_auto_create.py
python3 test.py
-f
insert/insert_before_use_db.py
python3 test.py
-f
insert/insert_before_use_db.py
python3 test.py
-f
alter/alter_keep.py
python3 test.py
-f
alter/alter_keep.py
...
...
tests/pytest/insert/insertTelnetLines.py
浏览文件 @
65b415d8
...
@@ -29,7 +29,6 @@ class TDTestCase:
...
@@ -29,7 +29,6 @@ class TDTestCase:
tdSql
.
execute
(
"create database if not exists test precision 'us'"
)
tdSql
.
execute
(
"create database if not exists test precision 'us'"
)
tdSql
.
execute
(
'use test'
)
tdSql
.
execute
(
'use test'
)
### metric ###
### metric ###
print
(
"============= step1 : test metric ================"
)
print
(
"============= step1 : test metric ================"
)
lines0
=
[
lines0
=
[
...
@@ -215,7 +214,7 @@ class TDTestCase:
...
@@ -215,7 +214,7 @@ class TDTestCase:
#binary
#binary
lines2_7
=
[
lines2_7
=
[
"stb2_7 1626006833610ms
\"
binary_val.!@#$%^&*
\"
host=
\"
host0
\"
"
,
"stb2_7 1626006833610ms
\"
binary_val .!@#$%^&*
\"
host=
\"
host0
\"
"
,
"stb2_7 1626006833620ms
\"
binary_val.:;,./?|+-=
\"
host=
\"
host0
\"
"
,
"stb2_7 1626006833620ms
\"
binary_val.:;,./?|+-=
\"
host=
\"
host0
\"
"
,
"stb2_7 1626006833630ms
\"
binary_val.()[]{}<>
\"
host=
\"
host0
\"
"
"stb2_7 1626006833630ms
\"
binary_val.()[]{}<>
\"
host=
\"
host0
\"
"
]
]
...
@@ -232,7 +231,7 @@ class TDTestCase:
...
@@ -232,7 +231,7 @@ class TDTestCase:
#nchar
#nchar
lines2_8
=
[
lines2_8
=
[
"stb2_8 1626006833610ms L
\"
nchar_val数值一
\"
host=
\"
host0
\"
"
,
"stb2_8 1626006833610ms L
\"
nchar_val 数值一
\"
host=
\"
host0
\"
"
,
"stb2_8 1626006833620ms L
\"
nchar_val数值二
\"
host=
\"
host0
\"
"
"stb2_8 1626006833620ms L
\"
nchar_val数值二
\"
host=
\"
host0
\"
"
]
]
...
...
tests/pytest/insert/line_insert.py
浏览文件 @
65b415d8
...
@@ -31,9 +31,9 @@ class TDTestCase:
...
@@ -31,9 +31,9 @@ class TDTestCase:
tdSql
.
execute
(
'create stable ste(ts timestamp, f int) tags(t1 bigint)'
)
tdSql
.
execute
(
'create stable ste(ts timestamp, f int) tags(t1 bigint)'
)
lines
=
[
"st,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000"
,
lines
=
[
"st,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
\"\"
a pa,
\"
s si,t
\"\"
\"
,c2=false,c4=4f64 1626006833639000000"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 1626006833640000000"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 1626006833640000000"
,
"ste,t2=5f64,t3=L
\"
ste
\"
c1=true,c2=4i64,c3=
\"
iam
\"
1626056811823316532"
,
"ste,t2=5f64,t3=L
\"
ste
\"
c1=true,c2=4i64,c3=
\"
i,
\"
a
\"
m,
\"\"
\"
1626056811823316532"
,
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000"
,
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000"
,
"st,t1=4i64,t2=5f64,t3=
\"
t4
\"
c1=3i64,c3=L
\"
passitagain
\"
,c2=true,c4=5f64 1626006833642000000"
,
"st,t1=4i64,t2=5f64,t3=
\"
t4
\"
c1=3i64,c3=L
\"
passitagain
\"
,c2=true,c4=5f64 1626006833642000000"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false 1626056811843316532"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false 1626056811843316532"
,
...
...
tests/pytest/table/create.py
浏览文件 @
65b415d8
...
@@ -298,8 +298,7 @@ class TDTestCase:
...
@@ -298,8 +298,7 @@ class TDTestCase:
print
(
"==============step3,#create regular_table; insert regular_table; show regular_table; select regular_table; drop regular_table"
)
print
(
"==============step3,#create regular_table; insert regular_table; show regular_table; select regular_table; drop regular_table"
)
self
.
regular_table
=
"regular_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}"
self
.
regular_table
=
"regular_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}"
#self.regular_table = "regular_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}"
tdSql
.
execute
(
"create table `%s` (ts timestamp,i int) ;"
%
self
.
regular_table
)
tdSql
.
execute
(
"create table `%s` (ts timestamp,i int) ;"
%
self
.
regular_table
)
tdSql
.
query
(
"describe `%s` ; "
%
self
.
regular_table
)
tdSql
.
query
(
"describe `%s` ; "
%
self
.
regular_table
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
...
@@ -328,9 +327,9 @@ class TDTestCase:
...
@@ -328,9 +327,9 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
self
.
crr_tb
=
"create_r_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}"
self
.
crr_tb
=
"create_r_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}"
#
tdSql.execute("create table `%s` as select * from `%s` ;" %(self.crr_tb,self.regular_table))
tdSql
.
execute
(
"create table `%s` as select * from `%s` ;"
%
(
self
.
crr_tb
,
self
.
regular_table
))
# tdSql.query("show db
.tables like 'create_r_table%' ")
tdSql
.
query
(
"show db2
.tables like 'create_r_table%' "
)
#
tdSql.checkRows(1)
tdSql
.
checkRows
(
1
)
print
(
"==============drop table\stable"
)
print
(
"==============drop table\stable"
)
try
:
try
:
...
@@ -340,15 +339,6 @@ class TDTestCase:
...
@@ -340,15 +339,6 @@ class TDTestCase:
tdSql
.
error
(
"select * from `%s`"
%
self
.
regular_table
)
tdSql
.
error
(
"select * from `%s`"
%
self
.
regular_table
)
#表名:192个字符,还要包含前面的数据库名
#taosdemo 建数据库表 # 单独放
# self.tsdemo = "tsdemo~!@#$%^&*()-_+=[]{}"
# os.system("%staosdemo -d test -m `%s` -t 10 -n 100 -l 10 -y " % (binPath,self.tsdemo))
# tdSql.execute("use #!#!#!")
# tdSql.query("select count (tbname) from #!#!#!")
# tdSql.checkData(0, 0, 1000)
...
...
tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo.py
0 → 100644
浏览文件 @
65b415d8
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
import
time
import
os
from
util.log
import
tdLog
from
util.cases
import
tdCases
from
util.sql
import
tdSql
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
projPath
=
selfPath
[:
selfPath
.
find
(
"community"
)]
else
:
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
if
(
"taosd"
in
files
):
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
if
(
"packaging"
not
in
rootRealPath
):
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
break
return
buildPath
def
run
(
self
):
buildPath
=
self
.
getBuildPath
()
if
(
buildPath
==
""
):
tdLog
.
exit
(
"taosd not found!"
)
else
:
tdLog
.
info
(
"taosd found in %s"
%
buildPath
)
binPath
=
buildPath
+
"/build/bin/"
os
.
system
(
"rm -rf tools/taosdemoAllTest/TD-10539/create_taosdemo.py.sql"
)
tdSql
.
prepare
()
#print("==============taosdemo,#create stable,table; insert table; show table; select table; drop table")
self
.
tsdemo
=
"tsdemo~!.@#$%^*[]-_=+{,?.}"
#this escape character is not support in shell . include & () <> | /
os
.
system
(
"%staosdemo -d test -E -m %s -t 10 -n 100 -l 10 -y "
%
(
binPath
,
self
.
tsdemo
))
tdSql
.
execute
(
"use test ;"
)
tdSql
.
query
(
"select count(*) from meters"
)
tdSql
.
checkData
(
0
,
0
,
1000
)
tdSql
.
query
(
"show test.tables like 'tsdemo%'"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"show test.tables like '%s_'"
%
self
.
tsdemo
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select _block_dist() from `%s1`"
%
self
.
tsdemo
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"describe test.`%s1` ; "
%
self
.
tsdemo
)
tdSql
.
checkRows
(
13
)
tdSql
.
query
(
"show create table test.`%s1` ; "
%
self
.
tsdemo
)
tdSql
.
checkData
(
0
,
0
,
self
.
tsdemo
+
str
(
1
))
tdSql
.
checkData
(
0
,
1
,
"CREATE TABLE `%s1` USING `meters` TAGS (1,
\"
beijing
\"
)"
%
self
.
tsdemo
)
print
(
"==============drop table\stable"
)
try
:
tdSql
.
execute
(
"drop table test.`%s1` ; "
%
self
.
tsdemo
)
except
Exception
as
e
:
tdLog
.
exit
(
e
)
tdSql
.
error
(
"select * from test.`%s1` ; "
%
self
.
tsdemo
)
tdSql
.
query
(
"show test.tables like '%s_'"
%
self
.
tsdemo
)
tdSql
.
checkRows
(
9
)
try
:
tdSql
.
execute
(
"drop table test.meters "
)
except
Exception
as
e
:
tdLog
.
exit
(
e
)
tdSql
.
error
(
"select * from test.meters "
)
tdSql
.
error
(
"select * from test.`%s2` ; "
%
self
.
tsdemo
)
# Exception
os
.
system
(
"%staosdemo -d test -m %s -t 10 -n 100 -l 10 -y "
%
(
binPath
,
self
.
tsdemo
))
tdSql
.
query
(
"show test.tables "
)
tdSql
.
checkRows
(
0
)
#print("==============taosdemo,#create regular table; insert table; show table; select table; drop table")
self
.
tsdemo
=
"tsdemo~!.@#$%^*[]-_=+{,?.}"
#this escape character is not support in shell . include & () <> | /
os
.
system
(
"%staosdemo -N -E -m %s -t 10 -n 100 -l 10 -y "
%
(
binPath
,
self
.
tsdemo
))
tdSql
.
execute
(
"use test ;"
)
tdSql
.
query
(
"select count(*) from `%s1`"
%
self
.
tsdemo
)
tdSql
.
checkData
(
0
,
0
,
100
)
tdSql
.
query
(
"show test.tables like 'tsdemo%'"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"show test.tables like '%s_'"
%
self
.
tsdemo
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select _block_dist() from `%s1`"
%
self
.
tsdemo
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"describe test.`%s1` ; "
%
self
.
tsdemo
)
tdSql
.
checkRows
(
11
)
tdSql
.
query
(
"show create table test.`%s1` ; "
%
self
.
tsdemo
)
tdSql
.
checkData
(
0
,
0
,
self
.
tsdemo
+
str
(
1
))
tdSql
.
checkData
(
0
,
1
,
"create table `%s1` (ts TIMESTAMP,c0 FLOAT,c1 INT,c2 INT,c3 INT,c4 INT,c5 INT,c6 INT,c7 INT,c8 INT,c9 INT)"
%
self
.
tsdemo
)
print
(
"==============drop table\stable"
)
try
:
tdSql
.
execute
(
"drop table test.`%s1` ; "
%
self
.
tsdemo
)
except
Exception
as
e
:
tdLog
.
exit
(
e
)
tdSql
.
error
(
"select * from test.`%s1` ; "
%
self
.
tsdemo
)
tdSql
.
query
(
"show test.tables like '%s_'"
%
self
.
tsdemo
)
tdSql
.
checkRows
(
9
)
# Exception
os
.
system
(
"%staosdemo -N -m %s -t 10 -n 100 -l 10 -y "
%
(
binPath
,
self
.
tsdemo
))
tdSql
.
query
(
"show test.tables "
)
tdSql
.
checkRows
(
0
)
#print("==============taosdemo——json_yes,#create stable,table; insert table; show table; select table; drop table")
os
.
system
(
"%staosdemo -f tools/taosdemoAllTest/TD-10539/create_taosdemo_yes.json -y "
%
binPath
)
tdSql
.
execute
(
"use dbyes"
)
self
.
tsdemo_stable
=
"tsdemo_stable~!.@#$%^*[]-_=+{,?.}"
self
.
tsdemo
=
"tsdemo~!.@#$%^*[]-_=+{,?.}"
tdSql
.
query
(
"select count(*) from dbyes.`%s`"
%
self
.
tsdemo_stable
)
tdSql
.
checkData
(
0
,
0
,
1000
)
tdSql
.
query
(
"show dbyes.tables like 'tsdemo%'"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"show dbyes.tables like '%s_'"
%
self
.
tsdemo
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select _block_dist() from `%s1`"
%
self
.
tsdemo
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"describe dbyes.`%s1` ; "
%
self
.
tsdemo
)
tdSql
.
checkRows
(
13
)
tdSql
.
query
(
"show create table dbyes.`%s1` ; "
%
self
.
tsdemo
)
tdSql
.
checkData
(
0
,
0
,
self
.
tsdemo
+
str
(
1
))
tdSql
.
checkData
(
0
,
1
,
"CREATE TABLE `%s1` USING `%s` TAGS (1,1)"
%
(
self
.
tsdemo
,
self
.
tsdemo_stable
))
print
(
"==============drop table\stable"
)
try
:
tdSql
.
execute
(
"drop table dbyes.`%s1` ; "
%
self
.
tsdemo
)
except
Exception
as
e
:
tdLog
.
exit
(
e
)
tdSql
.
error
(
"select * from dbyes.`%s1` ; "
%
self
.
tsdemo
)
tdSql
.
query
(
"show dbyes.tables like '%s_'"
%
self
.
tsdemo
)
tdSql
.
checkRows
(
9
)
try
:
tdSql
.
execute
(
"drop table dbyes.`%s` ; "
%
self
.
tsdemo_stable
)
except
Exception
as
e
:
tdLog
.
exit
(
e
)
tdSql
.
error
(
"select * from dbyes.`%s` ; "
%
self
.
tsdemo_stable
)
tdSql
.
error
(
"select * from dbyes.`%s2` ; "
%
self
.
tsdemo
)
#print("==============taosdemo——json_no,#create stable,table; insert table; show table; select table; drop table")
assert
os
.
system
(
"%staosdemo -f tools/taosdemoAllTest/TD-10539/create_taosdemo_no.json -y "
%
binPath
)
==
0
tdSql
.
query
(
"show dbno.tables "
)
tdSql
.
checkRows
(
0
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo_no.json
0 → 100644
浏览文件 @
65b415d8
{
"filetype"
:
"insert"
,
"cfgdir"
:
"/etc/taos"
,
"host"
:
"127.0.0.1"
,
"port"
:
6030
,
"user"
:
"root"
,
"password"
:
"taosdata"
,
"thread_count"
:
10
,
"thread_count_create_tbl"
:
10
,
"result_file"
:
"./insert_res.txt"
,
"confirm_parameter_prompt"
:
"no"
,
"insert_interval"
:
0
,
"interlace_rows"
:
10
,
"num_of_records_per_req"
:
1
,
"max_sql_len"
:
1024000
,
"databases"
:
[{
"dbinfo"
:
{
"name"
:
"dbno"
,
"drop"
:
"yes"
,
"replica"
:
1
,
"days"
:
10
,
"cache"
:
50
,
"blocks"
:
8
,
"precision"
:
"ms"
,
"keep"
:
36500
,
"minRows"
:
100
,
"maxRows"
:
4096
,
"comp"
:
2
,
"walLevel"
:
1
,
"cachelast"
:
0
,
"quorum"
:
1
,
"fsync"
:
3000
,
"update"
:
0
},
"super_tables"
:
[{
"name"
:
"meters"
,
"child_table_exists"
:
"no"
,
"childtable_count"
:
10
,
"childtable_prefix"
:
"tsdemo~!.@#$%^*[]-_=+{,?.}"
,
"escape_character"
:
"no"
,
"auto_create_table"
:
"no"
,
"batch_create_tbl_num"
:
1
,
"data_source"
:
"rand"
,
"insert_mode"
:
"taosc"
,
"insert_rows"
:
100
,
"childtable_limit"
:
0
,
"childtable_offset"
:
0
,
"multi_thread_write_one_tbl"
:
"no"
,
"interlace_rows"
:
0
,
"insert_interval"
:
0
,
"max_sql_len"
:
1024000
,
"disorder_ratio"
:
0
,
"disorder_range"
:
1000
,
"timestamp_step"
:
1
,
"start_timestamp"
:
"2020-10-01 00:00:00.000"
,
"sample_format"
:
"csv"
,
"sample_file"
:
""
,
"tags_file"
:
""
,
"columns"
:
[{
"type"
:
"INT"
,
"count"
:
9
},
{
"type"
:
"BINARY"
,
"len"
:
16
,
"count"
:
1
}],
"tags"
:
[{
"type"
:
"INT"
,
"count"
:
2
}]
}]
}]
}
tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo_yes.json
0 → 100644
浏览文件 @
65b415d8
{
"filetype"
:
"insert"
,
"cfgdir"
:
"/etc/taos"
,
"host"
:
"127.0.0.1"
,
"port"
:
6030
,
"user"
:
"root"
,
"password"
:
"taosdata"
,
"thread_count"
:
5
,
"thread_count_create_tbl"
:
10
,
"result_file"
:
"./insert_res.txt"
,
"confirm_parameter_prompt"
:
"no"
,
"insert_interval"
:
0
,
"interlace_rows"
:
10
,
"num_of_records_per_req"
:
1
,
"max_sql_len"
:
1024000
,
"databases"
:
[{
"dbinfo"
:
{
"name"
:
"dbyes"
,
"drop"
:
"yes"
,
"replica"
:
1
,
"days"
:
10
,
"cache"
:
50
,
"blocks"
:
8
,
"precision"
:
"ms"
,
"keep"
:
36500
,
"minRows"
:
100
,
"maxRows"
:
4096
,
"comp"
:
2
,
"walLevel"
:
1
,
"cachelast"
:
0
,
"quorum"
:
1
,
"fsync"
:
3000
,
"update"
:
0
},
"super_tables"
:
[{
"name"
:
"tsdemo_stable~!.@#$%^*[]-_=+{,?.}"
,
"child_table_exists"
:
"no"
,
"childtable_count"
:
10
,
"childtable_prefix"
:
"tsdemo~!.@#$%^*[]-_=+{,?.}"
,
"escape_character"
:
"yes"
,
"auto_create_table"
:
"no"
,
"batch_create_tbl_num"
:
1
,
"data_source"
:
"rand"
,
"insert_mode"
:
"taosc"
,
"insert_rows"
:
100
,
"childtable_limit"
:
0
,
"childtable_offset"
:
0
,
"multi_thread_write_one_tbl"
:
"no"
,
"interlace_rows"
:
0
,
"insert_interval"
:
0
,
"max_sql_len"
:
1024000
,
"disorder_ratio"
:
0
,
"disorder_range"
:
1000
,
"timestamp_step"
:
1
,
"start_timestamp"
:
"2020-10-01 00:00:00.000"
,
"sample_format"
:
"csv"
,
"sample_file"
:
""
,
"tags_file"
:
""
,
"columns"
:
[{
"type"
:
"INT"
,
"count"
:
9
},
{
"type"
:
"BINARY"
,
"len"
:
16
,
"count"
:
1
}],
"tags"
:
[{
"type"
:
"INT"
,
"count"
:
2
}]
}]
}]
}
tests/pytest/tools/taosdemoAllTest/stmt/nsertColumnsAndTagNumLarge4096-stmt.json
→
tests/pytest/tools/taosdemoAllTest/stmt/
i
nsertColumnsAndTagNumLarge4096-stmt.json
浏览文件 @
65b415d8
文件已移动
tests/pytest/tools/taosdumpTest3.py
浏览文件 @
65b415d8
...
@@ -62,8 +62,12 @@ class TDTestCase:
...
@@ -62,8 +62,12 @@ class TDTestCase:
os
.
makedirs
(
"./taosdumptest/tmp3"
)
os
.
makedirs
(
"./taosdumptest/tmp3"
)
if
not
os
.
path
.
exists
(
"./taosdumptest/tmp4"
):
if
not
os
.
path
.
exists
(
"./taosdumptest/tmp4"
):
os
.
makedirs
(
"./taosdumptest/tmp4"
)
os
.
makedirs
(
"./taosdumptest/tmp4"
)
if
not
os
.
path
.
exists
(
"./taosdumptest/tmp5"
):
os
.
makedirs
(
"./taosdumptest/tmp5"
)
if
not
os
.
path
.
exists
(
"./taosdumptest/tmp6"
):
os
.
makedirs
(
"./taosdumptest/tmp6"
)
if
not
os
.
path
.
exists
(
"./taosdumptest/tmp7"
):
os
.
makedirs
(
"./taosdumptest/tmp7"
)
buildPath
=
self
.
getBuildPath
()
buildPath
=
self
.
getBuildPath
()
if
(
buildPath
==
""
):
if
(
buildPath
==
""
):
tdLog
.
exit
(
"taosdump not found!"
)
tdLog
.
exit
(
"taosdump not found!"
)
...
@@ -72,6 +76,8 @@ class TDTestCase:
...
@@ -72,6 +76,8 @@ class TDTestCase:
binPath
=
buildPath
+
"/build/bin/"
binPath
=
buildPath
+
"/build/bin/"
# create db1 , one stables and one table ; create general tables
# create db1 , one stables and one table ; create general tables
tdSql
.
execute
(
"drop database if exists dp1"
)
tdSql
.
execute
(
"drop database if exists dp2"
)
tdSql
.
execute
(
"create database if not exists dp1"
)
tdSql
.
execute
(
"create database if not exists dp1"
)
tdSql
.
execute
(
"use dp1"
)
tdSql
.
execute
(
"use dp1"
)
tdSql
.
execute
(
"create stable st0(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int)"
)
tdSql
.
execute
(
"create stable st0(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int)"
)
...
@@ -82,9 +88,10 @@ class TDTestCase:
...
@@ -82,9 +88,10 @@ class TDTestCase:
tdSql
.
execute
(
"create table if not exists gt1 (ts timestamp, c0 int, c1 double) "
)
tdSql
.
execute
(
"create table if not exists gt1 (ts timestamp, c0 int, c1 double) "
)
tdSql
.
execute
(
"insert into gt0 values(1614218412000,637,8.861)"
)
tdSql
.
execute
(
"insert into gt0 values(1614218412000,637,8.861)"
)
tdSql
.
execute
(
"insert into gt1 values(1614218413000,638,8.862)"
)
tdSql
.
execute
(
"insert into gt1 values(1614218413000,638,8.862)"
)
# create db1 , three stables:stb0,include ctables stb0_0 \ stb0_1,stb1 include ctables stb1_0 and stb1_1
# create db1 , three stables:stb0,include ctables stb0_0 \ stb0_1,stb1 include ctables stb1_0 and stb1_1
# \stb3,include ctables stb3_0 and stb3_1
# \stb3,include ctables stb3_0 and stb3_1
#
;
create general three tables gt0 gt1 gt2
# create general three tables gt0 gt1 gt2
tdSql
.
execute
(
"create database if not exists dp2"
)
tdSql
.
execute
(
"create database if not exists dp2"
)
tdSql
.
execute
(
"use dp2"
)
tdSql
.
execute
(
"use dp2"
)
tdSql
.
execute
(
"create stable st0(ts timestamp, c01 int, c02 nchar(10)) tags(t1 int)"
)
tdSql
.
execute
(
"create stable st0(ts timestamp, c01 int, c02 nchar(10)) tags(t1 int)"
)
...
@@ -102,94 +109,188 @@ class TDTestCase:
...
@@ -102,94 +109,188 @@ class TDTestCase:
tdSql
.
execute
(
"create table if not exists gt0 (ts timestamp, c00 int, c01 float) "
)
tdSql
.
execute
(
"create table if not exists gt0 (ts timestamp, c00 int, c01 float) "
)
tdSql
.
execute
(
"create table if not exists gt1 (ts timestamp, c10 int, c11 double) "
)
tdSql
.
execute
(
"create table if not exists gt1 (ts timestamp, c10 int, c11 double) "
)
tdSql
.
execute
(
"create table if not exists gt2 (ts timestamp, c20 int, c21 float) "
)
tdSql
.
execute
(
"create table if not exists gt2 (ts timestamp, c20 int, c21 float) "
)
tdSql
.
execute
(
"insert into gt0 values(1614218412000,8637,78.86155)"
)
tdSql
.
execute
(
"insert into gt0 values(1614218412700,8637,78.86155)"
)
tdSql
.
execute
(
"insert into gt1 values(1614218413000,8638,78.862020199)"
)
tdSql
.
execute
(
"insert into gt1 values(1614218413800,8638,78.862020199)"
)
tdSql
.
execute
(
"insert into gt2 values(1614218413000,8639,78.863)"
)
tdSql
.
execute
(
"insert into gt2 values(1614218413900,8639,78.863)"
)
# create
tdSql
.
execute
(
"create database if not exists dp3 precision 'ns'"
)
tdSql
.
execute
(
"use dp3"
)
tdSql
.
execute
(
"create stable st0(ts timestamp, c01 int, c02 nchar(10)) tags(t1 int)"
)
tdSql
.
execute
(
"create table st0_0 using st0 tags(0) st0_1 using st0 tags(1) "
)
tdSql
.
execute
(
"insert into st0_0 values(1614218412000000001,8600,'R')(1614218422000000002,8600,'E')"
)
tdSql
.
execute
(
"insert into st0_1 values(1614218413000000001,8601,'A')(1614218423000000002,8601,'D')"
)
# tdSql.execute("insert into t0 values(1614218422000,8638,'R')")
# tdSql.execute("insert into t0 values(1614218422000,8638,'R')")
os
.
system
(
"rm -rf ./taosdumptest/tmp1/*"
)
os
.
system
(
"rm -rf ./taosdumptest/tmp1/*"
)
os
.
system
(
"rm -rf ./taosdumptest/tmp2/*"
)
os
.
system
(
"rm -rf ./taosdumptest/tmp2/*"
)
os
.
system
(
"rm -rf ./taosdumptest/tmp3/*"
)
os
.
system
(
"rm -rf ./taosdumptest/tmp3/*"
)
os
.
system
(
"rm -rf ./taosdumptest/tmp4/*"
)
os
.
system
(
"rm -rf ./taosdumptest/tmp4/*"
)
os
.
system
(
"rm -rf ./taosdumptest/tmp5/*"
)
# # taosdump stable and general table
# # taosdump stable and general table
# os.system("%staosdump -o ./taosdumptest/tmp1 -D dp1 dp2 " % binPath)
os
.
system
(
"%staosdump -o ./taosdumptest/tmp1 -D dp1,dp2 "
%
binPath
)
# os.system("%staosdump -o ./taosdumptest/tmp2 dp1 st0 gt0 " % binPath)
os
.
system
(
"%staosdump -o ./taosdumptest/tmp2 dp1 st0 gt0 "
%
binPath
)
# os.system("%staosdump -o ./taosdumptest/tmp3 dp2 st0 st1_0 gt0" % binPath)
os
.
system
(
"%staosdump -o ./taosdumptest/tmp3 dp2 st0 st1_0 gt0"
%
binPath
)
# os.system("%staosdump -o ./taosdumptest/tmp4 dp2 st0 st2 gt0 gt2" % binPath)、
os
.
system
(
"%staosdump -o ./taosdumptest/tmp4 dp2 st0 st2 gt0 gt2"
%
binPath
)
# verify ns
os
.
system
(
"%staosdump -o ./taosdumptest/tmp6 dp3 st0_0"
%
binPath
)
assert
os
.
system
(
"%staosdump -o ./taosdumptest/tmp6 dp3 st0_0 -C ns "
%
binPath
)
!=
0
# verify -D:--database
# verify -D:--database
# os.system("%staosdump --databases dp1 -o ./taosdumptest/tmp3 dp2 st0 st1_0 gt0" % binPath)
os
.
system
(
"%staosdump -o ./taosdumptest/tmp5 --databases dp1,dp2 "
%
binPath
)
# os.system("%staosdump --databases dp1,dp2 -o ./taosdumptest/tmp3 " % binPath)
# verify mixed -D:--database and dbname tbname
assert
os
.
system
(
"%staosdump --databases dp1 -o ./taosdumptest/tmp5 dp2 st0 st1_0 gt0"
%
binPath
)
!=
0
# #check taosdumptest/tmp1
# tdSql.execute("drop database dp1")
#check taosdumptest/tmp1
# tdSql.execute("drop database dp2")
tdSql
.
execute
(
"drop database dp1"
)
# os.system("%staosdump -i ./taosdumptest/tmp1 -T 2 " % binPath)
tdSql
.
execute
(
"drop database dp2"
)
# tdSql.execute("use dp1")
os
.
system
(
"%staosdump -i ./taosdumptest/tmp1 -T 2 "
%
binPath
)
# tdSql.query("show stables")
tdSql
.
execute
(
"use dp1"
)
# tdSql.checkRows(1)
tdSql
.
query
(
"show stables"
)
# tdSql.query("show tables")
tdSql
.
checkRows
(
1
)
# tdSql.checkRows(4)
tdSql
.
query
(
"show tables"
)
# tdSql.execute("use dp2")
tdSql
.
checkRows
(
4
)
# tdSql.query("show stables")
tdSql
.
query
(
"select c1 from st0_0 order by ts"
)
# tdSql.checkRows(3)
tdSql
.
checkData
(
0
,
0
,
8537
)
# tdSql.query("show tables")
tdSql
.
query
(
"select c2 from st0_1 order by ts"
)
# tdSql.checkRows(9)
tdSql
.
checkData
(
1
,
0
,
"D"
)
# tdSql.query("select c01 from gt0")
tdSql
.
query
(
"select * from gt0"
)
# tdSql.checkData(0,0,78.86155)
tdSql
.
checkData
(
0
,
0
,
'2021-02-25 10:00:12.000'
)
# tdSql.query("select c11 from gt1")
tdSql
.
checkData
(
0
,
1
,
637
)
# tdSql.checkData(0, 0, 78.862020199)
tdSql
.
execute
(
"use dp2"
)
# tdSql.query("select c21 from gt2")
tdSql
.
query
(
"show stables"
)
# tdSql.checkData(0, 0, 78.86300)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"show tables"
)
# #check taosdumptest/tmp2
tdSql
.
checkRows
(
9
)
# tdSql.execute("drop database dp1")
tdSql
.
query
(
"select ts from gt0"
)
# tdSql.execute("drop database dp2")
tdSql
.
checkData
(
0
,
0
,
'2021-02-25 10:00:12.700'
)
# os.system("%staosdump -i ./taosdumptest/tmp2 -T 2 " % binPath)
tdSql
.
query
(
"select c10 from gt1"
)
# tdSql.execute("use dp1")
tdSql
.
checkData
(
0
,
0
,
8638
)
# tdSql.query("show stables")
tdSql
.
query
(
"select c20 from gt2"
)
# tdSql.checkRows(1)
tdSql
.
checkData
(
0
,
0
,
8639
)
# tdSql.query("show tables")
# tdSql.checkRows(3)
# tdSql.error("use dp2")
#check taosdumptest/tmp2
# tdSql.query("select c01 from gt0")
tdSql
.
execute
(
"drop database dp1"
)
# tdSql.checkData(0,0,78.86155)
tdSql
.
execute
(
"drop database dp2"
)
os
.
system
(
"%staosdump -i ./taosdumptest/tmp2 -T 2 "
%
binPath
)
# #check taosdumptest/tmp3
tdSql
.
execute
(
"use dp1"
)
# tdSql.execute("drop database dp1")
tdSql
.
query
(
"show stables"
)
# os.system("%staosdump -i ./taosdumptest/tmp3 -T 2 " % binPath)
tdSql
.
checkRows
(
1
)
# tdSql.execute("use dp2")
tdSql
.
query
(
"show tables"
)
# tdSql.query("show stables")
tdSql
.
checkRows
(
3
)
# tdSql.checkRows(2)
tdSql
.
query
(
"select c1 from st0_0 order by ts"
)
# tdSql.query("show tables")
tdSql
.
checkData
(
0
,
0
,
8537
)
# tdSql.checkRows(4)
tdSql
.
query
(
"select c2 from st0_1 order by ts"
)
# tdSql.query("select count(*) from st1_0")
tdSql
.
checkData
(
1
,
0
,
"D"
)
# tdSql.query("select c01 from gt0")
tdSql
.
query
(
"select * from gt0"
)
# tdSql.checkData(0,0,78.86155)
tdSql
.
checkData
(
0
,
0
,
'2021-02-25 10:00:12.000'
)
# tdSql.error("use dp1")
tdSql
.
checkData
(
0
,
1
,
637
)
# tdSql.error("select count(*) from st2_0")
tdSql
.
error
(
"select count(*) from gt1"
)
# tdSql.error("select count(*) from gt2")
tdSql
.
error
(
"use dp2"
)
# #check taosdumptest/tmp4
# tdSql.execute("drop database dp2")
#check taosdumptest/tmp3
# os.system("%staosdump -i ./taosdumptest/tmp4 -T 2 " % binPath)
tdSql
.
execute
(
"drop database dp1"
)
# tdSql.execute("use dp2")
os
.
system
(
"%staosdump -i ./taosdumptest/tmp3 -T 2 "
%
binPath
)
# tdSql.query("show stables")
tdSql
.
execute
(
"use dp2"
)
# tdSql.checkRows(2)
tdSql
.
query
(
"show stables"
)
# tdSql.query("show tables")
tdSql
.
checkRows
(
2
)
# tdSql.checkRows(6)
tdSql
.
query
(
"show tables"
)
# tdSql.query("select c21 from gt2")
tdSql
.
checkRows
(
4
)
# tdSql.checkData(0, 0, 78.86300)
tdSql
.
query
(
"select count(*) from st1_0"
)
# tdSql.query("select count(*) from st2_0")
tdSql
.
checkData
(
0
,
0
,
2
)
# tdSql.error("use dp1")
tdSql
.
query
(
"select ts from gt0"
)
# tdSql.error("select count(*) from st1_0")
tdSql
.
checkData
(
0
,
0
,
'2021-02-25 10:00:12.700'
)
# tdSql.error("select count(*) from gt3")
tdSql
.
error
(
"use dp1"
)
# tdSql.execute("drop database dp2")
tdSql
.
error
(
"select count(*) from st2_0"
)
tdSql
.
error
(
"select count(*) from gt2"
)
# os.system("rm -rf ./taosdumptest/tmp1")
#check taosdumptest/tmp4
# os.system("rm -rf ./taosdumptest/tmp2")
tdSql
.
execute
(
"drop database dp2"
)
# os.system("rm -rf ./dump_result.txt")
os
.
system
(
"%staosdump -i ./taosdumptest/tmp4 -T 2 "
%
binPath
)
# os.system("rm -rf ./db.csv")
tdSql
.
execute
(
"use dp2"
)
tdSql
.
query
(
"show stables"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
6
)
tdSql
.
query
(
"select c20 from gt2"
)
tdSql
.
checkData
(
0
,
0
,
8639
)
tdSql
.
query
(
"select count(*) from st0_0"
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
query
(
"select count(*) from st0_1"
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
query
(
"select count(*) from st2_1"
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
query
(
"select count(*) from st2_0"
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
error
(
"use dp1"
)
tdSql
.
error
(
"select count(*) from st1_0"
)
tdSql
.
error
(
"select count(*) from st1_1"
)
tdSql
.
error
(
"select count(*) from gt3"
)
#check taosdumptest/tmp5
tdSql
.
execute
(
"drop database dp2"
)
os
.
system
(
"%staosdump -i ./taosdumptest/tmp5 -T 2 "
%
binPath
)
tdSql
.
execute
(
"use dp2"
)
tdSql
.
query
(
"show stables"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
9
)
tdSql
.
query
(
"select c20 from gt2"
)
tdSql
.
checkData
(
0
,
0
,
8639
)
tdSql
.
query
(
"select count(*) from st0_0"
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
query
(
"select count(*) from st0_1"
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
query
(
"select count(*) from st2_1"
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
query
(
"select count(*) from st2_0"
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
query
(
"select count(*) from st1_1"
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
query
(
"select count(*) from st1_0"
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
execute
(
"use dp1"
)
tdSql
.
query
(
"show stables"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
"select c1 from st0_0 order by ts"
)
tdSql
.
checkData
(
0
,
0
,
8537
)
tdSql
.
query
(
"select c2 from st0_1 order by ts"
)
tdSql
.
checkData
(
1
,
0
,
"D"
)
tdSql
.
query
(
"select * from gt0"
)
tdSql
.
checkData
(
0
,
0
,
'2021-02-25 10:00:12.000'
)
tdSql
.
checkData
(
0
,
1
,
637
)
#check taosdumptest/tmp6
tdSql
.
execute
(
"drop database dp1"
)
tdSql
.
execute
(
"drop database dp2"
)
tdSql
.
execute
(
"drop database dp3"
)
os
.
system
(
"%staosdump -i ./taosdumptest/tmp6 -T 2 "
%
binPath
)
tdSql
.
execute
(
"use dp3"
)
tdSql
.
query
(
"show stables"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select count(*) from st0_0"
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
query
(
"select * from st0 order by ts"
)
tdSql
.
checkData
(
0
,
0
,
'2021-02-25 10:00:12.000000001'
)
tdSql
.
checkData
(
0
,
1
,
8600
)
os
.
system
(
"rm -rf ./taosdumptest/tmp1"
)
os
.
system
(
"rm -rf ./taosdumptest/tmp2"
)
os
.
system
(
"rm -rf ./taosdumptest/tmp3"
)
os
.
system
(
"rm -rf ./taosdumptest/tmp4"
)
os
.
system
(
"rm -rf ./taosdumptest/tmp5"
)
os
.
system
(
"rm -rf ./dump_result.txt"
)
os
.
system
(
"rm -rf ./db.csv"
)
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
...
...
tests/script/api/batchprepare.c
浏览文件 @
65b415d8
...
@@ -119,7 +119,11 @@ int stmt_scol_func1(TAOS_STMT *stmt) {
...
@@ -119,7 +119,11 @@ int stmt_scol_func1(TAOS_STMT *stmt) {
printf
(
"failed to execute insert statement.
\n
"
);
printf
(
"failed to execute insert statement.
\n
"
);
exit
(
1
);
exit
(
1
);
}
}
int
affectedRows
=
taos_stmt_affected_rows
(
stmt
);
if
(
affectedRows
!=
100
)
{
printf
(
"failed to insert 100 rows"
);
}
return
0
;
return
0
;
}
}
...
...
tests/script/api/stmt.c
浏览文件 @
65b415d8
...
@@ -46,6 +46,7 @@ void taos_stmt_init_test() {
...
@@ -46,6 +46,7 @@ void taos_stmt_init_test() {
}
}
stmt
=
taos_stmt_init
(
taos
);
stmt
=
taos_stmt_init
(
taos
);
assert
(
stmt
!=
NULL
);
assert
(
stmt
!=
NULL
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
printf
(
"finish taos_stmt_init test
\n
"
);
printf
(
"finish taos_stmt_init test
\n
"
);
}
}
...
@@ -127,6 +128,7 @@ void taos_stmt_set_tbname_test() {
...
@@ -127,6 +128,7 @@ void taos_stmt_set_tbname_test() {
assert
(
taos_stmt_set_tbname
(
stmt
,
name
)
==
0
);
assert
(
taos_stmt_set_tbname
(
stmt
,
name
)
==
0
);
free
(
name
);
free
(
name
);
free
(
stmt_sql
);
free
(
stmt_sql
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
printf
(
"finish taos_stmt_set_tbname test
\n
"
);
printf
(
"finish taos_stmt_set_tbname test
\n
"
);
}
}
...
@@ -166,6 +168,7 @@ void taos_stmt_set_tbname_tags_test() {
...
@@ -166,6 +168,7 @@ void taos_stmt_set_tbname_tags_test() {
free
(
stmt_sql
);
free
(
stmt_sql
);
free
(
name
);
free
(
name
);
free
(
tags
);
free
(
tags
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
printf
(
"finish taos_stmt_set_tbname_tags test
\n
"
);
printf
(
"finish taos_stmt_set_tbname_tags test
\n
"
);
}
}
...
@@ -194,8 +197,10 @@ void taos_stmt_set_sub_tbname_test() {
...
@@ -194,8 +197,10 @@ void taos_stmt_set_sub_tbname_test() {
assert
(
taos_stmt_set_sub_tbname
(
stmt
,
name
)
!=
0
);
assert
(
taos_stmt_set_sub_tbname
(
stmt
,
name
)
!=
0
);
sprintf
(
name
,
"tb"
);
sprintf
(
name
,
"tb"
);
assert
(
taos_stmt_set_sub_tbname
(
stmt
,
name
)
==
0
);
assert
(
taos_stmt_set_sub_tbname
(
stmt
,
name
)
==
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
assert
(
taos_load_table_info
(
taos
,
"super, tb"
)
==
0
);
assert
(
taos_load_table_info
(
taos
,
"super, tb"
)
==
0
);
assert
(
taos_stmt_set_sub_tbname
(
stmt
,
name
)
==
0
);
assert
(
taos_stmt_set_sub_tbname
(
stmt
,
name
)
==
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
free
(
name
);
free
(
name
);
free
(
stmt_sql
);
free
(
stmt_sql
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
...
@@ -238,6 +243,7 @@ void taos_stmt_bind_param_test() {
...
@@ -238,6 +243,7 @@ void taos_stmt_bind_param_test() {
assert
(
taos_stmt_bind_param
(
stmt
,
params
)
!=
0
);
assert
(
taos_stmt_bind_param
(
stmt
,
params
)
!=
0
);
assert
(
taos_stmt_set_tbname
(
stmt
,
"super"
)
==
0
);
assert
(
taos_stmt_set_tbname
(
stmt
,
"super"
)
==
0
);
assert
(
taos_stmt_bind_param
(
stmt
,
params
)
==
0
);
assert
(
taos_stmt_bind_param
(
stmt
,
params
)
==
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
free
(
params
);
free
(
params
);
free
(
stmt_sql
);
free
(
stmt_sql
);
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
...
@@ -249,6 +255,7 @@ void taos_stmt_bind_single_param_batch_test() {
...
@@ -249,6 +255,7 @@ void taos_stmt_bind_single_param_batch_test() {
TAOS_STMT
*
stmt
=
NULL
;
TAOS_STMT
*
stmt
=
NULL
;
TAOS_MULTI_BIND
*
bind
=
NULL
;
TAOS_MULTI_BIND
*
bind
=
NULL
;
assert
(
taos_stmt_bind_single_param_batch
(
stmt
,
bind
,
0
)
!=
0
);
assert
(
taos_stmt_bind_single_param_batch
(
stmt
,
bind
,
0
)
!=
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
printf
(
"finish taos_stmt_bind_single_param_batch test
\n
"
);
printf
(
"finish taos_stmt_bind_single_param_batch test
\n
"
);
}
}
...
@@ -257,6 +264,7 @@ void taos_stmt_bind_param_batch_test() {
...
@@ -257,6 +264,7 @@ void taos_stmt_bind_param_batch_test() {
TAOS_STMT
*
stmt
=
NULL
;
TAOS_STMT
*
stmt
=
NULL
;
TAOS_MULTI_BIND
*
bind
=
NULL
;
TAOS_MULTI_BIND
*
bind
=
NULL
;
assert
(
taos_stmt_bind_param_batch
(
stmt
,
bind
)
!=
0
);
assert
(
taos_stmt_bind_param_batch
(
stmt
,
bind
)
!=
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
printf
(
"finish taos_stmt_bind_param_batch test
\n
"
);
printf
(
"finish taos_stmt_bind_param_batch test
\n
"
);
}
}
...
@@ -293,10 +301,14 @@ void taos_stmt_add_batch_test() {
...
@@ -293,10 +301,14 @@ void taos_stmt_add_batch_test() {
params
[
1
].
length
=
&
params
[
1
].
buffer_length
;
params
[
1
].
length
=
&
params
[
1
].
buffer_length
;
params
[
1
].
is_null
=
NULL
;
params
[
1
].
is_null
=
NULL
;
assert
(
taos_stmt_set_tbname
(
stmt
,
"super"
)
==
0
);
assert
(
taos_stmt_set_tbname
(
stmt
,
"super"
)
==
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
assert
(
taos_stmt_bind_param
(
stmt
,
params
)
==
0
);
assert
(
taos_stmt_bind_param
(
stmt
,
params
)
==
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
assert
(
taos_stmt_add_batch
(
stmt
)
==
0
);
assert
(
taos_stmt_add_batch
(
stmt
)
==
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
free
(
params
);
free
(
params
);
free
(
stmt_sql
);
free
(
stmt_sql
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
printf
(
"finish taos_stmt_add_batch test
\n
"
);
printf
(
"finish taos_stmt_add_batch test
\n
"
);
}
}
...
@@ -317,10 +329,13 @@ void taos_stmt_execute_test() {
...
@@ -317,10 +329,13 @@ void taos_stmt_execute_test() {
stmt
=
taos_stmt_init
(
taos
);
stmt
=
taos_stmt_init
(
taos
);
assert
(
stmt
!=
NULL
);
assert
(
stmt
!=
NULL
);
assert
(
taos_stmt_execute
(
stmt
)
!=
0
);
assert
(
taos_stmt_execute
(
stmt
)
!=
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
char
*
stmt_sql
=
calloc
(
1
,
1000
);
char
*
stmt_sql
=
calloc
(
1
,
1000
);
sprintf
(
stmt_sql
,
"insert into ? values (?,?)"
);
sprintf
(
stmt_sql
,
"insert into ? values (?,?)"
);
assert
(
taos_stmt_prepare
(
stmt
,
stmt_sql
,
0
)
==
0
);
assert
(
taos_stmt_prepare
(
stmt
,
stmt_sql
,
0
)
==
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
assert
(
taos_stmt_execute
(
stmt
)
!=
0
);
assert
(
taos_stmt_execute
(
stmt
)
!=
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
TAOS_BIND
*
params
=
calloc
(
2
,
sizeof
(
TAOS_BIND
));
TAOS_BIND
*
params
=
calloc
(
2
,
sizeof
(
TAOS_BIND
));
int64_t
ts
=
(
int64_t
)
1591060628000
;
int64_t
ts
=
(
int64_t
)
1591060628000
;
params
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
params
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
...
@@ -335,11 +350,17 @@ void taos_stmt_execute_test() {
...
@@ -335,11 +350,17 @@ void taos_stmt_execute_test() {
params
[
1
].
length
=
&
params
[
1
].
buffer_length
;
params
[
1
].
length
=
&
params
[
1
].
buffer_length
;
params
[
1
].
is_null
=
NULL
;
params
[
1
].
is_null
=
NULL
;
assert
(
taos_stmt_set_tbname
(
stmt
,
"super"
)
==
0
);
assert
(
taos_stmt_set_tbname
(
stmt
,
"super"
)
==
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
assert
(
taos_stmt_execute
(
stmt
)
!=
0
);
assert
(
taos_stmt_execute
(
stmt
)
!=
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
assert
(
taos_stmt_bind_param
(
stmt
,
params
)
==
0
);
assert
(
taos_stmt_bind_param
(
stmt
,
params
)
==
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
assert
(
taos_stmt_execute
(
stmt
)
!=
0
);
assert
(
taos_stmt_execute
(
stmt
)
!=
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
assert
(
taos_stmt_add_batch
(
stmt
)
==
0
);
assert
(
taos_stmt_add_batch
(
stmt
)
==
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
0
);
assert
(
taos_stmt_execute
(
stmt
)
==
0
);
assert
(
taos_stmt_execute
(
stmt
)
==
0
);
assert
(
taos_stmt_affected_rows
(
stmt
)
==
1
);
free
(
params
);
free
(
params
);
free
(
stmt_sql
);
free
(
stmt_sql
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
...
@@ -542,4 +563,4 @@ int main(int argc, char *argv[]) {
...
@@ -542,4 +563,4 @@ int main(int argc, char *argv[]) {
test_api_reliability
();
test_api_reliability
();
test_query
();
test_query
();
return
0
;
return
0
;
}
}
\ No newline at end of file
tests/script/api/stmtTest.c
浏览文件 @
65b415d8
...
@@ -229,6 +229,14 @@ int main(int argc, char *argv[]) {
...
@@ -229,6 +229,14 @@ int main(int argc, char *argv[]) {
PRINT_SUCCESS
PRINT_SUCCESS
printf
(
"Successfully execute insert statement.
\n
"
);
printf
(
"Successfully execute insert statement.
\n
"
);
int
affectedRows
=
taos_stmt_affected_rows
(
stmt
);
printf
(
"Successfully inserted %d rows
\n
"
,
affectedRows
);
if
(
affectedRows
!=
10
)
{
PRINT_ERROR
printf
(
"failed to insert 10 rows
\n
"
);
exit
(
EXIT_FAILURE
);
}
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
check_result
(
taos
,
i
,
1
);
check_result
(
taos
,
i
,
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录