~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to sql/sql_string.cc

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <my_sys.h>
24
24
#include <m_string.h>
25
25
#include <m_ctype.h>
 
26
#include <mysql_com.h>
26
27
#ifdef HAVE_FCONVERT
27
28
#include <floatingpoint.h>
28
29
#endif
975
976
        uint pad_length= to_cs->mbminlen - from_offset;
976
977
        bzero(to, pad_length);
977
978
        memmove(to + pad_length, from, from_offset);
 
979
        /*
 
980
          In some cases left zero-padding can create an incorrect character.
 
981
          For example:
 
982
            INSERT INTO t1 (utf32_column) VALUES (0x110000);
 
983
          We'll pad the value to 0x00110000, which is a wrong UTF32 sequence!
 
984
          The valid characters range is limited to 0x00000000..0x0010FFFF.
 
985
          
 
986
          Make sure we didn't pad to an incorrect character.
 
987
        */
 
988
        if (to_cs->cset->well_formed_len(to_cs,
 
989
                                         to, to + to_cs->mbminlen, 1,
 
990
                                         &well_formed_error) !=
 
991
                                         to_cs->mbminlen)
 
992
        {
 
993
          *from_end_pos= *well_formed_error_pos= from;
 
994
          *cannot_convert_error_pos= NULL;
 
995
          return 0;
 
996
        }
978
997
        nchars--;
979
998
        from+= from_offset;
980
999
        from_length-= from_offset;