vitess.io/vitess@v0.16.2/go/vt/vtgate/planbuilder/operators/update.go (about)

     1  /*
     2  Copyright 2022 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package operators
    18  
    19  import (
    20  	"vitess.io/vitess/go/vt/sqlparser"
    21  	"vitess.io/vitess/go/vt/vtgate/engine"
    22  	"vitess.io/vitess/go/vt/vtgate/planbuilder/operators/ops"
    23  	"vitess.io/vitess/go/vt/vtgate/semantics"
    24  	"vitess.io/vitess/go/vt/vtgate/vindexes"
    25  )
    26  
    27  type Update struct {
    28  	QTable              *QueryTable
    29  	VTable              *vindexes.Table
    30  	Assignments         map[string]sqlparser.Expr
    31  	ChangedVindexValues map[string]*engine.VindexValues
    32  	OwnedVindexQuery    string
    33  	AST                 *sqlparser.Update
    34  
    35  	noInputs
    36  	noColumns
    37  	noPredicates
    38  }
    39  
    40  var _ ops.PhysicalOperator = (*Update)(nil)
    41  
    42  // Introduces implements the PhysicalOperator interface
    43  func (u *Update) Introduces() semantics.TableSet {
    44  	return u.QTable.ID
    45  }
    46  
    47  // IPhysical implements the PhysicalOperator interface
    48  func (u *Update) IPhysical() {}
    49  
    50  // Clone implements the Operator interface
    51  func (u *Update) Clone(inputs []ops.Operator) ops.Operator {
    52  	return &Update{
    53  		QTable:              u.QTable,
    54  		VTable:              u.VTable,
    55  		Assignments:         u.Assignments,
    56  		ChangedVindexValues: u.ChangedVindexValues,
    57  		OwnedVindexQuery:    u.OwnedVindexQuery,
    58  		AST:                 u.AST,
    59  	}
    60  }
    61  
    62  func (u *Update) TablesUsed() []string {
    63  	if u.VTable != nil {
    64  		return SingleQualifiedIdentifier(u.VTable.Keyspace, u.VTable.Name)
    65  	}
    66  	return nil
    67  }