~percona-dev/percona-server/release-5.5.11-20.2-fix-bug-764138

« back to all changes in this revision

Viewing changes to HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test11.pl

  • Committer: Ignacio Nin
  • Date: 2011-03-13 17:18:23 UTC
  • mfrom: (33.3.17 release-5.5.8-20)
  • Revision ID: ignacio.nin@percona.com-20110313171823-m06xs104nekulywb
Merge changes from release-5.5.8-20 to 5.5.9

Merge changes from the release branch of 5.5.8 to 5.5.9. These include
the HandlerSocket and UDF directories and the building scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
# vim:sw=2:ai
 
4
 
 
5
# test for increment/decrement
 
6
 
 
7
BEGIN {
 
8
        push @INC, "../common/";
 
9
};
 
10
 
 
11
use strict;
 
12
use warnings;
 
13
use hstest;
 
14
 
 
15
my $dbh = hstest::init_testdb();
 
16
my $table = 'hstesttbl';
 
17
my $tablesize = 100;
 
18
$dbh->do(
 
19
  "create table $table (k varchar(30) primary key, v varchar(30) not null) " .
 
20
  "engine = innodb");
 
21
srand(999);
 
22
 
 
23
my %valmap = ();
 
24
 
 
25
my $sth = $dbh->prepare("insert into $table values (?,?)");
 
26
for (my $i = 0; $i < $tablesize; ++$i) {
 
27
  my $k = "k" . $i;
 
28
  my $v = $i;
 
29
  $sth->execute($k, $v);
 
30
  $valmap{$k} = $v;
 
31
}
 
32
 
 
33
my $hs = hstest::get_hs_connection(undef, 9999);
 
34
my $dbname = $hstest::conf{dbname};
 
35
$hs->open_index(1, $dbname, $table, '', 'k,v');
 
36
$hs->open_index(2, $dbname, $table, '', 'v');
 
37
 
 
38
exec_multi(
 
39
  "VAL",
 
40
  [ 1, '=', [ 'k5' ], 1, 0 ],
 
41
  [ 1, '=', [ 'k6' ], 1, 0 ],
 
42
  [ 1, '=', [ 'k7' ], 1, 0 ],
 
43
  [ 1, '=', [ 'k8' ], 1, 0 ],
 
44
);
 
45
# 5, 6, 7, 8
 
46
 
 
47
exec_multi(
 
48
  "INCREMENT",
 
49
  [ 2, '=', [ 'k5' ], 1, 0, '+', [ 3 ] ],
 
50
  [ 2, '=', [ 'k6' ], 1, 0, '+', [ 12 ] ],
 
51
  [ 2, '=', [ 'k7' ], 1, 0, '+', [ -11 ] ],
 
52
  [ 2, '=', [ 'k8' ], 1, 0, '+', [ -15 ] ],
 
53
);
 
54
 
 
55
exec_multi(
 
56
  "VAL",
 
57
  [ 1, '=', [ 'k5' ], 1, 0 ],
 
58
  [ 1, '=', [ 'k6' ], 1, 0 ],
 
59
  [ 1, '=', [ 'k7' ], 1, 0 ],
 
60
  [ 1, '=', [ 'k8' ], 1, 0 ],
 
61
);
 
62
# 8, 18, -4, -7
 
63
 
 
64
exec_multi(
 
65
  "DECREMENT",
 
66
  [ 2, '=', [ 'k5' ], 1, 0, '-', [ 2 ] ],
 
67
  [ 2, '=', [ 'k6' ], 1, 0, '-', [ 24 ] ],
 
68
  [ 2, '=', [ 'k7' ], 1, 0, '-', [ 80 ] ],
 
69
  [ 2, '=', [ 'k8' ], 1, 0, '-', [ -80 ] ],
 
70
);
 
71
# mod, no, mod, no
 
72
 
 
73
exec_multi(
 
74
  "VAL",
 
75
  [ 1, '=', [ 'k5' ], 1, 0 ],
 
76
  [ 1, '=', [ 'k6' ], 1, 0 ],
 
77
  [ 1, '=', [ 'k7' ], 1, 0 ],
 
78
  [ 1, '=', [ 'k8' ], 1, 0 ],
 
79
);
 
80
# 6, 18, -84, -7
 
81
 
 
82
exec_multi(
 
83
  "INCREMENT",
 
84
  [ 2, '=', [ 'k5' ], 1, 0, '+?', [ 1 ] ],
 
85
  [ 2, '=', [ 'k5' ], 1, 0, '+?', [ 1 ] ],
 
86
  [ 2, '=', [ 'k5' ], 1, 0, '+?', [ 1 ] ],
 
87
  [ 2, '=', [ 'k5' ], 1, 0, '+?', [ 1 ] ],
 
88
  [ 2, '=', [ 'k5' ], 1, 0, '+?', [ 1 ] ],
 
89
  [ 2, '=', [ 'k5' ], 1, 0, '+?', [ 1 ] ],
 
90
  [ 2, '=', [ 'k5' ], 1, 0, '+?', [ 1 ] ],
 
91
  [ 2, '=', [ 'k5' ], 1, 0, '+?', [ 1 ] ],
 
92
  [ 2, '=', [ 'k5' ], 1, 0, '+?', [ 1 ] ],
 
93
);
 
94
 
 
95
exec_multi(
 
96
  "VAL",
 
97
  [ 1, '=', [ 'k5' ], 1, 0 ],
 
98
);
 
99
# 15
 
100
 
 
101
sub exec_multi {
 
102
  my $mess = shift(@_);
 
103
  print "$mess\n";
 
104
  my $mres = $hs->execute_multi(\@_);
 
105
  for my $res (@$mres) {
 
106
    for my $fld (@$res) {
 
107
      print "[$fld]";
 
108
    }
 
109
    print "\n";
 
110
  }
 
111
}
 
112