where.sim 9.6 KB
Newer Older
1 2 3
system sh/stop_dnodes.sh

system sh/deploy.sh -n dnode1 -i 1
4
system sh/cfg.sh -n dnode1 -c walLevel -v 1
H
Haojun Liao 已提交
5
system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4
6 7
system sh/exec.sh -n dnode1 -s start

H
Haojun Liao 已提交
8
sleep 100
S
slguan 已提交
9 10 11 12 13 14 15 16
sql connect

$dbPrefix = wh_db
$tbPrefix = wh_tb
$mtPrefix = wh_mt
$tbNum = 10
$rowNum = 10000
$totalNum = $tbNum * $rowNum
17 18

print =============== where.sim
S
slguan 已提交
19 20 21
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i
22

H
Haojun Liao 已提交
23
sql drop database if exists $db -x step1
24
step1:
R
scripts  
root 已提交
25
sql create database if not exists $db 
S
slguan 已提交
26
sql use $db
27 28
sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int)

H
Haojun Liao 已提交
29 30
$half = $tbNum / 2

31
$i = 0
H
Haojun Liao 已提交
32
while $i < $half
33
  $tb = $tbPrefix . $i
H
Haojun Liao 已提交
34 35 36 37

  $nextSuffix = $i + $half
  $tb1 = $tbPrefix . $nextSuffix

38
  sql create table $tb using $mt tags( $i )
H
Haojun Liao 已提交
39
  sql create table $tb1 using $mt tags( $nextSuffix )
40 41 42

  $x = 0
  while $x < $rowNum
S
TD-1530  
Shengliang Guan 已提交
43 44
    $y = $x * 60000
    $ms = 1600099200000 + $y
45 46 47 48 49 50 51
    $c = $x / 100
    $c = $c * 100
    $c = $x - $c
    $binary = 'binary . $c
    $binary = $binary . '
    $nchar = 'nchar . $c
    $nchar = $nchar . '
H
Haojun Liao 已提交
52
    sql insert into $tb values ($ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar )  $tb1 values ($ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar )
53 54 55 56 57
    $x = $x + 1
  endw

  $i = $i + 1
endw
S
slguan 已提交
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89

sleep 100

$i = 1
$tb = $tbPrefix . $i

##
sql_error select * from $tb where c7

# TBASE-654 : invalid filter expression cause server crashed
sql_error select count(*) from $tb where c1<10 and c1<>2

sql select * from $tb where c7 = false
$val = $rowNum / 100
if $rows != $val then
  return -1
endi
sql select * from $mt where c7 = false
$val = $totalNum / 100
if $rows != $val then
  return -1
endi

sql select tbname from $mt
if $rows != $tbNum then
  return -1
endi

sql select tbname from $mt where t1 < 2
if $rows != 2 then
  return -1
endi
H
Haojun Liao 已提交
90 91

print $tbPrefix
S
slguan 已提交
92
$tb = $tbPrefix . 0
H
Haojun Liao 已提交
93 94
if $data00 != wh_tb1 then
  print expect wh_tb1, actual:$data00
S
slguan 已提交
95 96 97
  return -1
endi
$tb = $tbPrefix . 1
H
Haojun Liao 已提交
98 99
if $data10 != wh_tb0 then
  print expect wh_tb0, actual:$data00
S
slguan 已提交
100 101 102 103 104
  return -1
endi

## select specified columns

S
TD-1530  
Shengliang Guan 已提交
105
print select c1 from $mt
S
slguan 已提交
106
sql select c1 from $mt
S
TD-1530  
Shengliang Guan 已提交
107 108 109

print rows $rows
print totalNum $totalNum
S
slguan 已提交
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
if $rows != $totalNum then
  return -1
endi
sql select count(c1) from $mt
if $data00 != $totalNum then
  return -1
endi

sql select c1 from $mt where c1 >= 0
if $rows != $totalNum then
  return -1
endi
sql select count(c1) from $mt where c1 <> -1
if $data00 != $totalNum then
  return -1
endi
sql select count(c1) from $mt where c1 <> -1 group by t1
if $rows != $tbNum then
  return -1
endi
if $data00 != $rowNum then
  return -1
endi

## like
sql_error select * from $mt where c1 like 1
#sql_error select * from $mt where t1 like 1

