diff options
author | unknown <monty@mishka.local> | 2005-07-19 19:25:05 +0300 |
---|---|---|
committer | unknown <monty@mishka.local> | 2005-07-19 19:25:05 +0300 |
commit | 3a31f7b91f9aea5c6bab45157c3a661252720174 (patch) | |
tree | 98d1121d654b01cf2306965326d1355704fc1218 /sql/field_conv.cc | |
parent | ddc3586495aa82f310b0e5c2127b77f28c711c27 (diff) | |
download | mariadb-git-3a31f7b91f9aea5c6bab45157c3a661252720174.tar.gz |
Simple fixes during review of new code
include/my_global.h:
Added floatget() to read unaligned flaot
mysql-test/r/select.result:
Added test for found_rows()
mysql-test/t/select.test:
Added test for found_rows()
sql/des_key_file.cc:
Moved initalization of LOCK_des_key_file to mysqld to make simpler code and avoid theoretical race condition
sql/field_conv.cc:
Added optimizzed varsion of do_cut_string (for simple character sets)
sql/item_func.cc:
Simplify code (and ensure DBUG_ENTER is excuted before main code)
sql/item_strfunc.cc:
Safe calculation of max_length
This was needed as max_length can now be 1<<32-1 (after konstantins recent patch to fix BLOB_LENGTH)
Remove init_des_key_file() as this is not initialized in mysqld.cc
sql/item_timefunc.cc:
Safe calculation of max_length
This was needed as max_length can now be 1<<32-1 (after konstantins recent patch to fix BLOB_LENGTH)
sql/log_event.cc:
Simplify code
sql/mysql_priv.h:
Moved initalization of LOCK_des_key_file to mysqld to make simpler code and avoid theoretical race condition
sql/mysqld.cc:
Moved initalization of LOCK_des_key_file to mysqld to make simpler code and avoid theoretical race condition
Revert wrong patch of calling close_connection() in first close_connections() loop. (Bug #7403)
Instead we now print a warning for closed connections only if mysqld is sarted with --warnings
Added comments to make the close_connections() logic clearer
sql/sql_prepare.cc:
Use floatget() and doubleget() to protect against unaligned data
sql/sql_select.cc:
Fixed some cases unlikely cases where found_rows() would return wrong for queries that would return 0 or 1 rows
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r-- | sql/field_conv.cc | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc index a447716a818..7998dd6d5f8 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -324,7 +324,34 @@ static void do_field_real(Copy_field *copy) } +/* + string copy for single byte characters set when to string is shorter than + from string +*/ + static void do_cut_string(Copy_field *copy) +{ + CHARSET_INFO *cs= copy->from_field->charset(); + memcpy(copy->to_ptr,copy->from_ptr,copy->to_length); + + /* Check if we loosed any important characters */ + if (cs->cset->scan(cs, + copy->from_ptr + copy->to_length, + copy->from_ptr + copy->from_length, + MY_SEQ_SPACES) < copy->from_length - copy->to_length) + { + copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, + ER_WARN_DATA_TRUNCATED, 1); + } +} + + +/* + string copy for multi byte characters set when to string is shorter than + from string +*/ + +static void do_cut_string_complex(Copy_field *copy) { // Shorter string field int well_formed_error; CHARSET_INFO *cs= copy->from_field->charset(); @@ -351,6 +378,8 @@ static void do_cut_string(Copy_field *copy) } + + static void do_expand_string(Copy_field *copy) { CHARSET_INFO *cs= copy->from_field->charset(); @@ -517,7 +546,8 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*) from_length) return do_varstring; else if (to_length < from_length) - return do_cut_string; + return (from->charset()->mbmaxlen == 1 ? + do_cut_string : do_cut_string_complex); else if (to_length > from_length) return do_expand_string; } |