github.com/cockroachdb/cockroachdb-parser@v0.23.3-0.20240213214944-911057d40c9a/pkg/sql/sem/tree/alter_schema.go (about)

     1  // Copyright 2020 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  // AlterSchema represents an ALTER SCHEMA statement.
    14  type AlterSchema struct {
    15  	Schema ObjectNamePrefix
    16  	Cmd    AlterSchemaCmd
    17  }
    18  
    19  var _ Statement = &AlterSchema{}
    20  
    21  // Format implements the NodeFormatter interface.
    22  func (node *AlterSchema) Format(ctx *FmtCtx) {
    23  	ctx.WriteString("ALTER SCHEMA ")
    24  	ctx.FormatNode(&node.Schema)
    25  	ctx.FormatNode(node.Cmd)
    26  }
    27  
    28  // AlterSchemaCmd represents a schema modification operation.
    29  type AlterSchemaCmd interface {
    30  	NodeFormatter
    31  	alterSchemaCmd()
    32  }
    33  
    34  func (*AlterSchemaRename) alterSchemaCmd() {}
    35  
    36  // AlterSchemaRename represents an ALTER SCHEMA RENAME command.
    37  type AlterSchemaRename struct {
    38  	NewName Name
    39  }
    40  
    41  // Format implements the NodeFormatter interface.
    42  func (node *AlterSchemaRename) Format(ctx *FmtCtx) {
    43  	ctx.WriteString(" RENAME TO ")
    44  	ctx.FormatNode(&node.NewName)
    45  }
    46  
    47  func (*AlterSchemaOwner) alterSchemaCmd() {}
    48  
    49  // AlterSchemaOwner represents an ALTER SCHEMA OWNER TO command.
    50  type AlterSchemaOwner struct {
    51  	Owner RoleSpec
    52  }
    53  
    54  // Format implements the NodeFormatter interface.
    55  func (node *AlterSchemaOwner) Format(ctx *FmtCtx) {
    56  	ctx.WriteString(" OWNER TO ")
    57  	ctx.FormatNode(&node.Owner)
    58  }