The call notation of CHARSET_INFO routines has some disadvantages:
- it looks cumbersome
- it exposes internal structure of CHARSET_INFO to the caller
To make the call notation simple and proof to changes in CHARSET_INFO, lets do the following:
- Add pure C wrappers for all virtual functions in MY_CHARSET_HANDLER and MY_COLLATION_HANDLER, e.g.
Let's call all new functions using the my_ci_ prefix, to make it clear that the first argument is CHARSET_INFO.
- Add C++ methods into struct charset_info_st, like this:
so the code in the above examples will turn into:
The new notation is better, as it does not contain sequences like cs->cset-> and cs->coll->, and the CHARSET_INFO parameter is mentioned only one time (instead of two times), so the new style of the caller code:
- is shorter
- is less bug prone
- is future proof: it won't change if we change the structure CHARSET_INFO, e.g. decompose CHARSET_INFO into smaller pieces responsible for character set and collation properties. Only the wrapper functions and methods will change, the caller code will remain the same.