diff options
author | unknown <mhansson@dl145s.mysql.com> | 2007-05-21 10:27:33 +0200 |
---|---|---|
committer | unknown <mhansson@dl145s.mysql.com> | 2007-05-21 10:27:33 +0200 |
commit | 84966af9fc33a4cfa72f24a57da170db28f1c55a (patch) | |
tree | a62ec66f999f1c490922cac311cd09db6534054b /sql | |
parent | 1e33cfb36a84b477a468dbcfc1ccc3035a9efb81 (diff) | |
download | mariadb-git-84966af9fc33a4cfa72f24a57da170db28f1c55a.tar.gz |
bug#23856
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.h | 5 | ||||
-rw-r--r-- | sql/field_conv.cc | 14 | ||||
-rw-r--r-- | sql/item_sum.cc | 14 | ||||
-rw-r--r-- | sql/sql_select.cc | 5 |
4 files changed, 32 insertions, 6 deletions
diff --git a/sql/field.h b/sql/field.h index 47f61c1fe8b..94c5d94def4 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1108,6 +1108,11 @@ public: class Field_varstring :public Field_longstr { public: + /* + The maximum space available in a Field_varstring, in bytes. See + length_bytes. + */ + static const int MAX_SIZE= UINT_MAX16; /* Store number of bytes used to store length (1 or 2) */ uint32 length_bytes; Field_varstring(char *ptr_arg, diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 5670b1e0676..5c74ea9e49f 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -530,7 +530,21 @@ void Copy_field::set(char *to,Field *from) } +/* + To do: + + If 'save\ is set to true and the 'from' is a blob field, do_copy is set to + do_save_blob rather than do_conv_blob. The only differences between them + appears to be: + - do_save_blob allocates and uses an intermediate buffer before calling + Field_blob::store. Is this in order to trigger the call to + well_formed_copy_nchars, by changing the pointer copy->tmp.ptr()? + That call will take place anyway in all known cases. + + - The above causes a truncation to MAX_FIELD_WIDTH. Is this the intended + effect? Truncation is handled by well_formed_copy_nchars anyway. + */ void Copy_field::set(Field *to,Field *from,bool save) { if (to->type() == FIELD_TYPE_NULL) diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 4579ecd48ae..443b3782d6b 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -432,7 +432,7 @@ Field *Item_sum::create_tmp_field(bool group, TABLE *table, 2-byte lenght. */ if (max_length/collation.collation->mbmaxlen > 255 && - convert_blob_length < UINT_MAX16 && convert_blob_length) + convert_blob_length <= Field_varstring::MAX_SIZE && convert_blob_length) return new Field_varstring(convert_blob_length, maybe_null, name, table, collation.collation); @@ -3269,14 +3269,20 @@ bool Item_func_group_concat::setup(THD *thd) tmp_table_param->force_copy_fields= force_copy_fields; DBUG_ASSERT(table == 0); /* + Currently we have to force conversion of BLOB values to VARCHAR's + if we are to store them in TREE objects used for ORDER BY and + DISTINCT. This leads to truncation if the BLOB's size exceeds + Field_varstring::MAX_SIZE. + */ + if (arg_count_order > 0 || distinct) + set_if_smaller(tmp_table_param->convert_blob_length, + Field_varstring::MAX_SIZE); + /* We have to create a temporary table to get descriptions of fields (types, sizes and so on). Note that in the table, we first have the ORDER BY fields, then the field list. - - We need to set set_sum_field in true for storing value of blob in buffer - of a record instead of a pointer of one. */ if (!(table= create_tmp_table(thd, tmp_table_param, all_fields, (ORDER*) 0, 0, TRUE, diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 967322600a7..1d8e10ed84b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8794,7 +8794,7 @@ Field* create_tmp_field_from_field(THD *thd, Field* org_field, Make sure that the blob fits into a Field_varstring which has 2-byte lenght. */ - if (convert_blob_length && convert_blob_length < UINT_MAX16 && + if (convert_blob_length && convert_blob_length <= Field_varstring::MAX_SIZE && (org_field->flags & BLOB_FLAG)) new_field= new Field_varstring(convert_blob_length, org_field->maybe_null(), @@ -8885,7 +8885,8 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, 2-byte lenght. */ else if (item->max_length/item->collation.collation->mbmaxlen > 255 && - convert_blob_length < UINT_MAX16 && convert_blob_length) + convert_blob_length <= Field_varstring::MAX_SIZE && + convert_blob_length) new_field= new Field_varstring(convert_blob_length, maybe_null, item->name, table, item->collation.collation); |