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

Method DropMaterializedView

backend/store/model/database.go:721–747  ·  view source on GitHub ↗

DropMaterializedView drops a materialized view from the schema. Returns an error if the materialized view does not exist.

(viewName string)

Source from the content-addressed store, hash-verified

719// DropMaterializedView drops a materialized view from the schema.
720// Returns an error if the materialized view does not exist.
721func (s *SchemaMetadata) DropMaterializedView(viewName string) error {
722 // Check if materialized view exists
723 if s.GetMaterializedView(viewName) == nil {
724 return errors.Errorf("materialized view %q does not exist in schema %q", viewName, s.proto.Name)
725 }
726
727 // Remove from internal map
728 viewID := normalizeNameByCaseSensitivity(viewName, s.isObjectCaseSensitive)
729 delete(s.internalMaterializedView, viewID)
730
731 // Remove from proto's materialized view list
732 newViews := make([]*storepb.MaterializedViewMetadata, 0, len(s.proto.MaterializedViews)-1)
733 for _, view := range s.proto.MaterializedViews {
734 if s.isObjectCaseSensitive {
735 if view.Name != viewName {
736 newViews = append(newViews, view)
737 }
738 } else {
739 if !strings.EqualFold(view.Name, viewName) {
740 newViews = append(newViews, view)
741 }
742 }
743 }
744 s.proto.MaterializedViews = newViews
745
746 return nil
747}
748
749// DropMaterializedViewIndex drops an index from a materialized view.
750func (s *SchemaMetadata) DropMaterializedViewIndex(viewName, indexName string) error {

Callers

nothing calls this directly

Calls 3

GetMaterializedViewMethod · 0.95
ErrorfMethod · 0.80

Tested by

no test coverage detected