Skip to content

Commit 72d6708

Browse files
author
Nisha Gopalakrishnan
committed
BUG#11748842:CREATE TABLE: NO WARNING IF REQUESTED DUPLICATE INDEX FOR
THE SAME COLUMN. Analysis: -------- Creation of duplicate index is allowed since the logic to detect the duplicate index has not been implemented. Fix: --- A new member 'key_is_set_by_user' has been added to struct KEY_CREATE_INFO. This member is set when a index is created or modified by the user. An SQL-condition of the WARNING level is reported upon execution of such a DDL statement if all the following conditions are satisfied: a) Index types[BTREE|HASH] are the same. b) Key constraint/indexes are the same. c) The constraint/indexes fields are in the same order. However this does not apply to the foreign key constraint. The SQL-condition is propagated to the ERROR level under the STRICT mode condition.
1 parent f17d251 commit 72d6708

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+474
-31
lines changed

mysql-test/extra/rpl_tests/rpl_loaddata.test

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ save_master_pos;
7070
connection slave;
7171
# 1062 = ER_DUP_ENTRY
7272
call mtr.add_suppression("Slave SQL.*Error .Duplicate entry .10. for key .b.. on query.* Error_code: 1062");
73-
call mtr.add_suppression("Slave SQL.*Query caused different errors on master and slave.*Error on master:.*error code=1062.*Error on slave:.*Error_code: 1833");
73+
call mtr.add_suppression("Slave SQL.*Query caused different errors on master and slave.*Error on master:.*error code=1062.*Error on slave:.*Error_code: 1834");
7474
call mtr.add_suppression("The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state");
7575
--let $slave_sql_errno= 1062
7676
--source include/wait_for_slave_sql_error_and_skip.inc
@@ -161,10 +161,10 @@ if (`SELECT @@global.binlog_format != 'ROW'`)
161161
# Query causes error on master but not on slave. This causes the slave to
162162
# stop with error code 0 (which is wrong: see BUG#57287)
163163
# A new error code ER_INCONSISTENT_ERROR has been introduced instead of 0.
164-
# The error code is 1833
164+
# The error code is 1834
165165
# ER_MTS_INCONSISTENT_DATA
166-
#1833 = ER_INCONSISTENT_ERROR
167-
--let $slave_sql_errno= 1833,1756
166+
#1834 = ER_INCONSISTENT_ERROR
167+
--let $slave_sql_errno= 1834,1756
168168
--source include/wait_for_slave_sql_error.inc
169169
drop table t1, t2;
170170
}

mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ insert into t1 values(1),(2);
2424
drop table t1;
2525

2626
connection slave;
27-
call mtr.add_suppression("Slave SQL.*Query caused different errors on master and slave.*Error on master:.* error code=1062.*Error on slave:.* Error_code: 1833");
27+
call mtr.add_suppression("Slave SQL.*Query caused different errors on master and slave.*Error on master:.* error code=1062.*Error on slave:.* Error_code: 1834");
2828
call mtr.add_suppression("The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state");
2929

3030
--echo (expect different error codes on master and slave)
3131
# ER_MTS_INCONSISTENT_DATA
32-
#1833 = ER_INCONSISTENT_ERROR
33-
--let $slave_sql_errno= 1833,1756
32+
#1834 = ER_INCONSISTENT_ERROR
33+
--let $slave_sql_errno= 1834,1756
3434
# can't print error text. MTS reports a separate error in this case.
3535
# Todo: to fix single-threaded-slave BUG#57287.
3636
--let $show_slave_sql_error= 0

mysql-test/r/alter_table.result

