Bug #109885 ALTER TABLE doesn't update use_stopword when dropping & recreating
Submitted: 1 Feb 2023 21:19 Modified: 2 Feb 2023 8:01
Reporter: Flaviu Tamas Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: FULLTEXT search Severity:S3 (Non-critical)
Version:8.0.23, 8.0.32 OS:Linux (Docker mysql:8.0.23)
Assigned to: CPU Architecture:x86

[1 Feb 2023 21:19] Flaviu Tamas
Description:
After altering the `innodb_ft_enable_stopword` flag, dropping and recreating a full-text in a single alter table statement will fail to update the 'use_stopword' flag.

How to repeat:
CREATE TABLE test (id INT, name VARCHAR(255));
SET innodb_ft_enable_stopword = 1;
ALTER TABLE test
    ADD FULLTEXT INDEX name_fti (name) WITH PARSER ngram;
SET GLOBAL innodb_ft_aux_table= '<snip>/test';
SELECT value FROM information_schema.INNODB_FT_CONFIG where `key`='use_stopword';
-- returns 1

SET innodb_ft_enable_stopword = 0;
ALTER TABLE test
    DROP INDEX name_fti,
    ADD FULLTEXT INDEX name_fti (name) WITH PARSER ngram;
SELECT value FROM information_schema.INNODB_FT_CONFIG where `key`='use_stopword';
-- returns 1

ALTER TABLE test
    DROP INDEX name_fti;
ALTER TABLE test
    ADD FULLTEXT INDEX name_fti (name) WITH PARSER ngram;
SELECT value FROM information_schema.INNODB_FT_CONFIG where `key`='use_stopword';
-- returns 0

Suggested fix:
I suspect this is related to the following call chain prepare_inplace_alter_table_dict() -> innobase_fts_load_stopword() -> fts_load_stopword(reload=false)

Correct behavior would be to call fts_load_stopword(reload=true) in this case.
[2 Feb 2023 8:01] MySQL Verification Team
Hello Flaviu Tamas,

Thank you for the report and test case.
Verified as described.

regards,
Umesh