diff options
author | mkanat%kerio.com <> | 2005-03-03 16:15:01 +0100 |
---|---|---|
committer | mkanat%kerio.com <> | 2005-03-03 16:15:01 +0100 |
commit | 0e8f16e1c64b07cf6d90264f8f754307d340b30e (patch) | |
tree | 152e914a81eab2318a92d22e7c7033feec662ccc /Bugzilla | |
parent | d0d2e9fddc55b47bc9df5f5d60acac9f86d13183 (diff) | |
download | bugzilla-0e8f16e1c64b07cf6d90264f8f754307d340b30e.tar.gz bugzilla-0e8f16e1c64b07cf6d90264f8f754307d340b30e.tar.xz |
Bug 284172: checksetup cannot run CREATE DATABASE on PostgreSQL
Patch By Max Kanat-Alexander <mkanat@kerio.com> r=glob, a=justdave
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/DB.pm | 38 | ||||
-rw-r--r-- | Bugzilla/DB/Mysql.pm | 6 | ||||
-rw-r--r-- | Bugzilla/DB/Pg.pm | 13 | ||||
-rw-r--r-- | Bugzilla/Search.pm | 4 |
4 files changed, 44 insertions, 17 deletions
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index 073e929eb..db6c0b405 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -173,7 +173,8 @@ sub _handle_error { # List of abstract methods we are checking the derived class implements our @_abstract_methods = qw(new sql_regexp sql_not_regexp sql_limit sql_to_days sql_date_format sql_interval - bz_lock_tables bz_unlock_tables); + bz_lock_tables bz_unlock_tables + REQUIRED_VERSION PROGRAM_NAME); # This overriden import method will check implementation of inherited classes # for missing implementation of abstract methods @@ -200,17 +201,10 @@ sub import { $Exporter::ExportLevel-- if $is_exporter; } -# note that when multiple databases are supported, version number does not -# make sense anymore (as it is DB-dependent). This needs to be removed in -# the future and places where it's used fixed. -my $cached_server_version; -sub server_version { - return $cached_server_version if defined($cached_server_version); - my $dbh = Bugzilla->dbh; - my $sth = $dbh->prepare('SELECT VERSION()'); - $sth->execute(); - ($cached_server_version) = $sth->fetchrow_array(); - return $cached_server_version; +# XXX - Needs to be documented. +sub bz_server_version { + my ($self) = @_; + return $self->get_info(18); # SQL_DBMS_VER } sub bz_get_field_defs { @@ -522,6 +516,26 @@ Access to the old SendSQL-based database routines are also provided by importing the C<:deprecated> tag. These routines should not be used in new code. +=head1 CONSTANTS + +Subclasses of Bugzilla::DB are required to define certain constants. These +constants are required to be subroutines or "use constant" variables. + +=over 4 + +=item C<REQUIRED_VERSION> + +This is the minimum required version of the database server that the +Bugzilla::DB subclass requires. It should be in a format suitable for +passing to vers_cmp during installation. + +=item C<PROGRAM_NAME> + +The human-readable name of this database. For example, for MySQL, this +would be 'MySQL.' You should not depend on this variable to know what +type of database you are running on; this is intended merely for displaying +to the admin to let them know what DB they're running. + =head1 CONNECTION A new database handle to the required database can be created using this diff --git a/Bugzilla/DB/Mysql.pm b/Bugzilla/DB/Mysql.pm index d2204433b..4e0a3e5b2 100644 --- a/Bugzilla/DB/Mysql.pm +++ b/Bugzilla/DB/Mysql.pm @@ -47,11 +47,15 @@ use Carp; # This module extends the DB interface via inheritance use base qw(Bugzilla::DB); +use constant REQUIRED_VERSION => '3.23.41'; +use constant PROGRAM_NAME => 'MySQL'; + sub new { my ($class, $user, $pass, $host, $dbname, $port, $sock) = @_; # construct the DSN from the parameters we got - my $dsn = "DBI:mysql:host=$host;database=$dbname;port=$port"; + my $dsn = "DBI:mysql:host=$host;database=$dbname"; + $dsn .= ";port=$port" if $port; $dsn .= ";mysql_socket=$sock" if $sock; my $self = $class->db_new($dsn, $user, $pass); diff --git a/Bugzilla/DB/Pg.pm b/Bugzilla/DB/Pg.pm index a23c38666..9766da383 100644 --- a/Bugzilla/DB/Pg.pm +++ b/Bugzilla/DB/Pg.pm @@ -47,12 +47,21 @@ use Carp; # This module extends the DB interface via inheritance use base qw(Bugzilla::DB); +use constant REQUIRED_VERSION => '7.02.0000'; +use constant PROGRAM_NAME => 'PostgreSQL'; + sub new { my ($class, $user, $pass, $host, $dbname, $port) = @_; + # The default database name for PostgreSQL. We have + # to connect to SOME database, even if we have + # no $dbname parameter. + $dbname ||= 'template1'; + # construct the DSN from the parameters we got - my $dsn = "DBI:Pg:host=$host;dbname=$dbname;port=$port"; - + my $dsn = "DBI:Pg:host=$host;dbname=$dbname"; + $dsn .= ";port=$port" if $port; + my $self = $class->db_new($dsn, $user, $pass); # all class local variables stored in DBI derived class needs to have diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index ff9befa28..f2e630784 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -954,8 +954,8 @@ sub init { # mysql 4.0.1 and lower do not support CAST # mysql 3.*.* had a case-sensitive INSTR # (checksetup has a check for unsupported versions) - my $server_version = Bugzilla::DB->server_version; - if ($server_version =~ /^3\./) { + my $server_version = $dbh->bz_server_version; + if ($dbh->isa('Bugzilla::DB::Mysql') && $server_version =~ /^3\./) { $term = "INSTR($ff ,$q)"; } else { $term = "INSTR(CAST($ff AS BINARY), CAST($q AS BINARY))"; |