github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/sem/tree/revoke.go (about) 1 // Copyright 2012, Google Inc. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in licenses/BSD-vitess.txt. 4 5 // Portions of this file are additionally subject to the following 6 // license and copyright. 7 // 8 // Copyright 2015 The Cockroach Authors. 9 // 10 // Use of this software is governed by the Business Source License 11 // included in the file licenses/BSL.txt. 12 // 13 // As of the Change Date specified in that file, in accordance with 14 // the Business Source License, use of this software will be governed 15 // by the Apache License, Version 2.0, included in the file 16 // licenses/APL.txt. 17 18 // This code was derived from https://github.com/youtube/vitess. 19 20 package tree 21 22 import "github.com/cockroachdb/cockroach/pkg/sql/privilege" 23 24 // Revoke represents a REVOKE statement. 25 // PrivilegeList and TargetList are defined in grant.go 26 type Revoke struct { 27 Privileges privilege.List 28 Targets TargetList 29 Grantees NameList 30 } 31 32 // Format implements the NodeFormatter interface. 33 func (node *Revoke) Format(ctx *FmtCtx) { 34 ctx.WriteString("REVOKE ") 35 node.Privileges.Format(&ctx.Buffer) 36 ctx.WriteString(" ON ") 37 ctx.FormatNode(&node.Targets) 38 ctx.WriteString(" FROM ") 39 ctx.FormatNode(&node.Grantees) 40 } 41 42 // RevokeRole represents a REVOKE <role> statement. 43 type RevokeRole struct { 44 Roles NameList 45 Members NameList 46 AdminOption bool 47 } 48 49 // Format implements the NodeFormatter interface. 50 func (node *RevokeRole) Format(ctx *FmtCtx) { 51 ctx.WriteString("REVOKE ") 52 if node.AdminOption { 53 ctx.WriteString("ADMIN OPTION FOR ") 54 } 55 ctx.FormatNode(&node.Roles) 56 ctx.WriteString(" FROM ") 57 ctx.FormatNode(&node.Members) 58 }