Merge branch 'develop' into docs/Update-Latest-Feature
This commit is contained in:
commit
60166d182c
|
@ -27,7 +27,6 @@ tests/hdfs/
|
||||||
nmake/
|
nmake/
|
||||||
sln/
|
sln/
|
||||||
hdfs/
|
hdfs/
|
||||||
c/
|
|
||||||
taoshebei/
|
taoshebei/
|
||||||
taosdalipu/
|
taosdalipu/
|
||||||
Target/
|
Target/
|
||||||
|
|
|
@ -16,6 +16,7 @@ SET(TD_GRANT FALSE)
|
||||||
SET(TD_MQTT FALSE)
|
SET(TD_MQTT FALSE)
|
||||||
SET(TD_TSDB_PLUGINS FALSE)
|
SET(TD_TSDB_PLUGINS FALSE)
|
||||||
SET(TD_STORAGE FALSE)
|
SET(TD_STORAGE FALSE)
|
||||||
|
SET(TD_TOPIC FALSE)
|
||||||
|
|
||||||
SET(TD_COVER FALSE)
|
SET(TD_COVER FALSE)
|
||||||
SET(TD_MEM_CHECK FALSE)
|
SET(TD_MEM_CHECK FALSE)
|
||||||
|
|
|
@ -227,6 +227,8 @@ pipeline {
|
||||||
./test-all.sh p4
|
./test-all.sh p4
|
||||||
cd ${WKC}/tests
|
cd ${WKC}/tests
|
||||||
./test-all.sh full jdbc
|
./test-all.sh full jdbc
|
||||||
|
cd ${WKC}/tests
|
||||||
|
./test-all.sh full unit
|
||||||
date'''
|
date'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,8 @@ mkdir debug && cd debug
|
||||||
cmake .. && cmake --build .
|
cmake .. && cmake --build .
|
||||||
```
|
```
|
||||||
|
|
||||||
To compile on an ARM processor (aarch64 or aarch32), please add option CPUTYPE as below:
|
TDengine build script can detect the host machine's architecture on X86-64, X86, arm64 and arm32 platform.
|
||||||
|
You can also specify CPUTYPE option like aarch64 or aarch32 too if the detection result is not correct:
|
||||||
|
|
||||||
aarch64:
|
aarch64:
|
||||||
```bash
|
```bash
|
||||||
|
|
|
@ -25,6 +25,10 @@ IF (TD_STORAGE)
|
||||||
ADD_DEFINITIONS(-D_STORAGE)
|
ADD_DEFINITIONS(-D_STORAGE)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
IF (TD_TOPIC)
|
||||||
|
ADD_DEFINITIONS(-D_TOPIC)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
IF (TD_GODLL)
|
IF (TD_GODLL)
|
||||||
ADD_DEFINITIONS(-D_TD_GO_DLL_)
|
ADD_DEFINITIONS(-D_TD_GO_DLL_)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
|
@ -9,6 +9,14 @@ ELSEIF (${ACCOUNT} MATCHES "false")
|
||||||
MESSAGE(STATUS "Build without account plugins")
|
MESSAGE(STATUS "Build without account plugins")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
IF (${TOPIC} MATCHES "true")
|
||||||
|
SET(TD_TOPIC TRUE)
|
||||||
|
MESSAGE(STATUS "Build with topic plugins")
|
||||||
|
ELSEIF (${TOPIC} MATCHES "false")
|
||||||
|
SET(TD_TOPIC FALSE)
|
||||||
|
MESSAGE(STATUS "Build without topic plugins")
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
IF (${COVER} MATCHES "true")
|
IF (${COVER} MATCHES "true")
|
||||||
SET(TD_COVER TRUE)
|
SET(TD_COVER TRUE)
|
||||||
MESSAGE(STATUS "Build with test coverage")
|
MESSAGE(STATUS "Build with test coverage")
|
||||||
|
|
|
@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS)
|
||||||
#INSTALL(TARGETS taos RUNTIME DESTINATION driver)
|
#INSTALL(TARGETS taos RUNTIME DESTINATION driver)
|
||||||
#INSTALL(TARGETS shell RUNTIME DESTINATION .)
|
#INSTALL(TARGETS shell RUNTIME DESTINATION .)
|
||||||
IF (TD_MVN_INSTALLED)
|
IF (TD_MVN_INSTALLED)
|
||||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.20-dist.jar DESTINATION connector/jdbc)
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.21-dist.jar DESTINATION connector/jdbc)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
ELSEIF (TD_DARWIN)
|
ELSEIF (TD_DARWIN)
|
||||||
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
|
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
|
||||||
|
|
|
@ -4,7 +4,7 @@ PROJECT(TDengine)
|
||||||
IF (DEFINED VERNUMBER)
|
IF (DEFINED VERNUMBER)
|
||||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||||
ELSE ()
|
ELSE ()
|
||||||
SET(TD_VER_NUMBER "2.0.16.0")
|
SET(TD_VER_NUMBER "2.0.17.0")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (DEFINED VERCOMPATIBLE)
|
IF (DEFINED VERCOMPATIBLE)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<!DOCTYPE html><html lang='en'><head><title>Documentation | Taos Data</title><meta name='description' content='TDengine is an open-source big data platform for IoT. Along with a 10x faster time-series database, it provides caching, stream computing, message queuing, and other functionalities. It is designed and optimized for Internet of Things, Connected Cars, and Industrial IoT. Read the documentation for TDengine here to get started right away.'><meta name='keywords' content='TDengine, Big Data, Open Source, IoT, Connected Cars, Industrial IoT, time-series database, caching, stream computing, message queuing, IT infrastructure monitoring, application performance monitoring, Internet of Things,TAOS Data, Documentation, programming, coding, syntax, frequently asked questions, questions, faq'><meta name='title' content='Documentation | Taos Data'><meta property='og:site_name' content='Taos Data'/><meta property='og:title' content='Documentation | Taos Data'/><meta property='og:type' content='article'/><meta property='og:url' content='https://www.taosdata.com/en/documentation/faq/index.php'/><meta property='og:description' content='TDengine is an open-source big data platform for IoT. Along with a 10x faster time-series database, it provides caching, stream computing, message queuing, and other functionalities. It is designed and optimized for Internet of Things, Connected Cars, and Industrial IoT. Read the documentation for TDengine here to get started right away.' /><link rel='canonical' href='https://www.taosdata.com/en/documentation/faq/index.php'/><script src='../lib/jquery-3.4.1.min.js' type='application/javascript'></script><link href='../lib/bootstrap.min.css' rel='stylesheet'><link href='../styles/base.min.css' rel='stylesheet'><link rel='stylesheet' href='../lib/docs/taosdataprettify.css'><link rel='stylesheet' href='../lib/docs/docs.css'><script src='../lib/docs/prettify.js'></script><script src='../lib/docs/prettyprint-sql.js'></script></head><body><script>$('#documentation-href').addClass('active')</script><div class='container-fluid'><main class='content-wrapper'><section class='documentation'><a href='../index.html'>Back</a><h1>FAQ</h1>
|
<!DOCTYPE html><html lang='en'><head><title>Documentation | Taos Data</title><meta name='description' content='TDengine is an open-source big data platform for IoT. Along with a 10x faster time-series database, it provides caching, stream computing, message queuing, and other functionalities. It is designed and optimized for Internet of Things, Connected Cars, and Industrial IoT. Read the documentation for TDengine here to get started right away.'><meta name='keywords' content='TDengine, Big Data, Open Source, IoT, Connected Cars, Industrial IoT, time-series database, caching, stream computing, message queuing, IT infrastructure monitoring, application performance monitoring, Internet of Things,TAOS Data, Documentation, programming, coding, syntax, frequently asked questions, questions, faq'><meta name='title' content='Documentation | Taos Data'><meta property='og:site_name' content='Taos Data'/><meta property='og:title' content='Documentation | Taos Data'/><meta property='og:type' content='article'/><meta property='og:url' content='https://www.taosdata.com/en/documentation/faq/index.php'/><meta property='og:description' content='TDengine is an open-source big data platform for IoT. Along with a 10x faster time-series database, it provides caching, stream computing, message queuing, and other functionalities. It is designed and optimized for Internet of Things, Connected Cars, and Industrial IoT. Read the documentation for TDengine here to get started right away.' /><link rel='canonical' href='https://www.taosdata.com/en/documentation/faq/index.php'/><script src='../lib/jquery-3.4.1.min.js' type='application/javascript'></script><link href='../lib/bootstrap.min.css' rel='stylesheet'><link href='../styles/base.min.css' rel='stylesheet'><link rel='stylesheet' href='../lib/docs/taosdataprettify.css'><link rel='stylesheet' href='../lib/docs/docs.css'><script src='../lib/docs/prettify.js'></script><script src='../lib/docs/prettyprint-sql.js'></script></head><body><script>$('#documentation-href').addClass('active')</script><div class='container-fluid'><main class='content-wrapper'><section class='documentation'><a href='../index.html'>Back</a><h1>FAQ</h1>
|
||||||
<h4>1. When encoutered with the error "failed to connect to server", what can I do?</h4>
|
<h4>1. When encountered with the error "failed to connect to server", what can I do?</h4>
|
||||||
<p>The client may encounter connection errors. Please follow the steps below for troubleshooting:</p>
|
<p>The client may encounter connection errors. Please follow the steps below for troubleshooting:</p>
|
||||||
<ol>
|
<ol>
|
||||||
<li>On the server side, execute <code>systemctl status taosd</code> to check the status of <em>taosd</em> service. If <em>taosd</em> is not running, start it and retry connecting.</li>
|
<li>On the server side, execute <code>systemctl status taosd</code> to check the status of <em>taosd</em> service. If <em>taosd</em> is not running, start it and retry connecting.</li>
|
||||||
|
|
|
@ -31,6 +31,20 @@ TDengine是一个高效的存储、查询、分析时序大数据的平台,专
|
||||||
* [创建超级表](/model#create-stable):为同一类型的数据采集点创建一个超级表
|
* [创建超级表](/model#create-stable):为同一类型的数据采集点创建一个超级表
|
||||||
* [创建表](/model#create-table):使用超级表做模板,为每一个具体的数据采集点单独建表
|
* [创建表](/model#create-table):使用超级表做模板,为每一个具体的数据采集点单独建表
|
||||||
|
|
||||||
|
## [TAOS SQL](/taos-sql)
|
||||||
|
|
||||||
|
* [支持的数据类型](/taos-sql#data-type):支持时间戳、整型、浮点型、布尔型、字符型等多种数据类型
|
||||||
|
* [数据库管理](/taos-sql#management):添加、删除、查看数据库
|
||||||
|
* [表管理](/taos-sql#table):添加、删除、查看、修改表
|
||||||
|
* [超级表管理](/taos-sql#super-table):添加、删除、查看、修改超级表
|
||||||
|
* [标签管理](/taos-sql#tags):增加、删除、修改标签
|
||||||
|
* [数据写入](/taos-sql#insert):支持单表单条、多条、多表多条写入,支持历史数据写入
|
||||||
|
* [数据查询](/taos-sql#select):支持时间段、值过滤、排序、查询结果手动分页等
|
||||||
|
* [SQL函数](/taos-sql#functions):支持各种聚合函数、选择函数、计算函数,如avg, min, diff等
|
||||||
|
* [时间维度聚合](/taos-sql#aggregation):将表中数据按照时间段进行切割后聚合,降维处理
|
||||||
|
* [边界限制](/taos-sql#limitation):库、表、SQL等边界限制条件
|
||||||
|
* [错误码](/taos-sql/error-code):TDengine 2.0 错误码以及对应的十进制码
|
||||||
|
|
||||||
## [高效写入数据](/insert)
|
## [高效写入数据](/insert)
|
||||||
|
|
||||||
* [SQL写入](/insert#sql):使用SQL insert命令向一张或多张表写入单条或多条记录
|
* [SQL写入](/insert#sql):使用SQL insert命令向一张或多张表写入单条或多条记录
|
||||||
|
@ -94,20 +108,6 @@ TDengine是一个高效的存储、查询、分析时序大数据的平台,专
|
||||||
* [文件目录结构](/administrator#directories):TDengine数据文件、配置文件等所在目录
|
* [文件目录结构](/administrator#directories):TDengine数据文件、配置文件等所在目录
|
||||||
* [参数限制与保留关键字](/administrator#keywords):TDengine的参数限制与保留关键字列表
|
* [参数限制与保留关键字](/administrator#keywords):TDengine的参数限制与保留关键字列表
|
||||||
|
|
||||||
## [TAOS SQL](/taos-sql)
|
|
||||||
|
|
||||||
* [支持的数据类型](/taos-sql#data-type):支持时间戳、整型、浮点型、布尔型、字符型等多种数据类型
|
|
||||||
* [数据库管理](/taos-sql#management):添加、删除、查看数据库
|
|
||||||
* [表管理](/taos-sql#table):添加、删除、查看、修改表
|
|
||||||
* [超级表管理](/taos-sql#super-table):添加、删除、查看、修改超级表
|
|
||||||
* [标签管理](/taos-sql#tags):增加、删除、修改标签
|
|
||||||
* [数据写入](/taos-sql#insert):支持单表单条、多条、多表多条写入,支持历史数据写入
|
|
||||||
* [数据查询](/taos-sql#select):支持时间段、值过滤、排序、查询结果手动分页等
|
|
||||||
* [SQL函数](/taos-sql#functions):支持各种聚合函数、选择函数、计算函数,如avg, min, diff等
|
|
||||||
* [时间维度聚合](/taos-sql#aggregation):将表中数据按照时间段进行切割后聚合,降维处理
|
|
||||||
* [边界限制](/taos-sql#limitation):库、表、SQL等边界限制条件
|
|
||||||
* [错误码](/taos-sql/error-code):TDengine 2.0 错误码以及对应的十进制码
|
|
||||||
|
|
||||||
## TDengine的技术设计
|
## TDengine的技术设计
|
||||||
|
|
||||||
* [系统模块](/architecture/taosd):taosd的功能和模块划分
|
* [系统模块](/architecture/taosd):taosd的功能和模块划分
|
||||||
|
|
|
@ -12,10 +12,13 @@ RUN tar -zxf ${pkgFile}
|
||||||
WORKDIR /root/${dirName}/
|
WORKDIR /root/${dirName}/
|
||||||
RUN /bin/bash install.sh -e no
|
RUN /bin/bash install.sh -e no
|
||||||
|
|
||||||
|
RUN apt-get clean && apt-get update && apt-get install -y locales
|
||||||
|
RUN locale-gen en_US.UTF-8
|
||||||
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib"
|
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib"
|
||||||
|
ENV LC_CTYPE=en_US.UTF-8
|
||||||
ENV LANG=en_US.UTF-8
|
ENV LANG=en_US.UTF-8
|
||||||
ENV LANGUAGE=en_US:en
|
|
||||||
ENV LC_ALL=en_US.UTF-8
|
ENV LC_ALL=en_US.UTF-8
|
||||||
|
|
||||||
EXPOSE 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042
|
EXPOSE 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042
|
||||||
CMD ["taosd"]
|
CMD ["taosd"]
|
||||||
VOLUME [ "/var/lib/taos", "/var/log/taos","/etc/taos/" ]
|
VOLUME [ "/var/lib/taos", "/var/log/taos","/etc/taos/" ]
|
||||||
|
|
|
@ -36,10 +36,10 @@ done
|
||||||
echo "verNumber=${verNumber}"
|
echo "verNumber=${verNumber}"
|
||||||
|
|
||||||
#docker manifest create -a tdengine/tdengine:${verNumber} tdengine/tdengine-amd64:${verNumber} tdengine/tdengine-aarch64:${verNumber} tdengine/tdengine-aarch32:${verNumber}
|
#docker manifest create -a tdengine/tdengine:${verNumber} tdengine/tdengine-amd64:${verNumber} tdengine/tdengine-aarch64:${verNumber} tdengine/tdengine-aarch32:${verNumber}
|
||||||
docker manifest create -a tdengine/tdengine tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest
|
docker manifest create -a tdengine/tdengine:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest
|
||||||
|
|
||||||
docker login -u tdengine -p ${passWord} #replace the docker registry username and password
|
docker login -u tdengine -p ${passWord} #replace the docker registry username and password
|
||||||
|
|
||||||
docker manifest push tdengine/tdengine
|
docker manifest push tdengine/tdengine:latest
|
||||||
|
|
||||||
# how set latest version ???
|
# how set latest version ???
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: tdengine
|
name: tdengine
|
||||||
base: core18
|
base: core18
|
||||||
version: '2.0.16.0'
|
version: '2.0.17.0'
|
||||||
icon: snap/gui/t-dengine.svg
|
icon: snap/gui/t-dengine.svg
|
||||||
summary: an open-source big data platform designed and optimized for IoT.
|
summary: an open-source big data platform designed and optimized for IoT.
|
||||||
description: |
|
description: |
|
||||||
|
@ -72,7 +72,7 @@ parts:
|
||||||
- usr/bin/taosd
|
- usr/bin/taosd
|
||||||
- usr/bin/taos
|
- usr/bin/taos
|
||||||
- usr/bin/taosdemo
|
- usr/bin/taosdemo
|
||||||
- usr/lib/libtaos.so.2.0.16.0
|
- usr/lib/libtaos.so.2.0.17.0
|
||||||
- usr/lib/libtaos.so.1
|
- usr/lib/libtaos.so.1
|
||||||
- usr/lib/libtaos.so
|
- usr/lib/libtaos.so
|
||||||
|
|
||||||
|
|
|
@ -270,7 +270,7 @@ void tscPrintSelectClause(SSqlObj* pSql, int32_t subClauseIndex);
|
||||||
bool hasMoreVnodesToTry(SSqlObj *pSql);
|
bool hasMoreVnodesToTry(SSqlObj *pSql);
|
||||||
bool hasMoreClauseToTry(SSqlObj* pSql);
|
bool hasMoreClauseToTry(SSqlObj* pSql);
|
||||||
|
|
||||||
void tscFreeQueryInfo(SSqlCmd* pCmd);
|
void tscFreeQueryInfo(SSqlCmd* pCmd, bool removeMeta);
|
||||||
|
|
||||||
void tscTryQueryNextVnode(SSqlObj *pSql, __async_cb_func_t fp);
|
void tscTryQueryNextVnode(SSqlObj *pSql, __async_cb_func_t fp);
|
||||||
void tscAsyncQuerySingleRowForNextVnode(void *param, TAOS_RES *tres, int numOfRows);
|
void tscAsyncQuerySingleRowForNextVnode(void *param, TAOS_RES *tres, int numOfRows);
|
||||||
|
|
|
@ -442,6 +442,8 @@ void tscCloseTscObj(void *pObj);
|
||||||
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int),
|
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int),
|
||||||
void *param, TAOS **taos);
|
void *param, TAOS **taos);
|
||||||
TAOS_RES* taos_query_h(TAOS* taos, const char *sqlstr, int64_t* res);
|
TAOS_RES* taos_query_h(TAOS* taos, const char *sqlstr, int64_t* res);
|
||||||
|
TAOS_RES * taos_query_ra(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, void *param);
|
||||||
|
|
||||||
void waitForQueryRsp(void *param, TAOS_RES *tres, int code);
|
void waitForQueryRsp(void *param, TAOS_RES *tres, int code);
|
||||||
|
|
||||||
void doAsyncQuery(STscObj *pObj, SSqlObj *pSql, __async_cb_func_t fp, void *param, const char *sqlstr, size_t sqlLen);
|
void doAsyncQuery(STscObj *pObj, SSqlObj *pSql, __async_cb_func_t fp, void *param, const char *sqlstr, size_t sqlLen);
|
||||||
|
|
|
@ -74,12 +74,16 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, __async_cb_func_t fp, void* para
|
||||||
|
|
||||||
// TODO return the correct error code to client in tscQueueAsyncError
|
// TODO return the correct error code to client in tscQueueAsyncError
|
||||||
void taos_query_a(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, void *param) {
|
void taos_query_a(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, void *param) {
|
||||||
|
taos_query_ra(taos, sqlstr, fp, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_RES * taos_query_ra(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, void *param) {
|
||||||
STscObj *pObj = (STscObj *)taos;
|
STscObj *pObj = (STscObj *)taos;
|
||||||
if (pObj == NULL || pObj->signature != pObj) {
|
if (pObj == NULL || pObj->signature != pObj) {
|
||||||
tscError("bug!!! pObj:%p", pObj);
|
tscError("bug!!! pObj:%p", pObj);
|
||||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
tscQueueAsyncError(fp, param, TSDB_CODE_TSC_DISCONNECTED);
|
tscQueueAsyncError(fp, param, TSDB_CODE_TSC_DISCONNECTED);
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sqlLen = (int32_t)strlen(sqlstr);
|
int32_t sqlLen = (int32_t)strlen(sqlstr);
|
||||||
|
@ -87,7 +91,7 @@ void taos_query_a(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, void *pa
|
||||||
tscError("sql string exceeds max length:%d", tsMaxSQLStringLen);
|
tscError("sql string exceeds max length:%d", tsMaxSQLStringLen);
|
||||||
terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT;
|
terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT;
|
||||||
tscQueueAsyncError(fp, param, terrno);
|
tscQueueAsyncError(fp, param, terrno);
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
nPrintTsc("%s", sqlstr);
|
nPrintTsc("%s", sqlstr);
|
||||||
|
@ -96,12 +100,15 @@ void taos_query_a(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, void *pa
|
||||||
if (pSql == NULL) {
|
if (pSql == NULL) {
|
||||||
tscError("failed to malloc sqlObj");
|
tscError("failed to malloc sqlObj");
|
||||||
tscQueueAsyncError(fp, param, TSDB_CODE_TSC_OUT_OF_MEMORY);
|
tscQueueAsyncError(fp, param, TSDB_CODE_TSC_OUT_OF_MEMORY);
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
doAsyncQuery(pObj, pSql, fp, param, sqlstr, sqlLen);
|
doAsyncQuery(pObj, pSql, fp, param, sqlstr, sqlLen);
|
||||||
|
|
||||||
|
return pSql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void tscAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOfRows) {
|
static void tscAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOfRows) {
|
||||||
if (tres == NULL) {
|
if (tres == NULL) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1872,6 +1872,24 @@ void setResultColName(char* name, tSqlExprItem* pItem, int32_t functionId, SStrT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void setLastOrderForGoupBy(SQueryInfo* pQueryInfo, STableMetaInfo* pTableMetaInfo) { // todo refactor
|
||||||
|
SSqlGroupbyExpr* pGroupBy = &pQueryInfo->groupbyExpr;
|
||||||
|
if (pGroupBy->numOfGroupCols > 0) {
|
||||||
|
size_t idx = taosArrayGetSize(pQueryInfo->exprList);
|
||||||
|
for(int32_t k = 0; k < pGroupBy->numOfGroupCols; ++k) {
|
||||||
|
SColIndex* pIndex = taosArrayGet(pGroupBy->columnInfo, k);
|
||||||
|
if (!TSDB_COL_IS_TAG(pIndex->flag) && pIndex->colIndex < tscGetNumOfColumns(pTableMetaInfo->pTableMeta)) { // group by normal columns
|
||||||
|
SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, idx - 1);
|
||||||
|
pExpr->numOfParams = 1;
|
||||||
|
pExpr->param->i64 = TSDB_ORDER_ASC;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t colIndex, tSqlExprItem* pItem, bool finalResult) {
|
int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t colIndex, tSqlExprItem* pItem, bool finalResult) {
|
||||||
STableMetaInfo* pTableMetaInfo = NULL;
|
STableMetaInfo* pTableMetaInfo = NULL;
|
||||||
int32_t optr = pItem->pNode->nSQLOptr;
|
int32_t optr = pItem->pNode->nSQLOptr;
|
||||||
|
@ -2152,6 +2170,10 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
||||||
if (setExprInfoForFunctions(pCmd, pQueryInfo, &pSchema[j], cvtFunc, name, colIndex++, &index, finalResult) != 0) {
|
if (setExprInfoForFunctions(pCmd, pQueryInfo, &pSchema[j], cvtFunc, name, colIndex++, &index, finalResult) != 0) {
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (optr == TK_LAST) {
|
||||||
|
setLastOrderForGoupBy(pQueryInfo, pTableMetaInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -2173,24 +2195,12 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
||||||
bool multiColOutput = pItem->pNode->pParam->nExpr > 1;
|
bool multiColOutput = pItem->pNode->pParam->nExpr > 1;
|
||||||
setResultColName(name, pItem, cvtFunc.originFuncId, &pParamElem->pNode->colInfo, multiColOutput);
|
setResultColName(name, pItem, cvtFunc.originFuncId, &pParamElem->pNode->colInfo, multiColOutput);
|
||||||
|
|
||||||
if (setExprInfoForFunctions(pCmd, pQueryInfo, pSchema, cvtFunc, name, colIndex + i, &index, finalResult) != 0) {
|
if (setExprInfoForFunctions(pCmd, pQueryInfo, pSchema, cvtFunc, name, colIndex++, &index, finalResult) != 0) {
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optr == TK_LAST) { // todo refactor
|
if (optr == TK_LAST) {
|
||||||
SSqlGroupbyExpr* pGroupBy = &pQueryInfo->groupbyExpr;
|
setLastOrderForGoupBy(pQueryInfo, pTableMetaInfo);
|
||||||
if (pGroupBy->numOfGroupCols > 0) {
|
|
||||||
for(int32_t k = 0; k < pGroupBy->numOfGroupCols; ++k) {
|
|
||||||
SColIndex* pIndex = taosArrayGet(pGroupBy->columnInfo, k);
|
|
||||||
if (!TSDB_COL_IS_TAG(pIndex->flag) && pIndex->colIndex < tscGetNumOfColumns(pTableMetaInfo->pTableMeta)) { // group by normal columns
|
|
||||||
SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, colIndex + i);
|
|
||||||
pExpr->numOfParams = 1;
|
|
||||||
pExpr->param->i64 = TSDB_ORDER_ASC;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2220,6 +2230,10 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
||||||
}
|
}
|
||||||
|
|
||||||
colIndex++;
|
colIndex++;
|
||||||
|
|
||||||
|
if (optr == TK_LAST) {
|
||||||
|
setLastOrderForGoupBy(pQueryInfo, pTableMetaInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfFields += tscGetNumOfColumns(pTableMetaInfo->pTableMeta);
|
numOfFields += tscGetNumOfColumns(pTableMetaInfo->pTableMeta);
|
||||||
|
@ -5614,6 +5628,8 @@ static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDbInfo* pCreateDb) {
|
||||||
pMsg->ignoreExist = pCreateDb->ignoreExists;
|
pMsg->ignoreExist = pCreateDb->ignoreExists;
|
||||||
pMsg->update = pCreateDb->update;
|
pMsg->update = pCreateDb->update;
|
||||||
pMsg->cacheLastRow = pCreateDb->cachelast;
|
pMsg->cacheLastRow = pCreateDb->cachelast;
|
||||||
|
pMsg->dbType = pCreateDb->dbType;
|
||||||
|
pMsg->partitions = htons(pCreateDb->partitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDbInfo* pCreateDbSql) {
|
int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDbInfo* pCreateDbSql) {
|
||||||
|
@ -6244,6 +6260,15 @@ int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCreateDbMsg* pCreate) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val = (int16_t)htons(pCreate->partitions);
|
||||||
|
if (val != -1 &&
|
||||||
|
(val < TSDB_MIN_DB_PARTITON_OPTION || val > TSDB_MAX_DB_PARTITON_OPTION)) {
|
||||||
|
snprintf(msg, tListLen(msg), "invalid topic option partition: %d valid range: [%d, %d]", val,
|
||||||
|
TSDB_MIN_DB_PARTITON_OPTION, TSDB_MAX_DB_PARTITON_OPTION);
|
||||||
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1055,7 +1055,8 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
int32_t tscBuildCreateDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int32_t tscBuildCreateDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
pCmd->payloadLen = sizeof(SCreateDbMsg);
|
pCmd->payloadLen = sizeof(SCreateDbMsg);
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_CREATE_DB;
|
|
||||||
|
pCmd->msgType = (pInfo->pMiscInfo->dbOpt.dbType == TSDB_DB_TYPE_DEFAULT) ? TSDB_MSG_TYPE_CM_CREATE_DB : TSDB_MSG_TYPE_CM_CREATE_TP;
|
||||||
|
|
||||||
SCreateDbMsg *pCreateDbMsg = (SCreateDbMsg *)pCmd->payload;
|
SCreateDbMsg *pCreateDbMsg = (SCreateDbMsg *)pCmd->payload;
|
||||||
|
|
||||||
|
@ -1187,7 +1188,7 @@ int32_t tscBuildDropDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
pDropDbMsg->ignoreNotExists = pInfo->pMiscInfo->existsCheck ? 1 : 0;
|
pDropDbMsg->ignoreNotExists = pInfo->pMiscInfo->existsCheck ? 1 : 0;
|
||||||
|
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_DB;
|
pCmd->msgType = (pInfo->pMiscInfo->dbType == TSDB_DB_TYPE_DEFAULT) ? TSDB_MSG_TYPE_CM_DROP_DB : TSDB_MSG_TYPE_CM_DROP_TP;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1514,9 +1515,11 @@ int tscBuildUpdateTagMsg(SSqlObj* pSql, SSqlInfo *pInfo) {
|
||||||
int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
pCmd->payloadLen = sizeof(SAlterDbMsg);
|
pCmd->payloadLen = sizeof(SAlterDbMsg);
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_ALTER_DB;
|
pCmd->msgType = (pInfo->pMiscInfo->dbOpt.dbType == TSDB_DB_TYPE_DEFAULT) ? TSDB_MSG_TYPE_CM_ALTER_DB : TSDB_MSG_TYPE_CM_ALTER_TP;
|
||||||
|
|
||||||
SAlterDbMsg *pAlterDbMsg = (SAlterDbMsg* )pCmd->payload;
|
SAlterDbMsg *pAlterDbMsg = (SAlterDbMsg* )pCmd->payload;
|
||||||
|
pAlterDbMsg->dbType = -1;
|
||||||
|
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
tNameExtractFullName(&pTableMetaInfo->name, pAlterDbMsg->db);
|
tNameExtractFullName(&pTableMetaInfo->name, pAlterDbMsg->db);
|
||||||
|
|
||||||
|
|
|
@ -1941,7 +1941,11 @@ void tscFirstRoundRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
|
|
||||||
// tag or group by column
|
// tag or group by column
|
||||||
if (TSDB_COL_IS_TAG(pExpr->colInfo.flag) || pExpr->functionId == TSDB_FUNC_PRJ) {
|
if (TSDB_COL_IS_TAG(pExpr->colInfo.flag) || pExpr->functionId == TSDB_FUNC_PRJ) {
|
||||||
|
if (row[i] == NULL) {
|
||||||
|
setNull(p + offset, pExpr->resType, pExpr->resBytes);
|
||||||
|
} else {
|
||||||
memcpy(p + offset, row[i], length[i]);
|
memcpy(p + offset, row[i], length[i]);
|
||||||
|
}
|
||||||
offset += pExpr->resBytes;
|
offset += pExpr->resBytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2802,7 +2806,7 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
|
||||||
numOfFailed += 1;
|
numOfFailed += 1;
|
||||||
|
|
||||||
// clean up tableMeta in cache
|
// clean up tableMeta in cache
|
||||||
tscFreeQueryInfo(&pSql->cmd);
|
tscFreeQueryInfo(&pSql->cmd, false);
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetailSafely(&pSql->cmd, 0);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetailSafely(&pSql->cmd, 0);
|
||||||
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);
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include "ttokendef.h"
|
#include "ttokendef.h"
|
||||||
|
|
||||||
static void freeQueryInfoImpl(SQueryInfo* pQueryInfo);
|
static void freeQueryInfoImpl(SQueryInfo* pQueryInfo);
|
||||||
static void clearAllTableMetaInfo(SQueryInfo* pQueryInfo);
|
static void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, bool removeMeta);
|
||||||
|
|
||||||
static void tscStrToLower(char *str, int32_t n) {
|
static void tscStrToLower(char *str, int32_t n) {
|
||||||
if (str == NULL || n <= 0) { return;}
|
if (str == NULL || n <= 0) { return;}
|
||||||
|
@ -367,7 +367,7 @@ static void tscDestroyResPointerInfo(SSqlRes* pRes) {
|
||||||
pRes->data = NULL; // pRes->data points to the buffer of pRsp, no need to free
|
pRes->data = NULL; // pRes->data points to the buffer of pRsp, no need to free
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscFreeQueryInfo(SSqlCmd* pCmd) {
|
void tscFreeQueryInfo(SSqlCmd* pCmd, bool removeMeta) {
|
||||||
if (pCmd == NULL || pCmd->numOfClause == 0) {
|
if (pCmd == NULL || pCmd->numOfClause == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -376,7 +376,7 @@ void tscFreeQueryInfo(SSqlCmd* pCmd) {
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, i);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, i);
|
||||||
|
|
||||||
freeQueryInfoImpl(pQueryInfo);
|
freeQueryInfoImpl(pQueryInfo);
|
||||||
clearAllTableMetaInfo(pQueryInfo);
|
clearAllTableMetaInfo(pQueryInfo, removeMeta);
|
||||||
tfree(pQueryInfo);
|
tfree(pQueryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool removeMeta) {
|
||||||
|
|
||||||
pCmd->pTableBlockHashList = tscDestroyBlockHashTable(pCmd->pTableBlockHashList, removeMeta);
|
pCmd->pTableBlockHashList = tscDestroyBlockHashTable(pCmd->pTableBlockHashList, removeMeta);
|
||||||
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
||||||
tscFreeQueryInfo(pCmd);
|
tscFreeQueryInfo(pCmd, removeMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscFreeSqlResult(SSqlObj* pSql) {
|
void tscFreeSqlResult(SSqlObj* pSql) {
|
||||||
|
@ -1847,10 +1847,17 @@ SArray* tscVgroupTableInfoDup(SArray* pVgroupTables) {
|
||||||
return pa;
|
return pa;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearAllTableMetaInfo(SQueryInfo* pQueryInfo) {
|
void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, bool removeMeta) {
|
||||||
for(int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
|
for(int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, i);
|
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, i);
|
||||||
|
|
||||||
|
if (removeMeta) {
|
||||||
|
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
tNameExtractFullName(&pTableMetaInfo->name, name);
|
||||||
|
|
||||||
|
taosHashRemove(tscTableMetaInfo, name, strnlen(name, TSDB_TABLE_FNAME_LEN));
|
||||||
|
}
|
||||||
|
|
||||||
tscFreeVgroupTableInfo(pTableMetaInfo->pVgroupTables);
|
tscFreeVgroupTableInfo(pTableMetaInfo->pVgroupTables);
|
||||||
tscClearTableMetaInfo(pTableMetaInfo);
|
tscClearTableMetaInfo(pTableMetaInfo);
|
||||||
free(pTableMetaInfo);
|
free(pTableMetaInfo);
|
||||||
|
@ -2714,7 +2721,11 @@ STableMeta* createSuperTableMeta(STableMetaMsg* pChild) {
|
||||||
uint32_t tscGetTableMetaSize(STableMeta* pTableMeta) {
|
uint32_t tscGetTableMetaSize(STableMeta* pTableMeta) {
|
||||||
assert(pTableMeta != NULL);
|
assert(pTableMeta != NULL);
|
||||||
|
|
||||||
int32_t totalCols = pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags;
|
int32_t totalCols = 0;
|
||||||
|
if (pTableMeta->tableInfo.numOfColumns >= 0 && pTableMeta->tableInfo.numOfTags >= 0) {
|
||||||
|
totalCols = pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags;
|
||||||
|
}
|
||||||
|
|
||||||
return sizeof(STableMeta) + totalCols * sizeof(SSchema);
|
return sizeof(STableMeta) + totalCols * sizeof(SSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ extern int8_t tsCompression;
|
||||||
extern int8_t tsWAL;
|
extern int8_t tsWAL;
|
||||||
extern int32_t tsFsyncPeriod;
|
extern int32_t tsFsyncPeriod;
|
||||||
extern int32_t tsReplications;
|
extern int32_t tsReplications;
|
||||||
|
extern int16_t tsPartitons;
|
||||||
extern int32_t tsQuorum;
|
extern int32_t tsQuorum;
|
||||||
extern int8_t tsUpdate;
|
extern int8_t tsUpdate;
|
||||||
extern int8_t tsCacheLastRow;
|
extern int8_t tsCacheLastRow;
|
||||||
|
|
|
@ -126,8 +126,9 @@ int8_t tsWAL = TSDB_DEFAULT_WAL_LEVEL;
|
||||||
int32_t tsFsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD;
|
int32_t tsFsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD;
|
||||||
int32_t tsReplications = TSDB_DEFAULT_DB_REPLICA_OPTION;
|
int32_t tsReplications = TSDB_DEFAULT_DB_REPLICA_OPTION;
|
||||||
int32_t tsQuorum = TSDB_DEFAULT_DB_QUORUM_OPTION;
|
int32_t tsQuorum = TSDB_DEFAULT_DB_QUORUM_OPTION;
|
||||||
|
int16_t tsPartitons = TSDB_DEFAULT_DB_PARTITON_OPTION;
|
||||||
int8_t tsUpdate = TSDB_DEFAULT_DB_UPDATE_OPTION;
|
int8_t tsUpdate = TSDB_DEFAULT_DB_UPDATE_OPTION;
|
||||||
int8_t tsCacheLastRow = TSDB_DEFAULT_CACHE_BLOCK_SIZE;
|
int8_t tsCacheLastRow = TSDB_DEFAULT_CACHE_LAST_ROW;
|
||||||
int32_t tsMaxVgroupsPerDb = 0;
|
int32_t tsMaxVgroupsPerDb = 0;
|
||||||
int32_t tsMinTablePerVnode = TSDB_TABLES_STEP;
|
int32_t tsMinTablePerVnode = TSDB_TABLES_STEP;
|
||||||
int32_t tsMaxTablePerVnode = TSDB_DEFAULT_TABLES;
|
int32_t tsMaxTablePerVnode = TSDB_DEFAULT_TABLES;
|
||||||
|
@ -430,10 +431,10 @@ static void doInitGlobalConfig(void) {
|
||||||
// port
|
// port
|
||||||
cfg.option = "serverPort";
|
cfg.option = "serverPort";
|
||||||
cfg.ptr = &tsServerPort;
|
cfg.ptr = &tsServerPort;
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT16;
|
cfg.valType = TAOS_CFG_VTYPE_UINT16;
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
|
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
|
||||||
cfg.minValue = 1;
|
cfg.minValue = 1;
|
||||||
cfg.maxValue = 65535;
|
cfg.maxValue = 65056;
|
||||||
cfg.ptrLength = 0;
|
cfg.ptrLength = 0;
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||||
taosInitConfigOption(cfg);
|
taosInitConfigOption(cfg);
|
||||||
|
@ -853,6 +854,16 @@ static void doInitGlobalConfig(void) {
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||||
taosInitConfigOption(cfg);
|
taosInitConfigOption(cfg);
|
||||||
|
|
||||||
|
cfg.option = "partitions";
|
||||||
|
cfg.ptr = &tsPartitons;
|
||||||
|
cfg.valType = TAOS_CFG_VTYPE_INT16;
|
||||||
|
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
||||||
|
cfg.minValue = TSDB_MIN_DB_PARTITON_OPTION;
|
||||||
|
cfg.maxValue = TSDB_MAX_DB_PARTITON_OPTION;
|
||||||
|
cfg.ptrLength = 0;
|
||||||
|
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||||
|
taosInitConfigOption(cfg);
|
||||||
|
|
||||||
cfg.option = "quorum";
|
cfg.option = "quorum";
|
||||||
cfg.ptr = &tsQuorum;
|
cfg.ptr = &tsQuorum;
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
||||||
|
|
|
@ -8,7 +8,7 @@ IF (TD_MVN_INSTALLED)
|
||||||
ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME}
|
ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME}
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
|
COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.20-dist.jar ${LIBRARY_OUTPUT_PATH}
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.21-dist.jar ${LIBRARY_OUTPUT_PATH}
|
||||||
COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
|
COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
|
||||||
COMMENT "build jdbc driver")
|
COMMENT "build jdbc driver")
|
||||||
ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME})
|
ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME})
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<groupId>com.taosdata.jdbc</groupId>
|
<groupId>com.taosdata.jdbc</groupId>
|
||||||
<artifactId>taos-jdbcdriver</artifactId>
|
<artifactId>taos-jdbcdriver</artifactId>
|
||||||
<version>2.0.20</version>
|
<version>2.0.21</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>JDBCDriver</name>
|
<name>JDBCDriver</name>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.taosdata.jdbc</groupId>
|
<groupId>com.taosdata.jdbc</groupId>
|
||||||
<artifactId>taos-jdbcdriver</artifactId>
|
<artifactId>taos-jdbcdriver</artifactId>
|
||||||
<version>2.0.20</version>
|
<version>2.0.21</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>JDBCDriver</name>
|
<name>JDBCDriver</name>
|
||||||
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
|
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
|
||||||
|
@ -102,6 +102,7 @@
|
||||||
<include>**/*Test.java</include>
|
<include>**/*Test.java</include>
|
||||||
</includes>
|
</includes>
|
||||||
<excludes>
|
<excludes>
|
||||||
|
<exclude>**/DatetimeBefore1970Test.java</exclude>
|
||||||
<exclude>**/AppMemoryLeakTest.java</exclude>
|
<exclude>**/AppMemoryLeakTest.java</exclude>
|
||||||
<exclude>**/AuthenticationTest.java</exclude>
|
<exclude>**/AuthenticationTest.java</exclude>
|
||||||
<exclude>**/TaosInfoMonitorTest.java</exclude>
|
<exclude>**/TaosInfoMonitorTest.java</exclude>
|
||||||
|
|
|
@ -1,76 +1,12 @@
|
||||||
package com.taosdata.jdbc;
|
package com.taosdata.jdbc;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.sql.Driver;
|
import java.sql.Driver;
|
||||||
import java.sql.DriverPropertyInfo;
|
import java.sql.DriverPropertyInfo;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
public abstract class AbstractDriver implements Driver {
|
public abstract class AbstractDriver implements Driver {
|
||||||
|
|
||||||
private static final String TAOS_CFG_FILENAME = "taos.cfg";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param cfgDirPath
|
|
||||||
* @return return the config dir
|
|
||||||
**/
|
|
||||||
protected File loadConfigDir(String cfgDirPath) {
|
|
||||||
if (cfgDirPath == null)
|
|
||||||
return loadDefaultConfigDir();
|
|
||||||
File cfgDir = new File(cfgDirPath);
|
|
||||||
if (!cfgDir.exists())
|
|
||||||
return loadDefaultConfigDir();
|
|
||||||
return cfgDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return search the default config dir, if the config dir is not exist will return null
|
|
||||||
*/
|
|
||||||
protected File loadDefaultConfigDir() {
|
|
||||||
File cfgDir;
|
|
||||||
File cfgDir_linux = new File("/etc/taos");
|
|
||||||
cfgDir = cfgDir_linux.exists() ? cfgDir_linux : null;
|
|
||||||
File cfgDir_windows = new File("C:\\TDengine\\cfg");
|
|
||||||
cfgDir = (cfgDir == null && cfgDir_windows.exists()) ? cfgDir_windows : cfgDir;
|
|
||||||
return cfgDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected List<String> loadConfigEndpoints(File cfgFile) {
|
|
||||||
List<String> endpoints = new ArrayList<>();
|
|
||||||
try (BufferedReader reader = new BufferedReader(new FileReader(cfgFile))) {
|
|
||||||
String line = null;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
if (line.trim().startsWith("firstEp") || line.trim().startsWith("secondEp")) {
|
|
||||||
endpoints.add(line.substring(line.indexOf('p') + 1).trim());
|
|
||||||
}
|
|
||||||
if (endpoints.size() > 1)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return endpoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void loadTaosConfig(Properties info) {
|
|
||||||
if ((info.getProperty(TSDBDriver.PROPERTY_KEY_HOST) == null ||
|
|
||||||
info.getProperty(TSDBDriver.PROPERTY_KEY_HOST).isEmpty()) && (
|
|
||||||
info.getProperty(TSDBDriver.PROPERTY_KEY_PORT) == null ||
|
|
||||||
info.getProperty(TSDBDriver.PROPERTY_KEY_PORT).isEmpty())) {
|
|
||||||
File cfgDir = loadConfigDir(info.getProperty(TSDBDriver.PROPERTY_KEY_CONFIG_DIR));
|
|
||||||
File cfgFile = cfgDir.listFiles((dir, name) -> TAOS_CFG_FILENAME.equalsIgnoreCase(name))[0];
|
|
||||||
List<String> endpoints = loadConfigEndpoints(cfgFile);
|
|
||||||
if (!endpoints.isEmpty()) {
|
|
||||||
info.setProperty(TSDBDriver.PROPERTY_KEY_HOST, endpoints.get(0).split(":")[0]);
|
|
||||||
info.setProperty(TSDBDriver.PROPERTY_KEY_PORT, endpoints.get(0).split(":")[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected DriverPropertyInfo[] getPropertyInfo(Properties info) {
|
protected DriverPropertyInfo[] getPropertyInfo(Properties info) {
|
||||||
DriverPropertyInfo hostProp = new DriverPropertyInfo(TSDBDriver.PROPERTY_KEY_HOST, info.getProperty(TSDBDriver.PROPERTY_KEY_HOST));
|
DriverPropertyInfo hostProp = new DriverPropertyInfo(TSDBDriver.PROPERTY_KEY_HOST, info.getProperty(TSDBDriver.PROPERTY_KEY_HOST));
|
||||||
hostProp.required = false;
|
hostProp.required = false;
|
||||||
|
@ -156,6 +92,4 @@ public abstract class AbstractDriver implements Driver {
|
||||||
return urlProps;
|
return urlProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,4 +52,14 @@ public class ColumnMetaData {
|
||||||
public void setColIndex(int colIndex) {
|
public void setColIndex(int colIndex) {
|
||||||
this.colIndex = colIndex;
|
this.colIndex = colIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ColumnMetaData{" +
|
||||||
|
"colType=" + colType +
|
||||||
|
", colName='" + colName + '\'' +
|
||||||
|
", colSize=" + colSize +
|
||||||
|
", colIndex=" + colIndex +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,7 +308,7 @@ public class DatabaseMetaDataResultSet implements ResultSet {
|
||||||
return colMetaData.getColIndex() + 1;
|
return colMetaData.getColIndex() + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -87,11 +87,10 @@ public class TSDBConnection extends AbstractConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() throws SQLException {
|
public void close() throws SQLException {
|
||||||
if (isClosed()) {
|
if (isClosed)
|
||||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
return;
|
||||||
}
|
|
||||||
this.isClosed = true;
|
|
||||||
this.connector.closeConnection();
|
this.connector.closeConnection();
|
||||||
|
this.isClosed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isClosed() throws SQLException {
|
public boolean isClosed() throws SQLException {
|
||||||
|
|
|
@ -14,16 +14,13 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package com.taosdata.jdbc;
|
package com.taosdata.jdbc;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Types;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class TSDBConstants {
|
public abstract class TSDBConstants {
|
||||||
|
|
||||||
public static final String STATEMENT_CLOSED = "statement is closed";
|
|
||||||
public static final String UNSUPPORTED_METHOD_EXCEPTION_MSG = "this operation is NOT supported currently!";
|
|
||||||
public static final String INVALID_VARIABLES = "invalid variables";
|
|
||||||
public static final String RESULT_SET_IS_CLOSED = "resultSet is closed";
|
|
||||||
|
|
||||||
public static final String DEFAULT_PORT = "6200";
|
public static final String DEFAULT_PORT = "6200";
|
||||||
public static Map<Integer, String> DATATYPE_MAP = null;
|
public static Map<Integer, String> DATATYPE_MAP = null;
|
||||||
|
|
||||||
|
@ -77,8 +74,65 @@ public abstract class TSDBConstants {
|
||||||
return WrapErrMsg("unkown error!");
|
return WrapErrMsg("unkown error!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int taosType2JdbcType(int taosType) throws SQLException {
|
||||||
|
switch (taosType) {
|
||||||
|
case TSDBConstants.TSDB_DATA_TYPE_NULL:
|
||||||
|
return Types.NULL;
|
||||||
|
case TSDBConstants.TSDB_DATA_TYPE_BOOL:
|
||||||
|
return Types.BOOLEAN;
|
||||||
|
case TSDBConstants.TSDB_DATA_TYPE_TINYINT:
|
||||||
|
return Types.TINYINT;
|
||||||
|
case TSDBConstants.TSDB_DATA_TYPE_SMALLINT:
|
||||||
|
return Types.SMALLINT;
|
||||||
|
case TSDBConstants.TSDB_DATA_TYPE_INT:
|
||||||
|
return Types.INTEGER;
|
||||||
|
case TSDBConstants.TSDB_DATA_TYPE_BIGINT:
|
||||||
|
return Types.BIGINT;
|
||||||
|
case TSDBConstants.TSDB_DATA_TYPE_FLOAT:
|
||||||
|
return Types.FLOAT;
|
||||||
|
case TSDBConstants.TSDB_DATA_TYPE_DOUBLE:
|
||||||
|
return Types.DOUBLE;
|
||||||
|
case TSDBConstants.TSDB_DATA_TYPE_BINARY:
|
||||||
|
return Types.BINARY;
|
||||||
|
case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
|
return Types.TIMESTAMP;
|
||||||
|
case TSDBConstants.TSDB_DATA_TYPE_NCHAR:
|
||||||
|
return Types.NCHAR;
|
||||||
|
}
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_SQL_TYPE_IN_TDENGINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int jdbcType2TaosType(int jdbcType) throws SQLException {
|
||||||
|
switch (jdbcType){
|
||||||
|
case Types.NULL:
|
||||||
|
return TSDBConstants.TSDB_DATA_TYPE_NULL;
|
||||||
|
case Types.BOOLEAN:
|
||||||
|
return TSDBConstants.TSDB_DATA_TYPE_BOOL;
|
||||||
|
case Types.TINYINT:
|
||||||
|
return TSDBConstants.TSDB_DATA_TYPE_TINYINT;
|
||||||
|
case Types.SMALLINT:
|
||||||
|
return TSDBConstants.TSDB_DATA_TYPE_SMALLINT;
|
||||||
|
case Types.INTEGER:
|
||||||
|
return TSDBConstants.TSDB_DATA_TYPE_INT;
|
||||||
|
case Types.BIGINT:
|
||||||
|
return TSDBConstants.TSDB_DATA_TYPE_BIGINT;
|
||||||
|
case Types.FLOAT:
|
||||||
|
return TSDBConstants.TSDB_DATA_TYPE_FLOAT;
|
||||||
|
case Types.DOUBLE:
|
||||||
|
return TSDBConstants.TSDB_DATA_TYPE_DOUBLE;
|
||||||
|
case Types.BINARY:
|
||||||
|
return TSDBConstants.TSDB_DATA_TYPE_BINARY;
|
||||||
|
case Types.TIMESTAMP:
|
||||||
|
return TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
|
case Types.NCHAR:
|
||||||
|
return TSDBConstants.TSDB_DATA_TYPE_NCHAR;
|
||||||
|
}
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_SQL_TYPE_IN_TDENGINE);
|
||||||
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
DATATYPE_MAP = new HashMap<>();
|
DATATYPE_MAP = new HashMap<>();
|
||||||
|
DATATYPE_MAP.put(0, "NULL");
|
||||||
DATATYPE_MAP.put(1, "BOOL");
|
DATATYPE_MAP.put(1, "BOOL");
|
||||||
DATATYPE_MAP.put(2, "TINYINT");
|
DATATYPE_MAP.put(2, "TINYINT");
|
||||||
DATATYPE_MAP.put(3, "SMALLINT");
|
DATATYPE_MAP.put(3, "SMALLINT");
|
||||||
|
@ -90,4 +144,8 @@ public abstract class TSDBConstants {
|
||||||
DATATYPE_MAP.put(9, "TIMESTAMP");
|
DATATYPE_MAP.put(9, "TIMESTAMP");
|
||||||
DATATYPE_MAP.put(10, "NCHAR");
|
DATATYPE_MAP.put(10, "NCHAR");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String jdbcType2TaosTypeName(int type) throws SQLException {
|
||||||
|
return DATATYPE_MAP.get(jdbcType2TaosType(type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,6 @@ public class TSDBDriver extends AbstractDriver {
|
||||||
if ((props = parseURL(url, info)) == null) {
|
if ((props = parseURL(url, info)) == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
//load taos.cfg start
|
|
||||||
loadTaosConfig(info);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
TSDBJNIConnector.init((String) props.get(PROPERTY_KEY_CONFIG_DIR), (String) props.get(PROPERTY_KEY_LOCALE),
|
TSDBJNIConnector.init((String) props.get(PROPERTY_KEY_CONFIG_DIR), (String) props.get(PROPERTY_KEY_LOCALE),
|
||||||
|
|
|
@ -18,6 +18,7 @@ public class TSDBErrorNumbers {
|
||||||
public static final int ERROR_INVALID_FOR_EXECUTE = 0x230c; //not a valid sql for execute: (SQL)
|
public static final int ERROR_INVALID_FOR_EXECUTE = 0x230c; //not a valid sql for execute: (SQL)
|
||||||
public static final int ERROR_PARAMETER_INDEX_OUT_RANGE = 0x230d; // parameter index out of range
|
public static final int ERROR_PARAMETER_INDEX_OUT_RANGE = 0x230d; // parameter index out of range
|
||||||
public static final int ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED = 0x230e; // connection already closed
|
public static final int ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED = 0x230e; // connection already closed
|
||||||
|
public static final int ERROR_UNKNOWN_SQL_TYPE_IN_TDENGINE = 0x230f; //unknown sql type in tdengine
|
||||||
|
|
||||||
public static final int ERROR_UNKNOWN = 0x2350; //unknown error
|
public static final int ERROR_UNKNOWN = 0x2350; //unknown error
|
||||||
|
|
||||||
|
@ -49,6 +50,7 @@ public class TSDBErrorNumbers {
|
||||||
errorNumbers.add(ERROR_INVALID_FOR_EXECUTE);
|
errorNumbers.add(ERROR_INVALID_FOR_EXECUTE);
|
||||||
errorNumbers.add(ERROR_PARAMETER_INDEX_OUT_RANGE);
|
errorNumbers.add(ERROR_PARAMETER_INDEX_OUT_RANGE);
|
||||||
errorNumbers.add(ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED);
|
errorNumbers.add(ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED);
|
||||||
|
errorNumbers.add(ERROR_UNKNOWN_SQL_TYPE_IN_TDENGINE);
|
||||||
|
|
||||||
/*****************************************************/
|
/*****************************************************/
|
||||||
errorNumbers.add(ERROR_SUBSCRIBE_FAILED);
|
errorNumbers.add(ERROR_SUBSCRIBE_FAILED);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/***************************************************************************
|
/**
|
||||||
|
* *************************************************************************
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
@ -20,6 +21,9 @@ import java.sql.SQLException;
|
||||||
import java.sql.SQLWarning;
|
import java.sql.SQLWarning;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JNI connector
|
||||||
|
* */
|
||||||
public class TSDBJNIConnector {
|
public class TSDBJNIConnector {
|
||||||
private static volatile Boolean isInitialized = false;
|
private static volatile Boolean isInitialized = false;
|
||||||
|
|
||||||
|
|
|
@ -20,18 +20,16 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TSDBResultSet extends AbstractResultSet implements ResultSet {
|
public class TSDBResultSet extends AbstractResultSet implements ResultSet {
|
||||||
private TSDBJNIConnector jniConnector;
|
private final TSDBJNIConnector jniConnector;
|
||||||
|
|
||||||
private final TSDBStatement statement;
|
private final TSDBStatement statement;
|
||||||
private long resultSetPointer = 0L;
|
private final long resultSetPointer;
|
||||||
private List<ColumnMetaData> columnMetaDataList = new ArrayList<>();
|
private List<ColumnMetaData> columnMetaDataList = new ArrayList<>();
|
||||||
|
private final TSDBResultSetRowData rowData;
|
||||||
private TSDBResultSetRowData rowData;
|
private final TSDBResultSetBlockData blockData;
|
||||||
private TSDBResultSetBlockData blockData;
|
|
||||||
|
|
||||||
private boolean batchFetch = false;
|
private boolean batchFetch = false;
|
||||||
private boolean lastWasNull = false;
|
private boolean lastWasNull = false;
|
||||||
private final int COLUMN_INDEX_START_VALUE = 1;
|
private boolean isClosed;
|
||||||
|
|
||||||
public void setBatchFetch(boolean batchFetch) {
|
public void setBatchFetch(boolean batchFetch) {
|
||||||
this.batchFetch = batchFetch;
|
this.batchFetch = batchFetch;
|
||||||
|
@ -56,13 +54,13 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
|
||||||
|
|
||||||
int code = this.jniConnector.getSchemaMetaData(this.resultSetPointer, this.columnMetaDataList);
|
int code = this.jniConnector.getSchemaMetaData(this.resultSetPointer, this.columnMetaDataList);
|
||||||
if (code == TSDBConstants.JNI_CONNECTION_NULL) {
|
if (code == TSDBConstants.JNI_CONNECTION_NULL) {
|
||||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL);
|
||||||
}
|
}
|
||||||
if (code == TSDBConstants.JNI_RESULT_SET_NULL) {
|
if (code == TSDBConstants.JNI_RESULT_SET_NULL) {
|
||||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_RESULT_SET_NULL));
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL);
|
||||||
}
|
}
|
||||||
if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) {
|
if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) {
|
||||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_NUM_OF_FIELDS_0));
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_NUM_OF_FIELDS_0);
|
||||||
}
|
}
|
||||||
this.rowData = new TSDBResultSetRowData(this.columnMetaDataList.size());
|
this.rowData = new TSDBResultSetRowData(this.columnMetaDataList.size());
|
||||||
this.blockData = new TSDBResultSetBlockData(this.columnMetaDataList, this.columnMetaDataList.size());
|
this.blockData = new TSDBResultSetBlockData(this.columnMetaDataList, this.columnMetaDataList.size());
|
||||||
|
@ -78,16 +76,12 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
|
||||||
this.blockData.reset();
|
this.blockData.reset();
|
||||||
|
|
||||||
if (code == TSDBConstants.JNI_CONNECTION_NULL) {
|
if (code == TSDBConstants.JNI_CONNECTION_NULL) {
|
||||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL);
|
||||||
} else if (code == TSDBConstants.JNI_RESULT_SET_NULL) {
|
} else if (code == TSDBConstants.JNI_RESULT_SET_NULL) {
|
||||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_RESULT_SET_NULL));
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL);
|
||||||
} else if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) {
|
} else if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) {
|
||||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_NUM_OF_FIELDS_0));
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_NUM_OF_FIELDS_0);
|
||||||
} else if (code == TSDBConstants.JNI_FETCH_END) {
|
} else return code != TSDBConstants.JNI_FETCH_END;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
if (rowData != null) {
|
if (rowData != null) {
|
||||||
this.rowData.clear();
|
this.rowData.clear();
|
||||||
|
@ -95,11 +89,11 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
|
||||||
|
|
||||||
int code = this.jniConnector.fetchRow(this.resultSetPointer, this.rowData);
|
int code = this.jniConnector.fetchRow(this.resultSetPointer, this.rowData);
|
||||||
if (code == TSDBConstants.JNI_CONNECTION_NULL) {
|
if (code == TSDBConstants.JNI_CONNECTION_NULL) {
|
||||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL);
|
||||||
} else if (code == TSDBConstants.JNI_RESULT_SET_NULL) {
|
} else if (code == TSDBConstants.JNI_RESULT_SET_NULL) {
|
||||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_RESULT_SET_NULL));
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL);
|
||||||
} else if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) {
|
} else if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) {
|
||||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_NUM_OF_FIELDS_0));
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_NUM_OF_FIELDS_0);
|
||||||
} else if (code == TSDBConstants.JNI_FETCH_END) {
|
} else if (code == TSDBConstants.JNI_FETCH_END) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -109,14 +103,17 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() throws SQLException {
|
public void close() throws SQLException {
|
||||||
|
if (isClosed)
|
||||||
|
return;
|
||||||
if (this.jniConnector != null) {
|
if (this.jniConnector != null) {
|
||||||
int code = this.jniConnector.freeResultSet(this.resultSetPointer);
|
int code = this.jniConnector.freeResultSet(this.resultSetPointer);
|
||||||
if (code == TSDBConstants.JNI_CONNECTION_NULL) {
|
if (code == TSDBConstants.JNI_CONNECTION_NULL) {
|
||||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL);
|
||||||
} else if (code == TSDBConstants.JNI_RESULT_SET_NULL) {
|
} else if (code == TSDBConstants.JNI_RESULT_SET_NULL) {
|
||||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_RESULT_SET_NULL));
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
isClosed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean wasNull() throws SQLException {
|
public boolean wasNull() throws SQLException {
|
||||||
|
@ -415,8 +412,8 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isClosed() throws SQLException {
|
public boolean isClosed() throws SQLException {
|
||||||
//TODO: check if need release resources
|
if (isClosed)
|
||||||
boolean isClosed = true;
|
return true;
|
||||||
if (jniConnector != null) {
|
if (jniConnector != null) {
|
||||||
isClosed = jniConnector.isResultsetClosed();
|
isClosed = jniConnector.isResultsetClosed();
|
||||||
}
|
}
|
||||||
|
@ -429,14 +426,12 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getTrueColumnIndex(int columnIndex) throws SQLException {
|
private int getTrueColumnIndex(int columnIndex) throws SQLException {
|
||||||
if (columnIndex < this.COLUMN_INDEX_START_VALUE) {
|
if (columnIndex < 1)
|
||||||
throw new SQLException("Column Index out of range, " + columnIndex + " < " + this.COLUMN_INDEX_START_VALUE);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE, "columnIndex(" + columnIndex + "): < 1");
|
||||||
}
|
|
||||||
|
|
||||||
int numOfCols = this.columnMetaDataList.size();
|
int numOfCols = this.columnMetaDataList.size();
|
||||||
if (columnIndex > numOfCols) {
|
if (columnIndex > numOfCols)
|
||||||
throw new SQLException("Column Index out of range, " + columnIndex + " > " + numOfCols);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE, "columnIndex: " + columnIndex);
|
||||||
}
|
|
||||||
return columnIndex - 1;
|
return columnIndex - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.sql.Timestamp;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TSDBResultSetMetaData implements ResultSetMetaData {
|
public class TSDBResultSetMetaData extends WrapperImpl implements ResultSetMetaData {
|
||||||
|
|
||||||
List<ColumnMetaData> colMetaDataList = null;
|
List<ColumnMetaData> colMetaDataList = null;
|
||||||
|
|
||||||
|
@ -28,14 +28,6 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
|
||||||
this.colMetaDataList = metaDataList;
|
this.colMetaDataList = metaDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
|
||||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
|
||||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getColumnCount() throws SQLException {
|
public int getColumnCount() throws SQLException {
|
||||||
return colMetaDataList.size();
|
return colMetaDataList.size();
|
||||||
}
|
}
|
||||||
|
@ -94,7 +86,7 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSchemaName(int column) throws SQLException {
|
public String getSchemaName(int column) throws SQLException {
|
||||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPrecision(int column) throws SQLException {
|
public int getPrecision(int column) throws SQLException {
|
||||||
|
@ -125,18 +117,18 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTableName(int column) throws SQLException {
|
public String getTableName(int column) throws SQLException {
|
||||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCatalogName(int column) throws SQLException {
|
public String getCatalogName(int column) throws SQLException {
|
||||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColumnType(int column) throws SQLException {
|
public int getColumnType(int column) throws SQLException {
|
||||||
ColumnMetaData meta = this.colMetaDataList.get(column - 1);
|
ColumnMetaData meta = this.colMetaDataList.get(column - 1);
|
||||||
switch (meta.getColType()) {
|
switch (meta.getColType()) {
|
||||||
case TSDBConstants.TSDB_DATA_TYPE_BOOL:
|
case TSDBConstants.TSDB_DATA_TYPE_BOOL:
|
||||||
return java.sql.Types.BIT;
|
return Types.BOOLEAN;
|
||||||
case TSDBConstants.TSDB_DATA_TYPE_TINYINT:
|
case TSDBConstants.TSDB_DATA_TYPE_TINYINT:
|
||||||
return java.sql.Types.TINYINT;
|
return java.sql.Types.TINYINT;
|
||||||
case TSDBConstants.TSDB_DATA_TYPE_SMALLINT:
|
case TSDBConstants.TSDB_DATA_TYPE_SMALLINT:
|
||||||
|
@ -150,13 +142,13 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
|
||||||
case TSDBConstants.TSDB_DATA_TYPE_DOUBLE:
|
case TSDBConstants.TSDB_DATA_TYPE_DOUBLE:
|
||||||
return java.sql.Types.DOUBLE;
|
return java.sql.Types.DOUBLE;
|
||||||
case TSDBConstants.TSDB_DATA_TYPE_BINARY:
|
case TSDBConstants.TSDB_DATA_TYPE_BINARY:
|
||||||
return java.sql.Types.CHAR;
|
return Types.BINARY;
|
||||||
case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP:
|
case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
return java.sql.Types.BIGINT;
|
return java.sql.Types.TIMESTAMP;
|
||||||
case TSDBConstants.TSDB_DATA_TYPE_NCHAR:
|
case TSDBConstants.TSDB_DATA_TYPE_NCHAR:
|
||||||
return java.sql.Types.CHAR;
|
return Types.NCHAR;
|
||||||
}
|
}
|
||||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColumnTypeName(int column) throws SQLException {
|
public String getColumnTypeName(int column) throws SQLException {
|
||||||
|
@ -173,7 +165,7 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDefinitelyWritable(int column) throws SQLException {
|
public boolean isDefinitelyWritable(int column) throws SQLException {
|
||||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColumnClassName(int column) throws SQLException {
|
public String getColumnClassName(int column) throws SQLException {
|
||||||
|
|
|
@ -1153,11 +1153,11 @@ public class TSDBResultSetWrapper implements ResultSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
|
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
|
||||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
|
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
|
||||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -73,12 +73,12 @@ public class TSDBStatement extends AbstractStatement {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() throws SQLException {
|
public void close() throws SQLException {
|
||||||
if (!isClosed) {
|
if (isClosed)
|
||||||
if (this.resultSet != null)
|
return;
|
||||||
|
if (this.resultSet != null && !this.resultSet.isClosed())
|
||||||
this.resultSet.close();
|
this.resultSet.close();
|
||||||
isClosed = true;
|
isClosed = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean execute(String sql) throws SQLException {
|
public boolean execute(String sql) throws SQLException {
|
||||||
// check if closed
|
// check if closed
|
||||||
|
|
|
@ -14,12 +14,11 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package com.taosdata.jdbc;
|
package com.taosdata.jdbc;
|
||||||
|
|
||||||
import javax.management.OperationsException;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class TSDBSubscribe {
|
public class TSDBSubscribe {
|
||||||
private TSDBJNIConnector connecter = null;
|
private final TSDBJNIConnector connecter;
|
||||||
private long id = 0;
|
private final long id;
|
||||||
|
|
||||||
TSDBSubscribe(TSDBJNIConnector connecter, long id) throws SQLException {
|
TSDBSubscribe(TSDBJNIConnector connecter, long id) throws SQLException {
|
||||||
if (null != connecter) {
|
if (null != connecter) {
|
||||||
|
|
|
@ -18,10 +18,10 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
|
||||||
private final String database;
|
private final String database;
|
||||||
private final Statement statement;
|
private final Statement statement;
|
||||||
// data
|
// data
|
||||||
private ArrayList<ArrayList<Object>> resultSet = new ArrayList<>();
|
private ArrayList<ArrayList<Object>> resultSet;
|
||||||
// meta
|
// meta
|
||||||
private ArrayList<String> columnNames = new ArrayList<>();
|
private ArrayList<String> columnNames;
|
||||||
private ArrayList<Field> columns = new ArrayList<>();
|
private ArrayList<Field> columns;
|
||||||
private RestfulResultSetMetaData metaData;
|
private RestfulResultSetMetaData metaData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,11 +29,36 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
|
||||||
*
|
*
|
||||||
* @param resultJson: 包含data信息的结果集,有sql返回的结果集
|
* @param resultJson: 包含data信息的结果集,有sql返回的结果集
|
||||||
***/
|
***/
|
||||||
public RestfulResultSet(String database, Statement statement, JSONObject resultJson) {
|
public RestfulResultSet(String database, Statement statement, JSONObject resultJson) throws SQLException {
|
||||||
this.database = database;
|
this.database = database;
|
||||||
this.statement = statement;
|
this.statement = statement;
|
||||||
|
// column metadata
|
||||||
|
JSONArray columnMeta = resultJson.getJSONArray("column_meta");
|
||||||
|
columnNames = new ArrayList<>();
|
||||||
|
columns = new ArrayList<>();
|
||||||
|
for (int colIndex = 0; colIndex < columnMeta.size(); colIndex++) {
|
||||||
|
JSONArray col = columnMeta.getJSONArray(colIndex);
|
||||||
|
String col_name = col.getString(0);
|
||||||
|
int col_type = TSDBConstants.taosType2JdbcType(col.getInteger(1));
|
||||||
|
int col_length = col.getInteger(2);
|
||||||
|
columnNames.add(col_name);
|
||||||
|
columns.add(new Field(col_name, col_type, col_length, ""));
|
||||||
|
}
|
||||||
|
this.metaData = new RestfulResultSetMetaData(this.database, columns, this);
|
||||||
|
|
||||||
// row data
|
// row data
|
||||||
JSONArray data = resultJson.getJSONArray("data");
|
JSONArray data = resultJson.getJSONArray("data");
|
||||||
|
resultSet = new ArrayList<>();
|
||||||
|
for (int rowIndex = 0; rowIndex < data.size(); rowIndex++) {
|
||||||
|
ArrayList row = new ArrayList();
|
||||||
|
JSONArray jsonRow = data.getJSONArray(rowIndex);
|
||||||
|
for (int colIndex = 0; colIndex < jsonRow.size(); colIndex++) {
|
||||||
|
row.add(parseColumnData(jsonRow, colIndex, columns.get(colIndex).type));
|
||||||
|
}
|
||||||
|
resultSet.add(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
int columnIndex = 0;
|
int columnIndex = 0;
|
||||||
for (; columnIndex < data.size(); columnIndex++) {
|
for (; columnIndex < data.size(); columnIndex++) {
|
||||||
ArrayList oneRow = new ArrayList<>();
|
ArrayList oneRow = new ArrayList<>();
|
||||||
|
@ -52,50 +77,77 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
|
||||||
columns.add(new Field(name, "", 0, ""));
|
columns.add(new Field(name, "", 0, ""));
|
||||||
}
|
}
|
||||||
this.metaData = new RestfulResultSetMetaData(this.database, columns, this);
|
this.metaData = new RestfulResultSetMetaData(this.database, columns, this);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private Object parseColumnData(JSONArray row, int colIndex, int sqlType) {
|
||||||
* 由多个resultSet的JSON构造结果集
|
switch (sqlType) {
|
||||||
*
|
case Types.NULL:
|
||||||
* @param resultJson: 包含data信息的结果集,有sql返回的结果集
|
|
||||||
* @param fieldJson: 包含多个(最多2个)meta信息的结果集,有describe xxx
|
|
||||||
**/
|
|
||||||
public RestfulResultSet(String database, Statement statement, JSONObject resultJson, List<JSONObject> fieldJson) {
|
|
||||||
this(database, statement, resultJson);
|
|
||||||
ArrayList<Field> newColumns = new ArrayList<>();
|
|
||||||
|
|
||||||
for (Field column : columns) {
|
|
||||||
Field field = findField(column.name, fieldJson);
|
|
||||||
if (field != null) {
|
|
||||||
newColumns.add(field);
|
|
||||||
} else {
|
|
||||||
newColumns.add(column);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.columns = newColumns;
|
|
||||||
this.metaData = new RestfulResultSetMetaData(this.database, this.columns, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Field findField(String columnName, List<JSONObject> fieldJsonList) {
|
|
||||||
for (JSONObject fieldJSON : fieldJsonList) {
|
|
||||||
JSONArray fieldDataJson = fieldJSON.getJSONArray("data");
|
|
||||||
for (int i = 0; i < fieldDataJson.size(); i++) {
|
|
||||||
JSONArray field = fieldDataJson.getJSONArray(i);
|
|
||||||
if (columnName.equalsIgnoreCase(field.getString(0))) {
|
|
||||||
return new Field(field.getString(0), field.getString(1), field.getInteger(2), field.getString(3));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
|
case Types.BOOLEAN:
|
||||||
|
return row.getBoolean(colIndex);
|
||||||
|
case Types.TINYINT:
|
||||||
|
case Types.SMALLINT:
|
||||||
|
return row.getShort(colIndex);
|
||||||
|
case Types.INTEGER:
|
||||||
|
return row.getInteger(colIndex);
|
||||||
|
case Types.BIGINT:
|
||||||
|
return row.getBigInteger(colIndex);
|
||||||
|
case Types.FLOAT:
|
||||||
|
return row.getFloat(colIndex);
|
||||||
|
case Types.DOUBLE:
|
||||||
|
return row.getDouble(colIndex);
|
||||||
|
case Types.TIMESTAMP:
|
||||||
|
return new Timestamp(row.getDate(colIndex).getTime());
|
||||||
|
case Types.BINARY:
|
||||||
|
case Types.NCHAR:
|
||||||
|
default:
|
||||||
|
return row.getString(colIndex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 由多个resultSet的JSON构造结果集
|
||||||
|
// *
|
||||||
|
// * @param resultJson: 包含data信息的结果集,有sql返回的结果集
|
||||||
|
// * @param fieldJson: 包含多个(最多2个)meta信息的结果集,有describe xxx
|
||||||
|
// **/
|
||||||
|
// public RestfulResultSet(String database, Statement statement, JSONObject resultJson, List<JSONObject> fieldJson) throws SQLException {
|
||||||
|
// this(database, statement, resultJson);
|
||||||
|
// ArrayList<Field> newColumns = new ArrayList<>();
|
||||||
|
//
|
||||||
|
// for (Field column : columns) {
|
||||||
|
// Field field = findField(column.name, fieldJson);
|
||||||
|
// if (field != null) {
|
||||||
|
// newColumns.add(field);
|
||||||
|
// } else {
|
||||||
|
// newColumns.add(column);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// this.columns = newColumns;
|
||||||
|
// this.metaData = new RestfulResultSetMetaData(this.database, this.columns, this);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public Field findField(String columnName, List<JSONObject> fieldJsonList) {
|
||||||
|
// for (JSONObject fieldJSON : fieldJsonList) {
|
||||||
|
// JSONArray fieldDataJson = fieldJSON.getJSONArray("data");
|
||||||
|
// for (int i = 0; i < fieldDataJson.size(); i++) {
|
||||||
|
// JSONArray field = fieldDataJson.getJSONArray(i);
|
||||||
|
// if (columnName.equalsIgnoreCase(field.getString(0))) {
|
||||||
|
// return new Field(field.getString(0), field.getString(1), field.getInteger(2), field.getString(3));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
public class Field {
|
public class Field {
|
||||||
String name;
|
String name;
|
||||||
String type;
|
int type;
|
||||||
int length;
|
int length;
|
||||||
String note;
|
String note;
|
||||||
|
|
||||||
public Field(String name, String type, int length, String note) {
|
public Field(String name, int type, int length, String note) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.taosdata.jdbc.TSDBConstants;
|
||||||
import java.sql.ResultSetMetaData;
|
import java.sql.ResultSetMetaData;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.sql.Types;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class RestfulResultSetMetaData implements ResultSetMetaData {
|
public class RestfulResultSetMetaData implements ResultSetMetaData {
|
||||||
|
@ -53,14 +54,14 @@ public class RestfulResultSetMetaData implements ResultSetMetaData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSigned(int column) throws SQLException {
|
public boolean isSigned(int column) throws SQLException {
|
||||||
String type = this.fields.get(column - 1).type.toUpperCase();
|
int type = this.fields.get(column - 1).type;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "TINYINT":
|
case Types.TINYINT:
|
||||||
case "SMALLINT":
|
case Types.SMALLINT:
|
||||||
case "INT":
|
case Types.INTEGER:
|
||||||
case "BIGINT":
|
case Types.BIGINT:
|
||||||
case "FLOAT":
|
case Types.FLOAT:
|
||||||
case "DOUBLE":
|
case Types.DOUBLE:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -89,14 +90,14 @@ public class RestfulResultSetMetaData implements ResultSetMetaData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPrecision(int column) throws SQLException {
|
public int getPrecision(int column) throws SQLException {
|
||||||
String type = this.fields.get(column - 1).type.toUpperCase();
|
int type = this.fields.get(column - 1).type;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "FLOAT":
|
case Types.FLOAT:
|
||||||
return 5;
|
return 5;
|
||||||
case "DOUBLE":
|
case Types.DOUBLE:
|
||||||
return 9;
|
return 9;
|
||||||
case "BINARY":
|
case Types.BINARY:
|
||||||
case "NCHAR":
|
case Types.NCHAR:
|
||||||
return this.fields.get(column - 1).length;
|
return this.fields.get(column - 1).length;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -105,11 +106,11 @@ public class RestfulResultSetMetaData implements ResultSetMetaData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getScale(int column) throws SQLException {
|
public int getScale(int column) throws SQLException {
|
||||||
String type = this.fields.get(column - 1).type.toUpperCase();
|
int type = this.fields.get(column - 1).type;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "FLOAT":
|
case Types.FLOAT:
|
||||||
return 5;
|
return 5;
|
||||||
case "DOUBLE":
|
case Types.DOUBLE:
|
||||||
return 9;
|
return 9;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -128,36 +129,13 @@ public class RestfulResultSetMetaData implements ResultSetMetaData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnType(int column) throws SQLException {
|
public int getColumnType(int column) throws SQLException {
|
||||||
String type = this.fields.get(column - 1).type.toUpperCase();
|
return this.fields.get(column - 1).type;
|
||||||
switch (type) {
|
|
||||||
case "BOOL":
|
|
||||||
return java.sql.Types.BOOLEAN;
|
|
||||||
case "TINYINT":
|
|
||||||
return java.sql.Types.TINYINT;
|
|
||||||
case "SMALLINT":
|
|
||||||
return java.sql.Types.SMALLINT;
|
|
||||||
case "INT":
|
|
||||||
return java.sql.Types.INTEGER;
|
|
||||||
case "BIGINT":
|
|
||||||
return java.sql.Types.BIGINT;
|
|
||||||
case "FLOAT":
|
|
||||||
return java.sql.Types.FLOAT;
|
|
||||||
case "DOUBLE":
|
|
||||||
return java.sql.Types.DOUBLE;
|
|
||||||
case "BINARY":
|
|
||||||
return java.sql.Types.BINARY;
|
|
||||||
case "TIMESTAMP":
|
|
||||||
return java.sql.Types.TIMESTAMP;
|
|
||||||
case "NCHAR":
|
|
||||||
return java.sql.Types.NCHAR;
|
|
||||||
}
|
|
||||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColumnTypeName(int column) throws SQLException {
|
public String getColumnTypeName(int column) throws SQLException {
|
||||||
String type = fields.get(column - 1).type;
|
int type = fields.get(column - 1).type;
|
||||||
return type.toUpperCase();
|
return TSDBConstants.jdbcType2TaosTypeName(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -177,26 +155,26 @@ public class RestfulResultSetMetaData implements ResultSetMetaData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColumnClassName(int column) throws SQLException {
|
public String getColumnClassName(int column) throws SQLException {
|
||||||
String type = this.fields.get(column - 1).type;
|
int type = this.fields.get(column - 1).type;
|
||||||
String columnClassName = "";
|
String columnClassName = "";
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "BOOL":
|
case Types.BOOLEAN:
|
||||||
return Boolean.class.getName();
|
return Boolean.class.getName();
|
||||||
case "TINYINT":
|
case Types.TINYINT:
|
||||||
case "SMALLINT":
|
case Types.SMALLINT:
|
||||||
return Short.class.getName();
|
return Short.class.getName();
|
||||||
case "INT":
|
case Types.INTEGER:
|
||||||
return Integer.class.getName();
|
return Integer.class.getName();
|
||||||
case "BIGINT":
|
case Types.BIGINT:
|
||||||
return Long.class.getName();
|
return Long.class.getName();
|
||||||
case "FLOAT":
|
case Types.FLOAT:
|
||||||
return Float.class.getName();
|
return Float.class.getName();
|
||||||
case "DOUBLE":
|
case Types.DOUBLE:
|
||||||
return Double.class.getName();
|
return Double.class.getName();
|
||||||
case "TIMESTAMP":
|
case Types.TIMESTAMP:
|
||||||
return Timestamp.class.getName();
|
return Timestamp.class.getName();
|
||||||
case "BINARY":
|
case Types.BINARY:
|
||||||
case "NCHAR":
|
case Types.NCHAR:
|
||||||
return String.class.getName();
|
return String.class.getName();
|
||||||
}
|
}
|
||||||
return columnClassName;
|
return columnClassName;
|
||||||
|
|
|
@ -151,22 +151,21 @@ public class RestfulStatement extends AbstractStatement {
|
||||||
throw new SQLException(TSDBConstants.WrapErrMsg("SQL execution error: " + resultJson.getString("desc") + "\n" + "error code: " + resultJson.getString("code")));
|
throw new SQLException(TSDBConstants.WrapErrMsg("SQL execution error: " + resultJson.getString("desc") + "\n" + "error code: " + resultJson.getString("code")));
|
||||||
}
|
}
|
||||||
// parse table name from sql
|
// parse table name from sql
|
||||||
String[] tableIdentifiers = parseTableIdentifier(sql);
|
// String[] tableIdentifiers = parseTableIdentifier(sql);
|
||||||
if (tableIdentifiers != null) {
|
// if (tableIdentifiers != null) {
|
||||||
List<JSONObject> fieldJsonList = new ArrayList<>();
|
// List<JSONObject> fieldJsonList = new ArrayList<>();
|
||||||
for (String tableIdentifier : tableIdentifiers) {
|
// for (String tableIdentifier : tableIdentifiers) {
|
||||||
// field meta
|
// String fields = HttpClientPoolUtil.execute(url, "DESCRIBE " + tableIdentifier);
|
||||||
String fields = HttpClientPoolUtil.execute(url, "DESCRIBE " + tableIdentifier);
|
// JSONObject fieldJson = JSON.parseObject(fields);
|
||||||
JSONObject fieldJson = JSON.parseObject(fields);
|
// if (fieldJson.getString("status").equals("error")) {
|
||||||
if (fieldJson.getString("status").equals("error")) {
|
// throw new SQLException(TSDBConstants.WrapErrMsg("SQL execution error: " + fieldJson.getString("desc") + "\n" + "error code: " + fieldJson.getString("code")));
|
||||||
throw new SQLException(TSDBConstants.WrapErrMsg("SQL execution error: " + fieldJson.getString("desc") + "\n" + "error code: " + fieldJson.getString("code")));
|
// }
|
||||||
}
|
// fieldJsonList.add(fieldJson);
|
||||||
fieldJsonList.add(fieldJson);
|
// }
|
||||||
}
|
// this.resultSet = new RestfulResultSet(database, this, resultJson, fieldJsonList);
|
||||||
this.resultSet = new RestfulResultSet(database, this, resultJson, fieldJsonList);
|
// } else {
|
||||||
} else {
|
|
||||||
this.resultSet = new RestfulResultSet(database, this, resultJson);
|
this.resultSet = new RestfulResultSet(database, this, resultJson);
|
||||||
}
|
// }
|
||||||
this.affectedRows = 0;
|
this.affectedRows = 0;
|
||||||
return resultSet;
|
return resultSet;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +200,7 @@ public class RestfulStatement extends AbstractStatement {
|
||||||
@Override
|
@Override
|
||||||
public ResultSet getResultSet() throws SQLException {
|
public ResultSet getResultSet() throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||||
return resultSet;
|
return resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import java.util.HashMap;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class ResultSetTest {
|
public class ResultSetTest {
|
||||||
static Connection connection;
|
static Connection connection;
|
||||||
|
|
|
@ -48,29 +48,28 @@ public class SubscribeTest {
|
||||||
@Test
|
@Test
|
||||||
public void subscribe() {
|
public void subscribe() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String rawSql = "select * from " + dbName + "." + tName + ";";
|
String rawSql = "select * from " + dbName + "." + tName + ";";
|
||||||
System.out.println(rawSql);
|
System.out.println(rawSql);
|
||||||
TSDBSubscribe subscribe = ((TSDBConnection) connection).subscribe(topic, rawSql, false);
|
// TSDBSubscribe subscribe = ((TSDBConnection) connection).subscribe(topic, rawSql, false);
|
||||||
|
|
||||||
int a = 0;
|
// int a = 0;
|
||||||
while (true) {
|
// while (true) {
|
||||||
TimeUnit.MILLISECONDS.sleep(1000);
|
// TimeUnit.MILLISECONDS.sleep(1000);
|
||||||
TSDBResultSet resSet = subscribe.consume();
|
// TSDBResultSet resSet = subscribe.consume();
|
||||||
while (resSet.next()) {
|
// while (resSet.next()) {
|
||||||
for (int i = 1; i <= resSet.getMetaData().getColumnCount(); i++) {
|
// for (int i = 1; i <= resSet.getMetaData().getColumnCount(); i++) {
|
||||||
System.out.printf(i + ": " + resSet.getString(i) + "\t");
|
// System.out.printf(i + ": " + resSet.getString(i) + "\t");
|
||||||
}
|
// }
|
||||||
System.out.println("\n======" + a + "==========");
|
// System.out.println("\n======" + a + "==========");
|
||||||
}
|
// }
|
||||||
a++;
|
// a++;
|
||||||
if (a >= 2) {
|
// if (a >= 2) {
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
// resSet.close();
|
// resSet.close();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
subscribe.close(true);
|
// subscribe.close(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
package com.taosdata.jdbc;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.SQLWarning;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TSDBJNIConnectorTest {
|
||||||
|
|
||||||
|
private static TSDBResultSetRowData rowData;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
try {
|
||||||
|
// init
|
||||||
|
TSDBJNIConnector.init(null, null, null, null);
|
||||||
|
// connect
|
||||||
|
TSDBJNIConnector connector = new TSDBJNIConnector();
|
||||||
|
connector.connect("127.0.0.1", 6030, null, "root", "taosdata");
|
||||||
|
// executeQuery
|
||||||
|
long pSql = connector.executeQuery("show variables");
|
||||||
|
if (connector.isUpdateQuery(pSql)) {
|
||||||
|
connector.freeResultSet(pSql);
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEQUERY);
|
||||||
|
}
|
||||||
|
// get schema
|
||||||
|
List<ColumnMetaData> columnMetaDataList = new ArrayList<>();
|
||||||
|
int code = connector.getSchemaMetaData(pSql, columnMetaDataList);
|
||||||
|
if (code == TSDBConstants.JNI_CONNECTION_NULL) {
|
||||||
|
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
||||||
|
}
|
||||||
|
if (code == TSDBConstants.JNI_RESULT_SET_NULL) {
|
||||||
|
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_RESULT_SET_NULL));
|
||||||
|
}
|
||||||
|
if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) {
|
||||||
|
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_NUM_OF_FIELDS_0));
|
||||||
|
}
|
||||||
|
int columnSize = columnMetaDataList.size();
|
||||||
|
// print metadata
|
||||||
|
for (int i = 0; i < columnSize; i++) {
|
||||||
|
System.out.println(columnMetaDataList.get(i));
|
||||||
|
}
|
||||||
|
rowData = new TSDBResultSetRowData(columnSize);
|
||||||
|
// iterate resultSet
|
||||||
|
for (int i = 0; next(connector, pSql); i++) {
|
||||||
|
System.out.println("col[" + i + "] size: " + rowData.getColSize());
|
||||||
|
rowData.getData().stream().forEach(col -> System.out.print(col + "\t"));
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
// close resultSet
|
||||||
|
code = connector.freeResultSet(pSql);
|
||||||
|
if (code == TSDBConstants.JNI_CONNECTION_NULL) {
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL);
|
||||||
|
} else if (code == TSDBConstants.JNI_RESULT_SET_NULL) {
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL);
|
||||||
|
}
|
||||||
|
// close statement
|
||||||
|
|
||||||
|
// close connection
|
||||||
|
connector.closeConnection();
|
||||||
|
|
||||||
|
} catch (SQLWarning throwables) {
|
||||||
|
throwables.printStackTrace();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean next(TSDBJNIConnector connector, long pSql) throws SQLException {
|
||||||
|
if (rowData != null)
|
||||||
|
rowData.clear();
|
||||||
|
|
||||||
|
int code = connector.fetchRow(pSql, rowData);
|
||||||
|
if (code == TSDBConstants.JNI_CONNECTION_NULL) {
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL);
|
||||||
|
} else if (code == TSDBConstants.JNI_RESULT_SET_NULL) {
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL);
|
||||||
|
} else if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) {
|
||||||
|
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_NUM_OF_FIELDS_0);
|
||||||
|
} else if (code == TSDBConstants.JNI_FETCH_END) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.taosdata.jdbc.cases;
|
||||||
|
|
||||||
|
import com.taosdata.jdbc.utils.TimestampUtil;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
|
||||||
|
public class DatetimeBefore1970Test {
|
||||||
|
|
||||||
|
private static Connection conn;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
try (Statement stmt = conn.createStatement()) {
|
||||||
|
stmt.executeUpdate("insert into weather(ts) values('1969-12-31 23:59:59.999')");
|
||||||
|
stmt.executeUpdate("insert into weather(ts) values('1970-01-01 00:00:00.000')");
|
||||||
|
stmt.executeUpdate("insert into weather(ts) values('1970-01-01 08:00:00.000')");
|
||||||
|
stmt.executeUpdate("insert into weather(ts) values('1970-01-01 07:59:59.999')");
|
||||||
|
|
||||||
|
ResultSet rs = stmt.executeQuery("select * from weather");
|
||||||
|
while (rs.next()) {
|
||||||
|
Timestamp ts = rs.getTimestamp("ts");
|
||||||
|
System.out.println("long: " + ts.getTime() + ", string: " + TimestampUtil.longToDatetime(ts.getTime()));
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("timestamp: " + Long.MAX_VALUE + ", string: " + TimestampUtil.longToDatetime(Long.MAX_VALUE));
|
||||||
|
System.out.println("timestamp: " + Long.MIN_VALUE + ", string: " + TimestampUtil.longToDatetime(Long.MIN_VALUE));
|
||||||
|
System.out.println("timestamp: " + 0 + ", string: " + TimestampUtil.longToDatetime(0));
|
||||||
|
System.out.println("timestamp: " + -1 + ", string: " + TimestampUtil.longToDatetime(-1));
|
||||||
|
String datetime = "1970-01-01 00:00:00.000";
|
||||||
|
System.out.println("timestamp: " + TimestampUtil.datetimeToLong(datetime) + ", string: " + datetime);
|
||||||
|
datetime = "1969-12-31 23:59:59.999";
|
||||||
|
System.out.println("timestamp: " + TimestampUtil.datetimeToLong(datetime) + ", string: " + datetime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void beforeClass() {
|
||||||
|
try {
|
||||||
|
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||||
|
conn = DriverManager.getConnection("jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata");
|
||||||
|
Statement stmt = conn.createStatement();
|
||||||
|
stmt.execute("drop database if exists test_timestamp");
|
||||||
|
stmt.execute("create database if not exists test_timestamp keep 36500");
|
||||||
|
stmt.execute("use test_timestamp");
|
||||||
|
stmt.execute("create table weather(ts timestamp,f1 float)");
|
||||||
|
stmt.close();
|
||||||
|
} catch (ClassNotFoundException | SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void afterClass() {
|
||||||
|
try {
|
||||||
|
if (conn != null)
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,6 @@ import org.junit.Test;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class FailOverTest {
|
public class FailOverTest {
|
||||||
|
@ -18,13 +17,17 @@ public class FailOverTest {
|
||||||
|
|
||||||
long end = System.currentTimeMillis() + 1000 * 60 * 5;
|
long end = System.currentTimeMillis() + 1000 * 60 * 5;
|
||||||
while (System.currentTimeMillis() < end) {
|
while (System.currentTimeMillis() < end) {
|
||||||
try (Connection conn = DriverManager.getConnection(url)) {
|
try (Connection conn = DriverManager.getConnection(url); Statement stmt = conn.createStatement()) {
|
||||||
Statement stmt = conn.createStatement();
|
ResultSet rs = stmt.executeQuery("show dnodes");
|
||||||
ResultSet resultSet = stmt.executeQuery("select server_status()");
|
ResultSetMetaData meta = rs.getMetaData();
|
||||||
resultSet.next();
|
while (rs.next()) {
|
||||||
int status = resultSet.getInt("server_status()");
|
for (int i = 1; i <= meta.getColumnCount(); i++) {
|
||||||
System.out.println(">>>>>>>>>" + sdf.format(new Date()) + " status : " + status);
|
System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t");
|
||||||
stmt.close();
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
System.out.println("=======================");
|
||||||
|
rs.close();
|
||||||
TimeUnit.SECONDS.sleep(5);
|
TimeUnit.SECONDS.sleep(5);
|
||||||
} catch (SQLException | InterruptedException e) {
|
} catch (SQLException | InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -323,6 +323,18 @@ public class SQLTest {
|
||||||
SQLExecutor.executeQuery(connection, sql);
|
SQLExecutor.executeQuery(connection, sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCase052() {
|
||||||
|
String sql = "select server_status()";
|
||||||
|
SQLExecutor.executeQuery(connection, sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCase053() {
|
||||||
|
String sql = "select avg(cpu_taosd), avg(cpu_system), max(cpu_cores), avg(mem_taosd), avg(mem_system), max(mem_total), avg(disk_used), max(disk_total), avg(band_speed), avg(io_read), avg(io_write), sum(req_http), sum(req_select), sum(req_insert) from log.dn1 where ts> now - 60m and ts<= now interval(1m) fill(value, 0)";
|
||||||
|
SQLExecutor.executeQuery(connection, sql);
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void before() throws ClassNotFoundException, SQLException {
|
public static void before() throws ClassNotFoundException, SQLException {
|
||||||
Class.forName("com.taosdata.jdbc.rs.RestfulDriver");
|
Class.forName("com.taosdata.jdbc.rs.RestfulDriver");
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class TimeStampUtil {
|
public class TimestampUtil {
|
||||||
|
|
||||||
private static final String datetimeFormat = "yyyy-MM-dd HH:mm:ss.SSS";
|
private static final String datetimeFormat = "yyyy-MM-dd HH:mm:ss.SSS";
|
||||||
|
|
|
@ -31,6 +31,10 @@ IF (TD_MQTT)
|
||||||
TARGET_LINK_LIBRARIES(taosd mqtt)
|
TARGET_LINK_LIBRARIES(taosd mqtt)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
IF (TD_TOPIC)
|
||||||
|
TARGET_LINK_LIBRARIES(taosd topic)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
SET(PREPARE_ENV_CMD "prepare_env_cmd")
|
SET(PREPARE_ENV_CMD "prepare_env_cmd")
|
||||||
SET(PREPARE_ENV_TARGET "prepare_env_target")
|
SET(PREPARE_ENV_TARGET "prepare_env_target")
|
||||||
ADD_CUSTOM_COMMAND(OUTPUT ${PREPARE_ENV_CMD}
|
ADD_CUSTOM_COMMAND(OUTPUT ${PREPARE_ENV_CMD}
|
||||||
|
|
|
@ -29,7 +29,7 @@ typedef struct {
|
||||||
static SCheckItem tsCheckItem[TSDB_CHECK_ITEM_MAX] = {{0}};
|
static SCheckItem tsCheckItem[TSDB_CHECK_ITEM_MAX] = {{0}};
|
||||||
int64_t tsMinFreeMemSizeForStart = 0;
|
int64_t tsMinFreeMemSizeForStart = 0;
|
||||||
|
|
||||||
static int32_t bindTcpPort(int16_t port) {
|
static int32_t bindTcpPort(uint16_t port) {
|
||||||
SOCKET serverSocket;
|
SOCKET serverSocket;
|
||||||
struct sockaddr_in server_addr;
|
struct sockaddr_in server_addr;
|
||||||
|
|
||||||
|
@ -85,9 +85,9 @@ static int32_t bindUdpPort(int16_t port) {
|
||||||
|
|
||||||
static int32_t dnodeCheckNetwork() {
|
static int32_t dnodeCheckNetwork() {
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
int16_t startPort = tsServerPort;
|
uint16_t startPort = tsServerPort;
|
||||||
|
|
||||||
for (int16_t port = startPort; port < startPort + 12; port++) {
|
for (uint16_t port = startPort; port < startPort + 12; port++) {
|
||||||
ret = bindTcpPort(port);
|
ret = bindTcpPort(port);
|
||||||
if (0 != ret) {
|
if (0 != ret) {
|
||||||
dError("failed to tcp bind port %d, quit", port);
|
dError("failed to tcp bind port %d, quit", port);
|
||||||
|
|
|
@ -189,6 +189,11 @@ static void dnodeCheckDataDirOpenned(char *dir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dnodeInitStorage() {
|
static int32_t dnodeInitStorage() {
|
||||||
|
if (tsDiskCfgNum == 1 && dnodeCreateDir(tsDataDir) < 0) {
|
||||||
|
dError("failed to create dir: %s, reason: %s", tsDataDir, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (tfsInit(tsDiskCfg, tsDiskCfgNum) < 0) {
|
if (tfsInit(tsDiskCfg, tsDiskCfgNum) < 0) {
|
||||||
dError("failed to init TFS since %s", tstrerror(terrno));
|
dError("failed to init TFS since %s", tstrerror(terrno));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -47,8 +47,11 @@ int32_t dnodeInitShell() {
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_DNODE]= dnodeDispatchToMWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_DNODE]= dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_DNODE] = dnodeDispatchToMWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_DNODE] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_DB] = dnodeDispatchToMWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_DB] = dnodeDispatchToMWriteQueue;
|
||||||
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_TP] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_DB] = dnodeDispatchToMWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_DB] = dnodeDispatchToMWriteQueue;
|
||||||
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_TP] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_DB] = dnodeDispatchToMWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_DB] = dnodeDispatchToMWriteQueue;
|
||||||
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_TP] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_TABLE]= dnodeDispatchToMWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_TABLE]= dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_TABLE] = dnodeDispatchToMWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_TABLE] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_TABLE] = dnodeDispatchToMWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_TABLE] = dnodeDispatchToMWriteQueue;
|
||||||
|
|
|
@ -198,6 +198,14 @@ void dnodeCleanupVnodes() {
|
||||||
static void dnodeProcessStatusRsp(SRpcMsg *pMsg) {
|
static void dnodeProcessStatusRsp(SRpcMsg *pMsg) {
|
||||||
if (pMsg->code != TSDB_CODE_SUCCESS) {
|
if (pMsg->code != TSDB_CODE_SUCCESS) {
|
||||||
dError("status rsp is received, error:%s", tstrerror(pMsg->code));
|
dError("status rsp is received, error:%s", tstrerror(pMsg->code));
|
||||||
|
if (pMsg->code == TSDB_CODE_MND_DNODE_NOT_EXIST) {
|
||||||
|
char clusterId[TSDB_CLUSTER_ID_LEN];
|
||||||
|
dnodeGetClusterId(clusterId);
|
||||||
|
if (clusterId[0] != '\0') {
|
||||||
|
dError("exit zombie dropped dnode");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer);
|
taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,6 +222,9 @@ do { \
|
||||||
#define TSDB_MQTT_TOPIC_LEN 64
|
#define TSDB_MQTT_TOPIC_LEN 64
|
||||||
#define TSDB_MQTT_CLIENT_ID_LEN 32
|
#define TSDB_MQTT_CLIENT_ID_LEN 32
|
||||||
|
|
||||||
|
#define TSDB_DB_TYPE_DEFAULT 0
|
||||||
|
#define TSDB_DB_TYPE_TOPIC 1
|
||||||
|
|
||||||
#define TSDB_DEFAULT_PKT_SIZE 65480 //same as RPC_MAX_UDP_SIZE
|
#define TSDB_DEFAULT_PKT_SIZE 65480 //same as RPC_MAX_UDP_SIZE
|
||||||
|
|
||||||
#define TSDB_PAYLOAD_SIZE TSDB_DEFAULT_PKT_SIZE
|
#define TSDB_PAYLOAD_SIZE TSDB_DEFAULT_PKT_SIZE
|
||||||
|
@ -286,7 +289,7 @@ do { \
|
||||||
#define TSDB_MAX_COMP_LEVEL 2
|
#define TSDB_MAX_COMP_LEVEL 2
|
||||||
#define TSDB_DEFAULT_COMP_LEVEL 2
|
#define TSDB_DEFAULT_COMP_LEVEL 2
|
||||||
|
|
||||||
#define TSDB_MIN_WAL_LEVEL 1
|
#define TSDB_MIN_WAL_LEVEL 0
|
||||||
#define TSDB_MAX_WAL_LEVEL 2
|
#define TSDB_MAX_WAL_LEVEL 2
|
||||||
#define TSDB_DEFAULT_WAL_LEVEL 1
|
#define TSDB_DEFAULT_WAL_LEVEL 1
|
||||||
|
|
||||||
|
@ -306,6 +309,10 @@ do { \
|
||||||
#define TSDB_MAX_DB_REPLICA_OPTION 3
|
#define TSDB_MAX_DB_REPLICA_OPTION 3
|
||||||
#define TSDB_DEFAULT_DB_REPLICA_OPTION 1
|
#define TSDB_DEFAULT_DB_REPLICA_OPTION 1
|
||||||
|
|
||||||
|
#define TSDB_MIN_DB_PARTITON_OPTION 0
|
||||||
|
#define TSDB_MAX_DB_PARTITON_OPTION 1000
|
||||||
|
#define TSDB_DEFAULT_DB_PARTITON_OPTION 4
|
||||||
|
|
||||||
#define TSDB_MIN_DB_QUORUM_OPTION 1
|
#define TSDB_MIN_DB_QUORUM_OPTION 1
|
||||||
#define TSDB_MAX_DB_QUORUM_OPTION 2
|
#define TSDB_MAX_DB_QUORUM_OPTION 2
|
||||||
#define TSDB_DEFAULT_DB_QUORUM_OPTION 1
|
#define TSDB_DEFAULT_DB_QUORUM_OPTION 1
|
||||||
|
|
|
@ -185,6 +185,9 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MND_INVALID_DB_OPTION_DAYS TAOS_DEF_ERROR_CODE(0, 0x0390) //"Invalid database option: days out of range")
|
#define TSDB_CODE_MND_INVALID_DB_OPTION_DAYS TAOS_DEF_ERROR_CODE(0, 0x0390) //"Invalid database option: days out of range")
|
||||||
#define TSDB_CODE_MND_INVALID_DB_OPTION_KEEP TAOS_DEF_ERROR_CODE(0, 0x0391) //"Invalid database option: keep >= keep1 >= keep0 >= days")
|
#define TSDB_CODE_MND_INVALID_DB_OPTION_KEEP TAOS_DEF_ERROR_CODE(0, 0x0391) //"Invalid database option: keep >= keep1 >= keep0 >= days")
|
||||||
|
|
||||||
|
#define TSDB_CODE_MND_INVALID_TOPIC TAOS_DEF_ERROR_CODE(0, 0x0392) //"Invalid topic name)
|
||||||
|
#define TSDB_CODE_MND_INVALID_TOPIC_OPTION TAOS_DEF_ERROR_CODE(0, 0x0393) //"Invalid topic option)
|
||||||
|
|
||||||
// dnode
|
// dnode
|
||||||
#define TSDB_CODE_DND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0400) //"Message not processed")
|
#define TSDB_CODE_DND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0400) //"Message not processed")
|
||||||
#define TSDB_CODE_DND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0401) //"Dnode out of memory")
|
#define TSDB_CODE_DND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0401) //"Dnode out of memory")
|
||||||
|
|
|
@ -107,6 +107,12 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY13, "dummy13" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY14, "dummy14" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY14, "dummy14" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_NETWORK_TEST, "nettest" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_NETWORK_TEST, "nettest" )
|
||||||
|
|
||||||
|
// message for topic
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_TP, "create-tp" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_TP, "drop-tp" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_USE_TP, "use-tp" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_TP, "alter-tp" )
|
||||||
|
|
||||||
#ifndef TAOS_MESSAGE_C
|
#ifndef TAOS_MESSAGE_C
|
||||||
TSDB_MSG_TYPE_MAX // 105
|
TSDB_MSG_TYPE_MAX // 105
|
||||||
#endif
|
#endif
|
||||||
|
@ -141,6 +147,7 @@ enum _mgmt_table {
|
||||||
TSDB_MGMT_TABLE_VNODES,
|
TSDB_MGMT_TABLE_VNODES,
|
||||||
TSDB_MGMT_TABLE_STREAMTABLES,
|
TSDB_MGMT_TABLE_STREAMTABLES,
|
||||||
TSDB_MGMT_TABLE_CLUSTER,
|
TSDB_MGMT_TABLE_CLUSTER,
|
||||||
|
TSDB_MGMT_TABLE_TP,
|
||||||
TSDB_MGMT_TABLE_MAX,
|
TSDB_MGMT_TABLE_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -555,7 +562,9 @@ typedef struct {
|
||||||
int8_t ignoreExist;
|
int8_t ignoreExist;
|
||||||
int8_t update;
|
int8_t update;
|
||||||
int8_t cacheLastRow;
|
int8_t cacheLastRow;
|
||||||
int8_t reserve[8];
|
int8_t dbType;
|
||||||
|
int16_t partitions;
|
||||||
|
int8_t reserve[5];
|
||||||
} SCreateDbMsg, SAlterDbMsg;
|
} SCreateDbMsg, SAlterDbMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -674,7 +683,8 @@ typedef struct {
|
||||||
int8_t cacheLastRow;
|
int8_t cacheLastRow;
|
||||||
int32_t vgCfgVersion;
|
int32_t vgCfgVersion;
|
||||||
int8_t dbReplica;
|
int8_t dbReplica;
|
||||||
int8_t reserved[9];
|
int8_t dbType;
|
||||||
|
int8_t reserved[8];
|
||||||
} SVnodeCfg;
|
} SVnodeCfg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TDENGINE_TP
|
||||||
|
#define TDENGINE_TP
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int32_t tpInit();
|
||||||
|
void tpCleanUp();
|
||||||
|
void tpUpdateTs(int32_t *seq, void *pMsg);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -62,170 +62,176 @@
|
||||||
#define TK_BITNOT 43
|
#define TK_BITNOT 43
|
||||||
#define TK_SHOW 44
|
#define TK_SHOW 44
|
||||||
#define TK_DATABASES 45
|
#define TK_DATABASES 45
|
||||||
#define TK_MNODES 46
|
#define TK_TOPICS 46
|
||||||
#define TK_DNODES 47
|
#define TK_MNODES 47
|
||||||
#define TK_ACCOUNTS 48
|
#define TK_DNODES 48
|
||||||
#define TK_USERS 49
|
#define TK_ACCOUNTS 49
|
||||||
#define TK_MODULES 50
|
#define TK_USERS 50
|
||||||
#define TK_QUERIES 51
|
#define TK_MODULES 51
|
||||||
#define TK_CONNECTIONS 52
|
#define TK_QUERIES 52
|
||||||
#define TK_STREAMS 53
|
#define TK_CONNECTIONS 53
|
||||||
#define TK_VARIABLES 54
|
#define TK_STREAMS 54
|
||||||
#define TK_SCORES 55
|
#define TK_VARIABLES 55
|
||||||
#define TK_GRANTS 56
|
#define TK_SCORES 56
|
||||||
#define TK_VNODES 57
|
#define TK_GRANTS 57
|
||||||
#define TK_IPTOKEN 58
|
#define TK_VNODES 58
|
||||||
#define TK_DOT 59
|
#define TK_IPTOKEN 59
|
||||||
#define TK_CREATE 60
|
#define TK_DOT 60
|
||||||
#define TK_TABLE 61
|
#define TK_CREATE 61
|
||||||
#define TK_DATABASE 62
|
#define TK_TABLE 62
|
||||||
#define TK_TABLES 63
|
#define TK_DATABASE 63
|
||||||
#define TK_STABLES 64
|
#define TK_TABLES 64
|
||||||
#define TK_VGROUPS 65
|
#define TK_STABLES 65
|
||||||
#define TK_DROP 66
|
#define TK_VGROUPS 66
|
||||||
#define TK_STABLE 67
|
#define TK_DROP 67
|
||||||
#define TK_DNODE 68
|
#define TK_STABLE 68
|
||||||
#define TK_USER 69
|
#define TK_TOPIC 69
|
||||||
#define TK_ACCOUNT 70
|
#define TK_DNODE 70
|
||||||
#define TK_USE 71
|
#define TK_USER 71
|
||||||
#define TK_DESCRIBE 72
|
#define TK_ACCOUNT 72
|
||||||
#define TK_ALTER 73
|
#define TK_USE 73
|
||||||
#define TK_PASS 74
|
#define TK_DESCRIBE 74
|
||||||
#define TK_PRIVILEGE 75
|
#define TK_ALTER 75
|
||||||
#define TK_LOCAL 76
|
#define TK_PASS 76
|
||||||
#define TK_IF 77
|
#define TK_PRIVILEGE 77
|
||||||
#define TK_EXISTS 78
|
#define TK_LOCAL 78
|
||||||
#define TK_PPS 79
|
#define TK_IF 79
|
||||||
#define TK_TSERIES 80
|
#define TK_EXISTS 80
|
||||||
#define TK_DBS 81
|
#define TK_PPS 81
|
||||||
#define TK_STORAGE 82
|
#define TK_TSERIES 82
|
||||||
#define TK_QTIME 83
|
#define TK_DBS 83
|
||||||
#define TK_CONNS 84
|
#define TK_STORAGE 84
|
||||||
#define TK_STATE 85
|
#define TK_QTIME 85
|
||||||
#define TK_KEEP 86
|
#define TK_CONNS 86
|
||||||
#define TK_CACHE 87
|
#define TK_STATE 87
|
||||||
#define TK_REPLICA 88
|
#define TK_KEEP 88
|
||||||
#define TK_QUORUM 89
|
#define TK_CACHE 89
|
||||||
#define TK_DAYS 90
|
#define TK_REPLICA 90
|
||||||
#define TK_MINROWS 91
|
#define TK_QUORUM 91
|
||||||
#define TK_MAXROWS 92
|
#define TK_DAYS 92
|
||||||
#define TK_BLOCKS 93
|
#define TK_MINROWS 93
|
||||||
#define TK_CTIME 94
|
#define TK_MAXROWS 94
|
||||||
#define TK_WAL 95
|
#define TK_BLOCKS 95
|
||||||
#define TK_FSYNC 96
|
#define TK_CTIME 96
|
||||||
#define TK_COMP 97
|
#define TK_WAL 97
|
||||||
#define TK_PRECISION 98
|
#define TK_FSYNC 98
|
||||||
#define TK_UPDATE 99
|
#define TK_COMP 99
|
||||||
#define TK_CACHELAST 100
|
#define TK_PRECISION 100
|
||||||
#define TK_LP 101
|
#define TK_UPDATE 101
|
||||||
#define TK_RP 102
|
#define TK_CACHELAST 102
|
||||||
#define TK_UNSIGNED 103
|
#define TK_PARTITIONS 103
|
||||||
#define TK_TAGS 104
|
#define TK_LP 104
|
||||||
#define TK_USING 105
|
#define TK_RP 105
|
||||||
#define TK_COMMA 106
|
#define TK_UNSIGNED 106
|
||||||
#define TK_AS 107
|
#define TK_TAGS 107
|
||||||
#define TK_NULL 108
|
#define TK_USING 108
|
||||||
#define TK_SELECT 109
|
#define TK_COMMA 109
|
||||||
#define TK_UNION 110
|
#define TK_AS 110
|
||||||
#define TK_ALL 111
|
#define TK_NULL 111
|
||||||
#define TK_DISTINCT 112
|
#define TK_SELECT 112
|
||||||
#define TK_FROM 113
|
#define TK_UNION 113
|
||||||
#define TK_VARIABLE 114
|
#define TK_ALL 114
|
||||||
#define TK_INTERVAL 115
|
#define TK_DISTINCT 115
|
||||||
#define TK_FILL 116
|
#define TK_FROM 116
|
||||||
#define TK_SLIDING 117
|
#define TK_VARIABLE 117
|
||||||
#define TK_ORDER 118
|
#define TK_INTERVAL 118
|
||||||
#define TK_BY 119
|
#define TK_FILL 119
|
||||||
#define TK_ASC 120
|
#define TK_SLIDING 120
|
||||||
#define TK_DESC 121
|
#define TK_ORDER 121
|
||||||
#define TK_GROUP 122
|
#define TK_BY 122
|
||||||
#define TK_HAVING 123
|
#define TK_ASC 123
|
||||||
#define TK_LIMIT 124
|
#define TK_DESC 124
|
||||||
#define TK_OFFSET 125
|
#define TK_GROUP 125
|
||||||
#define TK_SLIMIT 126
|
#define TK_HAVING 126
|
||||||
#define TK_SOFFSET 127
|
#define TK_LIMIT 127
|
||||||
#define TK_WHERE 128
|
#define TK_OFFSET 128
|
||||||
#define TK_NOW 129
|
#define TK_SLIMIT 129
|
||||||
#define TK_RESET 130
|
#define TK_SOFFSET 130
|
||||||
#define TK_QUERY 131
|
#define TK_WHERE 131
|
||||||
#define TK_ADD 132
|
#define TK_NOW 132
|
||||||
#define TK_COLUMN 133
|
#define TK_RESET 133
|
||||||
#define TK_TAG 134
|
#define TK_QUERY 134
|
||||||
#define TK_CHANGE 135
|
#define TK_ADD 135
|
||||||
#define TK_SET 136
|
#define TK_COLUMN 136
|
||||||
#define TK_KILL 137
|
#define TK_TAG 137
|
||||||
#define TK_CONNECTION 138
|
#define TK_CHANGE 138
|
||||||
#define TK_STREAM 139
|
#define TK_SET 139
|
||||||
#define TK_COLON 140
|
#define TK_KILL 140
|
||||||
#define TK_ABORT 141
|
#define TK_CONNECTION 141
|
||||||
#define TK_AFTER 142
|
#define TK_STREAM 142
|
||||||
#define TK_ATTACH 143
|
#define TK_COLON 143
|
||||||
#define TK_BEFORE 144
|
#define TK_ABORT 144
|
||||||
#define TK_BEGIN 145
|
#define TK_AFTER 145
|
||||||
#define TK_CASCADE 146
|
#define TK_ATTACH 146
|
||||||
#define TK_CLUSTER 147
|
#define TK_BEFORE 147
|
||||||
#define TK_CONFLICT 148
|
#define TK_BEGIN 148
|
||||||
#define TK_COPY 149
|
#define TK_CASCADE 149
|
||||||
#define TK_DEFERRED 150
|
#define TK_CLUSTER 150
|
||||||
#define TK_DELIMITERS 151
|
#define TK_CONFLICT 151
|
||||||
#define TK_DETACH 152
|
#define TK_COPY 152
|
||||||
#define TK_EACH 153
|
#define TK_DEFERRED 153
|
||||||
#define TK_END 154
|
#define TK_DELIMITERS 154
|
||||||
#define TK_EXPLAIN 155
|
#define TK_DETACH 155
|
||||||
#define TK_FAIL 156
|
#define TK_EACH 156
|
||||||
#define TK_FOR 157
|
#define TK_END 157
|
||||||
#define TK_IGNORE 158
|
#define TK_EXPLAIN 158
|
||||||
#define TK_IMMEDIATE 159
|
#define TK_FAIL 159
|
||||||
#define TK_INITIALLY 160
|
#define TK_FOR 160
|
||||||
#define TK_INSTEAD 161
|
#define TK_IGNORE 161
|
||||||
#define TK_MATCH 162
|
#define TK_IMMEDIATE 162
|
||||||
#define TK_KEY 163
|
#define TK_INITIALLY 163
|
||||||
#define TK_OF 164
|
#define TK_INSTEAD 164
|
||||||
#define TK_RAISE 165
|
#define TK_MATCH 165
|
||||||
#define TK_REPLACE 166
|
#define TK_KEY 166
|
||||||
#define TK_RESTRICT 167
|
#define TK_OF 167
|
||||||
#define TK_ROW 168
|
#define TK_RAISE 168
|
||||||
#define TK_STATEMENT 169
|
#define TK_REPLACE 169
|
||||||
#define TK_TRIGGER 170
|
#define TK_RESTRICT 170
|
||||||
#define TK_VIEW 171
|
#define TK_ROW 171
|
||||||
#define TK_COUNT 172
|
#define TK_STATEMENT 172
|
||||||
#define TK_SUM 173
|
#define TK_TRIGGER 173
|
||||||
#define TK_AVG 174
|
#define TK_VIEW 174
|
||||||
#define TK_MIN 175
|
#define TK_COUNT 175
|
||||||
#define TK_MAX 176
|
#define TK_SUM 176
|
||||||
#define TK_FIRST 177
|
#define TK_AVG 177
|
||||||
#define TK_LAST 178
|
#define TK_MIN 178
|
||||||
#define TK_TOP 179
|
#define TK_MAX 179
|
||||||
#define TK_BOTTOM 180
|
#define TK_FIRST 180
|
||||||
#define TK_STDDEV 181
|
#define TK_LAST 181
|
||||||
#define TK_PERCENTILE 182
|
#define TK_TOP 182
|
||||||
#define TK_APERCENTILE 183
|
#define TK_BOTTOM 183
|
||||||
#define TK_LEASTSQUARES 184
|
#define TK_STDDEV 184
|
||||||
#define TK_HISTOGRAM 185
|
#define TK_PERCENTILE 185
|
||||||
#define TK_DIFF 186
|
#define TK_APERCENTILE 186
|
||||||
#define TK_SPREAD 187
|
#define TK_LEASTSQUARES 187
|
||||||
#define TK_TWA 188
|
#define TK_HISTOGRAM 188
|
||||||
#define TK_INTERP 189
|
#define TK_DIFF 189
|
||||||
#define TK_LAST_ROW 190
|
#define TK_SPREAD 190
|
||||||
#define TK_RATE 191
|
#define TK_TWA 191
|
||||||
#define TK_IRATE 192
|
#define TK_INTERP 192
|
||||||
#define TK_SUM_RATE 193
|
#define TK_LAST_ROW 193
|
||||||
#define TK_SUM_IRATE 194
|
#define TK_RATE 194
|
||||||
#define TK_AVG_RATE 195
|
#define TK_IRATE 195
|
||||||
#define TK_AVG_IRATE 196
|
#define TK_SUM_RATE 196
|
||||||
#define TK_TBID 197
|
#define TK_SUM_IRATE 197
|
||||||
#define TK_SEMI 198
|
#define TK_AVG_RATE 198
|
||||||
#define TK_NONE 199
|
#define TK_AVG_IRATE 199
|
||||||
#define TK_PREV 200
|
#define TK_TBID 200
|
||||||
#define TK_LINEAR 201
|
#define TK_SEMI 201
|
||||||
#define TK_IMPORT 202
|
#define TK_NONE 202
|
||||||
#define TK_METRIC 203
|
#define TK_PREV 203
|
||||||
#define TK_TBNAME 204
|
#define TK_LINEAR 204
|
||||||
#define TK_JOIN 205
|
#define TK_IMPORT 205
|
||||||
#define TK_METRICS 206
|
#define TK_METRIC 206
|
||||||
#define TK_INSERT 207
|
#define TK_TBNAME 207
|
||||||
#define TK_INTO 208
|
#define TK_JOIN 208
|
||||||
#define TK_VALUES 209
|
#define TK_METRICS 209
|
||||||
|
#define TK_INSERT 210
|
||||||
|
#define TK_INTO 211
|
||||||
|
#define TK_VALUES 212
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,17 @@
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"password": "taosdata",
|
"password": "taosdata",
|
||||||
"thread_count": 4,
|
"thread_count": 4,
|
||||||
"thread_count_create_tbl": 1,
|
"thread_count_create_tbl": 4,
|
||||||
"result_file": "./insert_res.txt",
|
"result_file": "./insert_res.txt",
|
||||||
"confirm_parameter_prompt": "no",
|
"confirm_parameter_prompt": "no",
|
||||||
|
"insert_interval": 0,
|
||||||
|
"num_of_records_per_req": 100,
|
||||||
"databases": [{
|
"databases": [{
|
||||||
"dbinfo": {
|
"dbinfo": {
|
||||||
"name": "db",
|
"name": "db",
|
||||||
"drop": "no",
|
"drop": "yes",
|
||||||
"replica": 1,
|
"replica": 1,
|
||||||
"days": 2,
|
"days": 10,
|
||||||
"cache": 16,
|
"cache": 16,
|
||||||
"blocks": 8,
|
"blocks": 8,
|
||||||
"precision": "ms",
|
"precision": "ms",
|
||||||
|
@ -23,6 +25,7 @@
|
||||||
"maxRows": 4096,
|
"maxRows": 4096,
|
||||||
"comp":2,
|
"comp":2,
|
||||||
"walLevel":1,
|
"walLevel":1,
|
||||||
|
"cachelast":0,
|
||||||
"quorum":1,
|
"quorum":1,
|
||||||
"fsync":3000,
|
"fsync":3000,
|
||||||
"update": 0
|
"update": 0
|
||||||
|
@ -30,20 +33,19 @@
|
||||||
"super_tables": [{
|
"super_tables": [{
|
||||||
"name": "stb",
|
"name": "stb",
|
||||||
"child_table_exists":"no",
|
"child_table_exists":"no",
|
||||||
"childtable_count": 1,
|
"childtable_count": 100,
|
||||||
"childtable_prefix": "stb_",
|
"childtable_prefix": "stb_",
|
||||||
"auto_create_table": "no",
|
"auto_create_table": "no",
|
||||||
"data_source": "rand",
|
"data_source": "rand",
|
||||||
"insert_mode": "taosc",
|
"insert_mode": "taosc",
|
||||||
"insert_rate": 0,
|
|
||||||
"insert_rows": 100000,
|
"insert_rows": 100000,
|
||||||
"multi_thread_write_one_tbl": "no",
|
"multi_thread_write_one_tbl": "no",
|
||||||
"number_of_tbl_in_one_sql": 1,
|
"number_of_tbl_in_one_sql": 0,
|
||||||
"rows_per_tbl": 100,
|
"rows_per_tbl": 100,
|
||||||
"max_sql_len": 1024000,
|
"max_sql_len": 1024000,
|
||||||
"disorder_ratio": 0,
|
"disorder_ratio": 0,
|
||||||
"disorder_range": 1000,
|
"disorder_range": 1000,
|
||||||
"timestamp_step": 10,
|
"timestamp_step": 1,
|
||||||
"start_timestamp": "2020-10-01 00:00:00.000",
|
"start_timestamp": "2020-10-01 00:00:00.000",
|
||||||
"sample_format": "csv",
|
"sample_format": "csv",
|
||||||
"sample_file": "./sample.csv",
|
"sample_file": "./sample.csv",
|
||||||
|
|
|
@ -6,13 +6,14 @@
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"password": "taosdata",
|
"password": "taosdata",
|
||||||
"confirm_parameter_prompt": "yes",
|
"confirm_parameter_prompt": "yes",
|
||||||
"databases": "db01",
|
"databases": "dbx",
|
||||||
"specified_table_query":
|
"specified_table_query":
|
||||||
{"query_interval":1, "concurrent":1,
|
{"query_interval":1, "concurrent":4,
|
||||||
"sqls": [{"sql": "select count(*) from stb01", "result": "./query_res0.txt"}]
|
"sqls": [{"sql": "select last_row(*) from stb where color='red'", "result": "./query_res0.txt"},
|
||||||
|
{"sql": "select count(*) from stb_01", "result": "./query_res1.txt"}]
|
||||||
},
|
},
|
||||||
"super_table_query":
|
"super_table_query":
|
||||||
{"stblname": "stb01", "query_interval":1, "threads":1,
|
{"stblname": "stb", "query_interval":1, "threads":4,
|
||||||
"sqls": [{"sql": "select count(*) from xxxx", "result": "./query_res1.txt"}]
|
"sqls": [{"sql": "select last_row(*) from xxxx", "result": "./query_res2.txt"}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"port": 6030,
|
"port": 6030,
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"password": "taosdata",
|
"password": "taosdata",
|
||||||
"databases": "db",
|
"databases": "dbx",
|
||||||
"specified_table_query":
|
"specified_table_query":
|
||||||
{"concurrent":1, "mode":"sync", "interval":5000, "restart":"yes", "keepProgress":"yes",
|
{"concurrent":1, "mode":"sync", "interval":5000, "restart":"yes", "keepProgress":"yes",
|
||||||
"sqls": [{"sql": "select avg(col1) from stb01 where col1 > 1;", "result": "./subscribe_res0.txt"}]
|
"sqls": [{"sql": "select avg(col1) from stb01 where col1 > 1;", "result": "./subscribe_res0.txt"}]
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -769,6 +769,7 @@ int32_t taosSaveTableOfMetricToTempFile(TAOS *taosCon, char* metric, struct argu
|
||||||
}
|
}
|
||||||
sprintf(tmpBuf, ".select-tbname.tmp");
|
sprintf(tmpBuf, ".select-tbname.tmp");
|
||||||
(void)remove(tmpBuf);
|
(void)remove(tmpBuf);
|
||||||
|
free(tblBuf);
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1523,6 +1524,7 @@ int taosDumpDb(SDbInfo *dbInfo, struct arguments *arguments, FILE *fp, TAOS *tao
|
||||||
}
|
}
|
||||||
sprintf(tmpBuf, ".show-tables.tmp");
|
sprintf(tmpBuf, ".show-tables.tmp");
|
||||||
(void)remove(tmpBuf);
|
(void)remove(tmpBuf);
|
||||||
|
free(tblBuf);
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,9 @@ typedef struct {
|
||||||
int8_t quorum;
|
int8_t quorum;
|
||||||
int8_t update;
|
int8_t update;
|
||||||
int8_t cacheLastRow;
|
int8_t cacheLastRow;
|
||||||
int8_t reserved[10];
|
int8_t dbType;
|
||||||
|
int16_t partitions;
|
||||||
|
int8_t reserved[7];
|
||||||
} SDbCfg;
|
} SDbCfg;
|
||||||
|
|
||||||
typedef struct SDbObj {
|
typedef struct SDbObj {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
#include "tbn.h"
|
#include "tbn.h"
|
||||||
#include "tdataformat.h"
|
#include "tdataformat.h"
|
||||||
|
#include "tp.h"
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
#include "mnodeDef.h"
|
#include "mnodeDef.h"
|
||||||
#include "mnodeInt.h"
|
#include "mnodeInt.h"
|
||||||
|
@ -39,7 +40,7 @@
|
||||||
|
|
||||||
#define VG_LIST_SIZE 8
|
#define VG_LIST_SIZE 8
|
||||||
int64_t tsDbRid = -1;
|
int64_t tsDbRid = -1;
|
||||||
static void * tsDbSdb = NULL;
|
void * tsDbSdb = NULL;
|
||||||
static int32_t tsDbUpdateSize;
|
static int32_t tsDbUpdateSize;
|
||||||
|
|
||||||
static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *pMsg);
|
static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *pMsg);
|
||||||
|
@ -48,8 +49,14 @@ static int32_t mnodeSetDbDropping(SDbObj *pDb);
|
||||||
static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
||||||
static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
static int32_t mnodeProcessCreateDbMsg(SMnodeMsg *pMsg);
|
static int32_t mnodeProcessCreateDbMsg(SMnodeMsg *pMsg);
|
||||||
static int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg);
|
|
||||||
static int32_t mnodeProcessDropDbMsg(SMnodeMsg *pMsg);
|
static int32_t mnodeProcessDropDbMsg(SMnodeMsg *pMsg);
|
||||||
|
int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg);
|
||||||
|
|
||||||
|
#ifndef _TOPIC
|
||||||
|
int32_t tpInit() { return 0; }
|
||||||
|
void tpCleanUp() {}
|
||||||
|
void tpUpdateTs(int32_t *seq, void *pMsg) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void mnodeDestroyDb(SDbObj *pDb) {
|
static void mnodeDestroyDb(SDbObj *pDb) {
|
||||||
pthread_mutex_destroy(&pDb->mutex);
|
pthread_mutex_destroy(&pDb->mutex);
|
||||||
|
@ -176,7 +183,7 @@ int32_t mnodeInitDbs() {
|
||||||
mnodeAddShowFreeIterHandle(TSDB_MGMT_TABLE_DB, mnodeCancelGetNextDb);
|
mnodeAddShowFreeIterHandle(TSDB_MGMT_TABLE_DB, mnodeCancelGetNextDb);
|
||||||
|
|
||||||
mDebug("table:dbs table is created");
|
mDebug("table:dbs table is created");
|
||||||
return 0;
|
return tpInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *mnodeGetNextDb(void *pIter, SDbObj **pDb) {
|
void *mnodeGetNextDb(void *pIter, SDbObj **pDb) {
|
||||||
|
@ -332,6 +339,17 @@ static int32_t mnodeCheckDbCfg(SDbCfg *pCfg) {
|
||||||
return TSDB_CODE_MND_INVALID_DB_OPTION;
|
return TSDB_CODE_MND_INVALID_DB_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pCfg->dbType < 0 || pCfg->dbType > 1) {
|
||||||
|
mError("invalid db option dbType:%d valid range: [%d, %d]", pCfg->dbType, 0, 1);
|
||||||
|
return TSDB_CODE_MND_INVALID_DB_OPTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pCfg->partitions < TSDB_MIN_DB_PARTITON_OPTION || pCfg->partitions > TSDB_MAX_DB_PARTITON_OPTION) {
|
||||||
|
mError("invalid db option partitions:%d valid range: [%d, %d]", pCfg->partitions, TSDB_MIN_DB_PARTITON_OPTION,
|
||||||
|
TSDB_MAX_DB_PARTITON_OPTION);
|
||||||
|
return TSDB_CODE_MND_INVALID_DB_OPTION;
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,6 +372,8 @@ static void mnodeSetDefaultDbCfg(SDbCfg *pCfg) {
|
||||||
if (pCfg->quorum < 0) pCfg->quorum = tsQuorum;
|
if (pCfg->quorum < 0) pCfg->quorum = tsQuorum;
|
||||||
if (pCfg->update < 0) pCfg->update = tsUpdate;
|
if (pCfg->update < 0) pCfg->update = tsUpdate;
|
||||||
if (pCfg->cacheLastRow < 0) pCfg->cacheLastRow = tsCacheLastRow;
|
if (pCfg->cacheLastRow < 0) pCfg->cacheLastRow = tsCacheLastRow;
|
||||||
|
if (pCfg->dbType < 0) pCfg->dbType = 0;
|
||||||
|
if (pCfg->partitions < 0) pCfg->partitions = tsPartitons;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeCreateDbCb(SMnodeMsg *pMsg, int32_t code) {
|
static int32_t mnodeCreateDbCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
|
@ -408,7 +428,9 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
|
||||||
.replications = pCreate->replications,
|
.replications = pCreate->replications,
|
||||||
.quorum = pCreate->quorum,
|
.quorum = pCreate->quorum,
|
||||||
.update = pCreate->update,
|
.update = pCreate->update,
|
||||||
.cacheLastRow = pCreate->cacheLastRow
|
.cacheLastRow = pCreate->cacheLastRow,
|
||||||
|
.dbType = pCreate->dbType,
|
||||||
|
.partitions = pCreate->partitions
|
||||||
};
|
};
|
||||||
|
|
||||||
mnodeSetDefaultDbCfg(&pDb->cfg);
|
mnodeSetDefaultDbCfg(&pDb->cfg);
|
||||||
|
@ -501,6 +523,7 @@ void mnodeRemoveVgroupFromDb(SVgObj *pVgroup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mnodeCleanupDbs() {
|
void mnodeCleanupDbs() {
|
||||||
|
tpCleanUp();
|
||||||
sdbCloseTable(tsDbRid);
|
sdbCloseTable(tsDbRid);
|
||||||
tsDbSdb = NULL;
|
tsDbSdb = NULL;
|
||||||
}
|
}
|
||||||
|
@ -660,7 +683,7 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *mnodeGetDbStr(char *src) {
|
char *mnodeGetDbStr(char *src) {
|
||||||
char *pos = strstr(src, TS_PATH_DELIMITER);
|
char *pos = strstr(src, TS_PATH_DELIMITER);
|
||||||
if (pos != NULL) ++pos;
|
if (pos != NULL) ++pos;
|
||||||
|
|
||||||
|
@ -852,6 +875,7 @@ static int32_t mnodeProcessCreateDbMsg(SMnodeMsg *pMsg) {
|
||||||
pCreate->daysToKeep2 = htonl(pCreate->daysToKeep2);
|
pCreate->daysToKeep2 = htonl(pCreate->daysToKeep2);
|
||||||
pCreate->commitTime = htonl(pCreate->commitTime);
|
pCreate->commitTime = htonl(pCreate->commitTime);
|
||||||
pCreate->fsyncPeriod = htonl(pCreate->fsyncPeriod);
|
pCreate->fsyncPeriod = htonl(pCreate->fsyncPeriod);
|
||||||
|
pCreate->partitions = htons(pCreate->partitions);
|
||||||
pCreate->minRowsPerFileBlock = htonl(pCreate->minRowsPerFileBlock);
|
pCreate->minRowsPerFileBlock = htonl(pCreate->minRowsPerFileBlock);
|
||||||
pCreate->maxRowsPerFileBlock = htonl(pCreate->maxRowsPerFileBlock);
|
pCreate->maxRowsPerFileBlock = htonl(pCreate->maxRowsPerFileBlock);
|
||||||
|
|
||||||
|
@ -887,6 +911,8 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
|
||||||
int8_t precision = pAlter->precision;
|
int8_t precision = pAlter->precision;
|
||||||
int8_t update = pAlter->update;
|
int8_t update = pAlter->update;
|
||||||
int8_t cacheLastRow = pAlter->cacheLastRow;
|
int8_t cacheLastRow = pAlter->cacheLastRow;
|
||||||
|
int8_t dbType = pAlter->dbType;
|
||||||
|
int16_t partitions = htons(pAlter->partitions);
|
||||||
|
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@ -1004,6 +1030,16 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
|
||||||
newCfg.cacheLastRow = cacheLastRow;
|
newCfg.cacheLastRow = cacheLastRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dbType >= 0 && dbType != pDb->cfg.dbType) {
|
||||||
|
mDebug("db:%s, dbType:%d change to %d", pDb->name, pDb->cfg.dbType, dbType);
|
||||||
|
newCfg.dbType = dbType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (partitions >= 0 && partitions != pDb->cfg.partitions) {
|
||||||
|
mDebug("db:%s, partitions:%d change to %d", pDb->name, pDb->cfg.partitions, partitions);
|
||||||
|
newCfg.partitions = partitions;
|
||||||
|
}
|
||||||
|
|
||||||
return newCfg;
|
return newCfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1031,6 +1067,8 @@ static int32_t mnodeAlterDbCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
|
static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
|
||||||
|
mDebug("db:%s, type:%d do alter operation", pDb->name, pDb->cfg.dbType);
|
||||||
|
|
||||||
SDbCfg newCfg = mnodeGetAlterDbOption(pDb, pAlter);
|
SDbCfg newCfg = mnodeGetAlterDbOption(pDb, pAlter);
|
||||||
if (terrno != TSDB_CODE_SUCCESS) {
|
if (terrno != TSDB_CODE_SUCCESS) {
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -1061,9 +1099,9 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg) {
|
int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg) {
|
||||||
SAlterDbMsg *pAlter = pMsg->rpcMsg.pCont;
|
SAlterDbMsg *pAlter = pMsg->rpcMsg.pCont;
|
||||||
mDebug("db:%s, alter db msg is received from thandle:%p", pAlter->db, pMsg->rpcMsg.handle);
|
mDebug("db:%s, alter db msg is received from thandle:%p, dbType:%d", pAlter->db, pMsg->rpcMsg.handle, pAlter->dbType);
|
||||||
|
|
||||||
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDb(pAlter->db);
|
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDb(pAlter->db);
|
||||||
if (pMsg->pDb == NULL) {
|
if (pMsg->pDb == NULL) {
|
||||||
|
|
|
@ -109,6 +109,7 @@ static char *mnodeGetShowType(int32_t showType) {
|
||||||
case TSDB_MGMT_TABLE_VNODES: return "show vnodes";
|
case TSDB_MGMT_TABLE_VNODES: return "show vnodes";
|
||||||
case TSDB_MGMT_TABLE_CLUSTER: return "show clusters";
|
case TSDB_MGMT_TABLE_CLUSTER: return "show clusters";
|
||||||
case TSDB_MGMT_TABLE_STREAMTABLES : return "show streamtables";
|
case TSDB_MGMT_TABLE_STREAMTABLES : return "show streamtables";
|
||||||
|
case TSDB_MGMT_TABLE_TP: return "show topics";
|
||||||
default: return "undefined";
|
default: return "undefined";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -832,12 +832,13 @@ static int32_t mnodeProcessBatchCreateTableMsg(SMnodeMsg *pMsg) {
|
||||||
return code;
|
return code;
|
||||||
} else if (code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
} else if (code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
++pMsg->pBatchMasterMsg->received;
|
++pMsg->pBatchMasterMsg->received;
|
||||||
|
pMsg->pBatchMasterMsg->code = code;
|
||||||
mnodeDestroySubMsg(pMsg);
|
mnodeDestroySubMsg(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received
|
if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received
|
||||||
>= pMsg->pBatchMasterMsg->expected) {
|
>= pMsg->pBatchMasterMsg->expected) {
|
||||||
dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, TSDB_CODE_SUCCESS);
|
dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, pMsg->pBatchMasterMsg->code);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
@ -916,11 +917,13 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
|
||||||
return TSDB_CODE_MND_DB_IN_DROPPING;
|
return TSDB_CODE_MND_DB_IN_DROPPING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (mnodeCheckIsMonitorDB(pMsg->pDb->name, tsMonitorDbName)) {
|
if (mnodeCheckIsMonitorDB(pMsg->pDb->name, tsMonitorDbName)) {
|
||||||
mError("msg:%p, app:%p table:%s, failed to drop table, in monitor database", pMsg, pMsg->rpcMsg.ahandle,
|
mError("msg:%p, app:%p table:%s, failed to drop table, in monitor database", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
pDrop->name);
|
pDrop->name);
|
||||||
return TSDB_CODE_MND_MONITOR_DB_FORBIDDEN;
|
return TSDB_CODE_MND_MONITOR_DB_FORBIDDEN;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pDrop->name);
|
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pDrop->name);
|
||||||
if (pMsg->pTable == NULL) {
|
if (pMsg->pTable == NULL) {
|
||||||
|
@ -1906,7 +1909,8 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
sdbDeleteRow(&desc);
|
sdbDeleteRow(&desc);
|
||||||
|
|
||||||
if (pMsg->pBatchMasterMsg) {
|
if (pMsg->pBatchMasterMsg) {
|
||||||
++pMsg->pBatchMasterMsg->successed;
|
++pMsg->pBatchMasterMsg->received;
|
||||||
|
pMsg->pBatchMasterMsg->code = code;
|
||||||
if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received
|
if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received
|
||||||
>= pMsg->pBatchMasterMsg->expected) {
|
>= pMsg->pBatchMasterMsg->expected) {
|
||||||
dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, code);
|
dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, code);
|
||||||
|
@ -2688,6 +2692,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
|
||||||
|
|
||||||
if (pMsg->pBatchMasterMsg) {
|
if (pMsg->pBatchMasterMsg) {
|
||||||
++pMsg->pBatchMasterMsg->received;
|
++pMsg->pBatchMasterMsg->received;
|
||||||
|
pMsg->pBatchMasterMsg->code = code;
|
||||||
if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received
|
if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received
|
||||||
>= pMsg->pBatchMasterMsg->expected) {
|
>= pMsg->pBatchMasterMsg->expected) {
|
||||||
dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, code);
|
dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, code);
|
||||||
|
@ -2726,6 +2731,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
|
||||||
|
|
||||||
if (pMsg->pBatchMasterMsg) {
|
if (pMsg->pBatchMasterMsg) {
|
||||||
++pMsg->pBatchMasterMsg->received;
|
++pMsg->pBatchMasterMsg->received;
|
||||||
|
pMsg->pBatchMasterMsg->code = rpcMsg->code;
|
||||||
if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received
|
if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received
|
||||||
>= pMsg->pBatchMasterMsg->expected) {
|
>= pMsg->pBatchMasterMsg->expected) {
|
||||||
dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, rpcMsg->code);
|
dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, rpcMsg->code);
|
||||||
|
@ -3020,10 +3026,12 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
|
||||||
return TSDB_CODE_MND_DB_IN_DROPPING;
|
return TSDB_CODE_MND_DB_IN_DROPPING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (mnodeCheckIsMonitorDB(pMsg->pDb->name, tsMonitorDbName)) {
|
if (mnodeCheckIsMonitorDB(pMsg->pDb->name, tsMonitorDbName)) {
|
||||||
mError("msg:%p, app:%p table:%s, failed to alter table, its log db", pMsg, pMsg->rpcMsg.ahandle, pAlter->tableFname);
|
mError("msg:%p, app:%p table:%s, failed to alter table, its log db", pMsg, pMsg->rpcMsg.ahandle, pAlter->tableFname);
|
||||||
return TSDB_CODE_MND_MONITOR_DB_FORBIDDEN;
|
return TSDB_CODE_MND_MONITOR_DB_FORBIDDEN;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pAlter->tableFname);
|
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pAlter->tableFname);
|
||||||
if (pMsg->pTable == NULL) {
|
if (pMsg->pTable == NULL) {
|
||||||
|
|
|
@ -367,6 +367,11 @@ static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) {
|
||||||
maxIdPoolSize = MAX(maxIdPoolSize, idPoolSize);
|
maxIdPoolSize = MAX(maxIdPoolSize, idPoolSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create one table each vnode
|
||||||
|
if (pDb->cfg.dbType == TSDB_DB_TYPE_TOPIC) {
|
||||||
|
maxIdPoolSize = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// new vgroup
|
// new vgroup
|
||||||
if (pInputVgroup->idPool == NULL) {
|
if (pInputVgroup->idPool == NULL) {
|
||||||
pInputVgroup->idPool = taosInitIdPool(maxIdPoolSize);
|
pInputVgroup->idPool = taosInitIdPool(maxIdPoolSize);
|
||||||
|
@ -379,6 +384,11 @@ static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create one table each vnode
|
||||||
|
if (pDb->cfg.dbType == TSDB_DB_TYPE_TOPIC) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
// realloc all vgroups in db
|
// realloc all vgroups in db
|
||||||
int32_t newIdPoolSize;
|
int32_t newIdPoolSize;
|
||||||
if (minIdPoolSize * 4 < tsTableIncStepPerVnode) {
|
if (minIdPoolSize * 4 < tsTableIncStepPerVnode) {
|
||||||
|
@ -449,6 +459,10 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi
|
||||||
maxVgroupsPerDb = MIN(maxVgroupsPerDb, TSDB_MAX_VNODES_PER_DB);
|
maxVgroupsPerDb = MIN(maxVgroupsPerDb, TSDB_MAX_VNODES_PER_DB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pDb->cfg.dbType == TSDB_DB_TYPE_TOPIC) {
|
||||||
|
maxVgroupsPerDb = TSDB_MAX_DB_PARTITON_OPTION;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_MND_NO_ENOUGH_DNODES;
|
int32_t code = TSDB_CODE_MND_NO_ENOUGH_DNODES;
|
||||||
if (pDb->numOfVgroups < maxVgroupsPerDb) {
|
if (pDb->numOfVgroups < maxVgroupsPerDb) {
|
||||||
mDebug("msg:%p, app:%p db:%s, try to create a new vgroup, numOfVgroups:%d maxVgroupsPerDb:%d", pMsg,
|
mDebug("msg:%p, app:%p db:%s, try to create a new vgroup, numOfVgroups:%d maxVgroupsPerDb:%d", pMsg,
|
||||||
|
@ -537,6 +551,7 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
|
|
||||||
if (pMsg->pBatchMasterMsg) {
|
if (pMsg->pBatchMasterMsg) {
|
||||||
++pMsg->pBatchMasterMsg->received;
|
++pMsg->pBatchMasterMsg->received;
|
||||||
|
pMsg->pBatchMasterMsg->code = pMsg->code;
|
||||||
if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received
|
if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received
|
||||||
>= pMsg->pBatchMasterMsg->expected) {
|
>= pMsg->pBatchMasterMsg->expected) {
|
||||||
dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, pMsg->code);
|
dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, pMsg->code);
|
||||||
|
@ -880,6 +895,7 @@ static SCreateVnodeMsg *mnodeBuildVnodeMsg(SVgObj *pVgroup) {
|
||||||
pCfg->update = pDb->cfg.update;
|
pCfg->update = pDb->cfg.update;
|
||||||
pCfg->cacheLastRow = pDb->cfg.cacheLastRow;
|
pCfg->cacheLastRow = pDb->cfg.cacheLastRow;
|
||||||
pCfg->dbReplica = pDb->cfg.replications;
|
pCfg->dbReplica = pDb->cfg.replications;
|
||||||
|
pCfg->dbType = pDb->cfg.dbType;
|
||||||
|
|
||||||
SVnodeDesc *pNodes = pVnode->nodes;
|
SVnodeDesc *pNodes = pVnode->nodes;
|
||||||
for (int32_t j = 0; j < pVgroup->numOfVnodes; ++j) {
|
for (int32_t j = 0; j < pVgroup->numOfVnodes; ++j) {
|
||||||
|
@ -1002,6 +1018,7 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
|
||||||
|
|
||||||
if (mnodeMsg->pBatchMasterMsg) {
|
if (mnodeMsg->pBatchMasterMsg) {
|
||||||
++mnodeMsg->pBatchMasterMsg->received;
|
++mnodeMsg->pBatchMasterMsg->received;
|
||||||
|
mnodeMsg->pBatchMasterMsg->code = code;
|
||||||
if (mnodeMsg->pBatchMasterMsg->successed + mnodeMsg->pBatchMasterMsg->received
|
if (mnodeMsg->pBatchMasterMsg->successed + mnodeMsg->pBatchMasterMsg->received
|
||||||
>= mnodeMsg->pBatchMasterMsg->expected) {
|
>= mnodeMsg->pBatchMasterMsg->expected) {
|
||||||
dnodeSendRpcMWriteRsp(mnodeMsg->pBatchMasterMsg, code);
|
dnodeSendRpcMWriteRsp(mnodeMsg->pBatchMasterMsg, code);
|
||||||
|
@ -1024,6 +1041,7 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
|
||||||
|
|
||||||
if (mnodeMsg->pBatchMasterMsg) {
|
if (mnodeMsg->pBatchMasterMsg) {
|
||||||
++mnodeMsg->pBatchMasterMsg->received;
|
++mnodeMsg->pBatchMasterMsg->received;
|
||||||
|
mnodeMsg->pBatchMasterMsg->code = mnodeMsg->code;
|
||||||
if (mnodeMsg->pBatchMasterMsg->successed + mnodeMsg->pBatchMasterMsg->received
|
if (mnodeMsg->pBatchMasterMsg->successed + mnodeMsg->pBatchMasterMsg->received
|
||||||
>= mnodeMsg->pBatchMasterMsg->expected) {
|
>= mnodeMsg->pBatchMasterMsg->expected) {
|
||||||
dnodeSendRpcMWriteRsp(mnodeMsg->pBatchMasterMsg, mnodeMsg->code);
|
dnodeSendRpcMWriteRsp(mnodeMsg->pBatchMasterMsg, mnodeMsg->code);
|
||||||
|
|
|
@ -83,6 +83,20 @@ extern "C" {
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define DEFAULT_DOUBLE_COMP(x, y) \
|
||||||
|
do { \
|
||||||
|
if (isnan(x) && isnan(y)) { return 0; } \
|
||||||
|
if (isnan(x)) { return -1; } \
|
||||||
|
if (isnan(y)) { return 1; } \
|
||||||
|
if ((x) == (y)) { \
|
||||||
|
return 0; \
|
||||||
|
} else { \
|
||||||
|
return (x) < (y) ? -1 : 1; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define DEFAULT_FLOAT_COMP(x, y) DEFAULT_DOUBLE_COMP(x, y)
|
||||||
|
|
||||||
#define ALIGN_NUM(n, align) (((n) + ((align)-1)) & (~((align)-1)))
|
#define ALIGN_NUM(n, align) (((n) + ((align)-1)) & (~((align)-1)))
|
||||||
|
|
||||||
// align to 8bytes
|
// align to 8bytes
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
#define REST_JSON_DATA_LEN 4
|
#define REST_JSON_DATA_LEN 4
|
||||||
#define REST_JSON_HEAD "head"
|
#define REST_JSON_HEAD "head"
|
||||||
#define REST_JSON_HEAD_LEN 4
|
#define REST_JSON_HEAD_LEN 4
|
||||||
|
#define REST_JSON_HEAD_INFO "column_meta"
|
||||||
|
#define REST_JSON_HEAD_INFO_LEN 11
|
||||||
#define REST_JSON_ROWS "rows"
|
#define REST_JSON_ROWS "rows"
|
||||||
#define REST_JSON_ROWS_LEN 4
|
#define REST_JSON_ROWS_LEN 4
|
||||||
#define REST_JSON_AFFECT_ROWS "affected_rows"
|
#define REST_JSON_AFFECT_ROWS "affected_rows"
|
||||||
|
|
|
@ -59,7 +59,9 @@ void httpDispatchToResultQueue(void *param, TAOS_RES *result, int32_t code, int3
|
||||||
pMsg->fp = fp;
|
pMsg->fp = fp;
|
||||||
taosWriteQitem(tsHttpQueue, TAOS_QTYPE_RPC, pMsg);
|
taosWriteQitem(tsHttpQueue, TAOS_QTYPE_RPC, pMsg);
|
||||||
} else {
|
} else {
|
||||||
(*fp)(param, result, code, rows);
|
taos_stop_query(result);
|
||||||
|
taos_free_result(result);
|
||||||
|
//(*fp)(param, result, code, rows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,44 @@ void restStartSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result)
|
||||||
// head array end
|
// head array end
|
||||||
httpJsonToken(jsonBuf, JsonArrEnd);
|
httpJsonToken(jsonBuf, JsonArrEnd);
|
||||||
|
|
||||||
|
// column_meta begin
|
||||||
|
httpJsonItemToken(jsonBuf);
|
||||||
|
httpJsonPairHead(jsonBuf, REST_JSON_HEAD_INFO, REST_JSON_HEAD_INFO_LEN);
|
||||||
|
// column_meta array begin
|
||||||
|
httpJsonItemToken(jsonBuf);
|
||||||
|
httpJsonToken(jsonBuf, JsonArrStt);
|
||||||
|
|
||||||
|
if (num_fields == 0) {
|
||||||
|
httpJsonItemToken(jsonBuf);
|
||||||
|
httpJsonToken(jsonBuf, JsonArrStt);
|
||||||
|
|
||||||
|
httpJsonItemToken(jsonBuf);
|
||||||
|
httpJsonString(jsonBuf, REST_JSON_AFFECT_ROWS, REST_JSON_AFFECT_ROWS_LEN);
|
||||||
|
httpJsonItemToken(jsonBuf);
|
||||||
|
httpJsonInt(jsonBuf, TSDB_DATA_TYPE_INT);
|
||||||
|
httpJsonItemToken(jsonBuf);
|
||||||
|
httpJsonInt(jsonBuf, 4);
|
||||||
|
|
||||||
|
httpJsonToken(jsonBuf, JsonArrEnd);
|
||||||
|
} else {
|
||||||
|
for (int32_t i = 0; i < num_fields; ++i) {
|
||||||
|
httpJsonItemToken(jsonBuf);
|
||||||
|
httpJsonToken(jsonBuf, JsonArrStt);
|
||||||
|
|
||||||
|
httpJsonItemToken(jsonBuf);
|
||||||
|
httpJsonString(jsonBuf, fields[i].name, (int32_t)strlen(fields[i].name));
|
||||||
|
httpJsonItemToken(jsonBuf);
|
||||||
|
httpJsonInt(jsonBuf, fields[i].type);
|
||||||
|
httpJsonItemToken(jsonBuf);
|
||||||
|
httpJsonInt(jsonBuf, fields[i].bytes);
|
||||||
|
|
||||||
|
httpJsonToken(jsonBuf, JsonArrEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// column_meta array end
|
||||||
|
httpJsonToken(jsonBuf, JsonArrEnd);
|
||||||
|
|
||||||
// data begin
|
// data begin
|
||||||
httpJsonItemToken(jsonBuf);
|
httpJsonItemToken(jsonBuf);
|
||||||
httpJsonPairHead(jsonBuf, REST_JSON_DATA, REST_JSON_DATA_LEN);
|
httpJsonPairHead(jsonBuf, REST_JSON_DATA, REST_JSON_DATA_LEN);
|
||||||
|
|
|
@ -125,6 +125,8 @@ typedef struct SCreateDbInfo {
|
||||||
int8_t update;
|
int8_t update;
|
||||||
int8_t cachelast;
|
int8_t cachelast;
|
||||||
SArray *keep;
|
SArray *keep;
|
||||||
|
int8_t dbType;
|
||||||
|
int16_t partitions;
|
||||||
} SCreateDbInfo;
|
} SCreateDbInfo;
|
||||||
|
|
||||||
typedef struct SCreateAcctInfo {
|
typedef struct SCreateAcctInfo {
|
||||||
|
@ -155,6 +157,7 @@ typedef struct SUserInfo {
|
||||||
typedef struct SMiscInfo {
|
typedef struct SMiscInfo {
|
||||||
SArray *a; // SArray<SStrToken>
|
SArray *a; // SArray<SStrToken>
|
||||||
bool existsCheck;
|
bool existsCheck;
|
||||||
|
int16_t dbType;
|
||||||
int16_t tableType;
|
int16_t tableType;
|
||||||
SUserInfo user;
|
SUserInfo user;
|
||||||
union {
|
union {
|
||||||
|
@ -265,7 +268,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,int16_t tableType);
|
void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck,int16_t dbType,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);
|
||||||
|
|
||||||
void setCreateDbInfo(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDbInfo *pDB, SStrToken *pIgExists);
|
void setCreateDbInfo(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDbInfo *pDB, SStrToken *pIgExists);
|
||||||
|
@ -276,6 +279,7 @@ void setKillSql(SSqlInfo *pInfo, int32_t type, SStrToken *ip);
|
||||||
void setAlterUserSql(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* pPwd, SStrToken *pPrivilege);
|
void setAlterUserSql(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* pPwd, SStrToken *pPrivilege);
|
||||||
|
|
||||||
void setDefaultCreateDbOption(SCreateDbInfo *pDBInfo);
|
void setDefaultCreateDbOption(SCreateDbInfo *pDBInfo);
|
||||||
|
void setDefaultCreateTopicOption(SCreateDbInfo *pDBInfo);
|
||||||
|
|
||||||
// prefix show db.tables;
|
// prefix show db.tables;
|
||||||
void setDbName(SStrToken *pCpxName, SStrToken *pDb);
|
void setDbName(SStrToken *pCpxName, SStrToken *pDb);
|
||||||
|
|
|
@ -64,6 +64,7 @@ program ::= cmd. {}
|
||||||
|
|
||||||
//////////////////////////////////THE SHOW STATEMENT///////////////////////////////////////////
|
//////////////////////////////////THE SHOW STATEMENT///////////////////////////////////////////
|
||||||
cmd ::= SHOW DATABASES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_DB, 0, 0);}
|
cmd ::= SHOW DATABASES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_DB, 0, 0);}
|
||||||
|
cmd ::= SHOW TOPICS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_TP, 0, 0);}
|
||||||
cmd ::= SHOW MNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_MNODE, 0, 0);}
|
cmd ::= SHOW MNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_MNODE, 0, 0);}
|
||||||
cmd ::= SHOW DNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_DNODE, 0, 0);}
|
cmd ::= SHOW DNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_DNODE, 0, 0);}
|
||||||
cmd ::= SHOW ACCOUNTS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_ACCT, 0, 0);}
|
cmd ::= SHOW ACCOUNTS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_ACCT, 0, 0);}
|
||||||
|
@ -131,16 +132,18 @@ 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, -1);
|
setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &X, &Y, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//drop stable
|
//drop stable
|
||||||
cmd ::= DROP STABLE ifexists(Y) ids(X) cpxName(Z). {
|
cmd ::= DROP STABLE ifexists(Y) ids(X) cpxName(Z). {
|
||||||
X.n += Z.n;
|
X.n += Z.n;
|
||||||
setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &X, &Y, TSDB_SUPER_TABLE);
|
setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &X, &Y, -1, TSDB_SUPER_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd ::= DROP DATABASE ifexists(Y) ids(X). { setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &X, &Y, -1); }
|
cmd ::= DROP DATABASE ifexists(Y) ids(X). { setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &X, &Y, TSDB_DB_TYPE_DEFAULT, -1); }
|
||||||
|
cmd ::= DROP TOPIC ifexists(Y) ids(X). { setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &X, &Y, TSDB_DB_TYPE_TOPIC, -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); }
|
||||||
|
@ -162,6 +165,7 @@ cmd ::= ALTER DNODE ids(X) ids(Y) ids(Z). { setDCLSQLElems(pInfo, TSDB_SQL
|
||||||
cmd ::= ALTER LOCAL ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &X); }
|
cmd ::= ALTER LOCAL ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &X); }
|
||||||
cmd ::= ALTER LOCAL ids(X) ids(Y). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &X, &Y); }
|
cmd ::= ALTER LOCAL ids(X) ids(Y). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &X, &Y); }
|
||||||
cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &X, &Y, &t);}
|
cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &X, &Y, &t);}
|
||||||
|
cmd ::= ALTER TOPIC ids(X) alter_topic_optr(Y). { SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &X, &Y, &t);}
|
||||||
|
|
||||||
cmd ::= ALTER ACCOUNT ids(X) acct_optr(Z). { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &X, NULL, &Z);}
|
cmd ::= ALTER ACCOUNT ids(X) acct_optr(Z). { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &X, NULL, &Z);}
|
||||||
cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &X, &Y, &Z);}
|
cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &X, &Y, &Z);}
|
||||||
|
@ -187,6 +191,7 @@ cmd ::= CREATE DNODE ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_CREATE_DNODE
|
||||||
cmd ::= CREATE ACCOUNT ids(X) PASS ids(Y) acct_optr(Z).
|
cmd ::= CREATE ACCOUNT ids(X) PASS ids(Y) acct_optr(Z).
|
||||||
{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &X, &Y, &Z);}
|
{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &X, &Y, &Z);}
|
||||||
cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &X, &Y, &Z);}
|
cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &X, &Y, &Z);}
|
||||||
|
cmd ::= CREATE TOPIC ifnotexists(Z) ids(X) topic_optr(Y). { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &X, &Y, &Z);}
|
||||||
cmd ::= CREATE USER ids(X) PASS ids(Y). { setCreateUserSql(pInfo, &X, &Y);}
|
cmd ::= CREATE USER ids(X) PASS ids(Y). { setCreateUserSql(pInfo, &X, &Y);}
|
||||||
|
|
||||||
pps(Y) ::= . { Y.n = 0; }
|
pps(Y) ::= . { Y.n = 0; }
|
||||||
|
@ -247,9 +252,10 @@ comp(Y) ::= COMP INTEGER(X). { Y = X; }
|
||||||
prec(Y) ::= PRECISION STRING(X). { Y = X; }
|
prec(Y) ::= PRECISION STRING(X). { Y = X; }
|
||||||
update(Y) ::= UPDATE INTEGER(X). { Y = X; }
|
update(Y) ::= UPDATE INTEGER(X). { Y = X; }
|
||||||
cachelast(Y) ::= CACHELAST INTEGER(X). { Y = X; }
|
cachelast(Y) ::= CACHELAST INTEGER(X). { Y = X; }
|
||||||
|
partitions(Y) ::= PARTITIONS INTEGER(X). { Y = X; }
|
||||||
|
|
||||||
%type db_optr {SCreateDbInfo}
|
%type db_optr {SCreateDbInfo}
|
||||||
db_optr(Y) ::= . {setDefaultCreateDbOption(&Y);}
|
db_optr(Y) ::= . {setDefaultCreateDbOption(&Y); Y.dbType = TSDB_DB_TYPE_DEFAULT;}
|
||||||
|
|
||||||
db_optr(Y) ::= db_optr(Z) cache(X). { Y = Z; Y.cacheBlockSize = strtol(X.z, NULL, 10); }
|
db_optr(Y) ::= db_optr(Z) cache(X). { Y = Z; Y.cacheBlockSize = strtol(X.z, NULL, 10); }
|
||||||
db_optr(Y) ::= db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); }
|
db_optr(Y) ::= db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); }
|
||||||
|
@ -267,8 +273,13 @@ db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; }
|
||||||
db_optr(Y) ::= db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); }
|
db_optr(Y) ::= db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); }
|
||||||
db_optr(Y) ::= db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); }
|
db_optr(Y) ::= db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); }
|
||||||
|
|
||||||
|
%type topic_optr {SCreateDbInfo}
|
||||||
|
|
||||||
|
topic_optr(Y) ::= db_optr(Z). { Y = Z; Y.dbType = TSDB_DB_TYPE_TOPIC; }
|
||||||
|
topic_optr(Y) ::= topic_optr(Z) partitions(X). { Y = Z; Y.partitions = strtol(X.z, NULL, 10); }
|
||||||
|
|
||||||
%type alter_db_optr {SCreateDbInfo}
|
%type alter_db_optr {SCreateDbInfo}
|
||||||
alter_db_optr(Y) ::= . { setDefaultCreateDbOption(&Y);}
|
alter_db_optr(Y) ::= . { setDefaultCreateDbOption(&Y); Y.dbType = TSDB_DB_TYPE_DEFAULT;}
|
||||||
|
|
||||||
alter_db_optr(Y) ::= alter_db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); }
|
alter_db_optr(Y) ::= alter_db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); }
|
||||||
alter_db_optr(Y) ::= alter_db_optr(Z) quorum(X). { Y = Z; Y.quorum = strtol(X.z, NULL, 10); }
|
alter_db_optr(Y) ::= alter_db_optr(Z) quorum(X). { Y = Z; Y.quorum = strtol(X.z, NULL, 10); }
|
||||||
|
@ -280,6 +291,11 @@ alter_db_optr(Y) ::= alter_db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = s
|
||||||
alter_db_optr(Y) ::= alter_db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); }
|
alter_db_optr(Y) ::= alter_db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); }
|
||||||
alter_db_optr(Y) ::= alter_db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); }
|
alter_db_optr(Y) ::= alter_db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); }
|
||||||
|
|
||||||
|
%type alter_topic_optr {SCreateDbInfo}
|
||||||
|
|
||||||
|
alter_topic_optr(Y) ::= alter_db_optr(Z). { Y = Z; Y.dbType = TSDB_DB_TYPE_TOPIC; }
|
||||||
|
alter_topic_optr(Y) ::= alter_topic_optr(Z) partitions(X). { Y = Z; Y.partitions = strtol(X.z, NULL, 10); }
|
||||||
|
|
||||||
%type typename {TAOS_FIELD}
|
%type typename {TAOS_FIELD}
|
||||||
typename(A) ::= ids(X). {
|
typename(A) ::= ids(X). {
|
||||||
X.type = 0;
|
X.type = 0;
|
||||||
|
@ -821,3 +837,4 @@ cmd ::= KILL QUERY INTEGER(X) COLON(Z) INTEGER(Y). {X.n += (Z.n + Y.n); s
|
||||||
COUNT SUM AVG MIN MAX FIRST LAST TOP BOTTOM STDDEV PERCENTILE APERCENTILE LEASTSQUARES HISTOGRAM DIFF
|
COUNT SUM AVG MIN MAX FIRST LAST TOP BOTTOM STDDEV PERCENTILE APERCENTILE LEASTSQUARES HISTOGRAM DIFF
|
||||||
SPREAD TWA INTERP LAST_ROW RATE IRATE SUM_RATE SUM_IRATE AVG_RATE AVG_IRATE TBID NOW IPTOKEN SEMI NONE PREV LINEAR IMPORT
|
SPREAD TWA INTERP LAST_ROW RATE IRATE SUM_RATE SUM_IRATE AVG_RATE AVG_IRATE TBID NOW IPTOKEN SEMI NONE PREV LINEAR IMPORT
|
||||||
METRIC TBNAME JOIN METRICS STABLE NULL INSERT INTO VALUES.
|
METRIC TBNAME JOIN METRICS STABLE NULL INSERT INTO VALUES.
|
||||||
|
|