summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB.pm
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-04-17 16:24:13 +0200
committermkanat%kerio.com <>2005-04-17 16:24:13 +0200
commit8231d98d0644c387ea8476f61b4a3301848403d9 (patch)
tree7c7783053928ac0f548bfb529e5003557da27b7e /Bugzilla/DB.pm
parent77691d57c478404d33235d45cb94156efd3a95f2 (diff)
downloadbugzilla-8231d98d0644c387ea8476f61b4a3301848403d9.tar.gz
bugzilla-8231d98d0644c387ea8476f61b4a3301848403d9.tar.xz
Bug 290403: Slight cleanup of Bugzilla::DB index code
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=Tomas.Kopal, a=justdave
Diffstat (limited to 'Bugzilla/DB.pm')
-rw-r--r--Bugzilla/DB.pm62
1 files changed, 50 insertions, 12 deletions
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm
index 3a52e8802..a32406d5b 100644
--- a/Bugzilla/DB.pm
+++ b/Bugzilla/DB.pm
@@ -414,17 +414,36 @@ sub bz_add_index {
my $index_exists = $self->bz_index_info($table, $name);
if (!$index_exists) {
- my @statements = $self->_bz_real_schema->get_add_index_ddl(
- $table, $name, $definition);
- print "Adding new index '$name' to the $table table ...\n";
- foreach my $sql (@statements) {
- $self->do($sql);
- }
+ $self->_bz_add_index_raw($table, $name, $definition);
$self->_bz_real_schema->set_index($table, $name, $definition);
$self->_bz_store_real_schema;
}
}
+# bz_add_index_raw($table, $name, $silent)
+#
+# Description: A helper function for bz_add_index.
+# Adds an index to the database
+# without updating any Schema object. Generally
+# should only be called by bz_add_index.
+# Used when you don't yet have a Schema
+# object but you need to add an index, for some reason.
+# Params: $table - The name of the table the index is on.
+# $name - The name of the index you're adding.
+# $definition - The abstract index definition, in hashref
+# or arrayref format.
+# $silent - (optional) If specified and true, don't output
+# any message about this change.
+# Returns: nothing
+#
+sub bz_add_index_raw {
+ my ($self, $table, $name, $definition, $silent) = @_;
+ my @statements = $self->_bz_schema->get_add_index_ddl(
+ $table, $name, $definition);
+ print "Adding new index '$name' to the $table table ...\n" unless $silent;
+ $self->do($_) foreach (@statements);
+}
+
sub bz_add_table {
my ($self, $name) = @_;
@@ -520,17 +539,36 @@ sub bz_drop_index {
my $index_exists = $self->bz_index_info($table, $name);
if ($index_exists) {
- my @statements = $self->_bz_real_schema->get_drop_index_ddl(
- $table, $name);
- print "Removing index '$name' from the $table table...\n";
- foreach my $sql (@statements) {
- $self->do($sql);
- }
+ $self->_bz_drop_index_raw($table, $name);
$self->_bz_real_schema->delete_index($table, $name);
$self->_bz_store_real_schema;
}
}
+# bz_drop_index_raw($table, $name, $silent)
+#
+# Description: A helper function for bz_drop_index.
+# Drops an index from the database
+# without updating any Schema object. Generally
+# should only be called by bz_drop_index.
+# Used when either: (1) You don't yet have a Schema
+# object but you need to drop an index, for some reason.
+# (2) You need to drop an index that somehow got into the
+# database but doesn't exist in Schema.
+# Params: $table - The name of the table the index is on.
+# $name - The name of the index you're dropping.
+# $silent - (optional) If specified and true, don't output
+# any message about this change.
+# Returns: nothing
+#
+sub bz_drop_index_raw {
+ my ($self, $table, $name, $silent) = @_;
+ my @statements = $self->_bz_schema->get_drop_index_ddl(
+ $table, $name);
+ print "Removing index '$name' from the $table table...\n" unless $silent;
+ $self->do($_) foreach (@statements);
+}
+
# XXX - Needs to be made cross-db compatible
sub bz_drop_table_indexes ($) {
my ($self, $table) = @_;