github.com/dolthub/go-mysql-server@v0.18.0/sql/plan/open.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 plan 16 17 import ( 18 "fmt" 19 20 "github.com/dolthub/go-mysql-server/sql/expression" 21 22 "github.com/dolthub/go-mysql-server/sql" 23 ) 24 25 // Open represents the OPEN statement, which opens a cursor. 26 type Open struct { 27 Name string 28 Pref *expression.ProcedureReference 29 } 30 31 var _ sql.Node = (*Open)(nil) 32 var _ sql.CollationCoercible = (*Open)(nil) 33 var _ expression.ProcedureReferencable = (*Open)(nil) 34 35 // NewOpen returns a new *Open node. 36 func NewOpen(name string) *Open { 37 return &Open{ 38 Name: name, 39 } 40 } 41 42 // Resolved implements the interface sql.Node. 43 func (o *Open) Resolved() bool { 44 return true 45 } 46 47 func (o *Open) IsReadOnly() bool { 48 return true 49 } 50 51 // String implements the interface sql.Node. 52 func (o *Open) String() string { 53 return fmt.Sprintf("OPEN %s", o.Name) 54 } 55 56 // Schema implements the interface sql.Node. 57 func (o *Open) Schema() sql.Schema { 58 return nil 59 } 60 61 // Children implements the interface sql.Node. 62 func (o *Open) Children() []sql.Node { 63 return nil 64 } 65 66 // WithChildren implements the interface sql.Node. 67 func (o *Open) WithChildren(children ...sql.Node) (sql.Node, error) { 68 return NillaryWithChildren(o, children...) 69 } 70 71 // CheckPrivileges implements the interface sql.Node. 72 func (o *Open) CheckPrivileges(ctx *sql.Context, opChecker sql.PrivilegedOperationChecker) bool { 73 return true 74 } 75 76 // CollationCoercibility implements the interface sql.CollationCoercible. 77 func (*Open) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) { 78 return sql.Collation_binary, 7 79 } 80 81 // WithParamReference implements the interface expression.ProcedureReferencable. 82 func (o *Open) WithParamReference(pRef *expression.ProcedureReference) sql.Node { 83 no := *o 84 no.Pref = pRef 85 return &no 86 }