From 4f25eedf9065f28badf1e5e1df6c925062d8279e Mon Sep 17 00:00:00 2001 From: "mkanat%kerio.com" <> Date: Fri, 8 Jul 2005 09:31:41 +0000 Subject: Bug 285695: [PostgreSQL] Username checks for login, etc. need to be case insensitive Patch By Max Kanat-Alexander r=LpSolit, a=justdave --- Bugzilla/DB.pm | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'Bugzilla/DB.pm') diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index e11d52592..76e090d6c 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -218,6 +218,19 @@ sub import { $Exporter::ExportLevel-- if $is_exporter; } +sub sql_istrcmp { + my ($self, $left, $right, $op) = @_; + $op ||= "="; + + return $self->sql_istring($left) . " $op " . $self->sql_istring($right); +} + +sub sql_istring { + my ($self, $string) = @_; + + return "LOWER($string)"; +} + sub sql_position { my ($self, $fragment, $text) = @_; @@ -1153,6 +1166,33 @@ formatted SQL command have prefix C. All other methods have prefix C. $text = text to search for (scalar) Returns: formatted SQL for for full text search +=item C + + Description: Returns SQL for a case-insensitive string comparison. + Params: $left - What should be on the left-hand-side of the + operation. + $right - What should be on the right-hand-side of the + operation. + $op (optional) - What the operation is. Should be a + valid ANSI SQL comparison operator, like "=", "<", + "LIKE", etc. Defaults to "=" if not specified. + Returns: A SQL statement that will run the comparison in + a case-insensitive fashion. + Note: Uses sql_istring, so it has the same performance concerns. + Try to avoid using this function unless absolutely necessary. + Subclass Implementors: Override sql_istring instead of this + function, most of the time (this function uses sql_istring). + +=item C + + Description: Returns SQL syntax "preparing" a string or text column for + case-insensitive comparison. + Params: $string - string to convert (scalar) + Returns: formatted SQL making the string case insensitive + Note: The default implementation simply calls LOWER on the parameter. + If this is used to search on a text column with index, the index + will not be usually used unless it was created as LOWER(column). + =item C Description: Performs a table lock operation on specified tables. -- cgit v1.2.3-24-g4f1b