DropMaterializedViewIndex drops an index from a materialized view.
(viewName, indexName string)
| 748 | |
| 749 | // DropMaterializedViewIndex drops an index from a materialized view. |
| 750 | func (s *SchemaMetadata) DropMaterializedViewIndex(viewName, indexName string) error { |
| 751 | mv := s.GetMaterializedView(viewName) |
| 752 | if mv == nil { |
| 753 | return errors.Errorf("materialized view %q does not exist in schema %q", viewName, s.proto.Name) |
| 754 | } |
| 755 | |
| 756 | // Remove from indexes |
| 757 | newIndexes := make([]*storepb.IndexMetadata, 0, len(mv.Indexes)) |
| 758 | found := false |
| 759 | for _, idx := range mv.Indexes { |
| 760 | if s.isObjectCaseSensitive { |
| 761 | if idx.Name != indexName { |
| 762 | newIndexes = append(newIndexes, idx) |
| 763 | } else { |
| 764 | found = true |
| 765 | } |
| 766 | } else { |
| 767 | if !strings.EqualFold(idx.Name, indexName) { |
| 768 | newIndexes = append(newIndexes, idx) |
| 769 | } else { |
| 770 | found = true |
| 771 | } |
| 772 | } |
| 773 | } |
| 774 | if !found { |
| 775 | return errors.Errorf("index %q does not exist on materialized view %q", indexName, viewName) |
| 776 | } |
| 777 | mv.Indexes = newIndexes |
| 778 | return nil |
| 779 | } |
| 780 | |
| 781 | // GetDependentViews returns all views that depend on the given table and column. |
| 782 | // This is used to check if a column can be dropped or if a table can be dropped. |
nothing calls this directly
no test coverage detected