~percona-dev/percona-server/5.1-kill_idle_transaction-innodb_fake_changes

« back to all changes in this revision

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

  • Committer: Aleksandr Kuzminsky
  • Date: 2010-11-24 08:58:24 UTC
  • mto: This revision was merged to the branch mainline in revision 155.
  • Revision ID: aleksandr.kuzminsky@percona.com-20101124085824-9742ytdt2x50djw3
Added HandlerSocket-Plugin-for-MySQL sources

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 multiple modify requests
 
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 = "v" . int(rand(1000)) . $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
 
 
37
exec_multi(
 
38
  "DEL",
 
39
  [ 1, '=', [ 'k5' ], 1, 0, 'D' ],
 
40
  [ 1, '>=', [ 'k5' ], 2, 0 ],
 
41
);
 
42
exec_multi(
 
43
  "DELINS",
 
44
  [ 1, '>=', [ 'k6' ], 3, 0 ],
 
45
  [ 1, '=', [ 'k60' ], 1, 0, 'D' ],
 
46
  [ 1, '+', [ 'k60', 'INS' ] ],
 
47
  [ 1, '>=', [ 'k6' ], 3, 0 ],
 
48
);
 
49
exec_multi(
 
50
  "DELUPUP",
 
51
  [ 1, '>=', [ 'k7' ], 3, 0 ],
 
52
  [ 1, '=', [ 'k70' ], 1, 0, 'U', [ 'k70', 'UP' ] ],
 
53
  [ 1, '>=', [ 'k7' ], 3, 0 ],
 
54
);
 
55
 
 
56
sub exec_multi {
 
57
  my $mess = shift(@_);
 
58
  print "$mess\n";
 
59
  my $mres = $hs->execute_multi(\@_);
 
60
  for my $res (@$mres) {
 
61
    for my $fld (@$res) {
 
62
      print "[$fld]";
 
63
    }
 
64
    print "\n";
 
65
  }
 
66
}
 
67