2005-03-22 16:10:39 -08:00
drop table if exists t1,t2;
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
) ENGINE=blackhole;
INSERT INTO t1 VALUES (9410,9412);
select period from t1;
period
select * from t1;
Period Varor_period
select t1.* from t1;
Period Varor_period
CREATE TABLE t2 (
auto int NOT NULL auto_increment,
fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL,
companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL,
fld3 char(30) DEFAULT '' NOT NULL,
fld4 char(35) DEFAULT '' NOT NULL,
fld5 char(35) DEFAULT '' NOT NULL,
fld6 char(4) DEFAULT '' NOT NULL,
primary key (auto)
) ENGINE=blackhole;
2005-03-24 16:07:56 -08:00
INSERT INTO t2 VALUES (1192,068305,00,'Colombo','hardware','colicky','');
INSERT INTO t2 VALUES (1193,000000,00,'nondecreasing','implant','thrillingly','');
2005-03-22 16:10:39 -08:00
select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%";
fld3
select fld3 from t2 where fld3 like "%cultivation" ;
fld3
select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3;
fld3 companynr
select fld3,companynr from t2 where companynr = 58 order by fld3;
fld3 companynr
select fld3 from t2 order by fld3 desc limit 10;
fld3
select fld3 from t2 order by fld3 desc limit 5;
fld3
select fld3 from t2 order by fld3 desc limit 5,5;
fld3
select t2.fld3 from t2 where fld3 = 'honeysuckle';
fld3
select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_';
fld3
select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_';
fld3
select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%';
fld3
select t2.fld3 from t2 where fld3 LIKE 'h%le';
fld3
select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_';
fld3
select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%';
fld3
select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
fld3
select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
fld1 fld3
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
('Full-text indexes', 'are called collections'),
('Only MyISAM tables','support collections'),
('Function MATCH ... AGAINST()','is used to do a search'),
('Full-text search in MySQL', 'implements vector space model');
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 a 1 a NULL NULL NULL NULL YES FULLTEXT
t1 1 a 2 b NULL NULL NULL NULL YES FULLTEXT
select * from t1 where MATCH(a,b) AGAINST ("collections");
a b
Only MyISAM tables support collections
Full-text indexes are called collections
explain extended select * from t1 where MATCH(a,b) AGAINST ("collections");
2006-07-28 21:27:01 +04:00
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 fulltext a a 0 1 100.00 Using where
2005-03-22 16:10:39 -08:00
Warnings:
2005-03-25 13:43:42 -08:00
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (match `test`.`t1`.`a`,`test`.`t1`.`b` against (_latin1'collections'))
2005-03-22 16:10:39 -08:00
select * from t1 where MATCH(a,b) AGAINST ("indexes");
a b
Full-text indexes are called collections
select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
a b
Full-text indexes are called collections
Only MyISAM tables support collections
select * from t1 where MATCH(a,b) AGAINST ("only");
a b
2005-04-26 15:52:04 +02:00
reset master;
drop table t1,t2;
create table t1 (a int) engine=blackhole;
delete from t1 where a=10;
update t1 set a=11 where a=15;
insert into t1 values(1);
insert ignore into t1 values(1);
replace into t1 values(100);
create table t2 (a varchar(200)) engine=blackhole;
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/words.dat' into table t2;
2005-04-26 15:52:04 +02:00
alter table t1 add b int;
alter table t1 drop b;
create table t3 like t1;
insert into t1 select * from t3;
replace into t1 select * from t3;
select * from t1;
a
select * from t2;
a
select * from t3;
a
2008-01-21 22:31:31 +08:00
show binlog events;
2005-05-05 14:20:53 +02:00
Log_name Pos Event_type Server_id End_log_pos Info
2008-01-21 22:31:31 +08:00
master-bin.000001 # Format_desc # # Server ver: VERSION, Binlog ver: 4
2007-03-30 10:27:08 +02:00
master-bin.000001 # Query # # use `test`; drop table t1,t2
master-bin.000001 # Query # # use `test`; create table t1 (a int) engine=blackhole
2007-12-14 14:40:45 +01:00
master-bin.000001 # Query # # use `test`; BEGIN
2007-03-30 10:27:08 +02:00
master-bin.000001 # Query # # use `test`; delete from t1 where a=10
2007-12-14 14:40:45 +01:00
master-bin.000001 # Query # # use `test`; COMMIT
master-bin.000001 # Query # # use `test`; BEGIN
2007-03-30 10:27:08 +02:00
master-bin.000001 # Query # # use `test`; update t1 set a=11 where a=15
2007-12-14 14:40:45 +01:00
master-bin.000001 # Query # # use `test`; COMMIT
master-bin.000001 # Query # # use `test`; BEGIN
2007-03-30 10:27:08 +02:00
master-bin.000001 # Query # # use `test`; insert into t1 values(1)
2007-12-14 14:40:45 +01:00
master-bin.000001 # Query # # use `test`; COMMIT
master-bin.000001 # Query # # use `test`; BEGIN
2007-03-30 10:27:08 +02:00
master-bin.000001 # Query # # use `test`; insert ignore into t1 values(1)
2007-12-14 14:40:45 +01:00
master-bin.000001 # Query # # use `test`; COMMIT
master-bin.000001 # Query # # use `test`; BEGIN
2007-03-30 10:27:08 +02:00
master-bin.000001 # Query # # use `test`; replace into t1 values(100)
2007-12-14 14:40:45 +01:00
master-bin.000001 # Query # # use `test`; COMMIT
2007-03-30 10:27:08 +02:00
master-bin.000001 # Query # # use `test`; create table t2 (a varchar(200)) engine=blackhole
2007-12-14 14:40:45 +01:00
master-bin.000001 # Query # # use `test`; BEGIN
2008-01-29 14:43:41 +01:00
master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=581
master-bin.000001 # Execute_load_query # # use `test`; load data infile '../std_data_ln/words.dat' into table t2 ;file_id=#
2007-12-14 14:40:45 +01:00
master-bin.000001 # Query # # use `test`; COMMIT
2007-03-30 10:27:08 +02:00
master-bin.000001 # Query # # use `test`; alter table t1 add b int
master-bin.000001 # Query # # use `test`; alter table t1 drop b
master-bin.000001 # Query # # use `test`; create table t3 like t1
2007-12-14 14:40:45 +01:00
master-bin.000001 # Query # # use `test`; BEGIN
2007-03-30 10:27:08 +02:00
master-bin.000001 # Query # # use `test`; insert into t1 select * from t3
2007-12-14 14:40:45 +01:00
master-bin.000001 # Query # # use `test`; COMMIT
master-bin.000001 # Query # # use `test`; BEGIN
2007-03-30 10:27:08 +02:00
master-bin.000001 # Query # # use `test`; replace into t1 select * from t3
2007-12-14 14:40:45 +01:00
master-bin.000001 # Query # # use `test`; COMMIT
2005-04-26 15:52:04 +02:00
drop table t1,t2,t3;
2007-04-28 14:37:40 +05:00
CREATE TABLE t1(a INT) ENGINE=BLACKHOLE;
INSERT DELAYED INTO t1 VALUES(1);
Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
corrupts a MERGE table
Bug 26867 - LOCK TABLES + REPAIR + merge table result in
memory/cpu hogging
Bug 26377 - Deadlock with MERGE and FLUSH TABLE
Bug 25038 - Waiting TRUNCATE
Bug 25700 - merge base tables get corrupted by
optimize/analyze/repair table
Bug 30275 - Merge tables: flush tables or unlock tables
causes server to crash
Bug 19627 - temporary merge table locking
Bug 27660 - Falcon: merge table possible
Bug 30273 - merge tables: Can't lock file (errno: 155)
The problems were:
Bug 26379 - Combination of FLUSH TABLE and REPAIR TABLE
corrupts a MERGE table
1. A thread trying to lock a MERGE table performs busy waiting while
REPAIR TABLE or a similar table administration task is ongoing on
one or more of its MyISAM tables.
2. A thread trying to lock a MERGE table performs busy waiting until all
threads that did REPAIR TABLE or similar table administration tasks
on one or more of its MyISAM tables in LOCK TABLES segments do UNLOCK
TABLES. The difference against problem #1 is that the busy waiting
takes place *after* the administration task. It is terminated by
UNLOCK TABLES only.
3. Two FLUSH TABLES within a LOCK TABLES segment can invalidate the
lock. This does *not* require a MERGE table. The first FLUSH TABLES
can be replaced by any statement that requires other threads to
reopen the table. In 5.0 and 5.1 a single FLUSH TABLES can provoke
the problem.
Bug 26867 - LOCK TABLES + REPAIR + merge table result in
memory/cpu hogging
Trying DML on a MERGE table, which has a child locked and
repaired by another thread, made an infinite loop in the server.
Bug 26377 - Deadlock with MERGE and FLUSH TABLE
Locking a MERGE table and its children in parent-child order
and flushing the child deadlocked the server.
Bug 25038 - Waiting TRUNCATE
Truncating a MERGE child, while the MERGE table was in use,
let the truncate fail instead of waiting for the table to
become free.
Bug 25700 - merge base tables get corrupted by
optimize/analyze/repair table
Repairing a child of an open MERGE table corrupted the child.
It was necessary to FLUSH the child first.
Bug 30275 - Merge tables: flush tables or unlock tables
causes server to crash
Flushing and optimizing locked MERGE children crashed the server.
Bug 19627 - temporary merge table locking
Use of a temporary MERGE table with non-temporary children
could corrupt the children.
Temporary tables are never locked. So we do now prohibit
non-temporary chidlren of a temporary MERGE table.
Bug 27660 - Falcon: merge table possible
It was possible to create a MERGE table with non-MyISAM children.
Bug 30273 - merge tables: Can't lock file (errno: 155)
This was a Windows-only bug. Table administration statements
sometimes failed with "Can't lock file (errno: 155)".
These bugs are fixed by a new implementation of MERGE table open.
When opening a MERGE table in open_tables() we do now add the
child tables to the list of tables to be opened by open_tables()
(the "query_list"). The children are not opened in the handler at
this stage.
After opening the parent, open_tables() opens each child from the
now extended query_list. When the last child is opened, we remove
the children from the query_list again and attach the children to
the parent. This behaves similar to the old open. However it does
not open the MyISAM tables directly, but grabs them from the already
open children.
When closing a MERGE table in close_thread_table() we detach the
children only. Closing of the children is done implicitly because
they are in thd->open_tables.
For more detail see the comment at the top of ha_myisammrg.cc.
Changed from open_ltable() to open_and_lock_tables() in all places
that can be relevant for MERGE tables. The latter can handle tables
added to the list on the fly. When open_ltable() was used in a loop
over a list of tables, the list must be temporarily terminated
after every table for open_and_lock_tables().
table_list->required_type is set to FRMTYPE_TABLE to avoid open of
special tables. Handling of derived tables is suppressed.
These details are handled by the new function
open_n_lock_single_table(), which has nearly the same signature as
open_ltable() and can replace it in most cases.
In reopen_tables() some of the tables open by a thread can be
closed and reopened. When a MERGE child is affected, the parent
must be closed and reopened too. Closing of the parent is forced
before the first child is closed. Reopen happens in the order of
thd->open_tables. MERGE parents do not attach their children
automatically at open. This is done after all tables are reopened.
So all children are open when attaching them.
Special lock handling like mysql_lock_abort() or mysql_lock_remove()
needs to be suppressed for MERGE children or forwarded to the parent.
This depends on the situation. In loops over all open tables one
suppresses child lock handling. When a single table is touched,
forwarding is done.
Behavioral changes:
===================
This patch changes the behavior of temporary MERGE tables.
Temporary MERGE must have temporary children.
The old behavior was wrong. A temporary table is not locked. Hence
even non-temporary children were not locked. See
Bug 19627 - temporary merge table locking.
You cannot change the union list of a non-temporary MERGE table
when LOCK TABLES is in effect. The following does *not* work:
CREATE TABLE m1 ... ENGINE=MRG_MYISAM ...;
LOCK TABLES t1 WRITE, t2 WRITE, m1 WRITE;
ALTER TABLE m1 ... UNION=(t1,t2) ...;
However, you can do this with a temporary MERGE table.
You cannot create a MERGE table with CREATE ... SELECT, neither
as a temporary MERGE table, nor as a non-temporary MERGE table.
CREATE TABLE m1 ... ENGINE=MRG_MYISAM ... SELECT ...;
Gives error message: table is not BASE TABLE.
2007-11-15 20:25:43 +01:00
ERROR HY000: Binary logging not possible. Message: Row-based format required for this statement, but not allowed by this combination of engines
2007-04-28 14:37:40 +05:00
DROP TABLE t1;
2007-02-14 18:35:59 +02:00
CREATE TABLE t1(a INT, b INT) ENGINE=BLACKHOLE;
DELETE FROM t1 WHERE a=10;
ALTER TABLE t1 ADD INDEX(a);
DELETE FROM t1 WHERE a=10;
ALTER TABLE t1 DROP INDEX a;
ALTER TABLE t1 ADD UNIQUE INDEX(a);
DELETE FROM t1 WHERE a=10;
ALTER TABLE t1 DROP INDEX a;
ALTER TABLE t1 ADD PRIMARY KEY(a);
DELETE FROM t1 WHERE a=10;
DROP TABLE t1;
2005-12-02 01:11:49 +01:00
reset master;
create table t1 (a int) engine=blackhole;
set autocommit=0;
start transaction;
insert into t1 values(1);
commit;
start transaction;
insert into t1 values(2);
rollback;
set autocommit=1;
2008-01-21 22:31:31 +08:00
show binlog events;
2005-12-02 01:11:49 +01:00
Log_name Pos Event_type Server_id End_log_pos Info
2008-01-21 22:31:31 +08:00
master-bin.000001 # Format_desc # # Server ver: VERSION, Binlog ver: 4
2007-03-30 10:27:08 +02:00
master-bin.000001 # Query # # use `test`; create table t1 (a int) engine=blackhole
master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Query # # use `test`; insert into t1 values(1)
master-bin.000001 # Query # # use `test`; COMMIT
2006-05-09 13:31:46 -07:00
drop table if exists t1;