MCPcopy Index your code
hub / github.com/bytebase/bytebase / GetIndex

Method GetIndex

backend/store/model/database.go:343–367  ·  view source on GitHub ↗

GetIndex gets the index by name. Index names are unique within a schema in most databases.

(name string)

Source from the content-addressed store, hash-verified

341// GetIndex gets the index by name.
342// Index names are unique within a schema in most databases.
343func (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.
370func (s *SchemaMetadata) GetView(name string) *storepb.ViewMetadata {

Callers

nothing calls this directly

Calls 2

GetIndexMethod · 0.45

Tested by

no test coverage detected