summaryrefslogtreecommitdiff
path: root/storage/tokudb/mysql-test/tokudb/t/fast_update_varchar.test
blob: 66e5c977d1fc14e50ff90fdd2e8db56853b008ca (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
--source ../include/fast_update_gen_header.inc

--let GENERATED=$MYSQL_TMP_DIR/generated_fast_update_varchar.inc

--perl
  my $nrows = 100;
  open(FILE, '>', "$ENV{GENERATED}") or die;
  foreach my $t ('varchar', 'varbinary') {
    foreach my $l (32, 256) {
      foreach my $n ('null', 'not null') {
        test_varchar($t, $l, $n, $nrows)
      }
    }
  }
  close FILE;

  sub test_varchar {
    my $t = shift;
    my $l = shift;
    my $n = shift;
    my $nrows = shift;

    print FILE "create table tt (id bigint unsigned primary key,\n";
    print FILE "    f0 int $n,\n";
    foreach my $i (0..3) {
        print FILE "     v$i $t($l) $n,\n";
    }
    print FILE "     b0 text $n\n";
    print FILE ") engine=tokudb;\n";

    if ($n eq 'null') {
        print FILE "insert into tt (id) values (0);\n";
    }
    print FILE "insert into tt values (1, 2, 'a', 'b', 'c', 'd', 'e');\n";
    foreach my $i (2..($nrows - 1)) {
        print FILE "insert into tt values ($i, ".
                    ($i + 1).
                    ", '', '', '', '', '');\n";
    }

    print FILE "create table ti like tt;\n";
    print FILE "alter table ti engine=innodb;\n";
    print FILE "insert into ti select * from tt;\n";

    my @nulltest = ('null this', 'null is', 'null a', 'null test');
    foreach my $i (0..$#nulltest) {
      print FILE "update tt set v$i = '$nulltest[$i] $i' where id = 0;\n";
      print FILE "update ti set v$i = '$nulltest[$i] $i' where id = 0;\n";
    }

    my @test = ('this' ,'is', 'another', 'test');
    foreach my $i (0..$#test) {
      print FILE "update tt set v$i = '$test[$i] $i' where id = 1;\n";
      print FILE "update ti set v$i='$test[$i] $i' where id = 1;\n";
    }

    foreach my $id (2 .. ($nrows - 1)) {
      foreach my $i (0 .. 3) {
        my $long_str = rnd_str($l, ("A" .. "Z", 0 .. 9));
        print FILE "update tt set v$i='$long_str' where id=$id;\n";
        print FILE "update ti set v$i='$long_str' where id=$id;\n";
      }
    }

    print FILE 'let $diff_tables = test.tt, test.ti;'."\n";
    print FILE "source include/diff_tables.inc;\n";

    print FILE "drop table tt, ti;\n";
  }

  sub rnd_str { join '', @_[ map{ rand @_ } 1 .. shift ] }

EOF

--source ../include/fast_update_gen_footer_silent.inc