github.com/cockroachdb/cockroachdb-parser@v0.23.3-0.20240213214944-911057d40c9a/pkg/sql/sem/plpgsqltree/constants.go (about)

     1  // Copyright 2023 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 plpgsqltree
    12  
    13  import "github.com/cockroachdb/errors"
    14  
    15  // GetDiagnosticsKind represents the type of error diagnostic
    16  // item in stmt_getdiag.
    17  type GetDiagnosticsKind int
    18  
    19  const (
    20  	// GetDiagnosticsRowCount returns the number of rows processed by the recent
    21  	// SQL command.
    22  	GetDiagnosticsRowCount GetDiagnosticsKind = iota
    23  	// GetDiagnosticsContext returns text describing the current call stack.
    24  	GetDiagnosticsContext
    25  	// GetDiagnosticsErrorContext returns text describing the exception's
    26  	// callstack.
    27  	GetDiagnosticsErrorContext
    28  	// GetDiagnosticsErrorDetail returns the exceptions detail message.
    29  	GetDiagnosticsErrorDetail
    30  	// GetDiagnosticsErrorHint returns the exceptions hint message.
    31  	GetDiagnosticsErrorHint
    32  	// GetDiagnosticsReturnedSQLState returns the SQLSTATE error code related to
    33  	// the exception.
    34  	GetDiagnosticsReturnedSQLState
    35  	// GetDiagnosticsColumnName returns the column name related to the exception.
    36  	GetDiagnosticsColumnName
    37  	// GetDiagnosticsConstraintName returns the constraint name related to
    38  	// the exception.
    39  	GetDiagnosticsConstraintName
    40  	// GetDiagnosticsDatatypeName returns the data type name related to the
    41  	// exception.
    42  	GetDiagnosticsDatatypeName
    43  	// GetDiagnosticsMessageText returns the exceptions primary message.
    44  	GetDiagnosticsMessageText
    45  	// GetDiagnosticsTableName returns the name of the table related to the
    46  	// exception.
    47  	GetDiagnosticsTableName
    48  	// GetDiagnosticsSchemaName returns the name of the schema related to the
    49  	// exception.
    50  	GetDiagnosticsSchemaName
    51  )
    52  
    53  // String implements the fmt.Stringer interface.
    54  func (k GetDiagnosticsKind) String() string {
    55  	switch k {
    56  	case GetDiagnosticsRowCount:
    57  		return "ROW_COUNT"
    58  	case GetDiagnosticsContext:
    59  		return "PG_CONTEXT"
    60  	case GetDiagnosticsErrorContext:
    61  		return "PG_EXCEPTION_CONTEXT"
    62  	case GetDiagnosticsErrorDetail:
    63  		return "PG_EXCEPTION_DETAIL"
    64  	case GetDiagnosticsErrorHint:
    65  		return "PG_EXCEPTION_HINT"
    66  	case GetDiagnosticsReturnedSQLState:
    67  		return "RETURNED_SQLSTATE"
    68  	case GetDiagnosticsColumnName:
    69  		return "COLUMN_NAME"
    70  	case GetDiagnosticsConstraintName:
    71  		return "CONSTRAINT_NAME"
    72  	case GetDiagnosticsDatatypeName:
    73  		return "PG_DATATYPE_NAME"
    74  	case GetDiagnosticsMessageText:
    75  		return "MESSAGE_TEXT"
    76  	case GetDiagnosticsTableName:
    77  		return "TABLE_NAME"
    78  	case GetDiagnosticsSchemaName:
    79  		return "SCHEMA_NAME"
    80  	}
    81  	panic(errors.AssertionFailedf("unknown diagnostics kind"))
    82  }