Commit 67f0ce01 authored by Rich Prohaska's avatar Rich Prohaska

refs #5254 add fast update mysql tests

git-svn-id: file:///svn/mysql/tests/mysql-test@50365 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3c0eee62
set default_storage_engine='tokudb';
drop table if exists t;
create table t (id int primary key, b int, key(b));
set tokudb_enable_fast_update=1;
set tokudb_disable_slow_update=1;
update t set b=b+1 where id=42;
ERROR 42000: Table 't' uses an extension that doesn't exist in this MySQL version
drop table t;
set default_storage_engine='tokudb';
drop table if exists tt, ti;
set tokudb_enable_fast_update=1;
set tokudb_disable_slow_update=1;
create table tt (id int primary key, c char(32), b binary(32));
create table ti like tt;
alter table ti engine=innodb;
insert into tt values (1,null,null);
insert into ti values (1,null,null);
update tt set c='hi' where id=1;
update ti set c='hi' where id=1;
include/diff_tables.inc [test.tt, test.ti]
update tt set c='there' where id=1;
update ti set c='there' where id=1;
include/diff_tables.inc [test.tt, test.ti]
drop table tt, ti;
create table tt (id char(8) primary key, c char(32), b binary(32));
create table ti like tt;
alter table ti engine=innodb;
insert into tt values ('1',null,null);
insert into ti values ('1',null,null);
update tt set c='hi' where id='1';
update ti set c='hi' where id='1';
include/diff_tables.inc [test.tt, test.ti]
update tt set c='there' where id='1';
update ti set c='there' where id='1';
include/diff_tables.inc [test.tt, test.ti]
drop table tt, ti;
create table tt (id varchar(8) primary key, a int, b char(32), c char(32), d binary(32));
create table ti like tt;
alter table ti engine=innodb;
insert into tt values ('1',null,null,null,null);
insert into ti values ('1',null,null,null,null);
update tt set b='hi' where id='1';
update ti set b='hi' where id='1';
include/diff_tables.inc [test.tt, test.ti]
update tt set c='there' where id='1';
update ti set c='there' where id='1';
include/diff_tables.inc [test.tt, test.ti]
drop table tt, ti;
create table tt (id varchar(8) primary key, a int, b char(32), c char(32), d binary(32));
create table ti like tt;
alter table ti engine=innodb;
insert into tt values ('1',null,null,null,null);
insert into ti values ('1',null,null,null,null);
update tt set b='123' where id='1';
update ti set b='123' where id='1';
include/diff_tables.inc [test.tt, test.ti]
update tt set c=456 where id='1';
update ti set c=456 where id='1';
include/diff_tables.inc [test.tt, test.ti]
update tt set c=789 where id=1;
update ti set c=789 where id=1;
include/diff_tables.inc [test.tt, test.ti]
drop table tt, ti;
set default_storage_engine='tokudb';
drop table if exists tt;
set tokudb_enable_fast_update=1;
set tokudb_disable_slow_update=1;
create table tt (id int primary key, x int);
update tt set x=1 where id='abc';
ERROR 42000: Table 'tt' uses an extension that doesn't exist in this MySQL version
update tt set x='abc' where id=1;
ERROR 42000: Table 'tt' uses an extension that doesn't exist in this MySQL version
drop table tt;
set default_storage_engine='tokudb';
drop table if exists t;
create table tt (id int primary key, x int);
insert into tt values (1,0),(2,-pow(2,31)),(3,pow(2,31)-1);
create table ti like tt;
alter table ti engine=innodb;
insert into ti select * from tt;
set tokudb_enable_fast_update=1;
set tokudb_disable_slow_update=1;
update tt set x=x+1 where id=1;
update ti set x=x+1 where id=1;
include/diff_tables.inc [test.tt, test.ti]
update tt set x=x-2 where id=1;
update ti set x=x-2 where id=1;
include/diff_tables.inc [test.tt, test.ti]
update tt set x=x+1 where id=1;
update ti set x=x+1 where id=1;
include/diff_tables.inc [test.tt, test.ti]
update tt set x=x-1 where id=2;
update ti set x=x-1 where id=2;
Warnings:
Warning 1264 Out of range value for column 'x' at row 1
include/diff_tables.inc [test.tt, test.ti]
update tt set x=x+1 where id=2;
update ti set x=x+1 where id=2;
include/diff_tables.inc [test.tt, test.ti]
update tt set x=x+1 where id=3;
update ti set x=x+1 where id=3;
Warnings:
Warning 1264 Out of range value for column 'x' at row 1
include/diff_tables.inc [test.tt, test.ti]
update tt set x=x-1 where id=3;
update ti set x=x-1 where id=3;
include/diff_tables.inc [test.tt, test.ti]
insert into tt values (4,pow(2,31)-10);
insert into ti values (4,pow(2,31)-10);
update tt set x=x+20 where id=4;
update ti set x=x+20 where id=4;
Warnings:
Warning 1264 Out of range value for column 'x' at row 1
include/diff_tables.inc [test.tt, test.ti]
insert into tt values (5,pow(2,31)-10);
insert into ti values (5,pow(2,31)-10);
update tt set x=x - -20 where id=5;
update ti set x=x - -20 where id=5;
Warnings:
Warning 1264 Out of range value for column 'x' at row 1
include/diff_tables.inc [test.tt, test.ti]
insert into tt values (6,-pow(2,31)+10);
insert into ti values (6,-pow(2,31)+10);
update tt set x=x-20 where id=6;
update ti set x=x-20 where id=6;
Warnings:
Warning 1264 Out of range value for column 'x' at row 1
include/diff_tables.inc [test.tt, test.ti]
insert into tt values (7,-pow(2,31)+10);
insert into ti values (7,-pow(2,31)+10);
update tt set x=x + -20 where id=7;
update ti set x=x + -20 where id=7;
Warnings:
Warning 1264 Out of range value for column 'x' at row 1
include/diff_tables.inc [test.tt, test.ti]
drop table tt, ti;
set default_storage_engine='tokudb';
drop table if exists t;
set tokudb_enable_fast_update=1;
set tokudb_disable_slow_update=1;
create table t (id int primary key, x int not null);
insert into t values (1,0);
update t set x=42 where id=1;
update t set x=x+1 where id=1;
update t set x=x-1 where id=1;
set session sql_mode="NO_ENGINE_SUBSTITUTION,traditional";
update t set x=42 where id=1;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
update t set x=x+1 where id=1;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
update t set x=x-1 where id=1;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
set session sql_mode="NO_ENGINE_SUBSTITUTION";
drop table t;
set default_storage_engine='tokudb';
drop table if exists t;
create table tt (id int primary key, x int unsigned);
insert into tt values (1,0),(2,pow(2,32)-1);
create table ti like tt;
alter table ti engine=innodb;
insert into ti select * from tt;
set tokudb_enable_fast_update=1;
set tokudb_disable_slow_update=1;
update tt set x=x+1 where id=1;
update ti set x=x+1 where id=1;
include/diff_tables.inc [test.tt, test.ti]
update tt set x=x-2 where id=1;
update ti set x=if(x<2,0,x-2) where id=1;
include/diff_tables.inc [test.tt, test.ti]
update tt set x=x+1 where id=1;
update ti set x=x+1 where id=1;
include/diff_tables.inc [test.tt, test.ti]
update tt set x=x-1 where id=2;
update ti set x=x-1 where id=2;
include/diff_tables.inc [test.tt, test.ti]
update tt set x=x+1 where id=2;
update ti set x=x+1 where id=2;
include/diff_tables.inc [test.tt, test.ti]
insert into tt values (4,pow(2,32)-10);
insert into ti values (4,pow(2,32)-10);
update tt set x=x+20 where id=4;
update ti set x=x+20 where id=4;
Warnings:
Warning 1264 Out of range value for column 'x' at row 1
include/diff_tables.inc [test.tt, test.ti]
insert into tt values (5,10);
insert into ti values (5,10);
update tt set x=x-20 where id=5;
update ti set x=if(x<20,0,x-20) where id=5;
include/diff_tables.inc [test.tt, test.ti]
drop table tt, ti;
set default_storage_engine='tokudb';
drop table if exists t;
set tokudb_enable_fast_update=1;
set tokudb_disable_slow_update=1;
create table t (ida int not null, idb bigint not null, idc tinyint unsigned not null, x bigint);
update t set x=x+1 where ida=1;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
drop table t;
create table t (ida int not null, idb bigint not null, idc tinyint unsigned not null, x bigint, clustering key(ida,idb,idc));
update t set x=x+1 where ida=1;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
drop table t;
create table t (ida int not null, idb bigint not null, idc tinyint unsigned not null, x bigint, primary key(ida,idb,idc), key(x));
update t set x=x+1 where ida=1;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
drop table t;
create table t (ida int not null, idb bigint not null, idc tinyint unsigned not null, x bigint, primary key(ida,idb,idc));
insert into t values (1,2,3,0);
update t set x=x+1 where ida=1;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
update t set x=x+1 where ida=1 and idb=2;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
update t set x=x+1 where ida=1 and idb=2 or idc=3;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
update t set x=x+1 where ida=1 and idb=2 and idc=3;
select * from t;
ida idb idc x
1 2 3 1
update t set x=x+1 where idc=3 and ida=1 and idb=2;
select * from t;
ida idb idc x
1 2 3 2
drop table t;
set default_storage_engine='tokudb';
drop table if exists tt, ti;
set tokudb_enable_fast_upsert=1;
set tokudb_disable_slow_upsert=1;
create table tt (id int primary key, c char(32), b binary(32));
create table ti like tt;
alter table ti engine=innodb;
insert into tt values (1,null,null) on duplicate key update c='hi';
insert into ti values (1,null,null) on duplicate key update c='hi';
include/diff_tables.inc [test.tt, test.ti]
insert into tt values (1,null,null) on duplicate key update c='there';
insert into ti values (1,null,null) on duplicate key update c='there';
include/diff_tables.inc [test.tt, test.ti]
insert into tt values (1,null,null) on duplicate key update b='you';
insert into ti values (1,null,null) on duplicate key update b='you';
include/diff_tables.inc [test.tt, test.ti]
insert into tt values (1,null,null) on duplicate key update b='people';
insert into ti values (1,null,null) on duplicate key update b='people';
include/diff_tables.inc [test.tt, test.ti]
drop table tt, ti;
This diff is collapsed.
set default_storage_engine='tokudb';
drop table if exists t;
set tokudb_enable_fast_upsert=1;
set tokudb_disable_slow_upsert=1;
create table t (a int, b char(32), c varchar(32), d blob);
insert into t values (1,null,null,null) on duplicate key update a=42;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
drop table t;
create table t (id int primary key, a int, b char(32), c varchar(32), d blob, clustering key(a));
insert into t values (1,null,null,null,null) on duplicate key update a=42;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
drop table t;
create table t (id int primary key, a int, b char(32), c varchar(32), d blob, key(a));
insert into t values (1,null,null,null,null) on duplicate key update a=42;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
drop table t;
create table t (id int primary key, a int, b char(32), c varchar(32), d blob, key(b, a));
insert into t values (1,null,null,null,null) on duplicate key update a=42;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
drop table t;
set default_storage_engine='tokudb';
drop table if exists t;
set tokudb_enable_fast_upsert=1;
set tokudb_disable_slow_upsert=1;
create table t (id int primary key, x int not null);
insert into t values (1,0);
insert into t values (1,0) on duplicate key update x=42;
insert into t values (1,0) on duplicate key update x=x+1;
insert into t values (1,0) on duplicate key update x=x-1;
set session sql_mode="NO_ENGINE_SUBSTITUTION,traditional";
insert into t values (1,0) on duplicate key update x=42;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
insert into t values (1,0) on duplicate key update x=x+1;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
insert into t values (1,0) on duplicate key update x=x-1;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
set session sql_mode="NO_ENGINE_SUBSTITUTION";
drop table t;
# generate tests from test generator python programs
S = $(wildcard *.py)
T = $(patsubst %.py,%.test,$(S))
default: $(T)
%.test: %.py
python $< >$@
--source include/have_tokudb.inc
set default_storage_engine='tokudb';
--disable_warnings
drop table if exists t;
--enable_warnings
create table t (id int primary key, b int, key(b));
set tokudb_enable_fast_update=1;
set tokudb_disable_slow_update=1;
--error ER_UNSUPPORTED_EXTENSION
update t set b=b+1 where id=42;
drop table t;
# test that char field updates are fast
# test that char field primary keys are fast
source include/have_tokudb.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists tt, ti;
enable_warnings;
set tokudb_enable_fast_update=1;
set tokudb_disable_slow_update=1;
create table tt (id int primary key, c char(32), b binary(32));
create table ti like tt;
alter table ti engine=innodb;
insert into tt values (1,null,null);
insert into ti values (1,null,null);
update tt set c='hi' where id=1;
update ti set c='hi' where id=1;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set c='there' where id=1;
update ti set c='there' where id=1;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
drop table tt, ti;
create table tt (id char(8) primary key, c char(32), b binary(32));
create table ti like tt;
alter table ti engine=innodb;
insert into tt values ('1',null,null);
insert into ti values ('1',null,null);
update tt set c='hi' where id='1';
update ti set c='hi' where id='1';
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set c='there' where id='1';
update ti set c='there' where id='1';
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
drop table tt, ti;
create table tt (id varchar(8) primary key, a int, b char(32), c char(32), d binary(32));
create table ti like tt;
alter table ti engine=innodb;
insert into tt values ('1',null,null,null,null);
insert into ti values ('1',null,null,null,null);
update tt set b='hi' where id='1';
update ti set b='hi' where id='1';
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set c='there' where id='1';
update ti set c='there' where id='1';
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
drop table tt, ti;
create table tt (id varchar(8) primary key, a int, b char(32), c char(32), d binary(32));
create table ti like tt;
alter table ti engine=innodb;
insert into tt values ('1',null,null,null,null);
insert into ti values ('1',null,null,null,null);
update tt set b='123' where id='1';
update ti set b='123' where id='1';
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set c=456 where id='1';
update ti set c=456 where id='1';
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set c=789 where id=1;
update ti set c=789 where id=1;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
drop table tt, ti;
# test that char field updates are fast
# test that char field primary keys are fast
source include/have_tokudb.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists tt;
enable_warnings;
set tokudb_enable_fast_update=1;
set tokudb_disable_slow_update=1;
create table tt (id int primary key, x int);
error ER_UNSUPPORTED_EXTENSION;
update tt set x=1 where id='abc';
error ER_UNSUPPORTED_EXTENSION;
update tt set x='abc' where id=1;
drop table tt;
#!/usr/bin/env python
import sys
def main():
print "# generated by tokudb_fast_update_int.py"
print "source include/have_tokudb.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_enable_fast_update=1;"
print "set tokudb_disable_slow_update=1;"
# set is fast
print "update t set x=100 where id=2;"
print "select * from t;"
# increment is fast
print "update t set x=x+1 where id=3;"
print "select * from t;"
# decrement is fast
print "update t set x=x-1 where id=3;"
print "select * from t;"
# field=field+constant is fast
print "update t set x=x+100 where id=3;"
print "select * from t;"
# field=field-constant is fast
print "update 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 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 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 t set x=x+1 where id=1000000;"
print "select * from t;"
# range updates are not yet fast
print "replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;"
print "error ER_UNSUPPORTED_EXTENSION;"
print "update t set x=x+1 where 1 <= id and id < 1000;"
# full table updates are not yet fast
print "replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;"
print "error ER_UNSUPPORTED_EXTENSION;"
print "update t set x=x+1;"
print "drop table t;"
sys.exit(main())
--source include/have_tokudb.inc
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t;
enable_warnings;
create table tt (id int primary key, x int);
insert into tt values (1,0),(2,-pow(2,31)),(3,pow(2,31)-1);
create table ti like tt;
alter table ti engine=innodb;
insert into ti select * from tt;
set tokudb_enable_fast_update=1;
set tokudb_disable_slow_update=1;
update tt set x=x+1 where id=1;
update ti set x=x+1 where id=1;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set x=x-2 where id=1;
update ti set x=x-2 where id=1;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set x=x+1 where id=1;
update ti set x=x+1 where id=1;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set x=x-1 where id=2;
update ti set x=x-1 where id=2;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set x=x+1 where id=2;
update ti set x=x+1 where id=2;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set x=x+1 where id=3;
update ti set x=x+1 where id=3;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set x=x-1 where id=3;
update ti set x=x-1 where id=3;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
# test clip at maximum
insert into tt values (4,pow(2,31)-10);
insert into ti values (4,pow(2,31)-10);
update tt set x=x+20 where id=4;
update ti set x=x+20 where id=4;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
insert into tt values (5,pow(2,31)-10);
insert into ti values (5,pow(2,31)-10);
update tt set x=x - -20 where id=5;
update ti set x=x - -20 where id=5;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
# test clip at minimum
insert into tt values (6,-pow(2,31)+10);
insert into ti values (6,-pow(2,31)+10);
update tt set x=x-20 where id=6;
update ti set x=x-20 where id=6;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
insert into tt values (7,-pow(2,31)+10);
insert into ti values (7,-pow(2,31)+10);
update tt set x=x + -20 where id=7;
update ti set x=x + -20 where id=7;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
drop table tt, ti;
source include/have_tokudb.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t;
enable_warnings;
set tokudb_enable_fast_update=1;
set tokudb_disable_slow_update=1;
let $default_sql_mode = `select @@session.sql_mode`;
create table t (id int primary key, x int not null);
insert into t values (1,0);
update t set x=42 where id=1;
update t set x=x+1 where id=1;
update t set x=x-1 where id=1;
eval set session sql_mode="$default_sql_mode,traditional";
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
update t set x=42 where id=1;
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
update t set x=x+1 where id=1;
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
update t set x=x-1 where id=1;
eval set session sql_mode="$default_sql_mode";
drop table t;
--source include/have_tokudb.inc
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t;
enable_warnings;
create table tt (id int primary key, x int unsigned);
insert into tt values (1,0),(2,pow(2,32)-1);
create table ti like tt;
alter table ti engine=innodb;
insert into ti select * from tt;
set tokudb_enable_fast_update=1;
set tokudb_disable_slow_update=1;
update tt set x=x+1 where id=1;
update ti set x=x+1 where id=1;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set x=x-2 where id=1;
update ti set x=if(x<2,0,x-2) where id=1;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set x=x+1 where id=1;
update ti set x=x+1 where id=1;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set x=x-1 where id=2;
update ti set x=x-1 where id=2;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
update tt set x=x+1 where id=2;
update ti set x=x+1 where id=2;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
# test clip at maximum
insert into tt values (4,pow(2,32)-10);
insert into ti values (4,pow(2,32)-10);
update tt set x=x+20 where id=4;
update ti set x=x+20 where id=4;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
# test clip at minimum
insert into tt values (5,10);
insert into ti values (5,10);
update tt set x=x-20 where id=5;
update ti set x=if(x<20,0,x-20) where id=5;
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
drop table tt, ti;
#!/usr/bin/env python
import sys
def main():
print "# generated by tokudb_update_decr_floor.py"
print "source include/have_tokudb.inc;"
print "set default_storage_engine='tokudb';"
print "disable_warnings;"
print "drop table if exists t;"
print "enable_warnings;"
print "set tokudb_enable_fast_update=1;"
print "set tokudb_disable_slow_update=1;"
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 tt ("
print " id %s %s %s primary key," % (t, u, n)
print " x %s %s %s" % (t, u, n)
print ");"
print "insert into tt values (1,4);"
print "create table ti like tt;"
print "alter table ti engine=innodb;"
print "insert into ti select * from tt;"
if u == 'unsigned':
print "update tt set x=if(x=0,0,x-1) where id=1;"
print "update ti set x=if(x=0,0,x-1) where id=1;"
print "update tt set x=if(x=0,0,x-1) where id=1;"
print "update ti set x=if(x=0,0,x-1) where id=1;"
print "update tt set x=if(x=0,0,x-1) where id=1;"
print "update ti set x=if(x=0,0,x-1) where id=1;"
print "update tt set x=if(x=0,0,x-1) where id=1;"
print "update ti set x=if(x=0,0,x-1) where id=1;"
print "# try to decrement when x=0"
print "update tt set x=if(x=0,0,x-1) where id=1;"
print "update ti set x=if(x=0,0,x-1) where id=1;"
print "let $diff_tables = test.tt, test.ti;"
print "source include/diff_tables.inc;"
else:
print "replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;"
print "error ER_UNSUPPORTED_EXTENSION;"
print "update tt set x=if(x=0,0,x-1) where id=1;"
print "drop table tt, ti;"
sys.exit(main())
source include/have_tokudb.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t;
enable_warnings;
set tokudb_enable_fast_update=1;
set tokudb_disable_slow_update=1;
# must have primary key
create table t (ida int not null, idb bigint not null, idc tinyint unsigned not null, x bigint);
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
update t set x=x+1 where ida=1;
drop table t;
# must have no clustering keys
create table t (ida int not null, idb bigint not null, idc tinyint unsigned not null, x bigint, clustering key(ida,idb,idc));
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
update t set x=x+1 where ida=1;
drop table t;
# update field must not be part of any key
create table t (ida int not null, idb bigint not null, idc tinyint unsigned not null, x bigint, primary key(ida,idb,idc), key(x));
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
update t set x=x+1 where ida=1;
drop table t;
# test for point updates on compound keys
create table t (ida int not null, idb bigint not null, idc tinyint unsigned not null, x bigint, primary key(ida,idb,idc));
insert into t values (1,2,3,0);
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
update t set x=x+1 where ida=1;
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
update t set x=x+1 where ida=1 and idb=2;
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
update t set x=x+1 where ida=1 and idb=2 or idc=3;
update t set x=x+1 where ida=1 and idb=2 and idc=3;
select * from t;
update t set x=x+1 where idc=3 and ida=1 and idb=2;
select * from t;
drop table t;
source include/have_tokudb.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t0, t1;
enable_warnings;
set tokudb_enable_fast_upsert=1;
set tokudb_disable_slow_upsert=1;
create table t0 (id int primary key, b binary(32));
create table t1 like t0;
insert into t0 values (1,'hi'),(2,'there');
select * from t0;
insert into t1 values (1,null),(2,null);
insert into t1 values (1,null) on duplicate key update b='hi';
insert into t1 values (2,null) on duplicate key update b='there';
select * from t1;
let $diff_tables = test.t0, test.t1;
source include/diff_tables.inc;
drop table t0, t1;
source include/have_tokudb.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists tt, ti;
enable_warnings;
set tokudb_enable_fast_upsert=1;
set tokudb_disable_slow_upsert=1;
create table tt (id int primary key, c char(32), b binary(32));
create table ti like tt;
alter table ti engine=innodb;
insert into tt values (1,null,null) on duplicate key update c='hi';
insert into ti values (1,null,null) on duplicate key update c='hi';
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
insert into tt values (1,null,null) on duplicate key update c='there';
insert into ti values (1,null,null) on duplicate key update c='there';
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
insert into tt values (1,null,null) on duplicate key update b='you';
insert into ti values (1,null,null) on duplicate key update b='you';
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
insert into tt values (1,null,null) on duplicate key update b='people';
insert into ti values (1,null,null) on duplicate key update b='people';
let $diff_tables = test.tt, test.ti;
source include/diff_tables.inc;
drop table tt, ti;
#!/usr/bin/env python
import sys
def main():
print "# generated by tokudb_upsert_int.py"
print "source include/have_tokudb.inc;"
print "set default_storage_engine='tokudb';"
print "disable_warnings;"
print "drop table if exists tt, ti;"
print "enable_warnings;"
print "set tokudb_enable_fast_update=1;"
print "set tokudb_disable_slow_update=1;"
for t in [ 'tinyint', 'smallint', 'mediumint', 'int', 'bigint' ]:
for u in [ '', 'unsigned' ]:
for n in [ 'null', 'not null' ]:
test_upsert_int(t, u, n)
return 0
def test_upsert_int(t, u, n):
print "create table tt ("
print " id %s %s %s primary key," % (t, u, n)
if n == 'not null': n += ' default 0'
print " x %s %s %s," % (t, u, n)
print " y %s %s %s," % (t, u, n)
print " z %s %s %s," % (t, u, n)
print " a char(32), aa varchar(32)"
print ");"
print "insert into tt (id) values (1),(2),(3) on duplicate key update x=0;"
print "insert into tt (id) values (1) on duplicate key update y=0,z=42;"
print "insert into tt (id) values (1) on duplicate key update y=y+1,z=z+100;"
print "insert into tt (id) values (1) on duplicate key update y=y-1;"
print "insert into tt (id) values (1) on duplicate key update z=z-100;"
print "create table ti like tt;"
print "alter table ti engine=innodb;"
print "insert into ti (id) values (1),(2),(3) on duplicate key update x=0;"
print "insert into ti (id) values (1) on duplicate key update y=0,z=42;"
print "insert into ti (id) values (1) on duplicate key update y=y+1,z=z+100;"
print "insert into ti (id) values (1) on duplicate key update y=y-1;"
print "insert into ti (id) values (1) on duplicate key update z=z-100;"
print "let $diff_tables = test.tt, test.ti;"
print "source include/diff_tables.inc;"
print "drop table tt, ti;"
sys.exit(main())
This diff is collapsed.
source include/have_tokudb.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t;
enable_warnings;
set tokudb_enable_fast_upsert=1;
set tokudb_disable_slow_upsert=1;
# must have primary key
create table t (a int, b char(32), c varchar(32), d blob);
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
insert into t values (1,null,null,null) on duplicate key update a=42;
drop table t;
# must have no clustering keys
create table t (id int primary key, a int, b char(32), c varchar(32), d blob, clustering key(a));
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
insert into t values (1,null,null,null,null) on duplicate key update a=42;
drop table t;
# update field must not be part of any key
create table t (id int primary key, a int, b char(32), c varchar(32), d blob, key(a));
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
insert into t values (1,null,null,null,null) on duplicate key update a=42;
drop table t;
create table t (id int primary key, a int, b char(32), c varchar(32), d blob, key(b, a));
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
insert into t values (1,null,null,null,null) on duplicate key update a=42;
drop table t;
source include/have_tokudb.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t;
enable_warnings;
set tokudb_enable_fast_upsert=1;
set tokudb_disable_slow_upsert=1;
let $default_sql_mode = `select @@session.sql_mode`;
create table t (id int primary key, x int not null);
insert into t values (1,0);
insert into t values (1,0) on duplicate key update x=42;
insert into t values (1,0) on duplicate key update x=x+1;
insert into t values (1,0) on duplicate key update x=x-1;
eval set session sql_mode="$default_sql_mode,traditional";
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
insert into t values (1,0) on duplicate key update x=42;
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
insert into t values (1,0) on duplicate key update x=x+1;
replace_regex /MariaDB/XYZ/ /MySQL/XYZ/;
error ER_UNSUPPORTED_EXTENSION;
insert into t values (1,0) on duplicate key update x=x-1;
eval set session sql_mode="$default_sql_mode";
drop table t;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment