From 16a849f257d01ad1e03b37b4aa421559143e053f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Feb 2006 19:40:58 +0100 Subject: [PATCH 1/2] storage/example/ha_example.cc Copied from the general tree, to solve a build problem: ChangeSet 1.2121.1.5 2006/02/02 11:02:09 stewart@mysql.com build fix when building with example storage engine. storage/example/ha_example.cc: Copied from the general tree, to solve a build problem: ChangeSet 1.2121.1.5 2006/02/02 11:02:09 stewart@mysql.com build fix when building with example storage engine. --- storage/example/ha_example.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index 30034496291..0e9dcf231d9 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -106,6 +106,7 @@ handlerton example_hton= { NULL, /* Partition flags */ NULL, /* Alter table flags */ NULL, /* Alter tablespace */ + NULL, /* Fill Files table */ HTON_CAN_RECREATE }; From 733b1c4005965af7fe60d3bcf314567c0c6e7b09 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Feb 2006 01:49:33 +0300 Subject: [PATCH 2/2] Copied patch for BUG#15588 (BUG#16621) from 5.0 into 5.1-release. sql/field.cc: Use memmove() instead of memcpy() -- after implementation of WL#2984 (Make stored routine variables work according to the standard) it is possible to store in the field the value from this field. For instance, this can happen for the following statement: SET sp_var = SUBSTR(sp_var, 1, 3); sql/sp_head.cc: Work correctly with String: - String length has to be be reset before use; - qs_append() does not allocate memory, so the memory should be reserved beforehand. --- sql/field.cc | 4 ++-- sql/sp_head.cc | 37 +++++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 37cab37f7d2..0045c3ece8d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5880,7 +5880,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) field_length/ field_charset->mbmaxlen, &well_formed_error); - memcpy(ptr,from,copy_length); + memmove(ptr,from,copy_length); /* Append spaces if the string was shorter than the field. */ if (copy_length < field_length) @@ -6296,7 +6296,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) field_length/ field_charset->mbmaxlen, &well_formed_error); - memcpy(ptr + length_bytes, from, copy_length); + memmove(ptr + length_bytes, from, copy_length); if (length_bytes == 1) *ptr= (uchar) copy_length; else diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 33eb652208f..0119bac22f0 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -105,21 +105,27 @@ sp_get_item_value(Item *item, String *str) case STRING_RESULT: { - char buf_holder[STRING_BUFFER_USUAL_SIZE]; - String buf(buf_holder, sizeof(buf_holder), &my_charset_latin1); String *result= item->val_str(str); if (!result) return NULL; - buf.append('_'); - buf.append(result->charset()->csname); - buf.append('\''); - buf.append(*result); - buf.append('\''); - str->copy(buf); - - return str; + { + char buf_holder[STRING_BUFFER_USUAL_SIZE]; + String buf(buf_holder, sizeof (buf_holder), result->charset()); + + /* We must reset length of the buffer, because of String specificity. */ + buf.length(0); + + buf.append('_'); + buf.append(result->charset()->csname); + buf.append('\''); + buf.append(*result); + buf.append('\''); + str->copy(buf); + + return str; + } } case ROW_RESULT: @@ -3076,9 +3082,16 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp) void sp_instr_set_case_expr::print(String *str) { - str->append(STRING_WITH_LEN("set_case_expr ")); + const char CASE_EXPR_TAG[]= "set_case_expr "; + const int CASE_EXPR_TAG_LEN= sizeof(CASE_EXPR_TAG) - 1; + const int INT_STRING_MAX_LEN= 10; + + /* We must call reserve(), because qs_append() doesn't care about memory. */ + str->reserve(CASE_EXPR_TAG_LEN + INT_STRING_MAX_LEN + 2); + + str->qs_append(CASE_EXPR_TAG, CASE_EXPR_TAG_LEN); str->qs_append(m_case_expr_id); - str->append(' '); + str->qs_append(' '); m_case_expr->print(str); }