未验证 提交 824ce4e4 编写于 作者: J jianqingdu 提交者: GitHub

Merge branch 'taosdata:develop' into develop

......@@ -628,7 +628,7 @@ func insertData(threadIndex, start, end int, wg *sync.WaitGroup, successRows []i
buffer.WriteString(",")
for _, field := range subTableInfo.config.Fields {
buffer.WriteString(getFieldValue(currentRow[strings.ToLower(field.Name)]))
buffer.WriteString(getFieldValue(currentRow[strings.ToLower(field.Name)],field.Type))
buffer.WriteString(",")
}
......@@ -708,7 +708,10 @@ func executeBatchInsert(insertSql string, connection *sql.DB) int64 {
return affected
}
func getFieldValue(fieldValue interface{}) string {
func getFieldValue(fieldValue interface{},fieldtype interface{}) string {
if fieldtype == "timestamp" || fieldtype == "bigint" {
return fmt.Sprintf("%v", fieldValue)
}
return fmt.Sprintf("'%v'", fieldValue)
}
......
......@@ -18,6 +18,8 @@ tags = [
fields = [
# 字段列表,name 为字段名称,type 为字段类型
# 除主键外,其他field如果也要设置为timestamp,可以是type ="timestamp" 类型,此时value可同时支持'2006-01-02 15:04:05.000'和millisecond格式
# 也可以是type = "bigint",此时value只支持millisecond格式
{ name = "ts", type = "timestamp" },
{ name = "temperature", type = "int" },
{ name = "humidity", type = "float" },
......
......@@ -262,7 +262,7 @@ int32_t shellRunCommand(TAOS* con, char* command) {
}
if (c == '\\') {
if (quote != 0 && (*command == '_' || *command == '\\')) {
if (quote != 0 && (*command == '_' || *command == '%' || *command == '\\')) {
//DO nothing
} else {
esc = true;
......
......@@ -5710,6 +5710,11 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) {
}
}
if (pOperator->status == OP_EXEC_DONE) {
*newgroup = false;
return NULL;
}
while(1) {
bool prevVal = *newgroup;
......@@ -5722,7 +5727,7 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) {
//assert(*newgroup == false);
*newgroup = prevVal;
setQueryStatus(pRuntimeEnv, QUERY_COMPLETED);
doSetOperatorCompleted(pOperator);
break;
}
......
......@@ -278,6 +278,7 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
if (j <= size) {
if (c == '\\' && patterStr[i] == '_' && c1 == '_') { i++; continue; }
if (c == '\\' && patterStr[i] == '%' && c1 == '%') { i++; continue; }
if (c == c1 || tolower(c) == tolower(c1) || (c == pInfo->matchOne && c1 != 0)) {
continue;
}
......
......@@ -64,7 +64,7 @@ int32_t strRmquote(char *z, int32_t len){
int32_t j = 0;
for (uint32_t k = 1; k < len - 1; ++k) {
if (z[k] == '\\' || (z[k] == delim && z[k + 1] == delim)) {
if (z[k] == '\\' && z[k + 1] == '_') {
if ((z[k] == '\\' && z[k + 1] == '_') || (z[k] == '\\' && z[k + 1] == '%')) {
//match '_' self
} else {
z[j] = z[k + 1];
......
......@@ -10,6 +10,7 @@
###################################################################
# -*- coding: utf-8 -*-
from util.dnodes import tdDnodes
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
......@@ -71,6 +72,28 @@ class TDTestCase:
tdSql.query("select last_row(*), tbname from meters group by tbname order by ts desc")
tdSql.checkRows(2)
# TS-561 null tags group by crash
tdLog.info("test case for TS-561")
tdSql.execute("create database openfalcon")
tdSql.execute("use openfalcon")
tdSql.execute("create table stb (ts timestamp, value double) tags(_endpoint binary(150), _hostname binary(150), _indexname binary(50), _ip binary(50), _q_name binary(150))")
tdSql.execute("create table tb0 using stb tags('root.FTBI', 'CNSZ17VL4774', 'max_mem', '10.116.100.10_8088', 'root.line_volume_predict')")
tdSql.execute("create table tb1 using stb(_endpoint, _hostname, _indexname) tags('root.medium_high_freq', 'CNSZ17VL4775', 'max_mem_1')")
for i in range(2):
sql = "insert into tb%d values" % i
for j in range(10000):
sql += "(%d, %d)" % (ts + j * 500, random.randint(1, 10000) + random.uniform(1.0, 1000.0))
tdSql.execute(sql)
tdSql.query("select avg(value) from openfalcon.stb where ts > '2020-11-15 03:30:00.000' and ts < '2020-11-15 04:30:00.000' group by _hostname, _indexname, _ip, _q_name")
tdSql.checkRows(2)
tdDnodes.stop(1)
tdDnodes.start(1)
tdSql.query("select avg(value) from openfalcon.stb where ts > '2020-11-15 03:30:00.000' and ts < '2020-11-15 04:30:00.000' group by _hostname, _indexname, _ip, _q_name")
tdSql.checkRows(2)
def run(self):
tdSql.prepare()
......
......@@ -91,6 +91,12 @@ class TDTestCase:
tdSql.query("show stables")
tdSql.checkRows(1)
# TS-646
tdLog.info("test case for TS-646")
tdSql.execute("drop stable if exists db.st")
tdSql.execute("create table stb(ts timestamp, c1 int) tags(t1 int)")
tdSql.error("create table `` using stb tags(1)")
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
......
......@@ -23,7 +23,7 @@ sql create table $table2 (ts timestamp, b binary(20))
sql insert into $table1 values(now, "table_name")
sql insert into $table1 values(now-1m, "tablexname")
sql insert into $table1 values(now-2m, "tablexxx")
sql insert into $table1 values(now-2m, "table")
sql insert into $table1 values(now-3m, "table")
sql select b from $table1
if $rows != 4 then
......@@ -56,6 +56,45 @@ if $rows != 1 then
return -1
endi
sql create database escape_percentage;
sql use escape_percentage;
$table1 = tablename
$table2 = `table%`
sql create table $table1 (ts timestamp, b binary(20))
sql create table $table2 (ts timestamp, b binary(20))
sql insert into $table1 values(now, "table%name")
sql insert into $table1 values(now-1m, "table%")
sql insert into $table1 values(now-2m, "table%%%")
sql insert into $table1 values(now-3m, "table")
sql select b from $table1 where b like 'table\%'
print $rows
if $rows != 1 then
return -1
endi
sql select b from $table1 where b like 'table\%\%\%'
print $rows
if $rows != 1 then
return -1
endi
sql select b from $table1 where b like 'table%'
print $rows
if $rows != 4 then
return -1
endi
sql show tables like 'table\%'
print $rows
if $rows != 1 then
return -1
endi
sql show tables like 'table%'
print $rows
if $rows != 2 then
return -1
endi
sql drop database escape_percentage
system sh/exec.sh -n dnode1 -s stop -x SIGINT
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册