[4.4] Add database configuration option for "sql_big_selects" session variable on MySQL or MariaDB databases - alternative#42558
Closed
richard67 wants to merge 5 commits intojoomla:4.4-devfrom
Closed
Conversation
Add config option for SQL_BIG_SELECTS session variable on MySQL or MariaDB databases
Set "sql_big_selects session" variable if enforced by config
4 tasks
4 tasks
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request for Issue #41156 .
See also issues #17580 and #39479 , discussion #42198 and support forum thread https://forum.joomla.org/viewtopic.php?f=811&t=995872 .
Alternative approach to PR #42557 .
Summary of Changes
This pull request (PR) adds a new option to the "Database" section of Global Configuration which allows to set the "sql_big_selects" session variable to on or off or leave it untouched, which is the default.
In opposite to PR #42557 , this one here doesn't require an update of the database dependency from the framework, so it can be used in case if the framework PR joomla-framework/database#292 gets rejected for some reason.
So when people run into the
1104 The SELECT would examine more than MAX_JOIN_SIZE rows ...error with their database server, they can fix that by switching the new option to "Yes".When the default value of the option is used, which is also the case after a CMS update to a new version which includes this PR here, then nothing is done, so there is no unnecessary SQL statement issues with each connection in that case.
The issue has been reported more frequently in recent times, so I think we should fix it as a bug fix in 4.4-dev and merge it up later.
I have made the additional feature PR #42559 for the 5.1-dev branch to show the values of the "sql_big_selects" and "max_join_size" variables in the System Information on MySQL or MariaDB databases.
Testing Instructions
This PR is only relevant for MySQL or MariaDB databases, not for PostgreSQL.
For some test steps which change the global "sql_big_select" variable it needs to have administrator privileges for the database. E.g. on a local MySQL you have to connect with user "root" when using e.g. phpMyAdmin. That means that these test steps can't be executed in a shared hosting environment.
usestatements in the PHP code at the top, e.g. if Cassiopeia is used file "templates/cassiopeia/index.php" at line 20, to show the current value of the "sql_big_select" session variable:You can find packages for new installation and update and a custom update URL here: https://artifacts.joomla.org/drone/joomla/joomla-cms/4.4-dev/42558/downloads/72502 .
Result: There is a new list select option "Allow large queries", and the first value "No change (server controlled)" is selected, which is the default,
Result: The value of the "sql_big_selects" session variable has not changed, it is still the same as in step 2.
Result: The value of the "sql_big_selects" session variable has changed to the desired value (0 for "No" and 1 for "Yes").
In a client like e.g. phpMyAdmin, change the value of the "sql_big_selects" global variable so that the session variable should change. E.g. if the current value of the session variable check in step 9 was 0, change the global variable to 1, and vice versa.
Example for changing to 1:
Result: The value of the "sql_big_selects" session variable has not changed, it is still the same as selected in step 9.
Result: Now the value of the "sql_big_selects" session variable has changed compared to steps 9 and 11. It is equal to the value set in step10 for the global variable.
Result: When the new option has its default value "No change (server controlled)", the "sql_big_selects" session variable has the value as set by the server with the global variable.
If the new option has value "No", the "sql_big_selects" session variable is set to 0.
If the new option has value "Yes", the "sql_big_selects" session variable is set to 1.
Either just restart the database sever, or set the global variable back to the value which it had in step 3.
Actual result BEFORE applying this Pull Request
There is no way to change the value of the "sql_big_select" session variable.
Expected result AFTER applying this Pull Request
A new list select option "Allow large queries" is available at the end of the "Database" section in the "Server" tab of Global Configuration (
$dbsqlbigselectsinconfiguration.php).The option is only shown when the selected database type is "MySQLi" or "MySQL (PDO)". When "PostgreSQL (PDO)" is selected, the new option is hidden.
The value of that option is the default value "No change (server controlled)" after a new installation or an update.
When the new option has that default value, the value of the "sql_big_selects" session variable is not changed by the CMS, and no additional SQL statement is performed when connecting to the database.
When the new option has value "No", the value of the "sql_big_selects" session variable is set to 0 when connecting to the database.
When the new option has value "Yes", the value of the "sql_big_selects" session variable is set to 1 when connecting to the database. This will prevent the SQL error
1104 The SELECT would examine more than MAX_JOIN_SIZE rows ....Link to documentations
Please select:
Documentation link for docs.joomla.org: https://docs.joomla.org/Help4.x:Site_Global_Configuration https://docs.joomla.org/Help4.x:Site_Global_Configuration_Server
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
A description of the new "Allow large queries" parameter should be added to the end of sub-section "database" of the "Server" section on https://docs.joomla.org/Help4.x:Site_Global_Configuration / https://help.joomla.org/proxy?keyref=Help44:Site_Global_Configuration&lang=en .
Suggested text:
-- "No change (server controlled)" (default)
-- "No"
-- "Yes"
Use "Yes" if you get the SQL error "1104 The SELECT would examine more than MAX_JOIN_SIZE rows" on your site.
The screenshot on https://docs.joomla.org/Help4.x:Site_Global_Configuration_Server needs to be updated so it shows the new option.