github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/set_transaction.go (about)

     1  // Copyright 2017 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  package sql
    12  
    13  import (
    14  	"context"
    15  
    16  	"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
    17  	"github.com/cockroachdb/cockroach/pkg/util/hlc"
    18  )
    19  
    20  // SetTransaction sets a transaction's isolation level, priority, ro/rw state,
    21  // and as of timestamp.
    22  func (p *planner) SetTransaction(ctx context.Context, n *tree.SetTransaction) (planNode, error) {
    23  	var asOfTs hlc.Timestamp
    24  	if n.Modes.AsOf.Expr != nil {
    25  		var err error
    26  		asOfTs, err = p.EvalAsOfTimestamp(ctx, n.Modes.AsOf)
    27  		if err != nil {
    28  			return nil, err
    29  		}
    30  		p.semaCtx.AsOfTimestamp = &asOfTs
    31  	}
    32  
    33  	if err := p.extendedEvalCtx.TxnModesSetter.setTransactionModes(n.Modes, asOfTs); err != nil {
    34  		return nil, err
    35  	}
    36  	return newZeroNode(nil /* columns */), nil
    37  }