[3.x] Make database schema check ignore display widths for all integer types on MySQL or MariaDB databases#32605
Conversation
|
I have tested this item ✅ successfully on ff2a226 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32605. |
Thanks, will add a hint to testing instructions that exact number of problems doesn't matter for that test step.
The red error alerts stay on the page until closed, even on reload. That's why step 3 tells to close it. Maybe another bug we found.
You are right, that's a copy&paste remainder. Will remove it. Thanks for testing and feedback. |
|
I have tested this item ✅ successfully on ff2a226 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32605. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32605. |

Pull Request for #28501 (comment) .
Summary of Changes
This pull request (PR) extends the fix from #28501 for the database schema check to integer data types other than
intandtinyint.It only relevant for MySQL and MariaDB databases, ie not PostgreSQL.
As stated in PR #28501 and issue #32542 , the display width modifier has no impact on value range or storage size of a database column of one of the integer data types.
While MySQL deprecated these display widths beginning with version 8.0.17 and doesn't include them anymore in the type returned by a
SHOW COLUMNSstatement, MariaDB still supports and uses display widths modifiers for integer types so it still behaves like MySQL <= 5.7.With this PR I took the chance for refactoring the parts which have been modified before with #28501 for
intandtinyinttypes, so that code is more readable and also more precise with checking the types and so doesn't hide anymore typos in update SQL scripts.Testing Instructions
Requirement: Have an installation of current staging or latest 3.9.x nightly build which uses a MySQL or MariaDB database.
Testers please report back which of the following 2 kinds of databases you have used for the test:
If you have both scenarios available, please test both.
Step 1: Add 2 new update SQL scripts as follows to folder
administrator/components/com_admin/sql/updates/mysql:If you are not comfortable with editing you can also download them using the link in the script names.
The reason why it needs the 2nd script is that the database schema checker checks only for the existence of the table for
CREATE TABLEstatements but not for the columns. This is checked eg forALTER TABLE ... MODIFYstatements which here just add a default value for having some change but don't touch the data type.Step 2: Go to "Extensions -> Manage Database".
Result: An error alert about the 2 tables missing is shown, and some 23 database problems have been found (the exact number may differ, but it doesn't matter for this test step here):

Step 3: Close the red error alert by using the "x" button at its top right corner (only visible on hover).
Step 4: Use the "Fix" button.
Result: See section "Actual result BEFORE applying this Pull Request" below.
Step 5: Edit the 2nd SQL script
3.9.26-2021-03-06.sqland apply a typo by appending something to the data type for the database table for which no database problem is shown, ie:#__test_table_2#__test_table_1See example here with an
Xappended to theinttype of thecol_intcolumn:Then go again to "Extensions -> Manage Database", or if still there reload the page.
Result: There is still no database problem shown for that table, i.e. the typo is silently ignored.
Step 6: Revert the change with the typo made in the previous step in the 2nd SQL script.
Step 7: Only for MySQL database servers with versions lower than 8.0.17 or on any server version of MariaDB.
If you have a MySQL database servers with version 8.0.17 or later, skip this test step.
This test step doesn't test this PR but proofs that display widths don't matter for the value range and so safely can be ignored.
Using a tool like eg phpMyAdmin, insert a row as follows into the 2nd table
#__test_table_2:Replace
#__with your table prefix before executing the statement.Verify that the values of all columns have been saved for that record with the values specified in the insert statement, regardless of the fact that they all exceed the display width of the particular column.
Step 8: Apply the changes from this PR.
Step 9: Go again to "Extensions -> Manage Database", or if still there reload the page.
Result: See section "Expected result AFTER applying this Pull Request" below.
Step 10: Repeat Step 5: with the typo having something appended to the data type for any column of any of the 2 tables.
Result: A database problem is shown due to the not matching type with the typo, ie the typo in the SQL script becomes obvious now. Don't use the "Fix" button now, it would cause an SQL error.
Actual result BEFORE applying this Pull Request
6 errors reported for
#__test_table_1, no errors reported for#__test_table_2.6 errors reported for
#__test_table_2, no errors reported for#__test_table_1.Expected result AFTER applying this Pull Request
No database problems found.
Additional info for maintainers / release leads
This PR should go up to 3.10-dev and 4.0-dev, too.
It's most urgent for 4.0-dev since in J4 the database checker is also used for extensions and non only the core, so the likelihood to get a relevant SQL statement in an update SQL script which triggers the error (false database problems found) is much higher than in 3.9.x/3.10.
Documentation Changes Required
None.