mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.1
into moonbone.local:/work/merge-5.1
This commit is contained in:
commit
a3deb94518
3 changed files with 31 additions and 1 deletions
|
@ -336,8 +336,16 @@ UNIQUE i1idx (i1),
|
|||
UNIQUE i2idx (i2));
|
||||
desc t1;
|
||||
Field Type Null Key Default Extra
|
||||
i1 int(11) NO UNI
|
||||
i1 int(11) NO PRI
|
||||
i2 int(11) NO UNI
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i1` int(11) NOT NULL,
|
||||
`i2` int(11) NOT NULL,
|
||||
UNIQUE KEY `i1idx` (`i1`),
|
||||
UNIQUE KEY `i2idx` (`i2`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
c1 int,
|
||||
|
|
|
@ -334,6 +334,7 @@ create table t1 (
|
|||
UNIQUE i1idx (i1),
|
||||
UNIQUE i2idx (i2));
|
||||
desc t1;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
|
|
21
sql/table.cc
21
sql/table.cc
|
@ -1025,6 +1025,27 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
|
|||
if (share->key_info[key].flags & HA_FULLTEXT)
|
||||
share->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 ||
|
||||
share->field[fieldnr-1]->null_ptr ||
|
||||
share->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++)
|
||||
{
|
||||
Field *field;
|
||||
|
|
Loading…
Reference in a new issue