GetIndex gets the index by name. Index names are unique within a schema in most databases.
(name string)
| 341 | // GetIndex gets the index by name. |
| 342 | // Index names are unique within a schema in most databases. |
| 343 | func (s *SchemaMetadata) GetIndex(name string) *IndexMetadata { |
| 344 | if s == nil { |
| 345 | return nil |
| 346 | } |
| 347 | for _, table := range s.internalTables { |
| 348 | if index := table.GetIndex(name); index != nil { |
| 349 | return index |
| 350 | } |
| 351 | } |
| 352 | // Also search in materialized views |
| 353 | nameID := normalizeNameByCaseSensitivity(name, s.isObjectCaseSensitive) |
| 354 | for _, mv := range s.internalMaterializedView { |
| 355 | for _, idx := range mv.Indexes { |
| 356 | idxID := normalizeNameByCaseSensitivity(idx.Name, s.isObjectCaseSensitive) |
| 357 | if idxID == nameID { |
| 358 | // Return a wrapper IndexMetadata for the materialized view index |
| 359 | return &IndexMetadata{ |
| 360 | proto: idx, |
| 361 | tableProto: &storepb.TableMetadata{Name: mv.Name}, |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | return nil |
| 367 | } |
| 368 | |
| 369 | // GetView gets the view by name. |
| 370 | func (s *SchemaMetadata) GetView(name string) *storepb.ViewMetadata { |
nothing calls this directly
no test coverage detected