Character Set Modifications for MySQL innoDB on CloudSQL

86 views
Skip to first unread message

Tim Hj

unread,
Sep 10, 2020, 11:56:01 AM9/10/20
to Google Cloud SQL discuss
There's a need to add a couple of new characters as word characters for better fulltext indexing in our app. The solutions are doable on our local environments but not in CloudSQL.

The MySQL 5.7 docs suggest the following 3 methods for making modifications to the character sets to change fulltext indexing behaviour. None of them are doable with CloudSQL in its current state as far as I can tell. 

Character Set Modifications

For the built-in full-text parser, you can change the set of characters that are considered word characters in several ways, as described in the following list. After making the modification, rebuild the indexes for each table that contains any FULLTEXT indexes. Suppose that you want to treat the hyphen character ('-') as a word character. Use one of these methods:

  • Modify the MySQL source: In storage/innobase/handler/ha_innodb.cc (for InnoDB), or in storage/myisam/ftdefs.h (for MyISAM), see the true_word_char() and misc_word_char() macros. Add '-' to one of those macros and recompile MySQL.

  • Modify a character set file: This requires no recompilation. The true_word_char() macro uses a “character type” table to distinguish letters and numbers from other characters. . You can edit the contents of the <ctype><map> array in one of the character set XML files to specify that '-' is a “letter.” Then use the given character set for your FULLTEXT indexes. For information about the <ctype><map> array format, see Section 10.13.1, “Character Definition Arrays”.

  • Add a new collation for the character set used by the indexed columns, and alter the columns to use that collation. For general information about adding collations, see Section 10.14, “Adding a Collation to a Character Set”. For an example specific to full-text indexing, see Section 12.10.7, “Adding a User-Defined Collation for Full-Text Indexing”.

Is there away to extend the character sets used in CloudSQL's mysql or another way in cloudsql to add additional word characters for the purpose of fulltext indexing?

wushawn

unread,
Sep 15, 2020, 10:50:45 AM9/15/20
to Google Cloud SQL discuss
Cloud SQL MySQL only support character_set_server which 'stringutf8 or utf8mb4 (recommended)'
Reply all
Reply to author
Forward
0 new messages