github.com/dolthub/go-mysql-server@v0.18.0/sql/plan/leave.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"
    21  )
    22  
    23  // Leave represents the LEAVE statement, which instructs a loop to end. Equivalent to "break" in Go.
    24  type Leave struct {
    25  	Label string
    26  }
    27  
    28  var _ sql.Node = (*Leave)(nil)
    29  var _ sql.CollationCoercible = (*Leave)(nil)
    30  
    31  // NewLeave returns a new *Leave node.
    32  func NewLeave(label string) *Leave {
    33  	return &Leave{
    34  		Label: label,
    35  	}
    36  }
    37  
    38  // Resolved implements the interface sql.Node.
    39  func (l *Leave) Resolved() bool {
    40  	return true
    41  }
    42  
    43  // String implements the interface sql.Node.
    44  func (l *Leave) String() string {
    45  	return fmt.Sprintf("LEAVE %s", l.Label)
    46  }
    47  
    48  // Schema implements the interface sql.Node.
    49  func (l *Leave) Schema() sql.Schema {
    50  	return nil
    51  }
    52  
    53  func (l *Leave) IsReadOnly() bool {
    54  	return true
    55  }
    56  
    57  // Children implements the interface sql.Node.
    58  func (l *Leave) Children() []sql.Node {
    59  	return nil
    60  }
    61  
    62  // WithChildren implements the interface sql.Node.
    63  func (l *Leave) WithChildren(children ...sql.Node) (sql.Node, error) {
    64  	return NillaryWithChildren(l, children...)
    65  }
    66  
    67  // CheckPrivileges implements the interface sql.Node.
    68  func (l *Leave) CheckPrivileges(ctx *sql.Context, opChecker sql.PrivilegedOperationChecker) bool {
    69  	return true
    70  }
    71  
    72  // CollationCoercibility implements the interface sql.CollationCoercible.
    73  func (*Leave) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) {
    74  	return sql.Collation_binary, 7
    75  }