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

issue #445, licensing: use ANY_VALUE() around shortName column #536

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

t4k
Copy link
Contributor

@t4k t4k commented Feb 13, 2019

see #445

The underlying error from PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in …/licensing/admin/classes/domain/License.php on line 731, referer: http://localhost:8080/coral/organizations/index.php

is

Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'coral_licensing.L.shortName' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

Running the query directly in MySQL 5.7 will produce the error. Using the
ANY_VALUE() function suppresses the test for nondeterminism.

https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_any-value

The underlying error from `PHP Warning:  mysqli_fetch_assoc() expects parameter
1 to be mysqli_result, boolean given in
…/licensing/admin/classes/domain/License.php on line 731, referer:
http://localhost:8080/coral/organizations/index.php`

is

`Expression #1 of SELECT list is not in GROUP BY clause and contains
nonaggregated column 'coral_licensing.L.shortName' which is not functionally
dependent on columns in GROUP BY clause; this is incompatible with
sql_mode=only_full_group_by`

Running the query directly in MySQL 5.7 will produce the error. Using the
ANY_VALUE() function suppresses the test for nondeterminism.

https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_any-value
@t4k t4k added the bug This is a bug (not an enhancement) label Feb 13, 2019
@t4k t4k changed the title use ANY_VALUE() around shortName column licensing: use ANY_VALUE() around shortName column Feb 13, 2019
@t4k t4k changed the title licensing: use ANY_VALUE() around shortName column issue #445, licensing: use ANY_VALUE() around shortName column Feb 13, 2019
@veggiematts
Copy link
Contributor

Results of my test, which are not conclusive:

  • without the patch, without ONLY_FULL_GROUP_BY: OK
  • without the patch, with ONLY_FULL_GROUP_BY: NOK
  • with the patch, without ONLY_FULL_GROUP_BY: NOK (should be OK)
  • with the patch, with ONLY_FULL_GROUP_BY: NOK (should be OK).

Can someone else test this?

@t4k
Copy link
Contributor Author

t4k commented Mar 22, 2019

I've done some further testing on this and the results are confusing. MySQL 5.7 and MariaDB 10.3 each have different results with ONLY_FULL_GROUP_BY set in the SQL mode.

MariaDB 10.3

ONLY_FULL_GROUP_BY and zero results

  • no errors

ONLY_FULL_GROUP_BY and zero results with patch

  • PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/coral/licensing/admin/classes/domain/License.php on line 733

ONLY_FULL_GROUP_BY and one result

  • no errors

ONLY_FULL_GROUP_BY and one result with patch

  • PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/coral/licensing/admin/classes/domain/License.php on line 733

no ONLY_FULL_GROUP_BY and zero results

  • no errors

no ONLY_FULL_GROUP_BY and zero results with patch

  • PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/coral/licensing/admin/classes/domain/License.php on line 733

no ONLY_FULL_GROUP_BY and one result

  • no errors

no ONLY_FULL_GROUP_BY and one result with patch

  • PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/coral/licensing/admin/classes/domain/License.php on line 733

MySQL 5.7

ONLY_FULL_GROUP_BY and zero results

  • PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/coral/licensing/admin/classes/domain/License.php on line 733

ONLY_FULL_GROUP_BY and zero results with patch

  • no errors

ONLY_FULL_GROUP_BY and one result

  • PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/coral/licensing/admin/classes/domain/License.php on line 733

ONLY_FULL_GROUP_BY and one result with patch

  • no errors

no ONLY_FULL_GROUP_BY and zero results

  • PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/coral/licensing/admin/classes/domain/License.php on line 733

no ONLY_FULL_GROUP_BY and zero results with patch

  • no errors

no ONLY_FULL_GROUP_BY and one result

  • PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/coral/licensing/admin/classes/domain/License.php on line 733

no ONLY_FULL_GROUP_BY and one result with patch

  • no errors

@t4k t4k self-assigned this Mar 22, 2019
@t4k
Copy link
Contributor Author

t4k commented Mar 22, 2019

MariaDB does not have the ANY_VALUE() function: https://jira.mariadb.org/browse/MDEV-10426

We can use a different aggregate function to get around the ONLY_FULL_GROUP_BY problem: https://stackoverflow.com/a/54173805/4100024

I'll work on some experiments with MIN() and MAX() and maybe others.

https://mariadb.com/kb/en/library/aggregate-functions/
https://dev.mysql.com/doc/refman/5.7/en/group-by-functions.html

MariaDB does not have ANY_VALUE() function.
@t4k
Copy link
Contributor Author

t4k commented Mar 22, 2019

This issues turned out to be the easy one. I just matched the SELECT value to the GROUP BY value exactly by adding UPPER() around the GROUP BY.

The other patches I made in other issues using ANY_VALUE() are not going to work. I will work on those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is a bug (not an enhancement)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants