提交 ce0386a9 编写于 作者: S shenglian zhou

[TS-636]<fix>:escape % with \ suport

上级 1e61044b
...@@ -262,7 +262,7 @@ int32_t shellRunCommand(TAOS* con, char* command) { ...@@ -262,7 +262,7 @@ int32_t shellRunCommand(TAOS* con, char* command) {
} }
if (c == '\\') { if (c == '\\') {
if (quote != 0 && (*command == '_' || *command == '\\')) { if (quote != 0 && (*command == '_' || *command == '%' || *command == '\\')) {
//DO nothing //DO nothing
} else { } else {
esc = true; esc = true;
......
...@@ -278,6 +278,7 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat ...@@ -278,6 +278,7 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
if (j <= size) { if (j <= size) {
if (c == '\\' && patterStr[i] == '_' && c1 == '_') { i++; continue; } 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)) { if (c == c1 || tolower(c) == tolower(c1) || (c == pInfo->matchOne && c1 != 0)) {
continue; continue;
} }
......
...@@ -64,7 +64,7 @@ int32_t strRmquote(char *z, int32_t len){ ...@@ -64,7 +64,7 @@ int32_t strRmquote(char *z, int32_t len){
int32_t j = 0; int32_t j = 0;
for (uint32_t k = 1; k < len - 1; ++k) { for (uint32_t k = 1; k < len - 1; ++k) {
if (z[k] == '\\' || (z[k] == delim && z[k + 1] == delim)) { 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 //match '_' self
} else { } else {
z[j] = z[k + 1]; z[j] = z[k + 1];
......
...@@ -23,7 +23,7 @@ sql create table $table2 (ts timestamp, b binary(20)) ...@@ -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, "table_name")
sql insert into $table1 values(now-1m, "tablexname") sql insert into $table1 values(now-1m, "tablexname")
sql insert into $table1 values(now-2m, "tablexxx") 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 sql select b from $table1
if $rows != 4 then if $rows != 4 then
...@@ -56,6 +56,45 @@ if $rows != 1 then ...@@ -56,6 +56,45 @@ if $rows != 1 then
return -1 return -1
endi 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 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.
先完成此消息的编辑!
想要评论请 注册