## [TBASE-593]
sql create table wh_mt1 (ts timestamp, c1 smallint, c2 int, c3 bigint, c4 float, c5 double, c6 tinyint, c7 binary(10), c8 nchar(10), c9 bool, c10 timestamp) tags (t1 binary(10), t2 smallint, t3 int, t4 bigint, t5 float, t6 double)
sql create table wh_mt1_tb1 using wh_mt1 tags ('tb11', 1, 1, 1, 1, 1)
sql insert into wh_mt1_tb1 values (now, 1, 1, 1, 1, 1, 1, 'binary', 'nchar', true, '2019-01-01 00:00:00.000')
142 143 144 145 146 147 148 149 150 151 152 153
#sql_error select last(*) from wh_mt1 where c1 in ('1')
#sql_error select last(*) from wh_mt1_tb1 where c1 in ('1')
#sql_error select last(*) from wh_mt1 where c2 in ('1')
#sql_error select last(*) from wh_mt1_tb1 where c2 in ('1')
#sql_error select last(*) from wh_mt1 where c3 in ('1')
#sql_error select last(*) from wh_mt1_tb1 where c3 in ('1')
#sql_error select last(*) from wh_mt1 where c4 in ('1')
#sql_error select last(*) from wh_mt1_tb1 where c4 in ('1')
#sql_error select last(*) from wh_mt1 where c5 in ('1')
#sql_error select last(*) from wh_mt1_tb1 where c5 in ('1')
#sql_error select last(*) from wh_mt1 where c6 in ('1')
#sql_error select last(*) from wh_mt1_tb1 where c6 in ('1')
Y
yihaoDeng 已提交
154 155 156 157
#sql_error select last(*) from wh_mt1 where c7 in ('binary')
#sql_error select last(*) from wh_mt1_tb1 where c7 in ('binary')
#sql_error select last(*) from wh_mt1 where c8 in ('nchar')
#sql_error select last(*) from wh_mt1_tb1 where c9 in (true, false)
158 159
#sql_error select last(*) from wh_mt1 where c10 in ('2019-01-01 00:00:00.000')
#sql_error select last(*) from wh_mt1_tb1 where c10 in ('2019-01-01 00:00:00.000')
S
slguan 已提交
160 161 162 163 164 165 166 167 168 169 170 171 172 173
sql select last(*) from wh_mt1 where c1 = 1
if $rows != 1 then
  return -1
endi

## [TBASE-597]
sql create table wh_mt2 (ts timestamp, c1 timestamp, c2 binary(10), c3 nchar(10)) tags (t1 binary(10))
sql create table wh_mt2_tb1 using wh_mt2 tags ('wh_mt2_tb1')

# 2019-01-01 00:00:00.000     1546272000000
# 2019-01-01 00:10:00.000     1546272600000
# 2019-01-01 09:00:00.000     1546304400000
# 2019-01-01 09:10:00.000     1546305000000
sql insert into wh_mt2_tb1 values ('2019-01-01 00:00:00.000', '2019-01-01 09:00:00.000', 'binary10', 'nchar10') 
H
Haojun Liao 已提交
174 175
sql insert into wh_mt2_tb1 values ('2019-01-01 00:10:00.000', '2019-01-01 09:10:00.000', 'binary10', 'nchar10')

S
slguan 已提交
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
sql select * from wh_mt2_tb1 where c1 > 1546304400000
if $rows != 1 then
  return -1
endi
if $data00 != @19-01-01 00:10:00.000@ then
  return -1
endi
if $data01 != @19-01-01 09:10:00.000@ then
  return -1
endi

sql select * from wh_mt2_tb1 where c1 > '2019-01-01 09:00:00.000'
if $rows != 1 then
  return -1
endi
if $data00 != @19-01-01 00:10:00.000@ then
  return -1
endi
if $data01 != @19-01-01 09:10:00.000@ then
  return -1
endi

sql select * from wh_mt2_tb1 where c1 > 1546304400000 and ts < '2019-01-01 00:10:00.000'
if $rows != 0 then
  return -1
endi

sql select * from wh_mt2_tb1 where c1 > '2019-01-01 09:00:00.000' and ts < '2019-01-01 00:10:00.000'
if $rows != 0 then
  return -1
endi

sql select * from wh_mt2_tb1 where c1 >= 1546304400000 and c1 <= '2019-01-01 09:10:00.000'
if $rows != 2 then
  return -1
endi
if $data00 != @19-01-01 00:00:00.000@ then
  return -1
endi
if $data01 != @19-01-01 09:00:00.000@ then
  return -1
endi
if $data10 != @19-01-01 00:10:00.000@ then
  return -1
endi
if $data11 != @19-01-01 09:10:00.000@ then
  return -1
endi

sql select * from wh_mt2_tb1 where c1 >= '2019-01-01 09:00:00.000' and c1 <= '2019-01-01 09:10:00.000'
if $rows != 2 then
  return -1
endi
if $data00 != @19-01-01 00:00:00.000@ then
  return -1
endi
if $data01 != @19-01-01 09:00:00.000@ then
  return -1
endi
if $data10 != @19-01-01 00:10:00.000@ then
  return -1
endi
if $data11 != @19-01-01 09:10:00.000@ then
  return -1
endi

242
sql create table tb_where_NULL (ts timestamp, c1 float, c2 binary(10))
H
Haojun Liao 已提交
243 244 245 246 247 248 249

print ===================>td-1604
sql_error insert into tb_where_NULL values(?, ?, ?)
sql_error insert into tb_where_NULL values(now, 1, ?)
sql_error insert into tb_where_NULL values(?, 1, '')
sql_error insert into tb_where_NULL values(now, ?, '12')

