github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/statement.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  	"github.com/cockroachdb/cockroach/pkg/sql/parser"
    15  	"github.com/cockroachdb/cockroach/pkg/sql/sqlbase"
    16  )
    17  
    18  // Statement contains a statement with optional expected result columns and metadata.
    19  type Statement struct {
    20  	parser.Statement
    21  
    22  	ExpectedTypes sqlbase.ResultColumns
    23  	AnonymizedStr string
    24  	queryID       ClusterWideID
    25  
    26  	// Prepared is non-nil during the PREPARE phase, as well as during EXECUTE of
    27  	// a previously prepared statement. The Prepared statement can be modified
    28  	// during either phase; the PREPARE phase sets its initial state, and the
    29  	// EXECUTE phase can re-prepare it. This happens when the original plan has
    30  	// been invalidated by schema changes, session data changes, permission
    31  	// changes, or other changes to the context in which the original plan was
    32  	// prepared.
    33  	//
    34  	// Given that the PreparedStatement can be modified during planning, it is
    35  	// not safe for use on multiple threads.
    36  	Prepared *PreparedStatement
    37  }
    38  
    39  func (s Statement) String() string {
    40  	// We have the original SQL, but we still use String() because it obfuscates
    41  	// passwords.
    42  	return s.AST.String()
    43  }