github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/sem/tree/truncate.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 // Truncate represents a TRUNCATE statement. 23 type Truncate struct { 24 Tables TableNames 25 DropBehavior DropBehavior 26 } 27 28 // Format implements the NodeFormatter interface. 29 func (node *Truncate) Format(ctx *FmtCtx) { 30 ctx.WriteString("TRUNCATE TABLE ") 31 sep := "" 32 for i := range node.Tables { 33 ctx.WriteString(sep) 34 ctx.FormatNode(&node.Tables[i]) 35 sep = ", " 36 } 37 if node.DropBehavior != DropDefault { 38 ctx.WriteByte(' ') 39 ctx.WriteString(node.DropBehavior.String()) 40 } 41 }