summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2006-05-29 12:02:45 +0200
committermkanat%bugzilla.org <>2006-05-29 12:02:45 +0200
commitc922073c79f949a867827e4f302d2ec433bbe85e (patch)
tree4a658cc551009ff62185d08301fdc4c0b3c85cc2 /Bugzilla
parent7adc23f4c0b17143d2ba9f8dab4d6a37981ef688 (diff)
downloadbugzilla-c922073c79f949a867827e4f302d2ec433bbe85e.tar.gz
bugzilla-c922073c79f949a867827e4f302d2ec433bbe85e.tar.xz
Bug 302876: Database Version-Checking needs to be more modular and more generic
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=wicked, a=myk
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Constants.pm12
-rw-r--r--Bugzilla/DB.pm37
-rw-r--r--Bugzilla/DB/Mysql.pm5
-rw-r--r--Bugzilla/DB/Pg.pm4
4 files changed, 20 insertions, 38 deletions
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index aed574f67..0c451c8c3 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -101,6 +101,8 @@ use base qw(Exporter);
FIELD_TYPE_FREETEXT
BUG_STATE_OPEN
+
+ DB_MODULE
);
@Bugzilla::Constants::EXPORT_OK = qw(contenttypes);
@@ -277,3 +279,13 @@ use constant BUG_STATE_OPEN => ('NEW', 'REOPENED', 'ASSIGNED',
'UNCONFIRMED');
1;
+
+# Data about what we require for different databases.
+use constant DB_MODULE => {
+ 'mysql' => {db => 'Bugzilla::DB::Mysql', db_version => '4.0.14',
+ dbd => 'DBD::mysql', dbd_version => '2.9003',
+ name => 'MySQL'},
+ 'pg' => {db => 'Bugzilla::DB::Pg', db_version => '8.00.0000',
+ dbd => 'DBD::Pg', dbd_version => '1.45',
+ name => 'PostgreSQL'},
+};
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm
index 127218843..4a0099db4 100644
--- a/Bugzilla/DB.pm
+++ b/Bugzilla/DB.pm
@@ -48,6 +48,7 @@ use base qw(Exporter DBI::db);
Exporter::export_ok_tags('deprecated');
use Bugzilla::Config qw(:DEFAULT :db);
+use Bugzilla::Constants;
use Bugzilla::Util;
use Bugzilla::Error;
use Bugzilla::DB::Schema;
@@ -164,14 +165,11 @@ sub connect_main {
sub _connect {
my ($driver, $host, $dbname, $port, $sock, $user, $pass) = @_;
- # DB specific module have the same name as DB driver, here we
- # just make sure we are not case sensitive
- (my $db_module = $driver) =~ s/(\w+)/\u\L$1/g;
- my $pkg_module = "Bugzilla::DB::" . $db_module;
+ my $pkg_module = DB_MODULE->{lc($driver)}->{db};
# do the actual import
eval ("require $pkg_module")
- || die ("'$db_module' is not a valid choice for \$db_driver in "
+ || die ("'$driver' is not a valid choice for \$db_driver in "
. " localconfig: " . $@);
# instantiate the correct DB specific module
@@ -622,8 +620,9 @@ sub bz_rename_column {
sub _bz_schema {
my ($self) = @_;
return $self->{private_bz_schema} if exists $self->{private_bz_schema};
- $self->{private_bz_schema} =
- Bugzilla::DB::Schema->new($self->MODULE_NAME);
+ my @module_parts = split('::', ref $self);
+ my $module_name = pop @module_parts;
+ $self->{private_bz_schema} = Bugzilla::DB::Schema->new($module_name);
return $self->{private_bz_schema};
}
@@ -989,28 +988,6 @@ constants are required to be subroutines or "use constant" variables.
The C<\%attr> argument that must be passed to bind_param in order to
correctly escape a C<LONGBLOB> type.
-=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.
-
-=item C<MODULE_NAME>
-
-The name of the Bugzilla::DB module that we are. For example, for the MySQL
-Bugzilla::DB module, this would be "Mysql." For PostgreSQL it would be "Pg."
-
-=item C<DBD_VERSION>
-
-The minimum version of the DBD module that we require for this database.
-
=back
@@ -1559,4 +1536,6 @@ PopGlobalSQLState
L<DBI>
+L<Bugzilla::Constants> - The C<DB_MODULE> constant.
+
=cut
diff --git a/Bugzilla/DB/Mysql.pm b/Bugzilla/DB/Mysql.pm
index e03fbc910..9493fb099 100644
--- a/Bugzilla/DB/Mysql.pm
+++ b/Bugzilla/DB/Mysql.pm
@@ -49,11 +49,6 @@ use Bugzilla::Error;
# This module extends the DB interface via inheritance
use base qw(Bugzilla::DB);
-use constant REQUIRED_VERSION => '4.0.14';
-use constant PROGRAM_NAME => 'MySQL';
-use constant MODULE_NAME => 'Mysql';
-use constant DBD_VERSION => '2.9003';
-
sub new {
my ($class, $user, $pass, $host, $dbname, $port, $sock) = @_;
diff --git a/Bugzilla/DB/Pg.pm b/Bugzilla/DB/Pg.pm
index 5162466c5..7bf64ab9d 100644
--- a/Bugzilla/DB/Pg.pm
+++ b/Bugzilla/DB/Pg.pm
@@ -50,10 +50,6 @@ use DBD::Pg;
use base qw(Bugzilla::DB);
use constant BLOB_TYPE => { pg_type => DBD::Pg::PG_BYTEA };
-use constant REQUIRED_VERSION => '8.00.0000';
-use constant PROGRAM_NAME => 'PostgreSQL';
-use constant MODULE_NAME => 'Pg';
-use constant DBD_VERSION => '1.45';
sub new {
my ($class, $user, $pass, $host, $dbname, $port) = @_;