Commit c6efbc54 authored by Alexey Botchkov's avatar Alexey Botchkov

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

Warning added.
parent 4b5a14d0
...@@ -2093,3 +2093,7 @@ create table t1 (i int, j int, key(i), key(i)) as select 1 as i, 2 as j; ...@@ -2093,3 +2093,7 @@ create table t1 (i int, j int, key(i), key(i)) as select 1 as i, 2 as j;
Warnings: Warnings:
Note 1831 Duplicate index `i_2`. This is deprecated and will be disallowed in a future release Note 1831 Duplicate index `i_2`. This is deprecated and will be disallowed in a future release
drop table t1; 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; ...@@ -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; create table t1 (i int, j int, key(i), key(i)) as select 1 as i, 2 as j;
drop table t1; 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 ( ...@@ -732,6 +732,8 @@ CREATE TABLE t1 (
b LONGTEXT CHARACTER SET "latin1" COLLATE "latin1_bin", b LONGTEXT CHARACTER SET "latin1" COLLATE "latin1_bin",
PRIMARY KEY b (b(32)) PRIMARY KEY b (b(32))
); );
Warnings:
Warning 1280 Name 'b' ignored for PRIMARY key.
INSERT INTO t1 (b) VALUES ('a'), (_binary 0x1), (_binary 0x0), (''); INSERT INTO t1 (b) VALUES ('a'), (_binary 0x1), (_binary 0x0), ('');
explain explain
select hex(b) from t1 force index (PRIMARY) where b<'zzz'; select hex(b) from t1 force index (PRIMARY) where b<'zzz';
......
...@@ -10,6 +10,8 @@ tt char(255) not null ...@@ -10,6 +10,8 @@ tt char(255) not null
insert into t1 values (1,'Aa'); insert into t1 values (1,'Aa');
insert into t1 values (2,'Aas'); insert into t1 values (2,'Aas');
alter table t1 add primary key aaa(tt); alter table t1 add primary key aaa(tt);
Warnings:
Warning 1280 Name 'aaa' ignored for PRIMARY key.
select * from t1 where tt like 'Aa%'; select * from t1 where tt like 'Aa%';
id tt id tt
1 Aa 1 Aa
......
...@@ -816,11 +816,15 @@ POINT(1 1) ...@@ -816,11 +816,15 @@ POINT(1 1)
drop function fn3; drop function fn3;
create table t1(pt POINT); create table t1(pt POINT);
alter table t1 add primary key pti(pt); alter table t1 add primary key pti(pt);
Warnings:
Warning 1280 Name 'pti' ignored for PRIMARY key.
drop table t1; drop table t1;
create table t1(pt GEOMETRY); create table t1(pt GEOMETRY);
alter table t1 add primary key pti(pt); alter table t1 add primary key pti(pt);
ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length
alter table t1 add primary key pti(pt(20)); alter table t1 add primary key pti(pt(20));
Warnings:
Warning 1280 Name 'pti' ignored for PRIMARY key.
drop table t1; drop table t1;
create table t1 select GeomFromText('point(1 1)'); create table t1 select GeomFromText('point(1 1)');
desc t1; desc t1;
......
...@@ -3103,6 +3103,8 @@ CREATE TABLE t2 ( ...@@ -3103,6 +3103,8 @@ CREATE TABLE t2 (
a2 int, b2 int, filler2 char(64) default ' ', a2 int, b2 int, filler2 char(64) default ' ',
PRIMARY KEY idx(a2,b2,filler2) 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)); CREATE TABLE t3 (b3 int, c3 int, INDEX idx(b3));
INSERT INTO t1(a1) VALUES INSERT INTO t1(a1) VALUES
(4), (7), (1), (9), (8), (5), (3), (6), (2); (4), (7), (1), (9), (8), (5), (3), (6), (2);
......
...@@ -47,6 +47,8 @@ drop database if exists db1; ...@@ -47,6 +47,8 @@ drop database if exists db1;
create database db1; create database db1;
use db1; use db1;
create table t1 (i int auto_increment, f1 varchar(16), primary key pk (i,f1)) engine=MyISAM; 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'); insert into t1 (f1) values ('one'),('two');
connection slave; connection slave;
select * from db1.t1; select * from db1.t1;
......
connection node_1; connection node_1;
create table t1 (i int, j int, k int, primary key pk(i)) engine=innodb; 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); 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; 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; replace into t2 (i, j, k) select /*!99997 */ i, k, j from t1;
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
...@@ -326,6 +326,8 @@ ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, ...@@ -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) ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE, ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE; ALGORITHM = INPLACE;
Warnings:
Warning 1280 Name 'idx' ignored for PRIMARY key.
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_1 test/child test/parent 1 6 test/fk_1 test/child test/parent 1 6
...@@ -363,6 +365,8 @@ ALTER TABLE child ADD PRIMARY KEY idx (a1), ...@@ -363,6 +365,8 @@ ALTER TABLE child ADD PRIMARY KEY idx (a1),
ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b)
ON DELETE SET NULL ON UPDATE CASCADE, ON DELETE SET NULL ON UPDATE CASCADE,
ALGORITHM = INPLACE; ALGORITHM = INPLACE;
Warnings:
Warning 1280 Name 'idx' ignored for PRIMARY key.
SELECT * from information_schema.INNODB_SYS_FOREIGN; SELECT * from information_schema.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE ID FOR_NAME REF_NAME N_COLS TYPE
test/fk_1 test/child test/parent 1 6 test/fk_1 test/child test/parent 1 6
...@@ -556,6 +560,8 @@ ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1) REFERENCES parent(b), ...@@ -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_2 FOREIGN KEY (a2) REFERENCES parent(a),
ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a), ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a),
ALGORITHM = INPLACE; ALGORITHM = INPLACE;
Warnings:
Warning 1280 Name 'idx' ignored for PRIMARY key.
SHOW CREATE TABLE child; SHOW CREATE TABLE child;
Table Create Table Table Create Table
child CREATE TABLE `child` ( child CREATE TABLE `child` (
......
...@@ -6,6 +6,8 @@ wdraw_rsn varchar(4) NOT NULL DEFAULT '', ...@@ -6,6 +6,8 @@ wdraw_rsn varchar(4) NOT NULL DEFAULT '',
admit_term char(4) NOT NULL DEFAULT '', admit_term char(4) NOT NULL DEFAULT '',
CONSTRAINT gso_grad_supr_pky PRIMARY KEY (uw_id, term) CONSTRAINT gso_grad_supr_pky PRIMARY KEY (uw_id, term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) 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 ('1031',2,'CSM','','1009');
INSERT INTO `gso_grad_supr` VALUES ('1035',2,'CSM','ACAD','1009'); INSERT INTO `gso_grad_supr` VALUES ('1035',2,'CSM','ACAD','1009');
CREATE TABLE IF NOT EXISTS grad_degree ( 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 ...@@ -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', 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) CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Warnings:
Warning 1280 Name 'grad_degree_stu_plan_admit_pky' ignored for PRIMARY key.
SHOW CREATE TABLE grad_degree; SHOW CREATE TABLE grad_degree;
Table Create Table Table Create Table
grad_degree CREATE TABLE `grad_degree` ( grad_degree CREATE TABLE `grad_degree` (
...@@ -129,6 +133,8 @@ deg_start_term char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginn ...@@ -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', 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) CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Warnings:
Warning 1280 Name 'grad_degree_stu_plan_admit_pky' ignored for PRIMARY key.
SHOW CREATE TABLE grad_degree; SHOW CREATE TABLE grad_degree;
Table Create Table Table Create Table
grad_degree CREATE TABLE `grad_degree` ( grad_degree CREATE TABLE `grad_degree` (
...@@ -263,6 +269,8 @@ deg_start_term char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginn ...@@ -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', 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) CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Warnings:
Warning 1280 Name 'grad_degree_stu_plan_admit_pky' ignored for PRIMARY key.
SHOW CREATE TABLE grad_degree; SHOW CREATE TABLE grad_degree;
Table Create Table Table Create Table
grad_degree CREATE TABLE `grad_degree` ( grad_degree CREATE TABLE `grad_degree` (
......
...@@ -28,6 +28,8 @@ bug51378 CREATE TABLE `bug51378` ( ...@@ -28,6 +28,8 @@ bug51378 CREATE TABLE `bug51378` (
UNIQUE KEY `idx2` (`col1`,`col2`(31)) UNIQUE KEY `idx2` (`col1`,`col2`(31))
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
alter table bug51378 add primary key idx3(col1, col2(31)); alter table bug51378 add primary key idx3(col1, col2(31));
Warnings:
Warning 1280 Name 'idx3' ignored for PRIMARY key.
SHOW CREATE TABLE bug51378; SHOW CREATE TABLE bug51378;
Table Create Table Table Create Table
bug51378 CREATE TABLE `bug51378` ( bug51378 CREATE TABLE `bug51378` (
......
...@@ -4,6 +4,8 @@ DOB VARCHAR(50) NOT NULL, ...@@ -4,6 +4,8 @@ DOB VARCHAR(50) NOT NULL,
NAME NVARCHAR(255) NOT NULL, NAME NVARCHAR(255) NOT NULL,
CONSTRAINT PK_PERSON PRIMARY KEY (PERSON_ID, DOB) CONSTRAINT PK_PERSON PRIMARY KEY (PERSON_ID, DOB)
)Engine=InnoDB; )Engine=InnoDB;
Warnings:
Warning 1280 Name 'PK_PERSON' ignored for PRIMARY key.
CREATE TABLE PHOTO ( CREATE TABLE PHOTO (
PERSON_ID VARCHAR(50) NOT NULL, PERSON_ID VARCHAR(50) NOT NULL,
DOB VARCHAR(50) NOT NULL, DOB VARCHAR(50) NOT NULL,
...@@ -11,6 +13,8 @@ PHOTO_DETAILS VARCHAR(50) NULL, ...@@ -11,6 +13,8 @@ PHOTO_DETAILS VARCHAR(50) NULL,
CONSTRAINT PK_PHOTO PRIMARY KEY (PERSON_ID, DOB), CONSTRAINT PK_PHOTO PRIMARY KEY (PERSON_ID, DOB),
CONSTRAINT FK_PHOTO_2_PERSON FOREIGN KEY (PERSON_ID, DOB) REFERENCES PERSON (PERSON_ID, DOB) CONSTRAINT FK_PHOTO_2_PERSON FOREIGN KEY (PERSON_ID, DOB) REFERENCES PERSON (PERSON_ID, DOB)
)Engine=InnoDB; )Engine=InnoDB;
Warnings:
Warning 1280 Name 'PK_PHOTO' ignored for PRIMARY key.
CREATE TABLE ADDRESS ( CREATE TABLE ADDRESS (
PERSON_ID VARCHAR(50) NOT NULL, PERSON_ID VARCHAR(50) NOT NULL,
DOB VARCHAR(50) NOT NULL, DOB VARCHAR(50) NOT NULL,
...@@ -19,6 +23,8 @@ ADDRESS_DETAILS NVARCHAR(250) NULL, ...@@ -19,6 +23,8 @@ ADDRESS_DETAILS NVARCHAR(250) NULL,
CONSTRAINT PK_ADDRESS PRIMARY KEY (PERSON_ID, DOB, ADDRESS_ID), 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 CONSTRAINT FK_ADDRESS_2_PERSON FOREIGN KEY (PERSON_ID, DOB) REFERENCES PERSON (PERSON_ID, DOB) ON DELETE CASCADE
)Engine=InnoDB; )Engine=InnoDB;
Warnings:
Warning 1280 Name 'PK_ADDRESS' ignored for PRIMARY key.
INSERT INTO PERSON VALUES("10", "11011999", "John"); INSERT INTO PERSON VALUES("10", "11011999", "John");
INSERT INTO PHOTO VALUES("10", "11011999", "new photo"); INSERT INTO PHOTO VALUES("10", "11011999", "new photo");
DROP TABLE PHOTO; DROP TABLE PHOTO;
......
...@@ -796,11 +796,15 @@ POINT(1 1) ...@@ -796,11 +796,15 @@ POINT(1 1)
drop function fn3; drop function fn3;
create table t1(pt POINT); create table t1(pt POINT);
alter table t1 add primary key pti(pt); alter table t1 add primary key pti(pt);
Warnings:
Warning 1280 Name 'pti' ignored for PRIMARY key.
drop table t1; drop table t1;
create table t1(pt GEOMETRY); create table t1(pt GEOMETRY);
alter table t1 add primary key pti(pt); alter table t1 add primary key pti(pt);
ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length
alter table t1 add primary key pti(pt(20)); alter table t1 add primary key pti(pt(20));
Warnings:
Warning 1280 Name 'pti' ignored for PRIMARY key.
drop table t1; drop table t1;
create table t1 select ST_GeomFromText('point(1 1)'); create table t1 select ST_GeomFromText('point(1 1)');
desc t1; desc t1;
......
...@@ -792,11 +792,15 @@ POINT(1 1) ...@@ -792,11 +792,15 @@ POINT(1 1)
drop function fn3; drop function fn3;
create table t1(pt POINT); create table t1(pt POINT);
alter table t1 add primary key pti(pt); alter table t1 add primary key pti(pt);
Warnings:
Warning 1280 Name 'pti' ignored for PRIMARY key.
drop table t1; drop table t1;
create table t1(pt GEOMETRY); create table t1(pt GEOMETRY);
alter table t1 add primary key pti(pt); alter table t1 add primary key pti(pt);
ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length
alter table t1 add primary key pti(pt(20)); alter table t1 add primary key pti(pt(20));
Warnings:
Warning 1280 Name 'pti' ignored for PRIMARY key.
drop table t1; drop table t1;
create table t1 select ST_GeomFromText('point(1 1)'); create table t1 select ST_GeomFromText('point(1 1)');
desc t1; desc t1;
......
...@@ -515,6 +515,8 @@ pk09,pk10,pk11,pk12,pk13,pk14,pk15,pk16), ...@@ -515,6 +515,8 @@ pk09,pk10,pk11,pk12,pk13,pk14,pk15,pk16),
KEY pk(sk01,sk02,sk03,sk04,sk05,sk06,sk07,sk08, KEY pk(sk01,sk02,sk03,sk04,sk05,sk06,sk07,sk08,
sk09,sk10,sk11,sk12,sk13,sk14,sk15,sk16)) sk09,sk10,sk11,sk12,sk13,sk14,sk15,sk16))
ROW_FORMAT=Redundant ENGINE=InnoDB; ROW_FORMAT=Redundant ENGINE=InnoDB;
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
SET @r = repeat('a', 48); 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, 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); @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), ...@@ -546,6 +548,8 @@ pk09,pk10,pk11,pk12,pk13,pk14,pk15,pk16),
KEY pk(sk01,sk02,sk03,sk04,sk05,sk06,sk07,sk08, KEY pk(sk01,sk02,sk03,sk04,sk05,sk06,sk07,sk08,
sk09,sk10,sk11,sk12,sk13,sk14,sk15,sk16)) sk09,sk10,sk11,sk12,sk13,sk14,sk15,sk16))
ROW_FORMAT=Compressed KEY_BLOCK_SIZE=4 ENGINE=InnoDB; ROW_FORMAT=Compressed KEY_BLOCK_SIZE=4 ENGINE=InnoDB;
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
SET @r = repeat('a', 48); 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, 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); @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
......
...@@ -1070,6 +1070,8 @@ CREATE TABLE worklog5743 ( ...@@ -1070,6 +1070,8 @@ CREATE TABLE worklog5743 (
col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) , col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) ,
PRIMARY KEY `prefix_primary` (col_1_varchar(3072)) PRIMARY KEY `prefix_primary` (col_1_varchar(3072))
) ROW_FORMAT=DYNAMIC, engine = innodb; ) 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)); INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000));
CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (3072)); CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (3072));
INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000));
...@@ -1101,6 +1103,8 @@ CREATE TABLE worklog5743 ( ...@@ -1101,6 +1103,8 @@ CREATE TABLE worklog5743 (
col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) , col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) ,
PRIMARY KEY `prefix_primary` (col_1_varchar(3072)) PRIMARY KEY `prefix_primary` (col_1_varchar(3072))
) ROW_FORMAT=DYNAMIC, engine = innodb; ) 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)); INSERT INTO worklog5743 VALUES(REPEAT("a", 4000) , REPEAT("o", 4000));
CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (3072)); CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (3072));
INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000)); INSERT INTO worklog5743 VALUES(REPEAT("b", 4000) , REPEAT("p", 4000));
......
...@@ -47,6 +47,8 @@ drop database if exists db1; ...@@ -47,6 +47,8 @@ drop database if exists db1;
create database db1; create database db1;
use db1; use db1;
create table t1 (i int auto_increment, f1 varchar(16), primary key pk (i,f1)) engine=MyISAM; 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'); insert into t1 (f1) values ('one'),('two');
connection slave; connection slave;
select * from db1.t1; select * from db1.t1;
......
...@@ -18,6 +18,8 @@ t CREATE TABLE `t` ( ...@@ -18,6 +18,8 @@ t CREATE TABLE `t` (
(PARTITION `p1` DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB, (PARTITION `p1` DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB,
PARTITION `p2` 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; ALTER TABLE t ADD PRIMARY KEY pk(a), ALGORITHM=INPLACE;
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
SHOW CREATE TABLE t; SHOW CREATE TABLE t;
Table Create Table Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
...@@ -39,6 +41,8 @@ t CREATE TABLE `t` ( ...@@ -39,6 +41,8 @@ t CREATE TABLE `t` (
SET @TMP = @@GLOBAL.INNODB_FILE_PER_TABLE; SET @TMP = @@GLOBAL.INNODB_FILE_PER_TABLE;
SET GLOBAL INNODB_FILE_PER_TABLE=OFF; SET GLOBAL INNODB_FILE_PER_TABLE=OFF;
ALTER TABLE t ADD PRIMARY KEY pk(a), ALGORITHM=INPLACE; ALTER TABLE t ADD PRIMARY KEY pk(a), ALGORITHM=INPLACE;
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
SHOW CREATE TABLE t; SHOW CREATE TABLE t;
Table Create Table Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
......
...@@ -42,6 +42,8 @@ COUNT(*) ...@@ -42,6 +42,8 @@ COUNT(*)
>>> Something was written to binary log <<< >>> Something was written to binary log <<<
connection master; connection master;
ALTER TABLE t1 ADD PRIMARY KEY pk_t1 (a,b); ALTER TABLE t1 ADD PRIMARY KEY pk_t1 (a,b);
Warnings:
Warning 1280 Name 'pk_t1' ignored for PRIMARY key.
connection slave; connection slave;
connection master; connection master;
INSERT INTO t1 VALUES (1,2,1),(2,2,2),(3,2,3),(4,2,4); INSERT INTO t1 VALUES (1,2,1),(2,2,2),(3,2,3),(4,2,4);
......
...@@ -47,6 +47,8 @@ COUNT(*) ...@@ -47,6 +47,8 @@ COUNT(*)
>>> Something was written to binary log <<< >>> Something was written to binary log <<<
connection master; connection master;
ALTER TABLE t1 ADD PRIMARY KEY pk_t1 (a,b); ALTER TABLE t1 ADD PRIMARY KEY pk_t1 (a,b);
Warnings:
Warning 1280 Name 'pk_t1' ignored for PRIMARY key.
connection slave; connection slave;
connection master; connection master;
INSERT INTO t1 VALUES (1,2,1),(2,2,2),(3,2,3),(4,2,4); INSERT INTO t1 VALUES (1,2,1),(2,2,2),(3,2,3),(4,2,4);
......
...@@ -66,7 +66,9 @@ alter table t2 ...@@ -66,7 +66,9 @@ alter table t2
change a a int with system versioning, change a a int with system versioning,
add primary key pk (a); add primary key pk (a);
affected rows: 0 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; update t1 set a=2;
select count(*) from t1 for system_time all; select count(*) from t1 for system_time all;
count(*) count(*)
......
...@@ -421,7 +421,9 @@ ALTER TABLE t ...@@ -421,7 +421,9 @@ ALTER TABLE t
CHANGE a a INT WITH SYSTEM VERSIONING, CHANGE a a INT WITH SYSTEM VERSIONING,
ADD PRIMARY KEY pk(a); ADD PRIMARY KEY pk(a);
affected rows: 0 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 SELECT c.prtype FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS AS c
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES AS t INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES AS t
ON c.table_id=t.table_id ON c.table_id=t.table_id
......
This diff is collapsed.
...@@ -3671,6 +3671,17 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, ...@@ -3671,6 +3671,17 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name.str); my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name.str);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
if (key->type == Key::PRIMARY && key->name.str &&
my_strcasecmp(system_charset_info, key->name.str, primary_key_name) != 0)
{
bool sav_abort_on_warning= thd->abort_on_warning;
thd->abort_on_warning= FALSE; /* Don't make an error out of this. */
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_NAME_FOR_INDEX,
"Name '%-.100s' ignored for PRIMARY key.",
key->name.str);
thd->abort_on_warning= sav_abort_on_warning;
}
} }
tmp=file->max_keys(); tmp=file->max_keys();
if (*key_count > tmp) if (*key_count > tmp)
......
...@@ -6,6 +6,8 @@ family_name varchar(30) not null, ...@@ -6,6 +6,8 @@ family_name varchar(30) not null,
score int not null, score int not null,
primary key property (given_name, family_name, score) primary key property (given_name, family_name, score)
) default charset utf8; ) default charset utf8;
Warnings:
Warning 1280 Name 'property' ignored for PRIMARY key.
show create table scores; show create table scores;
Table Create Table Table Create Table
scores CREATE TABLE `scores` ( scores CREATE TABLE `scores` (
......
...@@ -469,6 +469,8 @@ DROP TABLE t1; ...@@ -469,6 +469,8 @@ DROP TABLE t1;
SET @prior_rocksdb_table_stats_sampling_pct = @@rocksdb_table_stats_sampling_pct; SET @prior_rocksdb_table_stats_sampling_pct = @@rocksdb_table_stats_sampling_pct;
set global rocksdb_table_stats_sampling_pct = 100; set global rocksdb_table_stats_sampling_pct = 100;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB; CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
Warnings:
Warning 1280 Name 'ka' ignored for PRIMARY key.
INSERT INTO t1 (a, b) VALUES (1, 10); INSERT INTO t1 (a, b) VALUES (1, 10);
INSERT INTO t1 (a, b) VALUES (2, 10); INSERT INTO t1 (a, b) VALUES (2, 10);
INSERT INTO t1 (a, b) VALUES (3, 20); INSERT INTO t1 (a, b) VALUES (3, 20);
......
...@@ -23,6 +23,8 @@ CREATE TABLE t1 (a INT, ...@@ -23,6 +23,8 @@ CREATE TABLE t1 (a INT,
b CHAR(8), b CHAR(8),
PRIMARY KEY ind2(b(1) DESC) KEY_BLOCK_SIZE=32768 COMMENT 'big key_block_size value' PRIMARY KEY ind2(b(1) DESC) KEY_BLOCK_SIZE=32768 COMMENT 'big key_block_size value'
) ENGINE=rocksdb; ) ENGINE=rocksdb;
Warnings:
Warning 1280 Name 'ind2' ignored for PRIMARY key.
SHOW INDEX IN t1; SHOW INDEX IN t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 PRIMARY 1 b A # 1 NULL LSMTREE big key_block_size value t1 0 PRIMARY 1 b A # 1 NULL LSMTREE big key_block_size value
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment