Moodle

Unicode check returns MySQL server default collation rather than the database collation - problem on hosted servers

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: 1.8
  • Fix Version/s: None
  • Component/s: Installation, Unicode
  • Labels:
    None
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_18_STABLE

Description

During installation, to ensure that the database uses unicode, there is a check to make sure that the database is using UTF8; however, the current check returns the collation default for the MySQL server rather than the particular database. As a result, if a hosted website by default uses latin1 but the user creates a utf8 database they still cannot install Moodle.

After researching the issue, I discovered that in MySQL 5.0.6 it became possible to check the collation of a particular database and I think we should use that rather than then previous method to help avoid issues on hosted sites. I am attaching the PMA_getDbCollation function used by phpMyAdmin to show how things work.

In essence I am proposing that if the database is MySQL 5.0.6 and greater that we use:

SELECT DEFAULT_COLLATION_NAME
FROM information_schema.SCHEMATA
WHERE SCHEMA_NAME = 'database_name';

rather than SHOW VARIABLES LIKE 'character_set_database';

Peace - Anthony

Issue Links

Activity

Hide
Anthony Borrow added a comment -

This screenshot shows a false positive on the error check. The database itself is unicode (utf8_general_ci); however, the database server default is latin.

Show
Anthony Borrow added a comment - This screenshot shows a false positive on the error check. The database itself is unicode (utf8_general_ci); however, the database server default is latin.
Hide
Anthony Borrow added a comment -

Hopefully some of the comments here are helpful

Show
Anthony Borrow added a comment - Hopefully some of the comments here are helpful
Hide
Anthony Borrow added a comment -

duplicate of MDL-11743

Show
Anthony Borrow added a comment - duplicate of MDL-11743
Hide
onitzuka added a comment -

I tried the statement on MySQL 5.0.37 and 5.0.45 and it worked.

Maybe this is good for MySQL 5.x in general.

Show
onitzuka added a comment - I tried the statement on MySQL 5.0.37 and 5.0.45 and it worked. Maybe this is good for MySQL 5.x in general.
Hide
onitzuka added a comment -

Wow... I tried the query doing with a wildcard for the fields like this:

SELECT * FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = 'database_name';

and it shows CHARACTER SET and COLLATION along with the name of the table! This is very cool!!

Show
onitzuka added a comment - Wow... I tried the query doing with a wildcard for the fields like this: SELECT * FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = 'database_name'; and it shows CHARACTER SET and COLLATION along with the name of the table! This is very cool!!

People

Vote (3)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: