summaryrefslogtreecommitdiffstats
path: root/mysql-test/main/mysqltest-break.test
blob: 5ef8b70fbd8d2552251f3b94349f001f33e33937 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
--source include/not_embedded.inc
#
# MDEV-12130 improve mysqltest language
#
# test "break" statement
#

# Break in a single loop

let $cnt= 4;
while($cnt > 1)
{
  dec $cnt;
  break;
  --echo $cnt
  --echo Break did not stop a single loop
}

# Break stops inner loop

let $outer= 4;
while($outer > 1)
{
  let $inner= 4;
  while($inner > 1)
  {
    if($outer == 2)
    {
      --echo OK
    }
    if($inner == 2)
    {
      break;
    }
    dec $inner;
  }
  dec $outer;
  --echo $outer
}

# Break stops outer loop
let $inner= 4;
let $outer= 4;
while($outer > 1)
{
  break;
  while($inner > 1)
  {
    dec $inner;
    --echo Outer loop`s break did not stop inner loop
  }
  dec $outer;
  --echo $outer
}

# Break stops loop in if
let $cnt= 4;
if($cnt > 1)
{
  while($cnt)
  {
    break;
  }
  dec $cnt;
}

--echo cnt=$cnt

# Break in inner if

let $cnt= 4;
while($cnt > 1)
{
  if($cnt == 2)
  {
    break;
    --echo "if" is working after break
  }
  dec $cnt;
}

--echo cnt=$cnt

# Stray break

--error 1
--exec echo "break;" | $MYSQL_TEST 2>&1