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

     1  // Copyright 2021 - 2022 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  type Execute struct {
    18  	Statement
    19  	Name      Identifier
    20  	Variables []*VarExpr
    21  }
    22  
    23  func (node *Execute) Format(ctx *FmtCtx) {
    24  	ctx.WriteString("execute ")
    25  	node.Name.Format(ctx)
    26  	if len(node.Variables) > 0 {
    27  		ctx.WriteString(" using ")
    28  		for i, varExpr := range node.Variables {
    29  			if i > 0 {
    30  				ctx.WriteString(",")
    31  			}
    32  			varExpr.Format(ctx)
    33  		}
    34  	}
    35  }
    36  
    37  func (node *Execute) Free() {
    38  
    39  }
    40  
    41  func (node *Execute) GetStatementType() string { return "Execute" }
    42  func (node *Execute) GetQueryType() string     { return QueryTypeOth }
    43  
    44  func NewExecute(name Identifier) *Execute {
    45  	return &Execute{
    46  		Name: name,
    47  	}
    48  }
    49  
    50  func NewExecuteWithVariables(name Identifier, variables []*VarExpr) *Execute {
    51  	return &Execute{
    52  		Name:      name,
    53  		Variables: variables,
    54  	}
    55  }