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

Errors due to MySQL8 ONLY_FULL_GROUP_BY setting #729

Closed
2SJH opened this issue Oct 17, 2021 · 6 comments
Closed

Errors due to MySQL8 ONLY_FULL_GROUP_BY setting #729

2SJH opened this issue Oct 17, 2021 · 6 comments
Labels

Comments

@2SJH
Copy link

2SJH commented Oct 17, 2021

With a new installation on Ubuntu 20.04, I've had issues with the rank keyword, but after working through that I'm finding that autosuggest doesn't work. The Javascript console reveals this:

Uncaught SyntaxError: expected expression, got '<'
setSuggestions http://localhost/jethro/resources/js/bsn_autosuggest.js?t=1634468773:186

This is caused by an uncaught exception in a HTTP request

GET | http://localhost/jethro/?call=find_person_json&search=h

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'pp.first_name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

Line 162 of File /home/www/html/jethro/include/jethrodb.php

This can be overcome by turning off the ONLY_FULL_GROUP_BY mode in MySQL

This command will temporarily clear the flag, allowing the query to work:
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

@tbar0970
Copy link
Owner

Another way of working around this for now is to enable the STRICT_MODE_FIX setting in conf.php

// Whether to explicity turn of MySQL's strict mode.
// Enable this if you experience strict-mode-related database errors and can't adjust your central Mysql config.
define('STRICT_MODE_FIX', TRUE);

@tbar0970 tbar0970 added the bug label Oct 19, 2021
@tbar0970
Copy link
Owner

Can you confirm your MySQL version?

@2SJH
Copy link
Author

2SJH commented Oct 19, 2021

Thanks for the alternative solution. I'm using mysql 8.0.26 as packaged in ubuntu 20.04.02

I found when trying the STRICT_MODE_FIX it also gives an error:

Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER' in /home/www/html/jethro/include/init.php:44 Stack trace: #0 /home/www/html/jethro/include/init.php(44):

It seems that my install of mysql also doesn't accept the NO_AUTO_CREATE_USER flag in the sql_mode. If I remove that flag from init.php, then it works fine.

The default sql_mode for my version is:

select @@sql_mode;
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |

@tbar0970
Copy link
Owner

tbar0970 commented Oct 19, 2021

Thanks for the info. I've done some reading which is telling me that

NO_AUTO_CREATE_USER is enabled by default in MySQL 5.7 but not supported in MySQL 8.0.

so as well as the problem you report in this issue, it looks like STRICT_MODE_FIX also needs adjusting.

@tbar0970 tbar0970 changed the title Autosuggest failing with MySQL 8 Errors due to MySQL8 ONLY_FULL_GROUP_BY setting Oct 26, 2021
tbar0970 added a commit that referenced this issue Oct 26, 2021
…LY_FULL_GROUP_BY is enabled by default in Mysql8 but Jethro can't function with that restriction.
@tbar0970
Copy link
Owner

tbar0970 commented Oct 26, 2021

Thanks for reporting. Overall diagnosis is:

  • There are bunch of places where Jethro relies on MySQL's previous 'relaxed' approach about GROUP BY, so Jethro can't operate with ONLY_FULL_GROUP_BY enabled (without a lot of work to rewrite queries).
  • STRICT_MODE_FIX was out of date - it referred to various settings that no longer exist in MySQL
  • Therefore I've removed the STRICT_MODE_FIX config option, and replaced it with an SQL_MODE setting which can be used to set the sql mode when required. Explained in conf.php.sample
  • It would be most efficient to disable ONLY_FULL_GROUP_BY via my.conf for those who have access to it.

@tbar0970
Copy link
Owner

I've now switched my dev environment to mysql8 (rather than mariaDB) to catch these issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants