mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge 4.1 to 5.0.
BitKeeper/etc/logging_ok: auto-union client/mysql.cc: Auto merged configure.in: Auto merged client/mysqltest.c: Auto merged include/my_global.h: Auto merged include/my_pthread.h: Auto merged include/mysql_com.h: Auto merged libmysql/libmysql.c: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/mi_check.c: Auto merged mysql-test/r/insert.result: Auto merged mysql-test/r/join_outer.result: Auto merged mysql-test/r/multi_update.result: Auto merged mysql-test/r/query_cache.result: Auto merged mysql-test/r/symlink.result: Auto merged mysql-test/t/func_time.test: Auto merged mysql-test/t/insert.test: Auto merged mysql-test/t/multi_update.test: Auto merged mysql-test/t/query_cache.test: Auto merged sql/ha_innodb.cc: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_subselect.cc: Auto merged sql/item_sum.cc: Auto merged sql/item_sum.h: Auto merged sql/item_timefunc.cc: Auto merged sql/lex.h: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/opt_range.cc: Auto merged sql/records.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.cc: Auto merged sql/slave.cc: Auto merged sql/sql_acl.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_load.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_rename.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.h: Auto merged sql/share/czech/errmsg.txt: Auto merged sql/share/romanian/errmsg.txt: Auto merged
This commit is contained in:
@ -1461,9 +1461,10 @@ static SEL_ARG *
|
||||
get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
|
||||
Item_func::Functype type,Item *value)
|
||||
{
|
||||
uint maybe_null=(uint) field->real_maybe_null();
|
||||
uint maybe_null=(uint) field->real_maybe_null(), copies;
|
||||
uint field_length=field->pack_length()+maybe_null;
|
||||
SEL_ARG *tree;
|
||||
char *str, *str2;
|
||||
DBUG_ENTER("get_mm_leaf");
|
||||
|
||||
if (type == Item_func::LIKE_FUNC)
|
||||
@ -1564,16 +1565,38 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
|
||||
/* This happens when we try to insert a NULL field in a not null column */
|
||||
DBUG_RETURN(&null_element); // cmp with NULL is never true
|
||||
}
|
||||
// Get local copy of key
|
||||
char *str= (char*) alloc_root(param->mem_root,
|
||||
key_part->part_length+maybe_null);
|
||||
/* Get local copy of key */
|
||||
copies= 1;
|
||||
if (field->key_type() == HA_KEYTYPE_VARTEXT)
|
||||
copies= 2;
|
||||
str= str2= (char*) alloc_root(param->mem_root,
|
||||
(key_part->part_length+maybe_null)*copies+1);
|
||||
if (!str)
|
||||
DBUG_RETURN(0);
|
||||
if (maybe_null)
|
||||
*str= (char) field->is_real_null(); // Set to 1 if null
|
||||
field->get_key_image(str+maybe_null,key_part->part_length,
|
||||
field->charset(),key_part->image_type);
|
||||
if (!(tree=new SEL_ARG(field,str,str)))
|
||||
if (copies == 2)
|
||||
{
|
||||
/*
|
||||
The key is stored as 2 byte length + key
|
||||
key doesn't match end space. In other words, a key 'X ' should match
|
||||
all rows between 'X' and 'X ...'
|
||||
*/
|
||||
uint length= uint2korr(str+maybe_null);
|
||||
str2= str+ key_part->part_length + maybe_null;
|
||||
/* remove end space */
|
||||
while (length > 0 && str[length+HA_KEY_BLOB_LENGTH+maybe_null-1] == ' ')
|
||||
length--;
|
||||
int2store(str+maybe_null, length);
|
||||
/* Create key that is space filled */
|
||||
memcpy(str2, str, length + HA_KEY_BLOB_LENGTH + maybe_null);
|
||||
bfill(str2+ length+ HA_KEY_BLOB_LENGTH +maybe_null,
|
||||
key_part->part_length-length - HA_KEY_BLOB_LENGTH, ' ');
|
||||
int2store(str2+maybe_null, key_part->part_length - HA_KEY_BLOB_LENGTH);
|
||||
}
|
||||
if (!(tree=new SEL_ARG(field,str,str2)))
|
||||
DBUG_RETURN(0); // out of memory
|
||||
|
||||
switch (type) {
|
||||
@ -2039,7 +2062,7 @@ key_or(SEL_ARG *key1,SEL_ARG *key2)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if (!key2)
|
||||
if (!key2)
|
||||
{
|
||||
key1->use_count--;
|
||||
key1->free_tree();
|
||||
@ -2798,7 +2821,8 @@ check_quick_keys(PARAM *param,uint idx,SEL_ARG *key_tree,
|
||||
param->range_count++;
|
||||
if (!tmp_min_flag && ! tmp_max_flag &&
|
||||
(uint) key_tree->part+1 == param->table->key_info[keynr].key_parts &&
|
||||
(param->table->key_info[keynr].flags & HA_NOSAME) &&
|
||||
(param->table->key_info[keynr].flags & (HA_NOSAME | HA_END_SPACE_KEY)) ==
|
||||
HA_NOSAME &&
|
||||
min_key_length == max_key_length &&
|
||||
!memcmp(param->min_key,param->max_key,min_key_length))
|
||||
tmp=1; // Max one record
|
||||
@ -2954,7 +2978,8 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key,
|
||||
{
|
||||
KEY *table_key=quick->head->key_info+quick->index;
|
||||
flag=EQ_RANGE;
|
||||
if (table_key->flags & HA_NOSAME && key->part == table_key->key_parts-1)
|
||||
if ((table_key->flags & (HA_NOSAME | HA_END_SPACE_KEY)) == HA_NOSAME &&
|
||||
key->part == table_key->key_parts-1)
|
||||
{
|
||||
if (!(table_key->flags & HA_NULL_PART_KEY) ||
|
||||
!null_part_in_key(key,
|
||||
@ -3000,7 +3025,7 @@ bool QUICK_RANGE_SELECT::unique_key_range()
|
||||
if (((tmp=ranges.head())->flag & (EQ_RANGE | NULL_RANGE)) == EQ_RANGE)
|
||||
{
|
||||
KEY *key=head->key_info+index;
|
||||
return ((key->flags & HA_NOSAME) &&
|
||||
return ((key->flags & (HA_NOSAME | HA_END_SPACE_KEY)) == HA_NOSAME &&
|
||||
key->key_length == tmp->min_length);
|
||||
}
|
||||
}
|
||||
@ -3036,6 +3061,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
|
||||
QUICK_RANGE_SELECT *quick=new QUICK_RANGE_SELECT(thd, table, ref->key, 1);
|
||||
KEY *key_info = &table->key_info[ref->key];
|
||||
KEY_PART *key_part;
|
||||
QUICK_RANGE *range;
|
||||
uint part;
|
||||
|
||||
if (!quick)
|
||||
@ -3049,18 +3075,18 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
|
||||
if (cp_buffer_from_ref(ref))
|
||||
{
|
||||
if (thd->is_fatal_error)
|
||||
return 0; // out of memory
|
||||
goto err; // out of memory
|
||||
return quick; // empty range
|
||||
}
|
||||
|
||||
QUICK_RANGE *range= new QUICK_RANGE();
|
||||
if (!range)
|
||||
if (!(range= new QUICK_RANGE()))
|
||||
goto err; // out of memory
|
||||
|
||||
range->min_key=range->max_key=(char*) ref->key_buff;
|
||||
range->min_length=range->max_length=ref->key_length;
|
||||
range->flag= ((ref->key_length == key_info->key_length &&
|
||||
(key_info->flags & HA_NOSAME)) ? EQ_RANGE : 0);
|
||||
(key_info->flags & (HA_NOSAME | HA_END_SPACE_KEY)) ==
|
||||
HA_NOSAME) ? EQ_RANGE : 0);
|
||||
|
||||
if (!(quick->key_parts=key_part=(KEY_PART *)
|
||||
alloc_root(&quick->alloc,sizeof(KEY_PART)*ref->key_parts)))
|
||||
|
Reference in New Issue
Block a user