Below is the list of changes that have just been committed into a local
5.0 repository of ram. When ram does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-10-25 14:55:03+05:00, ramil@stripped +3 -0
Fix for bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0,
file .\ha_innodb.
Problem: if a partial unique key followed by a non-partial one we declare
the second one as a primary key.
Fix: declaring an unique key as primary, check if it's the first key.
Note: I doubt we can change the order in the sort_keys() in the 5.x
as some clients may depend on the current behaviour.
mysql-test/r/key.result@stripped, 2007-10-25 14:55:01+05:00, ramil@stripped +18 -0
Fix for bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0,
file .\ha_innodb.
- test result.
mysql-test/t/key.test@stripped, 2007-10-25 14:55:01+05:00, ramil@stripped +14 -0
Fix for bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0,
file .\ha_innodb.
- test case.
sql/table.cc@stripped, 2007-10-25 14:55:01+05:00, ramil@stripped +5 -3
Fix for bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0,
file .\ha_innodb.
- we can declare only the first unique key as primary.
diff -Nrup a/mysql-test/r/key.result b/mysql-test/r/key.result
--- a/mysql-test/r/key.result 2007-09-20 13:54:44 +05:00
+++ b/mysql-test/r/key.result 2007-10-25 14:55:01 +05:00
@@ -462,4 +462,22 @@ EXPLAIN SELECT MAX(a) FROM t1 FORCE INDE
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1
DROP TABLE t1;
+create table t1(a int not null, key aa(a),
+b char(10) not null, unique key bb(b(1)),
+c char(4) not null, unique key cc(c));
+desc t1;
+Field Type Null Key Default Extra
+a int(11) NO MUL NULL
+b char(10) NO UNI NULL
+c char(4) NO UNI NULL
+drop table t1;
+create table t1(a int not null, key aa(a),
+b char(10) not null, unique key bb(b(10)),
+c char(4) not null, unique key cc(c));
+desc t1;
+Field Type Null Key Default Extra
+a int(11) NO MUL NULL
+b char(10) NO PRI NULL
+c char(4) NO UNI NULL
+drop table t1;
End of 5.0 tests.
diff -Nrup a/mysql-test/t/key.test b/mysql-test/t/key.test
--- a/mysql-test/t/key.test 2007-05-22 17:58:29 +05:00
+++ b/mysql-test/t/key.test 2007-10-25 14:55:01 +05:00
@@ -443,4 +443,18 @@ ALTER TABLE t1 DISABLE KEYS;
EXPLAIN SELECT MAX(a) FROM t1 FORCE INDEX(a);
DROP TABLE t1;
+#
+# #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0
+#
+create table t1(a int not null, key aa(a),
+ b char(10) not null, unique key bb(b(1)),
+ c char(4) not null, unique key cc(c));
+desc t1;
+drop table t1;
+create table t1(a int not null, key aa(a),
+ b char(10) not null, unique key bb(b(10)),
+ c char(4) not null, unique key cc(c));
+desc t1;
+drop table t1;
+
--echo End of 5.0 tests.
diff -Nrup a/sql/table.cc b/sql/table.cc
--- a/sql/table.cc 2007-08-02 05:39:11 +05:00
+++ b/sql/table.cc 2007-10-25 14:55:01 +05:00
@@ -686,11 +686,13 @@ int openfrm(THD *thd, const char *name,
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 (key == 0 &&
+ 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.
+ If the first 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++)
| Thread |
|---|
| • bk commit into 5.0 tree (ramil:1.2552) BUG#31137 | ramil | 25 Oct |