diff options
author | monty@mysql.com <> | 2004-03-25 22:18:31 +0200 |
---|---|---|
committer | monty@mysql.com <> | 2004-03-25 22:18:31 +0200 |
commit | 3b34a6a2dd73792e1b79047a491bd02b30d5ec68 (patch) | |
tree | e57ae2c11af5b2babaed4ac2ee1bc7352fdace68 /sql | |
parent | e5f9e18d2ff4a85a876b187e9fb7a210396bd20c (diff) | |
parent | 1448199bd75009ac9b4aa42c9d4fb8d827a4cb12 (diff) | |
download | mariadb-git-3b34a6a2dd73792e1b79047a491bd02b30d5ec68.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/my/mysql-4.1
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 13 | ||||
-rw-r--r-- | sql/filesort.cc | 10 | ||||
-rw-r--r-- | sql/ha_heap.cc | 10 | ||||
-rw-r--r-- | sql/ha_heap.h | 2 | ||||
-rw-r--r-- | sql/item.cc | 14 | ||||
-rw-r--r-- | sql/item.h | 11 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 3 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 4 | ||||
-rw-r--r-- | sql/item_func.cc | 4 | ||||
-rw-r--r-- | sql/sql_base.cc | 6 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 | ||||
-rw-r--r-- | sql/sql_union.cc | 9 |
12 files changed, 65 insertions, 23 deletions
diff --git a/sql/field.cc b/sql/field.cc index 6a891fac5c6..b7362d74c5f 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4209,10 +4209,10 @@ int Field_string::cmp(const char *a_ptr, const char *b_ptr) void Field_string::sort_string(char *to,uint length) { uint tmp=my_strnxfrm(field_charset, - (unsigned char *)to, length, - (unsigned char *) ptr, field_length); + (unsigned char *) to, length, + (unsigned char *) ptr, field_length); if (tmp < length) - bzero(to + tmp, length - tmp); + field_charset->cset->fill(field_charset, to + tmp, length - tmp, ' '); } @@ -4384,7 +4384,8 @@ void Field_varstring::sort_string(char *to,uint length) (unsigned char *) to, length, (unsigned char *)ptr+2, tot_length); if (tot_length < length) - bzero(to+tot_length,length-tot_length); + field_charset->cset->fill(field_charset, to+tot_length,length-tot_length, + binary() ? (char) 0 : ' '); } @@ -4838,7 +4839,9 @@ void Field_blob::sort_string(char *to,uint length) (unsigned char *)to, length, (unsigned char *)blob, blob_length); if (blob_length < length) - bzero(to+blob_length, length-blob_length); + field_charset->cset->fill(field_charset, to+blob_length, + length-blob_length, + binary() ? (char) 0 : ' '); } } diff --git a/sql/filesort.cc b/sql/filesort.cc index 064e92b7888..a15ffb43f6f 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -528,6 +528,8 @@ static void make_sortkey(register SORTPARAM *param, case STRING_RESULT: { CHARSET_INFO *cs=item->collation.collation; + char fill_char= ((cs->state & MY_CS_BINSORT) ? (char) 0 : ' '); + if ((maybe_null=item->maybe_null)) *to++=1; /* All item->str() to use some extra byte for end null.. */ @@ -564,14 +566,16 @@ static void make_sortkey(register SORTPARAM *param, uint tmp_length=my_strnxfrm(cs,to,sort_field->length, (unsigned char *) from, length); if (tmp_length < sort_field->length) - bzero((char*) to+tmp_length,sort_field->length-tmp_length); + cs->cset->fill(cs, (char*) to+tmp_length, + sort_field->length-tmp_length, + fill_char); } else { my_strnxfrm(cs,(uchar*)to,length,(const uchar*)res->ptr(),length); - bzero((char *)to+length,diff); + cs->cset->fill(cs, (char *)to+length,diff,fill_char); } - break; + break; } case INT_RESULT: { diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 807b6e35a29..c84f0da0d25 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -44,6 +44,16 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked) } } ref_length= sizeof(HEAP_PTR); + if (file) + { + /* Initialize variables for the opened table */ + btree_keys.clear_all(); + for (uint i= 0 ; i < table->keys ; i++) + { + if (table->key_info[i].algorithm == HA_KEY_ALG_BTREE) + btree_keys.set_bit(i); + } + } return (file ? 0 : 1); } diff --git a/sql/ha_heap.h b/sql/ha_heap.h index c369c7029b4..feadc0c3c0f 100644 --- a/sql/ha_heap.h +++ b/sql/ha_heap.h @@ -26,6 +26,7 @@ class ha_heap: public handler { HP_INFO *file; + key_map btree_keys; public: ha_heap(TABLE *table): handler(table), file(0) {} @@ -49,6 +50,7 @@ class ha_heap: public handler (HA_ONLY_WHOLE_INDEX | HA_WRONG_ASCII_ORDER | HA_NOT_READ_PREFIX_LAST)); } + const key_map *keys_to_use_for_scanning() { return &btree_keys; } uint max_record_length() const { return HA_MAX_REC_LENGTH; } uint max_keys() const { return MAX_KEY; } uint max_key_parts() const { return MAX_REF_PARTS; } diff --git a/sql/item.cc b/sql/item.cc index e889bbf1930..36b263f62cf 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -820,6 +820,16 @@ String *Item_copy_string::val_str(String *str) return &str_value; } + +int Item_copy_string::save_in_field(Field *field, bool no_conversions) +{ + if (null_value) + return set_field_to_null(field); + field->set_notnull(); + return field->store(str_value.ptr(),str_value.length(), + collation.collation); +} + /* Functions to convert item to field (for send_fields) */ @@ -1284,8 +1294,8 @@ int Item::save_in_field(Field *field, bool no_conversions) String *result; CHARSET_INFO *cs= collation.collation; char buff[MAX_FIELD_WIDTH]; // Alloc buffer for small columns - String loc_value(buff, sizeof(buff), cs); - result=val_str(&loc_value); + str_value.set_quick(buff, sizeof(buff), cs); + result=val_str(&str_value); if (null_value) return set_field_to_null_with_conversions(field, no_conversions); field->set_notnull(); diff --git a/sql/item.h b/sql/item.h index 5f94320b547..dffa93eaac8 100644 --- a/sql/item.h +++ b/sql/item.h @@ -102,7 +102,11 @@ public: enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE }; - String str_value; /* used to store value */ + /* + str_values's main purpose is to be used to cache the value in + save_in_field + */ + String str_value; my_string name; /* Name from select */ Item *next; uint32 max_length; @@ -138,7 +142,7 @@ public: virtual void make_field(Send_field *field); virtual bool fix_fields(THD *, struct st_table_list *, Item **); /* - should be used in case where we are shure that we do not need + should be used in case where we are sure that we do not need complete fix_fields() procedure. */ inline void quick_fix_field() { fixed= 1; } @@ -250,7 +254,7 @@ public: class Item_num: public Item { public: - virtual Item_num* neg()= 0; + virtual Item_num *neg()= 0; }; @@ -813,6 +817,7 @@ public: String *val_str(String*); void make_field(Send_field *field) { item->make_field(field); } void copy(); + int save_in_field(Field *field, bool no_conversions); table_map used_tables() const { return (table_map) 1L; } bool const_item() const { return 0; } bool is_null() { return null_value; } diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 8f55467a23e..9175f12a60c 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1920,7 +1920,8 @@ void Item_cond::neg_arguments(THD *thd) Item *new_item= item->neg_transformer(thd); if (!new_item) { - new_item= new Item_func_not(item); + if (!(new_item= new Item_func_not(item))) + return; // Fatal OEM error /* We can use 0 as tables list because Item_func_not do not use it on fix_fields and its arguments are already fixed. diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 95520c0c222..cbd1e9feffa 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -991,13 +991,13 @@ public: /* Some usefull inline functions */ -inline Item *and_conds(Item *a, Item *b, TABLE_LIST *tables) +inline Item *and_conds(THD *thd, Item *a, Item *b, TABLE_LIST *tables) { if (!b) return a; if (!a) return b; Item *cond= new Item_cond_and(a,b); if (cond) - cond->fix_fields(current_thd, tables, &cond); + cond->fix_fields(thd, tables, &cond); return cond; } diff --git a/sql/item_func.cc b/sql/item_func.cc index 9f80686e72c..fdc0ee9d6a0 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2792,8 +2792,8 @@ void Item_func_match::init_search(bool no_order) /* Above function used only to get value and do not need fix_fields for it: Item_string - basic constant - fields - fix_fieds already was called for this arguments - Item_func_concat_ws - do not need fix_fields to produce value + fields - fix_fields() was already called for this arguments + Item_func_concat_ws - do not need fix_fields() to produce value */ concat->quick_fix_field(); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 2d71f145ded..4115aac5123 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2365,7 +2365,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) !(specialflag & SPECIAL_NO_NEW_FUNC))) { table->outer_join= 0; - if (!(*conds= and_conds(*conds, table->on_expr, tables))) + if (!(*conds= and_conds(thd, *conds, table->on_expr, tables))) DBUG_RETURN(1); table->on_expr=0; } @@ -2407,14 +2407,14 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) if (!table->outer_join) // Not left join { - if (!(*conds= and_conds(*conds, cond_and, tables)) || + if (!(*conds= and_conds(thd, *conds, cond_and, tables)) || (*conds && !(*conds)->fixed && (*conds)->fix_fields(thd, tables, conds))) DBUG_RETURN(1); } else { - table->on_expr= and_conds(table->on_expr, cond_and, tables); + table->on_expr= and_conds(thd, table->on_expr, cond_and, tables); if (table->on_expr && !table->on_expr->fixed && table->on_expr->fix_fields(thd, tables, &table->on_expr)) DBUG_RETURN(1); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 94bedd9bfa2..34bfabd845f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3536,7 +3536,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) { /* Join with outer join condition */ COND *orig_cond=sel->cond; - sel->cond=and_conds(sel->cond, tab->on_expr, 0); + sel->cond=and_conds(join->thd, sel->cond, tab->on_expr, 0); if (sel->test_quick_select(join->thd, tab->keys, used_tables & ~ current_map, (join->select_options & diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 6eb72b3ac3d..f5488f59adf 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -150,6 +150,9 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, JOIN *join= new JOIN(thd_arg, sl->item_list, sl->options | thd_arg->options | additional_options, tmp_result); + if (!join) + goto err; + thd_arg->lex->current_select= sl; offset_limit_cnt= sl->offset_limit; select_limit_cnt= sl->select_limit+sl->offset_limit; @@ -178,6 +181,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, Item *item_tmp; while ((item_tmp= it++)) { + /* Error's in 'new' will be detected after loop */ types.push_back(new Item_type_holder(thd_arg, item_tmp)); } @@ -394,7 +398,10 @@ int st_select_lex_unit::exec() allocate JOIN for fake select only once (privent mysql_select automatic allocation) */ - fake_select_lex->join= new JOIN(thd, item_list, thd->options, result); + if (!(fake_select_lex->join= new JOIN(thd, item_list, thd->options, + result))) + DBUG_RETURN(-1); + /* Fake st_select_lex should have item list for correctref_array allocation. |