summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <ramil/ram@ramil.myoffice.izhnet.ru>2007-10-29 17:34:01 +0400
committerunknown <ramil/ram@ramil.myoffice.izhnet.ru>2007-10-29 17:34:01 +0400
commit99678229f2f509961e2edd233fbd2dec6a41d594 (patch)
tree7117971685e3a258e30af05331f0cf52e09d5e1e /sql
parent3076fff2bcda6cf1de901aff0e0a658b635054a1 (diff)
parent51a49b1783bf880d9bd9ddd105c57d42cbdd9a87 (diff)
downloadmariadb-git-99678229f2f509961e2edd233fbd2dec6a41d594.tar.gz
Merge mysql.com:/home/ram/work/b31137/b31137.5.0
into mysql.com:/home/ram/work/b31137/b31137.5.1 sql/sql_table.cc: Auto merged sql/structs.h: Auto merged mysql-test/include/mix1.inc: will merge tests manually mysql-test/r/innodb_mysql.result: will merge tests manually mysql-test/r/key.result: will merge tests manually mysql-test/t/key.test: will merge tests manually include/my_base.h: manual merge.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_table.cc26
-rw-r--r--sql/structs.h2
2 files changed, 19 insertions, 9 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 6e19077306d..e6d84d0ef45 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1782,7 +1782,8 @@ bool quick_rm_table(handlerton *base,const char *db,
/*
Sort keys in the following order:
- 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
- Normal keys
- Fulltext keys
@@ -1793,26 +1794,31 @@ bool quick_rm_table(handlerton *base,const char *db,
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;
- 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 */
- 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)
return -1;
if (b->name == primary_key_name)
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
- 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
@@ -2876,6 +2882,10 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
else
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_part_info++;
diff --git a/sql/structs.h b/sql/structs.h
index 09a3c4d7285..662d0a680b8 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -71,7 +71,7 @@ typedef struct st_key_part_info { /* Info about a key part */
typedef struct st_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 extra_length;
uint usable_key_parts; /* Should normally be = key_parts */