diff options
author | Dave Lawrence <dlawrence@mozilla.com> | 2012-11-14 17:25:01 +0100 |
---|---|---|
committer | Dave Lawrence <dlawrence@mozilla.com> | 2012-11-14 17:25:01 +0100 |
commit | e4e3c1b860c47976dc7314ec26d336caa59bebd0 (patch) | |
tree | 5161f7edb5d9b9046d7b98af3d000f37880f389b /Bugzilla/DB | |
parent | 38fa3fab5ae996c6116b55fe87e60ea6b53b2923 (diff) | |
parent | 442d6df4683b7219738bb799a3650dd8b9c8431f (diff) | |
download | bugzilla-e4e3c1b860c47976dc7314ec26d336caa59bebd0.tar.gz bugzilla-e4e3c1b860c47976dc7314ec26d336caa59bebd0.tar.xz |
merged with bugzilla/4.2
Diffstat (limited to 'Bugzilla/DB')
-rw-r--r-- | Bugzilla/DB/Oracle.pm | 30 | ||||
-rw-r--r-- | Bugzilla/DB/Pg.pm | 9 |
2 files changed, 24 insertions, 15 deletions
diff --git a/Bugzilla/DB/Oracle.pm b/Bugzilla/DB/Oracle.pm index da263e084..ebf59533f 100644 --- a/Bugzilla/DB/Oracle.pm +++ b/Bugzilla/DB/Oracle.pm @@ -56,6 +56,8 @@ use constant BLOB_TYPE => { ora_type => ORA_BLOB }; use constant MIN_LONG_READ_LEN => 32 * 1024; use constant FULLTEXT_OR => ' OR '; +our $fulltext_label = 0; + sub new { my ($class, $params) = @_; my ($user, $pass, $host, $dbname, $port) = @@ -124,7 +126,8 @@ sub bz_explain { sub sql_group_concat { my ($self, $text, $separator) = @_; $separator = $self->quote(', ') if !defined $separator; - return "group_concat(T_CLOB_DELIM($text, $separator))"; + my ($distinct, $rest) = $text =~/^(\s*DISTINCT\s|)(.+)$/i; + return "group_concat($distinct T_CLOB_DELIM(NVL($rest, ' '), $separator))"; } sub sql_regexp { @@ -170,11 +173,13 @@ sub sql_from_days{ return " TO_DATE($date,'J') "; } + sub sql_fulltext_search { - my ($self, $column, $text, $label) = @_; + my ($self, $column, $text) = @_; $text = $self->quote($text); trick_taint($text); - return "CONTAINS($column,$text,$label) > 0", "SCORE($label)"; + $fulltext_label++; + return "CONTAINS($column,$text,$fulltext_label) > 0", "SCORE($fulltext_label)"; } sub sql_date_format { @@ -545,14 +550,17 @@ sub bz_setup_database { . " RETURN NUMBER IS BEGIN RETURN LENGTH(COLUMN_NAME); END;"); # Create types for group_concat - my $t_clob_delim = $self->selectcol_arrayref(" - SELECT TYPE_NAME FROM USER_TYPES WHERE TYPE_NAME=?", - undef, 'T_CLOB_DELIM'); - - if ( !@$t_clob_delim ) { - $self->do("CREATE OR REPLACE TYPE T_CLOB_DELIM AS OBJECT " - . "( p_CONTENT CLOB, p_DELIMITER VARCHAR2(256));"); - } + $self->do("DROP TYPE T_GROUP_CONCAT"); + $self->do("CREATE OR REPLACE TYPE T_CLOB_DELIM AS OBJECT " + . "( p_CONTENT CLOB, p_DELIMITER VARCHAR2(256)" + . ", MAP MEMBER FUNCTION T_CLOB_DELIM_ToVarchar return VARCHAR2" + . ");"); + $self->do("CREATE OR REPLACE TYPE BODY T_CLOB_DELIM IS + MAP MEMBER FUNCTION T_CLOB_DELIM_ToVarchar return VARCHAR2 is + BEGIN + RETURN p_CONTENT; + END; + END;"); $self->do("CREATE OR REPLACE TYPE T_GROUP_CONCAT AS OBJECT ( CLOB_CONTENT CLOB, diff --git a/Bugzilla/DB/Pg.pm b/Bugzilla/DB/Pg.pm index b6be64011..4f818932b 100644 --- a/Bugzilla/DB/Pg.pm +++ b/Bugzilla/DB/Pg.pm @@ -215,11 +215,12 @@ sub bz_check_server_version { my $self = shift; my ($db) = @_; my $server_version = $self->SUPER::bz_check_server_version(@_); - my ($major_version) = $server_version =~ /^(\d+)/; - # Pg 9 requires DBD::Pg 2.17.2 in order to properly read bytea values. + my ($major_version, $minor_version) = $server_version =~ /^0*(\d+)\.0*(\d+)/; + # Pg 9.0 requires DBD::Pg 2.17.2 in order to properly read bytea values. + # Pg 9.2 requires DBD::Pg 2.19.3 as spclocation no longer exists. if ($major_version >= 9) { - local $db->{dbd}->{version} = '2.17.2'; - local $db->{name} = $db->{name} . ' 9+'; + local $db->{dbd}->{version} = ($minor_version >= 2) ? '2.19.3' : '2.17.2'; + local $db->{name} = $db->{name} . " ${major_version}.$minor_version"; Bugzilla::DB::_bz_check_dbd(@_); } } |