Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0f13cee8
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0f13cee8
编写于
4月 19, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stmt
上级
a1c4f5c2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
673 addition
and
155 deletion
+673
-155
include/client/taos.h
include/client/taos.h
+1
-1
source/libs/parser/inc/parInsertData.h
source/libs/parser/inc/parInsertData.h
+2
-2
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+6
-0
tests/script/api/batchprepare.c
tests/script/api/batchprepare.c
+662
-150
tests/script/api/makefile
tests/script/api/makefile
+2
-2
未找到文件。
include/client/taos.h
浏览文件 @
0f13cee8
...
@@ -95,7 +95,7 @@ typedef void (*__taos_async_fn_t)(void *param, TAOS_RES *, int code);
...
@@ -95,7 +95,7 @@ typedef void (*__taos_async_fn_t)(void *param, TAOS_RES *, int code);
typedef
struct
TAOS_BIND_v2
{
typedef
struct
TAOS_BIND_v2
{
int
buffer_type
;
int
buffer_type
;
void
*
buffer
;
void
*
buffer
;
uintptr_t
buffer_length
;
int32_t
buffer_length
;
int32_t
*
length
;
int32_t
*
length
;
char
*
is_null
;
char
*
is_null
;
int
num
;
int
num
;
...
...
source/libs/parser/inc/parInsertData.h
浏览文件 @
0f13cee8
...
@@ -98,7 +98,7 @@ static FORCE_INLINE void getSTSRowAppendInfo(uint8_t rowType, SParsedDataColInfo
...
@@ -98,7 +98,7 @@ static FORCE_INLINE void getSTSRowAppendInfo(uint8_t rowType, SParsedDataColInfo
*
toffset
=
(
spd
->
cols
+
schemaIdx
)
->
toffset
;
// the offset of firstPart
*
toffset
=
(
spd
->
cols
+
schemaIdx
)
->
toffset
;
// the offset of firstPart
*
colIdx
=
schemaIdx
;
*
colIdx
=
schemaIdx
;
}
else
{
}
else
{
*
toffset
=
idx
*
sizeof
(
S
Col
Idx
);
// the offset of SColIdx
*
toffset
=
idx
*
sizeof
(
S
KvRow
Idx
);
// the offset of SColIdx
*
colIdx
=
idx
;
*
colIdx
=
idx
;
}
}
}
else
{
}
else
{
...
@@ -108,7 +108,7 @@ static FORCE_INLINE void getSTSRowAppendInfo(uint8_t rowType, SParsedDataColInfo
...
@@ -108,7 +108,7 @@ static FORCE_INLINE void getSTSRowAppendInfo(uint8_t rowType, SParsedDataColInfo
*
toffset
=
(
spd
->
cols
+
schemaIdx
)
->
toffset
;
*
toffset
=
(
spd
->
cols
+
schemaIdx
)
->
toffset
;
*
colIdx
=
schemaIdx
;
*
colIdx
=
schemaIdx
;
}
else
{
}
else
{
*
toffset
=
((
spd
->
colIdxInfo
+
idx
)
->
finalIdx
)
*
sizeof
(
S
Col
Idx
);
*
toffset
=
((
spd
->
colIdxInfo
+
idx
)
->
finalIdx
)
*
sizeof
(
S
KvRow
Idx
);
*
colIdx
=
(
spd
->
colIdxInfo
+
idx
)
->
finalIdx
;
*
colIdx
=
(
spd
->
colIdxInfo
+
idx
)
->
finalIdx
;
}
}
}
}
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
0f13cee8
...
@@ -1319,6 +1319,8 @@ int32_t qBindStmtColsValue(void *pBlock, TAOS_BIND_v2 *bind, char *msgBuf, int32
...
@@ -1319,6 +1319,8 @@ int32_t qBindStmtColsValue(void *pBlock, TAOS_BIND_v2 *bind, char *msgBuf, int32
SMemParam
param
=
{.
rb
=
pBuilder
};
SMemParam
param
=
{.
rb
=
pBuilder
};
SMsgBuf
pBuf
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
SMsgBuf
pBuf
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
CHECK_CODE
(
initRowBuilder
(
&
pDataBlock
->
rowBuilder
,
pDataBlock
->
pTableMeta
->
sversion
,
&
pDataBlock
->
boundColumnInfo
));
CHECK_CODE
(
allocateMemForSize
(
pDataBlock
,
extendedRowSize
*
bind
->
num
));
CHECK_CODE
(
allocateMemForSize
(
pDataBlock
,
extendedRowSize
*
bind
->
num
));
for
(
int32_t
r
=
0
;
r
<
bind
->
num
;
++
r
)
{
for
(
int32_t
r
=
0
;
r
<
bind
->
num
;
++
r
)
{
...
@@ -1333,6 +1335,10 @@ int32_t qBindStmtColsValue(void *pBlock, TAOS_BIND_v2 *bind, char *msgBuf, int32
...
@@ -1333,6 +1335,10 @@ int32_t qBindStmtColsValue(void *pBlock, TAOS_BIND_v2 *bind, char *msgBuf, int32
getSTSRowAppendInfo
(
pBuilder
->
rowType
,
spd
,
c
,
&
param
.
toffset
,
&
param
.
colIdx
);
getSTSRowAppendInfo
(
pBuilder
->
rowType
,
spd
,
c
,
&
param
.
toffset
,
&
param
.
colIdx
);
if
(
bind
[
c
].
is_null
&&
bind
[
c
].
is_null
[
r
])
{
if
(
bind
[
c
].
is_null
&&
bind
[
c
].
is_null
[
r
])
{
if
(
pColSchema
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
return
buildInvalidOperationMsg
(
&
pBuf
,
"primary timestamp should not be NULL"
);
}
CHECK_CODE
(
MemRowAppend
(
&
pBuf
,
NULL
,
0
,
&
param
));
CHECK_CODE
(
MemRowAppend
(
&
pBuf
,
NULL
,
0
,
&
param
));
}
else
{
}
else
{
int32_t
colLen
=
pColSchema
->
bytes
;
int32_t
colLen
=
pColSchema
->
bytes
;
...
...
tests/script/api/batchprepare.c
浏览文件 @
0f13cee8
...
@@ -10,16 +10,68 @@
...
@@ -10,16 +10,68 @@
#include "../../../include/client/taos.h"
#include "../../../include/client/taos.h"
typedef
struct
{
typedef
struct
{
TAOS
*
taos
;
int64_t
*
tsData
;
int
idx
;
bool
*
boolData
;
}
T_par
;
int8_t
*
tinyData
;
uint8_t
*
utinyData
;
int16_t
*
smallData
;
uint16_t
*
usmallData
;
int32_t
*
intData
;
uint32_t
*
uintData
;
int64_t
*
bigData
;
uint64_t
*
ubigData
;
float
*
floatData
;
double
*
doubleData
;
char
*
binaryData
;
char
*
isNull
;
int32_t
*
binaryLen
;
TAOS_BIND_v2
*
pBind
;
char
*
sql
;
int32_t
*
colTypes
;
int32_t
colNum
;
}
BindData
;
int32_t
gVarCharSize
=
10
;
int32_t
gVarCharLen
=
5
;
int
insertAllCols
(
TAOS_STMT
*
stmt
);
int
insertSpecifyCols
(
TAOS_STMT
*
stmt
);
int32_t
shortColList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_INT
};
int32_t
longColList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_BOOL
,
TSDB_DATA_TYPE_TINYINT
,
TSDB_DATA_TYPE_UTINYINT
,
TSDB_DATA_TYPE_SMALLINT
,
TSDB_DATA_TYPE_USMALLINT
,
TSDB_DATA_TYPE_INT
,
TSDB_DATA_TYPE_UINT
,
TSDB_DATA_TYPE_BIGINT
,
TSDB_DATA_TYPE_UBIGINT
,
TSDB_DATA_TYPE_FLOAT
,
TSDB_DATA_TYPE_DOUBLE
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DATA_TYPE_NCHAR
};
#define tListLen(x) (sizeof(x) / sizeof((x)[0]))
typedef
struct
{
char
caseDesc
[
128
];
int32_t
colNum
;
int32_t
*
colList
;
bool
autoCreate
;
bool
fullCol
;
int32_t
(
*
runFn
)(
TAOS_STMT
*
);
int32_t
tblNum
;
int32_t
rowNum
;
int32_t
bindRowNum
;
int32_t
bindColNum
;
int32_t
bindNullNum
;
int32_t
runTimes
;
}
CaseCfg
;
CaseCfg
gCase
[]
=
{
// {"insert:all columns", tListLen(shortColList), shortColList, false, true, insertAllCols, 1, 10, 10, 2, 0, 10},
// {"insert:all columns", tListLen(shortColList), shortColList, false, true, insertAllCols, 10, 100, 10, 2, 0, 10},
{
"insert:all columns"
,
tListLen
(
longColList
),
longColList
,
false
,
true
,
insertAllCols
,
10
,
10
,
2
,
14
,
0
,
1
},
// {"insert:all columns", tListLen(longColList), longColList, false, false, insertSpecifyCols, 10, 10, 2, 6, 0, 1},
};
CaseCfg
*
gCurCase
=
NULL
;
void
taosMsleep
(
int
mseconds
);
int32_t
taosGetTimeOfDay
(
struct
timeval
*
tv
)
{
int32_t
taosGetTimeOfDay
(
struct
timeval
*
tv
)
{
return
gettimeofday
(
tv
,
NULL
);
return
gettimeofday
(
tv
,
NULL
);
}
}
void
*
taosMemoryMalloc
(
int32
_t
size
)
{
void
*
taosMemoryMalloc
(
uint64
_t
size
)
{
return
malloc
(
size
);
return
malloc
(
size
);
}
}
...
@@ -32,50 +84,396 @@ void taosMemoryFree(const void *ptr) {
...
@@ -32,50 +84,396 @@ void taosMemoryFree(const void *ptr) {
return
free
((
void
*
)
ptr
);
return
free
((
void
*
)
ptr
);
}
}
static
int64_t
taosGetTimestampMs
()
{
struct
timeval
systemTime
;
taosGetTimeOfDay
(
&
systemTime
);
return
(
int64_t
)
systemTime
.
tv_sec
*
1000L
+
(
int64_t
)
systemTime
.
tv_usec
/
1000
;
}
static
int64_t
taosGetTimestampUs
()
{
static
int64_t
taosGetTimestampUs
()
{
struct
timeval
systemTime
;
struct
timeval
systemTime
;
taosGetTimeOfDay
(
&
systemTime
);
taosGetTimeOfDay
(
&
systemTime
);
return
(
int64_t
)
systemTime
.
tv_sec
*
1000000L
+
(
int64_t
)
systemTime
.
tv_usec
;
return
(
int64_t
)
systemTime
.
tv_sec
*
1000000L
+
(
int64_t
)
systemTime
.
tv_usec
;
}
}
bool
colExists
(
TAOS_BIND_v2
*
pBind
,
int32_t
dataType
)
{
int32_t
i
=
0
;
while
(
true
)
{
if
(
0
==
pBind
[
i
].
buffer_type
)
{
return
false
;
}
if
(
pBind
[
i
].
buffer_type
==
dataType
)
{
return
true
;
}
int
stmt_allcol_func1
(
TAOS_STMT
*
stmt
)
{
++
i
;
struct
{
}
int64_t
ts
;
}
int32_t
v4
;
}
v
=
{
0
};
void
generateSql
(
BindData
*
data
)
{
int32_t
len
[
10
]
=
{
sizeof
(
v
.
ts
),
sizeof
(
v
.
v4
)};
int32_t
len
=
sprintf
(
data
->
sql
,
"insert into %s "
,
(
gCurCase
->
tblNum
>
1
?
"? "
:
"m0 "
));
if
(
!
gCurCase
->
fullCol
)
{
len
+=
sprintf
(
data
->
sql
+
len
,
"("
);
for
(
int
c
=
0
;
c
<
gCurCase
->
bindColNum
;
++
c
)
{
if
(
c
)
{
len
+=
sprintf
(
data
->
sql
+
len
,
","
);
}
switch
(
data
->
pBind
[
c
].
buffer_type
)
{
case
TSDB_DATA_TYPE_BOOL
:
len
+=
sprintf
(
data
->
sql
+
len
,
"booldata"
);
break
;
case
TSDB_DATA_TYPE_TINYINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"tinydata"
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"smalldata"
);
break
;
case
TSDB_DATA_TYPE_INT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"intdata"
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"bigdata"
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"floatdata"
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
len
+=
sprintf
(
data
->
sql
+
len
,
"doubledata"
);
break
;
case
TSDB_DATA_TYPE_VARCHAR
:
len
+=
sprintf
(
data
->
sql
+
len
,
"binarydata"
);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
len
+=
sprintf
(
data
->
sql
+
len
,
"ts"
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
len
+=
sprintf
(
data
->
sql
+
len
,
"nchardata"
);
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"utinydata"
);
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"usmalldata"
);
break
;
case
TSDB_DATA_TYPE_UINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"uintdata"
);
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"ubigdata"
);
break
;
default:
printf
(
"invalid col type:%d"
,
data
->
pBind
[
c
].
buffer_type
);
exit
(
1
);
}
}
len
+=
sprintf
(
data
->
sql
+
len
,
") "
);
}
len
+=
sprintf
(
data
->
sql
+
len
,
"values ("
);
for
(
int
c
=
0
;
c
<
gCurCase
->
bindColNum
;
++
c
)
{
if
(
c
)
{
len
+=
sprintf
(
data
->
sql
+
len
,
","
);
}
len
+=
sprintf
(
data
->
sql
+
len
,
"?"
);
}
len
+=
sprintf
(
data
->
sql
+
len
,
")"
);
TAOS_BIND_v2
params
[
10
];
}
params
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
params
[
0
].
buffer_length
=
sizeof
(
v
.
ts
);
params
[
0
].
buffer
=
&
v
.
ts
;
params
[
0
].
length
=
&
len
[
0
];
params
[
0
].
is_null
=
NULL
;
params
[
0
].
num
=
1
;
params
[
1
].
buffer_type
=
TSDB_DATA_TYPE_TINYINT
;
void
generateDataType
(
BindData
*
data
,
int32_t
bindIdx
,
int32_t
colIdx
,
int32_t
*
dataType
)
{
params
[
1
].
buffer_length
=
sizeof
(
v
.
v4
);
if
(
bindIdx
<
gCurCase
->
bindColNum
)
{
params
[
1
].
buffer
=
&
v
.
v4
;
if
(
colIdx
)
{
params
[
1
].
length
=
&
len
[
1
];
if
(
!
gCurCase
->
multiCol
)
{
params
[
1
].
is_null
=
NULL
;
*
dataType
=
TSDB_DATA_TYPE_INT
;
params
[
1
].
num
=
1
;
return
;
}
while
(
true
)
{
*
dataType
=
rand
()
%
(
TSDB_DATA_TYPE_MAX
-
1
)
+
1
;
if
(
*
dataType
==
TSDB_DATA_TYPE_JSON
||
*
dataType
==
TSDB_DATA_TYPE_DECIMAL
||
*
dataType
==
TSDB_DATA_TYPE_BLOB
||
*
dataType
==
TSDB_DATA_TYPE_MEDIUMBLOB
||
*
dataType
==
TSDB_DATA_TYPE_VARBINARY
)
{
continue
;
}
char
*
sql
=
"insert into m0 values(?,?)"
;
if
(
colExists
(
data
->
pBind
,
*
dataType
))
{
int
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
continue
;
}
break
;
}
}
}
else
{
*
dataType
=
data
->
pBind
[
bindIdx
%
gCurCase
->
bindColNum
].
buffer_type
;
}
}
int32_t
prepareColData
(
BindData
*
data
,
int32_t
bindIdx
,
int32_t
rowIdx
,
int32_t
colIdx
)
{
int32_t
dataType
=
TSDB_DATA_TYPE_TIMESTAMP
;
generateDataType
(
data
,
bindIdx
,
colIdx
,
&
dataType
);
switch
(
dataType
)
{
case
TSDB_DATA_TYPE_BOOL
:
data
->
pBind
[
bindIdx
].
buffer_length
=
sizeof
(
bool
);
data
->
pBind
[
bindIdx
].
buffer
=
data
->
boolData
+
rowIdx
;
data
->
pBind
[
bindIdx
].
length
=
NULL
;
data
->
pBind
[
bindIdx
].
is_null
=
data
->
isNull
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
data
->
pBind
[
bindIdx
].
buffer_length
=
sizeof
(
int8_t
);
data
->
pBind
[
bindIdx
].
buffer
=
data
->
tinyData
+
rowIdx
;
data
->
pBind
[
bindIdx
].
length
=
NULL
;
data
->
pBind
[
bindIdx
].
is_null
=
data
->
isNull
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
data
->
pBind
[
bindIdx
].
buffer_length
=
sizeof
(
int16_t
);
data
->
pBind
[
bindIdx
].
buffer
=
data
->
smallData
+
rowIdx
;
data
->
pBind
[
bindIdx
].
length
=
NULL
;
data
->
pBind
[
bindIdx
].
is_null
=
data
->
isNull
;
break
;
case
TSDB_DATA_TYPE_INT
:
data
->
pBind
[
bindIdx
].
buffer_length
=
sizeof
(
int32_t
);
data
->
pBind
[
bindIdx
].
buffer
=
data
->
intData
+
rowIdx
;
data
->
pBind
[
bindIdx
].
length
=
NULL
;
data
->
pBind
[
bindIdx
].
is_null
=
data
->
isNull
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
data
->
pBind
[
bindIdx
].
buffer_length
=
sizeof
(
int64_t
);
data
->
pBind
[
bindIdx
].
buffer
=
data
->
bigData
+
rowIdx
;
data
->
pBind
[
bindIdx
].
length
=
NULL
;
data
->
pBind
[
bindIdx
].
is_null
=
data
->
isNull
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
data
->
pBind
[
bindIdx
].
buffer_length
=
sizeof
(
float
);
data
->
pBind
[
bindIdx
].
buffer
=
data
->
floatData
+
rowIdx
;
data
->
pBind
[
bindIdx
].
length
=
NULL
;
data
->
pBind
[
bindIdx
].
is_null
=
data
->
isNull
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
data
->
pBind
[
bindIdx
].
buffer_length
=
sizeof
(
double
);
data
->
pBind
[
bindIdx
].
buffer
=
data
->
doubleData
+
rowIdx
;
data
->
pBind
[
bindIdx
].
length
=
NULL
;
data
->
pBind
[
bindIdx
].
is_null
=
data
->
isNull
;
break
;
case
TSDB_DATA_TYPE_VARCHAR
:
data
->
pBind
[
bindIdx
].
buffer_length
=
gVarCharSize
;
data
->
pBind
[
bindIdx
].
buffer
=
data
->
binaryData
+
rowIdx
;
data
->
pBind
[
bindIdx
].
length
=
data
->
binaryLen
;
data
->
pBind
[
bindIdx
].
is_null
=
data
->
isNull
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
data
->
pBind
[
bindIdx
].
buffer_length
=
sizeof
(
int64_t
);
data
->
pBind
[
bindIdx
].
buffer
=
data
->
tsData
+
rowIdx
;
data
->
pBind
[
bindIdx
].
length
=
NULL
;
data
->
pBind
[
bindIdx
].
is_null
=
NULL
;
break
;
case
TSDB_DATA_TYPE_NCHAR
:
data
->
pBind
[
bindIdx
].
buffer_length
=
gVarCharSize
;
data
->
pBind
[
bindIdx
].
buffer
=
data
->
binaryData
+
rowIdx
;
data
->
pBind
[
bindIdx
].
length
=
data
->
binaryLen
;
data
->
pBind
[
bindIdx
].
is_null
=
data
->
isNull
;
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
data
->
pBind
[
bindIdx
].
buffer_length
=
sizeof
(
uint8_t
);
data
->
pBind
[
bindIdx
].
buffer
=
data
->
utinyData
+
rowIdx
;
data
->
pBind
[
bindIdx
].
length
=
NULL
;
data
->
pBind
[
bindIdx
].
is_null
=
data
->
isNull
;
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
data
->
pBind
[
bindIdx
].
buffer_length
=
sizeof
(
uint16_t
);
data
->
pBind
[
bindIdx
].
buffer
=
data
->
usmallData
+
rowIdx
;
data
->
pBind
[
bindIdx
].
length
=
NULL
;
data
->
pBind
[
bindIdx
].
is_null
=
data
->
isNull
;
break
;
case
TSDB_DATA_TYPE_UINT
:
data
->
pBind
[
bindIdx
].
buffer_length
=
sizeof
(
uint32_t
);
data
->
pBind
[
bindIdx
].
buffer
=
data
->
uintData
+
rowIdx
;
data
->
pBind
[
bindIdx
].
length
=
NULL
;
data
->
pBind
[
bindIdx
].
is_null
=
data
->
isNull
;
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
data
->
pBind
[
bindIdx
].
buffer_length
=
sizeof
(
uint64_t
);
data
->
pBind
[
bindIdx
].
buffer
=
data
->
ubigData
+
rowIdx
;
data
->
pBind
[
bindIdx
].
length
=
NULL
;
data
->
pBind
[
bindIdx
].
is_null
=
data
->
isNull
;
break
;
default:
printf
(
"invalid col type:%d"
,
dataType
);
exit
(
1
);
}
data
->
pBind
[
bindIdx
].
buffer_type
=
dataType
;
data
->
pBind
[
bindIdx
].
num
=
gCurCase
->
bindRowNum
;
return
0
;
}
int32_t
prepareData
(
BindData
*
data
)
{
static
int64_t
tsData
=
1591060628000
;
uint64_t
allRowNum
=
gCurCase
->
rowNum
*
gCurCase
->
tblNum
;
data
->
colNum
=
0
;
data
->
colTypes
=
taosMemoryCalloc
(
30
,
sizeof
(
int32_t
));
data
->
sql
=
taosMemoryCalloc
(
1
,
1024
);
data
->
pBind
=
taosMemoryCalloc
((
allRowNum
/
gCurCase
->
bindRowNum
)
*
gCurCase
->
bindColNum
,
sizeof
(
TAOS_BIND_v2
));
data
->
tsData
=
taosMemoryMalloc
(
allRowNum
*
sizeof
(
int64_t
));
data
->
boolData
=
taosMemoryMalloc
(
allRowNum
*
sizeof
(
bool
));
data
->
tinyData
=
taosMemoryMalloc
(
allRowNum
*
sizeof
(
int8_t
));
data
->
utinyData
=
taosMemoryMalloc
(
allRowNum
*
sizeof
(
uint8_t
));
data
->
smallData
=
taosMemoryMalloc
(
allRowNum
*
sizeof
(
int16_t
));
data
->
usmallData
=
taosMemoryMalloc
(
allRowNum
*
sizeof
(
uint16_t
));
data
->
intData
=
taosMemoryMalloc
(
allRowNum
*
sizeof
(
int32_t
));
data
->
uintData
=
taosMemoryMalloc
(
allRowNum
*
sizeof
(
uint32_t
));
data
->
bigData
=
taosMemoryMalloc
(
allRowNum
*
sizeof
(
int64_t
));
data
->
ubigData
=
taosMemoryMalloc
(
allRowNum
*
sizeof
(
uint64_t
));
data
->
floatData
=
taosMemoryMalloc
(
allRowNum
*
sizeof
(
float
));
data
->
doubleData
=
taosMemoryMalloc
(
allRowNum
*
sizeof
(
double
));
data
->
binaryData
=
taosMemoryMalloc
(
allRowNum
*
gVarCharSize
);
data
->
binaryLen
=
taosMemoryMalloc
(
allRowNum
*
sizeof
(
int32_t
));
if
(
gCurCase
->
bindNullNum
)
{
data
->
isNull
=
taosMemoryCalloc
(
allRowNum
,
sizeof
(
char
));
}
for
(
int32_t
i
=
0
;
i
<
allRowNum
;
++
i
)
{
data
->
tsData
[
i
]
=
tsData
++
;
data
->
boolData
[
i
]
=
i
%
2
;
data
->
tinyData
[
i
]
=
i
;
data
->
utinyData
[
i
]
=
i
+
1
;
data
->
smallData
[
i
]
=
i
;
data
->
usmallData
[
i
]
=
i
+
1
;
data
->
intData
[
i
]
=
i
;
data
->
uintData
[
i
]
=
i
+
1
;
data
->
bigData
[
i
]
=
i
;
data
->
ubigData
[
i
]
=
i
+
1
;
data
->
floatData
[
i
]
=
i
;
data
->
doubleData
[
i
]
=
i
+
1
;
memset
(
data
->
binaryData
+
gVarCharSize
*
i
,
'a'
+
i
%
26
,
gVarCharLen
);
if
(
gCurCase
->
bindNullNum
)
{
data
->
isNull
[
i
]
=
i
%
2
;
}
data
->
binaryLen
[
i
]
=
gVarCharLen
;
}
for
(
int
b
=
0
;
b
<
(
allRowNum
/
gCurCase
->
bindRowNum
);
b
++
)
{
for
(
int
c
=
0
;
c
<
gCurCase
->
bindColNum
;
++
c
)
{
prepareColData
(
data
,
b
*
gCurCase
->
bindColNum
+
c
,
b
*
gCurCase
->
bindRowNum
,
c
);
}
}
generateSql
(
data
);
return
0
;
}
void
destroyData
(
BindData
*
data
)
{
taosMemoryFree
(
data
->
tsData
);
taosMemoryFree
(
data
->
boolData
);
taosMemoryFree
(
data
->
tinyData
);
taosMemoryFree
(
data
->
utinyData
);
taosMemoryFree
(
data
->
smallData
);
taosMemoryFree
(
data
->
usmallData
);
taosMemoryFree
(
data
->
intData
);
taosMemoryFree
(
data
->
uintData
);
taosMemoryFree
(
data
->
bigData
);
taosMemoryFree
(
data
->
ubigData
);
taosMemoryFree
(
data
->
floatData
);
taosMemoryFree
(
data
->
doubleData
);
taosMemoryFree
(
data
->
binaryData
);
taosMemoryFree
(
data
->
binaryLen
);
taosMemoryFree
(
data
->
isNull
);
taosMemoryFree
(
data
->
pBind
);
}
int
insertAllCols
(
TAOS_STMT
*
stmt
)
{
BindData
data
=
{
0
};
prepareData
(
&
data
);
printf
(
"SQL: %s
\n
"
,
data
.
sql
);
int
code
=
taos_stmt_prepare
(
stmt
,
data
.
sql
,
0
);
if
(
code
!=
0
){
if
(
code
!=
0
){
printf
(
"failed to execute taos_stmt_prepare. error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
printf
(
"failed to execute taos_stmt_prepare. error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
}
}
v
.
ts
=
1591060628000
;
int32_t
bindTimes
=
gCurCase
->
rowNum
/
gCurCase
->
bindRowNum
;
v
.
v4
=
111
;
for
(
int32_t
t
=
0
;
t
<
gCurCase
->
tblNum
;
++
t
)
{
if
(
gCurCase
->
tblNum
>
1
)
{
char
buf
[
32
];
sprintf
(
buf
,
"t%d"
,
t
);
code
=
taos_stmt_set_tbname
(
stmt
,
buf
);
if
(
code
!=
0
){
printf
(
"taos_stmt_set_tbname error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
}
}
for
(
int32_t
b
=
0
;
b
<
bindTimes
;
++
b
)
{
if
(
taos_stmt_bind_param_batch
(
stmt
,
data
.
pBind
+
t
*
bindTimes
*
gCurCase
->
bindColNum
+
b
*
gCurCase
->
bindColNum
))
{
printf
(
"taos_stmt_bind_param error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
}
if
(
taos_stmt_add_batch
(
stmt
))
{
printf
(
"taos_stmt_add_batch error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
}
}
}
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
printf
(
"taos_stmt_execute error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
}
return
0
;
}
int
insertSpecifyCols
(
TAOS_STMT
*
stmt
)
{
BindData
data
=
{
0
};
prepareData
(
&
data
);
printf
(
"SQL: %s
\n
"
,
data
.
sql
);
int
code
=
taos_stmt_prepare
(
stmt
,
data
.
sql
,
0
);
if
(
code
!=
0
){
printf
(
"failed to execute taos_stmt_prepare. error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
}
taos_stmt_bind_param
(
stmt
,
params
);
int32_t
bindTimes
=
gCurCase
->
rowNum
/
gCurCase
->
bindRowNum
;
taos_stmt_add_batch
(
stmt
);
for
(
int32_t
t
=
0
;
t
<
gCurCase
->
tblNum
;
++
t
)
{
if
(
gCurCase
->
tblNum
>
1
)
{
char
buf
[
32
];
sprintf
(
buf
,
"t%d"
,
t
);
code
=
taos_stmt_set_tbname
(
stmt
,
buf
);
if
(
code
!=
0
){
printf
(
"taos_stmt_set_tbname error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
}
}
for
(
int32_t
b
=
0
;
b
<
bindTimes
;
++
b
)
{
if
(
taos_stmt_bind_param_batch
(
stmt
,
data
.
pBind
+
t
*
bindTimes
*
gCurCase
->
bindColNum
+
b
*
gCurCase
->
bindColNum
))
{
printf
(
"taos_stmt_bind_param error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
}
if
(
taos_stmt_add_batch
(
stmt
))
{
printf
(
"taos_stmt_add_batch error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
}
}
}
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
printf
(
"
failed to execute insert statement, error:%s.
\n
"
,
taos_stmt_errstr
(
stmt
));
printf
(
"
taos_stmt_execute error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
exit
(
1
);
}
}
...
@@ -365,7 +763,7 @@ int stmt_scol_func3(TAOS_STMT *stmt) {
...
@@ -365,7 +763,7 @@ int stmt_scol_func3(TAOS_STMT *stmt) {
v
.
ts
[
i
]
=
tts
+
i
;
v
.
ts
[
i
]
=
tts
+
i
;
}
}
unsigned
long
long
starttime
=
taosGetTimestampUs
();
int64_t
starttime
=
taosGetTimestampUs
();
char
*
sql
=
"insert into ? (ts, v1,v2,f4,bin,bin2) values(?,?,?,?,?,?)"
;
char
*
sql
=
"insert into ? (ts, v1,v2,f4,bin,bin2) values(?,?,?,?,?,?)"
;
int
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
int
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
...
@@ -395,7 +793,7 @@ int stmt_scol_func3(TAOS_STMT *stmt) {
...
@@ -395,7 +793,7 @@ int stmt_scol_func3(TAOS_STMT *stmt) {
++
id
;
++
id
;
}
}
unsigned
long
long
endtime
=
taosGetTimestampUs
();
int64_t
endtime
=
taosGetTimestampUs
();
printf
(
"insert total %d records, used %u seconds, avg:%u useconds
\n
"
,
3000
*
300
*
60
,
(
endtime
-
starttime
)
/
1000000UL
,
(
endtime
-
starttime
)
/
(
3000
*
300
*
60
));
printf
(
"insert total %d records, used %u seconds, avg:%u useconds
\n
"
,
3000
*
300
*
60
,
(
endtime
-
starttime
)
/
1000000UL
,
(
endtime
-
starttime
)
/
(
3000
*
300
*
60
));
taosMemoryFree
(
v
.
ts
);
taosMemoryFree
(
v
.
ts
);
...
@@ -487,7 +885,7 @@ int stmt_scol_func4(TAOS_STMT *stmt) {
...
@@ -487,7 +885,7 @@ int stmt_scol_func4(TAOS_STMT *stmt) {
v
.
ts
[
i
]
=
tts
+
i
;
v
.
ts
[
i
]
=
tts
+
i
;
}
}
unsigned
long
long
starttime
=
taosGetTimestampUs
();
int64_t
starttime
=
taosGetTimestampUs
();
char
*
sql
=
"insert into ? (ts,b,v4,v8,f8) values(?,?,?,?,?)"
;
char
*
sql
=
"insert into ? (ts,b,v4,v8,f8) values(?,?,?,?,?)"
;
int
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
int
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
...
@@ -518,7 +916,7 @@ int stmt_scol_func4(TAOS_STMT *stmt) {
...
@@ -518,7 +916,7 @@ int stmt_scol_func4(TAOS_STMT *stmt) {
}
}
}
}
unsigned
long
long
endtime
=
taosGetTimestampUs
();
int64_t
endtime
=
taosGetTimestampUs
();
printf
(
"insert total %d records, used %u seconds, avg:%u useconds
\n
"
,
3000
*
300
*
60
,
(
endtime
-
starttime
)
/
1000000UL
,
(
endtime
-
starttime
)
/
(
3000
*
300
*
60
));
printf
(
"insert total %d records, used %u seconds, avg:%u useconds
\n
"
,
3000
*
300
*
60
,
(
endtime
-
starttime
)
/
1000000UL
,
(
endtime
-
starttime
)
/
(
3000
*
300
*
60
));
taosMemoryFree
(
v
.
ts
);
taosMemoryFree
(
v
.
ts
);
...
@@ -530,6 +928,59 @@ int stmt_scol_func4(TAOS_STMT *stmt) {
...
@@ -530,6 +928,59 @@ int stmt_scol_func4(TAOS_STMT *stmt) {
return
0
;
return
0
;
}
}
//1 tables 20 records
int
stmt_scol_func5
(
TAOS_STMT
*
stmt
)
{
int32_t
rowNum
=
gCurCase
->
rowNum
;
int32_t
bindRowNum
=
gCurCase
->
bindRowNum
;
int32_t
bindColNum
=
gCurCase
->
bindColNum
;
int32_t
nullNum
=
gCurCase
->
bindNullNum
;
BindData
data
=
{
0
};
prepareData
(
&
data
);
int64_t
starttime
=
taosGetTimestampUs
();
char
*
sql
=
"insert into ? (ts, v1,v2,f4,bin,bin2) values(?,?,?,?,?,?)"
;
int
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
if
(
code
!=
0
){
printf
(
"failed to execute taos_stmt_prepare. code:0x%x
\n
"
,
code
);
}
int
id
=
0
;
for
(
int
b
=
0
;
b
<
(
rowNum
/
bindRowNum
);
b
++
)
{
//for (int b = 0; b < 2; b++) {
for
(
int
zz
=
0
;
zz
<
10
;
zz
++
)
{
char
buf
[
32
];
sprintf
(
buf
,
"m%d"
,
zz
);
code
=
taos_stmt_set_tbname
(
stmt
,
buf
);
if
(
code
!=
0
){
printf
(
"failed to execute taos_stmt_set_tbname. code:0x%x
\n
"
,
code
);
}
taos_stmt_bind_param_batch
(
stmt
,
data
.
pBind
+
b
*
bindColNum
);
taos_stmt_add_batch
(
stmt
);
}
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
printf
(
"failed to execute insert statement.
\n
"
);
exit
(
1
);
}
++
id
;
}
int64_t
endtime
=
taosGetTimestampUs
();
printf
(
"insert total %d records, used %u seconds, avg:%u useconds
\n
"
,
rowNum
,
(
endtime
-
starttime
)
/
1000000UL
,
(
endtime
-
starttime
)
/
(
3000
*
300
*
60
));
destroyData
(
&
data
);
return
0
;
}
#if 0
#if 0
...
@@ -4261,12 +4712,13 @@ int stmt_funcb_sc3(TAOS_STMT *stmt) {
...
@@ -4261,12 +4712,13 @@ int stmt_funcb_sc3(TAOS_STMT *stmt) {
}
}
#endif
#endif
void
check_result
(
TAOS
*
taos
,
char
*
tname
,
int
printr
,
int
expected
)
{
void
prepareCheckResultImpl
(
TAOS
*
taos
,
char
*
tname
,
int
printr
,
int
expected
)
{
char
sql
[
255
]
=
"SELECT * FROM "
;
char
sql
[
255
]
=
"SELECT * FROM "
;
TAOS_RES
*
result
;
TAOS_RES
*
result
;
//FORCE NO PRINT
//FORCE NO PRINT
printr
=
0
;
//
printr = 0;
strcat
(
sql
,
tname
);
strcat
(
sql
,
tname
);
...
@@ -4307,6 +4759,20 @@ void check_result(TAOS *taos, char *tname, int printr, int expected) {
...
@@ -4307,6 +4759,20 @@ void check_result(TAOS *taos, char *tname, int printr, int expected) {
}
}
void
prepareCheckResult
(
TAOS
*
taos
)
{
char
buf
[
32
];
for
(
int32_t
t
=
0
;
t
<
gCurCase
->
tblNum
;
++
t
)
{
if
(
gCurCase
->
tblNum
>
1
)
{
sprintf
(
buf
,
"m%d"
,
t
);
}
else
{
sprintf
(
buf
,
"m%d"
,
0
);
}
prepareCheckResultImpl
(
taos
,
buf
,
1
,
gCurCase
->
rowNum
);
}
}
//120table 60 record each table
//120table 60 record each table
int
sql_perf1
(
TAOS
*
taos
)
{
int
sql_perf1
(
TAOS
*
taos
)
{
...
@@ -4452,8 +4918,120 @@ int sql_s_perf1(TAOS *taos) {
...
@@ -4452,8 +4918,120 @@ int sql_s_perf1(TAOS *taos) {
return
0
;
return
0
;
}
}
void
generateCreateTableSQL
(
char
*
buf
,
int32_t
tblIdx
,
int32_t
colNum
,
int32_t
*
colList
,
bool
stable
)
{
int32_t
blen
=
0
;
blen
=
sprintf
(
buf
,
"create table %s%d "
,
(
stable
?
"st"
:
"t"
),
tblIdx
);
if
(
stable
)
{
blen
+=
sprintf
(
buf
+
blen
,
"tags ("
);
for
(
int
c
=
0
;
c
<
colNum
;
++
c
)
{
switch
(
colList
[
c
])
{
case
TSDB_DATA_TYPE_BOOL
:
blen
+=
sprintf
(
buf
+
blen
,
"tbooldata bool"
);
break
;
case
TSDB_DATA_TYPE_TINYINT
:
blen
+=
sprintf
(
buf
+
blen
,
"ttinydata tinyint"
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
blen
+=
sprintf
(
buf
+
blen
,
"tsmalldata smallint"
);
break
;
case
TSDB_DATA_TYPE_INT
:
blen
+=
sprintf
(
buf
+
blen
,
"tintdata int"
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
blen
+=
sprintf
(
buf
+
blen
,
"tbigdata bigint"
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
blen
+=
sprintf
(
buf
+
blen
,
"tfloatdata float"
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
blen
+=
sprintf
(
buf
+
blen
,
"tdoubledata double"
);
break
;
case
TSDB_DATA_TYPE_VARCHAR
:
blen
+=
sprintf
(
buf
+
blen
,
"tbinarydata binary(%d)"
,
gVarCharSize
);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
blen
+=
sprintf
(
buf
+
blen
,
"tts ts"
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
blen
+=
sprintf
(
buf
+
blen
,
"tnchardata nchar(%d)"
,
gVarCharSize
);
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
blen
+=
sprintf
(
buf
+
blen
,
"tutinydata tinyint unsigned"
);
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
blen
+=
sprintf
(
buf
+
blen
,
"tusmalldata smallint unsigned"
);
break
;
case
TSDB_DATA_TYPE_UINT
:
blen
+=
sprintf
(
buf
+
blen
,
"tuintdata int unsigned"
);
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
blen
+=
sprintf
(
buf
+
blen
,
"tubigdata bigint unsigned"
);
break
;
default:
printf
(
"invalid col type:%d"
,
colList
[
c
]);
exit
(
1
);
}
}
blen
+=
sprintf
(
buf
+
blen
,
")"
);
}
blen
+=
sprintf
(
buf
+
blen
,
" ("
);
for
(
int
c
=
0
;
c
<
colNum
;
++
c
)
{
switch
(
colList
[
c
])
{
case
TSDB_DATA_TYPE_BOOL
:
blen
+=
sprintf
(
buf
+
blen
,
"booldata bool"
);
break
;
case
TSDB_DATA_TYPE_TINYINT
:
blen
+=
sprintf
(
buf
+
blen
,
"tinydata tinyint"
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
blen
+=
sprintf
(
buf
+
blen
,
"smalldata smallint"
);
break
;
case
TSDB_DATA_TYPE_INT
:
blen
+=
sprintf
(
buf
+
blen
,
"intdata int"
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
blen
+=
sprintf
(
buf
+
blen
,
"bigdata bigint"
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
blen
+=
sprintf
(
buf
+
blen
,
"floatdata float"
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
blen
+=
sprintf
(
buf
+
blen
,
"doubledata double"
);
break
;
case
TSDB_DATA_TYPE_VARCHAR
:
blen
+=
sprintf
(
buf
+
blen
,
"binarydata binary(%d)"
,
gVarCharSize
);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
blen
+=
sprintf
(
buf
+
blen
,
"ts ts"
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
blen
+=
sprintf
(
buf
+
blen
,
"nchardata nchar(%d)"
,
gVarCharSize
);
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
blen
+=
sprintf
(
buf
+
blen
,
"utinydata tinyint unsigned"
);
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
blen
+=
sprintf
(
buf
+
blen
,
"usmalldata smallint unsigned"
);
break
;
case
TSDB_DATA_TYPE_UINT
:
blen
+=
sprintf
(
buf
+
blen
,
"uintdata int unsigned"
);
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
blen
+=
sprintf
(
buf
+
blen
,
"ubigdata bigint unsigned"
);
break
;
default:
printf
(
"invalid col type:%d"
,
colList
[
c
]);
exit
(
1
);
}
}
blen
+=
sprintf
(
buf
+
blen
,
")"
);
}
void
prepare
(
TAOS
*
taos
,
int
bigsize
,
int
createChildTabl
e
)
{
void
prepare
(
TAOS
*
taos
,
int
32_t
colNum
,
int32_t
*
colList
,
int
autoCreat
e
)
{
TAOS_RES
*
result
;
TAOS_RES
*
result
;
int
code
;
int
code
;
...
@@ -4472,15 +5050,11 @@ void prepare(TAOS *taos, int bigsize, int createChildTable) {
...
@@ -4472,15 +5050,11 @@ void prepare(TAOS *taos, int bigsize, int createChildTable) {
result
=
taos_query
(
taos
,
"use demo"
);
result
=
taos_query
(
taos
,
"use demo"
);
taos_free_result
(
result
);
taos_free_result
(
result
);
if
(
createChildTabl
e
)
{
if
(
!
autoCreat
e
)
{
// create table
// create table
for
(
int
i
=
0
;
i
<
30
0
;
i
++
)
{
for
(
int
i
=
0
;
i
<
1
0
;
i
++
)
{
char
buf
[
1024
];
char
buf
[
1024
];
if
(
bigsize
)
{
generateCreateTableSQL
(
buf
,
i
,
colNum
,
colList
,
false
);
sprintf
(
buf
,
"create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), bin2 binary(40))"
,
i
)
;
}
else
{
sprintf
(
buf
,
"create table m%d (ts timestamp, b int)"
,
i
)
;
}
result
=
taos_query
(
taos
,
buf
);
result
=
taos_query
(
taos
,
buf
);
code
=
taos_errno
(
result
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -4492,12 +5066,7 @@ void prepare(TAOS *taos, int bigsize, int createChildTable) {
...
@@ -4492,12 +5066,7 @@ void prepare(TAOS *taos, int bigsize, int createChildTable) {
}
}
}
else
{
}
else
{
char
buf
[
1024
];
char
buf
[
1024
];
if
(
bigsize
)
{
generateCreateTableSQL
(
buf
,
1
,
colNum
,
colList
,
true
);
sprintf
(
buf
,
"create stable stb1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), bin2 binary(40))"
" tags(id1 int, id2 bool, id3 tinyint, id4 smallint, id5 bigint, id6 float, id7 double, id8 binary(40), id9 nchar(40))"
)
;
}
else
{
sprintf
(
buf
,
"create stable stb1 (ts timestamp, b int) tags(id1 int, id2 bool, id3 tinyint, id4 smallint, id5 bigint, id6 float, id7 double, id8 binary(40), id9 nchar(40))"
)
;
}
result
=
taos_query
(
taos
,
buf
);
result
=
taos_query
(
taos
,
buf
);
code
=
taos_errno
(
result
);
code
=
taos_errno
(
result
);
...
@@ -4511,65 +5080,29 @@ void prepare(TAOS *taos, int bigsize, int createChildTable) {
...
@@ -4511,65 +5080,29 @@ void prepare(TAOS *taos, int bigsize, int createChildTable) {
}
}
void
*
runcase
(
TAOS
*
taos
)
{
TAOS_STMT
*
stmt
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
sizeof
(
gCase
)
/
sizeof
(
gCase
[
0
]);
++
i
)
{
gCurCase
=
&
gCase
[
i
];
printf
(
"Case %d Begin
\n
"
,
i
);
void
preparem
(
TAOS
*
taos
,
int
bigsize
,
int
idx
)
{
for
(
int32_t
n
=
0
;
n
<
gCurCase
->
runTimes
;
++
n
)
{
TAOS_RES
*
result
;
prepare
(
taos
,
tListLen
(
gCurCase
->
colList
),
gCurCase
->
colList
,
gCurCase
->
autoCreate
);
int
code
;
char
dbname
[
32
],
sql
[
255
];
stmt
=
taos_stmt_init
(
taos
);
if
(
NULL
==
stmt
)
{
sprintf
(
dbname
,
"demo%d"
,
idx
);
printf
(
"taos_stmt_init failed, error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
sprintf
(
sql
,
"drop database %s"
,
dbname
);
exit
(
1
);
}
result
=
taos_query
(
taos
,
sql
);
taos_free_result
(
result
);
sprintf
(
sql
,
"create database %s keep 36500"
,
dbname
);
(
*
gCurCase
->
runFn
)(
stmt
);
result
=
taos_query
(
taos
,
sql
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
printf
(
"failed to create database, reason:%s
\n
"
,
taos_errstr
(
result
));
taos_free_result
(
result
);
exit
(
1
);
}
taos_free_result
(
result
);
sprintf
(
sql
,
"use %s"
,
dbname
);
prepareCheckResult
(
taos
);
result
=
taos_query
(
taos
,
sql
);
taos_free_result
(
result
);
// create table
for
(
int
i
=
0
;
i
<
300
;
i
++
)
{
char
buf
[
1024
];
if
(
bigsize
)
{
sprintf
(
buf
,
"create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), bin2 binary(40))"
,
i
)
;
}
else
{
sprintf
(
buf
,
"create table m%d (ts timestamp, b int)"
,
i
)
;
}
result
=
taos_query
(
taos
,
buf
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
printf
(
"failed to create table, reason:%s
\n
"
,
taos_errstr
(
result
));
taos_free_result
(
result
);
exit
(
1
);
}
}
taos_free_result
(
result
);
printf
(
"Case %d End
\n
"
,
i
);
}
}
}
//void runcase(TAOS *taos, int idx) {
void
*
runcase
(
void
*
par
)
{
T_par
*
tpar
=
(
T_par
*
)
par
;
TAOS
*
taos
=
tpar
->
taos
;
int
idx
=
tpar
->
idx
;
TAOS_STMT
*
stmt
;
(
void
)
idx
;
#if 0
#if 0
prepare(taos, 0, 1);
prepare(taos, 0, 1);
...
@@ -4636,7 +5169,7 @@ void* runcase(void *par) {
...
@@ -4636,7 +5169,7 @@ void* runcase(void *par) {
#if
1
#if
0
prepare(taos, 1, 1);
prepare(taos, 1, 1);
stmt = taos_stmt_init(taos);
stmt = taos_stmt_init(taos);
...
@@ -4655,9 +5188,8 @@ void* runcase(void *par) {
...
@@ -4655,9 +5188,8 @@ void* runcase(void *par) {
#endif
#endif
#if 0
#if
1
#if
0
prepare(taos, 1, 1);
prepare(taos, 1, 1);
stmt = taos_stmt_init(taos);
stmt = taos_stmt_init(taos);
...
@@ -4681,6 +5213,24 @@ void* runcase(void *par) {
...
@@ -4681,6 +5213,24 @@ void* runcase(void *par) {
#endif
#endif
#if 0
prepare(taos, 1, 1);
stmt = taos_stmt_init(taos);
printf("1t+2r+bm+specifycol start\n");
stmt_scol_func5(stmt);
printf("1t+2r+bm+specifycol end\n");
printf("check result start\n");
check_result(taos, "m0", 1, 40);
printf("check result end\n");
taos_stmt_close(stmt);
#endif
#if 0
#if 1
#if 1
prepare(taos, 1, 1);
prepare(taos, 1, 1);
...
@@ -5129,62 +5679,24 @@ void* runcase(void *par) {
...
@@ -5129,62 +5679,24 @@ void* runcase(void *par) {
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
TAOS
*
taos
[
4
]
;
TAOS
*
taos
=
NULL
;
srand
(
time
(
NULL
));
// connect to server
// connect to server
if
(
argc
<
2
)
{
if
(
argc
<
2
)
{
printf
(
"please input server ip
\n
"
);
printf
(
"please input server ip
\n
"
);
return
0
;
return
0
;
}
}
taos
[
0
]
=
taos_connect
(
argv
[
1
],
"root"
,
"taosdata"
,
NULL
,
0
);
taos
=
taos_connect
(
argv
[
1
],
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"failed to connect to db, reason:%s
\n
"
,
taos_errstr
(
taos
));
exit
(
1
);
}
taos
[
1
]
=
taos_connect
(
argv
[
1
],
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"failed to connect to db, reason:%s
\n
"
,
taos_errstr
(
taos
));
exit
(
1
);
}
taos
[
2
]
=
taos_connect
(
argv
[
1
],
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
if
(
taos
==
NULL
)
{
printf
(
"failed to connect to db, reason:%s
\n
"
,
taos_errstr
(
taos
));
printf
(
"failed to connect to db, reason:%s
\n
"
,
taos_errstr
(
taos
));
exit
(
1
);
exit
(
1
);
}
}
taos
[
3
]
=
taos_connect
(
argv
[
1
],
"root"
,
"taosdata"
,
NULL
,
0
);
runcase
(
taos
);
if
(
taos
==
NULL
)
{
printf
(
"failed to connect to db, reason:%s
\n
"
,
taos_errstr
(
taos
));
exit
(
1
);
}
pthread_t
*
pThreadList
=
(
pthread_t
*
)
taosMemoryCalloc
(
sizeof
(
pthread_t
),
4
);
pthread_attr_t
thattr
;
pthread_attr_init
(
&
thattr
);
pthread_attr_setdetachstate
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
T_par
par
[
4
];
par
[
0
].
taos
=
taos
[
0
];
par
[
0
].
idx
=
0
;
par
[
1
].
taos
=
taos
[
1
];
par
[
1
].
idx
=
1
;
par
[
2
].
taos
=
taos
[
2
];
par
[
2
].
idx
=
2
;
par
[
3
].
taos
=
taos
[
3
];
par
[
3
].
idx
=
3
;
pthread_create
(
&
(
pThreadList
[
0
]),
&
thattr
,
runcase
,
(
void
*
)
&
par
[
0
]);
//pthread_create(&(pThreadList[1]), &thattr, runcase, (void *)&par[1]);
//pthread_create(&(pThreadList[2]), &thattr, runcase, (void *)&par[2]);
//pthread_create(&(pThreadList[3]), &thattr, runcase, (void *)&par[3]);
while
(
1
)
{
sleep
(
1
);
}
return
0
;
return
0
;
}
}
tests/script/api/makefile
浏览文件 @
0f13cee8
...
@@ -4,9 +4,9 @@
...
@@ -4,9 +4,9 @@
ROOT
=
./
ROOT
=
./
TARGET
=
exe
TARGET
=
exe
LFLAGS
=
'-Wl,-rpath,/usr/local/taos/driver/'
-ltaos
-lpthread
-lm
-lrt
LFLAGS
=
'-Wl,-rpath,/usr/local/taos/driver/'
-ltaos
-lpthread
-lm
-lrt
CFLAGS
=
-O0
-g
-W
all
-W
no-deprecated
-fPIC
-Wno-unused-result
-Wconversion
\
CFLAGS
=
-O0
-g
-Wno-deprecated
-fPIC
-Wno-unused-result
-Wconversion
\
-Wno-char-subscripts
-D_REENTRANT
-Wno-format
-D_REENTRANT
-DLINUX
\
-Wno-char-subscripts
-D_REENTRANT
-Wno-format
-D_REENTRANT
-DLINUX
\
-Wno-unused-function
-D_M_X64
-I
/usr/local/taos/include
-std
=
gnu99
-Wno-unused-function
-D_M_X64
-I
/usr/local/taos/include
-std
=
gnu99
-Wno-sign-conversion
all
:
$(TARGET)
all
:
$(TARGET)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录