Summary: | Patrons with the most checkouts (bor_issues_top.pl) is failing with MySQL 8 | ||
---|---|---|---|
Product: | Koha | Reporter: | Humberto Chula <development> |
Component: | Reports | Assignee: | Jonathan Druart <jonathan.druart> |
Status: | Pushed to oldoldoldstable --- | QA Contact: | Marcel de Rooy <m.de.rooy> |
Severity: | critical | ||
Priority: | P5 - low | CC: | david, jonathan.druart, kyle, m.de.rooy, michael.hafen, victor, wainuiwitikapark |
Version: | unspecified | ||
Hardware: | All | ||
OS: | All | ||
See Also: |
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28524 https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23997 |
||
Change sponsored?: | --- | Patch complexity: | Trivial patch |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: |
21.11.00,21.05.02,20.11.08,20.05.14,19.11.20
|
|
Circulation function: | |||
Bug Depends on: | |||
Bug Blocks: | 23996 | ||
Attachments: |
Bug 28523: Escape 'rank' in bor_issues_top.pl
Bug 28523: Escape 'rank' in bor_issues_top.pl Bug 28523: Escape 'rank' in bor_issues_top.pl |
Description
Humberto Chula
2021-06-07 21:03:17 UTC
Created attachment 122037 [details] [review] Bug 28523: Escape 'rank' in bor_issues_top.pl It's a MySQL 8 keyword Test plan: Turn off strict_sql_modes (there are other problems in this script) Hit Home Reports > Patrons with the most checkouts Submit the form Without this patch you got: You have an error in your SQL syntax; check the manual that corresponds to your MySQL s erver version for the right syntax to use near 'RANK, borrowers.borrowernumber AS ID FROM `old_issues` With this patch applied you see the report result view I attempted to test this. With MySQL 8 I was able to get this to work following the test plan (starting KTD with ku=my8). However, if I change back to MariaDB (starting KTD with ku) I get a different error message: CGI::Compile::ROOT::kohadevbox_koha_reports_bor_issues_top_2epl::calculate(): DBI Exception: DBD::mysql::st execute failed: 'koha_kohadev.borrowers.surname' isn't in GROUP BY [for Statement "SELECT CONCAT_WS('', borrowers.surname , ",\t", borrowers.firstname), COUNT(*) AS `RANK`, borrowers.borrowernumber AS ID FROM `old_issues` LEFT JOIN borrowers USING(borrowernumber) LEFT JOIN items USING(itemnumber) LEFT JOIN biblioitems USING(biblioitemnumber) WHERE old_issues.borrowernumber IS NOT NULL AND old_issues.issuedate > '2021-06-01' AND old_issues.issuedate < '2021-06-30' AND old_issues.returndate > '2021-06-01' AND old_issues.returndate < '2021-06-30' GROUP BY borrowers.borrowernumber ORDER BY `RANK` DESC LIMIT 5"] at /kohadevbox/koha/reports/bor_issues_top.pl line 70 at /usr/share/perl5/DBIx/Class/Exception.pm line 77 Testing notes (koha-testing-docker): - Start KTD with MySQL 8 (rather than MariaDB): ku-my8 - Turn off strict mode (https://www.linode.com/community/questions/17070/how-can-i-disable-mysql-strict-mode): . access database container: docker exec -it koha_db_1 bash . mysql -uroot -ppassword . SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION'; . SELECT @@GLOBAL.sql_mode; Hi David, The "isn't in GROUP BY" error is happening when strict modes are set. To turn them off you need to edit $KOHA_CONF and set the value for <strict_sql_modes> to 0. Setting them globally is not enough as we are setting them when we initiate the connection to the DB: https://git.koha-community.org/Koha-community/Koha/src/commit/d3ab8dbeec188ad21c468d82ba8692e89df77a59/Koha/Database.pm#L77 Thanks Jonathan! I can now get this to work with MySQL 8 (ku-my8). With the patch applied in master with MariaDB (ku), I need to turn off strict mode to get this to work. Is that what is expected, or is another bug going to fix this? David Created attachment 122395 [details] [review] Bug 28523: Escape 'rank' in bor_issues_top.pl It's a MySQL 8 keyword Test plan: Turn off strict_sql_modes (there are other problems in this script) Hit Home Reports > Patrons with the most checkouts Submit the form Without this patch you got: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RANK, borrowers.borrowernumber AS ID FROM `old_issues` With this patch applied you see the report result view Signed-off-by: Owen Leonard <oleonard@myacpl.org> Created attachment 122417 [details] [review] Bug 28523: Escape 'rank' in bor_issues_top.pl It's a MySQL 8 keyword Test plan: Turn off strict_sql_modes (there are other problems in this script) Hit Home Reports > Patrons with the most checkouts Submit the form Without this patch you got: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RANK, borrowers.borrowernumber AS ID FROM `old_issues` With this patch applied you see the report result view Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Pushed to master for 21.11, thanks to everybody involved! Pushed to 21.05.x for 21.05.02 Hi, Fridolin impostor here. Backported: Pushed to 20.11.x branch for 20.11.08 Backported: Pushed to 20.05.x branch for 20.05.14 Backported to 19.11.x for 19.11.20 Currently getting this error when running Patrons with the most checkouts report (using KTD started with ku and on master) - is the this the same issue or something else? CGI::Compile::ROOT::kohadevbox_koha_reports_bor_issues_top_2epl::calculate(): DBI Exception: DBD::mysql::st execute failed: 'koha_kohadev.borrowers.surname' isn't in GROUP BY at /kohadevbox/koha/reports/bor_issues_top.pl line 63 at /usr/share/perl5/DBIx/Class/Exception.pm line 77 in DBIx::Class::Exception::throw at /usr/share/perl5/DBIx/Class/Exception.pm line 77 74: my $self = { msg => $msg }; 75: bless $self => $class; 76: 77: die $self; 78: } 79: 80: =head2 rethrow Show function arguments in DBIx::Class::Schema::throw_exception at /usr/share/perl5/DBIx/Class/Schema.pm line 1118 1115: }; 1116: } 1117: 1118: DBIx::Class::Exception->throw($args[0], $self->stacktrace); 1119: } 1120: 1121: =head2 deploy Show function arguments in DBIx::Class::Storage::throw_exception at /usr/share/perl5/DBIx/Class/Storage.pm line 113 110: my $self = shift; 111: 112: if (ref $self and $self->schema) { 113: $self->schema->throw_exception(@_); 114: } 115: else { 116: DBIx::Class::Exception->throw(@_); That is something else. The first line of the test plan states that there are other problems with the script, this is the other problem. In SQL Strict mode the query failed the ONLY_FULL_GROUP_BY check. I recently ran into that problem (and created a patch) on another report. (In reply to David Nind from comment #12) > Currently getting this error when running Patrons with the most checkouts > report (using KTD started with ku and on master) - is the this the same > issue or something else? > > CGI::Compile::ROOT::kohadevbox_koha_reports_bor_issues_top_2epl::calculate(): > DBI Exception: DBD::mysql::st execute failed: > 'koha_kohadev.borrowers.surname' isn't in GROUP BY at > /kohadevbox/koha/reports/bor_issues_top.pl line 63 > at /usr/share/perl5/DBIx/Class/Exception.pm line 77 > > in DBIx::Class::Exception::throw at > /usr/share/perl5/DBIx/Class/Exception.pm line 77 > > 74: my $self = { msg => $msg }; > 75: bless $self => $class; > 76: > 77: die $self; > 78: } > 79: > 80: =head2 rethrow > > Show function arguments > in DBIx::Class::Schema::throw_exception at > /usr/share/perl5/DBIx/Class/Schema.pm line 1118 > > 1115: }; > 1116: } > 1117: > 1118: DBIx::Class::Exception->throw($args[0], $self->stacktrace); > 1119: } > 1120: > 1121: =head2 deploy > > Show function arguments > in DBIx::Class::Storage::throw_exception at > /usr/share/perl5/DBIx/Class/Storage.pm line 113 > > 110: my $self = shift; > 111: > 112: if (ref $self and $self->schema) { > 113: $self->schema->throw_exception(@_); > 114: } > 115: else { > 116: DBIx::Class::Exception->throw(@_); Thanks Michael! |