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

     1  // Copyright 2018 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  // CreateChangefeed represents a CREATE CHANGEFEED statement.
    14  type CreateChangefeed struct {
    15  	Targets TargetList
    16  	SinkURI Expr
    17  	Options KVOptions
    18  }
    19  
    20  var _ Statement = &CreateChangefeed{}
    21  
    22  // Format implements the NodeFormatter interface.
    23  func (node *CreateChangefeed) Format(ctx *FmtCtx) {
    24  	if node.SinkURI != nil {
    25  		ctx.WriteString("CREATE ")
    26  	} else {
    27  		// Sinkless feeds don't really CREATE anything, so the syntax omits the
    28  		// prefix. They're also still EXPERIMENTAL, so they get marked as such.
    29  		ctx.WriteString("EXPERIMENTAL ")
    30  	}
    31  	ctx.WriteString("CHANGEFEED FOR ")
    32  	ctx.FormatNode(&node.Targets)
    33  	if node.SinkURI != nil {
    34  		ctx.WriteString(" INTO ")
    35  		ctx.FormatNode(node.SinkURI)
    36  	}
    37  	if node.Options != nil {
    38  		ctx.WriteString(" WITH ")
    39  		ctx.FormatNode(&node.Options)
    40  	}
    41  }