From b023bec0cd6521fa6ad97ae30497cd4099fe9965 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sun, 9 Oct 2016 09:30:58 +0200 Subject: [PATCH] Use placeholders in search SQL I didn't do that before in order to ensure that the planner could always optimize the LIKE queries, but it's optimizing them just fine with placeholders now. --- www/index.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/index.pl b/www/index.pl index 0075435..d2f2dec 100755 --- a/www/index.pl +++ b/www/index.pl @@ -777,9 +777,9 @@ sub dbSearch { return !$name ? [] : $s->dbAll( 'SELECT name, section FROM man_index !W ORDER BY name, section LIMIT ?', - { # Don't use wildcards in this query, prevents index usage. - "lower(name) LIKE '\L$name\E%'" => 1, - $sect ? ("section ILIKE '\L$sect\E%'" => 1) : () + { + 'lower(name) LIKE ?' => escape_like(lc $name).'%', + $sect ? ('section ILIKE ?' => escape_like(lc $sect).'%') : (), }, $limit );