WordPress/sqlite-database-integration

Support FORCE INDEX

adamziel opened this issue · 1 comments

bbPress uses the following query:

SELECT SQL_CALC_FOUND_ROWS wp_posts.* 
FROM wp_posts 
FORCE INDEX (PRIMARY, post_parent) 
WHERE 1=1 
AND (wp_posts.ID = 8 OR wp_posts.post_parent = 8) 
AND ((wp_posts.post_type = 'topic' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'private' OR wp_posts.post_status = 'hidden')) OR (wp_posts.post_type = 'reply' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'private' OR wp_posts.post_status = 'hidden'))) 
ORDER BY wp_posts.post_date ASC LIMIT 0, 15

Which fails, most likely due to the FORCE INDEX (PRIMARY, post_parent) part.

SQLite counterpart is INDEXED BY, although FORCE INDEX is going to be deprecated in MySQL so perhaps ignoring that part of the query in the rewriting engine would be an acceptable resolution.

MySQL may deprecate FORCE INDEX, but it will not be removed anytime soon; MariaDB has it, and it is not deprecated there. MySQL 8.0 deprecated a few things in 2018, and they still need to remove anything yet. And, WordPress plugins that use it will take even more years to be changed for that to have effect.