Bug 616981: Make whine.pl work with PostgreSQL 8.4+ by fixing sql_string_until

r=mkanat, a=mkanat


git-svn-id: svn://10.0.0.236/branches/BUGZILLA-3_6-BRANCH@261938 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mkanat%bugzilla.org 2011-02-14 20:27:00 +00:00
parent 1874eef40e
commit 9f3d5702d4
2 changed files with 13 additions and 1 deletions

View File

@ -1 +1 @@
7234
7235

View File

@ -184,6 +184,18 @@ sub sql_string_concat {
return '(CAST(' . join(' AS text) || CAST(', @params) . ' AS text))';
}
sub sql_string_until {
my ($self, $string, $substring) = @_;
# PostgreSQL does not permit a negative substring length; therefore we
# use CASE to only perform the SUBSTRING operation when $substring can
# be found withing $string.
return "CASE WHEN " . $self->sql_position($substring, $string)
. " != 0 THEN SUBSTRING($string FROM 1 FOR "
. $self->sql_position($substring, $string) . " - 1)"
. " ELSE $string END";
}
# Tell us whether or not a particular sequence exists in the DB.
sub bz_sequence_exists {
my ($self, $seq_name) = @_;