~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/test08.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 not-found
 
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();
 
34
my $dbname = $hstest::conf{dbname};
 
35
$hs->open_index(1, $dbname, $table, '', 'k,v');
 
36
 
 
37
dump_rec($hs, 1, 'k5');      # found
 
38
dump_rec($hs, 1, 'k000000'); # notfound
 
39
 
 
40
sub dump_rec {
 
41
  my ($hs, $idxid, $key) = @_;
 
42
  my $r = $hs->execute_single($idxid, '=', [ $key ], 1, 0);
 
43
  for my $fld (@$r) {
 
44
    print "[$fld]";
 
45
  }
 
46
  print "\n";
 
47
}
 
48