merge 3.0
This commit is contained in:
commit
eb79046a70
|
@ -2,7 +2,7 @@
|
||||||
IF (DEFINED VERNUMBER)
|
IF (DEFINED VERNUMBER)
|
||||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||||
ELSE ()
|
ELSE ()
|
||||||
SET(TD_VER_NUMBER "3.0.3.0")
|
SET(TD_VER_NUMBER "3.0.3.1")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (DEFINED VERCOMPATIBLE)
|
IF (DEFINED VERCOMPATIBLE)
|
||||||
|
|
|
@ -10,10 +10,11 @@ import TabItem from "@theme/TabItem";
|
||||||
`taospy` is the official Python connector for TDengine. taospy provides a rich API that makes it easy for Python applications to use TDengine. `taospy` wraps both the [native interface](/reference/connector/cpp) and [REST interface](/reference/rest-api) of TDengine, which correspond to the `taos` and `taosrest` modules of the `taospy` package, respectively.
|
`taospy` is the official Python connector for TDengine. taospy provides a rich API that makes it easy for Python applications to use TDengine. `taospy` wraps both the [native interface](/reference/connector/cpp) and [REST interface](/reference/rest-api) of TDengine, which correspond to the `taos` and `taosrest` modules of the `taospy` package, respectively.
|
||||||
In addition to wrapping the native and REST interfaces, `taospy` also provides a set of programming interfaces that conforms to the [Python Data Access Specification (PEP 249)](https://peps.python.org/pep-0249/). It is easy to integrate `taospy` with many third-party tools, such as [SQLAlchemy](https://www.sqlalchemy.org/) and [pandas](https://pandas.pydata.org/).
|
In addition to wrapping the native and REST interfaces, `taospy` also provides a set of programming interfaces that conforms to the [Python Data Access Specification (PEP 249)](https://peps.python.org/pep-0249/). It is easy to integrate `taospy` with many third-party tools, such as [SQLAlchemy](https://www.sqlalchemy.org/) and [pandas](https://pandas.pydata.org/).
|
||||||
|
|
||||||
The direct connection to the server using the native interface provided by the client driver is referred to hereinafter as a "native connection"; the connection to the server using the REST interface provided by taosAdapter is referred to hereinafter as a "REST connection".
|
`taos-ws-py` is an optional package to enable using WebSocket to connect TDengine.
|
||||||
|
|
||||||
|
The direct connection to the server using the native interface provided by the client driver is referred to hereinafter as a "native connection"; the connection to the server using the REST or WebSocket interface provided by taosAdapter is referred to hereinafter as a "REST connection" or "WebSocket connection".
|
||||||
|
|
||||||
The source code for the Python connector is hosted on [GitHub](https://github.com/taosdata/taos-connector-python).
|
The source code for the Python connector is hosted on [GitHub](https://github.com/taosdata/taos-connector-python).
|
||||||
|
|
||||||
## Supported platforms
|
## Supported platforms
|
||||||
|
|
||||||
- The [supported platforms](/reference/connector/#supported-platforms) for the native connection are the same as the ones supported by the TDengine client.
|
- The [supported platforms](/reference/connector/#supported-platforms) for the native connection are the same as the ones supported by the TDengine client.
|
||||||
|
@ -114,6 +115,15 @@ For REST connections, verifying that the `taosrest` module can be imported succe
|
||||||
import taosrest
|
import taosrest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value="ws" label="WebSocket connection">
|
||||||
|
|
||||||
|
For WebSocket connection, verifying that the `taosws` module can be imported successfully can be done in the Python Interactive Shell by typing.
|
||||||
|
|
||||||
|
```python
|
||||||
|
import taosws
|
||||||
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
@ -182,6 +192,28 @@ If the test is successful, it will output the server version information, e.g.
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value="ws" label="WebSocket connection" groupId="connect">
|
||||||
|
|
||||||
|
For WebSocket connection, make sure the cluster and taosAdapter component, are running. This can be testetd using the following `curl` command.
|
||||||
|
|
||||||
|
```
|
||||||
|
curl -i -N -d "show databases" -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: <FQDN>:<PORT>" -H "Origin: http://<FQDN>:<PORT>" http://<FQDN>:<PORT>/rest/sql
|
||||||
|
```
|
||||||
|
|
||||||
|
The FQDN above is the FQDN of the machine running taosAdapter, PORT is the port taosAdapter listening, default is `6041`.
|
||||||
|
|
||||||
|
If the test is successful, it will output the server version information, e.g.
|
||||||
|
|
||||||
|
```json
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json; charset=utf-8
|
||||||
|
Date: Tue, 21 Mar 2023 09:29:17 GMT
|
||||||
|
Transfer-Encoding: chunked
|
||||||
|
|
||||||
|
{"status":"succ","head":["server_version()"],"column_meta":[["server_version()",8,8]],"data":[["2.6.0.27"]],"rows":1}
|
||||||
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import PkgListV3 from "/components/PkgListV3";
|
||||||
|
|
||||||
Once the package is unzipped, you will see the following files in the directory:
|
Once the package is unzipped, you will see the following files in the directory:
|
||||||
- _ install_client.sh_: install script
|
- _ install_client.sh_: install script
|
||||||
- _ taos.tar.gz_: client driver package
|
- _ package.tar.gz_: client driver package
|
||||||
- _ driver_: TDengine client driver
|
- _ driver_: TDengine client driver
|
||||||
- _examples_: some example programs of different programming languages (C/C#/go/JDBC/MATLAB/python/R)
|
- _examples_: some example programs of different programming languages (C/C#/go/JDBC/MATLAB/python/R)
|
||||||
You can run `install_client.sh` to install it.
|
You can run `install_client.sh` to install it.
|
||||||
|
|
|
@ -10,6 +10,10 @@ For TDengine 2.x installation packages by version, please visit [here](https://w
|
||||||
|
|
||||||
import Release from "/components/ReleaseV3";
|
import Release from "/components/ReleaseV3";
|
||||||
|
|
||||||
|
## 3.0.3.1
|
||||||
|
|
||||||
|
<Release type="tdengine" version="3.0.3.1" />
|
||||||
|
|
||||||
## 3.0.3.0
|
## 3.0.3.0
|
||||||
|
|
||||||
<Release type="tdengine" version="3.0.3.0" />
|
<Release type="tdengine" version="3.0.3.0" />
|
||||||
|
|
|
@ -10,6 +10,10 @@ For other historical version installers, please visit [here](https://www.taosdat
|
||||||
|
|
||||||
import Release from "/components/ReleaseV3";
|
import Release from "/components/ReleaseV3";
|
||||||
|
|
||||||
|
## 2.4.10
|
||||||
|
|
||||||
|
<Release type="tools" version="2.4.10" />
|
||||||
|
|
||||||
## 2.4.9
|
## 2.4.9
|
||||||
|
|
||||||
<Release type="tools" version="2.4.9" />
|
<Release type="tools" version="2.4.9" />
|
||||||
|
|
|
@ -10,7 +10,9 @@ import TabItem from "@theme/TabItem";
|
||||||
`taospy` 是 TDengine 的官方 Python 连接器。`taospy` 提供了丰富的 API, 使得 Python 应用可以很方便地使用 TDengine。`taospy` 对 TDengine 的[原生接口](../cpp)和 [REST 接口](../rest-api)都进行了封装, 分别对应 `taospy` 包的 `taos` 模块 和 `taosrest` 模块。
|
`taospy` 是 TDengine 的官方 Python 连接器。`taospy` 提供了丰富的 API, 使得 Python 应用可以很方便地使用 TDengine。`taospy` 对 TDengine 的[原生接口](../cpp)和 [REST 接口](../rest-api)都进行了封装, 分别对应 `taospy` 包的 `taos` 模块 和 `taosrest` 模块。
|
||||||
除了对原生接口和 REST 接口的封装,`taospy` 还提供了符合 [Python 数据访问规范(PEP 249)](https://peps.python.org/pep-0249/) 的编程接口。这使得 `taospy` 和很多第三方工具集成变得简单,比如 [SQLAlchemy](https://www.sqlalchemy.org/) 和 [pandas](https://pandas.pydata.org/)。
|
除了对原生接口和 REST 接口的封装,`taospy` 还提供了符合 [Python 数据访问规范(PEP 249)](https://peps.python.org/pep-0249/) 的编程接口。这使得 `taospy` 和很多第三方工具集成变得简单,比如 [SQLAlchemy](https://www.sqlalchemy.org/) 和 [pandas](https://pandas.pydata.org/)。
|
||||||
|
|
||||||
使用客户端驱动提供的原生接口直接与服务端建立的连接的方式下文中称为“原生连接”;使用 taosAdapter 提供的 REST 接口与服务端建立的连接的方式下文中称为“REST 连接”。
|
`taos-ws-py` 是使用 WebSocket 方式连接 TDengine 的 Python 连接器包。可以选装。
|
||||||
|
|
||||||
|
使用客户端驱动提供的原生接口直接与服务端建立的连接的方式下文中称为“原生连接”;使用 taosAdapter 提供的 REST 接口或 WebSocket 接口与服务端建立的连接的方式下文中称为“REST 连接”或“WebSocket 连接”。
|
||||||
|
|
||||||
Python 连接器的源码托管在 [GitHub](https://github.com/taosdata/taos-connector-python)。
|
Python 连接器的源码托管在 [GitHub](https://github.com/taosdata/taos-connector-python)。
|
||||||
|
|
||||||
|
@ -115,6 +117,15 @@ import taos
|
||||||
import taosrest
|
import taosrest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value="ws" label="WebSocket 连接">
|
||||||
|
|
||||||
|
对于 WebSocket 连接,只需验证是否能成功导入 `taosws` 模块。可在 Python 交互式 Shell 中输入:
|
||||||
|
|
||||||
|
```python
|
||||||
|
import taosws
|
||||||
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
@ -183,6 +194,27 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value="ws" label="WebSocket 连接" groupId="connect">
|
||||||
|
|
||||||
|
对于 WebSocket 连接, 除了确保集群已经启动,还要确保 taosAdapter 组件已经启动。可以使用如下 curl 命令测试:
|
||||||
|
|
||||||
|
```
|
||||||
|
curl -i -N -d "show databases" -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: <FQDN>:<PORT>" -H "Origin: http://<FQDN>:<PORT>" http://<FQDN>:<PORT>/rest/sql
|
||||||
|
```
|
||||||
|
|
||||||
|
上面的 FQDN 为运行 taosAdapter 的机器的 FQDN, PORT 为 taosAdapter 配置的监听端口, 默认为 6041。
|
||||||
|
如果测试成功,会输出服务器版本信息,比如:
|
||||||
|
|
||||||
|
```json
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json; charset=utf-8
|
||||||
|
Date: Tue, 21 Mar 2023 09:29:17 GMT
|
||||||
|
Transfer-Encoding: chunked
|
||||||
|
|
||||||
|
{"status":"succ","head":["server_version()"],"column_meta":[["server_version()",8,8]],"data":[["2.6.0.27"]],"rows":1}
|
||||||
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import PkgListV3 from "/components/PkgListV3";
|
||||||
|
|
||||||
解压软件包之后,会在解压目录下看到以下文件(目录):
|
解压软件包之后,会在解压目录下看到以下文件(目录):
|
||||||
- _ install_client.sh_:安装脚本,用于应用驱动程序
|
- _ install_client.sh_:安装脚本,用于应用驱动程序
|
||||||
- _ taos.tar.gz_:应用驱动安装包
|
- _ package.tar.gz_:应用驱动安装包
|
||||||
- _ driver_:TDengine 应用驱动 driver
|
- _ driver_:TDengine 应用驱动 driver
|
||||||
- _examples_: 各种编程语言的示例程序(c/C#/go/JDBC/MATLAB/python/R)
|
- _examples_: 各种编程语言的示例程序(c/C#/go/JDBC/MATLAB/python/R)
|
||||||
运行 install_client.sh 进行安装。
|
运行 install_client.sh 进行安装。
|
||||||
|
|
|
@ -10,6 +10,10 @@ TDengine 2.x 各版本安装包请访问[这里](https://www.taosdata.com/all-do
|
||||||
|
|
||||||
import Release from "/components/ReleaseV3";
|
import Release from "/components/ReleaseV3";
|
||||||
|
|
||||||
|
## 3.0.3.1
|
||||||
|
|
||||||
|
<Release type="tdengine" version="3.0.3.1" />
|
||||||
|
|
||||||
## 3.0.3.0
|
## 3.0.3.0
|
||||||
|
|
||||||
<Release type="tdengine" version="3.0.3.0" />
|
<Release type="tdengine" version="3.0.3.0" />
|
||||||
|
|
|
@ -10,6 +10,10 @@ taosTools 各版本安装包下载链接如下:
|
||||||
|
|
||||||
import Release from "/components/ReleaseV3";
|
import Release from "/components/ReleaseV3";
|
||||||
|
|
||||||
|
## 2.4.10
|
||||||
|
|
||||||
|
<Release type="tools" version="2.4.10" />
|
||||||
|
|
||||||
## 2.4.9
|
## 2.4.9
|
||||||
|
|
||||||
<Release type="tools" version="2.4.9" />
|
<Release type="tools" version="2.4.9" />
|
||||||
|
|
|
@ -846,6 +846,8 @@ typedef struct {
|
||||||
int8_t replications;
|
int8_t replications;
|
||||||
int32_t sstTrigger;
|
int32_t sstTrigger;
|
||||||
int32_t minRows;
|
int32_t minRows;
|
||||||
|
int32_t walRetentionPeriod;
|
||||||
|
int32_t walRetentionSize;
|
||||||
} SAlterDbReq;
|
} SAlterDbReq;
|
||||||
|
|
||||||
int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq);
|
int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq);
|
||||||
|
|
|
@ -53,7 +53,7 @@ if [ -d ${top_dir}/tools/taos-tools/packaging/deb ]; then
|
||||||
cd ${top_dir}/tools/taos-tools/packaging/deb
|
cd ${top_dir}/tools/taos-tools/packaging/deb
|
||||||
[ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0"
|
[ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0"
|
||||||
|
|
||||||
taostools_ver=$(git tag |grep -v taos | sort | tail -1)
|
taostools_ver=$(git for-each-ref --sort=taggerdate --format '%(tag)' refs/tags|grep -v taos | tail -1)
|
||||||
taostools_install_dir="${release_dir}/${clientName2}Tools-${taostools_ver}"
|
taostools_install_dir="${release_dir}/${clientName2}Tools-${taostools_ver}"
|
||||||
|
|
||||||
cd ${curr_dir}
|
cd ${curr_dir}
|
||||||
|
|
|
@ -75,6 +75,14 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(JNIEnv *, jobject, jbyteArray, jlong);
|
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(JNIEnv *, jobject, jbyteArray, jlong);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: com_taosdata_jdbc_TSDBJNIConnector
|
||||||
|
* Method: executeQueryWithReqId
|
||||||
|
* Signature: ([BJJ)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryWithReqId(JNIEnv *, jobject, jbyteArray,
|
||||||
|
jlong, jlong);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: com_taosdata_jdbc_TSDBJNIConnector
|
* Class: com_taosdata_jdbc_TSDBJNIConnector
|
||||||
* Method: getErrCodeImp
|
* Method: getErrCodeImp
|
||||||
|
@ -186,6 +194,14 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtImp(JNIEnv *, jobject, jbyteArray, jlong);
|
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtImp(JNIEnv *, jobject, jbyteArray, jlong);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: com_taosdata_jdbc_TSDBJNIConnector
|
||||||
|
* Method: prepareStmtWithReqId
|
||||||
|
* Signature: ([BJJ)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtWithReqId(JNIEnv *, jobject, jbyteArray,
|
||||||
|
jlong, jlong);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: com_taosdata_jdbc_TSDBJNIConnector
|
* Class: com_taosdata_jdbc_TSDBJNIConnector
|
||||||
* Method: setBindTableNameImp
|
* Method: setBindTableNameImp
|
||||||
|
@ -260,6 +276,32 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(JN
|
||||||
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertImp(JNIEnv *, jobject, jobjectArray,
|
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertImp(JNIEnv *, jobject, jobjectArray,
|
||||||
jlong, jint, jint);
|
jlong, jint, jint);
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertWithReqId(JNIEnv *, jobject, jlong,
|
||||||
|
jobjectArray, jint, jint,
|
||||||
|
jlong);
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertWithTtl(JNIEnv *, jobject, jlong,
|
||||||
|
jobjectArray, jint, jint, jint);
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertWithTtlAndReqId(JNIEnv *, jobject,
|
||||||
|
jlong, jobjectArray,
|
||||||
|
jint, jint, jint,
|
||||||
|
jlong);
|
||||||
|
|
||||||
|
JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRaw(JNIEnv *, jobject, jlong, jstring,
|
||||||
|
jint, jint);
|
||||||
|
|
||||||
|
JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRawWithReqId(JNIEnv *, jobject, jlong,
|
||||||
|
jstring, jint, jint,
|
||||||
|
jlong);
|
||||||
|
|
||||||
|
JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRawWithTtl(JNIEnv *, jobject, jlong,
|
||||||
|
jstring, jint, jint, jint);
|
||||||
|
|
||||||
|
JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRawWithTtlAndReqId(JNIEnv *, jobject,
|
||||||
|
jlong, jstring,
|
||||||
|
jint, jint, jint,
|
||||||
|
jlong);
|
||||||
/**
|
/**
|
||||||
* Class: com_taosdata_jdbc_TSDBJNIConnector
|
* Class: com_taosdata_jdbc_TSDBJNIConnector
|
||||||
* Method: getTableVgID
|
* Method: getTableVgID
|
||||||
|
|
|
@ -331,13 +331,58 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(
|
||||||
int32_t code = taos_errno(tres);
|
int32_t code = taos_errno(tres);
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
jniError("jobj:%p, conn:%p, code:%s, msg:%s", jobj, tscon, tstrerror(code), taos_errstr(tres));
|
jniError("jobj:%p, conn:%p, code:0x%x, msg:%s", jobj, tscon, code, taos_errstr(tres));
|
||||||
} else {
|
} else {
|
||||||
if (taos_is_update_query(tres)) {
|
if (taos_is_update_query(tres)) {
|
||||||
int32_t affectRows = taos_affected_rows(tres);
|
int32_t affectRows = taos_affected_rows(tres);
|
||||||
jniDebug("jobj:%p, conn:%p, code:%s, affect rows:%d", jobj, tscon, tstrerror(code), affectRows);
|
jniDebug("jobj:%p, conn:%p, code:0x%x, affect rows:%d", jobj, tscon, code, affectRows);
|
||||||
} else {
|
} else {
|
||||||
jniDebug("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
jniDebug("jobj:%p, conn:%p, code:0x%x", jobj, tscon, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(str);
|
||||||
|
return (jlong)tres;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryWithReqId(JNIEnv *env, jobject jobj,
|
||||||
|
jbyteArray jsql, jlong con,
|
||||||
|
jlong reqId) {
|
||||||
|
TAOS *tscon = (TAOS *)con;
|
||||||
|
if (tscon == NULL) {
|
||||||
|
jniError("jobj:%p, connection already closed", jobj);
|
||||||
|
return JNI_CONNECTION_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jsql == NULL) {
|
||||||
|
jniError("jobj:%p, conn:%p, empty sql string", jobj, tscon);
|
||||||
|
return JNI_SQL_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
jsize len = (*env)->GetArrayLength(env, jsql);
|
||||||
|
|
||||||
|
char *str = (char *)taosMemoryCalloc(1, sizeof(char) * (len + 1));
|
||||||
|
if (str == NULL) {
|
||||||
|
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon);
|
||||||
|
return JNI_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*env)->GetByteArrayRegion(env, jsql, 0, len, (jbyte *)str);
|
||||||
|
if ((*env)->ExceptionCheck(env)) {
|
||||||
|
// todo handle error
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_RES *tres = taos_query_with_reqid(tscon, str, reqId);
|
||||||
|
int32_t code = taos_errno(tres);
|
||||||
|
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
jniError("jobj:%p, conn:%p, code:0x%x, msg:%s", jobj, tscon, code, taos_errstr(tres));
|
||||||
|
} else {
|
||||||
|
if (taos_is_update_query(tres)) {
|
||||||
|
int32_t affectRows = taos_affected_rows(tres);
|
||||||
|
jniDebug("jobj:%p, conn:%p, code:0x%x, affect rows:%d", jobj, tscon, code, affectRows);
|
||||||
|
} else {
|
||||||
|
jniDebug("jobj:%p, conn:%p, code:0x%x", jobj, tscon, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +534,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn
|
||||||
numOfFields);
|
numOfFields);
|
||||||
return JNI_FETCH_END;
|
return JNI_FETCH_END;
|
||||||
} else {
|
} else {
|
||||||
jniDebug("jobj:%p, conn:%p, interrupted query. fetch row error code: %d, msg:%s", jobj, tscon, code,
|
jniDebug("jobj:%p, conn:%p, interrupted query. fetch row error code: 0x%x, msg:%s", jobj, tscon, code,
|
||||||
taos_errstr(result));
|
taos_errstr(result));
|
||||||
return JNI_RESULT_SET_NULL;
|
return JNI_RESULT_SET_NULL;
|
||||||
}
|
}
|
||||||
|
@ -576,8 +621,8 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchBlockImp(JNI
|
||||||
|
|
||||||
int32_t numOfFields = taos_num_fields(tres);
|
int32_t numOfFields = taos_num_fields(tres);
|
||||||
if (numOfFields <= 0) {
|
if (numOfFields <= 0) {
|
||||||
jniError("jobj:%p, conn:%p, query interrupted. taos_num_fields error code:%d, msg:%s", jobj, tscon, numOfFields,
|
jniError("jobj:%p, conn:%p, query interrupted. taos_num_fields error code: 0x%x, msg:%s", jobj, tscon,
|
||||||
taos_errstr(tres));
|
taos_errno(tres), taos_errstr(tres));
|
||||||
return JNI_RESULT_SET_NULL;
|
return JNI_RESULT_SET_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,7 +634,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchBlockImp(JNI
|
||||||
jniDebug("jobj:%p, conn:%p, resultset:%p, no data to retrieve", jobj, tscon, (void *)res);
|
jniDebug("jobj:%p, conn:%p, resultset:%p, no data to retrieve", jobj, tscon, (void *)res);
|
||||||
return JNI_FETCH_END;
|
return JNI_FETCH_END;
|
||||||
} else {
|
} else {
|
||||||
jniError("jobj:%p, conn:%p, query interrupted. fetch block error code:%d, msg:%s", jobj, tscon, error_code,
|
jniError("jobj:%p, conn:%p, query interrupted. fetch block error code: 0x%x, msg:%s", jobj, tscon, error_code,
|
||||||
taos_errstr(tres));
|
taos_errstr(tres));
|
||||||
return JNI_RESULT_SET_NULL;
|
return JNI_RESULT_SET_NULL;
|
||||||
}
|
}
|
||||||
|
@ -639,7 +684,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab
|
||||||
}
|
}
|
||||||
|
|
||||||
int code = taos_validate_sql(tscon, str);
|
int code = taos_validate_sql(tscon, str);
|
||||||
jniDebug("jobj:%p, conn:%p, code is %d", jobj, tscon, code);
|
jniDebug("jobj:%p, conn:%p, code: 0x%x", jobj, tscon, code);
|
||||||
|
|
||||||
taosMemoryFreeClear(str);
|
taosMemoryFreeClear(str);
|
||||||
return code;
|
return code;
|
||||||
|
@ -704,7 +749,45 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtImp(J
|
||||||
int32_t code = taos_stmt_prepare(pStmt, str, len);
|
int32_t code = taos_stmt_prepare(pStmt, str, len);
|
||||||
taosMemoryFreeClear(str);
|
taosMemoryFreeClear(str);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
jniError("prepareStmt jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
jniError("prepareStmt jobj:%p, conn:%p, code: 0x%x", jobj, tscon, code);
|
||||||
|
return JNI_TDENGINE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (jlong)pStmt;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtWithReqId(JNIEnv *env, jobject jobj,
|
||||||
|
jbyteArray jsql, jlong con,
|
||||||
|
jlong reqId) {
|
||||||
|
TAOS *tscon = (TAOS *)con;
|
||||||
|
if (tscon == NULL) {
|
||||||
|
jniError("jobj:%p, connection already closed", jobj);
|
||||||
|
return JNI_CONNECTION_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jsql == NULL) {
|
||||||
|
jniError("jobj:%p, conn:%p, empty sql string", jobj, tscon);
|
||||||
|
return JNI_SQL_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
jsize len = (*env)->GetArrayLength(env, jsql);
|
||||||
|
|
||||||
|
char *str = (char *)taosMemoryCalloc(1, sizeof(char) * (len + 1));
|
||||||
|
if (str == NULL) {
|
||||||
|
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon);
|
||||||
|
return JNI_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*env)->GetByteArrayRegion(env, jsql, 0, len, (jbyte *)str);
|
||||||
|
if ((*env)->ExceptionCheck(env)) {
|
||||||
|
// todo handle error
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_STMT *pStmt = taos_stmt_init_with_reqid(tscon, reqId);
|
||||||
|
int32_t code = taos_stmt_prepare(pStmt, str, len);
|
||||||
|
taosMemoryFreeClear(str);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
jniError("prepareStmtWithReqId jobj:%p, conn:%p, code: 0x%x", jobj, tscon, code);
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -732,7 +815,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setBindTableNameI
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
(*env)->ReleaseStringUTFChars(env, jname, name);
|
(*env)->ReleaseStringUTFChars(env, jname, name);
|
||||||
|
|
||||||
jniError("bindTableName jobj:%p, conn:%p, code:%s", jobj, tsconn, tstrerror(code));
|
jniError("bindTableName jobj:%p, conn:%p, code: 0x%x", jobj, tsconn, code);
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,7 +890,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI
|
||||||
(*env)->ReleaseStringUTFChars(env, tableName, name);
|
(*env)->ReleaseStringUTFChars(env, tableName, name);
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
jniError("tableNameTags jobj:%p, conn:%p, code:%s", jobj, tsconn, tstrerror(code));
|
jniError("tableNameTags jobj:%p, conn:%p, code: 0x%x", jobj, tsconn, code);
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
return JNI_SUCCESS;
|
return JNI_SUCCESS;
|
||||||
|
@ -873,7 +956,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_bindColDataImp(
|
||||||
taosMemoryFreeClear(b);
|
taosMemoryFreeClear(b);
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
jniError("bindColData jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
jniError("bindColData jobj:%p, conn:%p, code: 0x%x", jobj, tscon, code);
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -896,7 +979,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_addBatchImp(JNIEn
|
||||||
|
|
||||||
int32_t code = taos_stmt_add_batch(pStmt);
|
int32_t code = taos_stmt_add_batch(pStmt);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
jniError("add batch jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
jniError("add batch jobj:%p, conn:%p, code: 0x%x", jobj, tscon, code);
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -920,7 +1003,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeBatchImp(J
|
||||||
|
|
||||||
int32_t code = taos_stmt_execute(pStmt);
|
int32_t code = taos_stmt_execute(pStmt);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
jniError("excute batch jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
jniError("excute batch jobj:%p, conn:%p, code: 0x%x", jobj, tscon, code);
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -944,7 +1027,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_closeStmt(JNIEnv
|
||||||
|
|
||||||
int32_t code = taos_stmt_close(pStmt);
|
int32_t code = taos_stmt_close(pStmt);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
jniError("close stmt jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
jniError("close stmt jobj:%p, conn:%p, code: 0x%x", jobj, tscon, code);
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,12 +1089,9 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(JN
|
||||||
|
|
||||||
TAOS_RES *tres = schemalessInsert(env, jobj, lines, taos, protocol, precision);
|
TAOS_RES *tres = schemalessInsert(env, jobj, lines, taos, protocol, precision);
|
||||||
|
|
||||||
if (tres == NULL) {
|
|
||||||
return JNI_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
int code = taos_errno(tres);
|
int code = taos_errno(tres);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
jniError("jobj:%p, conn:%p, code:%s, msg:%s", jobj, taos, tstrerror(code), taos_errstr(tres));
|
jniError("jobj:%p, conn:%p, code: 0x%x, msg:%s", jobj, taos, code, taos_errstr(tres));
|
||||||
taos_free_result(tres);
|
taos_free_result(tres);
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1030,12 +1110,247 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsert
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RES *tres = schemalessInsert(env, jobj, lines, taos, protocol, precision);
|
TAOS_RES *tres = schemalessInsert(env, jobj, lines, taos, protocol, precision);
|
||||||
if (tres == NULL) {
|
|
||||||
|
return (jlong)tres;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertWithReqId(
|
||||||
|
JNIEnv *env, jobject jobj, jlong conn, jobjectArray lines, jint protocol, jint precision, jlong reqId) {
|
||||||
|
TAOS *taos = (TAOS *)conn;
|
||||||
|
if (taos == NULL) {
|
||||||
|
jniError("jobj:%p, connection already closed", jobj);
|
||||||
|
return JNI_CONNECTION_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int numLines = (*env)->GetArrayLength(env, lines);
|
||||||
|
char **c_lines = taosMemoryCalloc(numLines, sizeof(char *));
|
||||||
|
if (c_lines == NULL) {
|
||||||
|
jniError("c_lines:%p, alloc memory failed", c_lines);
|
||||||
return JNI_OUT_OF_MEMORY;
|
return JNI_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < numLines; ++i) {
|
||||||
|
jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i));
|
||||||
|
c_lines[i] = (char *)(*env)->GetStringUTFChars(env, line, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_RES *tres = taos_schemaless_insert_with_reqid(taos, c_lines, numLines, protocol, precision, reqId);
|
||||||
|
|
||||||
|
for (int i = 0; i < numLines; ++i) {
|
||||||
|
jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i));
|
||||||
|
(*env)->ReleaseStringUTFChars(env, line, c_lines[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(c_lines);
|
||||||
|
|
||||||
return (jlong)tres;
|
return (jlong)tres;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertWithTtl(JNIEnv *env, jobject jobj,
|
||||||
|
jlong conn, jobjectArray lines,
|
||||||
|
jint protocol, jint precision,
|
||||||
|
jint ttl) {
|
||||||
|
TAOS *taos = (TAOS *)conn;
|
||||||
|
if (taos == NULL) {
|
||||||
|
jniError("jobj:%p, connection already closed", jobj);
|
||||||
|
return JNI_CONNECTION_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int numLines = (*env)->GetArrayLength(env, lines);
|
||||||
|
char **c_lines = taosMemoryCalloc(numLines, sizeof(char *));
|
||||||
|
if (c_lines == NULL) {
|
||||||
|
jniError("c_lines:%p, alloc memory failed", c_lines);
|
||||||
|
return JNI_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < numLines; ++i) {
|
||||||
|
jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i));
|
||||||
|
c_lines[i] = (char *)(*env)->GetStringUTFChars(env, line, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_RES *tres = taos_schemaless_insert_ttl(taos, c_lines, numLines, protocol, precision, ttl);
|
||||||
|
|
||||||
|
for (int i = 0; i < numLines; ++i) {
|
||||||
|
jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i));
|
||||||
|
(*env)->ReleaseStringUTFChars(env, line, c_lines[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(c_lines);
|
||||||
|
|
||||||
|
return (jlong)tres;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertWithTtlAndReqId(
|
||||||
|
JNIEnv *env, jobject jobj, jlong conn, jobjectArray lines, jint protocol, jint precision, jint ttl, jlong reqId) {
|
||||||
|
TAOS *taos = (TAOS *)conn;
|
||||||
|
if (taos == NULL) {
|
||||||
|
jniError("jobj:%p, connection already closed", jobj);
|
||||||
|
return JNI_CONNECTION_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int numLines = (*env)->GetArrayLength(env, lines);
|
||||||
|
char **c_lines = taosMemoryCalloc(numLines, sizeof(char *));
|
||||||
|
if (c_lines == NULL) {
|
||||||
|
jniError("c_lines:%p, alloc memory failed", c_lines);
|
||||||
|
return JNI_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < numLines; ++i) {
|
||||||
|
jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i));
|
||||||
|
c_lines[i] = (char *)(*env)->GetStringUTFChars(env, line, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_RES *tres = taos_schemaless_insert_ttl_with_reqid(taos, c_lines, numLines, protocol, precision, ttl, reqId);
|
||||||
|
|
||||||
|
for (int i = 0; i < numLines; ++i) {
|
||||||
|
jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i));
|
||||||
|
(*env)->ReleaseStringUTFChars(env, line, c_lines[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(c_lines);
|
||||||
|
|
||||||
|
return (jlong)tres;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jobject createSchemalessResp(JNIEnv *env, int totalRows, int code, const char *msg) {
|
||||||
|
// find class
|
||||||
|
jclass schemaless_clazz = (*env)->FindClass(env, "com/taosdata/jdbc/SchemalessResp");
|
||||||
|
// find methods
|
||||||
|
jmethodID init_method = (*env)->GetMethodID(env, schemaless_clazz, "<init>", "()V");
|
||||||
|
jmethodID setCode_method = (*env)->GetMethodID(env, schemaless_clazz, "setCode", "(I)V");
|
||||||
|
jmethodID setMsg_method = (*env)->GetMethodID(env, schemaless_clazz, "setMsg", "(Ljava/lang/String;)V");
|
||||||
|
jmethodID setTotalRows_method = (*env)->GetMethodID(env, schemaless_clazz, "setTotalRows", "(I)V");
|
||||||
|
// new schemaless
|
||||||
|
jobject schemaless_obj = (*env)->NewObject(env, schemaless_clazz, init_method);
|
||||||
|
// set code
|
||||||
|
(*env)->CallVoidMethod(env, schemaless_obj, setCode_method, code);
|
||||||
|
// set totalRows
|
||||||
|
(*env)->CallVoidMethod(env, schemaless_obj, setTotalRows_method, totalRows);
|
||||||
|
// set message
|
||||||
|
jstring message = (*env)->NewStringUTF(env, msg);
|
||||||
|
(*env)->CallVoidMethod(env, schemaless_obj, setMsg_method, message);
|
||||||
|
|
||||||
|
return schemaless_obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRaw(JNIEnv *env, jobject jobj,
|
||||||
|
jlong conn, jstring data,
|
||||||
|
jint protocol, jint precision) {
|
||||||
|
TAOS *taos = (TAOS *)conn;
|
||||||
|
if (taos == NULL) {
|
||||||
|
jniError("jobj:%p, connection already closed", jobj);
|
||||||
|
char *msg = "JNI connection is NULL";
|
||||||
|
return createSchemalessResp(env, 0, JNI_CONNECTION_NULL, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *line = (char *)(*env)->GetStringUTFChars(env, data, NULL);
|
||||||
|
jint len = (*env)->GetStringUTFLength(env, data);
|
||||||
|
int32_t totalRows;
|
||||||
|
TAOS_RES *tres = taos_schemaless_insert_raw(taos, line, len, &totalRows, protocol, precision);
|
||||||
|
|
||||||
|
(*env)->ReleaseStringUTFChars(env, data, line);
|
||||||
|
|
||||||
|
// if (tres == NULL) {
|
||||||
|
// jniError("jobj:%p, schemaless raw insert failed", jobj);
|
||||||
|
// char *msg = "JNI schemaless raw insert return null";
|
||||||
|
// return createSchemalessResp(env, 0, JNI_TDENGINE_ERROR, msg);
|
||||||
|
// }
|
||||||
|
|
||||||
|
int code = taos_errno(tres);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
jniError("jobj:%p, conn:%p, code: 0x%x, msg:%s", jobj, taos, code, taos_errstr(tres));
|
||||||
|
taos_free_result(tres);
|
||||||
|
return createSchemalessResp(env, 0, code, taos_errstr(tres));
|
||||||
|
}
|
||||||
|
taos_free_result(tres);
|
||||||
|
|
||||||
|
return createSchemalessResp(env, totalRows, JNI_SUCCESS, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRawWithReqId(
|
||||||
|
JNIEnv *env, jobject jobj, jlong conn, jstring data, jint protocol, jint precision, jlong reqId) {
|
||||||
|
TAOS *taos = (TAOS *)conn;
|
||||||
|
if (taos == NULL) {
|
||||||
|
jniError("jobj:%p, connection already closed", jobj);
|
||||||
|
char *msg = "JNI connection is NULL";
|
||||||
|
return createSchemalessResp(env, 0, JNI_CONNECTION_NULL, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *line = (char *)(*env)->GetStringUTFChars(env, data, NULL);
|
||||||
|
jint len = (*env)->GetStringUTFLength(env, data);
|
||||||
|
int32_t totalRows;
|
||||||
|
TAOS_RES *tres = taos_schemaless_insert_raw_with_reqid(taos, line, len, &totalRows, protocol, precision, reqId);
|
||||||
|
|
||||||
|
(*env)->ReleaseStringUTFChars(env, data, line);
|
||||||
|
|
||||||
|
int code = taos_errno(tres);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
jniError("jobj:%p, conn:%p, code: 0x%x, msg:%s", jobj, taos, code, taos_errstr(tres));
|
||||||
|
taos_free_result(tres);
|
||||||
|
return createSchemalessResp(env, 0, code, taos_errstr(tres));
|
||||||
|
}
|
||||||
|
taos_free_result(tres);
|
||||||
|
|
||||||
|
return createSchemalessResp(env, totalRows, JNI_SUCCESS, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRawWithTtl(JNIEnv *env, jobject jobj,
|
||||||
|
jlong conn, jstring data,
|
||||||
|
jint protocol,
|
||||||
|
jint precision, jint ttl) {
|
||||||
|
TAOS *taos = (TAOS *)conn;
|
||||||
|
if (taos == NULL) {
|
||||||
|
jniError("jobj:%p, connection already closed", jobj);
|
||||||
|
char *msg = "JNI connection is NULL";
|
||||||
|
return createSchemalessResp(env, 0, JNI_CONNECTION_NULL, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *line = (char *)(*env)->GetStringUTFChars(env, data, NULL);
|
||||||
|
jint len = (*env)->GetStringUTFLength(env, data);
|
||||||
|
int32_t totalRows;
|
||||||
|
TAOS_RES *tres = taos_schemaless_insert_raw_ttl(taos, line, len, &totalRows, protocol, precision, ttl);
|
||||||
|
|
||||||
|
(*env)->ReleaseStringUTFChars(env, data, line);
|
||||||
|
|
||||||
|
int code = taos_errno(tres);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
jniError("jobj:%p, conn:%p, code: 0x%x, msg:%s", jobj, taos, code, taos_errstr(tres));
|
||||||
|
taos_free_result(tres);
|
||||||
|
return createSchemalessResp(env, 0, code, taos_errstr(tres));
|
||||||
|
}
|
||||||
|
taos_free_result(tres);
|
||||||
|
|
||||||
|
return createSchemalessResp(env, totalRows, JNI_SUCCESS, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRawWithTtlAndReqId(
|
||||||
|
JNIEnv *env, jobject jobj, jlong conn, jstring data, jint protocol, jint precision, jint ttl, jlong reqId) {
|
||||||
|
TAOS *taos = (TAOS *)conn;
|
||||||
|
if (taos == NULL) {
|
||||||
|
jniError("jobj:%p, connection already closed", jobj);
|
||||||
|
char *msg = "JNI connection is NULL";
|
||||||
|
return createSchemalessResp(env, 0, JNI_CONNECTION_NULL, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *line = (char *)(*env)->GetStringUTFChars(env, data, NULL);
|
||||||
|
jint len = (*env)->GetStringUTFLength(env, data);
|
||||||
|
int32_t totalRows;
|
||||||
|
TAOS_RES *tres =
|
||||||
|
taos_schemaless_insert_raw_ttl_with_reqid(taos, line, len, &totalRows, protocol, precision, ttl, reqId);
|
||||||
|
|
||||||
|
(*env)->ReleaseStringUTFChars(env, data, line);
|
||||||
|
|
||||||
|
int code = taos_errno(tres);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
jniError("jobj:%p, conn:%p, code: 0x%x, msg:%s", jobj, taos, code, taos_errstr(tres));
|
||||||
|
taos_free_result(tres);
|
||||||
|
return createSchemalessResp(env, 0, code, taos_errstr(tres));
|
||||||
|
}
|
||||||
|
taos_free_result(tres);
|
||||||
|
|
||||||
|
return createSchemalessResp(env, totalRows, JNI_SUCCESS, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
// TABLE_VG_ID_FID_CACHE cache resp object for getTableVgID
|
// TABLE_VG_ID_FID_CACHE cache resp object for getTableVgID
|
||||||
typedef struct TABLE_VG_ID_FIELD_CACHE {
|
typedef struct TABLE_VG_ID_FIELD_CACHE {
|
||||||
int cached;
|
int cached;
|
||||||
|
|
|
@ -2219,6 +2219,8 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
||||||
if (tEncodeI8(&encoder, pReq->cacheLast) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->cacheLast) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->replications) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->replications) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->sstTrigger) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->sstTrigger) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->walRetentionPeriod) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->walRetentionSize) < 0) return -1;
|
||||||
|
|
||||||
// 1st modification
|
// 1st modification
|
||||||
if (tEncodeI32(&encoder, pReq->minRows) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->minRows) < 0) return -1;
|
||||||
|
@ -2250,6 +2252,13 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
||||||
if (tDecodeI8(&decoder, &pReq->cacheLast) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->cacheLast) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->replications) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->replications) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->sstTrigger) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->sstTrigger) < 0) return -1;
|
||||||
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
|
if (tDecodeI32(&decoder, &pReq->walRetentionPeriod) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->walRetentionSize) < 0) return -1;
|
||||||
|
} else {
|
||||||
|
pReq->walRetentionPeriod = -1;
|
||||||
|
pReq->walRetentionSize = -1;
|
||||||
|
}
|
||||||
|
|
||||||
// 1st modification
|
// 1st modification
|
||||||
if (!tDecodeIsEnd(&decoder)) {
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
|
|
|
@ -737,6 +737,20 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) {
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pAlter->walRetentionPeriod > TSDB_DB_MIN_WAL_RETENTION_PERIOD &&
|
||||||
|
pAlter->walRetentionPeriod != pDb->cfg.walRetentionPeriod) {
|
||||||
|
pDb->cfg.walRetentionPeriod = pAlter->walRetentionPeriod;
|
||||||
|
pDb->vgVersion++;
|
||||||
|
terrno = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pAlter->walRetentionSize > TSDB_DB_MIN_WAL_RETENTION_SIZE &&
|
||||||
|
pAlter->walRetentionSize != pDb->cfg.walRetentionSize) {
|
||||||
|
pDb->cfg.walRetentionSize = pAlter->walRetentionSize;
|
||||||
|
pDb->vgVersion++;
|
||||||
|
terrno = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -925,7 +925,12 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
taosMemoryFree(((SDescribeStmt*)pNode)->pMeta);
|
taosMemoryFree(((SDescribeStmt*)pNode)->pMeta);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_RESET_QUERY_CACHE_STMT: // no pointer field
|
case QUERY_NODE_RESET_QUERY_CACHE_STMT: // no pointer field
|
||||||
case QUERY_NODE_COMPACT_DATABASE_STMT: // no pointer field
|
case QUERY_NODE_COMPACT_DATABASE_STMT: {
|
||||||
|
SCompactDatabaseStmt* pStmt = (SCompactDatabaseStmt*)pNode;
|
||||||
|
nodesDestroyNode(pStmt->pStart);
|
||||||
|
nodesDestroyNode(pStmt->pEnd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case QUERY_NODE_CREATE_FUNCTION_STMT: // no pointer field
|
case QUERY_NODE_CREATE_FUNCTION_STMT: // no pointer field
|
||||||
case QUERY_NODE_DROP_FUNCTION_STMT: // no pointer field
|
case QUERY_NODE_DROP_FUNCTION_STMT: // no pointer field
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -237,6 +237,18 @@ alter_db_option(A) ::= REPLICA NK_INTEGER(B).
|
||||||
alter_db_option(A) ::= WAL_LEVEL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; }
|
alter_db_option(A) ::= WAL_LEVEL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; }
|
||||||
alter_db_option(A) ::= STT_TRIGGER NK_INTEGER(B). { A.type = DB_OPTION_STT_TRIGGER; A.val = B; }
|
alter_db_option(A) ::= STT_TRIGGER NK_INTEGER(B). { A.type = DB_OPTION_STT_TRIGGER; A.val = B; }
|
||||||
alter_db_option(A) ::= MINROWS NK_INTEGER(B). { A.type = DB_OPTION_MINROWS; A.val = B; }
|
alter_db_option(A) ::= MINROWS NK_INTEGER(B). { A.type = DB_OPTION_MINROWS; A.val = B; }
|
||||||
|
alter_db_option(A) ::= WAL_RETENTION_PERIOD NK_INTEGER(B). { A.type = DB_OPTION_WAL_RETENTION_PERIOD; A.val = B; }
|
||||||
|
alter_db_option(A) ::= WAL_RETENTION_PERIOD NK_MINUS(B) NK_INTEGER(C). {
|
||||||
|
SToken t = B;
|
||||||
|
t.n = (C.z + C.n) - B.z;
|
||||||
|
A.type = DB_OPTION_WAL_RETENTION_PERIOD; A.val = t;
|
||||||
|
}
|
||||||
|
alter_db_option(A) ::= WAL_RETENTION_SIZE NK_INTEGER(B). { A.type = DB_OPTION_WAL_RETENTION_SIZE; A.val = B; }
|
||||||
|
alter_db_option(A) ::= WAL_RETENTION_SIZE NK_MINUS(B) NK_INTEGER(C). {
|
||||||
|
SToken t = B;
|
||||||
|
t.n = (C.z + C.n) - B.z;
|
||||||
|
A.type = DB_OPTION_WAL_RETENTION_SIZE; A.val = t;
|
||||||
|
}
|
||||||
|
|
||||||
%type integer_list { SNodeList* }
|
%type integer_list { SNodeList* }
|
||||||
%destructor integer_list { nodesDestroyList($$); }
|
%destructor integer_list { nodesDestroyList($$); }
|
||||||
|
|
|
@ -925,8 +925,8 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) {
|
||||||
pOptions->numOfVgroups = -1;
|
pOptions->numOfVgroups = -1;
|
||||||
pOptions->singleStable = -1;
|
pOptions->singleStable = -1;
|
||||||
pOptions->schemaless = -1;
|
pOptions->schemaless = -1;
|
||||||
pOptions->walRetentionPeriod = -1;
|
pOptions->walRetentionPeriod = -2; // -1 is a valid value
|
||||||
pOptions->walRetentionSize = -1;
|
pOptions->walRetentionSize = -2; // -1 is a valid value
|
||||||
pOptions->walRollPeriod = -1;
|
pOptions->walRollPeriod = -1;
|
||||||
pOptions->walSegmentSize = -1;
|
pOptions->walSegmentSize = -1;
|
||||||
pOptions->sstTrigger = -1;
|
pOptions->sstTrigger = -1;
|
||||||
|
@ -935,7 +935,8 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) {
|
||||||
return (SNode*)pOptions;
|
return (SNode*)pOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, void* pVal) {
|
static SNode* setDatabaseOptionImpl(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, void* pVal,
|
||||||
|
bool alter) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SDatabaseOptions* pDbOptions = (SDatabaseOptions*)pOptions;
|
SDatabaseOptions* pDbOptions = (SDatabaseOptions*)pOptions;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -986,7 +987,9 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_REPLICA:
|
case DB_OPTION_REPLICA:
|
||||||
pDbOptions->replica = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
|
pDbOptions->replica = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
|
||||||
|
if (!alter) {
|
||||||
updateWalOptionsDefault(pDbOptions);
|
updateWalOptionsDefault(pDbOptions);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_STRICT:
|
case DB_OPTION_STRICT:
|
||||||
COPY_STRING_FORM_STR_TOKEN(pDbOptions->strictStr, (SToken*)pVal);
|
COPY_STRING_FORM_STR_TOKEN(pDbOptions->strictStr, (SToken*)pVal);
|
||||||
|
@ -1033,16 +1036,20 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti
|
||||||
return pOptions;
|
return pOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, void* pVal) {
|
||||||
|
return setDatabaseOptionImpl(pCxt, pOptions, type, pVal, false);
|
||||||
|
}
|
||||||
|
|
||||||
SNode* setAlterDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption) {
|
SNode* setAlterDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
switch (pAlterOption->type) {
|
switch (pAlterOption->type) {
|
||||||
case DB_OPTION_KEEP:
|
case DB_OPTION_KEEP:
|
||||||
case DB_OPTION_RETENTIONS:
|
case DB_OPTION_RETENTIONS:
|
||||||
return setDatabaseOption(pCxt, pOptions, pAlterOption->type, pAlterOption->pList);
|
return setDatabaseOptionImpl(pCxt, pOptions, pAlterOption->type, pAlterOption->pList, true);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return setDatabaseOption(pCxt, pOptions, pAlterOption->type, &pAlterOption->val);
|
return setDatabaseOptionImpl(pCxt, pOptions, pAlterOption->type, &pAlterOption->val, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* pDbName, SNode* pOptions) {
|
SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* pDbName, SNode* pOptions) {
|
||||||
|
|
|
@ -4254,6 +4254,8 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt,
|
||||||
pReq->replications = pStmt->pOptions->replica;
|
pReq->replications = pStmt->pOptions->replica;
|
||||||
pReq->sstTrigger = pStmt->pOptions->sstTrigger;
|
pReq->sstTrigger = pStmt->pOptions->sstTrigger;
|
||||||
pReq->minRows = pStmt->pOptions->minRowsPerBlock;
|
pReq->minRows = pStmt->pOptions->minRowsPerBlock;
|
||||||
|
pReq->walRetentionPeriod = pStmt->pOptions->walRetentionPeriod;
|
||||||
|
pReq->walRetentionSize = pStmt->pOptions->walRetentionSize;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6393,6 +6395,15 @@ static int32_t translateCreateFunction(STranslateContext* pCxt, SCreateFunctionS
|
||||||
if (fmIsBuiltinFunc(pStmt->funcName)) {
|
if (fmIsBuiltinFunc(pStmt->funcName)) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FUNCTION_NAME);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FUNCTION_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TSDB_DATA_TYPE_JSON == pStmt->outputDt.type ||
|
||||||
|
TSDB_DATA_TYPE_VARBINARY == pStmt->outputDt.type ||
|
||||||
|
TSDB_DATA_TYPE_DECIMAL == pStmt->outputDt.type ||
|
||||||
|
TSDB_DATA_TYPE_BLOB == pStmt->outputDt.type ||
|
||||||
|
TSDB_DATA_TYPE_MEDIUMBLOB == pStmt->outputDt.type) {
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, "Unsupported output type for UDF");
|
||||||
|
}
|
||||||
|
|
||||||
SCreateFuncReq req = {0};
|
SCreateFuncReq req = {0};
|
||||||
strcpy(req.name, pStmt->funcName);
|
strcpy(req.name, pStmt->funcName);
|
||||||
req.igExists = pStmt->ignoreExists;
|
req.igExists = pStmt->ignoreExists;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -109,7 +109,8 @@ TEST_F(ParserInitialATest, alterDnode) {
|
||||||
* | WAL_LEVEL int_value -- enum 1, 2, default 1
|
* | WAL_LEVEL int_value -- enum 1, 2, default 1
|
||||||
* | STT_TRIGGER int_value -- rang [1, 16], default 8
|
* | STT_TRIGGER int_value -- rang [1, 16], default 8
|
||||||
* | MINROWS int_value -- rang [10, 1000], default 100
|
* | MINROWS int_value -- rang [10, 1000], default 100
|
||||||
* }
|
* | WAL_RETENTION_PERIOD int_value -- rang [-1, INT32_MAX], default 0
|
||||||
|
* | WAL_RETENTION_SIZE int_value -- rang [-1, INT32_MAX], default 0
|
||||||
*/
|
*/
|
||||||
TEST_F(ParserInitialATest, alterDatabase) {
|
TEST_F(ParserInitialATest, alterDatabase) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
@ -135,6 +136,8 @@ TEST_F(ParserInitialATest, alterDatabase) {
|
||||||
expect.replications = -1;
|
expect.replications = -1;
|
||||||
expect.sstTrigger = -1;
|
expect.sstTrigger = -1;
|
||||||
expect.minRows = -1;
|
expect.minRows = -1;
|
||||||
|
expect.walRetentionPeriod = -2;
|
||||||
|
expect.walRetentionSize = -2;
|
||||||
};
|
};
|
||||||
auto setAlterDbBuffer = [&](int32_t buffer) { expect.buffer = buffer; };
|
auto setAlterDbBuffer = [&](int32_t buffer) { expect.buffer = buffer; };
|
||||||
auto setAlterDbPageSize = [&](int32_t pageSize) { expect.pageSize = pageSize; };
|
auto setAlterDbPageSize = [&](int32_t pageSize) { expect.pageSize = pageSize; };
|
||||||
|
@ -153,6 +156,10 @@ TEST_F(ParserInitialATest, alterDatabase) {
|
||||||
auto setAlterDbReplica = [&](int8_t replications) { expect.replications = replications; };
|
auto setAlterDbReplica = [&](int8_t replications) { expect.replications = replications; };
|
||||||
auto setAlterDbSttTrigger = [&](int8_t sstTrigger) { expect.sstTrigger = sstTrigger; };
|
auto setAlterDbSttTrigger = [&](int8_t sstTrigger) { expect.sstTrigger = sstTrigger; };
|
||||||
auto setAlterDbMinRows = [&](int32_t minRows) { expect.minRows = minRows; };
|
auto setAlterDbMinRows = [&](int32_t minRows) { expect.minRows = minRows; };
|
||||||
|
auto setAlterDbWalRetentionPeriod = [&](int32_t walRetentionPeriod) {
|
||||||
|
expect.walRetentionPeriod = walRetentionPeriod;
|
||||||
|
};
|
||||||
|
auto setAlterDbWalRetentionSize = [&](int32_t walRetentionSize) { expect.walRetentionSize = walRetentionSize; };
|
||||||
|
|
||||||
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||||
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_ALTER_DATABASE_STMT);
|
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_ALTER_DATABASE_STMT);
|
||||||
|
@ -174,6 +181,8 @@ TEST_F(ParserInitialATest, alterDatabase) {
|
||||||
ASSERT_EQ(req.replications, expect.replications);
|
ASSERT_EQ(req.replications, expect.replications);
|
||||||
ASSERT_EQ(req.sstTrigger, expect.sstTrigger);
|
ASSERT_EQ(req.sstTrigger, expect.sstTrigger);
|
||||||
ASSERT_EQ(req.minRows, expect.minRows);
|
ASSERT_EQ(req.minRows, expect.minRows);
|
||||||
|
ASSERT_EQ(req.walRetentionPeriod, expect.walRetentionPeriod);
|
||||||
|
ASSERT_EQ(req.walRetentionSize, expect.walRetentionSize);
|
||||||
});
|
});
|
||||||
|
|
||||||
const int32_t MINUTE_PER_DAY = MILLISECOND_PER_DAY / MILLISECOND_PER_MINUTE;
|
const int32_t MINUTE_PER_DAY = MILLISECOND_PER_DAY / MILLISECOND_PER_MINUTE;
|
||||||
|
@ -189,8 +198,10 @@ TEST_F(ParserInitialATest, alterDatabase) {
|
||||||
setAlterDbBuffer(16);
|
setAlterDbBuffer(16);
|
||||||
setAlterDbPages(128);
|
setAlterDbPages(128);
|
||||||
setAlterDbReplica(3);
|
setAlterDbReplica(3);
|
||||||
|
setAlterDbWalRetentionPeriod(10);
|
||||||
|
setAlterDbWalRetentionSize(20);
|
||||||
run("ALTER DATABASE test BUFFER 16 CACHEMODEL 'last_row' CACHESIZE 32 WAL_FSYNC_PERIOD 200 KEEP 10 PAGES 128 "
|
run("ALTER DATABASE test BUFFER 16 CACHEMODEL 'last_row' CACHESIZE 32 WAL_FSYNC_PERIOD 200 KEEP 10 PAGES 128 "
|
||||||
"REPLICA 3 WAL_LEVEL 1 STT_TRIGGER 16");
|
"REPLICA 3 WAL_LEVEL 1 STT_TRIGGER 16 WAL_RETENTION_PERIOD 10 WAL_RETENTION_SIZE 20");
|
||||||
clearAlterDbReq();
|
clearAlterDbReq();
|
||||||
|
|
||||||
initAlterDb("test");
|
initAlterDb("test");
|
||||||
|
@ -290,6 +301,20 @@ TEST_F(ParserInitialATest, alterDatabase) {
|
||||||
setAlterDbMinRows(1000);
|
setAlterDbMinRows(1000);
|
||||||
run("ALTER DATABASE test MINROWS 1000");
|
run("ALTER DATABASE test MINROWS 1000");
|
||||||
clearAlterDbReq();
|
clearAlterDbReq();
|
||||||
|
|
||||||
|
initAlterDb("test");
|
||||||
|
setAlterDbWalRetentionPeriod(-1);
|
||||||
|
run("ALTER DATABASE test WAL_RETENTION_PERIOD -1");
|
||||||
|
setAlterDbWalRetentionPeriod(50);
|
||||||
|
run("ALTER DATABASE test WAL_RETENTION_PERIOD 50");
|
||||||
|
clearAlterDbReq();
|
||||||
|
|
||||||
|
initAlterDb("test");
|
||||||
|
setAlterDbWalRetentionSize(-1);
|
||||||
|
run("ALTER DATABASE test WAL_RETENTION_SIZE -1");
|
||||||
|
setAlterDbWalRetentionSize(50);
|
||||||
|
run("ALTER DATABASE test WAL_RETENTION_SIZE 50");
|
||||||
|
clearAlterDbReq();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialATest, alterDatabaseSemanticCheck) {
|
TEST_F(ParserInitialATest, alterDatabaseSemanticCheck) {
|
||||||
|
@ -612,7 +637,9 @@ TEST_F(ParserInitialATest, alterTable) {
|
||||||
}
|
}
|
||||||
ASSERT_EQ(req.isNull, expect.isNull);
|
ASSERT_EQ(req.isNull, expect.isNull);
|
||||||
ASSERT_EQ(req.nTagVal, expect.nTagVal);
|
ASSERT_EQ(req.nTagVal, expect.nTagVal);
|
||||||
|
if (nullptr != req.pTagVal) {
|
||||||
ASSERT_EQ(memcmp(req.pTagVal, expect.pTagVal, expect.nTagVal), 0);
|
ASSERT_EQ(memcmp(req.pTagVal, expect.pTagVal, expect.nTagVal), 0);
|
||||||
|
}
|
||||||
ASSERT_EQ(req.updateTTL, expect.updateTTL);
|
ASSERT_EQ(req.updateTTL, expect.updateTTL);
|
||||||
ASSERT_EQ(req.newTTL, expect.newTTL);
|
ASSERT_EQ(req.newTTL, expect.newTTL);
|
||||||
if (nullptr != expect.newComment) {
|
if (nullptr != expect.newComment) {
|
||||||
|
|
|
@ -29,6 +29,9 @@ else
|
||||||
sql create function bit_and as '/tmp/udf/libbitand.so' outputtype int bufSize 8;
|
sql create function bit_and as '/tmp/udf/libbitand.so' outputtype int bufSize 8;
|
||||||
sql create aggregate function l2norm as '/tmp/udf/libl2norm.so' outputtype double bufSize 8;
|
sql create aggregate function l2norm as '/tmp/udf/libl2norm.so' outputtype double bufSize 8;
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql_error create function bit_and as '/tmp/udf/libbitand.so' oputtype json;
|
||||||
|
|
||||||
sql show functions;
|
sql show functions;
|
||||||
if $rows != 2 then
|
if $rows != 2 then
|
||||||
return -1
|
return -1
|
||||||
|
|
Loading…
Reference in New Issue