Commit bff40d61 authored by unknown's avatar unknown

Added more comments on the code and made some code polishing.


sql/ha_innodb.cc:
  Added more comments and some polishing.
parent d70df1b2
...@@ -5272,59 +5272,51 @@ ulonglong ha_innobase::get_mysql_bin_log_pos() ...@@ -5272,59 +5272,51 @@ ulonglong ha_innobase::get_mysql_bin_log_pos()
} }
extern "C" { extern "C" {
/*********************************************************************** /**********************************************************************
This function finds charset information and returns the character This function is used to find storage length of prefix_len characters
length for multibyte character set. */ in bytes for prefix indexes using multibyte character set.
Function finds charset information and returns length of
ulint innobase_get_charset_mbmaxlen( prefix_len characters in the index field in bytes. */
ulint charset_id) /* in: charset id */
{
CHARSET_INFO* charset; /* charset used in the field */
charset = get_charset(charset_id,MYF(MY_WME));
ut_ad(charset);
ut_ad(charset->mbmaxlen);
return charset->mbmaxlen;
}
}
extern "C" {
/***********************************************************************
This function finds charset information and returns position the nth
character for multibyte character set.*/
ulint innobase_get_at_most_n_mbchars( ulint innobase_get_at_most_n_mbchars(
/*=================================*/
ulint charset_id, /* in: character set id */ ulint charset_id, /* in: character set id */
ulint nth, /* in: nth character */ ulint prefix_len, /* in: prefix length of the index */
ulint data_len, /* in: length of the sting in bytes */ ulint data_len, /* in: length of the sting in bytes */
const char *pos) /* in: character string */ const char *pos) /* in: character string */
{ {
ulint byte_length; /* storage length, in bytes. */ ulint byte_length; /* storage length, in bytes. */
ulint char_length; /* character length in bytes */ ulint char_length; /* character length in bytes */
CHARSET_INFO* charset; /* charset used in the field */ CHARSET_INFO* charset; /* charset used in the field */
ut_ad(pos); ut_ad(pos);
byte_length = data_len; byte_length = data_len;
charset = get_charset(charset_id,MYF(MY_WME)); charset = get_charset(charset_id,MYF(MY_WME));
ut_ad(charset); ut_ad(charset);
ut_ad(charset->mbmaxlen); ut_ad(charset->mbmaxlen);
char_length= byte_length / charset->mbmaxlen; /* Calculate the storage length of the one character in bytes and
nth = nth / charset->mbmaxlen; how many characters the prefix index contains */
if (byte_length > char_length) char_length = byte_length / charset->mbmaxlen;
{ prefix_len = prefix_len / charset->mbmaxlen;
char_length= my_charpos(charset, pos, pos + byte_length, nth);
set_if_smaller(char_length, byte_length); /* If length of the string is greater than storage length of the
} one character, we have to find the storage position of the
else prefix_len character in the string */
char_length = nth;
if (byte_length > char_length) {
char_length = my_charpos(charset, pos,
pos + byte_length, prefix_len);
set_if_smaller(char_length, byte_length);
}
else {
char_length = prefix_len;
}
return char_length; return char_length;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment