mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
Merge mysql.com:/home/ram/work/b31137/b31137.5.0
into mysql.com:/home/ram/work/b31137/b31137.5.1
This commit is contained in:
commit
b6a808bd1f
3 changed files with 21 additions and 9 deletions
|
@ -244,6 +244,8 @@ enum ha_base_keytype {
|
||||||
HA_BINARY_PACK_KEY | HA_FULLTEXT | HA_UNIQUE_CHECK | \
|
HA_BINARY_PACK_KEY | HA_FULLTEXT | HA_UNIQUE_CHECK | \
|
||||||
HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
|
HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
|
||||||
|
|
||||||
|
#define HA_KEY_HAS_PART_KEY_SEG 65536 /* Key contains partial segments */
|
||||||
|
|
||||||
/* Automatic bits in key-flag */
|
/* Automatic bits in key-flag */
|
||||||
|
|
||||||
#define HA_SPACE_PACK_USED 4 /* Test for if SPACE_PACK used */
|
#define HA_SPACE_PACK_USED 4 /* Test for if SPACE_PACK used */
|
||||||
|
|
|
@ -1782,7 +1782,8 @@ bool quick_rm_table(handlerton *base,const char *db,
|
||||||
/*
|
/*
|
||||||
Sort keys in the following order:
|
Sort keys in the following order:
|
||||||
- PRIMARY KEY
|
- PRIMARY KEY
|
||||||
- UNIQUE keyws where all column are NOT NULL
|
- UNIQUE keys where all column are NOT NULL
|
||||||
|
- UNIQUE keys that don't contain partial segments
|
||||||
- Other UNIQUE keys
|
- Other UNIQUE keys
|
||||||
- Normal keys
|
- Normal keys
|
||||||
- Fulltext keys
|
- Fulltext keys
|
||||||
|
@ -1793,26 +1794,31 @@ bool quick_rm_table(handlerton *base,const char *db,
|
||||||
|
|
||||||
static int sort_keys(KEY *a, KEY *b)
|
static int sort_keys(KEY *a, KEY *b)
|
||||||
{
|
{
|
||||||
if (a->flags & HA_NOSAME)
|
ulong a_flags= a->flags, b_flags= b->flags;
|
||||||
|
|
||||||
|
if (a_flags & HA_NOSAME)
|
||||||
{
|
{
|
||||||
if (!(b->flags & HA_NOSAME))
|
if (!(b_flags & HA_NOSAME))
|
||||||
return -1;
|
return -1;
|
||||||
if ((a->flags ^ b->flags) & (HA_NULL_PART_KEY | HA_END_SPACE_KEY))
|
if ((a_flags ^ b_flags) & (HA_NULL_PART_KEY | HA_END_SPACE_KEY))
|
||||||
{
|
{
|
||||||
/* Sort NOT NULL keys before other keys */
|
/* Sort NOT NULL keys before other keys */
|
||||||
return (a->flags & (HA_NULL_PART_KEY | HA_END_SPACE_KEY)) ? 1 : -1;
|
return (a_flags & (HA_NULL_PART_KEY | HA_END_SPACE_KEY)) ? 1 : -1;
|
||||||
}
|
}
|
||||||
if (a->name == primary_key_name)
|
if (a->name == primary_key_name)
|
||||||
return -1;
|
return -1;
|
||||||
if (b->name == primary_key_name)
|
if (b->name == primary_key_name)
|
||||||
return 1;
|
return 1;
|
||||||
|
/* Sort keys don't containing partial segments before others */
|
||||||
|
if ((a_flags ^ b_flags) & HA_KEY_HAS_PART_KEY_SEG)
|
||||||
|
return (a_flags & HA_KEY_HAS_PART_KEY_SEG) ? 1 : -1;
|
||||||
}
|
}
|
||||||
else if (b->flags & HA_NOSAME)
|
else if (b_flags & HA_NOSAME)
|
||||||
return 1; // Prefer b
|
return 1; // Prefer b
|
||||||
|
|
||||||
if ((a->flags ^ b->flags) & HA_FULLTEXT)
|
if ((a_flags ^ b_flags) & HA_FULLTEXT)
|
||||||
{
|
{
|
||||||
return (a->flags & HA_FULLTEXT) ? 1 : -1;
|
return (a_flags & HA_FULLTEXT) ? 1 : -1;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Prefer original key order. usable_key_parts contains here
|
Prefer original key order. usable_key_parts contains here
|
||||||
|
@ -2876,6 +2882,10 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||||
else
|
else
|
||||||
key_info->flags|= HA_PACK_KEY;
|
key_info->flags|= HA_PACK_KEY;
|
||||||
}
|
}
|
||||||
|
/* Check if the key segment is partial, set the key flag accordingly */
|
||||||
|
if (length != sql_field->key_length)
|
||||||
|
key_info->flags|= HA_KEY_HAS_PART_KEY_SEG;
|
||||||
|
|
||||||
key_length+=length;
|
key_length+=length;
|
||||||
key_part_info++;
|
key_part_info++;
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ typedef struct st_key_part_info { /* Info about a key part */
|
||||||
|
|
||||||
typedef struct st_key {
|
typedef struct st_key {
|
||||||
uint key_length; /* Tot length of key */
|
uint key_length; /* Tot length of key */
|
||||||
uint flags; /* dupp key and pack flags */
|
ulong flags; /* dupp key and pack flags */
|
||||||
uint key_parts; /* How many key_parts */
|
uint key_parts; /* How many key_parts */
|
||||||
uint extra_length;
|
uint extra_length;
|
||||||
uint usable_key_parts; /* Should normally be = key_parts */
|
uint usable_key_parts; /* Should normally be = key_parts */
|
||||||
|
|
Loading…
Reference in a new issue