regex.sim 4.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
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')

S
shenglian zhou 已提交
25 26 27 28 29 30
sql select tbname from $st_name where tbname match '.*'
if $rows != 3 then
  return -1
endi


31 32 33 34 35
sql select tbname from $st_name where tbname match '^ct[[:digit:]]'
if $rows != 2 then
  return -1
endi

36 37 38 39 40
sql select tbname from $st_name where tbname nmatch '^ct[[:digit:]]'
if $rows != 1 then
  return -1
endi

S
shenglian zhou 已提交
41
sql select tbname from $st_name where tbname match '.*'
42 43 44 45 46 47
if $rows != 3 then
  return -1
endi

sql select tbname from $st_name where tbname nmatch '.*'
if $rows != 0 then
S
shenglian zhou 已提交
48 49 50
  return -1
endi

51 52 53 54 55
sql select tbname from $st_name where t1b match '[[:lower:]]+'
if $rows != 2 then
  return -1
endi

56 57 58 59 60
sql select tbname from $st_name where t1b nmatch '[[:lower:]]+'
if $rows != 1 then
  return -1
endi

61 62 63 64 65 66 67 68 69 70 71 72
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  

73 74 75 76 77 78 79 80
sql select c1b from $st_name where c1b nmatch 'engine'
if $data00 != @this is app egnine@ then
  return -1
endi

if $rows != 1 then
  return -1
endi  
81

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
sql select c1b from $st_name where c1b match '\\.\\*'
if $rows != 0 then
  return -1
endi

sql select c1b from $st_name where c1b match '\\\\'
if $rows != 0 then
  return -1
endi

sql insert into $ct1_name values(now+3s, '\\this is engine')

sql select c1b from $st_name where c1b match '\\'
if $rows != 1 then
  return -1
endi

99 100 101
sql_error select c1b from $st_name where c1b match e;
sql_error select c1b from $st_name where c1b nmatch e;

102 103
sql create table wrong_type(ts timestamp, c0 tinyint, c1 smallint, c2 int, c3 bigint, c4 float, c5 double, c6 bool, c7 nchar(20)) tags(t0 tinyint, t1 smallint, t2 int, t3 bigint, t4 float, t5 double, t6 bool, t7 nchar(10))
sql insert into wrong_type_1 using wrong_type tags(1, 2, 3, 4, 5, 6, true, 'notsupport') values(now, 1, 2, 3, 4, 5, 6, false, 'notsupport') 
104 105 106 107 108 109 110 111 112 113 114 115 116
sql_error select * from wrong_type where ts match '.*'
sql_error select * from wrong_type where ts nmatch '.*'
sql_error select * from wrong_type where c0 match '.*'
sql_error select * from wrong_type where c0 nmatch '.*'
sql_error select * from wrong_type where c1 match '.*'
sql_error select * from wrong_type where c1 nmatch '.*'
sql_error select * from wrong_type where c2 match '.*'
sql_error select * from wrong_type where c2 nmatch '.*'
sql_error select * from wrong_type where c3 match '.*'
sql_error select * from wrong_type where c3 nmatch '.*'
sql_error select * from wrong_type where c4 match '.*'
sql_error select * from wrong_type where c4 nmatch '.*'
sql_error select * from wrong_type where c5 match '.*'
117 118
sql_error select * from wrong_type where c5 nmatch '.*'
sql_error select * from wrong_type where c6 match '.*'
119
sql_error select * from wrong_type where c6 nmatch '.*'
120 121
sql_error select * from wrong_type where c7 match '.*'
sql_error select * from wrong_type where c7 nmatch '.*'
122 123 124
sql_error select * from wrong_type where t1 match '.*'
sql_error select * from wrong_type where t1 nmatch '.*'
sql_error select * from wrong_type where t2 match '.*'
125
sql_error select * from wrong_type where t2 nmatch '.*'
126
sql_error select * from wrong_type where t3 match '.*'
127
sql_error select * from wrong_type where t3 nmatch '.*'
128
sql_error select * from wrong_type where t4 match '.*'
129 130
sql_error select * from wrong_type where t4 nmatch '.*'
sql_error select * from wrong_type where t5 match '.*'
131
sql_error select * from wrong_type where t5 nmatch '.*'
132
sql_error select * from wrong_type where t6 match '.*'
133
sql_error select * from wrong_type where t6 nmatch '.*'
134 135
sql_error select * from wrong_type where t7 match '.*'
sql_error select * from wrong_type where t7 nmatch '.*'
136

137 138 139
system sh/exec.sh -n dnode1 -s stop -x SIGINT