Compare commits

..

5 commits

Author SHA1 Message Date
rxu
be3438d573
Merge e37312c397 into 2fce8aeb3e 2025-06-11 05:23:47 +00:00
rxu
e37312c397
[ticket/17524] Debug what's wrong
PHPBB-17524
2025-06-11 12:23:23 +07:00
rxu
4bdf5ab6d2
[ticket/17524] Do not hit MSSQL index key size limit of 900 bytes
MSSQL index size limitations are 16 key columns and 900 bytes
(prior to SQL Server 2016 (13.x)) and a maximum of 32 key columns
and a maximum index key size of 1,700 bytes (as of SQL Server 2016 (13.x)).

PHPBB-17524
2025-06-10 21:33:24 +07:00
rxu
993e637af9
[ticket/17524] test index key length only on MySQL where it does apply
PHPBB-17524
2025-06-10 15:22:46 +07:00
rxu
83c6ffce64
[ticket/17524] Add index migrator tests
PHPBB-17524
2025-06-10 13:55:48 +07:00
3 changed files with 11 additions and 12 deletions

View file

@ -514,7 +514,7 @@ class doctrine implements tools_interface
catch (Exception $e)
{
// @todo: check if it makes sense to properly handle the exception
return false;
return [$e->getMessage()];
}
}

View file

@ -26,15 +26,15 @@ class phpbb_dbal_migration_schema extends \phpbb\db\migration\migration
'COLUMNS' => [
'module_id' => ['UINT:3', NULL, 'auto_increment'],
'user_id' => ['ULINT', 0],
'endpoint' => ['TEXT', ''],
'endpoint' => ['VCHAR:220', ''],
'expiration_time' => ['TIMESTAMP', 0],
'p256dh' => ['VCHAR', ''],
'p256dh' => ['VCHAR:200', ''],
'auth' => ['VCHAR:100', ''],
],
'PRIMARY_KEY' => 'module_id',
'KEYS' => [
'i_simple' => ['INDEX', ['user_id', 'endpoint:191']],
'i_uniq' => ['UNIQUE', ['expiration_time', 'p256dh(100)']],
// 'i_simple' => ['INDEX', ['user_id', 'endpoint:191']],
// 'i_uniq' => ['UNIQUE', ['expiration_time', 'p256dh(100)']],
'i_auth' => ['INDEX', 'auth'],
],
],

View file

@ -409,8 +409,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
$this->assertTrue($this->db_tools->sql_table_exists('phpbb_foobar'));
$index_data_row = $this->db_tools->sql_get_table_index_data('phpbb_foobar');
$is_mysql = $this->db->get_sql_layer() === 'mysqli'; // Index length only applies to MySQL indexes
$is_mssql = in_array($this->db->get_sql_layer(), ['mssqlnative', 'mssql_odbc']); // MSSQL primary index key has 'clustered' flag
$mysql = $this->db->get_sql_layer() === 'mysqli'; // Index length only applies to MySQL indexes
foreach ($index_data_row as $index_name => $index_data)
{
switch ($index_name)
@ -423,9 +422,9 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
$this->assertTrue($index_data['is_simple']);
$this->assertEquals(2, count($index_data['options']['lengths']));
$this->assertEmpty($index_data['options']['lengths'][0]);
$this->assertEquals($is_mysql ? 191 : null, $index_data['options']['lengths'][1]);
$this->assertEquals($mysql ? 191 : null, $index_data['options']['lengths'][1]);
break;
case 'i_uniq':
/* case 'i_uniq':
$this->assertEquals(['expiration_time', 'p256dh'], $index_data['columns']);
$this->assertEmpty($index_data['flags']);
$this->assertFalse($index_data['is_primary']);
@ -433,8 +432,8 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
$this->assertFalse($index_data['is_simple']);
$this->assertEquals(2, count($index_data['options']['lengths']));
$this->assertEmpty($index_data['options']['lengths'][0]);
$this->assertEquals($is_mysql ? 100 : null, $index_data['options']['lengths'][1]);
break;
$this->assertEquals($mysql ? 100 : null, $index_data['options']['lengths'][1]);
break;*/
case 'i_auth':
$this->assertEquals(['auth'], $index_data['columns']);
$this->assertEmpty($index_data['flags']);
@ -446,7 +445,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
break;
default: // Primary key
$this->assertEquals(['module_id'], $index_data['columns']);
$this->assertEquals($is_mssql ? ['clustered'] : [], $index_data['flags']);
$this->assertEmpty($index_data['flags']);
$this->assertTrue($index_data['is_primary']);
$this->assertTrue($index_data['is_unique']);
$this->assertFalse($index_data['is_simple']);