Skip to content
Permalink
Browse files

MDEV-17544 No warning when trying to name a primary key constraint.

Warning added.
  • Loading branch information...
Alexey Botchkov
Alexey Botchkov committed Jul 30, 2019
1 parent 4b5a14d commit c6efbc543d6fb3004f320ef9d02542a4692ca88a
Showing with 115 additions and 19 deletions.
  1. +4 −0 mysql-test/main/create.result
  2. +7 −0 mysql-test/main/create.test
  3. +2 −0 mysql-test/main/ctype_collate.result
  4. +2 −0 mysql-test/main/ctype_latin2_ch.result
  5. +4 −0 mysql-test/main/gis.result
  6. +2 −0 mysql-test/main/join_cache.result
  7. +8 −8 mysql-test/main/system_mysql_db_fix50117.test
  8. +2 −0 mysql-test/suite/binlog_encryption/multisource.result
  9. +4 −0 mysql-test/suite/galera/r/GAL-382.result
  10. +6 −0 mysql-test/suite/innodb/r/innodb-index-online-fk.result
  11. +8 −0 mysql-test/suite/innodb/r/innodb-virtual-columns.result
  12. +2 −0 mysql-test/suite/innodb/r/innodb_bug51378.result
  13. +6 −0 mysql-test/suite/innodb/r/innodb_bug60229.result
  14. +4 −0 mysql-test/suite/innodb_gis/r/1.result
  15. +4 −0 mysql-test/suite/innodb_gis/r/gis.result
  16. +4 −0 mysql-test/suite/innodb_zip/r/page_size.result
  17. +4 −0 mysql-test/suite/innodb_zip/r/prefix_index_liftedlimit.result
  18. +2 −0 mysql-test/suite/multi_source/multisource.result
  19. +4 −0 mysql-test/suite/parts/r/alter_data_directory_innodb.result
  20. +2 −0 mysql-test/suite/rpl/r/rpl_blackhole.result
  21. +2 −0 mysql-test/suite/rpl/r/rpl_blackhole_row_annotate.result
  22. +3 −1 mysql-test/suite/versioning/r/online.result
  23. +3 −1 mysql-test/suite/versioning/r/trx_id.result
  24. +9 −9 scripts/mysql_system_tables.sql
  25. +11 −0 sql/sql_table.cc
  26. +2 −0 storage/mroonga/mysql-test/mroonga/storage/r/index_multiple_column_select_varchar.result
  27. +2 −0 storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace.result
  28. +2 −0 storage/rocksdb/mysql-test/rocksdb/r/index_key_block_size.result
@@ -2093,3 +2093,7 @@ create table t1 (i int, j int, key(i), key(i)) as select 1 as i, 2 as j;
Warnings:
Note 1831 Duplicate index `i_2`. This is deprecated and will be disallowed in a future release
drop table t1;
CREATE TABLE t1 ( id1 INT, id2 INT, CONSTRAINT `foo` PRIMARY KEY (id1), CONSTRAINT `bar` UNIQUE KEY(id2));
Warnings:
Warning 1280 Name 'foo' ignored for PRIMARY key.
DROP TABLE t1;
@@ -1941,3 +1941,10 @@ create table t1;
#
create table t1 (i int, j int, key(i), key(i)) as select 1 as i, 2 as j;
drop table t1;

#
# MDEV-17544 No warning when trying to name a primary key constraint.
#
CREATE TABLE t1 ( id1 INT, id2 INT, CONSTRAINT `foo` PRIMARY KEY (id1), CONSTRAINT `bar` UNIQUE KEY(id2));
DROP TABLE t1;

