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

     1  // Copyright 2015 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 pgwirebase
    12  
    13  import "math"
    14  
    15  //ClientMessageType represents a client pgwire message.
    16  //go:generate stringer -type=ClientMessageType
    17  type ClientMessageType byte
    18  
    19  //ServerMessageType represents a server pgwire message.
    20  //go:generate stringer -type=ServerMessageType
    21  type ServerMessageType byte
    22  
    23  // http://www.postgresql.org/docs/9.4/static/protocol-message-formats.html
    24  const (
    25  	ClientMsgBind        ClientMessageType = 'B'
    26  	ClientMsgClose       ClientMessageType = 'C'
    27  	ClientMsgCopyData    ClientMessageType = 'd'
    28  	ClientMsgCopyDone    ClientMessageType = 'c'
    29  	ClientMsgCopyFail    ClientMessageType = 'f'
    30  	ClientMsgDescribe    ClientMessageType = 'D'
    31  	ClientMsgExecute     ClientMessageType = 'E'
    32  	ClientMsgFlush       ClientMessageType = 'H'
    33  	ClientMsgParse       ClientMessageType = 'P'
    34  	ClientMsgPassword    ClientMessageType = 'p'
    35  	ClientMsgSimpleQuery ClientMessageType = 'Q'
    36  	ClientMsgSync        ClientMessageType = 'S'
    37  	ClientMsgTerminate   ClientMessageType = 'X'
    38  
    39  	ServerMsgAuth                 ServerMessageType = 'R'
    40  	ServerMsgBindComplete         ServerMessageType = '2'
    41  	ServerMsgCommandComplete      ServerMessageType = 'C'
    42  	ServerMsgCloseComplete        ServerMessageType = '3'
    43  	ServerMsgCopyInResponse       ServerMessageType = 'G'
    44  	ServerMsgDataRow              ServerMessageType = 'D'
    45  	ServerMsgEmptyQuery           ServerMessageType = 'I'
    46  	ServerMsgErrorResponse        ServerMessageType = 'E'
    47  	ServerMsgNoticeResponse       ServerMessageType = 'N'
    48  	ServerMsgNoData               ServerMessageType = 'n'
    49  	ServerMsgParameterDescription ServerMessageType = 't'
    50  	ServerMsgParameterStatus      ServerMessageType = 'S'
    51  	ServerMsgParseComplete        ServerMessageType = '1'
    52  	ServerMsgPortalSuspended      ServerMessageType = 's'
    53  	ServerMsgReady                ServerMessageType = 'Z'
    54  	ServerMsgRowDescription       ServerMessageType = 'T'
    55  )
    56  
    57  // ServerErrFieldType represents the error fields.
    58  //go:generate stringer -type=ServerErrFieldType
    59  type ServerErrFieldType byte
    60  
    61  // http://www.postgresql.org/docs/current/static/protocol-error-fields.html
    62  const (
    63  	ServerErrFieldSeverity    ServerErrFieldType = 'S'
    64  	ServerErrFieldSQLState    ServerErrFieldType = 'C'
    65  	ServerErrFieldMsgPrimary  ServerErrFieldType = 'M'
    66  	ServerErrFileldDetail     ServerErrFieldType = 'D'
    67  	ServerErrFileldHint       ServerErrFieldType = 'H'
    68  	ServerErrFieldSrcFile     ServerErrFieldType = 'F'
    69  	ServerErrFieldSrcLine     ServerErrFieldType = 'L'
    70  	ServerErrFieldSrcFunction ServerErrFieldType = 'R'
    71  )
    72  
    73  // PrepareType represents a subtype for prepare messages.
    74  //go:generate stringer -type=PrepareType
    75  type PrepareType byte
    76  
    77  const (
    78  	// PrepareStatement represents a prepared statement.
    79  	PrepareStatement PrepareType = 'S'
    80  	// PreparePortal represents a portal.
    81  	PreparePortal PrepareType = 'P'
    82  )
    83  
    84  // MaxPreparedStatementArgs is the maximum number of arguments a prepared
    85  // statement can have when prepared via the Postgres wire protocol. This is not
    86  // documented by Postgres, but is a consequence of the fact that a 16-bit
    87  // integer in the wire format is used to indicate the number of values to bind
    88  // during prepared statement execution.
    89  const MaxPreparedStatementArgs = math.MaxUint16