2000-12-28 02:56:38 +01:00
|
|
|
#
|
|
|
|
# test of MERGE TABLES
|
|
|
|
#
|
|
|
|
|
2003-01-06 00:48:59 +01:00
|
|
|
--disable_warnings
|
2001-09-27 20:45:48 +02:00
|
|
|
drop table if exists t1,t2,t3,t4,t5,t6;
|
2003-06-27 15:29:10 +02:00
|
|
|
drop database if exists mysqltest;
|
2003-01-06 00:48:59 +01:00
|
|
|
--enable_warnings
|
|
|
|
|
2000-12-28 02:56:38 +01:00
|
|
|
create table t1 (a int not null primary key auto_increment, message char(20));
|
|
|
|
create table t2 (a int not null primary key auto_increment, message char(20));
|
|
|
|
INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1");
|
|
|
|
INSERT INTO t2 (message) VALUES ("Testing"),("table"),("t2");
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t3 (a int not null, b char(20), key(a)) engine=MERGE UNION=(t1,t2);
|
2000-12-28 02:56:38 +01:00
|
|
|
select * from t3;
|
|
|
|
select * from t3 order by a desc;
|
|
|
|
drop table t3;
|
|
|
|
insert into t1 select NULL,message from t2;
|
|
|
|
insert into t2 select NULL,message from t1;
|
|
|
|
insert into t1 select NULL,message from t2;
|
|
|
|
insert into t2 select NULL,message from t1;
|
|
|
|
insert into t1 select NULL,message from t2;
|
|
|
|
insert into t2 select NULL,message from t1;
|
|
|
|
insert into t1 select NULL,message from t2;
|
|
|
|
insert into t2 select NULL,message from t1;
|
|
|
|
insert into t1 select NULL,message from t2;
|
|
|
|
insert into t2 select NULL,message from t1;
|
|
|
|
insert into t1 select NULL,message from t2;
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t3 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,test.t2);
|
2000-12-28 02:56:38 +01:00
|
|
|
explain select * from t3 where a < 10;
|
|
|
|
explain select * from t3 where a > 10 and a < 20;
|
|
|
|
select * from t3 where a = 10;
|
|
|
|
select * from t3 where a < 10;
|
|
|
|
select * from t3 where a > 10 and a < 20;
|
|
|
|
explain select a from t3 order by a desc limit 10;
|
|
|
|
select a from t3 order by a desc limit 10;
|
|
|
|
select a from t3 order by a desc limit 300,10;
|
2001-09-27 20:45:48 +02:00
|
|
|
delete from t3 where a=3;
|
|
|
|
select * from t3 where a < 10;
|
|
|
|
delete from t3 where a >= 6 and a <= 8;
|
|
|
|
select * from t3 where a < 10;
|
|
|
|
update t3 set a=3 where a=9;
|
|
|
|
select * from t3 where a < 10;
|
|
|
|
update t3 set a=6 where a=7;
|
|
|
|
select * from t3 where a < 10;
|
2001-02-17 13:19:19 +01:00
|
|
|
show create table t3;
|
2000-12-28 02:56:38 +01:00
|
|
|
|
|
|
|
# The following should give errors
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2);
|
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed my_error() to print error messages, which come from
arbitrary registered ranges of error messages. Messages can
be unregistered (and should be at end of the program).
Added registration of handler error messages.
Added a new mi_print_error() macro and a new
mi_report_error() function, which supply error
messages with a table name.
Added calls to mi_print_error() or mi_report_error()
at all places in MyISAM, where table corruption is detected.
extra/comp_err.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added prints for ER_ERROR_FIRST and ER_ERROR_LAST.
Removed print for ER_ERROR_MESSAGES.
include/errmsg.h:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added declaration for a new function.
Added first and last error number defines.
include/my_base.h:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added first and last error number defines.
include/my_sys.h:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Removed obsolete defines.
Removed a global variable, which held pointers to the error message arrays.
Added declarations for new functions.
include/mysys_err.h:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Removed an obsolete define.
Changed two defines to use the new defines.
Added first and last error number defines.
libmysql/errmsg.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Replaced global array initialization by proper registration
and unregistration of client error messages.
libmysql/libmysql.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added a call for unregistration of client error messages.
myisam/mi_delete.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
Added a debugging call to pretend MyISAM corruption in case a special
debug string is set.
Added a debugging call to test undefined error numbers in case a special
debug string is set.
myisam/mi_extra.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_info.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added the error logging function.
myisam/mi_key.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_keycache.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_locking.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_open.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
Added a debugging call to pretend MyISAM corruption in case a special
debug string is set.
myisam/mi_page.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_range.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_rkey.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_search.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_update.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
Added a debugging call to pretend MyISAM corruption in case a special
debug string is set.
myisam/mi_write.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
Added a debugging call to pretend MyISAM corruption in case a special
debug string is set.
myisam/myisamdef.h:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added the declaration of the new error logging function
and a new macro.
mysql-test/r/merge.result:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed test results. These come from the changed error reporting
in openfrm().
mysql-test/r/repair.result:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed test results. These come from the changed error reporting
in openfrm().
mysql-test/t/merge.test:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changederror numbers. These come from the changed error reporting
in openfrm().
mysys/errors.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Dropped the assignment of the global errors to the
dropped global pointer array.
mysys/my_error.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed my_error() from using a static array of pointers to
error message arrays to using a linked list of structures
with pointers to array message arrays.
Added functions for registering and unregistering error
message arrays to the chain.
sql/derror.cc:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed reading of mysqld error messages to using the new
registering and unregistering functions.
sql/handler.cc:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added initialization and deinitialization of handler error messages.
Included more handler error messages in the mapping to
mysqld error messages.
sql/mysqld.cc:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed deinitialization of error messages to proper
unregistration.
sql/table.cc:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed error reporting in openfrm() so that error messages from
handler::ha_open() are reported by handler::print_error(). This
changed messages from "Can't open 't1.MYI' (errno: 130)" to
"Incorrect file format 't1'" for example.
sql/unireg.h:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed two defines to use the new defines.
2004-12-23 20:11:38 +01:00
|
|
|
--error 1168
|
2001-08-29 16:33:41 +02:00
|
|
|
select * from t4;
|
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed my_error() to print error messages, which come from
arbitrary registered ranges of error messages. Messages can
be unregistered (and should be at end of the program).
Added registration of handler error messages.
Added a new mi_print_error() macro and a new
mi_report_error() function, which supply error
messages with a table name.
Added calls to mi_print_error() or mi_report_error()
at all places in MyISAM, where table corruption is detected.
extra/comp_err.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added prints for ER_ERROR_FIRST and ER_ERROR_LAST.
Removed print for ER_ERROR_MESSAGES.
include/errmsg.h:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added declaration for a new function.
Added first and last error number defines.
include/my_base.h:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added first and last error number defines.
include/my_sys.h:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Removed obsolete defines.
Removed a global variable, which held pointers to the error message arrays.
Added declarations for new functions.
include/mysys_err.h:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Removed an obsolete define.
Changed two defines to use the new defines.
Added first and last error number defines.
libmysql/errmsg.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Replaced global array initialization by proper registration
and unregistration of client error messages.
libmysql/libmysql.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added a call for unregistration of client error messages.
myisam/mi_delete.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
Added a debugging call to pretend MyISAM corruption in case a special
debug string is set.
Added a debugging call to test undefined error numbers in case a special
debug string is set.
myisam/mi_extra.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_info.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added the error logging function.
myisam/mi_key.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_keycache.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_locking.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_open.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
Added a debugging call to pretend MyISAM corruption in case a special
debug string is set.
myisam/mi_page.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_range.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_rkey.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_search.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
myisam/mi_update.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
Added a debugging call to pretend MyISAM corruption in case a special
debug string is set.
myisam/mi_write.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added calls to the new error logging function at all places, where
corruption is detected.
Added a debugging call to pretend MyISAM corruption in case a special
debug string is set.
myisam/myisamdef.h:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added the declaration of the new error logging function
and a new macro.
mysql-test/r/merge.result:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed test results. These come from the changed error reporting
in openfrm().
mysql-test/r/repair.result:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed test results. These come from the changed error reporting
in openfrm().
mysql-test/t/merge.test:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changederror numbers. These come from the changed error reporting
in openfrm().
mysys/errors.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Dropped the assignment of the global errors to the
dropped global pointer array.
mysys/my_error.c:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed my_error() from using a static array of pointers to
error message arrays to using a linked list of structures
with pointers to array message arrays.
Added functions for registering and unregistering error
message arrays to the chain.
sql/derror.cc:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed reading of mysqld error messages to using the new
registering and unregistering functions.
sql/handler.cc:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Added initialization and deinitialization of handler error messages.
Included more handler error messages in the mapping to
mysqld error messages.
sql/mysqld.cc:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed deinitialization of error messages to proper
unregistration.
sql/table.cc:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed error reporting in openfrm() so that error messages from
handler::ha_open() are reported by handler::print_error(). This
changed messages from "Can't open 't1.MYI' (errno: 130)" to
"Incorrect file format 't1'" for example.
sql/unireg.h:
WL#1895 - Print message to error log in case of detected MyISAM corruption
Changed two defines to use the new defines.
2004-12-23 20:11:38 +01:00
|
|
|
--error 1168
|
2003-06-27 15:29:10 +02:00
|
|
|
alter table t4 add column c int;
|
2000-12-28 02:56:38 +01:00
|
|
|
|
2003-06-27 15:29:10 +02:00
|
|
|
#
|
|
|
|
# Test tables in different databases
|
|
|
|
#
|
|
|
|
create database mysqltest;
|
|
|
|
create table mysqltest.t6 (a int not null primary key auto_increment, message char(20));
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t5 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,mysqltest.t6);
|
2003-06-27 15:29:10 +02:00
|
|
|
show create table t5;
|
2003-12-10 05:31:42 +01:00
|
|
|
alter table t5 engine=myisam;
|
2003-06-27 15:29:10 +02:00
|
|
|
drop table t5, mysqltest.t6;
|
|
|
|
drop database mysqltest;
|
2000-12-28 02:56:38 +01:00
|
|
|
|
2003-06-27 15:29:10 +02:00
|
|
|
# Because of windows, it's important that we drop the merge tables first!
|
2003-07-01 14:49:32 +02:00
|
|
|
drop table t4,t3,t1,t2;
|
2003-06-27 15:29:10 +02:00
|
|
|
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t1 (c char(10)) engine=myisam;
|
|
|
|
create table t2 (c char(10)) engine=myisam;
|
|
|
|
create table t3 (c char(10)) union=(t1,t2) engine=merge;
|
2000-12-28 02:56:38 +01:00
|
|
|
insert into t1 (c) values ('test1');
|
|
|
|
insert into t1 (c) values ('test1');
|
|
|
|
insert into t1 (c) values ('test1');
|
|
|
|
insert into t2 (c) values ('test2');
|
|
|
|
insert into t2 (c) values ('test2');
|
|
|
|
insert into t2 (c) values ('test2');
|
|
|
|
select * from t3;
|
|
|
|
select * from t3;
|
2001-03-06 14:24:08 +01:00
|
|
|
delete from t3 where 1=1;
|
2000-12-28 02:56:38 +01:00
|
|
|
select * from t3;
|
|
|
|
select * from t1;
|
|
|
|
drop table t3,t2,t1;
|
|
|
|
|
|
|
|
#
|
|
|
|
# Test 2
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (incr int not null, othr int not null, primary key(incr));
|
|
|
|
CREATE TABLE t2 (incr int not null, othr int not null, primary key(incr));
|
|
|
|
CREATE TABLE t3 (incr int not null, othr int not null, primary key(incr))
|
2003-12-10 05:31:42 +01:00
|
|
|
ENGINE=MERGE UNION=(t1,t2);
|
2000-12-28 02:56:38 +01:00
|
|
|
|
|
|
|
SELECT * from t3;
|
|
|
|
|
|
|
|
INSERT INTO t1 VALUES ( 1,10),( 3,53),( 5,21),( 7,12),( 9,17);
|
|
|
|
INSERT INTO t2 VALUES ( 2,24),( 4,33),( 6,41),( 8,26),( 0,32);
|
|
|
|
INSERT INTO t1 VALUES (11,20),(13,43),(15,11),(17,22),(19,37);
|
|
|
|
INSERT INTO t2 VALUES (12,25),(14,31),(16,42),(18,27),(10,30);
|
|
|
|
|
|
|
|
SELECT * from t3 where incr in (1,2,3,4) order by othr;
|
2001-01-28 20:35:50 +01:00
|
|
|
alter table t3 UNION=(t1);
|
|
|
|
select count(*) from t3;
|
|
|
|
alter table t3 UNION=(t1,t2);
|
|
|
|
select count(*) from t3;
|
2003-12-10 05:31:42 +01:00
|
|
|
alter table t3 ENGINE=MYISAM;
|
2001-01-28 20:35:50 +01:00
|
|
|
select count(*) from t3;
|
2001-03-06 14:24:08 +01:00
|
|
|
|
|
|
|
# Test that ALTER TABLE rembers the old UNION
|
|
|
|
|
|
|
|
drop table t3;
|
|
|
|
CREATE TABLE t3 (incr int not null, othr int not null, primary key(incr))
|
2003-12-10 05:31:42 +01:00
|
|
|
ENGINE=MERGE UNION=(t1,t2);
|
2001-03-06 14:24:08 +01:00
|
|
|
show create table t3;
|
|
|
|
alter table t3 drop primary key;
|
|
|
|
show create table t3;
|
|
|
|
|
2000-12-28 02:56:38 +01:00
|
|
|
drop table t3,t2,t1;
|
|
|
|
|
|
|
|
#
|
|
|
|
# Test table without unions
|
|
|
|
#
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t1 (a int not null, key(a)) engine=merge;
|
2001-01-21 15:30:16 +01:00
|
|
|
select * from t1;
|
|
|
|
drop table t1;
|
2001-05-16 23:06:30 +02:00
|
|
|
|
|
|
|
#
|
2003-01-06 00:48:59 +01:00
|
|
|
# Bug in flush tables combined with MERGE tables
|
2001-05-16 23:06:30 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
create table t1 (a int not null, b int not null, key(a,b));
|
|
|
|
create table t2 (a int not null, b int not null, key(a,b));
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t3 (a int not null, b int not null, key(a,b)) ENGINE=MERGE UNION=(t1,t2);
|
2001-05-16 23:06:30 +02:00
|
|
|
insert into t1 values (1,2),(2,1),(0,0),(4,4),(5,5),(6,6);
|
|
|
|
insert into t2 values (1,1),(2,2),(0,0),(4,4),(5,5),(6,6);
|
|
|
|
flush tables;
|
|
|
|
select * from t3 where a=1 order by b limit 2;
|
2001-09-11 23:11:18 +02:00
|
|
|
drop table t3,t1,t2;
|
2001-09-27 20:45:48 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# [phi] testing INSERT_METHOD stuff
|
|
|
|
#
|
|
|
|
|
|
|
|
# first testing of common stuff with new parameters
|
2002-07-22 00:46:30 +02:00
|
|
|
create table t1 (a int not null, b int not null auto_increment, primary key(a,b));
|
|
|
|
create table t2 (a int not null, b int not null auto_increment, primary key(a,b));
|
2001-09-27 20:45:48 +02:00
|
|
|
create table t3 (a int not null, b int not null, key(a,b)) UNION=(t1,t2) INSERT_METHOD=NO;
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t4 (a int not null, b int not null, key(a,b)) ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=NO;
|
|
|
|
create table t5 (a int not null, b int not null auto_increment, primary key(a,b)) ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=FIRST;
|
|
|
|
create table t6 (a int not null, b int not null auto_increment, primary key(a,b)) ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST;
|
2001-09-27 20:45:48 +02:00
|
|
|
show create table t3;
|
|
|
|
show create table t4;
|
|
|
|
show create table t5;
|
|
|
|
show create table t6;
|
2002-07-22 00:46:30 +02:00
|
|
|
insert into t1 values (1,NULL),(1,NULL),(1,NULL),(1,NULL);
|
|
|
|
insert into t2 values (2,NULL),(2,NULL),(2,NULL),(2,NULL);
|
2001-09-27 20:45:48 +02:00
|
|
|
select * from t3 order by b,a limit 3;
|
|
|
|
select * from t4 order by b,a limit 3;
|
|
|
|
select * from t5 order by b,a limit 3,3;
|
|
|
|
select * from t6 order by b,a limit 6,3;
|
|
|
|
# now testing inserts and where the data gets written
|
|
|
|
insert into t5 values (5,1),(5,2);
|
|
|
|
insert into t6 values (6,1),(6,2);
|
|
|
|
select * from t1 order by a,b;
|
|
|
|
select * from t2 order by a,b;
|
|
|
|
select * from t4 order by a,b;
|
|
|
|
# preperation for next test
|
|
|
|
insert into t3 values (3,1),(3,2),(3,3),(3,4);
|
|
|
|
select * from t3 order by a,b;
|
|
|
|
# now testing whether options are kept by alter table
|
|
|
|
alter table t4 UNION=(t1,t2,t3);
|
|
|
|
show create table t4;
|
|
|
|
select * from t4 order by a,b;
|
|
|
|
# testing switching off insert method and inserts again
|
|
|
|
alter table t4 INSERT_METHOD=FIRST;
|
|
|
|
show create table t4;
|
|
|
|
insert into t4 values (4,1),(4,2);
|
|
|
|
select * from t1 order by a,b;
|
|
|
|
select * from t2 order by a,b;
|
|
|
|
select * from t3 order by a,b;
|
|
|
|
select * from t4 order by a,b;
|
|
|
|
select * from t5 order by a,b;
|
2002-07-22 00:46:30 +02:00
|
|
|
# auto_increment
|
|
|
|
select 1;
|
|
|
|
insert into t5 values (1,NULL),(5,NULL);
|
|
|
|
insert into t6 values (2,NULL),(6,NULL);
|
|
|
|
select * from t1 order by a,b;
|
|
|
|
select * from t2 order by a,b;
|
|
|
|
select * from t5 order by a,b;
|
|
|
|
select * from t6 order by a,b;
|
2003-07-01 14:49:32 +02:00
|
|
|
insert into t1 values (99,NULL);
|
|
|
|
select * from t4 where a+0 > 90;
|
2004-06-25 15:12:13 +02:00
|
|
|
# bug#4008 - cannot determine a unique key that caused "dupl. key error"
|
|
|
|
--error 1062
|
|
|
|
insert t5 values (1,1);
|
|
|
|
--error 1062
|
|
|
|
insert t6 values (2,1);
|
|
|
|
insert t5 values (1,1) on duplicate key update b=b+10;
|
|
|
|
insert t6 values (2,1) on duplicate key update b=b+20;
|
|
|
|
select * from t5 where a < 3;
|
2003-07-01 14:49:32 +02:00
|
|
|
drop table t6, t5, t4, t3, t2, t1;
|
2002-07-22 00:46:30 +02:00
|
|
|
|
2003-12-10 05:31:42 +01:00
|
|
|
CREATE TABLE t1 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) ENGINE=MyISAM;
|
2002-06-15 19:59:42 +02:00
|
|
|
INSERT INTO t1 VALUES (1,1), (2,1);
|
2003-12-10 05:31:42 +01:00
|
|
|
CREATE TABLE t2 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) ENGINE=MyISAM;
|
2002-06-15 19:59:42 +02:00
|
|
|
INSERT INTO t2 VALUES (1,2), (2,2);
|
2003-12-10 05:31:42 +01:00
|
|
|
CREATE TABLE t3 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) ENGINE=MRG_MyISAM UNION=(t1,t2);
|
2003-01-06 00:48:59 +01:00
|
|
|
select max(b) from t3 where a = 2;
|
2002-06-18 16:38:06 +02:00
|
|
|
select max(b) from t1 where a = 2;
|
2003-07-01 14:49:32 +02:00
|
|
|
drop table t3,t1,t2;
|
2002-11-05 17:10:31 +01:00
|
|
|
|
2002-11-05 00:00:51 +01:00
|
|
|
#
|
|
|
|
# temporary merge tables
|
|
|
|
#
|
|
|
|
create table t1 (a int not null);
|
|
|
|
create table t2 (a int not null);
|
|
|
|
insert into t1 values (1);
|
|
|
|
insert into t2 values (2);
|
2003-12-10 05:31:42 +01:00
|
|
|
create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2);
|
2002-11-05 00:00:51 +01:00
|
|
|
select * from t3;
|
|
|
|
create temporary table t4 (a int not null);
|
|
|
|
create temporary table t5 (a int not null);
|
|
|
|
insert into t4 values (1);
|
|
|
|
insert into t5 values (2);
|
2003-12-10 05:31:42 +01:00
|
|
|
create temporary table t6 (a int not null) ENGINE=MERGE UNION=(t4,t5);
|
2002-11-05 00:00:51 +01:00
|
|
|
select * from t6;
|
2003-07-01 14:49:32 +02:00
|
|
|
drop table t6, t3, t1, t2, t4, t5;
|
2002-11-05 00:00:51 +01:00
|
|
|
|
2002-11-17 18:58:03 +01:00
|
|
|
#
|
|
|
|
# testing merge::records_in_range and optimizer
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
fileset_id tinyint(3) unsigned NOT NULL default '0',
|
|
|
|
file_code varchar(32) NOT NULL default '',
|
|
|
|
fileset_root_id tinyint(3) unsigned NOT NULL default '0',
|
|
|
|
PRIMARY KEY (fileset_id,file_code),
|
|
|
|
KEY files (fileset_id,fileset_root_id)
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MyISAM;
|
2002-11-17 18:58:03 +01:00
|
|
|
INSERT INTO t1 VALUES (2, '0000000111', 1), (2, '0000000112', 1), (2, '0000000113', 1),
|
|
|
|
(2, '0000000114', 1), (2, '0000000115', 1), (2, '0000000116', 1), (2, '0000000117', 1),
|
|
|
|
(2, '0000000118', 1), (2, '0000000119', 1), (2, '0000000120', 1);
|
|
|
|
CREATE TABLE t2 (
|
|
|
|
fileset_id tinyint(3) unsigned NOT NULL default '0',
|
|
|
|
file_code varchar(32) NOT NULL default '',
|
|
|
|
fileset_root_id tinyint(3) unsigned NOT NULL default '0',
|
|
|
|
PRIMARY KEY (fileset_id,file_code),
|
|
|
|
KEY files (fileset_id,fileset_root_id)
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MRG_MyISAM UNION=(t1);
|
2002-11-17 18:58:03 +01:00
|
|
|
|
|
|
|
EXPLAIN SELECT * FROM t2 IGNORE INDEX (files) WHERE fileset_id = 2
|
|
|
|
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
|
|
|
|
EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
|
|
|
|
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
|
|
|
|
EXPLAIN SELECT * FROM t1 WHERE fileset_id = 2
|
|
|
|
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
|
|
|
|
EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
|
|
|
|
AND file_code = '0000000115' LIMIT 1;
|
2003-01-06 00:48:59 +01:00
|
|
|
DROP TABLE t2, t1;
|
2002-11-17 18:58:03 +01:00
|
|
|
|
2003-07-03 10:55:36 +02:00
|
|
|
#
|
|
|
|
# Test of ORDER BY DESC on key (Bug #515)
|
|
|
|
#
|
|
|
|
|
|
|
|
create table t1 (x int, y int, index xy(x, y));
|
|
|
|
create table t2 (x int, y int, index xy(x, y));
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t3 (x int, y int, index xy(x, y)) engine=merge union=(t1,t2);
|
2003-07-03 10:55:36 +02:00
|
|
|
insert into t1 values(1, 2);
|
|
|
|
insert into t2 values(1, 3);
|
|
|
|
select * from t3 where x = 1 and y < 5 order by y;
|
|
|
|
# Bug is that followng query returns empty set while it must be same as above
|
|
|
|
select * from t3 where x = 1 and y < 5 order by y desc;
|
|
|
|
drop table t1,t2,t3;
|
2004-08-27 13:43:01 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bug#5232: CREATE TABLE ... SELECT
|
|
|
|
#
|
|
|
|
|
|
|
|
create table t1 (a int);
|
|
|
|
create table t2 (a int);
|
|
|
|
insert into t1 values (0);
|
|
|
|
insert into t2 values (1);
|
|
|
|
--error 1093
|
|
|
|
create table t3 engine=merge union=(t1, t2) select * from t1;
|
|
|
|
--error 1093
|
|
|
|
create table t3 engine=merge union=(t1, t2) select * from t2;
|
2004-09-10 01:22:44 +02:00
|
|
|
--error 1093
|
|
|
|
create table t3 engine=merge union=(t1, t2) select (select max(a) from t2);
|
2004-08-27 13:43:01 +02:00
|
|
|
drop table t1, t2;
|
2004-11-29 04:51:30 +01:00
|
|
|
|
2005-09-23 10:15:11 +02:00
|
|
|
#
|
|
|
|
# Bug#9112 - Merge table with composite index producing invalid results with some queries
|
|
|
|
# This test case will fail only without the bugfix and some
|
|
|
|
# non-deterministic circumstances. It depends on properly initialized
|
|
|
|
# "un-initialized" memory. At the time it happens with a standard
|
|
|
|
# non-debug build. But there is no guarantee that this will be always so.
|
|
|
|
#
|
|
|
|
create table t1 (
|
2005-09-27 15:26:16 +02:00
|
|
|
a double(14,4),
|
2005-09-23 10:15:11 +02:00
|
|
|
b varchar(10),
|
|
|
|
index (a,b)
|
|
|
|
) engine=merge union=(t2,t3);
|
|
|
|
|
|
|
|
create table t2 (
|
2005-09-27 15:26:16 +02:00
|
|
|
a double(14,4),
|
2005-09-23 10:15:11 +02:00
|
|
|
b varchar(10),
|
|
|
|
index (a,b)
|
|
|
|
) engine=myisam;
|
|
|
|
|
|
|
|
create table t3 (
|
2005-09-27 15:26:16 +02:00
|
|
|
a double(14,4),
|
2005-09-23 10:15:11 +02:00
|
|
|
b varchar(10),
|
|
|
|
index (a,b)
|
|
|
|
) engine=myisam;
|
|
|
|
|
|
|
|
insert into t2 values ( null, '');
|
2005-09-29 13:37:30 +02:00
|
|
|
insert into t2 values ( 9999999999.999, '');
|
2005-09-23 10:15:11 +02:00
|
|
|
insert into t3 select * from t2;
|
|
|
|
select min(a), max(a) from t1;
|
|
|
|
flush tables;
|
|
|
|
select min(a), max(a) from t1;
|
|
|
|
drop table t1, t2, t3;
|
2004-11-29 04:51:30 +01:00
|
|
|
# BUG#6699 : no sorting on 'ref' retrieval
|
|
|
|
create table t1 (a int,b int,c int, index (a,b,c));
|
|
|
|
create table t2 (a int,b int,c int, index (a,b,c));
|
|
|
|
create table t3 (a int,b int,c int, index (a,b,c))
|
|
|
|
engine=merge union=(t1 ,t2);
|
|
|
|
insert into t1 (a,b,c) values (1,1,0),(1,2,0);
|
|
|
|
insert into t2 (a,b,c) values (1,1,1),(1,2,1);
|
|
|
|
|
|
|
|
explain select a,b,c from t3 force index (a) where a=1 order by a,b,c;
|
|
|
|
select a,b,c from t3 force index (a) where a=1 order by a,b,c;
|
|
|
|
|
|
|
|
# this actually wasn't affected:
|
|
|
|
explain select a,b,c from t3 force index (a) where a=1 order by a desc, b desc, c desc;
|
|
|
|
select a,b,c from t3 force index (a) where a=1 order by a desc, b desc, c desc;
|
|
|
|
|
2004-12-27 13:05:35 +01:00
|
|
|
# BUG#7377 SHOW index on MERGE table crashes debug server
|
|
|
|
show index from t3;
|
|
|
|
|
2004-11-29 04:51:30 +01:00
|
|
|
drop table t1, t2, t3;
|
|
|
|
|
2005-05-18 19:40:39 +02:00
|
|
|
#
|
|
|
|
# Bug#10400 - Improperly-defined MERGE table crashes with INSERT ... ON DUPLICATE KEY UPDATE
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 ( a INT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(10), UNIQUE (b) )
|
|
|
|
ENGINE=MyISAM;
|
|
|
|
CREATE TABLE t2 ( a INT AUTO_INCREMENT, b VARCHAR(10), INDEX (a), INDEX (b) )
|
|
|
|
ENGINE=MERGE UNION (t1) INSERT_METHOD=FIRST;
|
|
|
|
INSERT INTO t2 (b) VALUES (1) ON DUPLICATE KEY UPDATE b=2;
|
|
|
|
INSERT INTO t2 (b) VALUES (1) ON DUPLICATE KEY UPDATE b=3;
|
|
|
|
SELECT b FROM t2;
|
|
|
|
DROP TABLE t1, t2;
|
|
|
|
|
2005-07-28 02:22:47 +02:00
|
|
|
# End of 4.1 tests
|