Commit d8f3d06a authored by mkanat%kerio.com's avatar mkanat%kerio.com

Bug 290414: bz_index_info is slightly broken and has unclear API

Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=Tomas.Kopal, a=justdave
parent 7be1f1c9
...@@ -587,8 +587,12 @@ sub bz_column_info { ...@@ -587,8 +587,12 @@ sub bz_column_info {
sub bz_index_info { sub bz_index_info {
my ($self, $table, $index) = @_; my ($self, $table, $index) = @_;
my $index_def =
return $self->_bz_real_schema->get_index_abstract($table, $index); $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<Bugzilla::DB::Schema::ABSTRACT_SCHEMA>. ...@@ -1368,7 +1372,10 @@ C<Bugzilla::DB::Schema::ABSTRACT_SCHEMA>.
Description: Get abstract index definition. Description: Get abstract index definition.
Params: $table - The table the index is on. Params: $table - The table the index is on.
$index - The name of the index. $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. If the index does not exist, we return undef.
=back =back
......
...@@ -1608,8 +1608,9 @@ sub get_index_abstract { ...@@ -1608,8 +1608,9 @@ sub get_index_abstract {
# Prevent a possible dereferencing of an undef hash, if the # Prevent a possible dereferencing of an undef hash, if the
# table doesn't exist. # table doesn't exist.
if (exists $self->{abstract_schema}->{$table}) { my $index_table = $self->get_table_abstract($table);
my %indexes = (@{ $self->{abstract_schema}{$table}{INDEXES} }); if ($index_table && exists $index_table->{INDEXES}) {
my %indexes = (@{ $index_table->{INDEXES} });
return $indexes{$index}; return $indexes{$index};
} }
return undef; return undef;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment