github.com/dolthub/go-mysql-server@v0.18.0/sql/engines.go (about) 1 // Copyright 2021 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 sql 16 17 import "fmt" 18 19 // Engine represents a sql engine. 20 type Engine struct { 21 Name string 22 support string 23 comment string 24 transaction string 25 xa string 26 savepoints string 27 } 28 29 var SupportedEngines = []Engine{ 30 {Name: "InnoDB", support: "DEFAULT", comment: "Supports transactions, row-level locking, and foreign keys", transaction: "YES", xa: "YES", savepoints: "YES"}, 31 } 32 33 // Support returns the server's level of support for the storage engine, 34 func (e Engine) Support() string { 35 support := e.support 36 if support == "" { 37 panic(fmt.Sprintf("%v does not have a default support set", e.String())) 38 } 39 return support 40 } 41 42 // Comment returns a brief description of the storage engine. 43 func (e Engine) Comment() string { 44 comment := e.comment 45 if comment == "" { 46 panic(fmt.Sprintf("%v does not have a comment", e.String())) 47 } 48 return comment 49 } 50 51 // Transactions returns whether the storage engine supports transactions. 52 func (e Engine) Transactions() string { 53 transaction := e.transaction 54 if transaction == "" { 55 panic(fmt.Sprintf("%v does not have a tranasaction", e.String())) 56 } 57 return transaction 58 } 59 60 // XA returns whether the storage engine supports XA transactions. 61 func (e Engine) XA() string { 62 xa := e.xa 63 if e.xa == "" { 64 panic(fmt.Sprintf("%v does not have xa support determined", e.String())) 65 } 66 return xa 67 } 68 69 // Savepoints returns whether the storage engine supports savepoints. 70 func (e Engine) Savepoints() string { 71 savepoints := e.savepoints 72 if savepoints == "" { 73 panic(fmt.Sprintf("%v does not have a default savepoints set", e.String())) 74 } 75 return savepoints 76 } 77 78 // String returns the string representation of the Engine. 79 func (e Engine) String() string { 80 return e.Name 81 }