Complex Character Sets

Character sets requiring special string collating routines for sorting or multi-byte character support will need custom work a configuration file simply cannot handle. To accomplish this task, you will need to be familiar with C programming, as you will need to create several C source files. If you plan to attempt this, it is highly recommended that you study the existing ctype-*.c files and base yours on these.

As with simple character sets, you need to edit the sql/share/charsets/Index and configure.in files. Instead of a configuration file, however, you need to create a C source file called ctype -charset.c. In our case, this file will be ctype-elvish.c. You can get a head start with your character set file by copying the source file for a similar character set.

The first task in this source file is to define ctype , to_lower , to_upper , and sort_order . These are the same arrays you configured in the previous section, except they are defined as C arrays. You’ll need to create:

  • ctype_ charset

  • to_upper_ charset

  • to_lower_ charset

  • sort_order_ charset

For our example, we need to create ctype_elvish, to_upper_elvish, to_lower_elvish, and sort_order_elvish.

If you need string collating functions, you must write your own custom string collating functions. These functions should be named:

  • my_strnncoll_ charset

  • my_strnxfrm_ charset

  • my_strcoll_ charset

  • my_strxfrm_ charset

  • my_like_range_ charset

We therefore need to create my_strnncoll_elvish, my_strnxfrm_elvish, my_strcoll_elvish, my_strxfrm_elvish, and my_like_range_elvish.

Multi-byte support requires the coding of special multi-byte functions:

  • ismbchar_ charset

  • ismbhead_ charset

  • mbcharlen_ charset

We need to create ismbchar_elvish, ismbhead_elvish, and mbcharlen_elvish.

With your coding complete, you need to create a comment header for your ctype file. This header should look like this:

/*
 * This comment is parsed by configure to create ctype.c,
 * so don't change it unless you know what you are doing.
 *
 * .configure. number_charset=[character set index number from Index file]
 * .configure. strxfrm_multiply_charset=[max ratio that strings may grow
 *                                       during my_strxfrm_charset - a
 *                                       positive integer]
 * .configure. mbmaxlen_charset=[size in bytes of largest char in set]
 */

For our example, this might look like:

 * .configure. number_elvish=32
 * .configure. strxfrm_multiply_elvish=1
 * .configure. mbmaxlen_elvish=2

Finally, compile MySQL and install your new binaries supporting the custom character set.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset