Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6369d442
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6369d442
编写于
10月 20, 2021
作者:
haoranc
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of github.com:taosdata/TDengine into dev/chr
上级
626f6821
d539af37
变更
20
展开全部
隐藏空白更改
内联
并排
Showing
20 changed file
with
360 addition
and
210 deletion
+360
-210
documentation20/cn/12.taos-sql/docs.md
documentation20/cn/12.taos-sql/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/AbstractDatabaseMetaData.java
...main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java
+41
-37
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java
...src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java
+1
-1
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
...dbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
+3
-3
src/inc/taos.h
src/inc/taos.h
+1
-0
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+138
-124
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+1
-5
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
tests/examples/c/makefile
tests/examples/c/makefile
+0
-4
tests/examples/c/prepare.c
tests/examples/c/prepare.c
+11
-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/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/12.taos-sql/docs.md
浏览文件 @
6369d442
...
@@ -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 与不为空的表达式适用范围**
...
...
src/client/inc/tscParseLine.h
浏览文件 @
6369d442
...
@@ -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
浏览文件 @
6369d442
...
@@ -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
浏览文件 @
6369d442
...
@@ -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
浏览文件 @
6369d442
...
@@ -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/AbstractDatabaseMetaData.java
浏览文件 @
6369d442
...
@@ -562,25 +562,27 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
...
@@ -562,25 +562,27 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<>();
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<>();
try
(
Statement
stmt
=
connection
.
createStatement
())
{
try
(
Statement
stmt
=
connection
.
createStatement
())
{
stmt
.
execute
(
"use "
+
catalog
);
stmt
.
execute
(
"use "
+
catalog
);
ResultSet
tables
=
stmt
.
executeQuery
(
"show tables"
);
try
(
ResultSet
tables
=
stmt
.
executeQuery
(
"show tables"
))
{
while
(
tables
.
next
())
{
while
(
tables
.
next
())
{
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
10
);
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
10
);
rowData
.
setStringValue
(
1
,
catalog
);
//TABLE_CAT
rowData
.
setStringValue
(
1
,
catalog
);
//TABLE_CAT
rowData
.
setStringValue
(
2
,
null
);
//TABLE_SCHEM
rowData
.
setStringValue
(
2
,
null
);
//TABLE_SCHEM
rowData
.
setStringValue
(
3
,
tables
.
getString
(
"table_name"
));
//TABLE_NAME
rowData
.
setStringValue
(
3
,
tables
.
getString
(
"table_name"
));
//TABLE_NAME
rowData
.
setStringValue
(
4
,
"TABLE"
);
//TABLE_TYPE
rowData
.
setStringValue
(
4
,
"TABLE"
);
//TABLE_TYPE
rowData
.
setStringValue
(
5
,
""
);
//REMARKS
rowData
.
setStringValue
(
5
,
""
);
//REMARKS
rowDataList
.
add
(
rowData
);
rowDataList
.
add
(
rowData
);
}
}
}
ResultSet
stables
=
stmt
.
executeQuery
(
"show stables"
);
try
(
ResultSet
stables
=
stmt
.
executeQuery
(
"show stables"
))
{
while
(
stables
.
next
())
{
while
(
stables
.
next
())
{
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
10
);
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
10
);
rowData
.
setStringValue
(
1
,
catalog
);
//TABLE_CAT
rowData
.
setStringValue
(
1
,
catalog
);
//TABLE_CAT
rowData
.
setStringValue
(
2
,
null
);
//TABLE_SCHEM
rowData
.
setStringValue
(
2
,
null
);
//TABLE_SCHEM
rowData
.
setStringValue
(
3
,
stables
.
getString
(
"name"
));
//TABLE_NAME
rowData
.
setStringValue
(
3
,
stables
.
getString
(
"name"
));
//TABLE_NAME
rowData
.
setStringValue
(
4
,
"TABLE"
);
//TABLE_TYPE
rowData
.
setStringValue
(
4
,
"TABLE"
);
//TABLE_TYPE
rowData
.
setStringValue
(
5
,
"STABLE"
);
//REMARKS
rowData
.
setStringValue
(
5
,
"STABLE"
);
//REMARKS
rowDataList
.
add
(
rowData
);
rowDataList
.
add
(
rowData
);
}
}
}
resultSet
.
setRowDataList
(
rowDataList
);
resultSet
.
setRowDataList
(
rowDataList
);
}
}
...
@@ -638,8 +640,9 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
...
@@ -638,8 +640,9 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
resultSet
.
setColumnMetaDataList
(
buildGetColumnsColumnMetaDataList
());
resultSet
.
setColumnMetaDataList
(
buildGetColumnsColumnMetaDataList
());
// set up rowDataList
// set up rowDataList
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<>();
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<>();
try
(
Statement
stmt
=
conn
.
createStatement
())
{
try
(
Statement
stmt
=
conn
.
createStatement
();
ResultSet
rs
=
stmt
.
executeQuery
(
"describe "
+
catalog
+
"."
+
tableNamePattern
);
ResultSet
rs
=
stmt
.
executeQuery
(
"describe "
+
catalog
+
"."
+
tableNamePattern
))
{
int
rowIndex
=
0
;
int
rowIndex
=
0
;
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
24
);
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
24
);
...
@@ -1147,9 +1150,9 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
...
@@ -1147,9 +1150,9 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
columnMetaDataList
.
add
(
buildTableCatalogMeta
(
1
));
// 1. TABLE_CAT
columnMetaDataList
.
add
(
buildTableCatalogMeta
(
1
));
// 1. TABLE_CAT
resultSet
.
setColumnMetaDataList
(
columnMetaDataList
);
resultSet
.
setColumnMetaDataList
(
columnMetaDataList
);
try
(
Statement
stmt
=
conn
.
createStatement
())
{
try
(
Statement
stmt
=
conn
.
createStatement
();
ResultSet
rs
=
stmt
.
executeQuery
(
"show databases"
))
{
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<>();
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<>();
ResultSet
rs
=
stmt
.
executeQuery
(
"show databases"
);
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
1
);
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
1
);
rowData
.
setStringValue
(
1
,
rs
.
getString
(
"name"
));
rowData
.
setStringValue
(
1
,
rs
.
getString
(
"name"
));
...
@@ -1168,12 +1171,13 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
...
@@ -1168,12 +1171,13 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
return
new
EmptyResultSet
();
return
new
EmptyResultSet
();
DatabaseMetaDataResultSet
resultSet
=
new
DatabaseMetaDataResultSet
();
DatabaseMetaDataResultSet
resultSet
=
new
DatabaseMetaDataResultSet
();
try
(
Statement
stmt
=
conn
.
createStatement
())
{
try
(
Statement
stmt
=
conn
.
createStatement
();
ResultSet
rs
=
stmt
.
executeQuery
(
"describe "
+
catalog
+
"."
+
table
))
{
// set up ColumnMetaDataList
// set up ColumnMetaDataList
resultSet
.
setColumnMetaDataList
(
buildGetPrimaryKeysMetadataList
());
resultSet
.
setColumnMetaDataList
(
buildGetPrimaryKeysMetadataList
());
// set rowData
// set rowData
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<>();
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<>();
ResultSet
rs
=
stmt
.
executeQuery
(
"describe "
+
catalog
+
"."
+
table
);
rs
.
next
();
rs
.
next
();
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
6
);
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
6
);
rowData
.
setStringValue
(
1
,
catalog
);
rowData
.
setStringValue
(
1
,
catalog
);
...
@@ -1217,15 +1221,14 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
...
@@ -1217,15 +1221,14 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
}
}
private
boolean
isAvailableCatalog
(
Connection
connection
,
String
catalog
)
{
private
boolean
isAvailableCatalog
(
Connection
connection
,
String
catalog
)
{
try
(
Statement
stmt
=
connection
.
createStatement
()
)
{
try
(
Statement
stmt
=
connection
.
createStatement
()
;
ResultSet
databases
=
stmt
.
executeQuery
(
"show databases"
);
ResultSet
databases
=
stmt
.
executeQuery
(
"show databases"
))
{
while
(
databases
.
next
())
{
while
(
databases
.
next
())
{
String
dbname
=
databases
.
getString
(
"name"
);
String
dbname
=
databases
.
getString
(
"name"
);
this
.
precision
=
databases
.
getString
(
"precision"
);
this
.
precision
=
databases
.
getString
(
"precision"
);
if
(
dbname
.
equalsIgnoreCase
(
catalog
))
if
(
dbname
.
equalsIgnoreCase
(
catalog
))
return
true
;
return
true
;
}
}
databases
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -1246,17 +1249,18 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
...
@@ -1246,17 +1249,18 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
resultSet
.
setColumnMetaDataList
(
buildGetSuperTablesColumnMetaDataList
());
resultSet
.
setColumnMetaDataList
(
buildGetSuperTablesColumnMetaDataList
());
// set result set row data
// set result set row data
stmt
.
execute
(
"use "
+
catalog
);
stmt
.
execute
(
"use "
+
catalog
);
ResultSet
rs
=
stmt
.
executeQuery
(
"show tables like '"
+
tableNamePattern
+
"'"
);
try
(
ResultSet
rs
=
stmt
.
executeQuery
(
"show tables like '"
+
tableNamePattern
+
"'"
))
{
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<>();
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<>();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
4
);
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
4
);
rowData
.
setStringValue
(
1
,
catalog
);
rowData
.
setStringValue
(
1
,
catalog
);
rowData
.
setStringValue
(
2
,
null
);
rowData
.
setStringValue
(
2
,
null
);
rowData
.
setStringValue
(
3
,
rs
.
getString
(
"table_name"
));
rowData
.
setStringValue
(
3
,
rs
.
getString
(
"table_name"
));
rowData
.
setStringValue
(
4
,
rs
.
getString
(
"stable_name"
));
rowData
.
setStringValue
(
4
,
rs
.
getString
(
"stable_name"
));
rowDataList
.
add
(
rowData
);
rowDataList
.
add
(
rowData
);
}
resultSet
.
setRowDataList
(
rowDataList
);
}
}
resultSet
.
setRowDataList
(
rowDataList
);
}
}
return
resultSet
;
return
resultSet
;
}
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java
浏览文件 @
6369d442
...
@@ -189,7 +189,7 @@ public class TSDBResultSetRowData {
...
@@ -189,7 +189,7 @@ public class TSDBResultSetRowData {
long
value
=
(
long
)
obj
;
long
value
=
(
long
)
obj
;
if
(
value
<
0
)
if
(
value
<
0
)
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_NUMERIC_VALUE_OUT_OF_RANGE
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_NUMERIC_VALUE_OUT_OF_RANGE
);
return
Long
.
valueOf
(
value
).
intValue
()
;
return
(
int
)
value
;
}
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
浏览文件 @
6369d442
...
@@ -64,9 +64,9 @@ public class RestfulDriver extends AbstractDriver {
...
@@ -64,9 +64,9 @@ public class RestfulDriver extends AbstractDriver {
RestfulConnection
conn
=
new
RestfulConnection
(
host
,
port
,
props
,
database
,
url
,
token
);
RestfulConnection
conn
=
new
RestfulConnection
(
host
,
port
,
props
,
database
,
url
,
token
);
if
(
database
!=
null
&&
!
database
.
trim
().
replaceAll
(
"\\s"
,
""
).
isEmpty
())
{
if
(
database
!=
null
&&
!
database
.
trim
().
replaceAll
(
"\\s"
,
""
).
isEmpty
())
{
Statement
stmt
=
conn
.
createStatement
();
try
(
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
execute
(
"use "
+
database
);
stmt
.
execute
(
"use "
+
database
);
stmt
.
close
();
}
}
}
return
conn
;
return
conn
;
}
}
...
...
src/inc/taos.h
浏览文件 @
6369d442
...
@@ -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
浏览文件 @
6369d442
此差异已折叠。
点击以展开。
src/kit/taosdump/taosdump.c
浏览文件 @
6369d442
...
@@ -638,11 +638,6 @@ static int queryDbImpl(TAOS *taos, char *command) {
...
@@ -638,11 +638,6 @@ static int queryDbImpl(TAOS *taos, char *command) {
TAOS_RES
*
res
=
NULL
;
TAOS_RES
*
res
=
NULL
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
if
(
NULL
!=
res
)
{
taos_free_result
(
res
);
res
=
NULL
;
}
res
=
taos_query
(
taos
,
command
);
res
=
taos_query
(
taos
,
command
);
code
=
taos_errno
(
res
);
code
=
taos_errno
(
res
);
...
@@ -1193,6 +1188,7 @@ static int64_t dumpNormalTable(
...
@@ -1193,6 +1188,7 @@ static int64_t dumpNormalTable(
jsonAvroSchema
);
jsonAvroSchema
);
}
}
tfree
(
jsonAvroSchema
);
freeTbDes
(
tableDes
);
freeTbDes
(
tableDes
);
return
ret
;
return
ret
;
}
}
...
...
src/plugins/monitor/src/monMain.c
浏览文件 @
6369d442
...
@@ -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
浏览文件 @
6369d442
...
@@ -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
;
}
}
...
...
tests/examples/c/makefile
浏览文件 @
6369d442
...
@@ -29,7 +29,3 @@ clean:
...
@@ -29,7 +29,3 @@ clean:
rm
$(ROOT)
stream
rm
$(ROOT)
stream
rm
$(ROOT)
subscribe
rm
$(ROOT)
subscribe
rm
$(ROOT)
apitest
rm
$(ROOT)
apitest
tests/examples/c/prepare.c
浏览文件 @
6369d442
...
@@ -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/insert/insertTelnetLines.py
浏览文件 @
6369d442
...
@@ -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
浏览文件 @
6369d442
...
@@ -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/script/api/batchprepare.c
浏览文件 @
6369d442
...
@@ -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
浏览文件 @
6369d442
...
@@ -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
浏览文件 @
6369d442
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录