250 251 252 253 254 255 256
sql insert into tb_where_NULL values ('2019-01-01 09:00:00.000', 1, 'val1')
sql insert into tb_where_NULL values ('2019-01-01 09:00:01.000', NULL, NULL)
sql insert into tb_where_NULL values ('2019-01-01 09:00:02.000', 2, 'val2')
sql_error select * from tb_where_NULL where c1 = NULL
sql_error select * from tb_where_NULL where c1 <> NULL
sql_error select * from tb_where_NULL where c1 < NULL
sql select * from tb_where_NULL where c1 = "NULL"
S
slguan 已提交
257 258 259 260
if $rows != 0 then
  return -1
endi

261
sql select * from tb_where_NULL where c1 <> "NULL"
S
slguan 已提交
262 263 264
if $rows != 2 then
  return -1
endi
265
sql select * from tb_where_NULL where c1 <> "nulL"
S
slguan 已提交
266 267 268 269
if $rows != 2 then
  return -1
endi

270
sql select * from tb_where_NULL where c1 > "NULL"
S
slguan 已提交
271 272 273 274
if $rows != 0 then
  return -1
endi

275
sql select * from tb_where_NULL where c1 >= "NULL"
S
slguan 已提交
276 277 278 279
if $rows != 0 then
  return -1
endi

280
sql select * from tb_where_NULL where c2 = "NULL"
S
slguan 已提交
281 282 283 284
if $rows != 0 then
  return -1
endi

285
sql select * from tb_where_NULL where c2 <> "NULL"
S
slguan 已提交
286 287 288
if $rows != 2 then
  return -1
endi
289
sql select * from tb_where_NULL where c2 <> "nUll"
S
slguan 已提交
290 291 292
if $rows != 2 then
  return -1
endi
S
scripts  
Shengliang Guan 已提交
293

H
Haojun Liao 已提交
294 295 296 297 298 299 300 301 302 303
print ==========tbase-1363
#sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int)

$i = 0
while $i < 1
  $tb = test_null_filter
  sql create table $tb using $mt tags( $i )

  $x = 0
  while $x < 10000
S
TD-1530  
Shengliang Guan 已提交
304 305
    $y = $x * 60000
    $ms = 1601481600000 + $y
H
Haojun Liao 已提交
306 307 308 309 310 311 312
    $c = $x / 100
    $c = $c * 100
    $c = $x - $c
    $binary = 'binary . $c
    $binary = $binary . '
    $nchar = 'nchar . $c
    $nchar = $nchar . '
S
TD-1530  
Shengliang Guan 已提交
313
    sql insert into $tb values ($ms , null , null , null , null , null , null , null , null , null )
H
Haojun Liao 已提交
314 315 316 317 318 319 320
    $x = $x + 1
  endw

  $i = $i + 1
endw

system sh/exec.sh -n dnode1 -s stop -x SIGINT
H
Haojun Liao 已提交
321
sleep 500
H
Haojun Liao 已提交
322 323 324

system sh/exec.sh -n dnode1 -s start

325 326 327
sql_error select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter');

sql select * from wh_mt0 where c3 = '1' and tbname in ('test_null_filter');
H
Haojun Liao 已提交
328 329 330 331
if $row != 0 then
  return -1
endi

332 333 334 335 336 337 338 339 340 341 342 343
sql select * from wh_mt0 where c3 = '1';
if $row == 0 then
  return -1
endi

sql select * from wh_mt0 where c3 is null and tbname in ('test_null_filter');
if $rows != 10000 then
  return -1
endi

sql select * from wh_mt0 where c3 is not null and tbname in ('test_null_filter');
if $rows != 0 then
H
Haojun Liao 已提交
344 345 346
  return -1
endi

H
Haojun Liao 已提交
347 348 349 350 351 352 353 354
print ==========================>td-3318
sql create table tu(ts timestamp,  k int, b binary(12))
sql insert into tu values(now, 1, 'abc')
sql select stddev(k) from tu where b <>'abc' interval(1s)
if $rows != 0 then
 return -1
endi

355 356 357 358 359 360 361 362 363 364 365 366 367 368
print ==========================> td-4783
sql create table where_ts(ts timestamp, f int)
sql insert into where_ts values('2021-06-19 16:22:00', 1);
sql insert into where_ts values('2021-06-19 16:23:00', 2);
sql insert into where_ts values('2021-06-19 16:24:00', 3);
sql insert into where_ts values('2021-06-19 16:25:00', 1);
sql select * from (select * from where_ts) where ts<'2021-06-19 16:25:00' and ts>'2021-06-19 16:22:00'
if $row != 2 then
  return -1
endi
print $data00, $data01
if $data01 != 2 then
  return -1
endi
Y
yihaoDeng 已提交
369
system sh/exec.sh -n dnode1 -s stop -x SIGINT