github.com/matrixorigin/matrixone@v0.7.0/pkg/sql/parsers/tree/mo_dump.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 "strconv"
    18  
    19  type MoDump struct {
    20  	statementImpl
    21  	DumpDatabase bool
    22  	Database     Identifier
    23  	Tables       TableNames
    24  	OutFile      string
    25  	MaxFileSize  int64
    26  	ExportParams *ExportParam
    27  }
    28  
    29  func (node *MoDump) Format(ctx *FmtCtx) {
    30  	ctx.WriteString("modump")
    31  	if node.DumpDatabase {
    32  		if node.Database != "" {
    33  			ctx.WriteString(" database ")
    34  			ctx.WriteString(string(node.Database))
    35  		}
    36  		if node.Tables != nil {
    37  			ctx.WriteString(" tables ")
    38  			node.Tables.Format(ctx)
    39  		}
    40  		if node.OutFile != "" {
    41  			ctx.WriteString(" into ")
    42  			ctx.WriteString(node.OutFile)
    43  		}
    44  		if node.MaxFileSize != 0 {
    45  			ctx.WriteString(" max_file_size ")
    46  			ctx.WriteString(strconv.FormatInt(node.MaxFileSize, 10))
    47  		}
    48  	} else {
    49  		ctx.WriteString(" query_result")
    50  		ctx.WriteByte(' ')
    51  		ctx.WriteString(node.ExportParams.QueryId)
    52  		ctx.WriteByte(' ')
    53  		node.ExportParams.format(ctx, false)
    54  	}
    55  }
    56  
    57  func (node *MoDump) GetStatementType() string { return "MoDump" }
    58  func (node *MoDump) GetQueryType() string     { return QueryTypeDQL }