summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2006-06-23 13:19:30 +0500
committerunknown <bar@mysql.com>2006-06-23 13:19:30 +0500
commit89e415950cf3b40b15e493cb72784f6ad3dc2b64 (patch)
treef4760a60110ab0b2fc303ee03d4218f5f4974dab
parent92ad3d5bd7fbfc64b083824f28470eebca5cd199 (diff)
downloadmariadb-git-89e415950cf3b40b15e493cb72784f6ad3dc2b64.tar.gz
Bug#11228: DESC shows arbitrary column as "PRI"
An UNIQUE KEY consisting of NOT NULL columns was displayed as PRIMARY KEY in "DESC t1". According to the code, that was intentional behaviour for some reasons unknown to me. This code was written before bitkeeper time, so I cannot check who and why made this. After discussing on dev-public, a decision was made to remove this code mysql-test/r/key.result: Adding test case. mysql-test/t/key.test: Adding test case. sql/table.cc: Removing old wrong code
-rw-r--r--mysql-test/r/key.result10
-rw-r--r--mysql-test/t/key.test11
-rw-r--r--sql/table.cc21
3 files changed, 21 insertions, 21 deletions
diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result
index f0a7afa239f..0bc241c0d19 100644
--- a/mysql-test/r/key.result
+++ b/mysql-test/r/key.result
@@ -326,6 +326,16 @@ alter table t1 add key (c1,c1,c2);
ERROR 42S21: Duplicate column name 'c1'
drop table t1;
create table t1 (
+i1 INT NOT NULL,
+i2 INT NOT NULL,
+UNIQUE i1idx (i1),
+UNIQUE i2idx (i2));
+desc t1;
+Field Type Null Key Default Extra
+i1 int(11) UNI 0
+i2 int(11) UNI 0
+drop table t1;
+create table t1 (
c1 int,
c2 varchar(20) not null,
primary key (c1),
diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test
index 85728582c75..796e36cb608 100644
--- a/mysql-test/t/key.test
+++ b/mysql-test/t/key.test
@@ -322,6 +322,17 @@ alter table t1 add key (c1,c1,c2);
drop table t1;
#
+# Bug#11228: DESC shows arbitrary column as "PRI"
+#
+create table t1 (
+ i1 INT NOT NULL,
+ i2 INT NOT NULL,
+ UNIQUE i1idx (i1),
+ UNIQUE i2idx (i2));
+desc t1;
+drop table t1;
+
+#
# Bug#12565 - ERROR 1034 when running simple UPDATE or DELETE
# on large MyISAM table
#
diff --git a/sql/table.cc b/sql/table.cc
index 8ac64ac198d..513f42665a6 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -567,27 +567,6 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
if (outparam->key_info[key].flags & HA_FULLTEXT)
outparam->key_info[key].algorithm= HA_KEY_ALG_FULLTEXT;
- if (primary_key >= MAX_KEY && (keyinfo->flags & HA_NOSAME))
- {
- /*
- If the UNIQUE key doesn't have NULL columns and is not a part key
- declare this as a primary key.
- */
- primary_key=key;
- for (i=0 ; i < keyinfo->key_parts ;i++)
- {
- uint fieldnr= key_part[i].fieldnr;
- if (!fieldnr ||
- outparam->field[fieldnr-1]->null_ptr ||
- outparam->field[fieldnr-1]->key_length() !=
- key_part[i].length)
- {
- primary_key=MAX_KEY; // Can't be used
- break;
- }
- }
- }
-
for (i=0 ; i < keyinfo->key_parts ; key_part++,i++)
{
if (new_field_pack_flag <= 1)