summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB
diff options
context:
space:
mode:
authorSam Morris <sam@robots.org.uk>2011-02-14 21:10:40 +0100
committerMax Kanat-Alexander <mkanat@bugzilla.org>2011-02-14 21:10:40 +0100
commit142ebe8513a2796381104548f2869bd14c214793 (patch)
treec3b78690ca0a75d50d0469690b5ee3c315edfee9 /Bugzilla/DB
parentf843497fb2836d42712a6bd66e08c3bd9f49dc2c (diff)
downloadbugzilla-142ebe8513a2796381104548f2869bd14c214793.tar.gz
bugzilla-142ebe8513a2796381104548f2869bd14c214793.tar.xz
Bug 616981: Make whine.pl work with PostgreSQL 8.4+ by fixing sql_string_until
r=mkanat, a=mkanat
Diffstat (limited to 'Bugzilla/DB')
-rw-r--r--Bugzilla/DB/Pg.pm12
1 files changed, 12 insertions, 0 deletions
diff --git a/Bugzilla/DB/Pg.pm b/Bugzilla/DB/Pg.pm
index e59a638a4..f0a395900 100644
--- a/Bugzilla/DB/Pg.pm
+++ b/Bugzilla/DB/Pg.pm
@@ -192,6 +192,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) = @_;