summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB.pm
diff options
context:
space:
mode:
authorMatt Tyson <mtyson@redhat.com>2015-09-23 23:20:10 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2015-09-23 23:20:10 +0200
commit05f74faf6a98ef8d2ac5d38007e093e6fa1bb1fc (patch)
treea505871a5423ec028877f5c180e16a8c23e41c6a /Bugzilla/DB.pm
parentcdcb6f1f12aff458c43432856a33525f65909276 (diff)
downloadbugzilla-05f74faf6a98ef8d2ac5d38007e093e6fa1bb1fc.tar.gz
bugzilla-05f74faf6a98ef8d2ac5d38007e093e6fa1bb1fc.tar.xz
Bug 1184431: Bug searching is slow on PostgreSQL
r=LpSolit
Diffstat (limited to 'Bugzilla/DB.pm')
-rw-r--r--Bugzilla/DB.pm92
1 files changed, 92 insertions, 0 deletions
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</sql_position>, but case-insensitive.
+=item C<sql_like>
+
+=over
+
+=item B<Description>
+
+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</sql_like> 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<Params>
+
+=over
+
+=item C<$fragment> - the string fragment that we are searching for (scalar)
+
+=item C<$column> - the column to search
+
+=back
+
+=item B<Returns>
+
+Formatted SQL to return results from columns that contain the fragment.
+
+=back
+
+=item C<sql_ilike>
+
+Just like L</sql_like>, but case-insensitive.
+
+=item C<sql_not_ilike>
+
+=over
+
+=item B<Description>
+
+Outputs SQL to search for columns (column) that I<do not> contain
+instances of the string (fragment).
+
+Note that the fragment must not be quoted. L</sql_not_ilike> will
+quote the fragment itself.
+
+This is a case insensitive search.
+
+=item B<Params>
+
+=over
+
+=item C<$fragment> - the string fragment that we are searching for (scalar)
+
+=item C<$column> - the column to search
+
+=back
+
+=item B<Returns>
+
+Formated sql to return results from columns that do not contain the fragment
+
+=back
+
=item C<sql_group_by>
=over