+39-13
Original file line numberDiff line numberDiff line change
@@ -1497,13 +1497,19 @@ affected rows: 0
14971497
info: Records: 0 Duplicates: 0 Warnings: 0
14981498
ALTER TABLE t1 ADD INDEX i2(b), ALGORITHM= DEFAULT;
14991499
affected rows: 0
1500-
info: Records: 0 Duplicates: 0 Warnings: 0
1500+
info: Records: 0 Duplicates: 0 Warnings: 1
1501+
Warnings:
1502+
Warning 1831 Duplicate index 'i2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
15011503
ALTER TABLE t1 ADD INDEX i3(b), ALGORITHM= COPY;
15021504
affected rows: 2
1503-
info: Records: 2 Duplicates: 0 Warnings: 0
1505+
info: Records: 2 Duplicates: 0 Warnings: 1
1506+
Warnings:
1507+
Warning 1831 Duplicate index 'i3' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
15041508
ALTER TABLE t1 ADD INDEX i4(b), ALGORITHM= INPLACE;
15051509
affected rows: 0
1506-
info: Records: 0 Duplicates: 0 Warnings: 0
1510+
info: Records: 0 Duplicates: 0 Warnings: 1
1511+
Warnings:
1512+
Warning 1831 Duplicate index 'i4' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
15071513
ALTER TABLE t1 ADD INDEX i5(b), ALGORITHM= INVALID;
15081514
ERROR HY000: Unknown ALGORITHM 'INVALID'
15091515
ALTER TABLE m1 ENABLE KEYS;
@@ -1526,13 +1532,19 @@ affected rows: 2
15261532
info: Records: 2 Duplicates: 0 Warnings: 0
15271533
ALTER TABLE t1 ADD INDEX i2(b), ALGORITHM= DEFAULT;
15281534
affected rows: 2
1529-
info: Records: 2 Duplicates: 0 Warnings: 0
1535+
info: Records: 2 Duplicates: 0 Warnings: 1
1536+
Warnings:
1537+
Warning 1831 Duplicate index 'i2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
15301538
ALTER TABLE t1 ADD INDEX i3(b), ALGORITHM= COPY;
15311539
affected rows: 2
1532-
info: Records: 2 Duplicates: 0 Warnings: 0
1540+
info: Records: 2 Duplicates: 0 Warnings: 1
1541+
Warnings:
1542+
Warning 1831 Duplicate index 'i3' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
15331543
ALTER TABLE t1 ADD INDEX i4(b), ALGORITHM= INPLACE;
15341544
affected rows: 0
1535-
info: Records: 0 Duplicates: 0 Warnings: 0
1545+
info: Records: 0 Duplicates: 0 Warnings: 1
1546+
Warnings:
1547+
Warning 1831 Duplicate index 'i4' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
15361548
SET SESSION old_alter_table= 0;
15371549
affected rows: 0
15381550
ALTER TABLE t1 DROP INDEX i1, DROP INDEX i2, DROP INDEX i3, DROP INDEX i4;
@@ -1552,13 +1564,19 @@ affected rows: 0
15521564
info: Records: 0 Duplicates: 0 Warnings: 0
15531565
ALTER TABLE t1 ADD INDEX i2(b), LOCK= NONE;
15541566
affected rows: 0
1555-
info: Records: 0 Duplicates: 0 Warnings: 0
1567+
info: Records: 0 Duplicates: 0 Warnings: 1
1568+
Warnings:
1569+
Warning 1831 Duplicate index 'i2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
15561570
ALTER TABLE t1 ADD INDEX i3(b), LOCK= SHARED;
15571571
affected rows: 0
1558-
info: Records: 0 Duplicates: 0 Warnings: 0
1572+
info: Records: 0 Duplicates: 0 Warnings: 1
1573+
Warnings:
1574+
Warning 1831 Duplicate index 'i3' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
15591575
ALTER TABLE t1 ADD INDEX i4(b), LOCK= EXCLUSIVE;
15601576
affected rows: 0
1561-
info: Records: 0 Duplicates: 0 Warnings: 0
1577+
info: Records: 0 Duplicates: 0 Warnings: 1
1578+
Warnings:
1579+
Warning 1831 Duplicate index 'i4' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
15621580
ALTER TABLE t1 ADD INDEX i5(b), LOCK= INVALID;
15631581
ERROR HY000: Unknown LOCK type 'INVALID'
15641582
ALTER TABLE m1 ENABLE KEYS, LOCK= DEFAULT;
@@ -1576,18 +1594,26 @@ affected rows: 0
15761594
info: Records: 0 Duplicates: 0 Warnings: 0
15771595
ALTER TABLE t1 ADD INDEX i2(b), ALGORITHM= INPLACE, LOCK= SHARED;
15781596
affected rows: 0
1579-
info: Records: 0 Duplicates: 0 Warnings: 0
1597+
info: Records: 0 Duplicates: 0 Warnings: 1
1598+
Warnings:
1599+
Warning 1831 Duplicate index 'i2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
15801600
ALTER TABLE t1 ADD INDEX i3(b), ALGORITHM= INPLACE, LOCK= EXCLUSIVE;
15811601
affected rows: 0
1582-
info: Records: 0 Duplicates: 0 Warnings: 0
1602+
info: Records: 0 Duplicates: 0 Warnings: 1
1603+
Warnings:
1604+
Warning 1831 Duplicate index 'i3' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
15831605
ALTER TABLE t1 ADD INDEX i4(b), ALGORITHM= COPY, LOCK= NONE;
15841606
ERROR 42000: This version of MySQL doesn't yet support 'ALTER TABLE t1 ADD INDEX i4(b), ALGORITHM= COPY, LOCK= NONE'
15851607
ALTER TABLE t1 ADD INDEX i5(b), ALGORITHM= COPY, LOCK= SHARED;
15861608
affected rows: 2
1587-
info: Records: 2 Duplicates: 0 Warnings: 0
1609+
info: Records: 2 Duplicates: 0 Warnings: 1
1610+
Warnings:
1611+
Warning 1831 Duplicate index 'i5' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
15881612
ALTER TABLE t1 ADD INDEX i6(b), ALGORITHM= COPY, LOCK= EXCLUSIVE;
15891613
affected rows: 2
1590-
info: Records: 2 Duplicates: 0 Warnings: 0
1614+
info: Records: 2 Duplicates: 0 Warnings: 1
1615+
Warnings:
1616+
Warning 1831 Duplicate index 'i6' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
15911617
ALTER TABLE m1 ENABLE KEYS, ALGORITHM= INPLACE, LOCK= NONE;
15921618
ERROR 42000: This version of MySQL doesn't yet support 'ALTER TABLE m1 ENABLE KEYS, ALGORITHM= INPLACE, LOCK= NONE'
15931619
ALTER TABLE m1 ENABLE KEYS, ALGORITHM= INPLACE, LOCK= SHARED;

mysql-test/r/check.result

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
drop table if exists t1,t2;
22
drop view if exists v1;
33
create table t1(n int not null, key(n), key(n), key(n), key(n));
4+
Warnings:
5+
Warning 1831 Duplicate index 'n_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
6+
Warning 1831 Duplicate index 'n_3' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
7+
Warning 1831 Duplicate index 'n_4' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
48
check table t1 extended;
59
insert into t1 values (200000);
610
Table Op Msg_type Msg_text

mysql-test/r/constraints.result

+4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ drop table t1;
1717
create table t1 (a int null);
1818
alter table t1 add constraint constraint_1 unique (a);
1919
alter table t1 add constraint unique key_1(a);
20+
Warnings:
21+
Warning 1831 Duplicate index 'key_1' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
2022
alter table t1 add constraint constraint_2 unique key_2(a);
23+
Warnings:
24+
Warning 1831 Duplicate index 'key_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
2125
show create table t1;
2226
Table Create Table
2327
t1 CREATE TABLE `t1` (

0 commit comments

Comments
 (0)