Commit bff40d61 authored by unknown's avatar unknown
Browse files

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


sql/ha_innodb.cc:
  Added more comments and some polishing.
parent d70df1b2
Loading
Loading
Loading
Loading
+33 −41
Original line number Diff line number Diff line
@@ -5272,32 +5272,16 @@ ulonglong ha_innobase::get_mysql_bin_log_pos()
}

extern "C" {
/***********************************************************************
This function finds charset information and returns the character
length for multibyte character set. */

ulint innobase_get_charset_mbmaxlen(
	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.*/
/**********************************************************************
This function is used to find storage length of prefix_len characters 
in bytes for prefix indexes using multibyte character set. 
Function finds charset information and returns length of
prefix_len characters in the index field in bytes. */

ulint innobase_get_at_most_n_mbchars(
/*=================================*/
	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 */
	const char *pos)	/* in: character string */
{
@@ -5313,16 +5297,24 @@ ulint innobase_get_at_most_n_mbchars(
	ut_ad(charset);
	ut_ad(charset->mbmaxlen);

	/* Calculate the storage length of the one character in bytes and
	how many characters the prefix index contains */

	char_length = byte_length / charset->mbmaxlen;
  nth = nth / charset->mbmaxlen;
	prefix_len = prefix_len / charset->mbmaxlen;

  if (byte_length > char_length)
  {
	char_length= my_charpos(charset, pos, pos + byte_length, nth);
	/* If length of the string is greater than storage length of the
	one character, we have to find the storage position of the 
	prefix_len character in the string */

	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 = nth;
	else {
		char_length = prefix_len;
	}

	return char_length;
}