Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-18439 - support MySQL 5.7 sql_mode=only_full_group_by #8511

Merged
merged 7 commits into from
Jul 13, 2016

Conversation

jitendrapurohit
Copy link
Contributor

@jitendrapurohit jitendrapurohit commented Jun 6, 2016

@yashodha yashodha merged commit b81f831 into civicrm:master Jul 13, 2016
$sqlMode = CRM_Core_DAO::singleValueQuery('SELECT @@sql_mode');

//return if ONLY_FULL_GROUP_BY is not enabled.
if (!version_compare($mysqlVersion, '5.7', '<') && !empty($sqlMode) && in_array('ONLY_FULL_GROUP_BY', explode(',', $sqlMode))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we do this? I understood the ONLY_FULL_GROUP_BY as forcing better queries - but I thought they would still be valid in pre 5.7?

Copy link
Contributor Author

@jitendrapurohit jitendrapurohit Jul 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few reason behind this-

  1. Main reason being the ANY_VALUE keyword which is only introduced in 5.7+ which we use it here in some summary reports (Membership, Contribution, etc) which enforces the result to group by selected columns.

  2. MySQL 5.7+ has some enhancements to ONLY_FULL_GROUP_BY mode that recognizes Functional Dependencies unlike in lower versions which work on blindly including all the select columns in group_by clause.

@jitendrapurohit jitendrapurohit deleted the CRM-18439 branch July 14, 2016 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants