INSERT INTO `t1` VALUES ('bla',1000),('bla',1001),('bla',1002);
check table t1;
unlock tables;
#
# Check that an empty table uses fast recreate of index when we fill it
# with insert ... select.
create table t2 like t1;
insert into t2 select * from t1;
# This should say that the table is already up to date
analyze table t2;
delete from t2;
insert into t2 select * from t1;
analyze table t2;
drop table t1,t2;
#
# Test when expanding a row so that it doesn't fit into the same page
#
create table t1 (a bigint auto_increment, primary key(a), b char(255), c varchar(20000));
let $1=1000;
--disable_query_log
--disable_warnings
while ($1)
{
insert into t1 () values();
dec $1;
}
--enable_query_log
update t1 set b=repeat('a',100) where a between 1 and 100;
check table t1;
update t1 set c=repeat('a',8192*2) where a between 200 and 202;
check table t1;
drop table t1;
#
# Test where we shrink varchar
#
CREATE TABLE t1 (a int, b int, v varchar(60000)) checksum=1 engine=maria;
insert into t1 values (1,1,"aaa"),(1,2,null);
checksum table t1;
lock table t1 write;
insert into t1 values (1,3,repeat('c',30000)),(4,4,repeat('a',30000));
update t1 set v="row5" where b=4;
delete from t1 where b=3;
select a, b, length(v) from t1;
drop table t1;
#
# Test tail pages for blobs
#
CREATE TABLE t1 (
auto int(5) unsigned NOT NULL auto_increment,
string char(10) default "hello",
tiny tinyint(4) DEFAULT '0' NOT NULL ,
short smallint(6) DEFAULT '1' NOT NULL ,
medium mediumint(8) DEFAULT '0' NOT NULL,
long_int int(11) DEFAULT '0' NOT NULL,
longlong bigint(13) DEFAULT '0' NOT NULL,
real_float float(13,1) DEFAULT 0.0 NOT NULL,
real_double double(16,4),
utiny tinyint(3) unsigned DEFAULT '0' NOT NULL,
ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL,
umedium mediumint(8) unsigned DEFAULT '0' NOT NULL,
ulong int(11) unsigned DEFAULT '0' NOT NULL,
ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL,
time_stamp timestamp,
date_field date,
time_field time,
date_time datetime,
blob_col blob,
tinyblob_col tinyblob,
mediumblob_col mediumblob not null default '',
longblob_col longblob not null default '',
options enum('one','two','tree') not null ,
flags set('one','two','tree') not null default '',
PRIMARY KEY (auto),
KEY (utiny),
KEY (tiny),
KEY (short),
KEY any_name (medium),
KEY (longlong),
KEY (real_float),
KEY (ushort),
KEY (umedium),
KEY (ulong),
KEY (ulonglong,ulong),
KEY (options,flags)
) engine=maria;
insert into t1 values (10,1,1,1,1,1,1,1,1,1,1,1,1,1,NULL,0,0,0,1,1,1,1,'one','one');
create table t2 (primary key (auto)) engine=maria row_format=page select auto+1 as auto,1 as t1, 'a' as t2, repeat('a',256) as t3, binary repeat('b',256) as t4, repeat('a',4096) as t5, binary repeat('b',4096) as t6, '' as t7, binary '' as t8 from t1;
check table t1,t2;
select t1,t2,length(t3),length(t4),length(t5),length(t6),t7,t8 from t2;
drop table t2;
create table t2 (primary key (auto)) engine=maria row_format=dynamic select auto+1 as auto,1 as t1, 'a' as t2, repeat('a',256) as t3, binary repeat('b',256) as t4, repeat('a',4096) as t5, binary repeat('b',4096) as t6, '' as t7, binary '' as t8 from t1;
check table t2;
drop table t1,t2;
# Test UPDATE with small BLOB which fits on head page
select lower(variable_name) as Variable_name, Variable_value as Value from information_schema.session_variables where variable_name like "maria%" and variable_name not like "maria_used_for_temp_tables" order by 1;
# Test delete of all rows in autocommit and not autocommit
#
create table t1 (a int not null);
lock tables t1 write;
insert into t1 values (1),(2);
delete from t1;
unlock tables;
select * from t1;
insert into t1 values (1),(2);
delete from t1;
select * from t1;
drop table t1;
# Test for bug "ha_enable_transaction(on) not called by CREATE TABLE"
# (originally from type_ranges.test)
create table t1 (c int);
insert into t1 values(1),(2);
create table t2 select * from t1;
--error 1060
create table t3 select * from t1, t2; # Should give an error
create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2;
drop table t1, t2, t3;
# Test for bug "maria_repair() (OPTIMIZE) leaves wrong
# data_file_length" (originally from type_datetime.test)
create table t1 (t datetime) engine=maria;
insert into t1 values (101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959),(20030100000000),(20030000000000);
select * from t1;
optimize table t1;
check table t1;
delete from t1 where t > 0;
optimize table t1;
check table t1;
drop table t1;
#
# Test auto-increment
#
SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
CREATE TABLE t1 (id int(11) PRIMARY KEY auto_increment,f1 varchar(10) NOT NULL UNIQUE);
INSERT IGNORE INTO t1 (f1) VALUES ("test1");
INSERT IGNORE INTO t1 (f1) VALUES ("test1");
INSERT IGNORE INTO t1 (f1) VALUES ("test2");
SELECT * FROM t1;
drop table t1;
SET SQL_MODE = 'TRADITIONAL';
create table t1 (n int not null primary key auto_increment, c char(1), unique(c));
insert into t1 values(100, "a");
insert into t1 values(300, "b");
--error 1062
insert into t1 values(50, "a");
insert into t1 values(null, "c");
select * from t1;
--error 1062
update t1 set n=400,c='a' where n=301;
insert into t1 values(null, "d");
select * from t1;
drop table t1;
create table t1 (n int not null primary key auto_increment, c char(1), unique(c)) transactional=0 row_format=dynamic;
insert into t1 values(100, "a");
insert into t1 values(300, "b");
--error 1062
insert into t1 values(50, "a");
insert into t1 values(null, "c");
select * from t1;
--error 1062
update t1 set n=400,c='a' where n=301;
insert into t1 values(null, "d");
select * from t1;
drop table t1;
#
# Test warnings with transactional=1 with MyISAM
#
create table t1 (n int not null, c char(1)) engine=maria;
alter table t1 engine=myisam;
alter table t1 engine=maria;
show create table t1;
drop table t1;
create table t1 (n int not null, c char(1)) engine=maria transactional=1;
alter table t1 engine=myisam;
alter table t1 engine=maria;
show create table t1;
drop table t1;
create table t1 (n int not null, c char(1)) engine=myisam transactional=1;
alter table t1 engine=maria;
show create table t1;
drop table t1;
#
# Some tests that have failed with transactional=0
#
# Testing buik insert
create table t1 (a int, key(a)) transactional=0;
insert into t1 values (0),(1),(2),(3),(4);
insert into t1 select NULL from t1;
check table t1;
drop table t1;
#
# Some tests with temporary tables
#
create temporary table t1 (a int, key(a)) transactional=1;
create temporary table t2 (a int, key(a)) transactional=1;