Don't guess system schema collation

Fixes #18950
This commit is contained in:
Maurício Meneghini Fauth 2024-01-30 13:43:00 -03:00 committed by GitHub
commit b0dceda8f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 12 deletions

View File

@ -2210,12 +2210,6 @@ class DatabaseInterface implements DbalInterface
*/
public function getDbCollation(string $db): string
{
if (Utilities::isSystemSchema($db)) {
// We don't have to check the collation of the virtual
// information_schema database: We know it!
return 'utf8_general_ci';
}
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
// this is slow with thousands of databases
$sql = 'SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA'

View File

@ -278,12 +278,6 @@ class DatabaseInterfaceTest extends AbstractTestCase
public function testGetDbCollation(): void
{
$GLOBALS['server'] = 1;
// test case for system schema
$this->assertEquals(
'utf8_general_ci',
$this->dbi->getDbCollation('information_schema')
);
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['cfg']['DBG']['sql'] = false;
@ -291,6 +285,16 @@ class DatabaseInterfaceTest extends AbstractTestCase
'utf8_general_ci',
$this->dbi->getDbCollation('pma_test')
);
$GLOBALS['cfg']['Server']['DisableIS'] = true;
$this->dummyDbi->addSelectDb('information_schema');
$GLOBALS['db'] = 'information_schema';
$this->dummyDbi->removeDefaultResults();
$this->dummyDbi->addResult('SELECT @@collation_database', [['utf8mb3_general_ci']], ['@@collation_database']);
$this->assertEquals('utf8mb3_general_ci', $this->dbi->getDbCollation('information_schema'));
}
/**