summaryrefslogtreecommitdiff
path: root/storage/tokudb/mysql-test/tokudb/t/fast_update_int.py
blob: f6414f0ec5b30d62168fd633fe17e29d61dddbb1 (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
#!/usr/bin/env python

import sys

def main():
    print "# generated by tokudb_fast_update_int.py"
    print "source include/have_tokudb.inc;"
    print "source include/have_innodb.inc;"
    print "set default_storage_engine='tokudb';"
    print "disable_warnings;"
    print "drop table if exists t;"
    print "enable_warnings;"

    for t in [ 'tinyint', 'smallint', 'mediumint', 'int', 'bigint' ]:
        for u in [ '', 'unsigned' ]:
            for n in [ 'null', 'not null' ]:
                test_int(t, u, n)
    return 0

def test_int(t, u, n):
    print "create table t ("
    print "    id %s %s %s primary key," % (t, u, n)
    print "    x %s %s %s" % (t, u, n)
    print ");"

    print "insert into t values (1,0),(2,0),(3,0);"
    print "select * from t;"

    print "set tokudb_disable_slow_update=1;"

    # set is fast
    print "update noar t set x=100 where id=2;"
    print "select * from t;"

    # increment is fast
    print "update noar t set x=x+1 where id=3;"
    print "select * from t;"

    # decrement is fast
    print "update noar t set x=x-1 where id=3;"
    print "select * from t;"

    # field=field+constant is fast
    print "update noar t set x=x+100 where id=3;"
    print "select * from t;"

    # field=field-constant is fast
    print "update noar t set x=x-100 where id=3;"
    print "select * from t;"

    # field=constant+field is not yet fast
    print "replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;"
    print "error ER_UNSUPPORTED_EXTENSION;"
    print "update noar t set x=1+x where id=1;"

    # field=-field is not yet fast
    print "replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;"
    print "error ER_UNSUPPORTED_EXTENSION;"
    print "update noar t set x=-x where id=1;"

    # yes, we can update a field in a non-existent row and the row is not inserted
    print "update noar t set x=x+1 where id=100;"
    print "select * from t;"

    # range updates are not yet fast
    print "replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;"
    print "error ER_UNSUPPORTED_EXTENSION;"
    print "update noar t set x=x+1 where 1 <= id and id < 100;"

    # full table updates are not yet fast
    print "replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;"
    print "error ER_UNSUPPORTED_EXTENSION;"
    print "update noar t set x=x+1;"

    print "drop table t;"

sys.exit(main())