-
Bug
-
Resolution: Fixed
-
Major
-
3.8.5, 3.9.2, 3.10, 4.0
-
MOODLE_310_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE
-
MOODLE_38_STABLE, MOODLE_39_STABLE
-
There are 2 issues to fix here (both were detected @ MDL-63252):
A) mariadb driver is fetching wrong defaults from database metadata
Has been confirmed that, for any mariadb version >= 10.2.7, columns having no default (aka, default = null), are interpreted (by metadata utilities) like having a default of '' (empty string).
This is easily reproducible by the xmldb_editor check defaults reports and may impact also upgrade scripts changing defaults here and there.
Tracing down the problem, it comes from MDL-59583, where the handling of defaults was changed, because of a change in mariadb 10.2.7 and up.
Also, itt seems that the case for null defaults (aka, no default), escaped all the checks. It seems that, in lib/dml/tests/dml_test.php, the test_get_columns test is missing to test nulls.
So this point is about to:
- Fix the metadata handling to correctly detect nulls as no-default.
- Complete existing tests to cover the fix.
B) xmldb reports (check indexes, check defaults, check bigints...) show old metadata info
All those reports, extending XMLDBCheckAction, use $DB->get_columns() to fetch metadata. Problem is that the information provided by that function is cached by MUC so, if anybody execute any ALTER statement to fix a default, an int... on next execution the report will continue showing the same information, leading to confusion.
For sure, that will make the reports slightly slower, but that's not really important at all, accuracy must win.
So this point is about to:
- Ensure that the reports always fetch fresh (non-cached) information from database.
And that's all, ciao
And thanks to syxton and smithrn for detecting the problems and reporting them.