diff options
-rw-r--r-- | mysql-test/r/ctype_cp1251.result | 4 | ||||
-rw-r--r-- | mysql-test/t/ctype_cp1251-master.opt | 2 | ||||
-rw-r--r-- | mysql-test/t/ctype_cp1251.test | 4 | ||||
-rw-r--r-- | sql/item_sum.cc | 4 | ||||
-rw-r--r-- | sql/sql_select.cc | 30 | ||||
-rw-r--r-- | sql/sql_select.h | 7 |
6 files changed, 24 insertions, 27 deletions
diff --git a/mysql-test/r/ctype_cp1251.result b/mysql-test/r/ctype_cp1251.result index 647f8c6236c..c65055e726d 100644 --- a/mysql-test/r/ctype_cp1251.result +++ b/mysql-test/r/ctype_cp1251.result @@ -1,6 +1,6 @@ drop table if exists t1; SET NAMES cp1251; -create table t1 (a varchar(10) not null); +create table t1 (a varchar(10) not null) character set cp1251; insert into t1 values ("a"),("ab"),("abc"); select * from t1; a @@ -23,7 +23,7 @@ a b c drop table t1; -create table t1 (a char(15) binary, b binary(15)); +create table t1 (a char(15) binary, b binary(15)) character set cp1251; insert into t1 values ('aaa','bbb'),('AAA','BBB'); select upper(a),upper(b) from t1; upper(a) upper(b) diff --git a/mysql-test/t/ctype_cp1251-master.opt b/mysql-test/t/ctype_cp1251-master.opt deleted file mode 100644 index af089d9f176..00000000000 --- a/mysql-test/t/ctype_cp1251-master.opt +++ /dev/null @@ -1,2 +0,0 @@ ---default-character-set=cp1251 --new - diff --git a/mysql-test/t/ctype_cp1251.test b/mysql-test/t/ctype_cp1251.test index 2d670ec3607..76873e6fa0e 100644 --- a/mysql-test/t/ctype_cp1251.test +++ b/mysql-test/t/ctype_cp1251.test @@ -10,7 +10,7 @@ SET NAMES cp1251; # Test problem with LEFT() (Bug #514) # -create table t1 (a varchar(10) not null); +create table t1 (a varchar(10) not null) character set cp1251; insert into t1 values ("a"),("ab"),("abc"); select * from t1; select a, left(a,1) as b from t1; @@ -21,7 +21,7 @@ drop table t1; # # Test of binary and upper/lower # -create table t1 (a char(15) binary, b binary(15)); +create table t1 (a char(15) binary, b binary(15)) character set cp1251; insert into t1 values ('aaa','bbb'),('AAA','BBB'); select upper(a),upper(b) from t1; select lower(a),lower(b) from t1; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 6b586c66ecf..3dbc3833f9e 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -311,8 +311,8 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table, { Field *field= ((Item_field*) args[0])->field; - if ((field= create_tmp_field_from_field(current_thd, field, this, table, - 0, convert_blob_length))) + if ((field= create_tmp_field_from_field(current_thd, field, name, table, + NULL, convert_blob_length))) field->flags&= ~NOT_NULL_FLAG; return field; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 461a0f8b9d6..00ef804d021 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7591,14 +7591,13 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item) create_tmp_field_from_field() thd Thread handler org_field field from which new field will be created - item Item to create a field for + name New field name table Temporary table - modify_item 1 if item->result_field should point to new item. - This is relevent for how fill_record() is going to - work: - If modify_item is 1 then fill_record() will update + item !=NULL if item->result_field should point to new field. + This is relevant for how fill_record() is going to work: + If item != NULL then fill_record() will update the record in the original table. - If modify_item is 0 then fill_record() will update + If item == NULL then fill_record() will update the temporary table convert_blob_length If >0 create a varstring(convert_blob_length) field instead of blob. @@ -7609,9 +7608,8 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item) */ Field* create_tmp_field_from_field(THD *thd, Field* org_field, - Item *item, TABLE *table, - bool modify_item, - uint convert_blob_length) + const char *name, TABLE *table, + Item_field *item, uint convert_blob_length) { Field *new_field; @@ -7624,10 +7622,10 @@ Field* create_tmp_field_from_field(THD *thd, Field* org_field, new_field= org_field->new_field(thd->mem_root, table); if (new_field) { - if (modify_item) - ((Item_field *)item)->result_field= new_field; + if (item) + item->result_field= new_field; else - new_field->field_name= item->name; + new_field->field_name= name; if (org_field->maybe_null()) new_field->flags&= ~NOT_NULL_FLAG; // Because of outer join if (org_field->type() == MYSQL_TYPE_VAR_STRING || @@ -7782,8 +7780,10 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, case Item::DEFAULT_VALUE_ITEM: { Item_field *field= (Item_field*) item; - return create_tmp_field_from_field(thd, (*from_field= field->field), item, - table, modify_item, convert_blob_length); + return create_tmp_field_from_field(thd, (*from_field= field->field), + item->name, table, + modify_item ? (Item_field*) item : NULL, + convert_blob_length); } case Item::FUNC_ITEM: case Item::COND_ITEM: @@ -7805,7 +7805,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, { Field *example= ((Item_type_holder *)item)->example(); if (example) - return create_tmp_field_from_field(thd, example, item, table, 0, + return create_tmp_field_from_field(thd, example, item->name, table, NULL, convert_blob_length); return create_tmp_field_from_item(thd, item, table, copy_func, 0, convert_blob_length); diff --git a/sql/sql_select.h b/sql/sql_select.h index 556d5b3d89b..381ccbba4fd 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -402,10 +402,9 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, int error, bool ignore_last_dupp_error); uint find_shortest_key(TABLE *table, const key_map *usable_keys); Field* create_tmp_field_from_field(THD *thd, Field* org_field, - Item *item, TABLE *table, - bool modify_item, - uint convert_blob_length); - + const char *name, TABLE *table, + Item_field *item, uint convert_blob_length); + /* functions from opt_sum.cc */ bool simple_pred(Item_func *func_item, Item **args, bool *inv_order); int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds); |