Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-75856

Ensure MySQL 5 & 8 return consistent column->max_length metadata for bigints

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • 3.11.10, 4.0.4, 4.1
    • Database SQL/XMLDB
    • None
    • MOODLE_311_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE

    Description

      It has been detected that MySQL 5 and 8 are returning different column->max_length metadata for bigints.

      • MySQL 5 returns 18.
      • MySQL 8 returns 19.

      While this doesn't have any impact running Moodle, there are other tools which tests started to fail (see local_ci, for example, because they perform some verifications of that metadata information.

      The change is caused because of changes between the 2 versions in the information_schema.columns->column_type information.

      With MySQL 5 it used to return the max length within parenthesis (aka, bigint(18)) and with MySQL 8 it doesn't return that info any more (aka, simple bigint).

      Because of that, some logic has started to fail within both fetch_columns() and get_column_info() leading to the different metadata results.

      So we need to keep the behavior consistent, returning those 18s when bigints are used.

      And cover it with specific MySQL tests (note it's already covered by generic test_get_columns(), but it's using assertGreaterThanOrEqual(), so both the 18 and the 19 are passing.

      Finally, don't forget to verify the behaviour of other ints too (small, tiny, medium, integer or int...). That has not been verified.

      Ciao

      PS: Again, note this doesn't have much impact in real Moodle usage, only utilities / checks using that metadata information are affected. Moodle doesn't use that for anything (that I've been able to find).

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              stronk7 Eloy Lafuente (stronk7)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: