mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
1f18bd630a
This bug happens when locking the same Aria "transactional" table (page format) more then once with LOCK TABLES and inserting into one of them with INSERT ... SELECT when the table is empty. Fixed by ensuring we don't use fast bulk insert if table is opened twice with LOCK TABLES (as this changes table->s->state) Code changes: - Added use_count to MARIA_USED_TABLES to be able to check if table is opened twice for a statement/lock table - Don't clear history or reset info->start_state if we don't have versioning. One reason for the bug was was that info->start_state was set to point to different states for the two tables. If there is no versioning info->start_state should always point to info->s->state.common. Other things: - Fixed also some typos that was noticed while scanning the code - More DBUG_PRINT
101 lines
3 KiB
Text
101 lines
3 KiB
Text
drop table if exists t1,t2;
|
|
Warnings:
|
|
Note 1051 Unknown table 't1'
|
|
Note 1051 Unknown table '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;
|