github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/sem/tree/discard.go (about)

     1  // Copyright 2017 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  package tree
    12  
    13  // Discard represents a DISCARD statement.
    14  type Discard struct {
    15  	Mode DiscardMode
    16  }
    17  
    18  var _ Statement = &Discard{}
    19  
    20  // DiscardMode is an enum of the various discard modes.
    21  type DiscardMode int
    22  
    23  const (
    24  	// DiscardModeAll represents a DISCARD ALL statement.
    25  	DiscardModeAll DiscardMode = iota
    26  )
    27  
    28  // Format implements the NodeFormatter interface.
    29  func (node *Discard) Format(ctx *FmtCtx) {
    30  	switch node.Mode {
    31  	case DiscardModeAll:
    32  		ctx.WriteString("DISCARD ALL")
    33  	}
    34  }
    35  
    36  // String implements the Statement interface.
    37  func (node *Discard) String() string {
    38  	return AsString(node)
    39  }