github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/parsers/tree/truncate.go (about) 1 // Copyright 2021 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package tree 16 17 import "github.com/matrixorigin/matrixone/pkg/common/reuse" 18 19 func init() { 20 reuse.CreatePool[TruncateTable]( 21 func() *TruncateTable { return &TruncateTable{} }, 22 func(t *TruncateTable) { t.reset() }, 23 reuse.DefaultOptions[TruncateTable](), //. 24 ) //WithEnableChecker() 25 26 } 27 28 // truncate table statement 29 type TruncateTable struct { 30 statementImpl 31 Name *TableName 32 } 33 34 func NewTruncateTable(name *TableName) *TruncateTable { 35 truncate := reuse.Alloc[TruncateTable](nil) 36 truncate.Name = name 37 return truncate 38 } 39 40 func (node *TruncateTable) Format(ctx *FmtCtx) { 41 ctx.WriteString("truncate table") 42 ctx.WriteByte(' ') 43 node.Name.Format(ctx) 44 } 45 46 func (node *TruncateTable) GetStatementType() string { return "Truncate" } 47 func (node *TruncateTable) GetQueryType() string { return QueryTypeDDL } 48 49 func (node *TruncateTable) Free() { 50 reuse.Free[TruncateTable](node, nil) 51 } 52 53 func (node *TruncateTable) reset() { 54 // if node.Name != nil { 55 // node.Name.Free() 56 // } 57 *node = TruncateTable{} 58 } 59 60 func (node TruncateTable) TypeName() string { return "tree.TruncateTable" }