[TD-6145]<feature>:add test for regex filter
This commit is contained in:
parent
28f2f0d70b
commit
6363169a47
|
@ -4525,7 +4525,7 @@ static int32_t validateMatchExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_
|
|||
char regErrBuf[256] = {0};
|
||||
|
||||
const char* pattern = pRight->value.pz;
|
||||
int cflags = REG_EXTENDED | REG_ICASE;
|
||||
int cflags = REG_EXTENDED;
|
||||
if ((errCode = regcomp(®ex, pattern, cflags)) != 0) {
|
||||
regerror(errCode, ®ex, regErrBuf, sizeof(regErrBuf));
|
||||
tscError("Failed to compile regex pattern %s. reason %s", pattern, regErrBuf);
|
||||
|
|
|
@ -4236,7 +4236,7 @@ void getTableListfromSkipList(tExprNode *pExpr, SSkipList *pSkipList, SArray *re
|
|||
param->setupInfoFn(pExpr, param->pExtInfo);
|
||||
|
||||
tQueryInfo *pQueryInfo = pExpr->_node.info;
|
||||
if (pQueryInfo->indexed && (pQueryInfo->optr != TSDB_RELATION_LIKE && pQueryInfo->optr == TSDB_RELATION_MATCH
|
||||
if (pQueryInfo->indexed && (pQueryInfo->optr != TSDB_RELATION_LIKE && pQueryInfo->optr != TSDB_RELATION_MATCH
|
||||
&& pQueryInfo->optr != TSDB_RELATION_IN)) {
|
||||
queryIndexedColumn(pSkipList, pQueryInfo, result);
|
||||
} else {
|
||||
|
|
|
@ -365,7 +365,7 @@ int32_t compareStrRegexComp(const void* pLeft, const void* pRight) {
|
|||
regex_t regex;
|
||||
char msgbuf[256] = {0};
|
||||
|
||||
int cflags = REG_EXTENDED | REG_ICASE;
|
||||
int cflags = REG_EXTENDED;
|
||||
if ((errCode = regcomp(®ex, pattern, cflags)) != 0) {
|
||||
regerror(errCode, ®ex, msgbuf, sizeof(msgbuf));
|
||||
uError("Failed to compile regex pattern %s. reason %s", pattern, msgbuf);
|
||||
|
|
|
@ -222,3 +222,4 @@ run general/stream/metrics_replica1_vnoden.sim
|
|||
run general/db/show_create_db.sim
|
||||
run general/db/show_create_table.sim
|
||||
run general/parser/like.sim
|
||||
run general/parser/regex.sim
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 1
|
||||
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
sleep 100
|
||||
sql connect
|
||||
|
||||
$db = testdb
|
||||
sql drop database if exists $db
|
||||
sql create database $db
|
||||
sql use $db
|
||||
|
||||
print ======================== regular expression match test
|
||||
$st_name = st
|
||||
$ct1_name = ct1
|
||||
$ct2_name = ct2
|
||||
|
||||
sql create table $st_name (ts timestamp, c1b binary(20)) tags(t1b binary(20));
|
||||
sql create table $ct1_name using $st_name tags('taosdata1')
|
||||
sql create table $ct2_name using $st_name tags('taosdata2')
|
||||
sql create table not_match using $st_name tags('NOTMATCH')
|
||||
|
||||
sql select tbname from $st_name where tbname match '^ct[[:digit:]]'
|
||||
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select tbname from $st_name where t1b match '[[:lower:]]+'
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql insert into $ct1_name values(now, 'this is engine')
|
||||
sql insert into $ct2_name values(now, 'this is app egnine')
|
||||
|
||||
sql select c1b from $st_name where c1b match 'engine'
|
||||
if $data00 != @this is engine@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
||||
|
Loading…
Reference in New Issue