github.com/matrixorigin/matrixone@v0.7.0/pkg/vm/engine/tae/moengine/sys_relation.go (about) 1 // Copyright 2021 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package moengine 16 17 import ( 18 "context" 19 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/containers" 20 21 pkgcatalog "github.com/matrixorigin/matrixone/pkg/catalog" 22 "github.com/matrixorigin/matrixone/pkg/container/batch" 23 "github.com/matrixorigin/matrixone/pkg/container/vector" 24 "github.com/matrixorigin/matrixone/pkg/vm/engine" 25 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/catalog" 26 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/iface/handle" 27 ) 28 29 var ( 30 _ engine.Relation = (*sysRelation)(nil) 31 ) 32 33 func newSysRelation(h handle.Relation) *sysRelation { 34 r := &sysRelation{} 35 r.handle = h 36 r.nodes = append(r.nodes, engine.Node{ 37 Addr: ADDR, 38 }) 39 return r 40 } 41 42 func isSysRelation(name string) bool { 43 if name == pkgcatalog.MO_DATABASE || 44 name == pkgcatalog.MO_TABLES || 45 name == pkgcatalog.MO_COLUMNS { 46 return true 47 } 48 return false 49 } 50 51 func isSysRelationId(id uint64) bool { 52 if id == pkgcatalog.MO_DATABASE_ID || 53 id == pkgcatalog.MO_TABLES_ID || 54 id == pkgcatalog.MO_COLUMNS_ID { 55 return true 56 } 57 return false 58 } 59 60 func (s *sysRelation) Write(_ context.Context, _ *batch.Batch) error { 61 return ErrReadOnly 62 } 63 64 func (s *sysRelation) AddBlksWithMetaLoc( 65 _ context.Context, 66 _ []containers.Vector, 67 _ string, 68 _ []string, 69 _ int32, 70 ) error { 71 return ErrReadOnly 72 } 73 74 func (s *sysRelation) Update(_ context.Context, _ *batch.Batch) error { 75 return ErrReadOnly 76 } 77 78 func (s *sysRelation) Delete(_ context.Context, _ *batch.Batch, _ string) error { 79 return ErrReadOnly 80 } 81 82 func (s *sysRelation) DeleteByPhyAddrKeys(_ context.Context, _ *vector.Vector) error { 83 return ErrReadOnly 84 } 85 86 func (s *sysRelation) UpdateConstraint(context.Context, *engine.ConstraintDef) error { 87 return ErrReadOnly 88 } 89 90 func (s *sysRelation) UpdateConstraintWithBin(context.Context, []byte) error { 91 return ErrReadOnly 92 } 93 94 func (s *sysRelation) TableColumns(_ context.Context) ([]*engine.Attribute, error) { 95 colDefs := s.handle.GetMeta().(*catalog.TableEntry).GetSchema().ColDefs 96 cols, _ := ColDefsToAttrs(colDefs) 97 return cols, nil 98 }