mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Reverted wrong bug fix (Bug#11228)
mysql-test/r/key.result: Fixed result after removing wrong bug fix mysql-test/t/key.test: Added SHOW CREATE TABLE, which is the proper way to check for table definitions sql/table.cc: Reverted wrong bug fix. The intention with the original code was to show that MySQL treats the first given unique key as a primary key. Clients can use the marked primary key as a real primary key to validate row changes in case of conflicting updates. The ODBC driver (and other drivers) may also use this fact to optimize/check updates and handle conflicts. The marked key also shows what some engines, like InnoDB or NDB, will use as it's internal primary key. For checking if someone has declared a true PRIMARY KEY, one should use 'SHOW CREATE TABLE'
This commit is contained in:
21
sql/table.cc
21
sql/table.cc
@@ -567,6 +567,27 @@ 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)
|
||||
|
||||
Reference in New Issue
Block a user