2001-10-03 15:19:58 -06:00
|
|
|
drop table if exists t1,t2,t3,t4,t5,t6;
|
2003-06-27 16:29:10 +03:00
|
|
|
drop database if exists mysqltest;
|
2001-09-27 23:05:54 -06: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 04:31:42 +00:00
|
|
|
create table t3 (a int not null, b char(20), key(a)) engine=MERGE UNION=(t1,t2);
|
2001-09-27 23:05:54 -06:00
|
|
|
select * from t3;
|
2000-12-28 03:56:38 +02:00
|
|
|
a b
|
|
|
|
1 Testing
|
|
|
|
2 table
|
|
|
|
3 t1
|
|
|
|
1 Testing
|
|
|
|
2 table
|
|
|
|
3 t2
|
2001-09-27 23:05:54 -06:00
|
|
|
select * from t3 order by a desc;
|
2000-12-28 03:56:38 +02:00
|
|
|
a b
|
|
|
|
3 t1
|
|
|
|
3 t2
|
|
|
|
2 table
|
|
|
|
2 table
|
|
|
|
1 Testing
|
|
|
|
1 Testing
|
2001-09-27 23:05:54 -06:00
|
|
|
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 04:31:42 +00:00
|
|
|
create table t3 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,test.t2);
|
2001-09-27 23:05:54 -06:00
|
|
|
explain select * from t3 where a < 10;
|
2002-09-26 23:08:22 +03:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2002-11-21 22:25:53 +02:00
|
|
|
1 SIMPLE t3 range a a 4 NULL 18 Using where
|
2001-09-27 23:05:54 -06:00
|
|
|
explain select * from t3 where a > 10 and a < 20;
|
2002-09-26 23:08:22 +03:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2005-05-13 12:08:08 +03:00
|
|
|
1 SIMPLE t3 range a a 4 NULL 17 Using where
|
2001-09-27 23:05:54 -06:00
|
|
|
select * from t3 where a = 10;
|
2000-12-28 03:56:38 +02:00
|
|
|
a b
|
|
|
|
10 Testing
|
|
|
|
10 Testing
|
2001-09-27 23:05:54 -06:00
|
|
|
select * from t3 where a < 10;
|
2000-12-28 03:56:38 +02:00
|
|
|
a b
|
|
|
|
1 Testing
|
|
|
|
1 Testing
|
|
|
|
2 table
|
|
|
|
2 table
|
|
|
|
3 t1
|
|
|
|
3 t2
|
|
|
|
4 Testing
|
|
|
|
4 Testing
|
|
|
|
5 table
|
|
|
|
5 table
|
|
|
|
6 t2
|
2006-02-11 21:51:43 +03:00
|
|
|
6 t1
|
2000-12-28 03:56:38 +02:00
|
|
|
7 Testing
|
|
|
|
7 Testing
|
|
|
|
8 table
|
|
|
|
8 table
|
|
|
|
9 t2
|
|
|
|
9 t2
|
2001-09-27 23:05:54 -06:00
|
|
|
select * from t3 where a > 10 and a < 20;
|
2000-12-28 03:56:38 +02:00
|
|
|
a b
|
|
|
|
11 table
|
|
|
|
11 table
|
|
|
|
12 t1
|
|
|
|
12 t1
|
|
|
|
13 Testing
|
|
|
|
13 Testing
|
|
|
|
14 table
|
|
|
|
14 table
|
|
|
|
15 t2
|
|
|
|
15 t2
|
|
|
|
16 Testing
|
|
|
|
16 Testing
|
|
|
|
17 table
|
|
|
|
17 table
|
|
|
|
18 t2
|
|
|
|
18 t2
|
|
|
|
19 Testing
|
|
|
|
19 Testing
|
2001-09-27 23:05:54 -06:00
|
|
|
explain select a from t3 order by a desc limit 10;
|
2002-09-26 23:08:22 +03:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2002-10-03 18:47:04 +03:00
|
|
|
1 SIMPLE t3 index NULL a 4 NULL 1131 Using index
|
2001-09-27 23:05:54 -06:00
|
|
|
select a from t3 order by a desc limit 10;
|
2000-12-28 03:56:38 +02:00
|
|
|
a
|
|
|
|
699
|
|
|
|
698
|
|
|
|
697
|
|
|
|
696
|
|
|
|
695
|
|
|
|
694
|
|
|
|
693
|
|
|
|
692
|
|
|
|
691
|
|
|
|
690
|
2001-09-27 23:05:54 -06:00
|
|
|
select a from t3 order by a desc limit 300,10;
|
2000-12-28 03:56:38 +02:00
|
|
|
a
|
|
|
|
416
|
|
|
|
415
|
|
|
|
415
|
|
|
|
414
|
|
|
|
414
|
|
|
|
413
|
|
|
|
413
|
|
|
|
412
|
|
|
|
412
|
|
|
|
411
|
2001-10-03 15:19:58 -06:00
|
|
|
delete from t3 where a=3;
|
|
|
|
select * from t3 where a < 10;
|
|
|
|
a b
|
|
|
|
1 Testing
|
|
|
|
1 Testing
|
|
|
|
2 table
|
|
|
|
2 table
|
|
|
|
4 Testing
|
|
|
|
4 Testing
|
|
|
|
5 table
|
|
|
|
5 table
|
|
|
|
6 t2
|
|
|
|
6 t1
|
|
|
|
7 Testing
|
|
|
|
7 Testing
|
|
|
|
8 table
|
|
|
|
8 table
|
|
|
|
9 t2
|
|
|
|
9 t2
|
|
|
|
delete from t3 where a >= 6 and a <= 8;
|
|
|
|
select * from t3 where a < 10;
|
|
|
|
a b
|
|
|
|
1 Testing
|
|
|
|
1 Testing
|
|
|
|
2 table
|
|
|
|
2 table
|
|
|
|
4 Testing
|
|
|
|
4 Testing
|
|
|
|
5 table
|
|
|
|
5 table
|
|
|
|
9 t2
|
|
|
|
9 t2
|
|
|
|
update t3 set a=3 where a=9;
|
|
|
|
select * from t3 where a < 10;
|
|
|
|
a b
|
|
|
|
1 Testing
|
|
|
|
1 Testing
|
|
|
|
2 table
|
|
|
|
2 table
|
|
|
|
3 t2
|
|
|
|
3 t2
|
|
|
|
4 Testing
|
|
|
|
4 Testing
|
|
|
|
5 table
|
|
|
|
5 table
|
|
|
|
update t3 set a=6 where a=7;
|
|
|
|
select * from t3 where a < 10;
|
|
|
|
a b
|
|
|
|
1 Testing
|
|
|
|
1 Testing
|
|
|
|
2 table
|
|
|
|
2 table
|
|
|
|
3 t2
|
|
|
|
3 t2
|
|
|
|
4 Testing
|
|
|
|
4 Testing
|
|
|
|
5 table
|
|
|
|
5 table
|
2001-09-27 23:05:54 -06:00
|
|
|
show create table t3;
|
2001-02-17 19:04:33 +02:00
|
|
|
Table Create Table
|
|
|
|
t3 CREATE TABLE `t3` (
|
2004-10-02 22:20:08 +03:00
|
|
|
`a` int(11) NOT NULL,
|
2006-02-22 10:09:59 +01:00
|
|
|
`b` char(20) DEFAULT NULL,
|
2001-02-17 19:04:33 +02:00
|
|
|
KEY `a` (`a`)
|
2003-12-10 04:31:42 +00:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`)
|
|
|
|
create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2);
|
2001-09-27 23:05:54 -06:00
|
|
|
select * from t4;
|
2006-10-06 10:54:47 +05:00
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
2003-06-27 16:29:10 +03:00
|
|
|
alter table t4 add column c int;
|
2006-10-06 10:54:47 +05:00
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
Table definition cache, part 2
The table opening process now works the following way:
- Create common TABLE_SHARE object
- Read the .frm file and unpack it into the TABLE_SHARE object
- Create a TABLE object based on the information in the TABLE_SHARE
object and open a handler to the table object
Other noteworthy changes:
- In TABLE_SHARE the most common strings are now LEX_STRING's
- Better error message when table is not found
- Variable table_cache is now renamed 'table_open_cache'
- New variable 'table_definition_cache' that is the number of table defintions that will be cached
- strxnmov() calls are now fixed to avoid overflows
- strxnmov() will now always add one end \0 to result
- engine objects are now created with a TABLE_SHARE object instead of a TABLE object.
- After creating a field object one must call field->init(table) before using it
- For a busy system this change will give you:
- Less memory usage for table object
- Faster opening of tables (if it's has been in use or is in table definition cache)
- Allow you to cache many table definitions objects
- Faster drop of table
mysql-test/mysql-test-run.sh:
Fixed some problems with --gdb option
Test both with socket and tcp/ip port that all old servers are killed
mysql-test/r/flush_table.result:
More tests with lock table with 2 threads + flush table
mysql-test/r/information_schema.result:
Removed old (now wrong) result
mysql-test/r/innodb.result:
Better error messages (thanks to TDC patch)
mysql-test/r/merge.result:
Extra flush table test
mysql-test/r/ndb_bitfield.result:
Better error messages (thanks to TDC patch)
mysql-test/r/ndb_partition_error.result:
Better error messages (thanks to TDC patch)
mysql-test/r/query_cache.result:
Remove tables left from old tests
mysql-test/r/temp_table.result:
Test truncate with temporary tables
mysql-test/r/variables.result:
Table_cache -> Table_open_cache
mysql-test/t/flush_table.test:
More tests with lock table with 2 threads + flush table
mysql-test/t/merge.test:
Extra flush table test
mysql-test/t/multi_update.test:
Added 'sleep' to make test predictable
mysql-test/t/query_cache.test:
Remove tables left from old tests
mysql-test/t/temp_table.test:
Test truncate with temporary tables
mysql-test/t/variables.test:
Table_cache -> Table_open_cache
mysql-test/valgrind.supp:
Remove warning that may happens becasue threads dies in different order
mysys/hash.c:
Fixed wrong DBUG_PRINT
mysys/mf_dirname.c:
More DBUG
mysys/mf_pack.c:
Better comment
mysys/mf_tempdir.c:
More DBUG
Ensure that we call cleanup_dirname() on all temporary directory paths.
If we don't do this, we will get a failure when comparing temporary table
names as in some cases the temporary table name is run through convert_dirname())
mysys/my_alloc.c:
Indentation fix
sql/examples/ha_example.cc:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/examples/ha_example.h:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/examples/ha_tina.cc:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/examples/ha_tina.h:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/field.cc:
Update for table definition cache:
- Field creation now takes TABLE_SHARE instead of TABLE as argument
(This is becasue field definitions are now cached in TABLE_SHARE)
When a field is created, one now must call field->init(TABLE) before using it
- Use s->db instead of s->table_cache_key
- Added Field::clone() to create a field in TABLE from a field in TABLE_SHARE
- make_field() takes TABLE_SHARE as argument instead of TABLE
- move_field() -> move_field_offset()
sql/field.h:
Update for table definition cache:
- Field creation now takes TABLE_SHARE instead of TABLE as argument
(This is becasue field definitions are now cached in TABLE_SHARE)
When a field is created, one now must call field->init(TABLE) before using it
- Added Field::clone() to create a field in TABLE from a field in TABLE_SHARE
- make_field() takes TABLE_SHARE as argument instead of TABLE
- move_field() -> move_field_offset()
sql/ha_archive.cc:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/ha_archive.h:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/ha_berkeley.cc:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
Changed name of argument create() to not hide internal 'table' variable.
table->s -> table_share
sql/ha_berkeley.h:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/ha_blackhole.cc:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/ha_blackhole.h:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/ha_federated.cc:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
Fixed comments
Remove index variable and replace with pointers (simple optimization)
move_field() -> move_field_offset()
Removed some strlen() calls
sql/ha_federated.h:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/ha_heap.cc:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
Simplify delete_table() and create() as the given file names are now without extension
sql/ha_heap.h:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/ha_innodb.cc:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/ha_innodb.h:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/ha_myisam.cc:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
Remove not needed fn_format()
Fixed for new table->s structure
sql/ha_myisam.h:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/ha_myisammrg.cc:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
Don't set 'is_view' for MERGE tables
Use new interface to find_temporary_table()
sql/ha_myisammrg.h:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
Added flag HA_NO_COPY_ON_ALTER
sql/ha_ndbcluster.cc:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
Fixed wrong calls to strxnmov()
Give error HA_ERR_TABLE_DEF_CHANGED if table definition has changed
drop_table -> intern_drop_table()
table->s -> table_share
Move part_info to TABLE
Fixed comments & DBUG print's
New arguments to print_error()
sql/ha_ndbcluster.h:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
sql/ha_partition.cc:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
We can't set up or use part_info when creating handler as there is not yet any table object
New ha_intialise() to work with TDC (Done by Mikael)
sql/ha_partition.h:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
Got set_part_info() from Mikael
sql/handler.cc:
We new use TABLE_SHARE instead of TABLE when creating engine handlers
ha_delete_table() now also takes database as an argument
handler::ha_open() now takes TABLE as argument
ha_open() now calls ha_allocate_read_write_set()
Simplify ha_allocate_read_write_set()
Remove ha_deallocate_read_write_set()
Use table_share (Cached by table definition cache)
sql/handler.h:
New table flag: HA_NO_COPY_ON_ALTER (used by merge tables)
Remove ha_deallocate_read_write_set()
get_new_handler() now takes TABLE_SHARE as argument
ha_delete_table() now gets database as argument
sql/item.cc:
table_name and db are now LEX_STRING objects
When creating fields, we have now have to call field->init(table)
move_field -> move_field_offset()
sql/item.h:
tmp_table_field_from_field_type() now takes an extra paramenter 'fixed_length' to allow one to force usage of CHAR
instead of BLOB
sql/item_cmpfunc.cc:
Fixed call to tmp_table_field_from_field_type()
sql/item_create.cc:
Assert if new not handled cast type
sql/item_func.cc:
When creating fields, we have now have to call field->init(table)
dummy_table used by 'sp' now needs a TABLE_SHARE object
sql/item_subselect.cc:
Trivial code cleanups
sql/item_sum.cc:
When creating fields, we have now have to call field->init(table)
sql/item_timefunc.cc:
Item_func_str_to_date::tmp_table_field() now replaced by call to
tmp_table_field_from_field_type() (see item_timefunc.h)
sql/item_timefunc.h:
Simply tmp_table_field()
sql/item_uniq.cc:
When creating fields, we have now have to call field->init(table)
sql/key.cc:
Added 'KEY' argument to 'find_ref_key' to simplify code
sql/lock.cc:
More debugging
Use create_table_def_key() to create key for table cache
Allocate TABLE_SHARE properly when creating name lock
Fix that locked_table_name doesn't test same table twice
sql/mysql_priv.h:
New functions for table definition cache
New interfaces to a lot of functions.
New faster interface to find_temporary_table() and close_temporary_table()
sql/mysqld.cc:
Added support for table definition cache of size 'table_def_size'
Fixed som calls to strnmov()
Changed name of 'table_cache' to 'table_open_cache'
sql/opt_range.cc:
Use new interfaces
Fixed warnings from valgrind
sql/parse_file.cc:
Safer calls to strxnmov()
Fixed typo
sql/set_var.cc:
Added variable 'table_definition_cache'
Variable table_cache renamed to 'table_open_cache'
sql/slave.cc:
Use new interface
sql/sp.cc:
Proper use of TABLE_SHARE
sql/sp_head.cc:
Remove compiler warnings
We have now to call field->init(table)
sql/sp_head.h:
Pointers to parsed strings are now const
sql/sql_acl.cc:
table_name is now a LEX_STRING
sql/sql_base.cc:
Main implementation of table definition cache
(The #ifdef's are there for the future when table definition cache will replace open table cache)
Now table definitions are cached indepndent of open tables, which will speed up things when a table is in use at once from several places
Views are not yet cached; For the moment we only cache if a table is a view or not.
Faster implementation of find_temorary_table()
Replace 'wait_for_refresh()' with the more general function 'wait_for_condition()'
Drop table is slightly faster as we can use the table definition cache to know the type of the table
sql/sql_cache.cc:
table_cache_key and table_name are now LEX_STRING
'sDBUG print fixes
sql/sql_class.cc:
table_cache_key is now a LEX_STRING
safer strxnmov()
sql/sql_class.h:
Added number of open table shares (table definitions)
sql/sql_db.cc:
safer strxnmov()
sql/sql_delete.cc:
Use new interface to find_temporary_table()
sql/sql_derived.cc:
table_name is now a LEX_STRING
sql/sql_handler.cc:
TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's
sql/sql_insert.cc:
TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's
sql/sql_lex.cc:
Make parsed string a const (to quickly find out if anything is trying to change the query string)
sql/sql_lex.h:
Make parsed string a const (to quickly find out if anything is trying to change the query string)
sql/sql_load.cc:
Safer strxnmov()
sql/sql_parse.cc:
Better error if wrong DB name
sql/sql_partition.cc:
part_info moved to TABLE from TABLE_SHARE
Indentation changes
sql/sql_select.cc:
Indentation fixes
Call field->init(TABLE) for new created fields
Update create_tmp_table() to use TABLE_SHARE properly
sql/sql_select.h:
Call field->init(TABLE) for new created fields
sql/sql_show.cc:
table_name is now a LEX_STRING
part_info moved to TABLE
sql/sql_table.cc:
Use table definition cache to speed up delete of tables
Fixed calls to functions with new interfaces
Don't use 'share_not_to_be_used'
Instead of doing openfrm() when doing repair, we now have to call
get_table_share() followed by open_table_from_share().
Replace some fn_format() with faster unpack_filename().
Safer strxnmov()
part_info is now in TABLE
Added Mikaels patch for partition and ALTER TABLE
Instead of using 'TABLE_SHARE->is_view' use 'table_flags() & HA_NO_COPY_ON_ALTER
sql/sql_test.cc:
table_name and table_cache_key are now LEX_STRING's
sql/sql_trigger.cc:
TABLE_SHARE->db and TABLE_SHARE->table_name are now LEX_STRING's
safer strxnmov()
Removed compiler warnings
sql/sql_update.cc:
Call field->init(TABLE) after field is created
sql/sql_view.cc:
safer strxnmov()
Create common TABLE_SHARE object for views to allow us to cache if table is a view
sql/structs.h:
Added SHOW_TABLE_DEFINITIONS
sql/table.cc:
Creation and destruct of TABLE_SHARE objects that are common for many TABLE objects
The table opening process now works the following way:
- Create common TABLE_SHARE object
- Read the .frm file and unpack it into the TABLE_SHARE object
- Create a TABLE object based on the information in the TABLE_SHARE
object and open a handler to the table object
open_table_def() is written in such a way that it should be trival to add parsing of the .frm files in new formats
sql/table.h:
TABLE objects for the same database table now share a common TABLE_SHARE object
In TABLE_SHARE the most common strings are now LEX_STRING's
sql/unireg.cc:
Changed arguments to rea_create_table() to have same order as other functions
Call field->init(table) for new created fields
sql/unireg.h:
Added OPEN_VIEW
strings/strxnmov.c:
Change strxnmov() to always add end \0
This makes usage of strxnmov() safer as most of MySQL code assumes that strxnmov() will create a null terminated string
2005-11-23 22:45:02 +02:00
|
|
|
flush tables;
|
|
|
|
select * from t4;
|
2006-10-06 11:09:58 +05:00
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
2003-06-27 16:29:10 +03:00
|
|
|
create database mysqltest;
|
|
|
|
create table mysqltest.t6 (a int not null primary key auto_increment, message char(20));
|
2003-12-10 04:31:42 +00:00
|
|
|
create table t5 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,mysqltest.t6);
|
2003-06-27 16:29:10 +03:00
|
|
|
show create table t5;
|
|
|
|
Table Create Table
|
|
|
|
t5 CREATE TABLE `t5` (
|
2004-10-02 22:20:08 +03:00
|
|
|
`a` int(11) NOT NULL,
|
2006-02-22 10:09:59 +01:00
|
|
|
`b` char(20) DEFAULT NULL,
|
2003-06-27 16:29:10 +03:00
|
|
|
KEY `a` (`a`)
|
2003-12-10 04:31:42 +00:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`mysqltest`.`t6`)
|
|
|
|
alter table t5 engine=myisam;
|
2003-06-27 16:29:10 +03:00
|
|
|
drop table t5, mysqltest.t6;
|
|
|
|
drop database mysqltest;
|
2003-07-01 15:49:32 +03:00
|
|
|
drop table t4,t3,t1,t2;
|
2003-12-10 04:31:42 +00: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;
|
2001-09-27 23:05:54 -06: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;
|
2000-12-28 03:56:38 +02:00
|
|
|
c
|
|
|
|
test1
|
|
|
|
test1
|
|
|
|
test1
|
|
|
|
test2
|
|
|
|
test2
|
|
|
|
test2
|
2001-09-27 23:05:54 -06:00
|
|
|
select * from t3;
|
2000-12-28 03:56:38 +02:00
|
|
|
c
|
|
|
|
test1
|
|
|
|
test1
|
|
|
|
test1
|
|
|
|
test2
|
|
|
|
test2
|
|
|
|
test2
|
2001-09-27 23:05:54 -06:00
|
|
|
delete from t3 where 1=1;
|
|
|
|
select * from t3;
|
2000-12-28 03:56:38 +02:00
|
|
|
c
|
2001-09-27 23:05:54 -06:00
|
|
|
select * from t1;
|
2000-12-28 03:56:38 +02:00
|
|
|
c
|
2001-09-27 23:05:54 -06:00
|
|
|
drop table t3,t2,t1;
|
|
|
|
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 04:31:42 +00:00
|
|
|
ENGINE=MERGE UNION=(t1,t2);
|
2001-09-27 23:05:54 -06:00
|
|
|
SELECT * from t3;
|
2000-12-28 03:56:38 +02:00
|
|
|
incr othr
|
2001-09-27 23:05:54 -06:00
|
|
|
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;
|
2000-12-28 03:56:38 +02:00
|
|
|
incr othr
|
|
|
|
1 10
|
|
|
|
2 24
|
|
|
|
4 33
|
|
|
|
3 53
|
2001-09-27 23:05:54 -06:00
|
|
|
alter table t3 UNION=(t1);
|
|
|
|
select count(*) from t3;
|
2001-01-28 21:35:50 +02:00
|
|
|
count(*)
|
|
|
|
10
|
2001-09-27 23:05:54 -06:00
|
|
|
alter table t3 UNION=(t1,t2);
|
|
|
|
select count(*) from t3;
|
2001-01-28 21:35:50 +02:00
|
|
|
count(*)
|
|
|
|
20
|
2003-12-10 04:31:42 +00:00
|
|
|
alter table t3 ENGINE=MYISAM;
|
2001-09-27 23:05:54 -06:00
|
|
|
select count(*) from t3;
|
2001-01-28 21:35:50 +02:00
|
|
|
count(*)
|
|
|
|
20
|
2001-09-27 23:05:54 -06:00
|
|
|
drop table t3;
|
|
|
|
CREATE TABLE t3 (incr int not null, othr int not null, primary key(incr))
|
2003-12-10 04:31:42 +00:00
|
|
|
ENGINE=MERGE UNION=(t1,t2);
|
2001-09-27 23:05:54 -06:00
|
|
|
show create table t3;
|
2001-03-06 15:24:08 +02:00
|
|
|
Table Create Table
|
|
|
|
t3 CREATE TABLE `t3` (
|
2004-10-02 22:20:08 +03:00
|
|
|
`incr` int(11) NOT NULL,
|
|
|
|
`othr` int(11) NOT NULL,
|
2006-02-02 11:39:28 -08:00
|
|
|
PRIMARY KEY (`incr`)
|
2003-12-10 04:31:42 +00:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`)
|
2001-09-27 23:05:54 -06:00
|
|
|
alter table t3 drop primary key;
|
|
|
|
show create table t3;
|
2001-03-06 15:24:08 +02:00
|
|
|
Table Create Table
|
|
|
|
t3 CREATE TABLE `t3` (
|
2004-10-02 22:20:08 +03:00
|
|
|
`incr` int(11) NOT NULL,
|
|
|
|
`othr` int(11) NOT NULL
|
2003-12-10 04:31:42 +00:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`)
|
2001-09-27 23:05:54 -06:00
|
|
|
drop table t3,t2,t1;
|
2003-12-10 04:31:42 +00:00
|
|
|
create table t1 (a int not null, key(a)) engine=merge;
|
2001-09-27 23:05:54 -06:00
|
|
|
select * from t1;
|
2006-09-29 01:36:17 +05:00
|
|
|
ERROR HY000: Got error 124 from storage engine
|
2001-09-27 23:05:54 -06:00
|
|
|
drop table t1;
|
|
|
|
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 04:31:42 +00:00
|
|
|
create table t3 (a int not null, b int not null, key(a,b)) ENGINE=MERGE UNION=(t1,t2);
|
2001-09-27 23:05:54 -06: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-05-16 23:06:30 +02:00
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
2001-09-27 23:05:54 -06:00
|
|
|
drop table t3,t1,t2;
|
2002-07-21 23:55:32 +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-10-03 15:19:58 -06:00
|
|
|
create table t3 (a int not null, b int not null, key(a,b)) UNION=(t1,t2) INSERT_METHOD=NO;
|
2003-12-10 04:31:42 +00: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-10-03 15:19:58 -06:00
|
|
|
show create table t3;
|
|
|
|
Table Create Table
|
|
|
|
t3 CREATE TABLE `t3` (
|
2004-10-02 22:20:08 +03:00
|
|
|
`a` int(11) NOT NULL,
|
|
|
|
`b` int(11) NOT NULL,
|
2001-10-03 15:19:58 -06:00
|
|
|
KEY `a` (`a`,`b`)
|
2003-12-10 04:31:42 +00:00
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
2001-10-03 15:19:58 -06:00
|
|
|
show create table t4;
|
|
|
|
Table Create Table
|
|
|
|
t4 CREATE TABLE `t4` (
|
2004-10-02 22:20:08 +03:00
|
|
|
`a` int(11) NOT NULL,
|
|
|
|
`b` int(11) NOT NULL,
|
2001-10-03 15:19:58 -06:00
|
|
|
KEY `a` (`a`,`b`)
|
2003-12-10 04:31:42 +00:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`)
|
2001-10-03 15:19:58 -06:00
|
|
|
show create table t5;
|
|
|
|
Table Create Table
|
|
|
|
t5 CREATE TABLE `t5` (
|
2004-10-02 22:20:08 +03:00
|
|
|
`a` int(11) NOT NULL,
|
2006-02-22 10:09:59 +01:00
|
|
|
`b` int(11) NOT NULL AUTO_INCREMENT,
|
2006-02-02 11:39:28 -08:00
|
|
|
PRIMARY KEY (`a`,`b`)
|
2003-12-10 04:31:42 +00:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST UNION=(`t1`,`t2`)
|
2001-10-03 15:19:58 -06:00
|
|
|
show create table t6;
|
|
|
|
Table Create Table
|
|
|
|
t6 CREATE TABLE `t6` (
|
2004-10-02 22:20:08 +03:00
|
|
|
`a` int(11) NOT NULL,
|
2006-02-22 10:09:59 +01:00
|
|
|
`b` int(11) NOT NULL AUTO_INCREMENT,
|
2006-02-02 11:39:28 -08:00
|
|
|
PRIMARY KEY (`a`,`b`)
|
2003-12-10 04:31:42 +00:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
|
2002-07-21 23:55:32 +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-10-03 15:19:58 -06:00
|
|
|
select * from t3 order by b,a limit 3;
|
|
|
|
a b
|
|
|
|
select * from t4 order by b,a limit 3;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
2 1
|
|
|
|
1 2
|
|
|
|
select * from t5 order by b,a limit 3,3;
|
|
|
|
a b
|
|
|
|
2 2
|
|
|
|
1 3
|
|
|
|
2 3
|
|
|
|
select * from t6 order by b,a limit 6,3;
|
|
|
|
a b
|
|
|
|
1 4
|
|
|
|
2 4
|
|
|
|
insert into t5 values (5,1),(5,2);
|
|
|
|
insert into t6 values (6,1),(6,2);
|
|
|
|
select * from t1 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
select * from t2 order by a,b;
|
|
|
|
a b
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
select * from t4 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
insert into t3 values (3,1),(3,2),(3,3),(3,4);
|
|
|
|
select * from t3 order by a,b;
|
|
|
|
a b
|
|
|
|
3 1
|
|
|
|
3 2
|
|
|
|
3 3
|
|
|
|
3 4
|
|
|
|
alter table t4 UNION=(t1,t2,t3);
|
|
|
|
show create table t4;
|
|
|
|
Table Create Table
|
|
|
|
t4 CREATE TABLE `t4` (
|
2004-10-02 22:20:08 +03:00
|
|
|
`a` int(11) NOT NULL,
|
|
|
|
`b` int(11) NOT NULL,
|
2001-10-03 15:19:58 -06:00
|
|
|
KEY `a` (`a`,`b`)
|
2003-12-10 04:31:42 +00:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`,`t3`)
|
2001-10-03 15:19:58 -06:00
|
|
|
select * from t4 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
3 1
|
|
|
|
3 2
|
|
|
|
3 3
|
|
|
|
3 4
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
alter table t4 INSERT_METHOD=FIRST;
|
|
|
|
show create table t4;
|
|
|
|
Table Create Table
|
|
|
|
t4 CREATE TABLE `t4` (
|
2004-10-02 22:20:08 +03:00
|
|
|
`a` int(11) NOT NULL,
|
|
|
|
`b` int(11) NOT NULL,
|
2001-10-03 15:19:58 -06:00
|
|
|
KEY `a` (`a`,`b`)
|
2003-12-10 04:31:42 +00:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST UNION=(`t1`,`t2`,`t3`)
|
2001-10-03 15:19:58 -06:00
|
|
|
insert into t4 values (4,1),(4,2);
|
|
|
|
select * from t1 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
4 1
|
|
|
|
4 2
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
select * from t2 order by a,b;
|
|
|
|
a b
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
select * from t3 order by a,b;
|
|
|
|
a b
|
|
|
|
3 1
|
|
|
|
3 2
|
|
|
|
3 3
|
|
|
|
3 4
|
|
|
|
select * from t4 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
3 1
|
|
|
|
3 2
|
|
|
|
3 3
|
|
|
|
3 4
|
|
|
|
4 1
|
|
|
|
4 2
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
select * from t5 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
4 1
|
|
|
|
4 2
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
6 1
|
|
|
|
6 2
|
2002-07-21 23:55:32 +02:00
|
|
|
select 1;
|
|
|
|
1
|
|
|
|
1
|
|
|
|
insert into t5 values (1,NULL),(5,NULL);
|
|
|
|
insert into t6 values (2,NULL),(6,NULL);
|
|
|
|
select * from t1 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
1 5
|
|
|
|
4 1
|
|
|
|
4 2
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
5 3
|
|
|
|
select * from t2 order by a,b;
|
|
|
|
a b
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
2 5
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
6 3
|
|
|
|
select * from t5 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
1 5
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
2 5
|
|
|
|
4 1
|
|
|
|
4 2
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
5 3
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
6 3
|
|
|
|
select * from t6 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
1 5
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
2 5
|
|
|
|
4 1
|
|
|
|
4 2
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
5 3
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
6 3
|
2003-07-01 15:49:32 +03:00
|
|
|
insert into t1 values (99,NULL);
|
|
|
|
select * from t4 where a+0 > 90;
|
|
|
|
a b
|
|
|
|
99 1
|
2004-06-25 15:12:13 +02:00
|
|
|
insert t5 values (1,1);
|
2006-01-23 12:17:05 +01:00
|
|
|
ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
|
2004-06-25 15:12:13 +02:00
|
|
|
insert t6 values (2,1);
|
2006-01-23 12:17:05 +01:00
|
|
|
ERROR 23000: Duplicate entry '2-1' for key 'PRIMARY'
|
2004-06-25 15:12:13 +02:00
|
|
|
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;
|
|
|
|
a b
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
1 5
|
|
|
|
1 11
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
2 5
|
|
|
|
2 21
|
2003-07-01 15:49:32 +03:00
|
|
|
drop table t6, t5, t4, t3, t2, t1;
|
2003-12-10 04:31:42 +00: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 20:59:42 +03:00
|
|
|
INSERT INTO t1 VALUES (1,1), (2,1);
|
2003-12-10 04:31:42 +00: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 20:59:42 +03:00
|
|
|
INSERT INTO t2 VALUES (1,2), (2,2);
|
2003-12-10 04:31:42 +00: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 01:48:59 +02:00
|
|
|
select max(b) from t3 where a = 2;
|
2002-06-15 20:59:42 +03:00
|
|
|
max(b)
|
2003-01-17 12:48:23 +01:00
|
|
|
2
|
2002-06-18 17:38:06 +03:00
|
|
|
select max(b) from t1 where a = 2;
|
|
|
|
max(b)
|
|
|
|
1
|
2003-07-01 15:49:32 +03:00
|
|
|
drop table t3,t1,t2;
|
2002-11-05 18:38:27 +01:00
|
|
|
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 04:31:42 +00:00
|
|
|
create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2);
|
2002-11-05 18:38:27 +01:00
|
|
|
select * from t3;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
|
|
|
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 04:31:42 +00:00
|
|
|
create temporary table t6 (a int not null) ENGINE=MERGE UNION=(t4,t5);
|
2002-11-05 18:38:27 +01:00
|
|
|
select * from t6;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
2003-07-01 15:49:32 +03:00
|
|
|
drop table t6, t3, t1, t2, t4, t5;
|
2002-11-17 18:58:03 +01:00
|
|
|
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 04:31:42 +00: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 04:31:42 +00: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;
|
2002-11-21 22:25:53 +02:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-12-06 02:00:37 +02:00
|
|
|
1 SIMPLE t2 range PRIMARY PRIMARY 35 NULL 5 Using where
|
2002-11-17 18:58:03 +01:00
|
|
|
EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
|
|
|
|
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
|
2002-11-21 22:25:53 +02:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-12-06 02:00:37 +02:00
|
|
|
1 SIMPLE t2 range PRIMARY,files PRIMARY 35 NULL 5 Using where
|
2002-11-17 18:58:03 +01:00
|
|
|
EXPLAIN SELECT * FROM t1 WHERE fileset_id = 2
|
|
|
|
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
|
2002-11-21 22:25:53 +02:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-12-06 02:00:37 +02:00
|
|
|
1 SIMPLE t1 range PRIMARY,files PRIMARY 35 NULL 5 Using where
|
2002-11-17 18:58:03 +01:00
|
|
|
EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
|
|
|
|
AND file_code = '0000000115' LIMIT 1;
|
2002-11-21 22:25:53 +02:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2006-10-16 18:09:58 +03:00
|
|
|
1 SIMPLE t2 const PRIMARY,files PRIMARY 35 const,const 1
|
2003-01-06 01:48:59 +02:00
|
|
|
DROP TABLE t2, t1;
|
2003-07-03 11:55:36 +03:00
|
|
|
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 04:31:42 +00:00
|
|
|
create table t3 (x int, y int, index xy(x, y)) engine=merge union=(t1,t2);
|
2003-07-03 11:55:36 +03: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;
|
|
|
|
x y
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
select * from t3 where x = 1 and y < 5 order by y desc;
|
|
|
|
x y
|
2003-07-04 14:42:57 +02:00
|
|
|
1 3
|
|
|
|
1 2
|
2003-07-03 11:55:36 +03:00
|
|
|
drop table t1,t2,t3;
|
2004-08-27 16:43:01 +05:00
|
|
|
create table t1 (a int);
|
|
|
|
create table t2 (a int);
|
|
|
|
insert into t1 values (0);
|
|
|
|
insert into t2 values (1);
|
|
|
|
create table t3 engine=merge union=(t1, t2) select * from t1;
|
2004-09-05 02:31:11 +03:00
|
|
|
ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
2004-08-27 16:43:01 +05:00
|
|
|
create table t3 engine=merge union=(t1, t2) select * from t2;
|
2004-09-05 02:31:11 +03:00
|
|
|
ERROR HY000: You can't specify target table 't2' for update in FROM clause
|
2004-09-10 13:09:27 +03:00
|
|
|
create table t3 engine=merge union=(t1, t2) select (select max(a) from t2);
|
|
|
|
ERROR HY000: You can't specify target table 't2' for update in FROM clause
|
2004-08-27 16:43:01 +05:00
|
|
|
drop table t1, t2;
|
2005-09-23 10:15:11 +02:00
|
|
|
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;
|
|
|
|
min(a) max(a)
|
2005-09-29 13:37:30 +02:00
|
|
|
9999999999.9990 9999999999.9990
|
2005-09-23 10:15:11 +02:00
|
|
|
flush tables;
|
|
|
|
select min(a), max(a) from t1;
|
|
|
|
min(a) max(a)
|
2005-09-29 13:37:30 +02:00
|
|
|
9999999999.9990 9999999999.9990
|
2005-09-23 10:15:11 +02:00
|
|
|
drop table t1, t2, t3;
|
2004-11-29 06:51:30 +03:00
|
|
|
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;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t3 ref a a 5 const 2 Using where; Using index
|
|
|
|
select a,b,c from t3 force index (a) where a=1 order by a,b,c;
|
|
|
|
a b c
|
|
|
|
1 1 0
|
|
|
|
1 1 1
|
|
|
|
1 2 0
|
|
|
|
1 2 1
|
|
|
|
explain select a,b,c from t3 force index (a) where a=1 order by a desc, b desc, c desc;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t3 ref a a 5 const 2 Using where; Using index
|
|
|
|
select a,b,c from t3 force index (a) where a=1 order by a desc, b desc, c desc;
|
|
|
|
a b c
|
|
|
|
1 2 1
|
|
|
|
1 2 0
|
|
|
|
1 1 1
|
|
|
|
1 1 0
|
2004-12-27 14:05:35 +02:00
|
|
|
show index from t3;
|
|
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
|
|
|
t3 1 a 1 a A NULL NULL NULL YES BTREE
|
|
|
|
t3 1 a 2 b A NULL NULL NULL YES BTREE
|
|
|
|
t3 1 a 3 c A NULL NULL NULL YES BTREE
|
2004-11-29 06:51:30 +03:00
|
|
|
drop table t1, t2, t3;
|
2005-05-18 19:40:39 +02:00
|
|
|
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;
|
|
|
|
b
|
|
|
|
3
|
|
|
|
DROP TABLE t1, t2;
|
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.1.
Extended the unique table check by a check of lock data.
Merge sub-tables cannot be detected by doing name checks only.
mysql-test/r/create.result:
BUG#5390 - problems with merge tables
Removed a duplicate test.
mysql-test/r/merge.result:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT
Added test results.
mysql-test/t/create.test:
BUG#5390 - problems with merge tables
Removed a duplicate test.
mysql-test/t/merge.test:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT
Added tests.
sql/lock.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.1.
Added a new function to find a duplicate lock in a list of tables.
sql/mysql_priv.h:
Problem #1: INSERT...SELECT, Version for 5.1.
Added the thread handle to unique_table().
Added a declaration for the new function.
sql/sql_base.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.1.
Added the thread handle to unique_table().
Added a call to the new mysql_lock_have_duplicate(),
which needs the thread handle, to unique_table().
sql/sql_delete.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.1.
Added the thread handle to unique_table().
sql/sql_insert.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.1.
Added the thread handle to unique_table().
sql/sql_load.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.1.
Added the thread handle to unique_table().
sql/sql_parse.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.1.
Added the thread handle to unique_table().
sql/sql_update.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.1.
Added the thread handle to unique_table().
Replaced a call to find_table_in_local_list() by
the newly extended unique_table().
2005-12-22 13:48:00 +01:00
|
|
|
create table t1(a int);
|
|
|
|
create table t2(a int);
|
|
|
|
insert into t1 values (1);
|
|
|
|
insert into t2 values (2);
|
|
|
|
create table t3 (a int) engine=merge union=(t1, t2) insert_method=first;
|
|
|
|
select * from t3;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
|
|
|
insert t2 select * from t2;
|
|
|
|
select * from t2;
|
|
|
|
a
|
|
|
|
2
|
|
|
|
2
|
|
|
|
insert t3 select * from t1;
|
|
|
|
select * from t3;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
1
|
|
|
|
2
|
|
|
|
2
|
|
|
|
insert t1 select * from t3;
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
2
|
|
|
|
2
|
|
|
|
select * from t2;
|
|
|
|
a
|
|
|
|
2
|
|
|
|
2
|
|
|
|
select * from t3;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
2
|
|
|
|
2
|
|
|
|
2
|
|
|
|
2
|
|
|
|
check table t1, t2;
|
|
|
|
Table Op Msg_type Msg_text
|
|
|
|
test.t1 check status OK
|
|
|
|
test.t2 check status OK
|
|
|
|
drop table t1, t2, t3;
|
2006-09-28 22:10:06 +05:00
|
|
|
CREATE TABLE t1(a INT);
|
|
|
|
INSERT INTO t1 VALUES(2),(1);
|
|
|
|
CREATE TABLE t2(a INT, KEY(a)) ENGINE=MERGE UNION=(t1);
|
|
|
|
SELECT * FROM t2 WHERE a=2;
|
|
|
|
ERROR HY000: Got error 124 from storage engine
|
|
|
|
DROP TABLE t1, t2;
|
2006-09-27 18:33:31 +05:00
|
|
|
CREATE TABLE t1(a INT) ENGINE=MEMORY;
|
|
|
|
CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1);
|
|
|
|
SELECT * FROM t2;
|
2006-10-06 10:54:47 +05:00
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
2006-09-27 18:33:31 +05:00
|
|
|
DROP TABLE t1, t2;
|
|
|
|
CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3);
|
|
|
|
SELECT * FROM t2;
|
2006-10-06 10:54:47 +05:00
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
2006-09-27 18:33:31 +05:00
|
|
|
DROP TABLE t2;
|
2006-05-30 17:10:53 -07:00
|
|
|
create table t1 (b bit(1));
|
|
|
|
create table t2 (b bit(1));
|
|
|
|
create table tm (b bit(1)) engine = merge union = (t1,t2);
|
|
|
|
select * from tm;
|
|
|
|
b
|
|
|
|
drop table tm, t1, t2;
|
2006-07-11 17:28:50 -07:00
|
|
|
create table t1 (a int) insert_method = last engine = merge;
|
|
|
|
insert into t1 values (1);
|
|
|
|
ERROR HY000: Table 't1' is read only
|
|
|
|
create table t2 (a int) engine = myisam;
|
|
|
|
alter table t1 union (t2);
|
|
|
|
insert into t1 values (1);
|
|
|
|
alter table t1 insert_method = no;
|
|
|
|
insert into t1 values (1);
|
|
|
|
ERROR HY000: Table 't1' is read only
|
|
|
|
drop table t2;
|
|
|
|
drop table t1;
|
|
|
|
End of 5.0 tests
|