From 05f74faf6a98ef8d2ac5d38007e093e6fa1bb1fc Mon Sep 17 00:00:00 2001 From: Matt Tyson Date: Wed, 23 Sep 2015 23:20:10 +0200 Subject: Bug 1184431: Bug searching is slow on PostgreSQL r=LpSolit --- Bugzilla/DB.pm | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'Bugzilla/DB.pm') diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index e82b823d7..999b6ae10 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -370,6 +370,31 @@ sub sql_position { return "POSITION($fragment IN $text)"; } +sub sql_like { + my ($self, $fragment, $column) = @_; + + my $quoted = $self->quote($fragment); + + return $self->sql_position($quoted, $column) . " > 0"; +} + +sub sql_ilike { + my ($self, $fragment, $column) = @_; + + my $quoted = $self->quote($fragment); + + return $self->sql_iposition($quoted, $column) . " > 0"; +} + +sub sql_not_ilike { + my ($self, $fragment, $column) = @_; + + my $quoted = $self->quote($fragment); + + return $self->sql_iposition($quoted, $column) . " = 0"; +} + + sub sql_group_by { my ($self, $needed_columns, $optional_columns) = @_; @@ -2021,6 +2046,73 @@ Formatted SQL for substring search (scalar) Just like L, but case-insensitive. +=item C + +=over + +=item B + +Outputs SQL to search for an instance of a string (fragment) +in a table column (column). + +Note that the fragment must not be quoted. L will +quote the fragment itself. + +This is a case sensitive search. + +Note: This does not necessarily generate an ANSI LIKE statement, but +could be overridden to do so in a database subclass if required. + +=item B + +=over + +=item C<$fragment> - the string fragment that we are searching for (scalar) + +=item C<$column> - the column to search + +=back + +=item B + +Formatted SQL to return results from columns that contain the fragment. + +=back + +=item C + +Just like L, but case-insensitive. + +=item C + +=over + +=item B + +Outputs SQL to search for columns (column) that I contain +instances of the string (fragment). + +Note that the fragment must not be quoted. L will +quote the fragment itself. + +This is a case insensitive search. + +=item B + +=over + +=item C<$fragment> - the string fragment that we are searching for (scalar) + +=item C<$column> - the column to search + +=back + +=item B + +Formated sql to return results from columns that do not contain the fragment + +=back + =item C =over -- cgit v1.2.3-24-g4f1b