github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/parsers/tree/upgrade.go (about)

     1  // Copyright 2024 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 UpgradeStatement struct {
    20  	statementImpl
    21  	Target *Target
    22  	Retry  int64
    23  }
    24  
    25  // input:  "upgrade account all with retry 10",
    26  type Target struct {
    27  	NodeFormatter
    28  	AccountName  string
    29  	IsALLAccount bool // Add attribute to indicate whether it is an ALL account
    30  }
    31  
    32  func (node *Target) Format(ctx *FmtCtx) {
    33  	if node.IsALLAccount {
    34  		ctx.WriteString("all")
    35  	} else {
    36  		ctx.WriteString(node.AccountName)
    37  	}
    38  }
    39  
    40  func (node *UpgradeStatement) Format(ctx *FmtCtx) {
    41  	ctx.WriteString("upgrade account ")
    42  	node.Target.Format(ctx)
    43  	if node.Retry > 0 {
    44  		ctx.WriteString(" with retry " + strconv.FormatInt(node.Retry, 10))
    45  	}
    46  }
    47  
    48  func (node *UpgradeStatement) GetStatementType() string { return "UpgradeStatement" }
    49  
    50  func (node *UpgradeStatement) GetQueryType() string { return QueryTypeOth }
    51  
    52  func (node UpgradeStatement) TypeName() string { return "tree.UpgradeStatement" }