github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/pingcap/tidb/ast/base.go (about)

     1  // Copyright 2015 PingCAP, Inc.
     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  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package ast
    15  
    16  import "github.com/insionng/yougam/libraries/pingcap/tidb/util/types"
    17  
    18  // node is the struct implements node interface except for Accept method.
    19  // Node implementations should embed it in.
    20  type node struct {
    21  	text string
    22  }
    23  
    24  // SetText implements Node interface.
    25  func (n *node) SetText(text string) {
    26  	n.text = text
    27  }
    28  
    29  // Text implements Node interface.
    30  func (n *node) Text() string {
    31  	return n.text
    32  }
    33  
    34  // stmtNode implements StmtNode interface.
    35  // Statement implementations should embed it in.
    36  type stmtNode struct {
    37  	node
    38  }
    39  
    40  // statement implements StmtNode interface.
    41  func (sn *stmtNode) statement() {}
    42  
    43  // ddlNode implements DDLNode interface.
    44  // DDL implementations should embed it in.
    45  type ddlNode struct {
    46  	stmtNode
    47  }
    48  
    49  // ddlStatement implements DDLNode interface.
    50  func (dn *ddlNode) ddlStatement() {}
    51  
    52  // dmlNode is the struct implements DMLNode interface.
    53  // DML implementations should embed it in.
    54  type dmlNode struct {
    55  	stmtNode
    56  }
    57  
    58  // dmlStatement implements DMLNode interface.
    59  func (dn *dmlNode) dmlStatement() {}
    60  
    61  // expressionNode is the struct implements Expression interface.
    62  // Expression implementations should embed it in.
    63  type exprNode struct {
    64  	node
    65  	types.Datum
    66  	Type *types.FieldType
    67  	flag uint64
    68  }
    69  
    70  // SetDatum implements Expression interface.
    71  func (en *exprNode) SetDatum(datum types.Datum) {
    72  	en.Datum = datum
    73  }
    74  
    75  // GetDatum implements Expression interface.
    76  func (en *exprNode) GetDatum() *types.Datum {
    77  	return &en.Datum
    78  }
    79  
    80  // SetType implements Expression interface.
    81  func (en *exprNode) SetType(tp *types.FieldType) {
    82  	en.Type = tp
    83  }
    84  
    85  // GetType implements Expression interface.
    86  func (en *exprNode) GetType() *types.FieldType {
    87  	return en.Type
    88  }
    89  
    90  // SetFlag implements Expression interface.
    91  func (en *exprNode) SetFlag(flag uint64) {
    92  	en.flag = flag
    93  }
    94  
    95  // GetFlag implements Expression interface.
    96  func (en *exprNode) GetFlag() uint64 {
    97  	return en.flag
    98  }
    99  
   100  type funcNode struct {
   101  	exprNode
   102  }
   103  
   104  // FunctionExpression implements FounctionNode interface.
   105  func (fn *funcNode) functionExpression() {}
   106  
   107  type resultSetNode struct {
   108  	resultFields []*ResultField
   109  }
   110  
   111  // GetResultFields implements ResultSetNode interface.
   112  func (rs *resultSetNode) GetResultFields() []*ResultField {
   113  	return rs.resultFields
   114  }
   115  
   116  // GetResultFields implements ResultSetNode interface.
   117  func (rs *resultSetNode) SetResultFields(rfs []*ResultField) {
   118  	rs.resultFields = rfs
   119  }