@@ -732,6 +732,8 @@ CREATE TABLE t1 (
b LONGTEXT CHARACTER SET "latin1" COLLATE "latin1_bin",
PRIMARY KEY b (b(32))
);
Warnings:
Warning 1280 Name 'b' ignored for PRIMARY key.
INSERT INTO t1 (b) VALUES ('a'), (_binary 0x1), (_binary 0x0), ('');
explain
select hex(b) from t1 force index (PRIMARY) where b<'zzz';
@@ -10,6 +10,8 @@ tt char(255) not null
insert into t1 values (1,'Aa');
insert into t1 values (2,'Aas');
alter table t1 add primary key aaa(tt);
Warnings:
Warning 1280 Name 'aaa' ignored for PRIMARY key.
select * from t1 where tt like 'Aa%';
id tt
1 Aa
@@ -816,11 +816,15 @@ POINT(1 1)
drop function fn3;
create table t1(pt POINT);
alter table t1 add primary key pti(pt);
Warnings:
Warning 1280 Name 'pti' ignored for PRIMARY key.
drop table t1;
create table t1(pt GEOMETRY);
alter table t1 add primary key pti(pt);
ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length
alter table t1 add primary key pti(pt(20));
Warnings:
Warning 1280 Name 'pti' ignored for PRIMARY key.
drop table t1;
create table t1 select GeomFromText('point(1 1)');
desc t1;
@@ -3103,6 +3103,8 @@ CREATE TABLE t2 (
a2 int, b2 int, filler2 char(64) default ' ',
PRIMARY KEY idx(a2,b2,filler2)
) ;
Warnings:
Warning 1280 Name 'idx' ignored for PRIMARY key.
CREATE TABLE t3 (b3 int, c3 int, INDEX idx(b3));
INSERT INTO t1(a1) VALUES
(4), (7), (1), (9), (8), (5), (3), (6), (2);

Large diffs are not rendered by default.

