summaryrefslogtreecommitdiff
path: root/storage/tokudb/mysql-test/tokudb/t/fast_update_blobs_with_varchar.test
blob: 15875c4729750be43f6609b76a004a2db879f3ac (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
76
77
78
79
80
81
82
83
84
--source ../include/fast_update_gen_header.inc

--let GENERATED=$MYSQL_TMP_DIR/generated_fast_update_blobs_with_varchar.inc

--perl

  my $nrows = 10;
  open(FILE, '>', "$ENV{GENERATED}") or die;
  my @blob_types = ('tinyblob', 'blob', 'mediumblob', 'longblob');
  foreach my $i (0, 1) {
    foreach my $a (@blob_types) {
      foreach my $b (@blob_types) {
        foreach my $c (@blob_types) {
          foreach my $n ('null', 'not null') {
            foreach my $v ('varchar(32)', 'varchar(256)') {
              test_blobs([$a, $b, $c], $v, $n, $i, $nrows);
            }
          }
        }
      }
    }
  }
  close FILE;

  sub test_blobs {
    my $cols = shift;
    my $v = shift;
    my $n = shift;
    my $need_fixed_int = shift;
    my $nrows = shift;

    print FILE "create table tt (id bigint unsigned primary key,\n";
    print FILE "    f0 int $n,\n" if ($need_fixed_int);
    print FILE "    v0 $v $n,\n";
    foreach my $i (0 .. $#{$cols}) {
      if ($i < $#{$cols}) {
        print FILE "    b$i $cols->[$i] $n,\n";
      }
      else {
        print FILE "    b$i $cols->[$i] $n\n";
      }
    }
    print FILE ") engine=tokudb;\n";

    foreach my $id (1 .. ($nrows - 1)) {
      if ($n eq 'null') {
        print FILE "insert into tt (id) values ($id);\n";
      }
      else {
        if ($need_fixed_int) {
          print FILE "insert into tt values ($id, 0, '', '', '', '');\n";
        }
        else {
          print FILE "insert into tt values ($id, '', '', '', '');\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";

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

        $long_str = rnd_str((rand(32) + 1), ("A" .. "Z", 0 .. 9));
        print FILE "update tt set b$i='$long_str' where id=$id;\n";
        print FILE "update ti set b$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