github.com/hasnat/dolt/go@v0.0.0-20210628190320-9eb5d843fbb7/libraries/doltcore/sqle/sqlutil/static_errors.go (about) 1 // Copyright 2020 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 sqlutil 16 17 import ( 18 "github.com/dolthub/go-mysql-server/sql" 19 ) 20 21 type StaticErrorTable struct { 22 sql.Table 23 err error 24 } 25 26 func (t *StaticErrorTable) Partitions(ctx *sql.Context) (sql.PartitionIter, error) { 27 return nil, t.err 28 } 29 30 func (t *StaticErrorTable) PartitionRows(ctx *sql.Context, p sql.Partition) (sql.RowIter, error) { 31 return nil, t.err 32 } 33 34 func NewStaticErrorTable(orig sql.Table, err error) sql.Table { 35 return &StaticErrorTable{orig, err} 36 } 37 38 type StaticErrorRowIter struct { 39 err error 40 } 41 42 func NewStaticErrorRowIter(err error) sql.RowIter { 43 return &StaticErrorRowIter{err} 44 } 45 46 func (i *StaticErrorRowIter) Next() (sql.Row, error) { 47 return nil, i.err 48 } 49 50 func (i *StaticErrorRowIter) Close(*sql.Context) error { 51 // Or i.err? 52 return nil 53 } 54 55 type StaticErrorEditor struct { 56 err error 57 } 58 59 func NewStaticErrorEditor(err error) *StaticErrorEditor { 60 return &StaticErrorEditor{err} 61 } 62 63 func (e *StaticErrorEditor) Insert(*sql.Context, sql.Row) error { 64 return e.err 65 } 66 67 func (e *StaticErrorEditor) Delete(*sql.Context, sql.Row) error { 68 return e.err 69 } 70 71 func (e *StaticErrorEditor) Update(*sql.Context, sql.Row, sql.Row) error { 72 return e.err 73 } 74 75 func (e *StaticErrorEditor) SetAutoIncrementValue(*sql.Context, interface{}) error { 76 return e.err 77 } 78 79 func (e *StaticErrorEditor) StatementBegin(ctx *sql.Context) {} 80 81 func (e *StaticErrorEditor) DiscardChanges(ctx *sql.Context, errorEncountered error) error { 82 return nil 83 } 84 85 func (e *StaticErrorEditor) StatementComplete(ctx *sql.Context) error { 86 return nil 87 } 88 89 func (e *StaticErrorEditor) Close(*sql.Context) error { 90 // Or e.err? 91 return nil 92 }