diff options
author | unknown <monty@mysql.com> | 2003-12-12 22:26:58 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2003-12-12 22:26:58 +0200 |
commit | 6c50fea9579d0f08754ac9e978550f58789c8638 (patch) | |
tree | 771f288d33d415cb8e3d292f33e46fdb512d9dff /sql/opt_range.cc | |
parent | a630198dde391e797d57b0aae64167a1c93db5b5 (diff) | |
download | mariadb-git-6c50fea9579d0f08754ac9e978550f58789c8638.tar.gz |
Fix autoincrement for signed columns (Bug #1366)
Fixed problem with char > 128 in QUOTE() function. (Bug #1868)
Disable creation of symlinks if my_disable_symlink is set
Fixed searching of TEXT with end space. (Bug #1651)
Fixed caching bug in multi-table-update where same table was used twice. (Bug #1711)
Fixed problem with UNIX_TIMESTAMP() for timestamps close to 0. (Bug #1998)
Fixed timestamp.test
include/my_base.h:
Add HA_END_SPACE_KEY to mark keys that has VARCHAR/TEXT fields.
myisam/mi_check.c:
Delete not used variable
myisam/mi_key.c:
Fix autoincrement for signed columns (Bug #1366). Patch by Holyfoot
myisam/mi_open.c:
Bug fix for future (doesn't affect current code)
myisam/mi_search.c:
Ignore end space for VARCHAR/TEXT columns
mysql-test/r/auto_increment.result:
Test auto_increment with signed numbers
mysql-test/r/binary.result:
Update results (old result was wrong)
mysql-test/r/func_str.result:
Added test of QUOTE()
mysql-test/r/func_time.result:
Add test of unix_timestamp()
mysql-test/r/have_met_timezone.require:
Fixed test
mysql-test/r/innodb.result:
Add test for InnoDB behaviour with TRUNCATE
mysql-test/r/multi_update.result:
Test of multi-update bug
mysql-test/r/symlink.result:
Test of ALTER TABLE and symlinks
mysql-test/r/timezone.result:
Test of from_unixtime()
mysql-test/r/truncate.result:
Test of truncate and auto_increment
mysql-test/r/type_blob.result:
Test of key search on TEXT/VARCHAR column with end space
mysql-test/t/auto_increment.test:
Test auto_increment with signed numbers
mysql-test/t/func_str.test:
Added test of QUOTE()
mysql-test/t/func_time.test:
Add test of unix_timestamp()
mysql-test/t/innodb.test:
Add test for InnoDB behaviour with TRUNCATE
mysql-test/t/multi_update.test:
Test of multi-update bug
mysql-test/t/symlink.test:
Test of ALTER TABLE and symlinks
mysql-test/t/timezone.test:
Test of from_unixtime()
mysql-test/t/truncate.test:
Test of truncate and auto_increment
mysql-test/t/type_blob.test:
Test of key search on TEXT/VARCHAR column with end space
mysys/my_symlink2.c:
Disable creation of symlinks if my_disable_symlink is set
sql/field.h:
Indentation cleanup
sql/ha_innodb.cc:
HA_PART_KEY -> HA_PART_KEY_SEG
sql/item_strfunc.cc:
Fixed problem with char > 128 in QUOTE() function. (Bug #1868)
sql/mysql_priv.h:
Make check_dup() external
sql/opt_range.cc:
Fixed searching of TEXT with end space. (Bug #1651)
sql/records.cc:
Fixed caching bug in multi-table-update where same table was used twice.
(Bug #1711)
sql/sql_acl.cc:
Reset ip and ip_mask if hostname is NULL
sql/sql_parse.cc:
Make check_dup() global
sql/sql_select.cc:
Fixed searching of TEXT with end space. (Bug #1651)
sql/sql_table.cc:
Fixed searching of TEXT with end space. (Bug #1651)
sql/sql_update.cc:
Fixed caching bug in multi-table-update where same table was used twice.
(Bug #1711)
sql/table.cc:
Fixed searching of TEXT with end space. (Bug #1651)
sql/table.h:
Fixed caching bug in multi-table-update where same table was used twice.
(Bug #1711)
sql/time.cc:
Fixed problem with UNIX_TIMESTAMP() for timestamps close to 0. (Bug #1998)
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r-- | sql/opt_range.cc | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 02b7699fad6..74fa237fd73 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -942,9 +942,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) @@ -1056,15 +1057,39 @@ 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); 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); - 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); + char *end; + str2= str+ key_part->part_length + maybe_null; + /* remove end space. The 2 is for the packed length */ + while (length > 0 && str[length+2+maybe_null-1] == ' ') + length--; + int2store(str+maybe_null, length); + /* Create key that is space filled */ + memcpy(str2, str, length+2+maybe_null); + end= str2+ maybe_null + key_part->part_length; + for (char *pos= str2+ 2+ length + maybe_null; pos < end ; pos++) + *pos++= ' '; + int2store(str2+maybe_null, key_part->part_length); + } + if (!(tree=new SEL_ARG(field,str,str2))) DBUG_RETURN(0); // out of memory switch (type) { @@ -2233,7 +2258,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 @@ -2367,7 +2393,8 @@ get_quick_keys(PARAM *param,QUICK_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, @@ -2412,7 +2439,7 @@ bool QUICK_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); } } @@ -2465,7 +2492,8 @@ QUICK_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, TABLE_REF *ref) 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))) |