提交 92605701 编写于 作者: D dapan1121

Merge remote-tracking branch 'origin/develop' into feature/TD-10501

...@@ -201,7 +201,7 @@ pipeline { ...@@ -201,7 +201,7 @@ pipeline {
stages { stages {
stage('pre_build'){ stage('pre_build'){
agent{label 'master'} agent{label 'master'}
when { when{
changeRequest() changeRequest()
} }
steps { steps {
...@@ -255,6 +255,7 @@ pipeline { ...@@ -255,6 +255,7 @@ pipeline {
expression{ expression{
return skipbuild.trim() == '2' return skipbuild.trim() == '2'
} }
not{ expression { env.CHANGE_BRANCH =~ /docs\// }}
} }
} }
parallel { parallel {
......
此差异已折叠。
此差异已折叠。
...@@ -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}]
} }
``` ```
......
...@@ -171,6 +171,7 @@ TDengine 缺省的时间戳是毫秒精度,但通过在 CREATE DATABASE 时传 ...@@ -171,6 +171,7 @@ TDengine 缺省的时间戳是毫秒精度,但通过在 CREATE DATABASE 时传
4) 子表名只能由字母、数字和下划线组成,且不能以数字开头,不区分大小写 4) 子表名只能由字母、数字和下划线组成,且不能以数字开头,不区分大小写
5) 使用数据类型 binary 或 nchar,需指定其最长的字节数,如 binary(20),表示 20 字节; 5) 使用数据类型 binary 或 nchar,需指定其最长的字节数,如 binary(20),表示 20 字节;
6) 为了兼容支持更多形式的表名,TDengine 引入新的转义符 "\`",可以让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查。但是同样具有长度限制要求。使用转义字符以后,不再对转义字符中的内容进行大小写统一。 6) 为了兼容支持更多形式的表名,TDengine 引入新的转义符 "\`",可以让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查。但是同样具有长度限制要求。使用转义字符以后,不再对转义字符中的内容进行大小写统一。
例如:\`aBc\` 和 \`abc\` 是不同的表名,但是 abc 和 aBc 是相同的表名。 例如:\`aBc\` 和 \`abc\` 是不同的表名,但是 abc 和 aBc 是相同的表名。
需要注意的是转义字符中的内容必须是可打印字符。 需要注意的是转义字符中的内容必须是可打印字符。
...@@ -1280,7 +1281,7 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 ...@@ -1280,7 +1281,7 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
适用于:**表、超级表**。 适用于:**表、超级表**。
说明:*P*值有效取值范围0≤P≤100,为 0 的时候等同于 MIN,为 100 的时候等同于MAX;*algo_type*的有效输入:**default** 和 **t-digest**。 用于指定计算近似分位数的算法。可不提供第三个参数的输入,此时将使用 default 的算法进行计算,即 apercentile(column_name, 50, "default") 与 apercentile(column_name, 50) 等价。当使用“t-digest”参数的时候,将使用t-digest方式采样计算近似分位数。但该参数指定计算算法的功能从2.2.0.x版本开始支持,2.2.0.0之前的版本不支持指定使用算法的功能。 说明:<br/>**P**值有效取值范围0≤P≤100,为 0 的时候等同于 MIN,为 100 的时候等同于MAX;<br/>**algo_type**的有效输入:**default** 和 **t-digest**。 用于指定计算近似分位数的算法。可不提供第三个参数的输入,此时将使用 default 的算法进行计算,即 apercentile(column_name, 50, "default") 与 apercentile(column_name, 50) 等价。当使用“t-digest”参数的时候,将使用t-digest方式采样计算近似分位数。但该参数指定计算算法的功能从2.2.0.x版本开始支持,2.2.0.0之前的版本不支持指定使用算法的功能。<br/>
嵌套子查询支持:适用于内层查询和外层查询。 嵌套子查询支持:适用于内层查询和外层查询。
...@@ -1319,9 +1320,9 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 ...@@ -1319,9 +1320,9 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
限制:LAST_ROW() 不能与 INTERVAL 一起使用。 限制:LAST_ROW() 不能与 INTERVAL 一起使用。
说明:在用于超级表时,时间戳完全一样且同为最大的数据行可能有多个,那么会从中随机返回一条,而并不保证多次运行所挑选的数据行必然一致。 说明:在用于超级表时,时间戳完全一样且同为最大的数据行可能有多个,那么会从中随机返回一条,而并不保证多次运行所挑选的数据行必然一致。<br/>
<br/>示例:
示例:
```mysql ```mysql
taos> SELECT LAST_ROW(current) FROM meters; taos> SELECT LAST_ROW(current) FROM meters;
last_row(current) | last_row(current) |
...@@ -1336,10 +1337,13 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 ...@@ -1336,10 +1337,13 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
Query OK, 1 row(s) in set (0.001042s) Query OK, 1 row(s) in set (0.001042s)
``` ```
- **INTERP** - **INTERP**
```mysql ```mysql
SELECT INTERP(field_name) FROM { tb_name | stb_name } WHERE ts='timestamp' [FILL ({ VALUE | PREV | NULL | LINEAR | NEXT})]; SELECT INTERP(field_name) FROM { tb_name | stb_name } WHERE ts='timestamp' [FILL ({ VALUE | PREV | NULL | LINEAR | NEXT})];
``` ```
功能说明:返回表/超级表的指定时间截面、指定字段的记录。 功能说明:返回表/超级表的指定时间截面、指定字段的记录。
返回结果数据类型:同字段类型。 返回结果数据类型:同字段类型。
...@@ -1348,15 +1352,9 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 ...@@ -1348,15 +1352,9 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
适用于:**表、超级表**。 适用于:**表、超级表**。
说明:(从 2.0.15.0 版本开始新增此函数) 说明:(从 2.0.15.0 版本开始新增此函数) <br/>1)INTERP 必须指定时间断面,如果该时间断面不存在直接对应的数据,那么会根据 FILL 参数的设定进行插值。此外,条件语句里面可附带筛选条件,例如标签、tbname。<br/>2)INTERP 查询要求查询的时间区间必须位于数据集合(表)的所有记录的时间范围之内。如果给定的时间戳位于时间范围之外,即使有插值指令,仍然不返回结果。<br/>3)单个 INTERP 函数查询只能够针对一个时间点进行查询,如果需要返回等时间间隔的断面数据,可以通过 INTERP 配合 EVERY 的方式来进行查询处理(而不是使用 INTERVAL),其含义是每隔固定长度的时间进行插值。<br/>
1)INTERP 必须指定时间断面,如果该时间断面不存在直接对应的数据,那么会根据 FILL 参数的设定进行插值。此外,条件语句里面可附带筛选条件,例如标签、tbname。
2)INTERP 查询要求查询的时间区间必须位于数据集合(表)的所有记录的时间范围之内。如果给定的时间戳位于时间范围之外,即使有插值指令,仍然不返回结果。
3)单个 INTERP 函数查询只能够针对一个时间点进行查询,如果需要返回等时间间隔的断面数据,可以通过 INTERP 配合 EVERY 的方式来进行查询处理(而不是使用 INTERVAL),其含义是每隔固定长度的时间进行插值。
示例: 示例:
```mysql ```mysql
taos> SELECT INTERP(*) FROM meters WHERE ts='2017-7-14 18:40:00.004'; taos> SELECT INTERP(*) FROM meters WHERE ts='2017-7-14 18:40:00.004';
interp(ts) | interp(current) | interp(voltage) | interp(phase) | interp(ts) | interp(current) | interp(voltage) | interp(phase) |
...@@ -1365,20 +1363,20 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 ...@@ -1365,20 +1363,20 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
Query OK, 1 row(s) in set (0.002652s) Query OK, 1 row(s) in set (0.002652s)
``` ```
如果给定的时间戳无对应的数据,在不指定插值生成策略的情况下,不会返回结果,如果指定了插值策略,会根据插值策略返回结果。 如果给定的时间戳无对应的数据,在不指定插值生成策略的情况下,不会返回结果,如果指定了插值策略,会根据插值策略返回结果。
```mysql ```mysql
taos> SELECT INTERP(*) FROM meters WHERE tbname IN ('d636') AND ts='2017-7-14 18:40:00.005'; taos> SELECT INTERP(*) FROM meters WHERE tbname IN ('d636') AND ts='2017-7-14 18:40:00.005';
Query OK, 0 row(s) in set (0.004022s) Query OK, 0 row(s) in set (0.004022s)
taos> SELECT INTERP(*) FROM meters WHERE tbname IN ('d636') AND ts='2017-7-14 18:40:00.005' FILL(PREV);; taos> SELECT INTERP(*) FROM meters WHERE tbname IN ('d636') AND ts='2017-7-14 18:40:00.005' FILL(PREV);
interp(ts) | interp(current) | interp(voltage) | interp(phase) | interp(ts) | interp(current) | interp(voltage) | interp(phase) |
========================================================================================== ==========================================================================================
2017-07-14 18:40:00.005 | 9.88150 | 217 | 0.32500 | 2017-07-14 18:40:00.005 | 9.88150 | 217 | 0.32500 |
Query OK, 1 row(s) in set (0.003056s) Query OK, 1 row(s) in set (0.003056s)
``` ```
如下所示代码表示在时间区间 `['2017-7-14 18:40:00', '2017-7-14 18:40:00.014']` 中每隔 5 毫秒 进行一次断面计算。 如下所示代码表示在时间区间 `['2017-7-14 18:40:00', '2017-7-14 18:40:00.014']` 中每隔 5 毫秒 进行一次断面计算。
```mysql ```mysql
taos> SELECT INTERP(current) FROM d636 WHERE ts>='2017-7-14 18:40:00' AND ts<='2017-7-14 18:40:00.014' EVERY(5a); taos> SELECT INTERP(current) FROM d636 WHERE ts>='2017-7-14 18:40:00' AND ts<='2017-7-14 18:40:00.014' EVERY(5a);
...@@ -1604,7 +1602,7 @@ SELECT AVG(current), MAX(current), LEASTSQUARES(current, start_val, step_val), P ...@@ -1604,7 +1602,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 与不为空的表达式适用范围**
......
...@@ -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 仪表盘
......
...@@ -254,7 +254,10 @@ function install_lib() { ...@@ -254,7 +254,10 @@ function install_lib() {
fi fi
if [ "$osType" != "Darwin" ]; then if [ "$osType" != "Darwin" ]; then
${csudo} cp ${binary_dir}/build/lib/libtaos.so.${verNumber} ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* ${csudo} cp ${binary_dir}/build/lib/libtaos.so.${verNumber} \
${install_main_dir}/driver \
&& ${csudo} chmod 777 ${install_main_dir}/driver/*
${csudo} ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 ${csudo} ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
${csudo} ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so ${csudo} ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
...@@ -263,11 +266,28 @@ function install_lib() { ...@@ -263,11 +266,28 @@ function install_lib() {
${csudo} ln -sf ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so ${csudo} ln -sf ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so
fi fi
else else
${csudo} cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib ${install_main_dir}/driver || ${csudo} cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib ${install_main_2_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* || ${csudo} chmod 777 ${install_main_2_dir}/driver/* ${csudo} cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \
${install_main_dir}/driver \
|| ${csudo} cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \
${install_main_2_dir}/driver \
&& ${csudo} chmod 777 ${install_main_dir}/driver/* \
|| ${csudo} chmod 777 ${install_main_2_dir}/driver/*
${csudo} ln -sf ${install_main_dir}/driver/libtaos.* \
${install_main_dir}/driver/libtaos.1.dylib \
|| ${csudo} ln -sf ${install_main_2_dir}/driver/libtaos.* \
${install_main_2_dir}/driver/libtaos.1.dylib || :
${csudo} ln -sf ${install_main_dir}/driver/libtaos.1.dylib \
${install_main_dir}/driver/libtaos.dylib \
|| ${csudo} ln -sf ${install_main_2_dir}/driver/libtaos.1.dylib \
${install_main_2_dir}/driver/libtaos.dylib || :
${csudo} ln -sf ${install_main_dir}/driver/libtaos.${verNumber}.dylib \
${lib_link_dir}/libtaos.1.dylib \
|| ${csudo} ln -sf ${install_main_2_dir}/driver/libtaos.${verNumber}.dylib \
${lib_link_dir}/libtaos.1.dylib || :
${csudo} ln -sf ${install_main_dir}/driver/libtaos.* ${install_main_dir}/driver/libtaos.1.dylib || ${csudo} ln -sf ${install_main_2_dir}/driver/libtaos.* ${install_main_2_dir}/driver/libtaos.1.dylib || :
${csudo} ln -sf ${install_main_dir}/driver/libtaos.1.dylib ${install_main_dir}/driver/libtaos.dylib || ${csudo} ln -sf ${install_main_2_dir}/driver/libtaos.1.dylib ${install_main_2_dir}/driver/libtaos.dylib || :
${csudo} ln -sf ${install_main_dir}/driver/libtaos.${verNumber}.dylib ${lib_link_dir}/libtaos.1.dylib || ${csudo} ln -sf ${install_main_2_dir}/driver/libtaos.${verNumber}.dylib ${lib_link_dir}/libtaos.1.dylib || :
${csudo} ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib || : ${csudo} ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib || :
fi fi
...@@ -282,11 +302,17 @@ function install_header() { ...@@ -282,11 +302,17 @@ function install_header() {
if [ "$osType" != "Darwin" ]; then if [ "$osType" != "Darwin" ]; then
${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || :
${csudo} cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taoserror.h ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* ${csudo} cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taoserror.h \
${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/*
${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
else else
${csudo} cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taoserror.h ${install_main_dir}/include || ${csudo} cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taoserror.h ${install_main_2_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* || ${csudo} chmod 644 ${install_main_2_dir}/include/* ${csudo} cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taoserror.h \
${install_main_dir}/include \
|| ${csudo} cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taoserror.h \
${install_main_2_dir}/include \
&& ${csudo} chmod 644 ${install_main_dir}/include/* \
|| ${csudo} chmod 644 ${install_main_2_dir}/include/*
fi fi
} }
...@@ -301,7 +327,12 @@ function install_config() { ...@@ -301,7 +327,12 @@ function install_config() {
${csudo} cp -f ${script_dir}/../cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org ${csudo} cp -f ${script_dir}/../cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org
${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg/taos.cfg ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg/taos.cfg
else else
${csudo} cp -f ${script_dir}/../cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org || ${csudo} cp -f ${script_dir}/../cfg/taos.cfg ${install_main_2_dir}/cfg/taos.cfg.org if [ "$osType" != "Darwin" ]; then
${csudo} cp -f ${script_dir}/../cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org
else
${csudo} cp -f ${script_dir}/../cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org\
|| ${csudo} cp -f ${script_dir}/../cfg/taos.cfg ${install_main_2_dir}/cfg/taos.cfg.org
fi
fi fi
} }
...@@ -312,14 +343,21 @@ function install_blm3_config() { ...@@ -312,14 +343,21 @@ function install_blm3_config() {
${csudo} cp ${binary_dir}/test/cfg/blm.toml ${cfg_install_dir} ${csudo} cp ${binary_dir}/test/cfg/blm.toml ${cfg_install_dir}
[ -f ${cfg_install_dir}/blm.toml ] && [ -f ${cfg_install_dir}/blm.toml ] &&
${csudo} chmod 644 ${cfg_install_dir}/blm.toml ${csudo} chmod 644 ${cfg_install_dir}/blm.toml
[ -f ${binary_dir}/test/cfg//blm.toml ] && [ -f ${binary_dir}/test/cfg/blm.toml ] &&
${csudo} cp -f ${binary_dir}/test/cfg/blm.toml ${install_main_dir}/cfg/blm.toml.org ${csudo} cp -f ${binary_dir}/test/cfg/blm.toml ${install_main_dir}/cfg/blm.toml.org
[ -f ${cfg_install_dir}/blm.toml ] && [ -f ${cfg_install_dir}/blm.toml ] &&
${csudo} ln -s ${cfg_install_dir}/blm.toml ${install_main_dir}/cfg/blm.toml ${csudo} ln -s ${cfg_install_dir}/blm.toml ${install_main_dir}/cfg/blm.toml
else else
[ -f ${binary_dir}/test/cfg//blm.toml ] && if [ -f "${binary_dir}/test/cfg/blm.toml" ]; then
if [ "$osType" != "Darwin" ]; then
${csudo} cp -f ${binary_dir}/test/cfg/blm.toml \
${install_main_dir}/cfg/blm.toml.org
else
${csudo} cp -f ${binary_dir}/test/cfg/blm.toml ${install_main_dir}/cfg/blm.toml.org \ ${csudo} cp -f ${binary_dir}/test/cfg/blm.toml ${install_main_dir}/cfg/blm.toml.org \
|| ${csudo} cp -f ${binary_dir}/test/cfg/blm.toml ${install_main_2_dir}/cfg/blm.toml.org || ${csudo} cp -f ${binary_dir}/test/cfg/blm.toml \
${install_main_2_dir}/cfg/blm.toml.org
fi
fi
fi fi
} }
......
...@@ -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);
......
...@@ -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, tstrerror(code)); tscError("SML:0x%"PRIx64" taos_stmt_prepare return %d:%s", info->id, code, taos_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,8 +807,9 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam ...@@ -795,8 +807,9 @@ 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, tstrerror(code), try); tscError("SML:0x%"PRIx64" taos_stmt_execute return %d:%s, try:%d", info->id, code, taos_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
...@@ -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 cannnot 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,
......
...@@ -138,14 +138,35 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch ...@@ -138,14 +138,35 @@ 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) == '"' && len != 1 && len != 2) {
searchQuote = false;
} else {
cur++;
len++;
continue;
}
}
if (*(cur + 1) != ' ') { if (*(cur + 1) != ' ') {
break; break;
} else { } else {
...@@ -153,7 +174,6 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch ...@@ -153,7 +174,6 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
continue; continue;
} }
} }
}
cur++; cur++;
len++; len++;
} }
......
...@@ -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) {
...@@ -1285,6 +1289,8 @@ static int insertBatchStmtExecute(STscStmt* pStmt) { ...@@ -1285,6 +1289,8 @@ static int insertBatchStmtExecute(STscStmt* pStmt) {
code = pStmt->pSql->res.code; code = pStmt->pSql->res.code;
pStmt->numOfRows += pStmt->pSql->res.numOfRows;
insertBatchClean(pStmt); insertBatchClean(pStmt);
return code; return code;
...@@ -1521,6 +1527,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) { ...@@ -1521,6 +1527,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) {
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.");
......
...@@ -5125,7 +5125,6 @@ static int32_t doAddTableName(char* nextStr, char** str, SArray* pNameArray, SSq ...@@ -5125,7 +5125,6 @@ static int32_t doAddTableName(char* nextStr, char** str, SArray* pNameArray, SSq
if (nextStr == NULL) { if (nextStr == NULL) {
tstrncpy(tablename, *str, TSDB_TABLE_FNAME_LEN); tstrncpy(tablename, *str, TSDB_TABLE_FNAME_LEN);
len = (int32_t) strlen(tablename);
} else { } else {
len = (int32_t)(nextStr - (*str)); len = (int32_t)(nextStr - (*str));
if (len >= TSDB_TABLE_NAME_LEN) { if (len >= TSDB_TABLE_NAME_LEN) {
......
...@@ -562,7 +562,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -562,7 +562,7 @@ 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
...@@ -572,7 +572,8 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -572,7 +572,8 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
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
...@@ -582,6 +583,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -582,6 +583,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
rowData.setStringValue(5, "STABLE"); //REMARKS rowData.setStringValue(5, "STABLE"); //REMARKS
rowDataList.add(rowData); rowDataList.add(rowData);
} }
}
resultSet.setRowDataList(rowDataList); resultSet.setRowDataList(rowDataList);
} }
return resultSet; return resultSet;
...@@ -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,7 +1249,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -1246,7 +1249,7 @@ 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);
...@@ -1258,6 +1261,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -1258,6 +1261,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
} }
resultSet.setRowDataList(rowDataList); resultSet.setRowDataList(rowDataList);
} }
}
return resultSet; return resultSet;
} }
......
...@@ -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;
......
...@@ -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;
} }
......
...@@ -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;
...@@ -85,7 +84,8 @@ public class TSDBStatement extends AbstractStatement { ...@@ -85,7 +84,8 @@ public class TSDBStatement extends AbstractStatement {
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;
} }
......
...@@ -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;
} }
......
...@@ -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);
} }
......
...@@ -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);
......
此差异已折叠。
此差异已折叠。
Subproject commit 4bfae86dcabea0d5a40ff81a72be7c822737269b Subproject commit c67fcc11bc5e82e3d7aea8db855a8cbf8b109239
...@@ -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() {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册