提交 8be1bd52 编写于 作者: C cpwu

Merge branch 'tdigest' of github.com:taosdata/TDengine into tdigest

......@@ -240,6 +240,16 @@ pipeline {
node nanosecondTest.js
'''
sh '''
cd ${WKC}/src/connector/node-rest/
npm install
npm run build
npm run build:test
npm run test
'''
sh '''
cd ${WKC}/tests/examples/C#/taosdemo
mcs -out:taosdemo *.cs > /dev/null 2>&1
......
......@@ -7,6 +7,7 @@
[![TDengine](TDenginelogo.png)](https://www.taosdata.com)
简体中文 | [English](./README.md)
很多职位正在热招中,请看[这里](https://www.taosdata.com/cn/careers/)
# TDengine 简介
......
......@@ -7,6 +7,7 @@
[![TDengine](TDenginelogo.png)](https://www.taosdata.com)
English | [简体中文](./README-CN.md)
We are hiring, check [here](https://www.taosdata.com/en/careers/)
# What is TDengine?
......
......@@ -4,7 +4,7 @@ TDengine支持多种接口写入数据,包括SQL, Prometheus, Telegraf, EMQ MQ
## <a class="anchor" id="sql"></a>SQL 写入
应用通过C/C++、JDBC、GO、C#或Python Connector 执行SQL insert语句来插入数据,用户还可以通过TAOS Shell,手动输入SQL insert语句插入数据。比如下面这条insert 就将一条记录写入到表d1001中:
应用通过C/C++, Java, Go, C#, Python, Node.js 连接器执行SQL insert语句来插入数据,用户还可以通过TAOS Shell,手动输入SQL insert语句插入数据。比如下面这条insert 就将一条记录写入到表d1001中:
```mysql
INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31);
```
......
......@@ -365,9 +365,9 @@ taos -C 或 taos --dump-config
- timezone
默认值:从系统中动态获取当前的时区设置
客户端运行系统所在的时区。为应对多时区的数据写入和查询问题,TDengine 采用 Unix 时间戳(Unix Timestamp)来记录和存储时间戳。Unix 时间戳的特点决定了任一时刻不论在任何时区,产生的时间戳均一致。需要注意的是,Unix时间戳是在客户端完成转换和记录。为了确保客户端其他形式的时间转换为正确的 Unix 时间戳,需要设置正确的时区。
默认值:从系统中动态获取当前客户端运行系统所在的时区。
为应对多时区的数据写入和查询问题,TDengine 采用 Unix 时间戳(Unix Timestamp)来记录和存储时间戳。Unix 时间戳的特点决定了任一时刻不论在任何时区,产生的时间戳均一致。需要注意的是,Unix时间戳是在客户端完成转换和记录。为了确保客户端其他形式的时间转换为正确的 Unix 时间戳,需要设置正确的时区。
在Linux系统中,客户端会自动读取系统设置的时区信息。用户也可以采用多种方式在配置文件设置时区。例如:
```
......@@ -835,7 +835,7 @@ taos -n sync -P 6042 -h <fqdn of server>
-h:所要连接的服务端的 FQDN 或 ip 地址。如果不设置这一项,会使用本机 taos.cfg 文件中 FQDN 参数的设置作为默认值。
-P:所连接服务端的网络端口。默认值为 6030。
-N:诊断过程中使用的网络包总数。最小值是 1、最大值是 10000,默认值为 100。
-l:单个网络包的大小(单位:字节)。最小值是 1024、最大值是 1024*1024*1024,默认值为 1000。
-l:单个网络包的大小(单位:字节)。最小值是 1024、最大值是 1024 * 1024 * 1024,默认值为 1000。
-S:网络封包的类型。可以是 TCP 或 UDP,默认值为 TCP。
#### FQDN 解析速度诊断
......
......@@ -4,7 +4,7 @@ TDengine supports multiple ways to write data, including SQL, Prometheus, Telegr
## <a class="anchor" id="sql"></a> Data Writing via SQL
Applications insert data by executing SQL insert statements through C/C++, JDBC, GO, C#, or Python Connector, and users can manually enter SQL insert statements to insert data through TAOS Shell. For example, the following insert writes a record to table d1001:
Applications insert data by executing SQL insert statements through C/C++, Java, Go, C#, Python, Node.js Connectors, and users can manually enter SQL insert statements to insert data through TAOS Shell. For example, the following insert writes a record to table d1001:
```mysql
INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31);
......
......@@ -407,7 +407,7 @@ See [video tutorials](https://www.taosdata.com/blog/2020/11/11/1963.html) for th
- python 2.7 or >= 3.4 installed
- pip or pip3 installed
### Python client installation
### Python connector installation
#### Linux
......@@ -540,7 +540,7 @@ Refer to help (taos.TDengineCursor) in python. This class corresponds to the wri
Used to generate an instance of taos.TDengineConnection.
### Python client code sample
### Python connector code sample
In tests/examples/python, we provide a sample Python program read_example. py to guide you to design your own write and query program. After installing the corresponding client, introduce the taos class through `import taos`. The steps are as follows:
......@@ -610,11 +610,11 @@ The return value is in JSON format, as follows:
```json
{
"status": "succ",
"head": ["ts","current", ],
"column_meta": [["ts",9,8],["current",6,4], ],
"head": ["ts","current",...],
"column_meta": [["ts",9,8],["current",6,4], ...],
"data": [
["2018-10-03 14:38:05.000", 10.3, ],
["2018-10-03 14:38:15.000", 12.6, ]
["2018-10-03 14:38:05.000", 10.3, ...],
["2018-10-03 14:38:15.000", 12.6, ...]
],
"rows": 2
}
......
......@@ -75,7 +75,7 @@ Note:
2. UPDATE marks the database support updating the same timestamp data;
3. Maximum length of the database name is 33;
4. Maximum length of a SQL statement is 65480 characters;
5. Database has more storage-related configuration parameters, see System Management.
5. Database has more storage-related configuration parameters, see [Server-side Configuration](https://www.taosdata.com/en/documentation/administrator#config) .
- **Show current system parameters**
......@@ -88,7 +88,7 @@ Note:
```mysql
USE db_name;
```
Use/switch database
Use/switch database (Invalid when accessing through RESTful connection)
- **Drop a database**
```mysql
......
......@@ -245,8 +245,8 @@ function install_lib() {
else
${csudo} cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
${csudo} ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib
${csudo} ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib
${csudo} ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib || :
${csudo} ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib || :
fi
install_jemalloc
......
......@@ -72,9 +72,19 @@ if [ "$verMode" == "cluster" ]; then
sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/bin/remove_pro.sh >> remove_prodb_temp.sh
mv remove_prodb_temp.sh ${install_dir}/bin/remove_pro.sh
mkdir -p ${install_dir}/nginxd && cp -r ${nginx_dir}/* ${install_dir}/nginxd
cp ${nginx_dir}/png/taos.png ${install_dir}/nginxd/admin/images/taos.png
rm -rf ${install_dir}/nginxd/png
# replace the OEM name, add by yangzy@2021-09-22
sed -i -e 's/www.taosdata.com/www.hanatech.com.cn/g' $(grep -r 'www.taosdata.com' ${install_dir}/nginxd | sed -r "s/(.*\.html):\s*(.*)/\1/g")
sed -i -e 's/TAOS Data/Hanatech/g' $(grep -r 'TAOS Data' ${install_dir}/nginxd | sed -r "s/(.*\.html):\s*(.*)/\1/g")
sed -i -e 's/taosd/prodbs/g' `grep -r 'taosd' ${install_dir}/nginxd | grep -E '*\.js\s*.*' | sed -r -e 's/(.*\.js):\s*(.*)/\1/g' | sort | uniq`
sed -i -e 's/<th style="font-weight: normal">taosd<\/th>/<th style="font-weight: normal">prodbs<\/th>/g' ${install_dir}/nginxd/admin/monitor.html
sed -i -e "s/data:\['taosd', 'system'\],/data:\['prodbs', 'system'\],/g" ${install_dir}/nginxd/admin/monitor.html
sed -i -e "s/name: 'taosd',/name: 'prodbs',/g" ${install_dir}/nginxd/admin/monitor.html
sed -i "s/TDengine/ProDB/g" ${install_dir}/nginxd/admin/*.html
sed -i "s/TDengine/ProDB/g" ${install_dir}/nginxd/admin/js/*.js
......
......@@ -2410,7 +2410,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
const char* msg10 = "derivative duration should be greater than 1 Second";
const char* msg11 = "third parameter in derivative should be 0 or 1";
const char* msg12 = "parameter is out of range [1, 100]";
const char* msg13 = "third parameter should be 0 or 1";
const char* msg13 = "third parameter algorithm must be 'default' or 't-digest'";
switch (functionId) {
case TSDB_FUNC_COUNT: {
......@@ -2807,6 +2807,9 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
SExprInfo* pExpr = NULL;
if (functionId == TSDB_FUNC_PERCT || functionId == TSDB_FUNC_APERCT) {
// param1 double
if(pVariant->nType != TSDB_DATA_TYPE_DOUBLE && pVariant->nType != TSDB_DATA_TYPE_BIGINT){
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5);
}
tVariantDump(pVariant, val, TSDB_DATA_TYPE_DOUBLE, true);
double dp = GET_DOUBLE_VAL(val);
if (dp < 0 || dp > TOP_BOTTOM_QUERY_LIMIT) {
......@@ -2828,12 +2831,22 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
if (taosArrayGetSize(pItem->pNode->Expr.paramList) == 3) {
if (pParamElem[2].pNode != NULL) {
pVariant = &pParamElem[2].pNode->value;
tVariantDump(pVariant, val, TSDB_DATA_TYPE_INT, true);
int32_t algo = GET_INT32_VAL(val);
if(algo < 0 || algo >1 ) {
// check type must string
if(pVariant->nType != TSDB_DATA_TYPE_BINARY || pVariant->pz == NULL){
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg13);
}
char* pzAlgo = pVariant->pz;
int32_t algo = 0;
if(strcasecmp(pzAlgo, "t-digest") == 0) {
algo = 1;
} else if(strcasecmp(pzAlgo, "default") == 0){
algo = 0;
} else {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg13);
}
tscExprAddParams(&pExpr->base, val, TSDB_DATA_TYPE_INT, sizeof(int32_t));
// append algo int32_t
tscExprAddParams(&pExpr->base, (char*)&algo, TSDB_DATA_TYPE_INT, sizeof(int32_t));
}
}
......
Subproject commit 4a4d79099b076b8ff12d5b4fdbcba54049a6866d
Subproject commit 016d8e82a24d72779be0ab0090580a372b4fffca
# Created by https://www.toptal.com/developers/gitignore/api/node
# Edit at https://www.toptal.com/developers/gitignore?templates=node
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
.env.production
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# End of https://www.toptal.com/developers/gitignore/api/node
lib/
yarn.lock
import {TDengineRestConnection} from './src/restConnect'
export function TDRestConnection(connection = {}) {
return new TDengineRestConnection(connection)
}
import {TDengineRestConnection} from "../src/restConnect";
let conn = new TDengineRestConnection({host: '127.0.0.1', user: 'root', pass: 'taosdata', port: 6041})
let cursor = conn.cursor();
console.log(conn)
let data = {};
(async () => {
data = await cursor.query("show databases");
data.toString()
})()
此差异已折叠。
{
"name": "td-rest-connector",
"version": "1.0.0",
"description": "A Node.js connector for TDengine restful",
"module": "src/TDengineRest.js",
"main": "lib/TDengineclearRest.js",
"license": "MIT",
"scripts": {
"prepare": "npm run build",
"build": "esbuild --bundle --platform=node --outfile=lib/TDengineRest.js ./TDengineRest.js",
"build:dev": "esbuild --bundle --platform=node --outfile=dist/examples/show-database.js examples/show-database.js ",
"build:test": "esbuild test/testRestConn.js --bundle --platform=node --outfile=dist/tests/testRestConn.js ",
"test": "node dist/tests/testRestConn.js"
},
"devDependencies": {
"esbuild": "^0.12.25",
"eslint": "^7.32.0",
"assert": "^2.0.0"
},
"dependencies": {
"node-fetch": "^2.x"
}
}
# TDengine Nodejs Restful
This is the Node.js library that lets you connect to [TDengine](https://www.github.com/taosdata/tdengine) though
restful. This restful can help you access the TDengine from different platform.
## Install
To get started, just type in the following to install the connector through [npm](https://www.npmjs.com/)
```cmd
npm install td-rest-connector
```
## Usage
### Connection
```javascript
import taoRest from 'TDengineRest'
var connRest = taoRest({host:'127.0.0.1',user:'root',pass:'taosdata',port:6041})
```
query
```javascript
(async()=>{
data = await connRest.query("show databases");
data.toString();
}
)()
```
## Example
An example of using the NodeJS Restful connector to create a table with weather data and create and execute queries can be found [here](https://github.com/taosdata/TDengine/tree/master/tests/examples/node-rest/show-database.js)
## Contributing to TDengine
Please follow the [contribution guidelines](https://github.com/taosdata/TDengine/blob/master/CONTRIBUTING.md) to contribute to the project.
## License
[GNU AGPL v3.0](http://www.gnu.org/licenses/agpl-3.0.html)
import {TDengineRestCursor} from '../src/restCursor'
/**
*this class collect basic information that can be used to build
* a restful connection.
*/
export class TDengineRestConnection {
/**
* constructor,give variables some default values
* @param options
* @returns {TDengineRestConnection}
*/
constructor(options) {
this.host = 'localhost'
this.port = '6041'
this.user = 'root'
this.pass = 'taosdata'
this.path = '/rest/sqlt/'
this._initConnection(options)
return this
}
/**
* used to init the connection info using the input options
* @param options
* @private
*/
_initConnection(options) {
if (options['host']) {
this.host = options['host']
}
if (options['port']) {
this.port = options['port']
}
if (options['user']) {
this.user = options['user']
}
if (options['pass']) {
this.pass = options['pass']
}
if (options['path']) {
this.path = options['path']
}
}
/**
* cursor will return an object of TDengineRestCursor, which can send restful(http) request and get
* the response from server.
* @returns {TDengineRestCursor}
*/
cursor() {
return new TDengineRestCursor(this)
}
}
/**
* indicate the every type's type code
* @type {{"0": string, "1": string, "2": string, "3": string, "4": string, "5": string, "6": string, "7": string, "8": string, "9": string, "10": string}}
*/
export const typeCodesToName = {
0: 'Null',
1: 'Boolean',
2: 'Tiny Int',
3: 'Small Int',
4: 'Int',
5: 'Big Int',
6: 'Float',
7: 'Double',
8: 'Binary',
9: 'Timestamp',
10: 'Nchar',
}
/**
* get the type of input typecode, in fact the response of restful will send every column's typecode
* @param typecode
* @returns {*}
*/
export function getTaoType(typecode) {
return typeCodesToName[typecode];
}
\ No newline at end of file
import fetch from 'node-fetch'
import {TDengineRestResultSet} from '../src/restResult'
/**
* this class is core of restful js connector
* this class resends http request to the TDengine server
* and receive the response.
*/
export class TDengineRestCursor {
/**
* constructor,used to get the connection info
* @param connection
*/
constructor(connection) {
this._connection = null;
this.data = [];
this.http = false
if (connection != null) {
this._connection = connection
} else {
throw new Error("A TDengineRestConnection object is required to be passed to the TDengineRestCursor")
}
}
/**
* used to build an url,like http://localhost:6041/rest/sql
* @returns {string}
* @private
*/
_apiUpl() {
return (this.http ? "https" : "http") + "://" + this._connection.host + ":" + this._connection.port + this._connection.path
}
/**
* used to make an authorization token
* @returns {string}
* @private
*/
_token() {
return 'Basic ' + Buffer.from(this._connection.user + ":" + this._connection.pass).toString('base64')
}
/**
* Used fetch to send http request, and return the response as an object of TDengineRestResultSet
* @param sql
* @returns {Promise<TDengineRestResultSet>}
*/
async query(sql) {
try {
let response = await fetch(this._apiUpl(), {
method: 'POST',
body: sql,
headers: {'Authorization': this._token()}
})
// if (response.status == 'succ') {
return await new TDengineRestResultSet(await response.json())
// } else {
// throw new Error(response.desc)
// }
} catch (e) {
console.log("Request Failed " + e)
}
}
}
import {getTaoType} from '../src/restConstant'
export class TDengineRestResultSet {
constructor(result) {
this.status = '' //succ
this.column_name = {} //head
this.column_type = {} //column_meta
this.data = {}
this.affectRows = null //rows
this.code = null
this.desc = null
this._init(result)
}
//initial the resultSet with a jason parameter
/**
*
* @param jason
*/
_init(result) {
if (result.status) {
this.status = result.status
}
if (result.head) {
this.column_name = result.head
}
if (result.column_meta) {
this.column_type = result.column_meta
}
if (result.data) {
this.data = result.data
}
if (result.rows) {
this.affectRows = result.rows
}
if (result.code) {
this.code = result.code
}
if (result.desc) {
this.desc = result.desc
}
}
getStatus() {
return this.status
}
getColumn_name() {
return this.column_name
}
getColumn_type() {
let column_data = []
this.column_type.forEach(function (column) {
column[1] = getTaoType(column[1])
column_data.push(column)
})
return column_data
}
getData() {
return this.data
}
getAffectRow() {
return this.affectRows
}
getCode() {
return this.code
}
getDesc() {
return this.desc
}
toString() {
if(this.status === 'succ'){
let fields = this.column_type
let rows = this.data
this._prettyStr(fields, rows)
}else{
console.log(this.status+":"+this.desc)
}
}
_prettyStr(fields, data) {
let colName = []
let colType = []
let colSize = []
let colStr = ""
for (let i = 0; i < fields.length; i++) {
colName.push(fields[i][0])
colType.push(fields[i][1])
if ((fields[i][1]) == 8 || (fields[i][1]) == 10) {
colSize.push(Math.max(fields[i][0].length, fields[i][2])); //max(column_name.length,column_type_precision)
} else {
colSize.push(Math.max(fields[i][0].length, suggestedMinWidths[fields[i][1]]));// max(column_name.length,suggest_column_with_suggestion)
}
// console.log(colSize)
}
colName.forEach((name, i) => {
colStr += this._fillEmpty(Math.floor(colSize[i] / 2 - name.length / 2)) + name.toString() + this._fillEmpty(Math.ceil(colSize[i] / 2 - name.length / 2)) + " | "
})
let strSperator = ""
let sizeSum = colSize.reduce((a, b) => a += b, (0)) + colSize.length * 3
strSperator = this._printN("=", sizeSum)
console.log("\n" + colStr)
console.log(strSperator)
data.forEach((row) => {
let rowStr = ""
row.forEach((cell, index) => {
rowStr += cell == null ? 'null' : cell.toString();
rowStr += this._fillEmpty(colSize[index] - cell.toString().length) + " | "
})
console.log(rowStr)
})
return colStr
}
_fillEmpty(n) {
let str = "";
for (let i = 0; i < n; i++) {
str += " ";
}
return str;
}
_printN(s, n) {
let f = "";
for (let i = 0; i < n; i++) {
f += s;
}
return f;
}
}
const suggestedMinWidths = {
0: 4,
1: 4,
2: 4,
3: 6,
4: 11,
5: 12,
6: 24,
7: 24,
8: 10,
9: 25,
10: 10,
}
import {TDRestConnection} from "../TDengineRest";
import assert from "assert"
let conn = new TDRestConnection({host: '127.0.0.1', user: 'root', pass: 'taosdata', port: 6041});
let cursor = conn.cursor();
const createDB = "create database if not exists node_rest";
const dropDB = "drop database if exists node_rest";
const createTBL = "CREATE STABLE if not exists node_rest.meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int)";
const dropTBL = "drop table if exists node_rest.meters ";
const insert = "INSERT INTO node_rest.d1001 USING node_rest.meters TAGS (\"Beijng.Chaoyang\", 2) VALUES (now, 10.2, 219, 0.32) ";
const select = "select * from node_rest.d1001 ";
const selectStbl = "select * from node_rest.meters";
async function execute(sql) {
console.log("SQL:" + sql);
let result = await cursor.query(sql);
try {
assert.strictEqual(result.getStatus(), 'succ', new Error("response error"))
result.toString()
} catch (e) {
console.log(e)
}
}
(async () => {
await execute(createDB);
await execute(createTBL);
await execute(insert);
await execute(select);
await execute(selectStbl);
await execute(dropDB);
})()
// (async () => {
// result = await cursor.query("drop database if exists node_rest").catch(e=>console.log(e))
// result.toString()
// })()
......@@ -586,6 +586,7 @@ static int64_t getTSRandTail(int64_t timeStampStep, int32_t seq,
int disorderRatio, int disorderRange);
static bool getInfoFromJsonFile(char* file);
static void init_rand_data();
static int regexMatch(const char *s, const char *reg, int cflags);
/* ************ Global variables ************ */
......@@ -803,7 +804,7 @@ static void printHelp() {
printf("%s%s%s%s\n", indent, "-q, --query-mode=MODE", "\t\t",
"Query mode -- 0: SYNC, 1: ASYNC. By default use SYNC.");
printf("%s%s%s%s\n", indent, "-b, --data-type=DATATYPE", "\t",
"The data_type of columns, By default use: FLOAT, INT, FLOAT.");
"The data_type of columns, By default use: FLOAT,INT,FLOAT. NCHAR and BINARY can also use custom length. Eg: NCHAR(16),BINARY(8)");
printf("%s%s%s%s%d\n", indent, "-w, --binwidth=WIDTH", "\t\t",
"The width of data_type 'BINARY' or 'NCHAR'. By default use ",
g_args.binwidth);
......@@ -1579,9 +1580,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
&& strcasecmp(dataType, "SMALLINT")
&& strcasecmp(dataType, "BIGINT")
&& strcasecmp(dataType, "DOUBLE")
&& strcasecmp(dataType, "BINARY")
&& strcasecmp(dataType, "TIMESTAMP")
&& strcasecmp(dataType, "NCHAR")
&& !regexMatch(dataType, "^(NCHAR|BINARY)(\\([1-9][0-9]*\\))?$", REG_ICASE | REG_EXTENDED)
&& strcasecmp(dataType, "UTINYINT")
&& strcasecmp(dataType, "USMALLINT")
&& strcasecmp(dataType, "UINT")
......@@ -1603,9 +1603,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments->data_type[0] = TSDB_DATA_TYPE_FLOAT;
} else if (0 == strcasecmp(dataType, "DOUBLE")) {
arguments->data_type[0] = TSDB_DATA_TYPE_DOUBLE;
} else if (0 == strcasecmp(dataType, "BINARY")) {
} else if (1 == regexMatch(dataType, "^BINARY(\\([1-9][0-9]*\\))?$", REG_ICASE |
REG_EXTENDED)) {
arguments->data_type[0] = TSDB_DATA_TYPE_BINARY;
} else if (0 == strcasecmp(dataType, "NCHAR")) {
} else if (1 == regexMatch(dataType, "^NCHAR(\\([1-9][0-9]*\\))?$", REG_ICASE |
REG_EXTENDED)) {
arguments->data_type[0] = TSDB_DATA_TYPE_NCHAR;
} else if (0 == strcasecmp(dataType, "BOOL")) {
arguments->data_type[0] = TSDB_DATA_TYPE_BOOL;
......@@ -1638,9 +1640,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
&& strcasecmp(token, "SMALLINT")
&& strcasecmp(token, "BIGINT")
&& strcasecmp(token, "DOUBLE")
&& strcasecmp(token, "BINARY")
&& strcasecmp(token, "TIMESTAMP")
&& strcasecmp(token, "NCHAR")
&& !regexMatch(token, "^(NCHAR|BINARY)(\\([1-9][0-9]*\\))?$", REG_ICASE | REG_EXTENDED)
&& strcasecmp(token, "UTINYINT")
&& strcasecmp(token, "USMALLINT")
&& strcasecmp(token, "UINT")
......@@ -1663,9 +1664,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments->data_type[index] = TSDB_DATA_TYPE_DOUBLE;
} else if (0 == strcasecmp(token, "TINYINT")) {
arguments->data_type[index] = TSDB_DATA_TYPE_TINYINT;
} else if (0 == strcasecmp(token, "BINARY")) {
} else if (1 == regexMatch(token, "^BINARY(\\([1-9][0-9]*\\))?$", REG_ICASE |
REG_EXTENDED)) {
arguments->data_type[index] = TSDB_DATA_TYPE_BINARY;
} else if (0 == strcasecmp(token, "NCHAR")) {
} else if (1 == regexMatch(token, "^NCHAR(\\([1-9][0-9]*\\))?$", REG_ICASE |
REG_EXTENDED)) {
arguments->data_type[index] = TSDB_DATA_TYPE_NCHAR;
} else if (0 == strcasecmp(token, "BOOL")) {
arguments->data_type[index] = TSDB_DATA_TYPE_BOOL;
......@@ -2735,7 +2738,7 @@ static int printfInsertMeta() {
g_Dbs.db[i].superTbls[j].sampleFile);
printf(" tagsFile: \033[33m%s\033[0m\n",
g_Dbs.db[i].superTbls[j].tagsFile);
printf(" columnCount: \033[33m%d\033[0m\n",
printf(" columnCount: \033[33m%d\033[0m\n ",
g_Dbs.db[i].superTbls[j].columnCount);
for (int k = 0; k < g_Dbs.db[i].superTbls[j].columnCount; k++) {
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].columns[k].dataType, g_Dbs.db[i].superTbls[j].columns[k].dataLen);
......@@ -2743,7 +2746,7 @@ static int printfInsertMeta() {
"binary", 6))
|| (0 == strncasecmp(g_Dbs.db[i].superTbls[j].columns[k].dataType,
"nchar", 5))) {
printf("column[\033[33m%d\033[0m]:\033[33m%s(%d)\033[0m ", k,
printf("column[%d]:\033[33m%s(%d)\033[0m ", k,
g_Dbs.db[i].superTbls[j].columns[k].dataType,
g_Dbs.db[i].superTbls[j].columns[k].dataLen);
} else {
......@@ -4271,6 +4274,10 @@ static int createSuperTable(
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"T%d %s,", tagIndex, "BIGINT UNSIGNED");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + BIGINT_BUFF_LEN;
} else if (strcasecmp(dataType, "TIMESTAMP") == 0) {
len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len,
"T%d %s,", tagIndex, "TIMESTAMP");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + TIMESTAMP_BUFF_LEN;
} else {
taos_close(taos);
free(command);
......@@ -6717,7 +6724,7 @@ static int generateSampleFromRand(
case TSDB_DATA_TYPE_NCHAR:
dataLen = (columns)?columns[c].dataLen:g_args.binwidth;
rand_string(data, dataLen);
rand_string(data, dataLen - 1);
pos += sprintf(buff + pos, "%s,", data);
break;
......@@ -8153,7 +8160,7 @@ UNUSED_FUNC static int32_t prepareStbStmtRand(
}
#if STMT_BIND_PARAM_BATCH == 1
static int execBindParamBatch(
static int execStbBindParamBatch(
threadInfo *pThreadInfo,
char *tableName,
int64_t tableSeq,
......@@ -8167,7 +8174,9 @@ static int execBindParamBatch(
TAOS_STMT *stmt = pThreadInfo->stmt;
SSuperTable *stbInfo = pThreadInfo->stbInfo;
uint32_t columnCount = (stbInfo)?pThreadInfo->stbInfo->columnCount:g_args.columnCount;
assert(stbInfo);
uint32_t columnCount = pThreadInfo->stbInfo->columnCount;
uint32_t thisBatch = MAX_SAMPLES - (*pSamplePos);
......@@ -8192,108 +8201,101 @@ static int execBindParamBatch(
param->buffer = pThreadInfo->bind_ts_array;
} else {
data_type = (stbInfo)?stbInfo->columns[c-1].data_type:g_args.data_type[c-1];
data_type = stbInfo->columns[c-1].data_type;
char *tmpP;
switch(data_type) {
case TSDB_DATA_TYPE_BINARY:
param->buffer_length =
stbInfo->columns[c-1].dataLen;
tmpP =
(char *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray
+sizeof(char*)*(c-1)));
verbosePrint("%s() LN%d, tmpP=%p pos=%"PRId64" width=%"PRIxPTR" position=%"PRId64"\n",
__func__, __LINE__, tmpP, *pSamplePos, param->buffer_length,
(*pSamplePos) * param->buffer_length);
param->buffer = (void *)(tmpP + *pSamplePos * param->buffer_length);
break;
case TSDB_DATA_TYPE_NCHAR:
param->buffer_length =
((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth);
stbInfo->columns[c-1].dataLen;
tmpP =
(char *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray
+sizeof(char*)*(c-1)));
verbosePrint("%s() LN%d, tmpP=%p pos=%"PRId64" width=%d position=%"PRId64"\n",
__func__, __LINE__, tmpP, *pSamplePos,
(((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth)),
(*pSamplePos) *
(((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth)));
verbosePrint("%s() LN%d, tmpP=%p pos=%"PRId64" width=%"PRIxPTR" position=%"PRId64"\n",
__func__, __LINE__, tmpP, *pSamplePos, param->buffer_length,
(*pSamplePos) * param->buffer_length);
param->buffer = (void *)(tmpP + *pSamplePos *
(((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth))
);
param->buffer = (void *)(tmpP + *pSamplePos * param->buffer_length);
break;
case TSDB_DATA_TYPE_INT:
case TSDB_DATA_TYPE_UINT:
param->buffer_length = sizeof(int32_t);
param->buffer = (stbInfo)?
param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen * (*pSamplePos)):
(void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(int32_t)*(*pSamplePos));
+ stbInfo->columns[c-1].dataLen * (*pSamplePos));
break;
case TSDB_DATA_TYPE_TINYINT:
case TSDB_DATA_TYPE_UTINYINT:
param->buffer_length = sizeof(int8_t);
param->buffer = (stbInfo)?
param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(
stbInfo->sampleBindBatchArray
+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen*(*pSamplePos)):
(void *)((uintptr_t)*(uintptr_t*)(
g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(int8_t)*(*pSamplePos));
+ stbInfo->columns[c-1].dataLen*(*pSamplePos));
break;
case TSDB_DATA_TYPE_SMALLINT:
case TSDB_DATA_TYPE_USMALLINT:
param->buffer_length = sizeof(int16_t);
param->buffer = (stbInfo)?
param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen * (*pSamplePos)):
(void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(int16_t)*(*pSamplePos));
+ stbInfo->columns[c-1].dataLen * (*pSamplePos));
break;
case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_UBIGINT:
param->buffer_length = sizeof(int64_t);
param->buffer = (stbInfo)?
param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen * (*pSamplePos)):
(void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(int64_t)*(*pSamplePos));
+ stbInfo->columns[c-1].dataLen * (*pSamplePos));
break;
case TSDB_DATA_TYPE_BOOL:
param->buffer_length = sizeof(int8_t);
param->buffer = (stbInfo)?
param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen * (*pSamplePos)):
(void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(int8_t)*(*pSamplePos));
+ stbInfo->columns[c-1].dataLen * (*pSamplePos));
break;
case TSDB_DATA_TYPE_FLOAT:
param->buffer_length = sizeof(float);
param->buffer = (stbInfo)?
param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen * (*pSamplePos)):
(void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(float)*(*pSamplePos));
+ stbInfo->columns[c-1].dataLen * (*pSamplePos));
break;
case TSDB_DATA_TYPE_DOUBLE:
param->buffer_length = sizeof(double);
param->buffer = (stbInfo)?
param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen * (*pSamplePos)):
(void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(double)*(*pSamplePos));
+ stbInfo->columns[c-1].dataLen * (*pSamplePos));
break;
case TSDB_DATA_TYPE_TIMESTAMP:
param->buffer_length = sizeof(int64_t);
param->buffer = (stbInfo)?
param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen * (*pSamplePos)):
(void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(int64_t)*(*pSamplePos));
+ stbInfo->columns[c-1].dataLen * (*pSamplePos));
break;
default:
......@@ -8314,7 +8316,7 @@ static int execBindParamBatch(
if (param->buffer_type == TSDB_DATA_TYPE_NCHAR) {
param->length[b] = strlen(
(char *)param->buffer + b *
((stbInfo)?stbInfo->columns[c].dataLen:g_args.binwidth)
stbInfo->columns[c].dataLen
);
} else {
param->length[b] = param->buffer_length;
......@@ -8869,7 +8871,7 @@ static int32_t prepareStbStmt(
}
#if STMT_BIND_PARAM_BATCH == 1
return execBindParamBatch(
return execStbBindParamBatch(
pThreadInfo,
tableName,
tableSeq,
......@@ -10557,15 +10559,18 @@ static void startMultiThreadInsertData(int threads, char* db_name,
}
}
fprintf(stderr, "insert delay, avg: %10.2fms, max: %10.2fms, min: %10.2fms\n\n",
(double)avgDelay/1000.0,
(double)maxDelay/1000.0,
(double)minDelay/1000.0);
if (g_fpOfInsertResult) {
fprintf(g_fpOfInsertResult, "insert delay, avg:%10.2fms, max: %10.2fms, min: %10.2fms\n\n",
(double)avgDelay/1000.0,
(double)maxDelay/1000.0,
(double)minDelay/1000.0);
if (minDelay != UINT64_MAX) {
fprintf(stderr, "insert delay, avg: %10.2fms, max: %10.2fms, min: %10.2fms\n\n",
(double)avgDelay/1000.0,
(double)maxDelay/1000.0,
(double)minDelay/1000.0);
if (g_fpOfInsertResult) {
fprintf(g_fpOfInsertResult, "insert delay, avg:%10.2fms, max: %10.2fms, min: %10.2fms\n\n",
(double)avgDelay/1000.0,
(double)maxDelay/1000.0,
(double)minDelay/1000.0);
}
}
//taos_close(taos);
......@@ -11736,6 +11741,8 @@ static void initOfQueryMeta() {
}
static void setParaFromArg() {
char type[20];
char length[20];
if (g_args.host) {
tstrncpy(g_Dbs.host, g_args.host, MAX_HOSTNAME_SIZE);
} else {
......@@ -11817,7 +11824,17 @@ static void setParaFromArg() {
g_Dbs.db[0].superTbls[0].columns[i].data_type = data_type[i];
tstrncpy(g_Dbs.db[0].superTbls[0].columns[i].dataType,
dataType[i], min(DATATYPE_BUFF_LEN, strlen(dataType[i]) + 1));
g_Dbs.db[0].superTbls[0].columns[i].dataLen = g_args.binwidth;
if (1 == regexMatch(dataType[i], "^(NCHAR|BINARY)(\\([1-9][0-9]*\\))$", REG_ICASE |
REG_EXTENDED)) {
sscanf(dataType[i], "%[^(](%[^)]", type, length);
g_Dbs.db[0].superTbls[0].columns[i].dataLen = atoi(length);
tstrncpy(g_Dbs.db[0].superTbls[0].columns[i].dataType,
type, min(DATATYPE_BUFF_LEN, strlen(type) + 1));
} else {
g_Dbs.db[0].superTbls[0].columns[i].dataLen = g_args.binwidth;
tstrncpy(g_Dbs.db[0].superTbls[0].columns[i].dataType,
dataType[i], min(DATATYPE_BUFF_LEN, strlen(dataType[i]) + 1));
}
g_Dbs.db[0].superTbls[0].columnCount++;
}
......@@ -12065,4 +12082,3 @@ int main(int argc, char *argv[]) {
return 0;
}
......@@ -6,6 +6,61 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc)
INCLUDE_DIRECTORIES(inc)
AUX_SOURCE_DIRECTORY(. SRC)
FIND_PACKAGE(Git)
IF(GIT_FOUND)
EXECUTE_PROCESS(
COMMAND ${GIT_EXECUTABLE} log --pretty=oneline -n 1 ${CMAKE_CURRENT_LIST_DIR}/taosdump.c
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE TAOSDUMP_COMMIT_SHA1
)
IF ("${TAOSDUMP_COMMIT_SHA1}" STREQUAL "")
SET(TAOSDUMP_COMMIT_SHA1 "unknown")
ELSE ()
STRING(SUBSTRING "${TAOSDUMP_COMMIT_SHA1}" 0 7 TAOSDUMP_COMMIT_SHA1)
STRING(STRIP "${TAOSDUMP_COMMIT_SHA1}" TAOSDUMP_COMMIT_SHA1)
ENDIF ()
EXECUTE_PROCESS(
COMMAND ${GIT_EXECUTABLE} status -z -s ${CMAKE_CURRENT_LIST_DIR}/taosdump.c
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE TAOSDUMP_STATUS
)
IF (TD_LINUX)
EXECUTE_PROCESS(
COMMAND bash "-c" "echo '${TAOSDUMP_STATUS}' | awk '{print $1}'"
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE TAOSDUMP_STATUS
)
ENDIF (TD_LINUX)
ELSE()
MESSAGE("Git not found")
SET(TAOSDUMP_COMMIT_SHA1 "unknown")
SET(TAOSDUMP_STATUS "unknown")
ENDIF (GIT_FOUND)
MESSAGE("taosdump's latest commit in short is:" ${TAOSDUMP_COMMIT_SHA1})
STRING(STRIP "${TAOSDUMP_STATUS}" TAOSDUMP_STATUS)
IF (TAOSDUMP_STATUS MATCHES "M")
SET(TAOSDUMP_STATUS "modified")
ELSE()
SET(TAOSDUMP_STATUS "")
ENDIF ()
MESSAGE("taosdump's status is:" ${TAOSDUMP_STATUS})
ADD_DEFINITIONS(-DTAOSDUMP_COMMIT_SHA1="${TAOSDUMP_COMMIT_SHA1}")
ADD_DEFINITIONS(-DTAOSDUMP_STATUS="${TAOSDUMP_STATUS}")
MESSAGE("VERNUMBER is:" ${VERNUMBER})
IF ("${VERNUMBER}" STREQUAL "")
SET(TD_VERSION_NUMBER "TDengine-version-unknown")
ELSE()
SET(TD_VERSION_NUMBER ${VERNUMBER})
ENDIF ()
MESSAGE("TD_VERSION_NUMBER is:" ${TD_VERSION_NUMBER})
ADD_DEFINITIONS(-DTD_VERNUMBER="${TD_VERSION_NUMBER}")
IF (TD_LINUX)
ADD_EXECUTABLE(taosdump ${SRC})
IF (TD_SOMODE_STATIC)
......
此差异已折叠。
......@@ -2502,18 +2502,17 @@ static void tdigest_merge(SQLFunctionCtx *pCtx) {
SAPercentileInfo *pInput = (SAPercentileInfo *)GET_INPUT_DATA_LIST(pCtx);
assert(pInput->pTDigest);
pInput->pTDigest = (TDigest*)((char*)pInput + sizeof(SAPercentileInfo));
pInput->pTDigest->centroids = (SCentroid*)((char*)pInput + sizeof(SAPercentileInfo) + sizeof(TDigest));
tdigestAutoFill(pInput->pTDigest, COMPRESSION);
// input merge no elements , no need merge
if(pInput->pTDigest->num_centroids == 0) {
if(pInput->pTDigest->num_centroids == 0 && pInput->pTDigest->num_buffered_pts == 0) {
return ;
}
SAPercentileInfo *pOutput = getAPerctInfo(pCtx);
TDigest* pTDigest = pOutput->pTDigest;
if(pTDigest->num_centroids == 0) {
memcpy(pTDigest, pInput->pTDigest, (size_t)TDIGEST_SIZE(COMPRESSION));
tdigestAutoFill(pTDigest, COMPRESSION);
if(pOutput->pTDigest->num_centroids == 0) {
memcpy(pOutput->pTDigest, pInput->pTDigest, (size_t)TDIGEST_SIZE(COMPRESSION));
tdigestAutoFill(pOutput->pTDigest, COMPRESSION);
} else {
tdigestMerge(pOutput->pTDigest, pInput->pTDigest);
}
......
......@@ -77,7 +77,7 @@ static void mergeCentroid(SMergeArgs *args, SCentroid *merge) {
args->weight_so_far += merge->weight;
k2 = INTEGRATED_LOCATION(args->t->size,
args->weight_so_far / (args->t->total_weight + merge->weight));
args->weight_so_far / args->t->total_weight);
//idx++
if(k2 - args->k1 > 1 && c->weight > 0) {
if(args->idx + 1 < args->t->size
......
......@@ -1005,7 +1005,7 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv, SRpcReqCont
// client shall send the request within tsRpcTime again for UDP, double it
if (pConn->connType != RPC_CONN_TCPS)
pConn->pIdleTimer = taosTmrStart(rpcProcessIdleTimer, tsRpcTimer*2, pConn, pRpc->tmrCtrl);
pConn->pIdleTimer = taosTmrStart(rpcProcessIdleTimer, tsRpcTimer*20, pConn, pRpc->tmrCtrl);
} else {
terrno = rpcProcessRspHead(pConn, pHead);
*ppContext = pConn->pContext;
......
......@@ -606,4 +606,4 @@ void taosDumpGlobalCfg() {
taosDumpCfg(cfg);
}
}
\ No newline at end of file
}
此差异已折叠。
......@@ -17,12 +17,6 @@ exe:
gcc $(CFLAGS) ./stream.c -o $(ROOT)stream $(LFLAGS)
gcc $(CFLAGS) ./subscribe.c -o $(ROOT)subscribe $(LFLAGS)
gcc $(CFLAGS) ./apitest.c -o $(ROOT)apitest $(LFLAGS)
gcc $(CFLAGS) ./clientcfgtest.c -o $(ROOT)clientcfgtest $(LFLAGS)
gcc $(CFLAGS) ./clientcfgtest-wrongtype.c -o $(ROOT)clientcfgtest-wrongtype $(LFLAGS)
gcc $(CFLAGS) ./clientcfgtest-wrongjson.c -o $(ROOT)clientcfgtest-wrongjson $(LFLAGS)
gcc $(CFLAGS) ./clientcfgtest-wrongvalue.c -o $(ROOT)clientcfgtest-wrongvalue $(LFLAGS)
gcc $(CFLAGS) ./clientcfgtest-taosd.c -o $(ROOT)clientcfgtest-taosd $(LFLAGS)
clean:
rm $(ROOT)asyncdemo
......@@ -32,9 +26,7 @@ clean:
rm $(ROOT)stream
rm $(ROOT)subscribe
rm $(ROOT)apitest
rm $(ROOT)clientcfgtest
rm $(ROOT)clientcfgtest-wrongtype
rm $(ROOT)clientcfgtest-wrongjson
rm $(ROOT)clientcfgtest-wrongvalue
rm $(ROOT)clientcfgtest-taosd
......@@ -18213,4 +18213,21 @@
obj:/usr/bin/python3.8
fun:PyVectorcall_Call
fun:_PyEval_EvalFrameDefault
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_buffer_get_info
fun:array_getbuffer
fun:__Pyx__GetBufferAndValidate.constprop.64
fun:__pyx_f_5numpy_6random_13bit_generator_12SeedSequence_mix_entropy
fun:__pyx_pw_5numpy_6random_13bit_generator_12SeedSequence_1__init__
obj:/usr/bin/python3.8
fun:__Pyx__PyObject_CallOneArg
fun:__Pyx_PyObject_CallOneArg
fun:__pyx_pw_5numpy_6random_13bit_generator_12BitGenerator_1__init__
obj:/usr/bin/python3.8
obj:/usr/bin/python3.8
}
\ No newline at end of file
......@@ -398,6 +398,7 @@ python3 ./test.py -f query/queryWildcardLength.py
python3 ./test.py -f query/queryTbnameUpperLower.py
python3 ./test.py -f query/query.py
python3 ./test.py -f query/queryDiffColsOr.py
python3 ./test.py -f query/queryRegex.py
#======================p4-end===============
......
......@@ -41,6 +41,14 @@ class TDTestCase:
tdSql.execute(
"insert into test22 using stest tags('test21','ccc') values ('2020-09-04 16:54:54.003',210,3)")
#2021-09-17 For jira: https://jira.taosdata.com:18080/browse/TD-6085
tdSql.query("select last(size),appname from stest where tbname in ('test1','test2','test11')")
tdSql.checkRows(1)
#2021-09-17 For jira: https://jira.taosdata.com:18080/browse/TD-6314
tdSql.query("select _block_dist() from stest")
tdSql.checkRows(1)
tdSql.query("select sum(size) from stest interval(1d) group by appname")
tdSql.checkRows(3)
......
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
import taos
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
from util.dnodes import tdDnodes
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
def run(self):
tdSql.prepare()
print("==============step1")
##2021-09-17 For jira: https://jira.taosdata.com:18080/browse/TD-6585
tdSql.execute(
"create stable if not exists stb_test(ts timestamp,c0 binary(32)) tags(t0 binary(32))"
)
tdSql.execute(
'create table if not exists stb_1 using stb_test tags("abcdefgasdfg12346")'
)
tdLog.info('insert into stb_1 values("2021-09-13 10:00:00.001","abcefdasdqwerxasdazx12345"')
tdSql.execute('insert into stb_1 values("2021-09-13 10:00:00.001","abcefdasdqwerxasdazx12345")')
tdSql.query('select * from stb_test where tbname match "asd"')
tdSql.checkRows(0)
tdSql.query('select * from stb_test where tbname nmatch "asd"')
tdSql.checkRows(1)
tdSql.query('select * from stb_test where c0 match "abc"')
tdSql.checkRows(1)
tdSql.checkData(0,1,"abcefdasdqwerxasdazx12345")
tdSql.query('select * from stb_test where c0 nmatch "abc"')
tdSql.checkRows(0)
tdSql.error('select * from stb_test where c0 match abc')
tdSql.error('select * from stb_test where c0 nmatch abc')
tdSql.execute('insert into stb_1 values("2020-10-13 10:00:00.001","abcd\\\efgh")')
tdSql.query("select * from stb_1 where c0 match '\\\\'")
tdSql.checkRows(1)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
// The test case to verfy TS-293
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <taos.h>
#include "os.h"
#include "taosdef.h"
#include "taoserror.h"
#include "tconfig.h"
#include "tglobal.h"
#include "tulog.h"
#include "tsocket.h"
#include "tutil.h"
extern SGlobalCfg *taosGetConfigOption(const char *option) ;
int main( int argc, char *argv[]){
printf("start to test\n");
//case1:
//Test config firstEp success
const char config1[128] = "{\"firstEp\":\"BCC-2:6030\",\"debugFlag\":\"135\"}";//input the parameter which want to be configured
taos_set_config(config1); //configure the parameter
SGlobalCfg *cfg ;
cfg = taosGetConfigOption("firstEp");//check the option result
if(cfg->cfgStatus != 3){ //If cfgStatus is 3,it means configure is success
printf("config firstEp 'BCC-2:6030'failures!\n");
exit(1);
}
cfg = taosGetConfigOption("debugFlag");//check the option result
if(cfg->cfgStatus != 3){
printf("config debugFlag '135' failures!\n");
exit(1);
}
//case2:
//Test config only useful at the first time
//The result is failure
const char config2[128] = "{\"fqdn\":\"BCC-3\"}";
taos_set_config(config2); //configure the parameter
cfg = taosGetConfigOption("fqdn");//check the option result
if(cfg->cfgStatus == 3){
printf("config firstEp to 'BCC-3' failures!\n");
exit(1);
}
else{
printf("test case success!\n");
exit(0);
}
return 0 ;
}
......@@ -7,7 +7,10 @@ LFLAGS = '-Wl,-rpath,/usr/local/taos/driver/' -ltaos -lpthread -lm -lrt
CFLAGS = -O0 -g -Wall -Wno-deprecated -fPIC -Wno-unused-result -Wconversion \
-Wno-char-subscripts -D_REENTRANT -Wno-format -D_REENTRANT -DLINUX \
-Wno-unused-function -D_M_X64 -I/usr/local/taos/include -std=gnu99 \
-fsanitize=address
-I../../../deps/cJson/inc\
-I../../../src/os/inc/ -I../../../src/inc -I../../../src/util/inc \
-I../../../src/common/inc -I../../../deps/cJson/inc
all: $(TARGET)
......@@ -17,8 +20,18 @@ exe:
gcc $(CFLAGS) ./stmtTest.c -o $(ROOT)stmtTest $(LFLAGS)
gcc $(CFLAGS) ./stmt_function.c -o $(ROOT)stmt_function $(LFLAGS)
gcc $(CFLAGS) ./clientcfgtest.c -o $(ROOT)clientcfgtest $(LFLAGS)
gcc $(CFLAGS) ./openTSDBTest.c -o $(ROOT)openTSDBTest $(LFLAGS)
clean:
rm $(ROOT)batchprepare
rm $(ROOT)stmtBatchTest
rm $(ROOT)stmtTest
rm $(ROOT)stmt_function
rm $(ROOT)clientcfgtest
rm $(ROOT)openTSDBTest
此差异已折叠。
......@@ -11,15 +11,15 @@ tests_dir=`pwd`
IN_TDINTERNAL="community"
function stopTaosd {
echo "Stop taosd"
echo "Stop taosd"
sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail'
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
while [ -n "$PID" ]
do
while [ -n "$PID" ]
do
pkill -TERM -x taosd
sleep 1
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
done
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
done
}
function dohavecore(){
......@@ -233,6 +233,7 @@ totalPyFailed=0
totalJDBCFailed=0
totalUnitFailed=0
totalExampleFailed=0
totalApiFailed=0
if [ "${OS}" == "Linux" ]; then
corepath=`grep -oP '.*(?=core_)' /proc/sys/kernel/core_pattern||grep -oP '.*(?=core-)' /proc/sys/kernel/core_pattern`
......@@ -532,7 +533,28 @@ if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "jdbc" ] && [ "$2" !=
echo "demo pass"
totalExamplePass=`expr $totalExamplePass + 1`
fi
echo "### run setconfig tests ###"
stopTaosd
cd $tests_dir
echo "current dir: "
pwd
cd script/api
echo "building setcfgtest"
make > /dev/null
./clientcfgtest
if [ $? != "0" ]; then
echo "clientcfgtest failed"
totalExampleFailed=`expr $totalExampleFailed + 1`
else
echo "clientcfgtest pass"
totalExamplePass=`expr $totalExamplePass + 1`
fi
if [ "$totalExamplePass" -gt "0" ]; then
echo -e "\n${GREEN} ### Total $totalExamplePass examples succeed! ### ${NC}"
fi
......@@ -544,7 +566,13 @@ if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "jdbc" ] && [ "$2" !=
if [ "${OS}" == "Linux" ]; then
dohavecore 1
fi
fi
exit $(($totalFailed + $totalPyFailed + $totalJDBCFailed + $totalUnitFailed + $totalExampleFailed))
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册