From 7b74343e9e204b80c26ed303e465526389d45caf Mon Sep 17 00:00:00 2001 From: Didier Gautheron Date: Thu, 16 Feb 2023 21:28:47 +0100 Subject: [PATCH] Bug 33116: Add sql statement limit to report query --- C4/Reports/Guided.pm | 13 +++++++++++++ debian/templates/koha-conf-site.xml.in | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index cbbc1a6f88..4e01dacfd5 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -608,6 +608,19 @@ sub execute_query { my $dbh = C4::Context->dbh; $dbh->do( 'UPDATE saved_sql SET last_run = NOW() WHERE id = ?', undef, $report_id ) if $report_id; + if (C4::Context->config('report_sql_max_statement_time') or C4::Context->config('report_sql_max_join_size') ) { + my $sql_limit = "SET STATEMENT "; + my $timeout = 0; + if (C4::Context->config('report_sql_max_statement_time')) { + $sql_limit .= "MAX_STATEMENT_TIME=" . C4::Context->config('report_sql_max_statement_time'); + $timeout = 1; + } + if (C4::Context->config('report_sql_max_join_size')) { + $sql_limit .= "," if $timeout; + $sql_limit .= "MAX_JOIN_SIZE=". C4::Context->config('report_sql_max_join_size'); + } + $sql = $sql_limit . " FOR " . $sql; + } my $sth = $dbh->prepare($sql); eval { diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in index bdb994c517..5a135b582f 100644 --- a/debian/templates/koha-conf-site.xml.in +++ b/debian/templates/koha-conf-site.xml.in @@ -260,6 +260,14 @@ __END_SRU_PUBLICSERVER__ __DB_TLS_CA_CERTIFICATE__ __DB_TLS_CLIENT_CERTIFICATE__ __DB_TLS_CLIENT_KEY__ + + + 300 --> + + + 10000000 --> + biblios 1 authorities -- 2.39.0