diff --git a/importSampleData/app/main.go b/importSampleData/app/main.go index e45e33e159f8636f8bdc5156b3b9b0947453bab4..3589c8c2a98f31e78c4dac3496f804605a0b2314 100644 --- a/importSampleData/app/main.go +++ b/importSampleData/app/main.go @@ -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) } diff --git a/importSampleData/config/cfg.toml b/importSampleData/config/cfg.toml index 52a5d5f3169d21ce17039ead956250a636b37a01..545bab071ad66af2f59447b3449c6606e2ff1078 100644 --- a/importSampleData/config/cfg.toml +++ b/importSampleData/config/cfg.toml @@ -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" }, diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index 40c5a5da8170c43315fe2657a91be64fe8a58b87..8ab9bfcf4e7685081cd6f09990f5365d94c4094b 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -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; diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index fc57c1f0fd7d60e8aee8c9f012090cdea8bcf647..6a89a2f823ad3ff57807561d7ead4b919851b000 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -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; } diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index 4bed561f71aef6aafcf4ec2af814c0a2c7e6b63f..23bb73ff860a2b0c4bd5a81005089910faa7792a 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -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; } diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index 31556b83d06224d285db29650eba82c4d3acab5e..c8172fc0aff010332de7d13071a28303f37cf7f5 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -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]; diff --git a/tests/pytest/query/queryGroupTbname.py b/tests/pytest/query/queryGroupTbname.py index 90e717508221ddd4a35dfc0f0122cdc0220273fd..bb67809e60087f94ad7f92ca7515aa8ddfc43151 100644 --- a/tests/pytest/query/queryGroupTbname.py +++ b/tests/pytest/query/queryGroupTbname.py @@ -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() diff --git a/tests/pytest/stable/insert.py b/tests/pytest/stable/insert.py index ef5635c77ce04ddd33354e1754dc70b2c9f8b6a5..f46a6bcf4a0becf6cbee54281a9b3ecc862d63ce 100644 --- a/tests/pytest/stable/insert.py +++ b/tests/pytest/stable/insert.py @@ -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__) diff --git a/tests/script/general/parser/like.sim b/tests/script/general/parser/like.sim index fce996ebee37d887e2f86fc2a8566d844e8d04f5..382240c91141a19e28bc4a25d81cea54737b6a55 100644 --- a/tests/script/general/parser/like.sim +++ b/tests/script/general/parser/like.sim @@ -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