Skip to content

Commit ac66465

Browse files
author
Sai Tharun Ambati
committed
Merge branch 'mysql-8.0' into mysql-8.4
Change-Id: I6eac134fc97069f2d4106a66a1707f7092475500
2 parents 646febf + 0254883 commit ac66465

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Create database and tables
2+
CREATE DATABASE testdb;
3+
USE testdb;
4+
CREATE TABLE t1 ( id int );
5+
INSERT INTO t1 VALUES (1);
6+
INSERT INTO t1 SELECT * FROM t1;
7+
INSERT INTO t1 SELECT * FROM t1;
8+
INSERT INTO t1 SELECT * FROM t1;
9+
INSERT INTO t1 SELECT * FROM t1;
10+
INSERT INTO t1 SELECT * FROM t1;
11+
CREATE TABLE t2 ( id int );
12+
INSERT INTO t2 SELECT * FROM t1;
13+
CREATE TABLE t3 (
14+
id INT
15+
)
16+
PARTITION BY RANGE (id) (
17+
PARTITION p0 VALUES LESS THAN (1000),
18+
PARTITION p1 VALUES LESS THAN (2000),
19+
PARTITION p2 VALUES LESS THAN (3000)
20+
);
21+
INSERT INTO t3 VALUES (800);
22+
INSERT INTO t3 VALUES (1500);
23+
INSERT INTO t3 VALUES (2300);
24+
BEGIN;
25+
SELECT COUNT(*) FROM t1;
26+
COUNT(*)
27+
32
28+
# Alter the partition table.
29+
ALTER TABLE testdb.t3 ADD COLUMN name varchar(10);
30+
# SELECT COUNT(*) must fail as the table definition is changed.
31+
SELECT COUNT(*) FROM testdb.t3;
32+
ERROR HY000: Table definition has changed, please retry transaction
33+
# SELECT * must fail as the table definition is changed.
34+
SELECT * FROM testdb.t3;
35+
ERROR HY000: Table definition has changed, please retry transaction
36+
# Clean up
37+
DROP DATABASE testdb;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
--connect (con1,localhost,root,,)
2+
--echo # Create database and tables
3+
CREATE DATABASE testdb;
4+
USE testdb;
5+
6+
CREATE TABLE t1 ( id int );
7+
INSERT INTO t1 VALUES (1);
8+
INSERT INTO t1 SELECT * FROM t1;
9+
INSERT INTO t1 SELECT * FROM t1;
10+
INSERT INTO t1 SELECT * FROM t1;
11+
INSERT INTO t1 SELECT * FROM t1;
12+
INSERT INTO t1 SELECT * FROM t1;
13+
14+
CREATE TABLE t2 ( id int );
15+
INSERT INTO t2 SELECT * FROM t1;
16+
17+
CREATE TABLE t3 (
18+
id INT
19+
)
20+
PARTITION BY RANGE (id) (
21+
PARTITION p0 VALUES LESS THAN (1000),
22+
PARTITION p1 VALUES LESS THAN (2000),
23+
PARTITION p2 VALUES LESS THAN (3000)
24+
);
25+
INSERT INTO t3 VALUES (800);
26+
INSERT INTO t3 VALUES (1500);
27+
INSERT INTO t3 VALUES (2300);
28+
29+
BEGIN;
30+
SELECT COUNT(*) FROM t1;
31+
32+
--connect (con2,localhost,root,,)
33+
--echo # Alter the partition table.
34+
ALTER TABLE testdb.t3 ADD COLUMN name varchar(10);
35+
36+
--connection con1
37+
--echo # SELECT COUNT(*) must fail as the table definition is changed.
38+
--error ER_TABLE_DEF_CHANGED
39+
SELECT COUNT(*) FROM testdb.t3;
40+
41+
--echo # SELECT * must fail as the table definition is changed.
42+
--error ER_TABLE_DEF_CHANGED
43+
SELECT * FROM testdb.t3;
44+
45+
--echo # Clean up
46+
DROP DATABASE testdb;

storage/innobase/handler/ha_innopart.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3215,6 +3215,12 @@ int ha_innopart::records(ha_rows *num_rows) {
32153215
return (HA_ERR_NO_SUCH_TABLE);
32163216
}
32173217

3218+
m_prebuilt->index_usable = m_prebuilt->index->is_usable(trx);
3219+
if (!m_prebuilt->index_usable) {
3220+
*num_rows = HA_POS_ERROR;
3221+
return HA_ERR_TABLE_DEF_CHANGED;
3222+
}
3223+
32183224
build_template(true);
32193225

32203226
indexes.push_back(m_prebuilt->table->first_index());

0 commit comments

Comments
 (0)