summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc29
-rw-r--r--sql/field.h11
-rw-r--r--sql/field_conv.cc9
3 files changed, 36 insertions, 13 deletions
diff --git a/sql/field.cc b/sql/field.cc
index aeeacf7f88d..ceea0893a3f 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -7068,6 +7068,35 @@ uint32 Field_blob::get_length(const uchar *pos, uint packlength_arg)
}
+/**
+ Copy a value from another BLOB field of the same character set.
+ This method is used by Copy_field, e.g. during ALTER TABLE.
+*/
+int Field_blob::copy_value(Field_blob *from)
+{
+ DBUG_ASSERT(field_charset == from->charset());
+ int rc= 0;
+ uint32 length= from->get_length();
+ uchar *data;
+ from->get_ptr(&data);
+ if (packlength < from->packlength)
+ {
+ int well_formed_errors;
+ set_if_smaller(length, Field_blob::max_data_length());
+ length= field_charset->cset->well_formed_len(field_charset,
+ (const char *) data,
+ (const char *) data + length,
+ length, &well_formed_errors);
+ rc= report_if_important_data((const char *) data + length,
+ (const char *) data + from->get_length(),
+ true);
+ }
+ store_length(length);
+ bmove(ptr + packlength, (uchar*) &data, sizeof(char*));
+ return rc;
+}
+
+
int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
{
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
diff --git a/sql/field.h b/sql/field.h
index 4c79847228e..49f94179a92 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1830,6 +1830,11 @@ protected:
*/
String value;
+ void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number);
+ inline void store_length(uint32 number)
+ {
+ store_length(ptr, packlength, number);
+ }
public:
Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg,
@@ -1902,11 +1907,6 @@ public:
int reset(void) { bzero(ptr, packlength+sizeof(uchar*)); return 0; }
void reset_fields() { bzero((uchar*) &value,sizeof(value)); }
uint32 get_field_buffer_size(void) { return value.alloced_length(); }
- void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number);
- inline void store_length(uint32 number)
- {
- store_length(ptr, packlength, number);
- }
inline uint32 get_length(uint row_offset= 0)
{ return get_length(ptr+row_offset, this->packlength); }
uint32 get_length(const uchar *ptr, uint packlength);
@@ -1935,6 +1935,7 @@ public:
{
set_ptr_offset(0, length, data);
}
+ int copy_value(Field_blob *from);
uint get_key_image(uchar *buff,uint length, imagetype type);
void set_key_image(const uchar *buff,uint length);
void sql_type(String &str) const;
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index d24f31e4fa1..3fdc1639266 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -332,9 +332,7 @@ static void do_copy_next_number(Copy_field *copy)
static void do_copy_blob(Copy_field *copy)
{
- ulong length=((Field_blob*) copy->from_field)->get_length();
- ((Field_blob*) copy->to_field)->store_length(length);
- memcpy(copy->to_ptr, copy->from_ptr, sizeof(char*));
+ ((Field_blob*) copy->to_field)->copy_value(((Field_blob*) copy->from_field));
}
static void do_conv_blob(Copy_field *copy)
@@ -709,12 +707,7 @@ Copy_field::get_copy_func(Field *to,Field *from)
if (!(from->flags & BLOB_FLAG) || from->charset() != to->charset())
return do_conv_blob;
if (from_length != to_length)
- {
- // Correct pointer to point at char pointer
- to_ptr+= to_length - to->table->s->blob_ptr_size;
- from_ptr+= from_length- from->table->s->blob_ptr_size;
return do_copy_blob;
- }
}
else
{