@@ -47,6 +47,8 @@ drop database if exists db1;
create database db1;
use db1;
create table t1 (i int auto_increment, f1 varchar(16), primary key pk (i,f1)) engine=MyISAM;
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
insert into t1 (f1) values ('one'),('two');
connection slave;
select * from db1.t1;
@@ -1,7 +1,11 @@
connection node_1;
create table t1 (i int, j int, k int, primary key pk(i)) engine=innodb;
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3);
create table t2 (i int, j int, k int, primary key pk(i, j, k), index idx(i, k, j)) engine=innodb;
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
replace into t2 (i, j, k) select /*!99997 */ i, k, j from t1;
DROP TABLE t1;
DROP TABLE t2;
@@ -326,6 +326,8 @@ ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT,
ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
Warnings:
Warning 1280 Name 'idx' ignored for PRIMARY key.
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_1 test/child test/parent 1 6
@@ -363,6 +365,8 @@ ALTER TABLE child ADD PRIMARY KEY idx (a1),
ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE;
Warnings:
Warning 1280 Name 'idx' ignored for PRIMARY key.
SELECT * from information_schema.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_1 test/child test/parent 1 6
@@ -556,6 +560,8 @@ ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1) REFERENCES parent(b),
ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2) REFERENCES parent(a),
ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a),
ALGORITHM = INPLACE;
Warnings:
Warning 1280 Name 'idx' ignored for PRIMARY key.
SHOW CREATE TABLE child;
Table Create Table
child CREATE TABLE `child` (
@@ -6,6 +6,8 @@ wdraw_rsn varchar(4) NOT NULL DEFAULT '',
admit_term char(4) NOT NULL DEFAULT '',
CONSTRAINT gso_grad_supr_pky PRIMARY KEY (uw_id, term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Warnings:
Warning 1280 Name 'gso_grad_supr_pky' ignored for PRIMARY key.
INSERT INTO `gso_grad_supr` VALUES ('1031',2,'CSM','','1009');
INSERT INTO `gso_grad_supr` VALUES ('1035',2,'CSM','ACAD','1009');
CREATE TABLE IF NOT EXISTS grad_degree (
@@ -23,6 +25,8 @@ deg_start_term char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginn
deg_as_of_term char(4) NOT NULL COMMENT 'In most cases also end term',
CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Warnings:
Warning 1280 Name 'grad_degree_stu_plan_admit_pky' ignored for PRIMARY key.
SHOW CREATE TABLE grad_degree;
Table Create Table
grad_degree CREATE TABLE `grad_degree` (
@@ -129,6 +133,8 @@ deg_start_term char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginn
deg_as_of_term char(4) NOT NULL COMMENT 'In most cases also end term',
CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Warnings:
Warning 1280 Name 'grad_degree_stu_plan_admit_pky' ignored for PRIMARY key.
SHOW CREATE TABLE grad_degree;
Table Create Table
grad_degree CREATE TABLE `grad_degree` (
@@ -263,6 +269,8 @@ deg_start_term char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginn
deg_as_of_term char(4) NOT NULL COMMENT 'In most cases also end term',
CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Warnings:
Warning 1280 Name 'grad_degree_stu_plan_admit_pky' ignored for PRIMARY key.
SHOW CREATE TABLE grad_degree;
Table Create Table
grad_degree CREATE TABLE `grad_degree` (
@@ -28,6 +28,8 @@ bug51378 CREATE TABLE `bug51378` (
UNIQUE KEY `idx2` (`col1`,`col2`(31))
) ENGINE=InnoDB DEFAULT CHARSET=latin1
alter table bug51378 add primary key idx3(col1, col2(31));
Warnings:
Warning 1280 Name 'idx3' ignored for PRIMARY key.
SHOW CREATE TABLE bug51378;
Table Create Table
bug51378 CREATE TABLE `bug51378` (
@@ -4,13 +4,17 @@ DOB VARCHAR(50) NOT NULL,
NAME NVARCHAR(255) NOT NULL,
CONSTRAINT PK_PERSON PRIMARY KEY (PERSON_ID, DOB)
)Engine=InnoDB;
Warnings:
Warning 1280 Name 'PK_PERSON' ignored for PRIMARY key.
CREATE TABLE PHOTO (
PERSON_ID VARCHAR(50) NOT NULL,
DOB VARCHAR(50) NOT NULL,
PHOTO_DETAILS VARCHAR(50) NULL,
CONSTRAINT PK_PHOTO PRIMARY KEY (PERSON_ID, DOB),
CONSTRAINT FK_PHOTO_2_PERSON FOREIGN KEY (PERSON_ID, DOB) REFERENCES PERSON (PERSON_ID, DOB)
)Engine=InnoDB;
Warnings:
Warning 1280 Name 'PK_PHOTO' ignored for PRIMARY key.
CREATE TABLE ADDRESS (
PERSON_ID VARCHAR(50) NOT NULL,
DOB VARCHAR(50) NOT NULL,
@@ -19,6 +23,8 @@ ADDRESS_DETAILS NVARCHAR(250) NULL,
CONSTRAINT PK_ADDRESS PRIMARY KEY (PERSON_ID, DOB, ADDRESS_ID),
CONSTRAINT FK_ADDRESS_2_PERSON FOREIGN KEY (PERSON_ID, DOB) REFERENCES PERSON (PERSON_ID, DOB) ON DELETE CASCADE
)Engine=InnoDB;
Warnings:
Warning 1280 Name 'PK_ADDRESS' ignored for PRIMARY key.
INSERT INTO PERSON VALUES("10", "11011999", "John");
INSERT INTO PHOTO VALUES("10", "11011999", "new photo");
DROP TABLE PHOTO;
@@ -796,11 +796,15 @@ POINT(1 1)
drop function fn3;
create table t1(pt POINT);
alter table t1 add primary key pti(pt);
Warnings:
Warning 1280 Name 'pti' ignored for PRIMARY key.
drop table t1;
create table t1(pt GEOMETRY);
alter table t1 add primary key pti(pt);
ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length
alter table t1 add primary key pti(pt(20));
Warnings:
Warning 1280 Name 'pti' ignored for PRIMARY key.
drop table t1;
create table t1 select ST_GeomFromText('point(1 1)');
desc t1;
@@ -792,11 +792,15 @@ POINT(1 1)
drop function fn3;
create table t1(pt POINT);
alter table t1 add primary key pti(pt);
Warnings:
Warning 1280 Name 'pti' ignored for PRIMARY key.
drop table t1;
create table t1(pt GEOMETRY);
alter table t1 add primary key pti(pt);
ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length
alter table t1 add primary key pti(pt(20));
Warnings:
Warning 1280 Name 'pti' ignored for PRIMARY key.
drop table t1;
create table t1 select ST_GeomFromText('point(1 1)');
desc t1;
@@ -515,6 +515,8 @@ pk09,pk10,pk11,pk12,pk13,pk14,pk15,pk16),
KEY pk(sk01,sk02,sk03,sk04,sk05,sk06,sk07,sk08,
sk09,sk10,sk11,sk12,sk13,sk14,sk15,sk16))
ROW_FORMAT=Redundant ENGINE=InnoDB;
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
SET @r = repeat('a', 48);
INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,
@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
@@ -546,6 +548,8 @@ pk09,pk10,pk11,pk12,pk13,pk14,pk15,pk16),
KEY pk(sk01,sk02,sk03,sk04,sk05,sk06,sk07,sk08,
sk09,sk10,sk11,sk12,sk13,sk14,sk15,sk16))
ROW_FORMAT=Compressed KEY_BLOCK_SIZE=4 ENGINE=InnoDB;
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
SET @r = repeat('a', 48);
INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,
@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
@@ -1070,6 +1070,8 @@ CREATE TABLE worklog5743 (
col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) ,
PRIMARY KEY `prefix_primary` (col_1_varchar(3072))
) ROW_FORMAT=DYNAMIC, engine = innodb;
Warnings:
Warning 1280 Name 'prefix_primary' ignored for PRIMARY key.
INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000));
CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (3072));
INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000));
@@ -1101,6 +1103,8 @@ CREATE TABLE worklog5743 (
col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) ,
PRIMARY KEY `prefix_primary` (col_1_varchar(3072))
) ROW_FORMAT=DYNAMIC, engine = innodb;
Warnings:
Warning 1280 Name 'prefix_primary' ignored for PRIMARY key.
INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000));
CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (3072));
INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000));
@@ -47,6 +47,8 @@ drop database if exists db1;
create database db1;
use db1;
create table t1 (i int auto_increment, f1 varchar(16), primary key pk (i,f1)) engine=MyISAM;
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
insert into t1 (f1) values ('one'),('two');
connection slave;
select * from db1.t1;
@@ -18,6 +18,8 @@ t CREATE TABLE `t` (
(PARTITION `p1` DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB,
PARTITION `p2` DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB)
ALTER TABLE t ADD PRIMARY KEY pk(a), ALGORITHM=INPLACE;
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
@@ -39,6 +41,8 @@ t CREATE TABLE `t` (
SET @TMP = @@GLOBAL.INNODB_FILE_PER_TABLE;
SET GLOBAL INNODB_FILE_PER_TABLE=OFF;
ALTER TABLE t ADD PRIMARY KEY pk(a), ALGORITHM=INPLACE;
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
@@ -42,6 +42,8 @@ COUNT(*)
>>> Something was written to binary log <<<
connection master;
ALTER TABLE t1 ADD PRIMARY KEY pk_t1 (a,b);
Warnings:
Warning 1280 Name 'pk_t1' ignored for PRIMARY key.
connection slave;
connection master;
INSERT INTO t1 VALUES (1,2,1),(2,2,2),(3,2,3),(4,2,4);
@@ -47,6 +47,8 @@ COUNT(*)
>>> Something was written to binary log <<<
connection master;
ALTER TABLE t1 ADD PRIMARY KEY pk_t1 (a,b);
Warnings:
Warning 1280 Name 'pk_t1' ignored for PRIMARY key.
connection slave;
connection master;
INSERT INTO t1 VALUES (1,2,1),(2,2,2),(3,2,3),(4,2,4);
@@ -66,7 +66,9 @@ alter table t2
change a a int with system versioning,
add primary key pk (a);
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
info: Records: 0 Duplicates: 0 Warnings: 1
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
update t1 set a=2;
select count(*) from t1 for system_time all;
count(*)
@@ -421,7 +421,9 @@ ALTER TABLE t
CHANGE a a INT WITH SYSTEM VERSIONING,
ADD PRIMARY KEY pk(a);
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
info: Records: 0 Duplicates: 0 Warnings: 1
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
SELECT c.prtype FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS AS c
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES AS t
ON c.table_id=t.table_id

0 comments on commit c6efbc5

Please sign in to comment.
You can’t perform that action at this time.