Tests: In Tests_dbDelta, only force MyISAM database engine on MySQL versions older than 5.7.

Since MySQL 5.7, InnoDB engine supports `FULLTEXT` indexes, so forcing MyISAM is unnecessary.

Follow-up to [47193], which addressed the issue in `Tests_dbDelta::setUp()`, but missed other tests.

Props xkon, joonasvanhatapio, SergeyBiryukov.
Fixes #49367.

git-svn-id: https://develop.svn.wordpress.org/trunk@47195 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-02-05 22:05:50 +00:00
parent 3d43f46907
commit 56e4630c0e

View File

@ -14,6 +14,13 @@ class Tests_dbDelta extends WP_UnitTestCase {
*/ */
protected $max_index_length = 191; protected $max_index_length = 191;
/**
* Database engine used for creating tables.
*
* Prior to MySQL 5.7, InnoDB did not support FULLTEXT indexes, so MyISAM is used instead.
*/
protected $db_engine = '';
/** /**
* Display width for BIGINT data type. * Display width for BIGINT data type.
* *
@ -40,11 +47,10 @@ class Tests_dbDelta extends WP_UnitTestCase {
global $wpdb; global $wpdb;
$db_version = $wpdb->db_version(); $db_version = $wpdb->db_version();
$db_engine = '';
if ( version_compare( $db_version, '5.7', '<' ) ) { if ( version_compare( $db_version, '5.7', '<' ) ) {
// Forcing MyISAM, because InnoDB only started supporting FULLTEXT indexes in MySQL 5.7. // Prior to MySQL 5.7, InnoDB did not support FULLTEXT indexes, so MyISAM is used instead.
$db_engine = 'ENGINE=MyISAM'; $this->db_engine = 'ENGINE=MyISAM';
} }
if ( version_compare( $db_version, '8.0.17', '<' ) ) { if ( version_compare( $db_version, '8.0.17', '<' ) ) {
@ -66,7 +72,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY compound_key (id,column_1(%d)), KEY compound_key (id,column_1(%d)),
FULLTEXT KEY fulltext_key (column_1)" . FULLTEXT KEY fulltext_key (column_1)" .
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
") $db_engine ") {$this->db_engine}
", ",
$this->max_index_length, $this->max_index_length,
$this->max_index_length $this->max_index_length
@ -450,7 +456,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY key_1 (column_1({$this->max_index_length})), KEY key_1 (column_1({$this->max_index_length})),
KEY compound_key (id,column_1($this->max_index_length)), KEY compound_key (id,column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1) FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
", ",
false false
); );
@ -475,7 +481,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY key_1 (column_1({$this->max_index_length})), KEY key_1 (column_1({$this->max_index_length})),
KEY compound_key (id,column_1($this->max_index_length)), KEY compound_key (id,column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1) FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
", ",
false false
); );
@ -500,7 +506,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY key_1 (column_1({$this->max_index_length})), KEY key_1 (column_1({$this->max_index_length})),
KEY compound_key (id,column_1($this->max_index_length)), KEY compound_key (id,column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1) FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
", ",
false false
); );
@ -531,7 +537,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY key_1 (column_1({$this->max_index_length})), KEY key_1 (column_1({$this->max_index_length})),
KEY compound_key (id,column_1($this->max_index_length)), KEY compound_key (id,column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1) FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
", ",
false false
); );
@ -596,7 +602,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
spatial_value {$geomcollection_name} NOT NULL, spatial_value {$geomcollection_name} NOT NULL,
KEY non_spatial (non_spatial), KEY non_spatial (non_spatial),
SPATIAL KEY spatial_key (spatial_value) SPATIAL KEY spatial_key (spatial_value)
) ENGINE=MyISAM; ) {$this->db_engine};
"; ";
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
@ -615,7 +621,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY non_spatial (non_spatial), KEY non_spatial (non_spatial),
SPATIAL KEY spatial_key (spatial_value) SPATIAL KEY spatial_key (spatial_value)
SPATIAL KEY spatial_key2 (spatial_value2) SPATIAL KEY spatial_key2 (spatial_value2)
) ENGINE=MyISAM; ) {$this->db_engine};
"; ";
$updates = dbDelta( $schema, false ); $updates = dbDelta( $schema, false );
@ -679,7 +685,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY compound_key (id , column_1($this->max_index_length)), KEY compound_key (id , column_1($this->max_index_length)),
KEY compound_key2 (id,`references`($this->max_index_length)), KEY compound_key2 (id,`references`($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1) FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
" "
); );
@ -725,7 +731,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
UNIQUE KEY key_3 (column_1($this->max_index_length)), UNIQUE KEY key_3 (column_1($this->max_index_length)),
UNIQUE INDEX key_4 (column_1($this->max_index_length)), UNIQUE INDEX key_4 (column_1($this->max_index_length)),
FULLTEXT INDEX key_5 (column_1), FULLTEXT INDEX key_5 (column_1),
) ENGINE=MyISAM ) {$this->db_engine}
"; ";
$creates = dbDelta( $schema ); $creates = dbDelta( $schema );
@ -760,7 +766,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
INDEX key_1 (column_1($this->max_index_length)), INDEX key_1 (column_1($this->max_index_length)),
INDEX compound_key (id,column_1($this->max_index_length)), INDEX compound_key (id,column_1($this->max_index_length)),
FULLTEXT INDEX fulltext_key (column_1) FULLTEXT INDEX fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
" "
); );
@ -785,7 +791,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
FULLTEXT KEY fulltext_key (column_1), FULLTEXT KEY fulltext_key (column_1),
KEY key_2 (column_1(10)), KEY key_2 (column_1(10)),
KEY key_3 (column_2(100),column_1(10)), KEY key_3 (column_2(100),column_1(10)),
) ENGINE=MyISAM ) {$this->db_engine}
"; ";
$creates = dbDelta( $schema ); $creates = dbDelta( $schema );
@ -818,7 +824,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY key_1 (column_1($this->max_index_length) DESC), KEY key_1 (column_1($this->max_index_length) DESC),
KEY compound_key (id,column_1($this->max_index_length) ASC), KEY compound_key (id,column_1($this->max_index_length) ASC),
FULLTEXT KEY fulltext_key (column_1) FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
" "
); );
@ -842,7 +848,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY key_1 (column_1($this->max_index_length)), KEY key_1 (column_1($this->max_index_length)),
KEY compound_key (id,column_1($this->max_index_length)), KEY compound_key (id,column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1) FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
" "
); );
@ -866,7 +872,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY key_1 ( column_1($this->max_index_length)), KEY key_1 ( column_1($this->max_index_length)),
KEY compound_key (id, column_1($this->max_index_length)), KEY compound_key (id, column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1) FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
" "
); );
@ -890,7 +896,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
key key_1 (column_1($this->max_index_length)), key key_1 (column_1($this->max_index_length)),
key compound_key (id,column_1($this->max_index_length)), key compound_key (id,column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1) FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
" "
); );
@ -914,7 +920,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY KEY_1 (column_1($this->max_index_length)), KEY KEY_1 (column_1($this->max_index_length)),
KEY compOUND_key (id,column_1($this->max_index_length)), KEY compOUND_key (id,column_1($this->max_index_length)),
FULLTEXT KEY FULLtext_kEY (column_1) FULLTEXT KEY FULLtext_kEY (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
", ",
false false
); );
@ -939,7 +945,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY key_1 (column_1({$this->max_index_length})), KEY key_1 (column_1({$this->max_index_length})),
KEY compound_key (id,column_1($this->max_index_length)), KEY compound_key (id,column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1) FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
", ",
false false
); );
@ -965,7 +971,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY compound_key (id,column_1($this->max_index_length)), KEY compound_key (id,column_1($this->max_index_length)),
KEY changing_key_length (column_1(20)), KEY changing_key_length (column_1(20)),
FULLTEXT KEY fulltext_key (column_1) FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
" "
); );
@ -988,7 +994,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY compound_key (id,column_1($this->max_index_length)), KEY compound_key (id,column_1($this->max_index_length)),
KEY changing_key_length (column_1(50)), KEY changing_key_length (column_1(50)),
FULLTEXT KEY fulltext_key (column_1) FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
" "
); );
@ -1006,7 +1012,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY compound_key (id,column_1($this->max_index_length)), KEY compound_key (id,column_1($this->max_index_length)),
KEY changing_key_length (column_1(1)), KEY changing_key_length (column_1(1)),
FULLTEXT KEY fulltext_key (column_1) FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
" "
); );
@ -1024,7 +1030,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY compound_key (id,column_1), KEY compound_key (id,column_1),
KEY changing_key_length (column_1), KEY changing_key_length (column_1),
FULLTEXT KEY fulltext_key (column_1) FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM ) {$this->db_engine}
" "
); );