Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_40195168达庆意
TDengine
提交
789fc754
TDengine
项目概览
weixin_40195168达庆意
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
789fc754
编写于
1月 20, 2021
作者:
P
Ping Xiao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into xiaoping/add_test_case
上级
c1ddf46e
99073f1d
变更
40
展开全部
隐藏空白更改
内联
并排
Showing
40 changed file
with
2928 addition
and
2423 deletion
+2928
-2423
Jenkinsfile
Jenkinsfile
+35
-29
documentation20/webdocs/assets/tdengine-jdbc-connector.png
documentation20/webdocs/assets/tdengine-jdbc-connector.png
+0
-0
documentation20/webdocs/markdowndocs/TAOS SQL-ch.md
documentation20/webdocs/markdowndocs/TAOS SQL-ch.md
+1
-1
documentation20/webdocs/markdowndocs/administrator-ch.md
documentation20/webdocs/markdowndocs/administrator-ch.md
+2
-2
documentation20/webdocs/markdowndocs/connector-ch.md
documentation20/webdocs/markdowndocs/connector-ch.md
+0
-7
documentation20/webdocs/markdowndocs/connector-java-ch.md
documentation20/webdocs/markdowndocs/connector-java-ch.md
+154
-68
documentation20/webdocs/markdowndocs/faq-ch.md
documentation20/webdocs/markdowndocs/faq-ch.md
+3
-6
packaging/cfg/taos.cfg
packaging/cfg/taos.cfg
+0
-3
src/client/inc/tscSubquery.h
src/client/inc/tscSubquery.h
+0
-1
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+2
-1
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+4
-0
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+18
-0
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+201
-53
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+6
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
...src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
+358
-92
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java
...src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java
+26
-26
src/connector/jdbc/src/test/java/TestTSDBDatabaseMetaData.java
...onnector/jdbc/src/test/java/TestTSDBDatabaseMetaData.java
+0
-33
src/connector/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java
...r/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java
+19
-8
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
...test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
+51
-9
src/connector/nodejs/nodetaos/cinterface.js
src/connector/nodejs/nodetaos/cinterface.js
+5
-5
src/connector/nodejs/nodetaos/cursor.js
src/connector/nodejs/nodetaos/cursor.js
+1
-1
src/connector/nodejs/package-lock.json
src/connector/nodejs/package-lock.json
+194
-753
src/connector/nodejs/package.json
src/connector/nodejs/package.json
+16
-13
src/inc/ttokendef.h
src/inc/ttokendef.h
+142
-139
src/mnode/src/mnodeProfile.c
src/mnode/src/mnodeProfile.c
+24
-4
src/os/src/detail/osTime.c
src/os/src/detail/osTime.c
+2
-2
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+4
-2
src/query/inc/sql.y
src/query/inc/sql.y
+65
-9
src/query/src/qParserImpl.c
src/query/src/qParserImpl.c
+4
-2
src/query/src/sql.c
src/query/src/sql.c
+1533
-1146
src/sync/src/syncMain.c
src/sync/src/syncMain.c
+1
-1
tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java
...JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java
+0
-1
tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcRestfulDemo.java
...o/src/main/java/com/taosdata/example/JdbcRestfulDemo.java
+45
-0
tests/examples/JDBC/taosdemo/pom.xml
tests/examples/JDBC/taosdemo/pom.xml
+3
-3
tests/examples/JDBC/taosdemo/src/main/resources/lib/taos-jdbcdriver-2.0.15-dist.jar
...mo/src/main/resources/lib/taos-jdbcdriver-2.0.15-dist.jar
+0
-0
tests/examples/nodejs/nodejsChecker.js
tests/examples/nodejs/nodejsChecker.js
+1
-0
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+4
-1
tests/script/general/http/restful_full.sim
tests/script/general/http/restful_full.sim
+1
-0
tests/script/general/parser/join.sim
tests/script/general/parser/join.sim
+2
-1
未找到文件。
Jenkinsfile
浏览文件 @
789fc754
...
@@ -41,13 +41,10 @@ def pre_test(){
...
@@ -41,13 +41,10 @@ def pre_test(){
cd ${WKC}
cd ${WKC}
git checkout develop
git checkout develop
git reset --hard HEAD~10
git reset --hard HEAD~10 >/dev/null
git pull
git fetch
git checkout ${CHANGE_BRANCH}
git reset --hard HEAD~10
git pull
git pull
git merge develop
git fetch origin +refs/pull/${CHANGE_ID}/merge
git checkout -qf FETCH_HEAD
cd ${WK}
cd ${WK}
git reset --hard HEAD~10
git reset --hard HEAD~10
git checkout develop
git checkout develop
...
@@ -87,11 +84,14 @@ pipeline {
...
@@ -87,11 +84,14 @@ pipeline {
steps
{
steps
{
pre_test
()
pre_test
()
sh
'''
timeout
(
time:
90
,
unit:
'MINUTES'
){
cd ${WKC}/tests
sh
'''
find pytest -name '*'sql|xargs rm -rf
cd ${WKC}/tests
./test-all.sh p1
find pytest -name '*'sql|xargs rm -rf
date'''
./test-all.sh p1
date'''
}
}
}
}
}
stage
(
'python_2'
)
{
stage
(
'python_2'
)
{
...
@@ -112,12 +112,14 @@ pipeline {
...
@@ -112,12 +112,14 @@ pipeline {
}
}
stage
(
'test_b1'
)
{
stage
(
'test_b1'
)
{
agent
{
label
'b1'
}
agent
{
label
'b1'
}
steps
{
steps
{
pre_test
()
timeout
(
time:
90
,
unit:
'MINUTES'
){
sh
'''
pre_test
()
cd ${WKC}/tests
sh
'''
./test-all.sh b1fq
cd ${WKC}/tests
date'''
./test-all.sh b1fq
date'''
}
}
}
}
}
...
@@ -137,12 +139,14 @@ pipeline {
...
@@ -137,12 +139,14 @@ pipeline {
./handle_crash_gen_val_log.sh
./handle_crash_gen_val_log.sh
'''
'''
}
}
sh
'''
timeout
(
time:
90
,
unit:
'MINUTES'
){
date
sh
'''
cd ${WKC}/tests
date
./test-all.sh b2fq
cd ${WKC}/tests
date
./test-all.sh b2fq
'''
date
'''
}
}
}
}
}
...
@@ -157,12 +161,14 @@ pipeline {
...
@@ -157,12 +161,14 @@ pipeline {
./valgrind-test.sh 2>&1 > mem-error-out.log
./valgrind-test.sh 2>&1 > mem-error-out.log
./handle_val_log.sh
./handle_val_log.sh
'''
'''
}
}
sh
'''
timeout
(
time:
90
,
unit:
'MINUTES'
){
date
sh
'''
cd ${WKC}/tests
date
./test-all.sh b3fq
cd ${WKC}/tests
date'''
./test-all.sh b3fq
date'''
}
}
}
}
}
...
...
documentation20/webdocs/assets/tdengine-jdbc-connector.png
0 → 100644
浏览文件 @
789fc754
41.6 KB
documentation20/webdocs/markdowndocs/TAOS SQL-ch.md
浏览文件 @
789fc754
...
@@ -743,7 +743,7 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
...
@@ -743,7 +743,7 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
应用字段:不能应用在timestamp、binary、nchar、bool类型字段。
应用字段:不能应用在timestamp、binary、nchar、bool类型字段。
适用于:表。
适用于:表。
(从 2.0.15 版本开始,本函数也支持超级表)
示例:
示例:
```mysql
```mysql
...
...
documentation20/webdocs/markdowndocs/administrator-ch.md
浏览文件 @
789fc754
...
@@ -124,10 +124,10 @@ taosd -C
...
@@ -124,10 +124,10 @@ taosd -C
对于一个应用场景,可能有多种数据特征的数据并存,最佳的设计是将具有相同数据特征的表放在一个库里,这样一个应用有多个库,而每个库可以配置不同的存储参数,从而保证系统有最优的性能。TDengine允许应用在创建库时指定上述存储参数,如果指定,该参数就将覆盖对应的系统配置参数。举例,有下述SQL:
对于一个应用场景,可能有多种数据特征的数据并存,最佳的设计是将具有相同数据特征的表放在一个库里,这样一个应用有多个库,而每个库可以配置不同的存储参数,从而保证系统有最优的性能。TDengine允许应用在创建库时指定上述存储参数,如果指定,该参数就将覆盖对应的系统配置参数。举例,有下述SQL:
```
```
create database demo days 10 cache 32 blocks 8 replica 3;
create database demo days 10 cache 32 blocks 8 replica 3
update 1
;
```
```
该SQL创建了一个库demo, 每个数据文件存储10天数据,内存块为32兆字节,每个VNODE占用8个内存块,副本数为3,而其他参数与系统配置完全一致。
该SQL创建了一个库demo, 每个数据文件存储10天数据,内存块为32兆字节,每个VNODE占用8个内存块,副本数为3,
允许更新,
而其他参数与系统配置完全一致。
TDengine集群中加入一个新的dnode时,涉及集群相关的一些参数必须与已有集群的配置相同,否则不能成功加入到集群中。会进行校验的参数如下:
TDengine集群中加入一个新的dnode时,涉及集群相关的一些参数必须与已有集群的配置相同,否则不能成功加入到集群中。会进行校验的参数如下:
...
...
documentation20/webdocs/markdowndocs/connector-ch.md
浏览文件 @
789fc754
...
@@ -288,13 +288,6 @@ C/C++的API类似于MySQL的C API。应用程序使用时,需要包含TDengine
...
@@ -288,13 +288,6 @@ C/C++的API类似于MySQL的C API。应用程序使用时,需要包含TDengine
*
res:
`taos_query_a`
回调时返回的结果集
*
res:
`taos_query_a`
回调时返回的结果集
*
fp:回调函数。其参数
`param`
是用户可定义的传递给回调函数的参数结构体;
`numOfRows`
是获取到的数据的行数(不是整个查询结果集的函数)。 在回调函数中,应用可以通过调用
`taos_fetch_row`
前向迭代获取批量记录中每一行记录。读完一块内的所有记录后,应用需要在回调函数中继续调用
`taos_fetch_rows_a`
获取下一批记录进行处理,直到返回的记录数(numOfRows)为零(结果返回完成)或记录数为负值(查询出错)。
*
fp:回调函数。其参数
`param`
是用户可定义的传递给回调函数的参数结构体;
`numOfRows`
是获取到的数据的行数(不是整个查询结果集的函数)。 在回调函数中,应用可以通过调用
`taos_fetch_row`
前向迭代获取批量记录中每一行记录。读完一块内的所有记录后,应用需要在回调函数中继续调用
`taos_fetch_rows_a`
获取下一批记录进行处理,直到返回的记录数(numOfRows)为零(结果返回完成)或记录数为负值(查询出错)。
-
`void taos_fetch_row_a(TAOS_RES *res, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row), void *param);`
异步获取一条记录。其中:
* res:`taos_query_a`回调时返回的结果集
* fp:回调函数。其参数`param`是应用提供的一个用于回调的参数。回调时,第三个参数`row`指向一行记录。不同于`taos_fetch_rows_a`,应用无需调用`taos_fetch_row`来获取一行数据,更加简单,但数据提取性能不及批量获取的API。
TDengine的异步API均采用非阻塞调用模式。应用程序可以用多线程同时打开多张表,并可以同时对每张打开的表进行查询或者插入操作。需要指出的是,
**客户端应用必须确保对同一张表的操作完全串行化**
,即对同一个表的插入或查询操作未完成时(未返回时),不能够执行第二个插入或查询操作。
TDengine的异步API均采用非阻塞调用模式。应用程序可以用多线程同时打开多张表,并可以同时对每张打开的表进行查询或者插入操作。需要指出的是,
**客户端应用必须确保对同一张表的操作完全串行化**
,即对同一个表的插入或查询操作未完成时(未返回时),不能够执行第二个插入或查询操作。
### 参数绑定API
### 参数绑定API
...
...
documentation20/webdocs/markdowndocs/connector-java-ch.md
浏览文件 @
789fc754
# Java Connector
# Java Connector
Java连接器支持的系统有:
TDengine 提供了遵循 JDBC 标准(3.0)API 规范的
`taos-jdbcdriver`
实现,可在 maven 的中央仓库
[
Sonatype Repository
][
1
]
搜索下载。
|
**CPU类型**
| x64(64bit) | | | ARM64 | ARM32 |
| ------------ | ------------ | -------- | -------- | -------- | -------- |
|
**OS类型**
| Linux | Win64 | Win32 | Linux | Linux |
|
**支持与否**
|
**支持**
|
**支持**
|
**支持**
|
**支持**
|
**支持**
|
Java连接器的使用请参见
<a
href=
https://www.taosdata.com/blog/2020/11/11/1955.html
>
视频教程
</a>
。
`taos-jdbcdriver的`
实现包括 2 种形式: JDBC-JNI 和 JDBC-RESTful(taos-jdbcdriver-2.0.16 开始支持 JDBC-RESTful)。 JDBC-JNI 通过调用客户端 libtaos.so(或 taos.dll )的本地方法实现, JDBC-RESTful 则在内部封装了 RESTful 接口实现
。
TDengine 为了方便 Java 应用使用,提供了遵循 JDBC 标准(3.0)API 规范的
`taos-jdbcdriver`
实现。目前可以通过
[
Sonatype Repository
][
1
]
搜索并下载。
![
tdengine-connector
](
../assets/tdengine-jdbc-connector.png
)
由于 TDengine 是使用 c 语言开发的,使用 taos-jdbcdriver 驱动包时需要依赖系统对应的本地函数库。
上图显示了 3 种 Java 应用使用连接器访问 TDengine 的方式:
*
libtaos.so
*
JDBC-JNI:Java 应用在物理节点1(pnode1)上使用 JDBC-JNI 的 API ,直接调用客户端 API(libtaos.so 或 taos.dll)将写入和查询请求发送到位于物理节点2(pnode2)上的 taosd 实例。
在 linux 系统中成功安装 TDengine 后,依赖的本地函数库 libtaos.so 文件会被自动拷贝至 /usr/lib/libtaos.so,该目录包含在 Linux 自动扫描路径上,无需单独指定。
*
RESTful:应用将 SQL 发送给位于物理节点2(pnode2)上的 RESTful 连接器,再调用客户端 API(libtaos.so)。
*
JDBC-RESTful:Java 应用通过 JDBC-RESTful 的 API ,将 SQL 封装成一个 RESTful 请求,发送给物理节点2的 RESTful 连接器。
*
taos.dll
在 windows 系统中安装完客户端之后,驱动包依赖的 taos.dll 文件会自动拷贝到系统默认搜索路径 C:/Windows/System32 下,同样无需要单独指定。
> 注意:在 windows 环境开发时需要安装 TDengine 对应的 [windows 客户端][14],Linux 服务器安装完 TDengine 之后默认已安装 client,也可以单独安装 [Linux 客户端][15] 连接远程 TDengine Server。
TDengine 的 JDBC 驱动实现尽可能与关系型数据库驱动保持一致,但时序空间数据库与关系对象型数据库服务的对象和技术特征存在差异,导致
`taos-jdbcdriver`
与传统的 JDBC driver 也存在一定差异。在使用时需要注意以下几点:
TDengine 的 JDBC 驱动实现尽可能的与关系型数据库驱动保持一致,但时序空间数据库与关系对象型数据库服务的对象和技术特征的差异导致 taos-jdbcdriver 并未完全实现 JDBC 标准规范。在使用时需要注意以下几点:
*
TDengine 目前不支持针对单条数据记录的删除操作。
*
目前不支持事务操作。
*
TDengine 不提供针对单条数据记录的删除和修改的操作,驱动中也没有支持相关方法。
*
由于不支持删除和修改,所以也不支持事务操作。
*
目前不支持表间的 union 操作。
*
目前不支持表间的 union 操作。
*
目前不支持嵌套查询(nested query),对每个 Connection 的实例,至多只能有一个打开的 ResultSet 实例;如果在 ResultSet还没关闭的情况下执行了新的查询,TSDBJDBCDriver 则会自动关闭上一个 ResultSet。
*
目前不支持嵌套查询(nested query)。
*
对每个 Connection 的实例,至多只能有一个打开的 ResultSet 实例;如果在 ResultSet 还没关闭的情况下执行了新的查询,taos-jdbcdriver 会自动关闭上一个 ResultSet。
## TAOS-JDBCDriver 版本以及支持的 TDengine 版本和 JDK 版本
| taos-jdbcdriver 版本 | TDengine 版本 | JDK 版本 |
## JDBC-JNI和JDBC-RESTful的对比
| --- | --- | --- |
| 2.0.12 及以上 | 2.0.8.0 及以上 | 1.8.x |
<table
>
| 2.0.4 - 2.0.11 | 2.0.0.0 - 2.0.7.x | 1.8.x |
<tr
align=
"center"
><th>
对比项
</th><th>
JDBC-JNI
</th><th>
JDBC-RESTful
</th></tr>
| 1.0.3 | 1.6.1.x 及以上 | 1.8.x |
<tr
align=
"center"
>
| 1.0.2 | 1.6.1.x 及以上 | 1.8.x |
<td>
支持的操作系统
</td>
| 1.0.1 | 1.6.1.x 及以上 | 1.8.x |
<td>
linux、windows
</td>
<td>
全平台
</td>
## TDengine DataType 和 Java DataType
</tr>
<tr
align=
"center"
>
TDengine 目前支持时间戳、数字、字符、布尔类型,与 Java 对应类型转换如下:
<td>
是否需要安装 client
</td>
<td>
需要
</td>
| TDengine DataType | Java DataType |
<td>
不需要
</td>
| --- | --- |
</tr>
| TIMESTAMP | java.sql.Timestamp |
<tr
align=
"center"
>
| INT | java.lang.Integer |
<td>
server 升级后是否需要升级 client
</td>
| BIGINT | java.lang.Long |
<td>
需要
</td>
| FLOAT | java.lang.Float |
<td>
不需要
</td>
| DOUBLE | java.lang.Double |
</tr>
| SMALLINT, TINYINT |java.lang.Short |
<tr
align=
"center"
>
| BOOL | java.lang.Boolean |
<td>
写入性能
</td>
| BINARY, NCHAR | java.lang.String |
<td
colspan=
"2"
>
JDBC-RESTful 是 JDBC-JNI 的 50%~90%
</td>
</tr>
## 如何获取 TAOS-JDBCDriver
<tr
align=
"center"
>
<td>
查询性能
</td>
<td
colspan=
"2"
>
JDBC-RESTful 与 JDBC-JNI 没有差别
</td>
</tr>
</table>
## 如何获取 taos-jdbcdriver
### maven 仓库
### maven 仓库
目前 taos-jdbcdriver 已经发布到
[
Sonatype Repository
][
1
]
仓库,且各大仓库都已同步。
目前 taos-jdbcdriver 已经发布到
[
Sonatype Repository
][
1
]
仓库,且各大仓库都已同步。
*
[
sonatype
][
8
]
*
[
sonatype
][
8
]
*
[
mvnrepository
][
9
]
*
[
mvnrepository
][
9
]
*
[
maven.aliyun
][
10
]
*
[
maven.aliyun
][
10
]
...
@@ -67,30 +67,63 @@ maven 项目中使用如下 pom.xml 配置即可:
...
@@ -67,30 +67,63 @@ maven 项目中使用如下 pom.xml 配置即可:
<dependency>
<dependency>
<groupId>
com.taosdata.jdbc
</groupId>
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.
4
</version>
<version>
2.0.
16
</version>
</dependency>
</dependency>
```
```
### 源码编译打包
### 源码编译打包
下载
[
TDengine
][
3
]
源码之后,进入 taos-jdbcdriver 源码目录
`src/connector/jdbc`
执行
`mvn clean package`
即可生成相应 jar 包。
下载
[
TDengine
][
3
]
源码之后,进入 taos-jdbcdriver 源码目录
`src/connector/jdbc`
执行
`mvn clean package -Dmaven.test.skip=true`
即可生成相应 jar 包。
## 使用说明
## JDBC的使用说明
### 获取连接
### 获取连接
#### 通过JdbcUrl获取连接
#### 指定URL获取连接
通过指定URL获取连接,如下所示:
```
java
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
String
jdbcUrl
=
"jdbc:TAOS-RS://taosdemo.com:6041/test?user=root&password=taosdata"
;
Connection
conn
=
DriverManager
.
getConnection
(
jdbcUrl
);
```
以上示例,使用
**JDBC-RESTful**
的 driver,建立了到 hostname 为 taosdemo.com,端口为 6041,数据库名为 test 的连接。这个 URL 中指定用户名(user)为 root,密码(password)为 taosdata。
使用 JDBC-RESTful 接口,不需要依赖本地函数库。与 JDBC-JNI 相比,仅需要:
1.
driverClass 指定为“com.taosdata.jdbc.rs.RestfulDriver”;
2.
jdbcUrl 以“jdbc:TAOS-RS://”开头;
3.
使用 6041 作为连接端口。
如果希望获得更好的写入和查询性能,Java 应用可以使用
**JDBC-JNI**
的driver,如下所示:
通过指定的jdbcUrl获取连接,如下所示:
```
java
```
java
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
String
jdbcUrl
=
"jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata"
;
String
jdbcUrl
=
"jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata"
;
Connection
conn
=
DriverManager
.
getConnection
(
jdbcUrl
);
Connection
conn
=
DriverManager
.
getConnection
(
jdbcUrl
);
```
```
以上示例,建立了到hostname为taosdemo.com,端口为6030(TDengine的默认端口),数据库名为test的连接。这个url中指定用户名(user)为root,密码(password)为taosdata。
以上示例,使用了 JDBC-JNI 的 driver,建立了到 hostname 为 taosdemo.com,端口为 6030(TDengine 的默认端口),数据库名为 test 的连接。这个 URL 中指定用户名(user)为 root,密码(password)为 taosdata。
**注意**
:使用 JDBC-JNI 的 driver,taos-jdbcdriver 驱动包时需要依赖系统对应的本地函数库。
*
libtaos.so
在 linux 系统中成功安装 TDengine 后,依赖的本地函数库 libtaos.so 文件会被自动拷贝至 /usr/lib/libtaos.so,该目录包含在 Linux 自动扫描路径上,无需单独指定。
*
taos.dll
在 windows 系统中安装完客户端之后,驱动包依赖的 taos.dll 文件会自动拷贝到系统默认搜索路径 C:/Windows/System32 下,同样无需要单独指定。
> 在 windows 环境开发时需要安装 TDengine 对应的 [windows 客户端][14],Linux 服务器安装完 TDengine 之后默认已安装 client,也可以单独安装 [Linux 客户端][15] 连接远程 TDengine Server。
JDBC-JNI 的使用请参见
<a
href=
https://www.taosdata.com/blog/2020/11/11/1955.html
>
视频教程
</a>
。
TDengine 的 JDBC URL 规范格式为:
TDengine 的 JDBC URL 规范格式为:
`jdbc:TAOS://[host_name]:[port]/[database_name]?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]`
`jdbc:[TAOS|TAOS-RS]://[host_name]:[port]/[database_name]?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]`
url中的配置参数如下:
url中的配置参数如下:
*
user:登录 TDengine 用户名,默认值 root。
*
user:登录 TDengine 用户名,默认值 root。
*
password:用户登录密码,默认值 taosdata。
*
password:用户登录密码,默认值 taosdata。
...
@@ -99,13 +132,17 @@ url中的配置参数如下:
...
@@ -99,13 +132,17 @@ url中的配置参数如下:
*
locale:客户端语言环境,默认值系统当前 locale。
*
locale:客户端语言环境,默认值系统当前 locale。
*
timezone:客户端使用的时区,默认值为系统当前时区。
*
timezone:客户端使用的时区,默认值为系统当前时区。
#### 使用JdbcUrl和Properties获取连接
除了通过指定的jdbcUrl获取连接,还可以使用Properties指定建立连接时的参数,如下所示:
#### 指定URL和Properties获取连接
除了通过指定的 URL 获取连接,还可以使用 Properties 指定建立连接时的参数,如下所示:
```
java
```
java
public
Connection
getConn
()
throws
Exception
{
public
Connection
getConn
()
throws
Exception
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
// Class.forName("com.taosdata.jdbc.rs.RestfulDriver");
String
jdbcUrl
=
"jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata"
;
String
jdbcUrl
=
"jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata"
;
// String jdbcUrl = "jdbc:TAOS-RS://taosdemo.com:6041/test?user=root&password=taosdata";
Properties
connProps
=
new
Properties
();
Properties
connProps
=
new
Properties
();
connProps
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
connProps
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
connProps
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
connProps
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
...
@@ -114,9 +151,10 @@ public Connection getConn() throws Exception{
...
@@ -114,9 +151,10 @@ public Connection getConn() throws Exception{
return
conn
;
return
conn
;
}
}
```
```
以上示例,建立一个到hostname为taosdemo.com,端口为6030,数据库名为test的连接。这个连接在url中指定了用户名(user)为root,密码(password)为taosdata,并在connProps中指定了使用的字符集、语言环境、时区等信息。
properties中的配置参数如下:
以上示例,建立一个到 hostname 为 taosdemo.com,端口为 6030,数据库名为 test 的连接。注释为使用 JDBC-RESTful 时的方法。这个连接在 url 中指定了用户名(user)为 root,密码(password)为 taosdata,并在 connProps 中指定了使用的字符集、语言环境、时区等信息。
properties 中的配置参数如下:
*
TSDBDriver.PROPERTY_KEY_USER:登录 TDengine 用户名,默认值 root。
*
TSDBDriver.PROPERTY_KEY_USER:登录 TDengine 用户名,默认值 root。
*
TSDBDriver.PROPERTY_KEY_PASSWORD:用户登录密码,默认值 taosdata。
*
TSDBDriver.PROPERTY_KEY_PASSWORD:用户登录密码,默认值 taosdata。
*
TSDBDriver.PROPERTY_KEY_CONFIG_DIR:客户端配置文件目录路径,Linux OS 上默认值 /etc/taos ,Windows OS 上默认值 C:/TDengine/cfg。
*
TSDBDriver.PROPERTY_KEY_CONFIG_DIR:客户端配置文件目录路径,Linux OS 上默认值 /etc/taos ,Windows OS 上默认值 C:/TDengine/cfg。
...
@@ -124,10 +162,14 @@ properties中的配置参数如下:
...
@@ -124,10 +162,14 @@ properties中的配置参数如下:
*
TSDBDriver.PROPERTY_KEY_LOCALE:客户端语言环境,默认值系统当前 locale。
*
TSDBDriver.PROPERTY_KEY_LOCALE:客户端语言环境,默认值系统当前 locale。
*
TSDBDriver.PROPERTY_KEY_TIME_ZONE:客户端使用的时区,默认值为系统当前时区。
*
TSDBDriver.PROPERTY_KEY_TIME_ZONE:客户端使用的时区,默认值为系统当前时区。
#### 使用客户端配置文件建立连接
#### 使用客户端配置文件建立连接
当使用JDBC连接TDengine集群时,可以使用客户端配置文件,在客户端配置文件中指定集群的firstEp、secondEp参数。
当使用 JDBC-JNI 连接 TDengine 集群时,可以使用客户端配置文件,在客户端配置文件中指定集群的 firstEp、secondEp参数。
如下所示:
如下所示:
1.
在java中不指定hostname和port
1.
在 Java 应用中不指定 hostname 和 port
```
java
```
java
public
Connection
getConn
()
throws
Exception
{
public
Connection
getConn
()
throws
Exception
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
...
@@ -140,7 +182,7 @@ public Connection getConn() throws Exception{
...
@@ -140,7 +182,7 @@ public Connection getConn() throws Exception{
return
conn
;
return
conn
;
}
}
```
```
2.
在配置文件中指定
firstEp和
secondEp
2.
在配置文件中指定
firstEp 和
secondEp
```
```
# first fully qualified domain name (FQDN) for TDengine system
# first fully qualified domain name (FQDN) for TDengine system
firstEp cluster_node1:6030
firstEp cluster_node1:6030
...
@@ -155,17 +197,19 @@ secondEp cluster_node2:6030
...
@@ -155,17 +197,19 @@ secondEp cluster_node2:6030
# locale en_US.UTF-8
# locale en_US.UTF-8
```
```
以上示例,jdbc
会使用客户端的配置文件,建立到hostname为cluster_node1,端口为6030,数据库名为test的连接。当集群中firstEp节点失效时,JDBC会尝试使用secondEp
连接集群。
以上示例,jdbc
会使用客户端的配置文件,建立到 hostname 为 cluster_node1、端口为 6030、数据库名为 test 的连接。当集群中 firstEp 节点失效时,JDBC 会尝试使用 secondEp
连接集群。
TDengine
中,只要保证firstEp和secondEp
中一个节点有效,就可以正常建立到集群的连接。
TDengine
中,只要保证 firstEp 和 secondEp
中一个节点有效,就可以正常建立到集群的连接。
> 注意:这里的配置文件指的是调用
JDBC Connector
的应用程序所在机器上的配置文件,Linux OS 上默认值 /etc/taos/taos.cfg ,Windows OS 上默认值 C://TDengine/cfg/taos.cfg。
> 注意:这里的配置文件指的是调用
JDBC Connector
的应用程序所在机器上的配置文件,Linux OS 上默认值 /etc/taos/taos.cfg ,Windows OS 上默认值 C://TDengine/cfg/taos.cfg。
#### 配置参数的优先级
#### 配置参数的优先级
通过以上3种方式获取连接,如果配置参数在url、Properties、客户端配置文件中有重复,则参数的
`优先级由高到低`
分别如下:
通过以上 3 种方式获取连接,如果配置参数在 url、Properties、客户端配置文件中有重复,则参数的
`优先级由高到低`
分别如下:
1.
JDBC URL 参数,如上所述,可以在 JDBC URL 的参数中指定。
1.
JDBC URL 参数,如上所述,可以在 JDBC URL 的参数中指定。
2.
Properties connProps
2.
Properties connProps
3.
客户端配置文件 taos.cfg
3.
客户端配置文件 taos.cfg
例如:在url中指定了password为taosdata,在Properties中指定了password为taosdemo,那么,JDBC会使用url中的password建立连接。
例如:在 url 中指定了 password 为 taosdata,在 Properties 中指定了 password 为 taosdemo,那么,JDBC 会使用 url 中的 password 建立连接。
> 更多详细配置请参考[客户端配置][13]
> 更多详细配置请参考[客户端配置][13]
...
@@ -183,6 +227,7 @@ stmt.executeUpdate("use db");
...
@@ -183,6 +227,7 @@ stmt.executeUpdate("use db");
// create table
// create table
stmt
.
executeUpdate
(
"create table if not exists tb (ts timestamp, temperature int, humidity float)"
);
stmt
.
executeUpdate
(
"create table if not exists tb (ts timestamp, temperature int, humidity float)"
);
```
```
> 注意:如果不使用 `use db` 指定数据库,则后续对表的操作都需要增加数据库名称作为前缀,如 db.tb。
> 注意:如果不使用 `use db` 指定数据库,则后续对表的操作都需要增加数据库名称作为前缀,如 db.tb。
### 插入数据
### 插入数据
...
@@ -193,6 +238,7 @@ int affectedRows = stmt.executeUpdate("insert into tb values(now, 23, 10.3) (now
...
@@ -193,6 +238,7 @@ int affectedRows = stmt.executeUpdate("insert into tb values(now, 23, 10.3) (now
System
.
out
.
println
(
"insert "
+
affectedRows
+
" rows."
);
System
.
out
.
println
(
"insert "
+
affectedRows
+
" rows."
);
```
```
> now 为系统内部函数,默认为服务器当前时间。
> now 为系统内部函数,默认为服务器当前时间。
> `now + 1s` 代表服务器当前时间往后加 1 秒,数字后面代表时间单位:a(毫秒), s(秒), m(分), h(小时), d(天),w(周), n(月), y(年)。
> `now + 1s` 代表服务器当前时间往后加 1 秒,数字后面代表时间单位:a(毫秒), s(秒), m(分), h(小时), d(天),w(周), n(月), y(年)。
...
@@ -214,6 +260,7 @@ while(resultSet.next()){
...
@@ -214,6 +260,7 @@ while(resultSet.next()){
System
.
out
.
printf
(
"%s, %d, %s\n"
,
ts
,
temperature
,
humidity
);
System
.
out
.
printf
(
"%s, %d, %s\n"
,
ts
,
temperature
,
humidity
);
}
}
```
```
> 查询和操作关系型数据库一致,使用下标获取返回字段内容时从 1 开始,建议使用字段名称获取。
> 查询和操作关系型数据库一致,使用下标获取返回字段内容时从 1 开始,建议使用字段名称获取。
### 订阅
### 订阅
...
@@ -248,7 +295,7 @@ while(true) {
...
@@ -248,7 +295,7 @@ while(true) {
}
}
```
```
`consume`
方法返回一个结果集,其中包含从上次
`consume`
到目前为止的所有新数据。请务必按需选择合理的调用
`consume`
的频率(如例子中的
`Thread.sleep(1000)`
),否则会给服务端造成不必要的压力。
`consume`
方法返回一个结果集,其中包含从上次
`consume`
到目前为止的所有新数据。请务必按需选择合理的调用
`consume`
的频率(如例子中的
`Thread.sleep(1000)`
),否则会给服务端造成不必要的压力。
#### 关闭订阅
#### 关闭订阅
...
@@ -265,8 +312,11 @@ resultSet.close();
...
@@ -265,8 +312,11 @@ resultSet.close();
stmt
.
close
();
stmt
.
close
();
conn
.
close
();
conn
.
close
();
```
```
> `注意务必要将 connection 进行关闭`,否则会出现连接泄露。
> `注意务必要将 connection 进行关闭`,否则会出现连接泄露。
## 与连接池使用
## 与连接池使用
**HikariCP**
**HikariCP**
...
@@ -306,6 +356,7 @@ conn.close();
...
@@ -306,6 +356,7 @@ conn.close();
connection
.
close
();
// put back to conneciton pool
connection
.
close
();
// put back to conneciton pool
}
}
```
```
> 通过 HikariDataSource.getConnection() 获取连接后,使用完成后需要调用 close() 方法,实际上它并不会关闭连接,只是放回连接池中。
> 通过 HikariDataSource.getConnection() 获取连接后,使用完成后需要调用 close() 方法,实际上它并不会关闭连接,只是放回连接池中。
> 更多 HikariCP 使用问题请查看[官方说明][5]
> 更多 HikariCP 使用问题请查看[官方说明][5]
...
@@ -356,6 +407,7 @@ public static void main(String[] args) throws Exception {
...
@@ -356,6 +407,7 @@ public static void main(String[] args) throws Exception {
connection
.
close
();
// put back to conneciton pool
connection
.
close
();
// put back to conneciton pool
}
}
```
```
> 更多 druid 使用问题请查看[官方说明][6]
> 更多 druid 使用问题请查看[官方说明][6]
**注意事项**
**注意事项**
...
@@ -370,10 +422,43 @@ server_status()|
...
@@ -370,10 +422,43 @@ server_status()|
Query OK, 1 row
(
s
)
in
set
(
0.000141s
)
Query OK, 1 row
(
s
)
in
set
(
0.000141s
)
```
```
## 与框架使用
## 与框架使用
*
Spring JdbcTemplate 中使用 taos-jdbcdriver,可参考
[
SpringJdbcTemplate
][
11
]
*
Spring JdbcTemplate 中使用 taos-jdbcdriver,可参考
[
SpringJdbcTemplate
][
11
]
*
Springboot + Mybatis 中使用,可参考
[
springbootdemo
][
12
]
*
Springboot + Mybatis 中使用,可参考
[
springbootdemo
## TAOS-JDBCDriver 版本以及支持的 TDengine 版本和 JDK 版本
| taos-jdbcdriver 版本 | TDengine 版本 | JDK 版本 |
| -------------------- | ----------------- | -------- |
| 2.0.12 及以上 | 2.0.8.0 及以上 | 1.8.x |
| 2.0.4 - 2.0.11 | 2.0.0.0 - 2.0.7.x | 1.8.x |
| 1.0.3 | 1.6.1.x 及以上 | 1.8.x |
| 1.0.2 | 1.6.1.x 及以上 | 1.8.x |
| 1.0.1 | 1.6.1.x 及以上 | 1.8.x |
## TDengine DataType 和 Java DataType
TDengine 目前支持时间戳、数字、字符、布尔类型,与 Java 对应类型转换如下:
| TDengine DataType | Java DataType |
| ----------------- | ------------------ |
| TIMESTAMP | java.sql.Timestamp |
| INT | java.lang.Integer |
| BIGINT | java.lang.Long |
| FLOAT | java.lang.Float |
| DOUBLE | java.lang.Double |
| SMALLINT, TINYINT | java.lang.Short |
| BOOL | java.lang.Boolean |
| BINARY, NCHAR | java.lang.String |
## 常见问题
## 常见问题
...
@@ -381,7 +466,7 @@ Query OK, 1 row(s) in set (0.000141s)
...
@@ -381,7 +466,7 @@ Query OK, 1 row(s) in set (0.000141s)
**原因**:程序没有找到依赖的本地函数库 taos。
**原因**:程序没有找到依赖的本地函数库 taos。
**解决方法**
:windows 下可以将 C:
\T
Dengine
\d
river
\t
aos.dll 拷贝到 C:
\W
indows
\S
ystem32
\
目录下,linux 下将建立如下软链
`
ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so`
即可。
**解决方法**:windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可。
* java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform
* java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform
...
@@ -406,3 +491,4 @@ Query OK, 1 row(s) in set (0.000141s)
...
@@ -406,3 +491,4 @@ Query OK, 1 row(s) in set (0.000141s)
[
13
]:
https://www.taosdata.com/cn/documentation20/administrator/#%E5%AE%A2%E6%88%B7%E7%AB%AF%E9%85%8D%E7%BD%AE
[
13
]:
https://www.taosdata.com/cn/documentation20/administrator/#%E5%AE%A2%E6%88%B7%E7%AB%AF%E9%85%8D%E7%BD%AE
[
14
]:
https://www.taosdata.com/cn/all-downloads/#TDengine-Windows-Client
[
14
]:
https://www.taosdata.com/cn/all-downloads/#TDengine-Windows-Client
[
15
]:
https://www.taosdata.com/cn/getting-started/#%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B
[
15
]:
https://www.taosdata.com/cn/getting-started/#%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B
documentation20/webdocs/markdowndocs/faq-ch.md
浏览文件 @
789fc754
...
@@ -85,7 +85,9 @@ TDengine还没有一组专用的validation queries。然而建议你使用系统
...
@@ -85,7 +85,9 @@ TDengine还没有一组专用的validation queries。然而建议你使用系统
## 9. 我可以删除或更新一条记录吗?
## 9. 我可以删除或更新一条记录吗?
不能。因为TDengine是为联网设备采集的数据设计的,不容许修改。但TDengine提供数据保留策略,只要数据记录超过保留时长,就会被自动删除。
TDengine 目前尚不支持删除功能,未来根据用户需求可能会支持。
从 2.0.8.0 开始,TDengine 支持更新已经写入数据的功能。使用更新功能需要在创建数据库时使用 UPDATE 1 参数,之后可以使用 INSERT INTO 命令更新已经写入的相同时间戳数据。UPDATE 参数不支持 ALTER DATABASE 命令修改。没有使用 UPDATE 1 参数创建的数据库,写入相同时间戳的数据不会修改之前的数据,也不会报错。
## 10. 我怎么创建超过1024列的表?
## 10. 我怎么创建超过1024列的表?
...
@@ -132,8 +134,3 @@ TDengine是根据hostname唯一标志一台机器的,在数据文件从机器A
...
@@ -132,8 +134,3 @@ TDengine是根据hostname唯一标志一台机器的,在数据文件从机器A
-
2.0.7.0 及以后的版本,到/var/lib/taos/dnode下,修复dnodeEps.json的dnodeId对应的FQDN,重启。确保机器内所有机器的此文件是完全相同的。
-
2.0.7.0 及以后的版本,到/var/lib/taos/dnode下,修复dnodeEps.json的dnodeId对应的FQDN,重启。确保机器内所有机器的此文件是完全相同的。
-
1.x 和 2.x 版本的存储结构不兼容,需要使用迁移工具或者自己开发应用导出导入数据。
-
1.x 和 2.x 版本的存储结构不兼容,需要使用迁移工具或者自己开发应用导出导入数据。
## 17. TDengine 是否支持删除或更新已经写入的数据?
TDengine 目前尚不支持删除功能,未来根据用户需求可能会支持。
从 2.0.8.0 开始,TDengine 支持更新已经写入数据的功能。使用更新功能需要在创建数据库时使用 UPDATE 1 参数,之后可以使用 INSERT INTO 命令更新已经写入的相同时间戳数据。UPDATE 参数不支持 ALTER DATABASE 命令修改。没有使用 UPDATE 1 参数创建的数据库,写入相同时间戳的数据不会修改之前的数据,也不会报错。
\ No newline at end of file
packaging/cfg/taos.cfg
浏览文件 @
789fc754
...
@@ -265,9 +265,6 @@
...
@@ -265,9 +265,6 @@
# maximum display width of binary and nchar fields in the shell. The parts exceeding this limit will be hidden
# maximum display width of binary and nchar fields in the shell. The parts exceeding this limit will be hidden
# maxBinaryDisplayWidth 30
# maxBinaryDisplayWidth 30
# enable/disable telemetry reporting
# telemetryReporting 1
# enable/disable stream (continuous query)
# enable/disable stream (continuous query)
# stream 1
# stream 1
...
...
src/client/inc/tscSubquery.h
浏览文件 @
789fc754
...
@@ -47,7 +47,6 @@ void tscLockByThread(int64_t *lockedBy);
...
@@ -47,7 +47,6 @@ void tscLockByThread(int64_t *lockedBy);
void
tscUnlockByThread
(
int64_t
*
lockedBy
);
void
tscUnlockByThread
(
int64_t
*
lockedBy
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/client/inc/tsclient.h
浏览文件 @
789fc754
...
@@ -317,7 +317,8 @@ typedef struct STscObj {
...
@@ -317,7 +317,8 @@ typedef struct STscObj {
}
STscObj
;
}
STscObj
;
typedef
struct
SSubqueryState
{
typedef
struct
SSubqueryState
{
int32_t
numOfRemain
;
// the number of remain unfinished subquery
pthread_mutex_t
mutex
;
int8_t
*
states
;
int32_t
numOfSub
;
// the number of total sub-queries
int32_t
numOfSub
;
// the number of total sub-queries
uint64_t
numOfRetrievedRows
;
// total number of points in this query
uint64_t
numOfRetrievedRows
;
// total number of points in this query
}
SSubqueryState
;
}
SSubqueryState
;
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
789fc754
...
@@ -1427,6 +1427,10 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
...
@@ -1427,6 +1427,10 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
tscResetForNextRetrieve
(
pRes
);
tscResetForNextRetrieve
(
pRes
);
if
(
pSql
->
signature
!=
pSql
||
pRes
==
NULL
||
pRes
->
pLocalReducer
==
NULL
)
{
// all data has been processed
if
(
pSql
->
signature
!=
pSql
||
pRes
==
NULL
||
pRes
->
pLocalReducer
==
NULL
)
{
// all data has been processed
if
(
pRes
->
code
==
TSDB_CODE_SUCCESS
)
{
return
pRes
->
code
;
}
tscError
(
"%p local merge abort due to error occurs, code:%s"
,
pSql
,
tstrerror
(
pRes
->
code
));
tscError
(
"%p local merge abort due to error occurs, code:%s"
,
pSql
,
tstrerror
(
pRes
->
code
));
return
pRes
->
code
;
return
pRes
->
code
;
}
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
789fc754
...
@@ -264,6 +264,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -264,6 +264,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case
TSDB_SQL_DROP_DB
:
{
case
TSDB_SQL_DROP_DB
:
{
const
char
*
msg2
=
"invalid name"
;
const
char
*
msg2
=
"invalid name"
;
const
char
*
msg3
=
"param name too long"
;
const
char
*
msg3
=
"param name too long"
;
const
char
*
msg4
=
"table is not super table"
;
SStrToken
*
pzName
=
&
pInfo
->
pDCLInfo
->
a
[
0
];
SStrToken
*
pzName
=
&
pInfo
->
pDCLInfo
->
a
[
0
];
if
((
pInfo
->
type
!=
TSDB_SQL_DROP_DNODE
)
&&
(
tscValidateName
(
pzName
)
!=
TSDB_CODE_SUCCESS
))
{
if
((
pInfo
->
type
!=
TSDB_SQL_DROP_DNODE
)
&&
(
tscValidateName
(
pzName
)
!=
TSDB_CODE_SUCCESS
))
{
...
@@ -285,6 +286,18 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -285,6 +286,18 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
if
(
pInfo
->
pDCLInfo
->
tableType
==
TSDB_SUPER_TABLE
)
{
code
=
tscGetTableMeta
(
pSql
,
pTableMetaInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
if
(
!
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
}
}
}
else
if
(
pInfo
->
type
==
TSDB_SQL_DROP_DNODE
)
{
}
else
if
(
pInfo
->
type
==
TSDB_SQL_DROP_DNODE
)
{
pzName
->
n
=
strdequote
(
pzName
->
z
);
pzName
->
n
=
strdequote
(
pzName
->
z
);
strncpy
(
pTableMetaInfo
->
name
,
pzName
->
z
,
pzName
->
n
);
strncpy
(
pTableMetaInfo
->
name
,
pzName
->
z
,
pzName
->
n
);
...
@@ -4794,6 +4807,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -4794,6 +4807,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const
char
*
msg17
=
"invalid column name"
;
const
char
*
msg17
=
"invalid column name"
;
const
char
*
msg18
=
"primary timestamp column cannot be dropped"
;
const
char
*
msg18
=
"primary timestamp column cannot be dropped"
;
const
char
*
msg19
=
"invalid new tag name"
;
const
char
*
msg19
=
"invalid new tag name"
;
const
char
*
msg20
=
"table is not super table"
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
@@ -4819,6 +4833,10 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -4819,6 +4833,10 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
if
(
pAlterSQL
->
tableType
==
TSDB_SUPER_TABLE
&&
!
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
)))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg20
);
}
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
||
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_DROP_TAG_COLUMN
||
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
||
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_DROP_TAG_COLUMN
||
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN
)
{
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN
)
{
if
(
UTIL_TABLE_IS_NORMAL_TABLE
(
pTableMetaInfo
))
{
if
(
UTIL_TABLE_IS_NORMAL_TABLE
(
pTableMetaInfo
))
{
...
...
src/client/src/tscServer.c
浏览文件 @
789fc754
...
@@ -2193,7 +2193,7 @@ int tscProcessDropTableRsp(SSqlObj *pSql) {
...
@@ -2193,7 +2193,7 @@ int tscProcessDropTableRsp(SSqlObj *pSql) {
tscDebug
(
"%p remove table meta after drop table:%s, numOfRemain:%d"
,
pSql
,
pTableMetaInfo
->
name
,
tscDebug
(
"%p remove table meta after drop table:%s, numOfRemain:%d"
,
pSql
,
pTableMetaInfo
->
name
,
(
int32_t
)
taosHashGetSize
(
tscTableMetaInfo
));
(
int32_t
)
taosHashGetSize
(
tscTableMetaInfo
));
assert
(
pTableMetaInfo
->
pTableMeta
==
NULL
)
;
pTableMetaInfo
->
pTableMeta
=
NULL
;
return
0
;
return
0
;
}
}
...
...
src/client/src/tscSubquery.c
浏览文件 @
789fc754
...
@@ -55,6 +55,58 @@ static void skipRemainValue(STSBuf* pTSBuf, tVariant* tag1) {
...
@@ -55,6 +55,58 @@ static void skipRemainValue(STSBuf* pTSBuf, tVariant* tag1) {
}
}
}
}
static
void
subquerySetState
(
SSqlObj
*
pSql
,
SSubqueryState
*
subState
,
int
idx
,
int8_t
state
)
{
assert
(
idx
<
subState
->
numOfSub
);
assert
(
subState
->
states
);
pthread_mutex_lock
(
&
subState
->
mutex
);
tscDebug
(
"subquery:%p,%d state set to %d"
,
pSql
,
idx
,
state
);
subState
->
states
[
idx
]
=
state
;
pthread_mutex_unlock
(
&
subState
->
mutex
);
}
static
bool
allSubqueryDone
(
SSqlObj
*
pParentSql
)
{
bool
done
=
true
;
SSubqueryState
*
subState
=
&
pParentSql
->
subState
;
//lock in caller
for
(
int
i
=
0
;
i
<
subState
->
numOfSub
;
i
++
)
{
if
(
0
==
subState
->
states
[
i
])
{
tscDebug
(
"%p subquery:%p,%d is NOT finished, total:%d"
,
pParentSql
,
pParentSql
->
pSubs
[
i
],
i
,
subState
->
numOfSub
);
done
=
false
;
break
;
}
else
{
tscDebug
(
"%p subquery:%p,%d is finished, total:%d"
,
pParentSql
,
pParentSql
->
pSubs
[
i
],
i
,
subState
->
numOfSub
);
}
}
return
done
;
}
static
bool
subAndCheckDone
(
SSqlObj
*
pSql
,
SSqlObj
*
pParentSql
,
int
idx
)
{
SSubqueryState
*
subState
=
&
pParentSql
->
subState
;
assert
(
idx
<
subState
->
numOfSub
);
pthread_mutex_lock
(
&
subState
->
mutex
);
tscDebug
(
"%p subquery:%p,%d state set to 1"
,
pParentSql
,
pSql
,
idx
);
subState
->
states
[
idx
]
=
1
;
bool
done
=
allSubqueryDone
(
pParentSql
);
pthread_mutex_unlock
(
&
subState
->
mutex
);
return
done
;
}
static
int64_t
doTSBlockIntersect
(
SSqlObj
*
pSql
,
SJoinSupporter
*
pSupporter1
,
SJoinSupporter
*
pSupporter2
,
STimeWindow
*
win
)
{
static
int64_t
doTSBlockIntersect
(
SSqlObj
*
pSql
,
SJoinSupporter
*
pSupporter1
,
SJoinSupporter
*
pSupporter2
,
STimeWindow
*
win
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
);
...
@@ -367,10 +419,6 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
...
@@ -367,10 +419,6 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
// scan all subquery, if one sub query has only ts, ignore it
// scan all subquery, if one sub query has only ts, ignore it
tscDebug
(
"%p start to launch secondary subqueries, %d out of %d needs to query"
,
pSql
,
numOfSub
,
pSql
->
subState
.
numOfSub
);
tscDebug
(
"%p start to launch secondary subqueries, %d out of %d needs to query"
,
pSql
,
numOfSub
,
pSql
->
subState
.
numOfSub
);
//the subqueries that do not actually launch the secondary query to virtual node is set as completed.
SSubqueryState
*
pState
=
&
pSql
->
subState
;
pState
->
numOfRemain
=
numOfSub
;
bool
success
=
true
;
bool
success
=
true
;
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
...
@@ -403,6 +451,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
...
@@ -403,6 +451,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
success
=
false
;
success
=
false
;
break
;
break
;
}
}
tscClearSubqueryInfo
(
&
pNew
->
cmd
);
tscClearSubqueryInfo
(
&
pNew
->
cmd
);
pSql
->
pSubs
[
i
]
=
pNew
;
pSql
->
pSubs
[
i
]
=
pNew
;
...
@@ -480,6 +529,8 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
...
@@ -480,6 +529,8 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
}
}
}
}
subquerySetState
(
pPrevSub
,
&
pSql
->
subState
,
i
,
0
);
size_t
numOfCols
=
taosArrayGetSize
(
pQueryInfo
->
colList
);
size_t
numOfCols
=
taosArrayGetSize
(
pQueryInfo
->
colList
);
tscDebug
(
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%"
PRIzu
", colList:%"
PRIzu
", fieldsInfo:%d, name:%s"
,
tscDebug
(
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%"
PRIzu
", colList:%"
PRIzu
", fieldsInfo:%d, name:%s"
,
pSql
,
pNew
,
0
,
pTableMetaInfo
->
vgroupIndex
,
pQueryInfo
->
type
,
taosArrayGetSize
(
pQueryInfo
->
exprList
),
pSql
,
pNew
,
0
,
pTableMetaInfo
->
vgroupIndex
,
pQueryInfo
->
type
,
taosArrayGetSize
(
pQueryInfo
->
exprList
),
...
@@ -517,20 +568,25 @@ void freeJoinSubqueryObj(SSqlObj* pSql) {
...
@@ -517,20 +568,25 @@ void freeJoinSubqueryObj(SSqlObj* pSql) {
SJoinSupporter
*
p
=
pSub
->
param
;
SJoinSupporter
*
p
=
pSub
->
param
;
tscDestroyJoinSupporter
(
p
);
tscDestroyJoinSupporter
(
p
);
if
(
pSub
->
res
.
code
==
TSDB_CODE_SUCCESS
)
{
taos_free_result
(
pSub
);
taos_free_result
(
pSub
);
pSql
->
pSubs
[
i
]
=
NULL
;
}
}
}
if
(
pSql
->
subState
.
states
)
{
pthread_mutex_destroy
(
&
pSql
->
subState
.
mutex
);
}
tfree
(
pSql
->
subState
.
states
);
pSql
->
subState
.
numOfSub
=
0
;
pSql
->
subState
.
numOfSub
=
0
;
}
}
static
void
quitAllSubquery
(
SSqlObj
*
pSqlObj
,
SJoinSupporter
*
pSupporter
)
{
static
void
quitAllSubquery
(
SSqlObj
*
pSqlSub
,
SSqlObj
*
pSqlObj
,
SJoinSupporter
*
pSupporter
)
{
assert
(
pSqlObj
->
subState
.
numOfRemain
>
0
);
if
(
subAndCheckDone
(
pSqlSub
,
pSqlObj
,
pSupporter
->
subqueryIndex
))
{
tscError
(
"%p all subquery return and query failed, global code:%s"
,
pSqlObj
,
tstrerror
(
pSqlObj
->
res
.
code
));
if
(
atomic_sub_fetch_32
(
&
pSqlObj
->
subState
.
numOfRemain
,
1
)
<=
0
)
{
tscError
(
"%p all subquery return and query failed, global code:%s"
,
pSqlObj
,
tstrerror
(
pSqlObj
->
res
.
code
));
freeJoinSubqueryObj
(
pSqlObj
);
freeJoinSubqueryObj
(
pSqlObj
);
return
;
}
}
//tscDestroyJoinSupporter(pSupporter);
//tscDestroyJoinSupporter(pSupporter);
...
@@ -777,6 +833,15 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
...
@@ -777,6 +833,15 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
assert
(
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_TAG_FILTER_QUERY
));
assert
(
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_TAG_FILTER_QUERY
));
if
(
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p abort query due to other subquery failure. code:%d, global code:%d"
,
pSql
,
numOfRows
,
pParentSql
->
res
.
code
);
quitAllSubquery
(
pSql
,
pParentSql
,
pSupporter
);
tscAsyncResultOnError
(
pParentSql
);
return
;
}
// check for the error code firstly
// check for the error code firstly
if
(
taos_errno
(
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
taos_errno
(
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
// todo retry if other subqueries are not failed
// todo retry if other subqueries are not failed
...
@@ -785,7 +850,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
...
@@ -785,7 +850,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
tscError
(
"%p sub query failed, code:%s, index:%d"
,
pSql
,
tstrerror
(
numOfRows
),
pSupporter
->
subqueryIndex
);
tscError
(
"%p sub query failed, code:%s, index:%d"
,
pSql
,
tstrerror
(
numOfRows
),
pSupporter
->
subqueryIndex
);
pParentSql
->
res
.
code
=
numOfRows
;
pParentSql
->
res
.
code
=
numOfRows
;
quitAllSubquery
(
pParentSql
,
pSupporter
);
quitAllSubquery
(
p
Sql
,
p
ParentSql
,
pSupporter
);
tscAsyncResultOnError
(
pParentSql
);
tscAsyncResultOnError
(
pParentSql
);
return
;
return
;
...
@@ -802,7 +867,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
...
@@ -802,7 +867,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
tscError
(
"%p failed to malloc memory"
,
pSql
);
tscError
(
"%p failed to malloc memory"
,
pSql
);
pParentSql
->
res
.
code
=
TAOS_SYSTEM_ERROR
(
errno
);
pParentSql
->
res
.
code
=
TAOS_SYSTEM_ERROR
(
errno
);
quitAllSubquery
(
pParentSql
,
pSupporter
);
quitAllSubquery
(
p
Sql
,
p
ParentSql
,
pSupporter
);
tscAsyncResultOnError
(
pParentSql
);
tscAsyncResultOnError
(
pParentSql
);
return
;
return
;
...
@@ -844,9 +909,10 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
...
@@ -844,9 +909,10 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
// no data exists in next vnode, mark the <tid, tags> query completed
// no data exists in next vnode, mark the <tid, tags> query completed
// only when there is no subquery exits any more, proceeds to get the intersect of the <tid, tags> tuple sets.
// only when there is no subquery exits any more, proceeds to get the intersect of the <tid, tags> tuple sets.
if
(
atomic_sub_fetch_32
(
&
pParentSql
->
subState
.
numOfRemain
,
1
)
>
0
)
{
if
(
!
subAndCheckDone
(
pSql
,
pParentSql
,
pSupporter
->
subqueryIndex
))
{
tscDebug
(
"%p tagRetrieve:%p,%d completed, total:%d"
,
pParentSql
,
tres
,
pSupporter
->
subqueryIndex
,
pParentSql
->
subState
.
numOfSub
);
return
;
return
;
}
}
SArray
*
s1
=
NULL
,
*
s2
=
NULL
;
SArray
*
s1
=
NULL
,
*
s2
=
NULL
;
int32_t
code
=
getIntersectionOfTableTuple
(
pQueryInfo
,
pParentSql
,
&
s1
,
&
s2
);
int32_t
code
=
getIntersectionOfTableTuple
(
pQueryInfo
,
pParentSql
,
&
s1
,
&
s2
);
...
@@ -891,8 +957,10 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
...
@@ -891,8 +957,10 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
((
SJoinSupporter
*
)
psub2
->
param
)
->
pVgroupTables
=
tscVgroupTableInfoClone
(
pTableMetaInfo2
->
pVgroupTables
);
((
SJoinSupporter
*
)
psub2
->
param
)
->
pVgroupTables
=
tscVgroupTableInfoClone
(
pTableMetaInfo2
->
pVgroupTables
);
pParentSql
->
subState
.
numOfSub
=
2
;
pParentSql
->
subState
.
numOfSub
=
2
;
pParentSql
->
subState
.
numOfRemain
=
pParentSql
->
subState
.
numOfSub
;
memset
(
pParentSql
->
subState
.
states
,
0
,
sizeof
(
pParentSql
->
subState
.
states
[
0
])
*
pParentSql
->
subState
.
numOfSub
);
tscDebug
(
"%p reset all sub states to 0"
,
pParentSql
);
for
(
int32_t
m
=
0
;
m
<
pParentSql
->
subState
.
numOfSub
;
++
m
)
{
for
(
int32_t
m
=
0
;
m
<
pParentSql
->
subState
.
numOfSub
;
++
m
)
{
SSqlObj
*
sub
=
pParentSql
->
pSubs
[
m
];
SSqlObj
*
sub
=
pParentSql
->
pSubs
[
m
];
issueTSCompQuery
(
sub
,
sub
->
param
,
pParentSql
);
issueTSCompQuery
(
sub
,
sub
->
param
,
pParentSql
);
...
@@ -915,6 +983,15 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
...
@@ -915,6 +983,15 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
assert
(
!
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_JOIN_SEC_STAGE
));
assert
(
!
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_JOIN_SEC_STAGE
));
if
(
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p abort query due to other subquery failure. code:%d, global code:%d"
,
pSql
,
numOfRows
,
pParentSql
->
res
.
code
);
quitAllSubquery
(
pSql
,
pParentSql
,
pSupporter
);
tscAsyncResultOnError
(
pParentSql
);
return
;
}
// check for the error code firstly
// check for the error code firstly
if
(
taos_errno
(
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
taos_errno
(
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
// todo retry if other subqueries are not failed yet
// todo retry if other subqueries are not failed yet
...
@@ -922,7 +999,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
...
@@ -922,7 +999,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
tscError
(
"%p sub query failed, code:%s, index:%d"
,
pSql
,
tstrerror
(
numOfRows
),
pSupporter
->
subqueryIndex
);
tscError
(
"%p sub query failed, code:%s, index:%d"
,
pSql
,
tstrerror
(
numOfRows
),
pSupporter
->
subqueryIndex
);
pParentSql
->
res
.
code
=
numOfRows
;
pParentSql
->
res
.
code
=
numOfRows
;
quitAllSubquery
(
pParentSql
,
pSupporter
);
quitAllSubquery
(
p
Sql
,
p
ParentSql
,
pSupporter
);
tscAsyncResultOnError
(
pParentSql
);
tscAsyncResultOnError
(
pParentSql
);
return
;
return
;
...
@@ -937,7 +1014,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
...
@@ -937,7 +1014,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
pParentSql
->
res
.
code
=
TAOS_SYSTEM_ERROR
(
errno
);
pParentSql
->
res
.
code
=
TAOS_SYSTEM_ERROR
(
errno
);
quitAllSubquery
(
pParentSql
,
pSupporter
);
quitAllSubquery
(
p
Sql
,
p
ParentSql
,
pSupporter
);
tscAsyncResultOnError
(
pParentSql
);
tscAsyncResultOnError
(
pParentSql
);
...
@@ -955,7 +1032,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
...
@@ -955,7 +1032,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
pParentSql
->
res
.
code
=
TAOS_SYSTEM_ERROR
(
errno
);
pParentSql
->
res
.
code
=
TAOS_SYSTEM_ERROR
(
errno
);
quitAllSubquery
(
pParentSql
,
pSupporter
);
quitAllSubquery
(
p
Sql
,
p
ParentSql
,
pSupporter
);
tscAsyncResultOnError
(
pParentSql
);
tscAsyncResultOnError
(
pParentSql
);
...
@@ -1009,9 +1086,9 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
...
@@ -1009,9 +1086,9 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
return
;
return
;
}
}
if
(
atomic_sub_fetch_32
(
&
pParentSql
->
subState
.
numOfRemain
,
1
)
>
0
)
{
if
(
!
subAndCheckDone
(
pSql
,
pParentSql
,
pSupporter
->
subqueryIndex
)
)
{
return
;
return
;
}
}
tscDebug
(
"%p all subquery retrieve ts complete, do ts block intersect"
,
pParentSql
);
tscDebug
(
"%p all subquery retrieve ts complete, do ts block intersect"
,
pParentSql
);
...
@@ -1049,6 +1126,17 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
...
@@ -1049,6 +1126,17 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
if
(
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p abort query due to other subquery failure. code:%d, global code:%d"
,
pSql
,
numOfRows
,
pParentSql
->
res
.
code
);
quitAllSubquery
(
pSql
,
pParentSql
,
pSupporter
);
tscAsyncResultOnError
(
pParentSql
);
return
;
}
if
(
taos_errno
(
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
taos_errno
(
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
assert
(
numOfRows
==
taos_errno
(
pSql
));
assert
(
numOfRows
==
taos_errno
(
pSql
));
...
@@ -1088,9 +1176,8 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
...
@@ -1088,9 +1176,8 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
}
}
}
}
assert
(
pState
->
numOfRemain
>
0
);
if
(
!
subAndCheckDone
(
pSql
,
pParentSql
,
pSupporter
->
subqueryIndex
))
{
if
(
atomic_sub_fetch_32
(
&
pState
->
numOfRemain
,
1
)
>
0
)
{
tscDebug
(
"%p sub:%p,%d completed, total:%d"
,
pParentSql
,
tres
,
pSupporter
->
subqueryIndex
,
pState
->
numOfSub
);
tscDebug
(
"%p sub:%p completed, remain:%d, total:%d"
,
pParentSql
,
tres
,
pState
->
numOfRemain
,
pState
->
numOfSub
);
return
;
return
;
}
}
...
@@ -1205,15 +1292,16 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
...
@@ -1205,15 +1292,16 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
}
}
}
}
// get the number of subquery that need to retrieve the next vnode.
if
(
orderedPrjQuery
)
{
if
(
orderedPrjQuery
)
{
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
if
(
pSub
!=
NULL
&&
pSub
->
res
.
row
>=
pSub
->
res
.
numOfRows
&&
pSub
->
res
.
completed
)
{
if
(
pSub
!=
NULL
&&
pSub
->
res
.
row
>=
pSub
->
res
.
numOfRows
&&
pSub
->
res
.
completed
)
{
pSql
->
subState
.
numOfRemain
++
;
subquerySetState
(
pSub
,
&
pSql
->
subState
,
i
,
0
)
;
}
}
}
}
}
}
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
...
@@ -1270,7 +1358,19 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
...
@@ -1270,7 +1358,19 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
// retrieve data from current vnode.
// retrieve data from current vnode.
tscDebug
(
"%p retrieve data from %d subqueries"
,
pSql
,
numOfFetch
);
tscDebug
(
"%p retrieve data from %d subqueries"
,
pSql
,
numOfFetch
);
SJoinSupporter
*
pSupporter
=
NULL
;
SJoinSupporter
*
pSupporter
=
NULL
;
pSql
->
subState
.
numOfRemain
=
numOfFetch
;
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
SSqlObj
*
pSql1
=
pSql
->
pSubs
[
i
];
if
(
pSql1
==
NULL
)
{
continue
;
}
SSqlRes
*
pRes1
=
&
pSql1
->
res
;
if
(
pRes1
->
row
>=
pRes1
->
numOfRows
)
{
subquerySetState
(
pSql1
,
&
pSql
->
subState
,
i
,
0
);
}
}
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
SSqlObj
*
pSql1
=
pSql
->
pSubs
[
i
];
SSqlObj
*
pSql1
=
pSql
->
pSubs
[
i
];
...
@@ -1372,7 +1472,8 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
...
@@ -1372,7 +1472,8 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
// retrieve actual query results from vnode during the second stage join subquery
// retrieve actual query results from vnode during the second stage join subquery
if
(
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p abort query due to other subquery failure. code:%d, global code:%d"
,
pSql
,
code
,
pParentSql
->
res
.
code
);
tscError
(
"%p abort query due to other subquery failure. code:%d, global code:%d"
,
pSql
,
code
,
pParentSql
->
res
.
code
);
quitAllSubquery
(
pParentSql
,
pSupporter
);
quitAllSubquery
(
pSql
,
pParentSql
,
pSupporter
);
tscAsyncResultOnError
(
pParentSql
);
tscAsyncResultOnError
(
pParentSql
);
return
;
return
;
...
@@ -1384,7 +1485,8 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
...
@@ -1384,7 +1485,8 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
tscError
(
"%p abort query, code:%s, global code:%s"
,
pSql
,
tstrerror
(
code
),
tstrerror
(
pParentSql
->
res
.
code
));
tscError
(
"%p abort query, code:%s, global code:%s"
,
pSql
,
tstrerror
(
code
),
tstrerror
(
pParentSql
->
res
.
code
));
pParentSql
->
res
.
code
=
code
;
pParentSql
->
res
.
code
=
code
;
quitAllSubquery
(
pParentSql
,
pSupporter
);
quitAllSubquery
(
pSql
,
pParentSql
,
pSupporter
);
tscAsyncResultOnError
(
pParentSql
);
tscAsyncResultOnError
(
pParentSql
);
return
;
return
;
...
@@ -1408,9 +1510,9 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
...
@@ -1408,9 +1510,9 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
// In case of consequence query from other vnode, do not wait for other query response here.
// In case of consequence query from other vnode, do not wait for other query response here.
if
(
!
(
pTableMetaInfo
->
vgroupIndex
>
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
)))
{
if
(
!
(
pTableMetaInfo
->
vgroupIndex
>
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
)))
{
if
(
atomic_sub_fetch_32
(
&
pParentSql
->
subState
.
numOfRemain
,
1
)
>
0
)
{
if
(
!
subAndCheckDone
(
pSql
,
pParentSql
,
pSupporter
->
subqueryIndex
)
)
{
return
;
return
;
}
}
}
}
tscSetupOutputColumnIndex
(
pParentSql
);
tscSetupOutputColumnIndex
(
pParentSql
);
...
@@ -1422,6 +1524,7 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
...
@@ -1422,6 +1524,7 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
if
(
pTableMetaInfo
->
vgroupIndex
>
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
if
(
pTableMetaInfo
->
vgroupIndex
>
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
pSql
->
fp
=
joinRetrieveFinalResCallback
;
// continue retrieve data
pSql
->
fp
=
joinRetrieveFinalResCallback
;
// continue retrieve data
pSql
->
cmd
.
command
=
TSDB_SQL_FETCH
;
pSql
->
cmd
.
command
=
TSDB_SQL_FETCH
;
tscProcessSql
(
pSql
);
tscProcessSql
(
pSql
);
}
else
{
// first retrieve from vnode during the secondary stage sub-query
}
else
{
// first retrieve from vnode during the secondary stage sub-query
// set the command flag must be after the semaphore been correctly set.
// set the command flag must be after the semaphore been correctly set.
...
@@ -1457,8 +1560,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
...
@@ -1457,8 +1560,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
pSql
->
pSubs
[
pSql
->
subState
.
numOfRemain
++
]
=
pNew
;
pSql
->
pSubs
[
tableIndex
]
=
pNew
;
assert
(
pSql
->
subState
.
numOfRemain
<=
pSql
->
subState
.
numOfSub
);
if
(
QUERY_IS_JOIN_QUERY
(
pQueryInfo
->
type
))
{
if
(
QUERY_IS_JOIN_QUERY
(
pQueryInfo
->
type
))
{
addGroupInfoForSubquery
(
pSql
,
pNew
,
0
,
tableIndex
);
addGroupInfoForSubquery
(
pSql
,
pNew
,
0
,
tableIndex
);
...
@@ -1590,6 +1692,19 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) {
...
@@ -1590,6 +1692,19 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) {
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
pSql
->
subState
.
numOfSub
=
pQueryInfo
->
numOfTables
;
pSql
->
subState
.
numOfSub
=
pQueryInfo
->
numOfTables
;
if
(
pSql
->
subState
.
states
==
NULL
)
{
pSql
->
subState
.
states
=
calloc
(
pSql
->
subState
.
numOfSub
,
sizeof
(
*
pSql
->
subState
.
states
));
if
(
pSql
->
subState
.
states
==
NULL
)
{
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
goto
_error
;
}
pthread_mutex_init
(
&
pSql
->
subState
.
mutex
,
NULL
);
}
memset
(
pSql
->
subState
.
states
,
0
,
sizeof
(
*
pSql
->
subState
.
states
)
*
pSql
->
subState
.
numOfSub
);
tscDebug
(
"%p reset all sub states to 0"
,
pSql
);
bool
hasEmptySub
=
false
;
bool
hasEmptySub
=
false
;
tscDebug
(
"%p start subquery, total:%d"
,
pSql
,
pQueryInfo
->
numOfTables
);
tscDebug
(
"%p start subquery, total:%d"
,
pSql
,
pQueryInfo
->
numOfTables
);
...
@@ -1622,14 +1737,25 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) {
...
@@ -1622,14 +1737,25 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) {
pSql
->
cmd
.
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
pSql
->
cmd
.
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
0
);
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
0
);
}
else
{
}
else
{
int
fail
=
0
;
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
if
(
fail
)
{
(
*
pSub
->
fp
)(
pSub
->
param
,
pSub
,
0
);
continue
;
}
if
((
code
=
tscProcessSql
(
pSub
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
tscProcessSql
(
pSub
))
!=
TSDB_CODE_SUCCESS
)
{
pSql
->
subState
.
numOfRemain
=
i
-
1
;
// the already sent request will continue and do not go to the error process routine
pRes
->
code
=
code
;
break
;
(
*
pSub
->
fp
)(
pSub
->
param
,
pSub
,
0
);
fail
=
1
;
}
}
}
}
if
(
fail
)
{
return
;
}
pSql
->
cmd
.
command
=
TSDB_SQL_TABLE_JOIN_RETRIEVE
;
pSql
->
cmd
.
command
=
TSDB_SQL_TABLE_JOIN_RETRIEVE
;
}
}
...
@@ -1728,7 +1854,21 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
...
@@ -1728,7 +1854,21 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
return
ret
;
return
ret
;
}
}
pState
->
numOfRemain
=
pState
->
numOfSub
;
if
(
pState
->
states
==
NULL
)
{
pState
->
states
=
calloc
(
pState
->
numOfSub
,
sizeof
(
*
pState
->
states
));
if
(
pState
->
states
==
NULL
)
{
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
tscAsyncResultOnError
(
pSql
);
tfree
(
pMemoryBuf
);
return
ret
;
}
pthread_mutex_init
(
&
pState
->
mutex
,
NULL
);
}
memset
(
pState
->
states
,
0
,
sizeof
(
*
pState
->
states
)
*
pState
->
numOfSub
);
tscDebug
(
"%p reset all sub states to 0"
,
pSql
);
pRes
->
code
=
TSDB_CODE_SUCCESS
;
pRes
->
code
=
TSDB_CODE_SUCCESS
;
int32_t
i
=
0
;
int32_t
i
=
0
;
...
@@ -1877,7 +2017,6 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
...
@@ -1877,7 +2017,6 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
assert
(
pSql
!=
NULL
);
assert
(
pSql
!=
NULL
);
SSubqueryState
*
pState
=
&
pParentSql
->
subState
;
SSubqueryState
*
pState
=
&
pParentSql
->
subState
;
assert
(
pState
->
numOfRemain
<=
pState
->
numOfSub
&&
pState
->
numOfRemain
>=
0
);
// retrieved in subquery failed. OR query cancelled in retrieve phase.
// retrieved in subquery failed. OR query cancelled in retrieve phase.
if
(
taos_errno
(
pSql
)
==
TSDB_CODE_SUCCESS
&&
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
taos_errno
(
pSql
)
==
TSDB_CODE_SUCCESS
&&
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -1908,14 +2047,12 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
...
@@ -1908,14 +2047,12 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
}
}
}
}
int32_t
remain
=
-
1
;
if
(
!
subAndCheckDone
(
pSql
,
pParentSql
,
subqueryIndex
))
{
if
((
remain
=
atomic_sub_fetch_32
(
&
pState
->
numOfRemain
,
1
))
>
0
)
{
tscDebug
(
"%p sub:%p,%d freed, not finished, total:%d"
,
pParentSql
,
pSql
,
trsupport
->
subqueryIndex
,
pState
->
numOfSub
);
tscDebug
(
"%p sub:%p orderOfSub:%d freed, finished subqueries:%d"
,
pParentSql
,
pSql
,
trsupport
->
subqueryIndex
,
pState
->
numOfSub
-
remain
);
tscFreeRetrieveSup
(
pSql
);
tscFreeRetrieveSup
(
pSql
);
return
;
return
;
}
}
// all subqueries are failed
// all subqueries are failed
tscError
(
"%p retrieve from %d vnode(s) completed,code:%s.FAILED."
,
pParentSql
,
pState
->
numOfSub
,
tscError
(
"%p retrieve from %d vnode(s) completed,code:%s.FAILED."
,
pParentSql
,
pState
->
numOfSub
,
...
@@ -1980,14 +2117,12 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
...
@@ -1980,14 +2117,12 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
return
;
return
;
}
}
int32_t
remain
=
-
1
;
if
(
!
subAndCheckDone
(
pSql
,
pParentSql
,
idx
))
{
if
((
remain
=
atomic_sub_fetch_32
(
&
pParentSql
->
subState
.
numOfRemain
,
1
))
>
0
)
{
tscDebug
(
"%p sub:%p orderOfSub:%d freed, not finished"
,
pParentSql
,
pSql
,
trsupport
->
subqueryIndex
);
tscDebug
(
"%p sub:%p orderOfSub:%d freed, finished subqueries:%d"
,
pParentSql
,
pSql
,
trsupport
->
subqueryIndex
,
pState
->
numOfSub
-
remain
);
tscFreeRetrieveSup
(
pSql
);
tscFreeRetrieveSup
(
pSql
);
return
;
return
;
}
}
// all sub-queries are returned, start to local merge process
// all sub-queries are returned, start to local merge process
pDesc
->
pColumnModel
->
capacity
=
trsupport
->
pExtMemBuffer
[
idx
]
->
numOfElemsPerPage
;
pDesc
->
pColumnModel
->
capacity
=
trsupport
->
pExtMemBuffer
[
idx
]
->
numOfElemsPerPage
;
...
@@ -2033,7 +2168,6 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
...
@@ -2033,7 +2168,6 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
SSqlObj
*
pParentSql
=
trsupport
->
pParentSql
;
SSqlObj
*
pParentSql
=
trsupport
->
pParentSql
;
SSubqueryState
*
pState
=
&
pParentSql
->
subState
;
SSubqueryState
*
pState
=
&
pParentSql
->
subState
;
assert
(
pState
->
numOfRemain
<=
pState
->
numOfSub
&&
pState
->
numOfRemain
>=
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
);
SVgroupInfo
*
pVgroup
=
&
pTableMetaInfo
->
vgroupList
->
vgroups
[
0
];
SVgroupInfo
*
pVgroup
=
&
pTableMetaInfo
->
vgroupList
->
vgroups
[
0
];
...
@@ -2254,7 +2388,8 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
...
@@ -2254,7 +2388,8 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
}
}
}
}
if
(
atomic_sub_fetch_32
(
&
pParentObj
->
subState
.
numOfRemain
,
1
)
>
0
)
{
if
(
!
subAndCheckDone
(
tres
,
pParentObj
,
pSupporter
->
index
))
{
tscDebug
(
"%p insert:%p,%d completed, total:%d"
,
pParentObj
,
tres
,
pSupporter
->
index
,
pParentObj
->
subState
.
numOfSub
);
return
;
return
;
}
}
...
@@ -2288,6 +2423,8 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
...
@@ -2288,6 +2423,8 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
STableMetaInfo
*
pMasterTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pParentObj
->
cmd
,
pSql
->
cmd
.
clauseIndex
,
0
);
STableMetaInfo
*
pMasterTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pParentObj
->
cmd
,
pSql
->
cmd
.
clauseIndex
,
0
);
tscAddTableMetaInfo
(
pQueryInfo
,
pMasterTableMetaInfo
->
name
,
NULL
,
NULL
,
NULL
,
NULL
);
tscAddTableMetaInfo
(
pQueryInfo
,
pMasterTableMetaInfo
->
name
,
NULL
,
NULL
,
NULL
,
NULL
);
subquerySetState
(
pSql
,
&
pParentObj
->
subState
,
i
,
0
);
tscDebug
(
"%p, failed sub:%d, %p"
,
pParentObj
,
i
,
pSql
);
tscDebug
(
"%p, failed sub:%d, %p"
,
pParentObj
,
i
,
pSql
);
}
}
}
}
...
@@ -2302,7 +2439,6 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
...
@@ -2302,7 +2439,6 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
}
}
pParentObj
->
cmd
.
parseFinished
=
false
;
pParentObj
->
cmd
.
parseFinished
=
false
;
pParentObj
->
subState
.
numOfRemain
=
numOfFailed
;
tscResetSqlCmdObj
(
&
pParentObj
->
cmd
);
tscResetSqlCmdObj
(
&
pParentObj
->
cmd
);
...
@@ -2378,7 +2514,19 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
...
@@ -2378,7 +2514,19 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
// the number of already initialized subqueries
// the number of already initialized subqueries
int32_t
numOfSub
=
0
;
int32_t
numOfSub
=
0
;
pSql
->
subState
.
numOfRemain
=
pSql
->
subState
.
numOfSub
;
if
(
pSql
->
subState
.
states
==
NULL
)
{
pSql
->
subState
.
states
=
calloc
(
pSql
->
subState
.
numOfSub
,
sizeof
(
*
pSql
->
subState
.
states
));
if
(
pSql
->
subState
.
states
==
NULL
)
{
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
goto
_error
;
}
pthread_mutex_init
(
&
pSql
->
subState
.
mutex
,
NULL
);
}
memset
(
pSql
->
subState
.
states
,
0
,
sizeof
(
*
pSql
->
subState
.
states
)
*
pSql
->
subState
.
numOfSub
);
tscDebug
(
"%p reset all sub states to 0"
,
pSql
);
pSql
->
pSubs
=
calloc
(
pSql
->
subState
.
numOfSub
,
POINTER_BYTES
);
pSql
->
pSubs
=
calloc
(
pSql
->
subState
.
numOfSub
,
POINTER_BYTES
);
if
(
pSql
->
pSubs
==
NULL
)
{
if
(
pSql
->
pSubs
==
NULL
)
{
goto
_error
;
goto
_error
;
...
...
src/client/src/tscUtil.c
浏览文件 @
789fc754
...
@@ -441,6 +441,12 @@ static void tscFreeSubobj(SSqlObj* pSql) {
...
@@ -441,6 +441,12 @@ static void tscFreeSubobj(SSqlObj* pSql) {
pSql
->
pSubs
[
i
]
=
NULL
;
pSql
->
pSubs
[
i
]
=
NULL
;
}
}
if
(
pSql
->
subState
.
states
)
{
pthread_mutex_destroy
(
&
pSql
->
subState
.
mutex
);
}
tfree
(
pSql
->
subState
.
states
);
pSql
->
subState
.
numOfSub
=
0
;
pSql
->
subState
.
numOfSub
=
0
;
}
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
浏览文件 @
789fc754
此差异已折叠。
点击以展开。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java
浏览文件 @
789fc754
...
@@ -26,9 +26,9 @@ public class TSDBResultSetRowData {
...
@@ -26,9 +26,9 @@ public class TSDBResultSetRowData {
public
TSDBResultSetRowData
(
int
colSize
)
{
public
TSDBResultSetRowData
(
int
colSize
)
{
this
.
setColSize
(
colSize
);
this
.
setColSize
(
colSize
);
}
}
public
TSDBResultSetRowData
()
{
public
TSDBResultSetRowData
()
{
this
.
data
=
new
ArrayList
<
Object
>();
this
.
data
=
new
ArrayList
<>();
this
.
setColSize
(
0
);
this
.
setColSize
(
0
);
}
}
...
@@ -39,7 +39,7 @@ public class TSDBResultSetRowData {
...
@@ -39,7 +39,7 @@ public class TSDBResultSetRowData {
if
(
this
.
colSize
==
0
)
{
if
(
this
.
colSize
==
0
)
{
return
;
return
;
}
}
this
.
data
=
new
ArrayList
<
Object
>(
colSize
);
this
.
data
=
new
ArrayList
<>(
colSize
);
this
.
data
.
addAll
(
Collections
.
nCopies
(
this
.
colSize
,
null
));
this
.
data
.
addAll
(
Collections
.
nCopies
(
this
.
colSize
,
null
));
}
}
...
@@ -53,7 +53,7 @@ public class TSDBResultSetRowData {
...
@@ -53,7 +53,7 @@ public class TSDBResultSetRowData {
public
boolean
getBoolean
(
int
col
,
int
srcType
)
throws
SQLException
{
public
boolean
getBoolean
(
int
col
,
int
srcType
)
throws
SQLException
{
Object
obj
=
data
.
get
(
col
);
Object
obj
=
data
.
get
(
col
);
switch
(
srcType
)
{
switch
(
srcType
)
{
case
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
:
return
(
Boolean
)
obj
;
case
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
:
return
(
Boolean
)
obj
;
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
return
((
Float
)
obj
)
==
1.0
?
Boolean
.
TRUE
:
Boolean
.
FALSE
;
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
return
((
Float
)
obj
)
==
1.0
?
Boolean
.
TRUE
:
Boolean
.
FALSE
;
...
@@ -64,10 +64,10 @@ public class TSDBResultSetRowData {
...
@@ -64,10 +64,10 @@ public class TSDBResultSetRowData {
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
return
((
Long
)
obj
)
==
1L
?
Boolean
.
TRUE
:
Boolean
.
FALSE
;
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
return
((
Long
)
obj
)
==
1L
?
Boolean
.
TRUE
:
Boolean
.
FALSE
;
}
}
return
Boolean
.
TRUE
;
return
Boolean
.
TRUE
;
}
}
public
void
setByte
(
int
col
,
byte
value
)
{
public
void
setByte
(
int
col
,
byte
value
)
{
data
.
set
(
col
,
value
);
data
.
set
(
col
,
value
);
}
}
...
@@ -82,20 +82,20 @@ public class TSDBResultSetRowData {
...
@@ -82,20 +82,20 @@ public class TSDBResultSetRowData {
public
int
getInt
(
int
col
,
int
srcType
)
throws
SQLException
{
public
int
getInt
(
int
col
,
int
srcType
)
throws
SQLException
{
Object
obj
=
data
.
get
(
col
);
Object
obj
=
data
.
get
(
col
);
switch
(
srcType
)
{
switch
(
srcType
)
{
case
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
:
return
Boolean
.
TRUE
.
equals
(
obj
)?
1
:
0
;
case
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
:
return
Boolean
.
TRUE
.
equals
(
obj
)?
1
:
0
;
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
return
((
Float
)
obj
).
intValue
();
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
return
((
Float
)
obj
).
intValue
();
case
TSDBConstants
.
TSDB_DATA_TYPE_DOUBLE
:
return
((
Double
)
obj
).
intValue
();
case
TSDBConstants
.
TSDB_DATA_TYPE_DOUBLE
:
return
((
Double
)
obj
).
intValue
();
case
TSDBConstants
.
TSDB_DATA_TYPE_TINYINT
:
return
(
Byte
)
obj
;
case
TSDBConstants
.
TSDB_DATA_TYPE_TINYINT
:
return
(
Byte
)
obj
;
case
TSDBConstants
.
TSDB_DATA_TYPE_SMALLINT
:
return
(
Short
)
obj
;
case
TSDBConstants
.
TSDB_DATA_TYPE_SMALLINT
:
return
(
Short
)
obj
;
case
TSDBConstants
.
TSDB_DATA_TYPE_INT
:
return
(
Integer
)
obj
;
case
TSDBConstants
.
TSDB_DATA_TYPE_INT
:
return
(
Integer
)
obj
;
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
return
((
Long
)
obj
).
intValue
();
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
return
((
Long
)
obj
).
intValue
();
case
TSDBConstants
.
TSDB_DATA_TYPE_NCHAR
:
case
TSDBConstants
.
TSDB_DATA_TYPE_NCHAR
:
case
TSDBConstants
.
TSDB_DATA_TYPE_BINARY
:
return
Integer
.
parseInt
((
String
)
obj
);
case
TSDBConstants
.
TSDB_DATA_TYPE_BINARY
:
return
Integer
.
parseInt
((
String
)
obj
);
}
}
return
0
;
return
0
;
}
}
...
@@ -105,7 +105,7 @@ public class TSDBResultSetRowData {
...
@@ -105,7 +105,7 @@ public class TSDBResultSetRowData {
public
long
getLong
(
int
col
,
int
srcType
)
throws
SQLException
{
public
long
getLong
(
int
col
,
int
srcType
)
throws
SQLException
{
Object
obj
=
data
.
get
(
col
);
Object
obj
=
data
.
get
(
col
);
switch
(
srcType
)
{
switch
(
srcType
)
{
case
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
:
return
Boolean
.
TRUE
.
equals
(
obj
)?
1
:
0
;
case
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
:
return
Boolean
.
TRUE
.
equals
(
obj
)?
1
:
0
;
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
return
((
Float
)
obj
).
longValue
();
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
return
((
Float
)
obj
).
longValue
();
...
@@ -116,9 +116,9 @@ public class TSDBResultSetRowData {
...
@@ -116,9 +116,9 @@ public class TSDBResultSetRowData {
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
return
(
Long
)
obj
;
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
return
(
Long
)
obj
;
case
TSDBConstants
.
TSDB_DATA_TYPE_NCHAR
:
case
TSDBConstants
.
TSDB_DATA_TYPE_NCHAR
:
case
TSDBConstants
.
TSDB_DATA_TYPE_BINARY
:
return
Long
.
parseLong
((
String
)
obj
);
case
TSDBConstants
.
TSDB_DATA_TYPE_BINARY
:
return
Long
.
parseLong
((
String
)
obj
);
}
}
return
0
;
return
0
;
}
}
...
@@ -128,7 +128,7 @@ public class TSDBResultSetRowData {
...
@@ -128,7 +128,7 @@ public class TSDBResultSetRowData {
public
float
getFloat
(
int
col
,
int
srcType
)
throws
SQLException
{
public
float
getFloat
(
int
col
,
int
srcType
)
throws
SQLException
{
Object
obj
=
data
.
get
(
col
);
Object
obj
=
data
.
get
(
col
);
switch
(
srcType
)
{
switch
(
srcType
)
{
case
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
:
return
Boolean
.
TRUE
.
equals
(
obj
)?
1
:
0
;
case
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
:
return
Boolean
.
TRUE
.
equals
(
obj
)?
1
:
0
;
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
return
(
Float
)
obj
;
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
return
(
Float
)
obj
;
...
@@ -139,7 +139,7 @@ public class TSDBResultSetRowData {
...
@@ -139,7 +139,7 @@ public class TSDBResultSetRowData {
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
return
(
Long
)
obj
;
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
return
(
Long
)
obj
;
}
}
return
0
;
return
0
;
}
}
...
@@ -149,7 +149,7 @@ public class TSDBResultSetRowData {
...
@@ -149,7 +149,7 @@ public class TSDBResultSetRowData {
public
double
getDouble
(
int
col
,
int
srcType
)
throws
SQLException
{
public
double
getDouble
(
int
col
,
int
srcType
)
throws
SQLException
{
Object
obj
=
data
.
get
(
col
);
Object
obj
=
data
.
get
(
col
);
switch
(
srcType
)
{
switch
(
srcType
)
{
case
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
:
return
Boolean
.
TRUE
.
equals
(
obj
)?
1
:
0
;
case
TSDBConstants
.
TSDB_DATA_TYPE_BOOL
:
return
Boolean
.
TRUE
.
equals
(
obj
)?
1
:
0
;
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
return
(
Float
)
obj
;
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
return
(
Float
)
obj
;
...
@@ -160,7 +160,7 @@ public class TSDBResultSetRowData {
...
@@ -160,7 +160,7 @@ public class TSDBResultSetRowData {
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
return
(
Long
)
obj
;
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
return
(
Long
)
obj
;
}
}
return
0
;
return
0
;
}
}
...
@@ -180,7 +180,7 @@ public class TSDBResultSetRowData {
...
@@ -180,7 +180,7 @@ public class TSDBResultSetRowData {
* The original type may not be a string type, but will be converted to by calling this method
* The original type may not be a string type, but will be converted to by calling this method
* @param col column index
* @param col column index
* @return
* @return
* @throws SQLException
* @throws SQLException
*/
*/
public
String
getString
(
int
col
,
int
srcType
)
throws
SQLException
{
public
String
getString
(
int
col
,
int
srcType
)
throws
SQLException
{
if
(
srcType
==
TSDBConstants
.
TSDB_DATA_TYPE_BINARY
||
srcType
==
TSDBConstants
.
TSDB_DATA_TYPE_NCHAR
)
{
if
(
srcType
==
TSDBConstants
.
TSDB_DATA_TYPE_BINARY
||
srcType
==
TSDBConstants
.
TSDB_DATA_TYPE_NCHAR
)
{
...
...
src/connector/jdbc/src/test/java/TestTSDBDatabaseMetaData.java
已删除
100644 → 0
浏览文件 @
c1ddf46e
import
com.taosdata.jdbc.TSDBDriver
;
import
java.sql.*
;
import
java.util.Properties
;
public
class
TestTSDBDatabaseMetaData
{
public
static
void
main
(
String
[]
args
)
throws
SQLException
{
Connection
connection
=
null
;
DatabaseMetaData
dbMetaData
=
null
;
ResultSet
resSet
=
null
;
try
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
"localhost"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://localhost:0/"
,
properties
);
dbMetaData
=
connection
.
getMetaData
();
resSet
=
dbMetaData
.
getCatalogs
();
while
(
resSet
.
next
())
{
for
(
int
i
=
1
;
i
<=
resSet
.
getMetaData
().
getColumnCount
();
i
++)
{
System
.
out
.
printf
(
"dbMetaData.getCatalogs(%d) = %s\n"
,
i
,
resSet
.
getString
(
i
));
}
}
resSet
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
if
(
null
!=
connection
)
{
connection
.
close
();
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java
浏览文件 @
789fc754
...
@@ -10,7 +10,7 @@ import java.util.Properties;
...
@@ -10,7 +10,7 @@ import java.util.Properties;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
StatementTest
extends
BaseTest
{
public
class
StatementTest
{
static
Connection
connection
=
null
;
static
Connection
connection
=
null
;
static
Statement
statement
=
null
;
static
Statement
statement
=
null
;
static
String
dbName
=
"test"
;
static
String
dbName
=
"test"
;
...
@@ -26,14 +26,29 @@ public class StatementTest extends BaseTest {
...
@@ -26,14 +26,29 @@ public class StatementTest extends BaseTest {
return
;
return
;
}
}
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
host
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/
?user=root&password=taosdata
"
,
properties
);
statement
=
connection
.
createStatement
();
statement
=
connection
.
createStatement
();
statement
.
executeUpdate
(
"drop database if exists "
+
dbName
);
statement
.
executeUpdate
(
"drop database if exists "
+
dbName
);
}
@Test
public
void
testCase
()
{
try
{
ResultSet
rs
=
statement
.
executeQuery
(
"show databases"
);
ResultSetMetaData
metaData
=
rs
.
getMetaData
();
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
metaData
.
getColumnCount
();
i
++)
{
System
.
out
.
print
(
metaData
.
getColumnLabel
(
i
)
+
":"
+
rs
.
getString
(
i
)
+
"\t"
);
}
System
.
out
.
println
();
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
...
@@ -54,9 +69,6 @@ public class StatementTest extends BaseTest {
...
@@ -54,9 +69,6 @@ public class StatementTest extends BaseTest {
@Test
@Test
public
void
testUnsupport
()
{
public
void
testUnsupport
()
{
// if(null == resSet) {
// return;
// }
TSDBStatement
tsdbStatement
=
(
TSDBStatement
)
statement
;
TSDBStatement
tsdbStatement
=
(
TSDBStatement
)
statement
;
try
{
try
{
tsdbStatement
.
unwrap
(
null
);
tsdbStatement
.
unwrap
(
null
);
...
@@ -163,11 +175,10 @@ public class StatementTest extends BaseTest {
...
@@ -163,11 +175,10 @@ public class StatementTest extends BaseTest {
@AfterClass
@AfterClass
public
static
void
close
()
throws
Exception
{
public
static
void
close
()
throws
Exception
{
if
(!
statement
.
isClosed
())
{
if
(!
statement
.
isClosed
())
{
statement
.
executeUpdate
(
"drop database "
+
dbName
);
statement
.
executeUpdate
(
"drop database
if exists
"
+
dbName
);
statement
.
close
();
statement
.
close
();
connection
.
close
();
connection
.
close
();
Thread
.
sleep
(
10
);
Thread
.
sleep
(
10
);
}
}
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
浏览文件 @
789fc754
...
@@ -4,10 +4,7 @@ import org.junit.Assert;
...
@@ -4,10 +4,7 @@ import org.junit.Assert;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
java.sql.Connection
;
import
java.sql.*
;
import
java.sql.DriverManager
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.Properties
;
import
java.util.Properties
;
public
class
TSDBDatabaseMetaDataTest
{
public
class
TSDBDatabaseMetaDataTest
{
...
@@ -642,7 +639,15 @@ public class TSDBDatabaseMetaDataTest {
...
@@ -642,7 +639,15 @@ public class TSDBDatabaseMetaDataTest {
@Test
@Test
public
void
getTables
()
throws
SQLException
{
public
void
getTables
()
throws
SQLException
{
Assert
.
assertNull
(
metaData
.
getTables
(
""
,
""
,
"*"
,
null
));
ResultSet
tables
=
metaData
.
getTables
(
"log"
,
""
,
null
,
null
);
ResultSetMetaData
metaData
=
tables
.
getMetaData
();
while
(
tables
.
next
())
{
System
.
out
.
print
(
metaData
.
getColumnLabel
(
3
)
+
":"
+
tables
.
getString
(
3
)
+
"\t"
);
System
.
out
.
print
(
metaData
.
getColumnLabel
(
4
)
+
":"
+
tables
.
getString
(
4
)
+
"\t"
);
System
.
out
.
print
(
metaData
.
getColumnLabel
(
5
)
+
":"
+
tables
.
getString
(
5
)
+
"\n"
);
}
System
.
out
.
println
();
Assert
.
assertNotNull
(
tables
);
}
}
@Test
@Test
...
@@ -652,17 +657,41 @@ public class TSDBDatabaseMetaDataTest {
...
@@ -652,17 +657,41 @@ public class TSDBDatabaseMetaDataTest {
@Test
@Test
public
void
getCatalogs
()
throws
SQLException
{
public
void
getCatalogs
()
throws
SQLException
{
Assert
.
assertNotNull
(
metaData
.
getCatalogs
());
ResultSet
catalogs
=
metaData
.
getCatalogs
();
ResultSetMetaData
meta
=
catalogs
.
getMetaData
();
while
(
catalogs
.
next
())
{
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
System
.
out
.
print
(
meta
.
getColumnLabel
(
i
)
+
": "
+
catalogs
.
getString
(
i
));
}
System
.
out
.
println
();
}
}
}
@Test
@Test
public
void
getTableTypes
()
throws
SQLException
{
public
void
getTableTypes
()
throws
SQLException
{
ResultSet
tableTypes
=
metaData
.
getTableTypes
();
while
(
tableTypes
.
next
())
{
System
.
out
.
println
(
tableTypes
.
getString
(
"TABLE_TYPE"
));
}
Assert
.
assertNotNull
(
metaData
.
getTableTypes
());
Assert
.
assertNotNull
(
metaData
.
getTableTypes
());
}
}
@Test
@Test
public
void
getColumns
()
throws
SQLException
{
public
void
getColumns
()
throws
SQLException
{
Assert
.
assertNotNull
(
metaData
.
getColumns
(
""
,
""
,
""
,
""
));
ResultSet
columns
=
metaData
.
getColumns
(
"log"
,
""
,
"dn"
,
""
);
ResultSetMetaData
meta
=
columns
.
getMetaData
();
while
(
columns
.
next
())
{
System
.
out
.
print
(
meta
.
getColumnLabel
(
1
)
+
": "
+
columns
.
getString
(
1
)
+
"\t"
);
System
.
out
.
print
(
meta
.
getColumnLabel
(
3
)
+
": "
+
columns
.
getString
(
3
)
+
"\t"
);
System
.
out
.
print
(
meta
.
getColumnLabel
(
4
)
+
": "
+
columns
.
getString
(
4
)
+
"\t"
);
System
.
out
.
print
(
meta
.
getColumnLabel
(
5
)
+
": "
+
columns
.
getString
(
5
)
+
"\t"
);
System
.
out
.
print
(
meta
.
getColumnLabel
(
6
)
+
": "
+
columns
.
getString
(
6
)
+
"\t"
);
System
.
out
.
print
(
meta
.
getColumnLabel
(
7
)
+
": "
+
columns
.
getString
(
7
)
+
"\t"
);
System
.
out
.
print
(
meta
.
getColumnLabel
(
9
)
+
": "
+
columns
.
getString
(
9
)
+
"\t"
);
System
.
out
.
print
(
meta
.
getColumnLabel
(
10
)
+
": "
+
columns
.
getString
(
10
)
+
"\t"
);
System
.
out
.
print
(
meta
.
getColumnLabel
(
11
)
+
": "
+
columns
.
getString
(
11
)
+
"\n"
);
System
.
out
.
print
(
meta
.
getColumnLabel
(
12
)
+
": "
+
columns
.
getString
(
12
)
+
"\n"
);
}
}
}
@Test
@Test
...
@@ -687,7 +716,15 @@ public class TSDBDatabaseMetaDataTest {
...
@@ -687,7 +716,15 @@ public class TSDBDatabaseMetaDataTest {
@Test
@Test
public
void
getPrimaryKeys
()
throws
SQLException
{
public
void
getPrimaryKeys
()
throws
SQLException
{
Assert
.
assertNotNull
(
metaData
.
getPrimaryKeys
(
""
,
""
,
""
));
ResultSet
rs
=
metaData
.
getPrimaryKeys
(
"log"
,
""
,
"dn1"
);
while
(
rs
.
next
())
{
System
.
out
.
println
(
"TABLE_NAME: "
+
rs
.
getString
(
"TABLE_NAME"
));
System
.
out
.
println
(
"COLUMN_NAME: "
+
rs
.
getString
(
"COLUMN_NAME"
));
System
.
out
.
println
(
"KEY_SEQ: "
+
rs
.
getString
(
"KEY_SEQ"
));
System
.
out
.
println
(
"PK_NAME: "
+
rs
.
getString
(
"PK_NAME"
));
}
Assert
.
assertNotNull
(
rs
);
}
}
@Test
@Test
...
@@ -812,7 +849,12 @@ public class TSDBDatabaseMetaDataTest {
...
@@ -812,7 +849,12 @@ public class TSDBDatabaseMetaDataTest {
@Test
@Test
public
void
getSuperTables
()
throws
SQLException
{
public
void
getSuperTables
()
throws
SQLException
{
Assert
.
assertNotNull
(
metaData
.
getSuperTables
(
""
,
""
,
""
));
ResultSet
rs
=
metaData
.
getSuperTables
(
"log"
,
""
,
"dn1"
);
while
(
rs
.
next
())
{
System
.
out
.
println
(
"TABLE_NAME: "
+
rs
.
getString
(
"TABLE_NAME"
));
System
.
out
.
println
(
"SUPERTABLE_NAME: "
+
rs
.
getString
(
"SUPERTABLE_NAME"
));
}
Assert
.
assertNotNull
(
rs
);
}
}
@Test
@Test
...
...
src/connector/nodejs/nodetaos/cinterface.js
浏览文件 @
789fc754
...
@@ -3,15 +3,15 @@
...
@@ -3,15 +3,15 @@
* @module CTaosInterface
* @module CTaosInterface
*/
*/
const
ref
=
require
(
'
ref
'
);
const
ref
=
require
(
'
ref
-napi
'
);
const
os
=
require
(
'
os
'
);
const
os
=
require
(
'
os
'
);
const
ffi
=
require
(
'
ffi
'
);
const
ffi
=
require
(
'
ffi
-napi
'
);
const
ArrayType
=
require
(
'
ref-array
'
);
const
ArrayType
=
require
(
'
ref-array
-napi
'
);
const
Struct
=
require
(
'
ref-struct
'
);
const
Struct
=
require
(
'
ref-struct
-napi
'
);
const
FieldTypes
=
require
(
'
./constants
'
);
const
FieldTypes
=
require
(
'
./constants
'
);
const
errors
=
require
(
'
./error
'
);
const
errors
=
require
(
'
./error
'
);
const
TaosObjects
=
require
(
'
./taosobjects
'
);
const
TaosObjects
=
require
(
'
./taosobjects
'
);
const
{
NULL_POINTER
}
=
require
(
'
ref
'
);
const
{
NULL_POINTER
}
=
require
(
'
ref
-napi
'
);
module
.
exports
=
CTaosInterface
;
module
.
exports
=
CTaosInterface
;
...
...
src/connector/nodejs/nodetaos/cursor.js
浏览文件 @
789fc754
const
ref
=
require
(
'
ref
'
);
const
ref
=
require
(
'
ref
-napi
'
);
require
(
'
./globalfunc.js
'
)
require
(
'
./globalfunc.js
'
)
const
CTaosInterface
=
require
(
'
./cinterface
'
)
const
CTaosInterface
=
require
(
'
./cinterface
'
)
const
errors
=
require
(
'
./error
'
)
const
errors
=
require
(
'
./error
'
)
...
...
src/connector/nodejs/package-lock.json
浏览文件 @
789fc754
此差异已折叠。
点击以展开。
src/connector/nodejs/package.json
浏览文件 @
789fc754
{
{
"name"
:
"td2.0-connector"
,
"name"
:
"td2.0-connector"
,
"version"
:
"2.0.
5
"
,
"version"
:
"2.0.
6
"
,
"description"
:
"A Node.js connector for TDengine."
,
"description"
:
"A Node.js connector for TDengine."
,
"main"
:
"tdengine.js"
,
"main"
:
"tdengine.js"
,
"directories"
:
{
"test"
:
"test"
},
"scripts"
:
{
"scripts"
:
{
"test"
:
"node test/test.js"
"test"
:
"node test/test.js"
},
},
"repository"
:
{
"type"
:
"git"
,
"url"
:
"git+https://github.com/taosdata/tdengine.git"
},
"keywords"
:
[
"keywords"
:
[
"TDengine"
,
"TDengine"
,
"TAOS Data"
,
"TAOS Data"
,
"Time Series Database"
,
"Time Series Database"
,
"Connector"
"Connector"
],
],
"author"
:
"StoneT2000"
,
"author"
:
"TaosData Inc."
,
"license"
:
"AGPL-3.0"
,
"license"
:
"AGPL-3.0-or-later"
,
"dependencies"
:
{
"ffi"
:
"^2.3.0"
,
"node-gyp"
:
"^5.0.2"
,
"ref"
:
"^1.3.5"
,
"ref-array"
:
"^1.2.0"
},
"homepage"
:
"https://github.com/taosdata/tdengine"
,
"bugs"
:
{
"bugs"
:
{
"url"
:
"https://github.com/taosdata/tdengine/issues"
"url"
:
"https://github.com/taosdata/tdengine/issues"
},
},
"repository"
:
{
"homepage"
:
"https://github.com/taosdata/tdengine#readme"
,
"type"
:
"git"
,
"dependencies"
:
{
"url"
:
"https://github.com/taosdata/tdengine.git"
"ffi-napi"
:
"^3.1.0"
,
"ref-array-napi"
:
"^1.2.1"
,
"ref-napi"
:
"^1.5.2"
,
"ref-struct-napi"
:
"^1.1.1"
}
}
}
}
src/inc/ttokendef.h
浏览文件 @
789fc754
...
@@ -82,151 +82,154 @@
...
@@ -82,151 +82,154 @@
#define TK_STABLES 64
#define TK_STABLES 64
#define TK_VGROUPS 65
#define TK_VGROUPS 65
#define TK_DROP 66
#define TK_DROP 66
#define TK_
DNODE
67
#define TK_
STABLE
67
#define TK_
USER
68
#define TK_
DNODE
68
#define TK_
ACCOUNT
69
#define TK_
USER
69
#define TK_
USE
70
#define TK_
ACCOUNT
70
#define TK_
DESCRIBE
71
#define TK_
USE
71
#define TK_
ALTER
72
#define TK_
DESCRIBE
72
#define TK_
PASS
73
#define TK_
ALTER
73
#define TK_P
RIVILEGE
74
#define TK_P
ASS
74
#define TK_
LOCAL
75
#define TK_
PRIVILEGE
75
#define TK_
IF
76
#define TK_
LOCAL
76
#define TK_
EXISTS
77
#define TK_
IF
77
#define TK_
PPS
78
#define TK_
EXISTS
78
#define TK_
TSERIES
79
#define TK_
PPS
79
#define TK_
DBS
80
#define TK_
TSERIES
80
#define TK_
STORAGE
81
#define TK_
DBS
81
#define TK_
QTIME
82
#define TK_
STORAGE
82
#define TK_
CONNS
83
#define TK_
QTIME
83
#define TK_
STATE
84
#define TK_
CONNS
84
#define TK_
KEEP
85
#define TK_
STATE
85
#define TK_
CACHE
86
#define TK_
KEEP
86
#define TK_
REPLICA
87
#define TK_
CACHE
87
#define TK_
QUORUM
88
#define TK_
REPLICA
88
#define TK_
DAYS
89
#define TK_
QUORUM
89
#define TK_
MINROWS
90
#define TK_
DAYS
90
#define TK_M
AX
ROWS 91
#define TK_M
IN
ROWS 91
#define TK_
BLOCKS
92
#define TK_
MAXROWS
92
#define TK_
CTIME
93
#define TK_
BLOCKS
93
#define TK_
WAL
94
#define TK_
CTIME
94
#define TK_
FSYNC
95
#define TK_
WAL
95
#define TK_
COMP
96
#define TK_
FSYNC
96
#define TK_
PRECISION
97
#define TK_
COMP
97
#define TK_
UPDATE
98
#define TK_
PRECISION
98
#define TK_
CACHELAST
99
#define TK_
UPDATE
99
#define TK_
LP
100
#define TK_
CACHELAST
100
#define TK_
R
P 101
#define TK_
L
P 101
#define TK_
UNSIGNED
102
#define TK_
RP
102
#define TK_
TAGS
103
#define TK_
UNSIGNED
103
#define TK_
USING
104
#define TK_
TAGS
104
#define TK_
AS
105
#define TK_
USING
105
#define TK_
COMMA
106
#define TK_
AS
106
#define TK_
NULL
107
#define TK_
COMMA
107
#define TK_
SELECT
108
#define TK_
NULL
108
#define TK_
UNION
109
#define TK_
SELECT
109
#define TK_
ALL
110
#define TK_
UNION
110
#define TK_
FROM
111
#define TK_
ALL
111
#define TK_
VARIABLE
112
#define TK_
FROM
112
#define TK_
INTERVAL
113
#define TK_
VARIABLE
113
#define TK_
FILL
114
#define TK_
INTERVAL
114
#define TK_
SLIDING
115
#define TK_
FILL
115
#define TK_
ORDER
116
#define TK_
SLIDING
116
#define TK_
BY
117
#define TK_
ORDER
117
#define TK_
ASC
118
#define TK_
BY
118
#define TK_
DESC
119
#define TK_
ASC
119
#define TK_
GROUP
120
#define TK_
DESC
120
#define TK_
HAVING
121
#define TK_
GROUP
121
#define TK_
LIMIT
122
#define TK_
HAVING
122
#define TK_
OFFSET
123
#define TK_
LIMIT
123
#define TK_
SLIMI
T 124
#define TK_
OFFSE
T 124
#define TK_S
OFFSET
125
#define TK_S
LIMIT
125
#define TK_
WHERE
126
#define TK_
SOFFSET
126
#define TK_
NOW
127
#define TK_
WHERE
127
#define TK_
RESET
128
#define TK_
NOW
128
#define TK_
QUERY
129
#define TK_
RESET
129
#define TK_
ADD
130
#define TK_
QUERY
130
#define TK_
COLUMN
131
#define TK_
ADD
131
#define TK_
TAG
132
#define TK_
COLUMN
132
#define TK_
CHANGE
133
#define TK_
TAG
133
#define TK_
SET
134
#define TK_
CHANGE
134
#define TK_
KILL
135
#define TK_
SET
135
#define TK_
CONNECTION
136
#define TK_
KILL
136
#define TK_
STREAM
137
#define TK_
CONNECTION
137
#define TK_
COLON
138
#define TK_
STREAM
138
#define TK_
ABORT
139
#define TK_
COLON
139
#define TK_A
FTER
140
#define TK_A
BORT
140
#define TK_A
TTACH
141
#define TK_A
FTER
141
#define TK_
BEFORE
142
#define TK_
ATTACH
142
#define TK_BE
GIN
143
#define TK_BE
FORE
143
#define TK_
CASCADE
144
#define TK_
BEGIN
144
#define TK_C
LUSTER
145
#define TK_C
ASCADE
145
#define TK_C
ONFLICT
146
#define TK_C
LUSTER
146
#define TK_CO
PY
147
#define TK_CO
NFLICT
147
#define TK_
DEFERRED
148
#define TK_
COPY
148
#define TK_DE
LIMITERS
149
#define TK_DE
FERRED
149
#define TK_DE
TACH
150
#define TK_DE
LIMITERS
150
#define TK_
EACH
151
#define TK_
DETACH
151
#define TK_E
ND
152
#define TK_E
ACH
152
#define TK_E
XPLAIN
153
#define TK_E
ND
153
#define TK_
FAIL
154
#define TK_
EXPLAIN
154
#define TK_F
OR
155
#define TK_F
AIL
155
#define TK_
IGNORE
156
#define TK_
FOR
156
#define TK_I
MMEDIATE
157
#define TK_I
GNORE
157
#define TK_I
NITIALLY
158
#define TK_I
MMEDIATE
158
#define TK_IN
STEAD
159
#define TK_IN
ITIALLY
159
#define TK_
MATCH
160
#define TK_
INSTEAD
160
#define TK_
KEY
161
#define TK_
MATCH
161
#define TK_
OF
162
#define TK_
KEY
162
#define TK_
RAISE
163
#define TK_
OF
163
#define TK_R
EPLACE
164
#define TK_R
AISE
164
#define TK_RE
STRICT
165
#define TK_RE
PLACE
165
#define TK_R
OW
166
#define TK_R
ESTRICT
166
#define TK_
STATEMENT
167
#define TK_
ROW
167
#define TK_
TRIGGER
168
#define TK_
STATEMENT
168
#define TK_
VIEW
169
#define TK_
TRIGGER
169
#define TK_
COUNT
170
#define TK_
VIEW
170
#define TK_
SUM
171
#define TK_
COUNT
171
#define TK_
AVG
172
#define TK_
SUM
172
#define TK_
MIN
173
#define TK_
AVG
173
#define TK_M
AX
174
#define TK_M
IN
174
#define TK_
FIRST
175
#define TK_
MAX
175
#define TK_
LAST
176
#define TK_
FIRST
176
#define TK_
TOP
177
#define TK_
LAST
177
#define TK_
BOTTOM
178
#define TK_
TOP
178
#define TK_
STDDEV
179
#define TK_
BOTTOM
179
#define TK_
PERCENTILE
180
#define TK_
STDDEV
180
#define TK_
APERCENTILE
181
#define TK_
PERCENTILE
181
#define TK_
LEASTSQUARES
182
#define TK_
APERCENTILE
182
#define TK_
HISTOGRAM
183
#define TK_
LEASTSQUARES
183
#define TK_
DIFF
184
#define TK_
HISTOGRAM
184
#define TK_
SPREAD
185
#define TK_
DIFF
185
#define TK_
TWA
186
#define TK_
SPREAD
186
#define TK_
INTERP
187
#define TK_
TWA
187
#define TK_
LAST_ROW
188
#define TK_
INTERP
188
#define TK_
RATE
189
#define TK_
LAST_ROW
189
#define TK_
IRATE
190
#define TK_
RATE
190
#define TK_
SUM_RATE
191
#define TK_
IRATE
191
#define TK_SUM_
IRATE
192
#define TK_SUM_
RATE
192
#define TK_
AVG_RATE
193
#define TK_
SUM_IRATE
193
#define TK_AVG_
IRATE
194
#define TK_AVG_
RATE
194
#define TK_
TBID
195
#define TK_
AVG_IRATE
195
#define TK_
SEMI
196
#define TK_
TBID
196
#define TK_
NONE
197
#define TK_
SEMI
197
#define TK_
PREV
198
#define TK_
NONE
198
#define TK_
LINEAR
199
#define TK_
PREV
199
#define TK_
IMPORT
200
#define TK_
LINEAR
200
#define TK_
METRIC
201
#define TK_
IMPORT
201
#define TK_
TBNAME
202
#define TK_
METRIC
202
#define TK_
JOIN
203
#define TK_
TBNAME
203
#define TK_
METRICS
204
#define TK_
JOIN
204
#define TK_
STABLE
205
#define TK_
METRICS
205
#define TK_INSERT 206
#define TK_INSERT 206
#define TK_INTO 207
#define TK_INTO 207
#define TK_VALUES 208
#define TK_VALUES 208
#define TK_SPACE 300
#define TK_SPACE 300
#define TK_COMMENT 301
#define TK_COMMENT 301
#define TK_ILLEGAL 302
#define TK_ILLEGAL 302
...
...
src/mnode/src/mnodeProfile.c
浏览文件 @
789fc754
...
@@ -385,12 +385,22 @@ static int32_t mnodeRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, v
...
@@ -385,12 +385,22 @@ static int32_t mnodeRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, v
SConnObj
*
pConnObj
=
NULL
;
SConnObj
*
pConnObj
=
NULL
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
char
*
pWrite
;
char
*
pWrite
;
void
*
pIter
;
char
str
[
TSDB_IPv4ADDR_LEN
+
6
]
=
{
0
};
char
str
[
TSDB_IPv4ADDR_LEN
+
6
]
=
{
0
};
while
(
numOfRows
<
rows
)
{
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
mnodeGetNextConn
(
pShow
->
pIter
,
&
pConnObj
);
pIter
=
mnodeGetNextConn
(
pShow
->
pIter
,
&
pConnObj
);
if
(
pConnObj
==
NULL
)
break
;
if
(
pConnObj
==
NULL
)
{
pShow
->
pIter
=
pIter
;
break
;
}
if
(
numOfRows
+
pConnObj
->
numOfQueries
>=
rows
)
{
mnodeCancelGetNextConn
(
pIter
);
break
;
}
pShow
->
pIter
=
pIter
;
for
(
int32_t
i
=
0
;
i
<
pConnObj
->
numOfQueries
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pConnObj
->
numOfQueries
;
++
i
)
{
SQueryDesc
*
pDesc
=
pConnObj
->
pQueries
+
i
;
SQueryDesc
*
pDesc
=
pConnObj
->
pQueries
+
i
;
cols
=
0
;
cols
=
0
;
...
@@ -518,12 +528,22 @@ static int32_t mnodeRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, v
...
@@ -518,12 +528,22 @@ static int32_t mnodeRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, v
SConnObj
*
pConnObj
=
NULL
;
SConnObj
*
pConnObj
=
NULL
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
char
*
pWrite
;
char
*
pWrite
;
void
*
pIter
;
char
ipStr
[
TSDB_IPv4ADDR_LEN
+
6
];
char
ipStr
[
TSDB_IPv4ADDR_LEN
+
6
];
while
(
numOfRows
<
rows
)
{
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
mnodeGetNextConn
(
pShow
->
pIter
,
&
pConnObj
);
pIter
=
mnodeGetNextConn
(
pShow
->
pIter
,
&
pConnObj
);
if
(
pConnObj
==
NULL
)
break
;
if
(
pConnObj
==
NULL
)
{
pShow
->
pIter
=
pIter
;
break
;
}
if
(
numOfRows
+
pConnObj
->
numOfStreams
>=
rows
)
{
mnodeCancelGetNextConn
(
pIter
);
break
;
}
pShow
->
pIter
=
pIter
;
for
(
int32_t
i
=
0
;
i
<
pConnObj
->
numOfStreams
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pConnObj
->
numOfStreams
;
++
i
)
{
SStreamDesc
*
pDesc
=
pConnObj
->
pStreams
+
i
;
SStreamDesc
*
pDesc
=
pConnObj
->
pStreams
+
i
;
cols
=
0
;
cols
=
0
;
...
...
src/os/src/detail/osTime.c
浏览文件 @
789fc754
...
@@ -504,13 +504,13 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
...
@@ -504,13 +504,13 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
int64_t
end
=
0
;
int64_t
end
=
0
;
// not enough time range
// not enough time range
if
(
INT64_MAX
-
start
>
pInterval
->
interval
-
1
)
{
if
(
start
<
0
||
INT64_MAX
-
start
>
pInterval
->
interval
-
1
)
{
end
=
start
+
pInterval
->
interval
-
1
;
end
=
start
+
pInterval
->
interval
-
1
;
while
(
end
<
t
&&
((
start
+
pInterval
->
sliding
)
<=
INT64_MAX
))
{
// move forward to the correct time window
while
(
end
<
t
&&
((
start
+
pInterval
->
sliding
)
<=
INT64_MAX
))
{
// move forward to the correct time window
start
+=
pInterval
->
sliding
;
start
+=
pInterval
->
sliding
;
if
(
INT64_MAX
-
start
>
pInterval
->
interval
-
1
)
{
if
(
start
<
0
||
INT64_MAX
-
start
>
pInterval
->
interval
-
1
)
{
end
=
start
+
pInterval
->
interval
-
1
;
end
=
start
+
pInterval
->
interval
-
1
;
}
else
{
}
else
{
end
=
INT64_MAX
;
end
=
INT64_MAX
;
...
...
src/query/inc/qSqlparser.h
浏览文件 @
789fc754
...
@@ -98,6 +98,7 @@ typedef struct SCreateTableSQL {
...
@@ -98,6 +98,7 @@ typedef struct SCreateTableSQL {
typedef
struct
SAlterTableSQL
{
typedef
struct
SAlterTableSQL
{
SStrToken
name
;
SStrToken
name
;
int16_t
tableType
;
int16_t
type
;
int16_t
type
;
STagData
tagData
;
STagData
tagData
;
SArray
*
pAddColumns
;
// SArray<TAOS_FIELD>
SArray
*
pAddColumns
;
// SArray<TAOS_FIELD>
...
@@ -156,6 +157,7 @@ typedef struct tDCLSQL {
...
@@ -156,6 +157,7 @@ typedef struct tDCLSQL {
int32_t
nAlloc
;
/* Number of entries allocated below */
int32_t
nAlloc
;
/* Number of entries allocated below */
SStrToken
*
a
;
/* one entry for element */
SStrToken
*
a
;
/* one entry for element */
bool
existsCheck
;
bool
existsCheck
;
int16_t
tableType
;
union
{
union
{
SCreateDBInfo
dbOpt
;
SCreateDBInfo
dbOpt
;
...
@@ -250,7 +252,7 @@ SCreateTableSQL *tSetCreateSqlElems(SArray *pCols, SArray *pTags, SQuerySQL *pSe
...
@@ -250,7 +252,7 @@ SCreateTableSQL *tSetCreateSqlElems(SArray *pCols, SArray *pTags, SQuerySQL *pSe
void
tSqlExprNodeDestroy
(
tSQLExpr
*
pExpr
);
void
tSqlExprNodeDestroy
(
tSQLExpr
*
pExpr
);
SAlterTableSQL
*
tAlterTableSqlElems
(
SStrToken
*
pTableName
,
SArray
*
pCols
,
SArray
*
pVals
,
int32_t
type
);
SAlterTableSQL
*
tAlterTableSqlElems
(
SStrToken
*
pTableName
,
SArray
*
pCols
,
SArray
*
pVals
,
int32_t
type
,
int16_t
tableTable
);
SCreatedTableInfo
createNewChildTableInfo
(
SStrToken
*
pTableName
,
SArray
*
pTagVals
,
SStrToken
*
pToken
,
SStrToken
*
igExists
);
SCreatedTableInfo
createNewChildTableInfo
(
SStrToken
*
pTableName
,
SArray
*
pTagVals
,
SStrToken
*
pToken
,
SStrToken
*
igExists
);
void
destroyAllSelectClause
(
SSubclauseInfo
*
pSql
);
void
destroyAllSelectClause
(
SSubclauseInfo
*
pSql
);
...
@@ -267,7 +269,7 @@ void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pTableNameToken, SStrToken
...
@@ -267,7 +269,7 @@ void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pTableNameToken, SStrToken
void
SqlInfoDestroy
(
SSqlInfo
*
pInfo
);
void
SqlInfoDestroy
(
SSqlInfo
*
pInfo
);
void
setDCLSQLElems
(
SSqlInfo
*
pInfo
,
int32_t
type
,
int32_t
nParams
,
...);
void
setDCLSQLElems
(
SSqlInfo
*
pInfo
,
int32_t
type
,
int32_t
nParams
,
...);
void
setDropDbTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pToken
,
SStrToken
*
existsCheck
);
void
setDropDbTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pToken
,
SStrToken
*
existsCheck
,
int16_t
tableType
);
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
prefix
,
SStrToken
*
pPatterns
);
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
prefix
,
SStrToken
*
pPatterns
);
tDCLSQL
*
tTokenListAppend
(
tDCLSQL
*
pTokenList
,
SStrToken
*
pToken
);
tDCLSQL
*
tTokenListAppend
(
tDCLSQL
*
pTokenList
,
SStrToken
*
pToken
);
...
...
src/query/inc/sql.y
浏览文件 @
789fc754
...
@@ -131,10 +131,16 @@ cmd ::= SHOW dbPrefix(X) VGROUPS ids(Y). {
...
@@ -131,10 +131,16 @@ cmd ::= SHOW dbPrefix(X) VGROUPS ids(Y). {
//drop configure for tables
//drop configure for tables
cmd ::= DROP TABLE ifexists(Y) ids(X) cpxName(Z). {
cmd ::= DROP TABLE ifexists(Y) ids(X) cpxName(Z). {
X.n += Z.n;
X.n += Z.n;
setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &X, &Y);
setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &X, &Y
, -1
);
}
}
cmd ::= DROP DATABASE ifexists(Y) ids(X). { setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &X, &Y); }
//drop stable
cmd ::= DROP STABLE ifexists(Y) ids(X) cpxName(Z). {
X.n += Z.n;
setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &X, &Y, TSDB_SUPER_TABLE);
}
cmd ::= DROP DATABASE ifexists(Y) ids(X). { setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &X, &Y, -1); }
cmd ::= DROP DNODE ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_DNODE, 1, &X); }
cmd ::= DROP DNODE ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_DNODE, 1, &X); }
cmd ::= DROP USER ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_USER, 1, &X); }
cmd ::= DROP USER ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_USER, 1, &X); }
cmd ::= DROP ACCOUNT ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_ACCT, 1, &X); }
cmd ::= DROP ACCOUNT ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_ACCT, 1, &X); }
...
@@ -305,6 +311,8 @@ signed(A) ::= MINUS INTEGER(X). { A = -strtol(X.z, NULL, 10);}
...
@@ -305,6 +311,8 @@ signed(A) ::= MINUS INTEGER(X). { A = -strtol(X.z, NULL, 10);}
////////////////////////////////// The CREATE TABLE statement ///////////////////////////////
////////////////////////////////// The CREATE TABLE statement ///////////////////////////////
cmd ::= CREATE TABLE create_table_args. {}
cmd ::= CREATE TABLE create_table_args. {}
cmd ::= CREATE TABLE create_stable_args. {}
cmd ::= CREATE STABLE create_stable_args. {}
cmd ::= CREATE TABLE create_table_list(Z). { pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = Z;}
cmd ::= CREATE TABLE create_table_list(Z). { pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = Z;}
%type create_table_list{SCreateTableSQL*}
%type create_table_list{SCreateTableSQL*}
...
@@ -333,7 +341,8 @@ create_table_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) LP columnlist(X) RP. {
...
@@ -333,7 +341,8 @@ create_table_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) LP columnlist(X) RP. {
}
}
// create super table
// create super table
create_table_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) LP columnlist(X) RP TAGS LP columnlist(Y) RP. {
%type create_stable_args{SCreateTableSQL*}
create_stable_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) LP columnlist(X) RP TAGS LP columnlist(Y) RP. {
A = tSetCreateSqlElems(X, Y, NULL, TSQL_CREATE_STABLE);
A = tSetCreateSqlElems(X, Y, NULL, TSQL_CREATE_STABLE);
setSqlInfo(pInfo, A, NULL, TSDB_SQL_CREATE_TABLE);
setSqlInfo(pInfo, A, NULL, TSDB_SQL_CREATE_TABLE);
...
@@ -683,7 +692,7 @@ cmd ::= RESET QUERY CACHE. { setDCLSQLElems(pInfo, TSDB_SQL_RESET_CACHE, 0);}
...
@@ -683,7 +692,7 @@ cmd ::= RESET QUERY CACHE. { setDCLSQLElems(pInfo, TSDB_SQL_RESET_CACHE, 0);}
///////////////////////////////////ALTER TABLE statement//////////////////////////////////
///////////////////////////////////ALTER TABLE statement//////////////////////////////////
cmd ::= ALTER TABLE ids(X) cpxName(F) ADD COLUMN columnlist(A). {
cmd ::= ALTER TABLE ids(X) cpxName(F) ADD COLUMN columnlist(A). {
X.n += F.n;
X.n += F.n;
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_COLUMN);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_COLUMN
, -1
);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
}
...
@@ -693,14 +702,14 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
...
@@ -693,14 +702,14 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
toTSDBType(A.type);
toTSDBType(A.type);
SArray* K = tVariantListAppendToken(NULL, &A, -1);
SArray* K = tVariantListAppendToken(NULL, &A, -1);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN
, -1
);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
}
//////////////////////////////////ALTER TAGS statement/////////////////////////////////////
//////////////////////////////////ALTER TAGS statement/////////////////////////////////////
cmd ::= ALTER TABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
cmd ::= ALTER TABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
X.n += Y.n;
X.n += Y.n;
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN
, -1
);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
}
cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
...
@@ -709,7 +718,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
...
@@ -709,7 +718,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
toTSDBType(Y.type);
toTSDBType(Y.type);
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN
, -1
);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
}
...
@@ -722,7 +731,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
...
@@ -722,7 +731,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
toTSDBType(Z.type);
toTSDBType(Z.type);
A = tVariantListAppendToken(A, &Z, -1);
A = tVariantListAppendToken(A, &Z, -1);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN
, -1
);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
}
...
@@ -733,7 +742,54 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
...
@@ -733,7 +742,54 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
A = tVariantListAppend(A, &Z, -1);
A = tVariantListAppend(A, &Z, -1);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
///////////////////////////////////ALTER STABLE statement//////////////////////////////////
cmd ::= ALTER STABLE ids(X) cpxName(F) ADD COLUMN columnlist(A). {
X.n += F.n;
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
cmd ::= ALTER STABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
X.n += F.n;
toTSDBType(A.type);
SArray* K = tVariantListAppendToken(NULL, &A, -1);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
//////////////////////////////////ALTER TAGS statement/////////////////////////////////////
cmd ::= ALTER STABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
X.n += Y.n;
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
cmd ::= ALTER STABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
X.n += Z.n;
toTSDBType(Y.type);
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
cmd ::= ALTER STABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
X.n += F.n;
toTSDBType(Y.type);
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
toTSDBType(Z.type);
A = tVariantListAppendToken(A, &Z, -1);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
}
...
...
src/query/src/qParserImpl.c
浏览文件 @
789fc754
...
@@ -585,11 +585,12 @@ SCreatedTableInfo createNewChildTableInfo(SStrToken *pTableName, SArray *pTagVal
...
@@ -585,11 +585,12 @@ SCreatedTableInfo createNewChildTableInfo(SStrToken *pTableName, SArray *pTagVal
return
info
;
return
info
;
}
}
SAlterTableSQL
*
tAlterTableSqlElems
(
SStrToken
*
pTableName
,
SArray
*
pCols
,
SArray
*
pVals
,
int32_t
type
)
{
SAlterTableSQL
*
tAlterTableSqlElems
(
SStrToken
*
pTableName
,
SArray
*
pCols
,
SArray
*
pVals
,
int32_t
type
,
int16_t
tableType
)
{
SAlterTableSQL
*
pAlterTable
=
calloc
(
1
,
sizeof
(
SAlterTableSQL
));
SAlterTableSQL
*
pAlterTable
=
calloc
(
1
,
sizeof
(
SAlterTableSQL
));
pAlterTable
->
name
=
*
pTableName
;
pAlterTable
->
name
=
*
pTableName
;
pAlterTable
->
type
=
type
;
pAlterTable
->
type
=
type
;
pAlterTable
->
tableType
=
tableType
;
if
(
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
||
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
)
{
if
(
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
||
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
)
{
pAlterTable
->
pAddColumns
=
pCols
;
pAlterTable
->
pAddColumns
=
pCols
;
...
@@ -733,9 +734,10 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
...
@@ -733,9 +734,10 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
va_end
(
va
);
va_end
(
va
);
}
}
void
setDropDbTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pToken
,
SStrToken
*
existsCheck
)
{
void
setDropDbTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pToken
,
SStrToken
*
existsCheck
,
int16_t
tableType
)
{
pInfo
->
type
=
type
;
pInfo
->
type
=
type
;
pInfo
->
pDCLInfo
=
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pToken
);
pInfo
->
pDCLInfo
=
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pToken
);
pInfo
->
pDCLInfo
->
tableType
=
tableType
;
pInfo
->
pDCLInfo
->
existsCheck
=
(
existsCheck
->
n
==
1
);
pInfo
->
pDCLInfo
->
existsCheck
=
(
existsCheck
->
n
==
1
);
}
}
...
...
src/query/src/sql.c
浏览文件 @
789fc754
此差异已折叠。
点击以展开。
src/sync/src/syncMain.c
浏览文件 @
789fc754
...
@@ -568,7 +568,7 @@ static void syncStartCheckPeerConn(SSyncPeer *pPeer) {
...
@@ -568,7 +568,7 @@ static void syncStartCheckPeerConn(SSyncPeer *pPeer) {
int32_t
ret
=
strcmp
(
pPeer
->
fqdn
,
tsNodeFqdn
);
int32_t
ret
=
strcmp
(
pPeer
->
fqdn
,
tsNodeFqdn
);
if
(
pPeer
->
nodeId
==
0
||
(
ret
>
0
)
||
(
ret
==
0
&&
pPeer
->
port
>
tsSyncPort
))
{
if
(
pPeer
->
nodeId
==
0
||
(
ret
>
0
)
||
(
ret
==
0
&&
pPeer
->
port
>
tsSyncPort
))
{
int32_t
checkMs
=
100
+
(
pNode
->
vgId
*
10
)
%
100
;
int32_t
checkMs
=
100
+
(
pNode
->
vgId
*
10
)
%
100
;
if
(
pNode
->
vgId
>
1
)
checkMs
=
tsStatusInterval
*
1000
+
checkMs
;
sDebug
(
"%s, check peer connection after %d ms"
,
pPeer
->
id
,
checkMs
);
sDebug
(
"%s, check peer connection after %d ms"
,
pPeer
->
id
,
checkMs
);
taosTmrReset
(
syncCheckPeerConnection
,
checkMs
,
(
void
*
)
pPeer
->
rid
,
tsSyncTmrCtrl
,
&
pPeer
->
timer
);
taosTmrReset
(
syncCheckPeerConnection
,
checkMs
,
(
void
*
)
pPeer
->
rid
,
tsSyncTmrCtrl
,
&
pPeer
->
timer
);
}
}
...
...
tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java
浏览文件 @
789fc754
...
@@ -48,7 +48,6 @@ public class JDBCDemo {
...
@@ -48,7 +48,6 @@ public class JDBCDemo {
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
}
}
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
"host"
,
host
);
properties
.
setProperty
(
"charset"
,
"UTF-8"
);
properties
.
setProperty
(
"charset"
,
"UTF-8"
);
properties
.
setProperty
(
"locale"
,
"en_US.UTF-8"
);
properties
.
setProperty
(
"locale"
,
"en_US.UTF-8"
);
properties
.
setProperty
(
"timezone"
,
"UTC-8"
);
properties
.
setProperty
(
"timezone"
,
"UTC-8"
);
...
...
tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcRestfulDemo.java
0 → 100644
浏览文件 @
789fc754
package
com.taosdata.example
;
import
java.sql.*
;
import
java.util.Properties
;
public
class
JdbcRestfulDemo
{
private
static
final
String
host
=
"master"
;
public
static
void
main
(
String
[]
args
)
{
try
{
// load JDBC-restful driver
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
// use port 6041 in url when use JDBC-restful
String
url
=
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
;
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
"charset"
,
"UTF-8"
);
properties
.
setProperty
(
"locale"
,
"en_US.UTF-8"
);
properties
.
setProperty
(
"timezone"
,
"UTC-8"
);
Connection
conn
=
DriverManager
.
getConnection
(
url
,
properties
);
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"create database if not exists restful_test"
);
stmt
.
execute
(
"use restful_test"
);
stmt
.
execute
(
"create table restful_test.weather(ts timestamp, temperature float) tags(location nchar(64))"
);
stmt
.
executeUpdate
(
"insert into t1 using restful_test.weather tags('北京') values(now, 18.2)"
);
ResultSet
rs
=
stmt
.
executeQuery
(
"select * from restful_test.weather"
);
ResultSetMetaData
meta
=
rs
.
getMetaData
();
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
System
.
out
.
print
(
meta
.
getColumnLabel
(
i
)
+
": "
+
rs
.
getString
(
i
)
+
"\t"
);
}
System
.
out
.
println
();
}
stmt
.
close
();
conn
.
close
();
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
tests/examples/JDBC/taosdemo/pom.xml
浏览文件 @
789fc754
...
@@ -67,9 +67,9 @@
...
@@ -67,9 +67,9 @@
<dependency>
<dependency>
<groupId>
com.taosdata.jdbc
</groupId>
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.1
5
</version>
<version>
2.0.1
6
</version>
<scope>
system
</scope
>
<!-- <scope>system</scope>--
>
<systemPath>
${project.basedir}/src/main/resources/lib/taos-jdbcdriver-2.0.15-dist.jar
</systemPath
>
<!-- <systemPath>${project.basedir}/src/main/resources/lib/taos-jdbcdriver-2.0.15-dist.jar</systemPath>--
>
</dependency>
</dependency>
<!-- fastjson -->
<!-- fastjson -->
<dependency>
<dependency>
...
...
tests/examples/JDBC/taosdemo/src/main/resources/lib/taos-jdbcdriver-2.0.15-dist.jar
已删除
100644 → 0
浏览文件 @
c1ddf46e
文件已删除
tests/examples/nodejs/nodejsChecker.js
浏览文件 @
789fc754
const
taos
=
require
(
'
td2.0-connector
'
);
const
taos
=
require
(
'
td2.0-connector
'
);
//const taos = require('../../../src/connector/nodejs/');
var
host
=
null
;
var
host
=
null
;
...
...
tests/pytest/fulltest.sh
浏览文件 @
789fc754
...
@@ -259,4 +259,7 @@ python3 ./test.py -f update/merge_commit_last.py
...
@@ -259,4 +259,7 @@ python3 ./test.py -f update/merge_commit_last.py
python3 ./test.py
-f
update/bug_td2279.py
python3 ./test.py
-f
update/bug_td2279.py
# wal
# wal
python3 ./test.py
-f
wal/addOldWalTest.py
python3 ./test.py
-f
wal/addOldWalTest.py
\ No newline at end of file
# account
python3 ./test.py
-f
account/account_create.py
\ No newline at end of file
tests/script/general/http/restful_full.sim
浏览文件 @
789fc754
...
@@ -15,6 +15,7 @@ print =============== step1 - login
...
@@ -15,6 +15,7 @@ print =============== step1 - login
system_content curl 127.0.0.1:7111/rest/
system_content curl 127.0.0.1:7111/rest/
print 1-> $system_content
print 1-> $system_content
if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then
if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then
print $system_content
return -1
return -1
endi
endi
...
...
tests/script/general/parser/join.sim
浏览文件 @
789fc754
...
@@ -415,6 +415,7 @@ sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_m
...
@@ -415,6 +415,7 @@ sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_m
$val = 100
$val = 100
if $rows != $val then
if $rows != $val then
print $rows
return -1
return -1
endi
endi
...
@@ -514,4 +515,4 @@ sql drop table tm2;
...
@@ -514,4 +515,4 @@ sql drop table tm2;
sql select count(*) from m1, m2 where m1.ts=m2.ts and m1.b=m2.a;
sql select count(*) from m1, m2 where m1.ts=m2.ts and m1.b=m2.a;
sql drop database ux1;
sql drop database ux1;
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录