github.com/dolthub/go-mysql-server@v0.18.0/sql/mysql_db/mysql_table.go (about) 1 // Copyright 2022 Dolthub, Inc. 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 mysql_db 16 17 import ( 18 "gopkg.in/src-d/go-errors.v1" 19 20 "github.com/dolthub/go-mysql-server/sql" 21 ) 22 23 var errPrimaryKeyUnknownEntry = errors.NewKind("the primary key for the `%s` table was given an unknown entry") 24 var errPrimaryKeyUnknownSchema = errors.NewKind("the primary key for the `%s` table was given a row belonging to an unknown schema") 25 26 type mysqlTable struct { 27 name string 28 sch sql.Schema 29 db *MySQLDb 30 } 31 32 var _ sql.Table = (*mysqlTable)(nil) 33 34 // newEmptyMySQLTable returns a new MySQL Table that does not contain any row data. Useful when you only need the 35 // schema of a table to exist, and don't need any data in it. 36 func newEmptyMySQLTable(name string, sch sql.Schema, db *MySQLDb) *mysqlTable { 37 return &mysqlTable{ 38 name: name, 39 db: db, 40 sch: sch, 41 } 42 } 43 44 // Name implements the interface sql.Table. 45 func (t *mysqlTable) Name() string { 46 return t.name 47 } 48 49 // String implements the interface sql.Table. 50 func (t *mysqlTable) String() string { 51 return t.name 52 } 53 54 // Schema implements the interface sql.Table. 55 func (t *mysqlTable) Schema() sql.Schema { 56 return t.sch.Copy() 57 } 58 59 // Collation implements the interface sql.Table. 60 func (t *mysqlTable) Collation() sql.CollationID { 61 return sql.Collation_utf8mb3_bin 62 } 63 64 // Partitions implements the interface sql.Table. 65 func (t *mysqlTable) Partitions(ctx *sql.Context) (sql.PartitionIter, error) { 66 return sql.PartitionsToPartitionIter(dummyPartition{}), nil 67 } 68 69 // PartitionRows implements the interface sql.Table. 70 func (t *mysqlTable) PartitionRows(ctx *sql.Context, partition sql.Partition) (sql.RowIter, error) { 71 return sql.RowsToRowIter(nil), nil 72 }