diff options
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/sql/field.cc b/sql/field.cc index 177f219c137..a5d2d759edc 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1224,7 +1224,8 @@ bool Field::test_if_equality_guarantees_uniqueness(const Item *item) const for temporal columns, so the query: WHERE temporal_column='string' cannot return multiple distinct temporal values. - QQ: perhaps we could allow INT/DECIMAL/DOUBLE types for temporal items. + + TODO: perhaps we could allow INT/DECIMAL/DOUBLE types for temporal items. */ return result_type() == item->result_type(); } @@ -5647,6 +5648,18 @@ Item *Field_temporal::get_equal_const_item_datetime(THD *thd, } break; case ANY_SUBST: + if (!is_temporal_type_with_date(const_item->field_type())) + { + MYSQL_TIME ltime; + if (const_item->get_date_with_conversion(<ime, + TIME_FUZZY_DATES | + TIME_INVALID_DATES)) + return NULL; + return new (thd->mem_root) + Item_datetime_literal_for_invalid_dates(thd, <ime, + ltime.second_part ? + TIME_SECOND_PART_DIGITS : 0); + } break; } return const_item; @@ -5955,7 +5968,10 @@ Item *Field_time::get_equal_const_item(THD *thd, const Context &ctx, { MYSQL_TIME ltime; // Get the value of const_item with conversion from DATETIME to TIME - if (const_item->get_time_with_conversion(thd, <ime, TIME_TIME_ONLY)) + if (const_item->get_time_with_conversion(thd, <ime, + TIME_TIME_ONLY | + TIME_FUZZY_DATES | + TIME_INVALID_DATES)) return NULL; /* Replace a DATE/DATETIME constant to a TIME constant: @@ -7121,8 +7137,7 @@ int Field_string::cmp(const uchar *a_ptr, const uchar *b_ptr) */ return field_charset->coll->strnncollsp(field_charset, a_ptr, a_len, - b_ptr, b_len, - 0); + b_ptr, b_len); } @@ -7496,7 +7511,7 @@ int Field_varstring::cmp_max(const uchar *a_ptr, const uchar *b_ptr, a_length, b_ptr+ length_bytes, - b_length,0); + b_length); return diff; } @@ -7519,7 +7534,7 @@ int Field_varstring::key_cmp(const uchar *key_ptr, uint max_key_length) length, key_ptr+ HA_KEY_BLOB_LENGTH, - uint2korr(key_ptr), 0); + uint2korr(key_ptr)); } @@ -7537,8 +7552,7 @@ int Field_varstring::key_cmp(const uchar *a,const uchar *b) a + HA_KEY_BLOB_LENGTH, uint2korr(a), b + HA_KEY_BLOB_LENGTH, - uint2korr(b), - 0); + uint2korr(b)); } @@ -7868,7 +7882,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED; uint copy_length, new_length; String_copier copier; - const char *tmp; + char *tmp; char buff[STRING_BUFFER_USUAL_SIZE]; String tmpstr(buff,sizeof(buff), &my_charset_bin); @@ -7878,6 +7892,29 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) return 0; } + if (table->blob_storage) // GROUP_CONCAT with ORDER BY | DISTINCT + { + DBUG_ASSERT(!f_is_hex_escape(flags)); + DBUG_ASSERT(field_charset == cs); + DBUG_ASSERT(length <= max_data_length()); + + new_length= length; + copy_length= table->in_use->variables.group_concat_max_len; + if (new_length > copy_length) + { + int well_formed_error; + new_length= cs->cset->well_formed_len(cs, from, from + copy_length, + new_length, &well_formed_error); + table->blob_storage->set_truncated_value(true); + } + if (!(tmp= table->blob_storage->store(from, new_length))) + goto oom_error; + + Field_blob::store_length(new_length); + bmove(ptr + packlength, (uchar*) &tmp, sizeof(char*)); + return 0; + } + /* If the 'from' address is in the range of the temporary 'value'- object we need to copy the content to a different location or it will be @@ -7904,15 +7941,14 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) new_length= MY_MIN(max_data_length(), field_charset->mbmaxlen * length); if (value.alloc(new_length)) goto oom_error; - + tmp= const_cast<char*>(value.ptr()); if (f_is_hex_escape(flags)) { copy_length= my_copy_with_hex_escaping(field_charset, - (char*) value.ptr(), new_length, - from, length); + tmp, new_length, + from, length); Field_blob::store_length(copy_length); - tmp= value.ptr(); bmove(ptr + packlength, (uchar*) &tmp, sizeof(char*)); return 0; } @@ -7920,7 +7956,6 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) (char*) value.ptr(), new_length, cs, from, length); Field_blob::store_length(copy_length); - tmp= value.ptr(); bmove(ptr+packlength,(uchar*) &tmp,sizeof(char*)); return check_conversion_status(&copier, from + length, cs, true); @@ -8017,8 +8052,7 @@ int Field_blob::cmp(const uchar *a,uint32 a_length, const uchar *b, uint32 b_length) { return field_charset->coll->strnncollsp(field_charset, - a, a_length, b, b_length, - 0); + a, a_length, b, b_length); } |