mirror of
https://github.com/MariaDB/server.git
synced 2025-11-08 00:28:29 +03:00
MDEV-36852 Table definition gets corrupt after adding unique hash key
This commit is contained in:
@@ -809,3 +809,29 @@ hex(c1) hex(c2) c3 hex(c4)
|
||||
NULL NULL NULL NULL
|
||||
drop table t1;
|
||||
# End of 10.5 tests
|
||||
#
|
||||
# MDEV-36852 Table definition gets corrupt after adding unique hash key
|
||||
#
|
||||
create table t1 (a text, b int, foreign key(a) references x(x)) engine=myisam;
|
||||
Warnings:
|
||||
Note 1071 Specified key was too long; max key length is 1000 bytes
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` text DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
KEY `a` (`a`(1000))
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||
alter table t1 add unique(a), add key(a);
|
||||
Warnings:
|
||||
Note 1071 Specified key was too long; max key length is 1000 bytes
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` text DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
UNIQUE KEY `a` (`a`) USING HASH,
|
||||
KEY `a_2` (`a`(1000))
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||
drop table t1;
|
||||
# End of 10.6 tests
|
||||
|
||||
@@ -772,3 +772,15 @@ select hex(c1), hex(c2), c3, hex(c4) from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # End of 10.5 tests
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-36852 Table definition gets corrupt after adding unique hash key
|
||||
--echo #
|
||||
|
||||
create table t1 (a text, b int, foreign key(a) references x(x)) engine=myisam;
|
||||
show create table t1;
|
||||
alter table t1 add unique(a), add key(a);
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # End of 10.6 tests
|
||||
|
||||
@@ -3337,8 +3337,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
Create_field *auto_increment_key= 0;
|
||||
Key_part_spec *column;
|
||||
|
||||
bool is_hash_field_needed= key->key_create_info.algorithm
|
||||
== HA_KEY_ALG_LONG_HASH;
|
||||
if (key->type == Key::IGNORE_KEY)
|
||||
{
|
||||
/* ignore redundant keys */
|
||||
@@ -3349,6 +3347,9 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
break;
|
||||
}
|
||||
|
||||
bool is_hash_field_needed= key->key_create_info.algorithm
|
||||
== HA_KEY_ALG_LONG_HASH;
|
||||
|
||||
if (key_check_without_overlaps(thd, create_info, alter_info, *key))
|
||||
DBUG_RETURN(true);
|
||||
|
||||
|
||||
@@ -2838,6 +2838,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
|
||||
hash_keypart->fieldnr= hash_field_used_no + 1;
|
||||
hash_field= share->field[hash_field_used_no];
|
||||
hash_field->flags|= LONG_UNIQUE_HASH_FIELD;//Used in parse_vcol_defs
|
||||
DBUG_ASSERT(hash_field->invisible == INVISIBLE_FULL);
|
||||
keyinfo->flags|= HA_NOSAME;
|
||||
share->virtual_fields++;
|
||||
share->stored_fields--;
|
||||
|
||||
Reference in New Issue
Block a user