From bc1337b9af7b6ade15bc78c6012e980dc98e2637 Mon Sep 17 00:00:00 2001 From: "mkanat%kerio.com" Date: Fri, 15 Apr 2005 05:46:04 +0000 Subject: [PATCH] Bug 290414: bz_index_info is slightly broken and has unclear API Patch By Max Kanat-Alexander r=Tomas.Kopal, a=justdave git-svn-id: svn://10.0.0.236/trunk@172265 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/Bugzilla/DB.pm | 13 ++++++++++--- mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm | 5 +++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/mozilla/webtools/bugzilla/Bugzilla/DB.pm b/mozilla/webtools/bugzilla/Bugzilla/DB.pm index d72cd5e8225..e8a3f362ebe 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/DB.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/DB.pm @@ -587,8 +587,12 @@ sub bz_column_info { sub bz_index_info { my ($self, $table, $index) = @_; - - return $self->_bz_real_schema->get_index_abstract($table, $index); + my $index_def = + $self->_bz_real_schema->get_index_abstract($table, $index); + if (ref($index_def) eq 'ARRAY') { + $index_def = {FIELDS => $index_def, TYPE => ''}; + } + return $index_def; } @@ -1368,7 +1372,10 @@ C. Description: Get abstract index definition. Params: $table - The table the index is on. $index - The name of the index. - Returns: An abstract index definition for that index. + Returns: An abstract index definition for that index, + always in hashref format. The hashref will + always contain the TYPE element, but it will + be an empty string if it's just a normal index. If the index does not exist, we return undef. =back diff --git a/mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm b/mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm index 99127ff6999..b151edf91db 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm @@ -1608,8 +1608,9 @@ sub get_index_abstract { # Prevent a possible dereferencing of an undef hash, if the # table doesn't exist. - if (exists $self->{abstract_schema}->{$table}) { - my %indexes = (@{ $self->{abstract_schema}{$table}{INDEXES} }); + my $index_table = $self->get_table_abstract($table); + if ($index_table && exists $index_table->{INDEXES}) { + my %indexes = (@{ $index_table->{INDEXES} }); return $indexes{$index}; } return undef;