github.com/dolthub/go-mysql-server@v0.18.0/sql/catalog_map.go (about) 1 package sql 2 3 import ( 4 "fmt" 5 ) 6 7 type MapCatalog struct { 8 Tables map[string]Table 9 Funcs map[string]Function 10 tabFuncs map[string]TableFunction 11 Databases map[string]Database 12 } 13 14 var _ Catalog = MapCatalog{} 15 16 func (t MapCatalog) WithTableFunctions(fns ...TableFunction) (TableFunctionProvider, error) { 17 //TODO implement me 18 panic("implement me") 19 } 20 21 func (t MapCatalog) Function(ctx *Context, name string) (Function, error) { 22 if f, ok := t.Funcs[name]; ok { 23 return f, nil 24 } 25 return nil, fmt.Errorf("func not found") 26 } 27 28 func (t MapCatalog) TableFunction(ctx *Context, name string) (TableFunction, error) { 29 if f, ok := t.tabFuncs[name]; ok { 30 return f, nil 31 } 32 return nil, fmt.Errorf("table func not found") 33 } 34 35 func (t MapCatalog) ExternalStoredProcedure(ctx *Context, name string, numOfParams int) (*ExternalStoredProcedureDetails, error) { 36 //TODO implement me 37 panic("implement me") 38 } 39 40 func (t MapCatalog) ExternalStoredProcedures(ctx *Context, name string) ([]ExternalStoredProcedureDetails, error) { 41 //TODO implement me 42 panic("implement me") 43 } 44 45 func (t MapCatalog) AllDatabases(ctx *Context) []Database { 46 //TODO implement me 47 panic("implement me") 48 } 49 50 func (t MapCatalog) HasDatabase(ctx *Context, name string) bool { 51 _, ok := t.Databases[name] 52 return ok 53 } 54 55 func (t MapCatalog) Database(ctx *Context, name string) (Database, error) { 56 if f, ok := t.Databases[name]; ok { 57 return f, nil 58 } 59 return nil, fmt.Errorf("database not found") 60 } 61 62 func (t MapCatalog) CreateDatabase(ctx *Context, dbName string, collation CollationID) error { 63 //TODO implement me 64 panic("implement me") 65 } 66 67 func (t MapCatalog) RemoveDatabase(ctx *Context, dbName string) error { 68 //TODO implement me 69 panic("implement me") 70 } 71 72 func (t MapCatalog) Table(ctx *Context, dbName, tableName string) (Table, Database, error) { 73 if db, ok := t.Databases[dbName]; ok { 74 if t, ok, err := db.GetTableInsensitive(ctx, tableName); ok { 75 return t, db, nil 76 } else { 77 return nil, nil, err 78 } 79 } 80 return nil, nil, fmt.Errorf("table not found") 81 } 82 83 func (t MapCatalog) TableAsOf(ctx *Context, dbName, tableName string, asOf interface{}) (Table, Database, error) { 84 return t.Table(ctx, dbName, tableName) 85 } 86 87 func (t MapCatalog) DatabaseTable(ctx *Context, db Database, tableName string) (Table, Database, error) { 88 if t, ok, err := db.GetTableInsensitive(ctx, tableName); ok { 89 return t, db, nil 90 } else { 91 return nil, nil, err 92 } 93 } 94 95 func (t MapCatalog) DatabaseTableAsOf(ctx *Context, db Database, tableName string, asOf interface{}) (Table, Database, error) { 96 return t.DatabaseTable(ctx, db, tableName) 97 } 98 99 func (t MapCatalog) RegisterFunction(ctx *Context, fns ...Function) { 100 //TODO implement me 101 panic("implement me") 102 } 103 104 func (t MapCatalog) LockTable(ctx *Context, table string) { 105 //TODO implement me 106 panic("implement me") 107 } 108 109 func (t MapCatalog) UnlockTables(ctx *Context, id uint32) error { 110 //TODO implement me 111 panic("implement me") 112 } 113 114 func (t MapCatalog) GetTableStats(ctx *Context, db, table string) ([]Statistic, error) { 115 //TODO implement me 116 panic("implement me") 117 } 118 119 func (t MapCatalog) RefreshTableStats(ctx *Context, table Table, db string) error { 120 //TODO implement me 121 panic("implement me") 122 } 123 124 func (t MapCatalog) SetStats(ctx *Context, stats Statistic) error { 125 //TODO implement me 126 panic("implement me") 127 } 128 129 func (t MapCatalog) GetStats(ctx *Context, qual StatQualifier, cols []string) (Statistic, bool) { 130 //TODO implement me 131 panic("implement me") 132 } 133 134 func (t MapCatalog) DropStats(ctx *Context, qual StatQualifier, cols []string) error { 135 //TODO implement me 136 panic("implement me") 137 } 138 139 func (t MapCatalog) RowCount(ctx *Context, db, table string) (uint64, error) { 140 return 1, nil 141 } 142 143 func (t MapCatalog) DataLength(ctx *Context, db, table string) (uint64, error) { 144 return 1, nil 145 } 146 147 func (t MapCatalog) DropDbStats(ctx *Context, db string, flush bool) error { 148 //TODO implement me 149 panic("implement me") 150 }