~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/test03.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 binary cleanness (#1)
 
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 = 256;
 
18
$dbh->do(
 
19
  "create table $table (k varchar(30) primary key, v varchar(30) not null) " .
 
20
  "engine = innodb default charset = binary");
 
21
srand(999);
 
22
 
 
23
my %valmap = ();
 
24
 
 
25
print "WR\n";
 
26
my $sth = $dbh->prepare("insert into $table values (?,?)");
 
27
for (my $i = 0; $i < $tablesize; ++$i) {
 
28
  my $k = "" . $i;
 
29
  my $v = pack("C", $i);
 
30
  my $vnum = unpack("C", $v);
 
31
  print "$k $vnum\n";
 
32
  $sth->execute($k, $v);
 
33
  $valmap{$k} = $v;
 
34
}
 
35
 
 
36
my $hs = hstest::get_hs_connection();
 
37
my $dbname = $hstest::conf{dbname};
 
38
$hs->open_index(1, $dbname, $table, '', 'k,v');
 
39
my $r = $hs->execute_single(1, '>=', [ '' ], 10000, 0);
 
40
shift(@$r);
 
41
print "HS\n";
 
42
for (my $i = 0; $i < $tablesize; ++$i) {
 
43
  my $k = $r->[$i * 2];
 
44
  my $v = $r->[$i * 2 + 1];
 
45
  my $vnum = unpack("C", $v);
 
46
  print "$k $vnum\n";
 
47
  print "MISMATCH\n" if ($k ne $vnum);
 
48
  print "LEN\n" if (length($v) != 1);
 
49
}
 
50
undef $hs;
 
51
 
 
52
print "MY\n";
 
53
my $aref = $dbh->selectall_arrayref("select k,v from $table order by k");
 
54
for my $row (@$aref) {
 
55
  my ($k, $v) = @$row;
 
56
  my $vnum = unpack("C", $v);
 
57
  print "$k $vnum\n";
 
58
  print "MISMATCH\n" if ($k ne $vnum);
 
59
  print "LEN\n" if (length($v) != 1);
 
60
}
 
61