File: multi_pk.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (76 lines) | stat: -rw-r--r-- 2,426 bytes parent folder | download
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
# WL#6745 InnoDB R-tree support
# This test case will test R-tree split.

--source include/have_debug.inc
--source include/big_test.inc
--source include/not_valgrind.inc

# Create table with R-tree index.
create table t1 (c1 int, c2 varchar(255), c3 geometry not null SRID 0, primary key(c1, c2), spatial index (c3))engine=innodb charset latin1;

# Insert enough values to let R-tree split.
delimiter |;

create function rand_string(str_length tinyint unsigned, str_type tinyint unsigned) returns varchar(255) charset latin1
begin
    declare counter int unsigned default 0;
    declare const_chars varchar(64) charset latin1 default '0123456789';
    declare result varchar(255) charset latin1 default '';

    if str_type = 1 then
        set const_chars = '0123456789';
    elseif str_type = 2 then
        set const_chars = 'abcdefghijklmnopqrstuvwxyz';
    elseif str_type = 3 then
        set const_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    elseif str_type = 4 then
        set const_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    elseif str_type = 5 then
        set const_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    else
        set const_chars = '0123456789';
    end if;

    while counter < str_length do
        set result = concat(result,substr(const_chars,ceil(rand()*(length(const_chars)-1)),1));
    set counter = counter + 1;
    end while;

    return result;
end|

create procedure insert_t1(IN total int)
begin
        declare i int default 1;
        declare i2 int default 1;
        declare str varchar(100) charset latin1 default '';
        declare dup_key int default 1;
        while i <= total DO
                set i2 = floor(0+(rand()*100));
                set str = rand_string(i2, 5);
                select count(*) into dup_key from t1 where c2 = str and c1 = i;
                while dup_key <> 0 do
                    set i2 = floor(0+(rand()*100));
                    set str = rand_string(i2, 5);
                    select count(*) into dup_key from t1 where c2 = str and c1 = i;
                end while;
                insert into t1 values (i, str, Point(i, i));
                set i = i + 1;
        end while;
end|

delimiter ;|

CALL insert_t1(10000);
check table t1;

start transaction;
CALL insert_t1(30000);
rollback;
check table t1;

# Clean up.
drop procedure insert_t1;
drop function rand_string;
drop table t1;