mariadb/mysql-test/suite/maria/lock.result
Monty 2f3779d31c Fixes for Aria transaction handling with lock tables
MDEV-10130 Assertion `share->in_trans == 0' failed in storage/maria/ma_close.c
MDEV-10378 Assertion `trn' failed in virtual int ha_maria::start_stmt

The problem was that maria_handler->trn was not properly reset
at commit/rollback and ha_maria::exernal_lock() could get confused
because.

There was some old code in ha_maria::implicit_commit() that tried
to take care of this, but it was not bullet proof.

Fixed by adding list of all tables that is part of the maria transaction to
TRN.

A nice side effect was of the fix is that loops in
ha_maria::implict_commit() got to be much simpler.

Other things:
- Fixed a bug in mysql_admin_table() where argument open_for_modify
  was wrongly reset for the next table in the chain
- rollback admin command also in case of fatal error.
- Split _ma_set_trn_for_table() to three version to simplify code
  and debugging.
- Several new asserts to detect the original problem (that file was
  not properly removed from trn before calling ma_close())
2018-05-22 23:05:48 +03:00

111 lines
3.3 KiB
Text

drop table if exists t1,t2;
Warnings:
Note 1051 Unknown table 'test.t1'
Note 1051 Unknown table 'test.t2'
CREATE TABLE t1 (i INT) ENGINE=Aria;
CREATE TABLE t2 (i INT) ENGINE=Aria;
LOCK TABLE t1 WRITE, t2 WRITE;
DROP TABLE t1;
UNLOCK TABLES;
DROP TABLE t2;
CREATE TABLE t1 (i INT) ENGINE=Aria;
CREATE TABLE t2 (i INT) ENGINE=Aria;
LOCK TABLE t1 WRITE, t2 WRITE;
FLUSH TABLE t1;
select * from t1;
i
unlock tables;
drop table t1,t2;
CREATE TABLE t1 (i INT) ENGINE=Aria;
CREATE TABLE t2 (i INT) ENGINE=Aria;
LOCK TABLE t1 WRITE, t2 WRITE;
repair table t1 use_frm;
Table Op Msg_type Msg_text
test.t1 repair status OK
select * from t1;
i
drop table t2;
unlock tables;
drop table t1;
CREATE TABLE t1 (i INT) ENGINE=Aria;
LOCK TABLES t1 WRITE, t1 AS t1a WRITE;
DROP TABLE t1;
#
# MDEV-8200 aria bug with insert select when select is a aria table
# (wrong result or assertion failure:
# `table->file->stats.records > 0 || error')
#
CREATE TABLE t1 (f1 INT) ENGINE=Aria;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) DEFAULT NULL
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
INSERT INTO t1 VALUES (1);
CREATE TABLE t2 (f2 INT) ENGINE=MyISAM;
CREATE TABLE tmp (f3 INT) engine=Aria;
LOCK TABLE t2 WRITE, tmp WRITE, tmp AS tmp_alias WRITE, t1 WRITE;
INSERT INTO tmp SELECT f1 FROM t1;
INSERT INTO t2 SELECT f3 FROM tmp AS tmp_alias;
select * from t2;
f2
1
unlock tables;
DROP TABLE t1,t2,tmp;
#
# Same without transactional
#
CREATE TABLE t1 (f1 INT) transactional=0 ENGINE=Aria;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) DEFAULT NULL
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
INSERT INTO t1 VALUES (2);
CREATE TABLE t2 (f2 INT) ENGINE=MyISAM;
CREATE TABLE tmp (f3 INT) transactional=0 engine=Aria;
LOCK TABLE t2 WRITE, tmp WRITE, tmp AS tmp_alias WRITE, t1 WRITE;
INSERT INTO tmp SELECT f1 FROM t1;
INSERT INTO t2 SELECT f3 FROM tmp AS tmp_alias;
select * from t2;
f2
2
unlock tables;
DROP TABLE t1,t2,tmp;
#
# Using spatical keys (disables versioning)
#
CREATE TABLE t1 (f1 INT, c1 geometry NOT NULL, SPATIAL KEY i1 (c1)) transactional=1 ENGINE=Aria;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) DEFAULT NULL,
`c1` geometry NOT NULL,
SPATIAL KEY `i1` (`c1`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
INSERT INTO t1 VALUES (3,
PolygonFromText('POLYGON((-18.6086111000 -66.9327777000,
-18.6055555000 -66.8158332999,
-18.7186111000 -66.8102777000,
-18.7211111000 -66.9269443999,
-18.6086111000 -66.9327777000))'));
CREATE TABLE t2 (f2 INT) ENGINE=MyISAM;
CREATE TABLE tmp (f3 INT, c1 geometry NOT NULL, SPATIAL KEY i1 (c1)) transactional=1 ENGINE=Aria;
LOCK TABLE t2 WRITE, tmp WRITE, tmp AS tmp_alias WRITE, t1 WRITE;
INSERT INTO tmp SELECT f1,c1 FROM t1;
INSERT INTO t2 (f2) SELECT f3 FROM tmp AS tmp_alias;
select * from t2;
f2
3
unlock tables;
DROP TABLE t1,t2,tmp;
#
# MDEV-10378 Assertion `trn' failed in virtual int ha_maria::start_stmt
#
CREATE TABLE t1 (f1 VARCHAR(3), f2 INT, pk INT, PRIMARY KEY (pk)) ENGINE=Aria;
INSERT INTO t1 VALUES ('foo',10,1), ('foo',1,2);
LOCK TABLE t1 WRITE;
ALTER TABLE t1 ADD UNIQUE KEY (f1);
ERROR 23000: Duplicate entry 'foo' for key 'f1'
ALTER TABLE t1 ADD KEY (f2);
DROP TABLE t1;