diff options
author | Jorgen Loland <jorgen.loland@oracle.com> | 2011-11-18 14:47:11 +0100 |
---|---|---|
committer | Jorgen Loland <jorgen.loland@oracle.com> | 2011-11-18 14:47:11 +0100 |
commit | 4fc5752fb88d1294010a62063e8f1081664286d3 (patch) | |
tree | f2c10e722e05f8fc5af94c7fe26fe02f5983ab13 | |
parent | 4de17022c2249a6e6ff718e5f52ca1625db83c9d (diff) | |
download | mariadb-git-4fc5752fb88d1294010a62063e8f1081664286d3.tar.gz |
Backmerge of BUG#12997905
-rw-r--r-- | sql/field.h | 17 | ||||
-rw-r--r-- | sql/field_conv.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 3 |
3 files changed, 21 insertions, 1 deletions
diff --git a/sql/field.h b/sql/field.h index 8db965a8270..ca23702fd8c 100644 --- a/sql/field.h +++ b/sql/field.h @@ -2128,6 +2128,23 @@ public: uchar *from_null_ptr,*to_null_ptr; my_bool *null_row; uint from_bit,to_bit; + /** + Number of bytes in the fields pointed to by 'from_ptr' and + 'to_ptr'. Usually this is the number of bytes that are copied from + 'from_ptr' to 'to_ptr'. + + For variable-length fields (VARCHAR), the first byte(s) describe + the actual length of the text. For VARCHARs with length + < 256 there is 1 length byte + >= 256 there is 2 length bytes + Thus, if from_field is VARCHAR(10), from_length (and in most cases + to_length) is 11. For VARCHAR(1024), the length is 1026. @see + Field_varstring::length_bytes + + Note that for VARCHARs, do_copy() will be do_varstring*() which + only copies the length-bytes (1 or 2) + the actual length of the + text instead of from/to_length bytes. @see get_copy_func() + */ uint from_length,to_length; Field *from_field,*to_field; String tmp; // For items diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 1dc7ec57944..ff56a1fdda8 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -707,7 +707,7 @@ Copy_field::get_copy_func(Field *to,Field *from) if (((Field_varstring*) to)->length_bytes != ((Field_varstring*) from)->length_bytes) return do_field_string; - if (to_length != from_length) + else return (((Field_varstring*) to)->length_bytes == 1 ? (from->charset()->mbmaxlen == 1 ? do_varstring1 : do_varstring1_mb) : diff --git a/sql/sql_select.cc b/sql/sql_select.cc index bf0cd7c9db8..72c826ff32d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -10647,6 +10647,9 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, if (open_tmp_table(table)) goto err; + // Make empty record so random data is not written to disk + empty_record(table); + thd->mem_root= mem_root_save; DBUG_RETURN(table); |