vitess.io/vitess@v0.16.2/go/vt/vtgate/semantics/FakeSI.go (about) 1 /* 2 Copyright 2021 The Vitess Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package semantics 18 19 import ( 20 "vitess.io/vitess/go/mysql/collations" 21 "vitess.io/vitess/go/vt/key" 22 topodatapb "vitess.io/vitess/go/vt/proto/topodata" 23 "vitess.io/vitess/go/vt/sqlparser" 24 "vitess.io/vitess/go/vt/vtgate/vindexes" 25 ) 26 27 var _ SchemaInformation = (*FakeSI)(nil) 28 29 // FakeSI is a fake SchemaInformation for testing 30 type FakeSI struct { 31 Tables map[string]*vindexes.Table 32 VindexTables map[string]vindexes.Vindex 33 } 34 35 // FindTableOrVindex implements the SchemaInformation interface 36 func (s *FakeSI) FindTableOrVindex(tablename sqlparser.TableName) (*vindexes.Table, vindexes.Vindex, string, topodatapb.TabletType, key.Destination, error) { 37 table, ok := s.Tables[sqlparser.String(tablename)] 38 if ok { 39 return table, nil, "", 0, nil, nil 40 } 41 return nil, s.VindexTables[sqlparser.String(tablename)], "", 0, nil, nil 42 } 43 44 func (FakeSI) ConnCollation() collations.ID { 45 return 45 46 }