Documentation ¶
Overview ¶
Package protocol implements the hdb command network protocol.
http://help.sap.com/hana/SAP_HANA_SQL_Command_Network_Protocol_Reference_en.pdf
Index ¶
- Constants
- Variables
- func RegisterScanType(dt DataType, scanType reflect.Type)
- type ConvertError
- type DataType
- type OnCloser
- type ParameterField
- type PrepareResult
- func (pr *PrepareResult) Check(qd *QueryDescr) error
- func (pr *PrepareResult) IsProcedureCall() bool
- func (pr *PrepareResult) NumField() int
- func (pr *PrepareResult) NumInputField() int
- func (pr *PrepareResult) ParameterField(idx int) *ParameterField
- func (pr *PrepareResult) Session() *Session
- func (pr *PrepareResult) StmtID() uint64
- type QueryDescr
- type QueryKind
- type ReadProvider
- type Session
- func (s *Session) CloseResultsetID(id uint64) error
- func (s *Session) Commit() error
- func (s *Session) Disconnect() error
- func (s *Session) DropStatementID(id uint64) error
- func (s *Session) Exec(pr *PrepareResult, args []interface{}, commit bool) (driver.Result, error)
- func (s *Session) ExecCall(pr *PrepareResult, args []interface{}) (driver.Result, error)
- func (s *Session) ExecDirect(query string, commit bool) (driver.Result, error)
- func (s *Session) HDBVersion() *hdb.Version
- func (s *Session) Prepare(query string) (*PrepareResult, error)
- func (s *Session) Query(pr *PrepareResult, args []interface{}, commit bool) (driver.Rows, error)
- func (s *Session) QueryCall(pr *PrepareResult, args []interface{}) (driver.Rows, error)
- func (s *Session) QueryDirect(query string, commit bool) (driver.Rows, error)
- func (s *Session) Rollback() error
- func (s *Session) SessionID() int64
- type SessionConfig
- type Sniffer
- type WriterSetter
Constants ¶
const ( // MaxNumArg is the maximum number of arguments allowed to send in a part. MaxNumArg = math.MaxInt16 )
Variables ¶
var ErrDecimalOutOfRange = errors.New("decimal out of range error")
ErrDecimalOutOfRange means that a big.Rat exceeds the size of hdb decimal fields.
var ErrFloatOutOfRange = errors.New("float out of range error")
ErrFloatOutOfRange means that a float exceeds the size of the hdb float field.
var ErrIntegerOutOfRange = errors.New("integer out of range error")
ErrIntegerOutOfRange means that an integer exceeds the size of the hdb integer field.
var ErrUint64OutOfRange = errors.New("uint64 values with high bit set are not supported")
ErrUint64OutOfRange means that a uint64 exceeds the size of a int64.
var QueryResultCache = newQueryResultCache()
QueryResultCache is a query result cache supporting reading procedure (call) table parameter via separate query (legacy mode).
Functions ¶
func RegisterScanType ¶
RegisterScanType registers driver owned datatype scantypes (e.g. Decimal, Lob).
Types ¶
type ConvertError ¶
type ConvertError struct {
// contains filtered or unexported fields
}
A ConvertError is returned by conversion methods if a go datatype to hdb datatype conversion fails.
func (*ConvertError) Error ¶
func (e *ConvertError) Error() string
func (*ConvertError) Unwrap ¶
func (e *ConvertError) Unwrap() error
Unwrap returns the nested error.
type DataType ¶
type DataType byte
DataType is the type definition for data types supported by this package.
const ( DtUnknown DataType = iota // unknown data type DtBoolean DtTinyint DtSmallint DtInteger DtBigint DtReal DtDouble DtDecimal DtTime DtString DtBytes DtLob DtRows )
Data type constants.
type OnCloser ¶
type OnCloser interface { OnClose() func() SetOnClose(func()) }
OnCloser defines getter and setter for a function which should be called when closing.
type ParameterField ¶
type ParameterField struct {
// contains filtered or unexported fields
}
ParameterField contains database field attributes for parameters.
func (*ParameterField) Convert ¶
func (f *ParameterField) Convert(s *Session, v interface{}) (interface{}, error)
Convert returns the result of the fieldType conversion.
func (*ParameterField) In ¶
func (f *ParameterField) In() bool
In returns true if the parameter field is an input field.
func (*ParameterField) Out ¶
func (f *ParameterField) Out() bool
Out returns true if the parameter field is an output field.
func (*ParameterField) String ¶
func (f *ParameterField) String() string
type PrepareResult ¶
type PrepareResult struct {
// contains filtered or unexported fields
}
A PrepareResult represents the result of a prepare statement.
func (*PrepareResult) Check ¶
func (pr *PrepareResult) Check(qd *QueryDescr) error
Check checks consistency of the prepare result.
func (*PrepareResult) IsProcedureCall ¶
func (pr *PrepareResult) IsProcedureCall() bool
IsProcedureCall returns true if the statement is a call statement.
func (*PrepareResult) NumField ¶
func (pr *PrepareResult) NumField() int
NumField returns the number of parameter fields in a database statement.
func (*PrepareResult) NumInputField ¶
func (pr *PrepareResult) NumInputField() int
NumInputField returns the number of input fields in a database statement.
func (*PrepareResult) ParameterField ¶
func (pr *PrepareResult) ParameterField(idx int) *ParameterField
ParameterField returns the parameter field at index idx.
func (*PrepareResult) Session ¶ added in v0.105.1
func (pr *PrepareResult) Session() *Session
Session returns the session the prepare result belongs to.
func (*PrepareResult) StmtID ¶
func (pr *PrepareResult) StmtID() uint64
StmtID returns the statement id.
type QueryDescr ¶
type QueryDescr struct {
// contains filtered or unexported fields
}
QueryDescr represents a query descriptor of a database statement.
func NewQueryDescr ¶
func NewQueryDescr(query string, sc *scanner.Scanner) (*QueryDescr, error)
NewQueryDescr returns a new QueryDescr instance.
func (*QueryDescr) ID ¶
func (d *QueryDescr) ID() uint64
ID return the query id of a query descriptor (legacy mode: call table output parameters).
func (*QueryDescr) IsBulk ¶
func (d *QueryDescr) IsBulk() bool
IsBulk returns true if the query is a bulk statement..
func (*QueryDescr) Kind ¶
func (d *QueryDescr) Kind() QueryKind
Kind return the query kind of a query descriptor.
func (*QueryDescr) Query ¶
func (d *QueryDescr) Query() string
Query return the query statement of a query descriptor.
func (*QueryDescr) String ¶
func (d *QueryDescr) String() string
type QueryKind ¶
type QueryKind int
QueryKind is the query type of a database statement.
type ReadProvider ¶
ReadProvider is the interface wrapping the Reader which provides an io.Reader.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents a HDB session.
func NewSession ¶
func NewSession(ctx context.Context, rw *bufio.ReadWriter, cfg *SessionConfig) (*Session, error)
NewSession creates a new database session.
func (*Session) CloseResultsetID ¶
CloseResultsetID releases the hdb resultset handle.
func (*Session) Disconnect ¶
Disconnect disconnects the session.
func (*Session) DropStatementID ¶
DropStatementID releases the hdb statement handle.
func (*Session) Exec ¶
Exec executes a sql statement.
Bulk insert containing LOBs:
- Precondition: .Sending more than one row with partial LOB data.
- Observations: .In hdb version 1 and 2 'piecewise' LOB writing does work. .Same does not work in case of geo fields which are LOBs en,- decoded as well. .In hana version 4 'piecewise' LOB writing seems not to work anymore at all.
- Server implementation (not documented): .'piecewise' LOB writing is only suppoerted for the last row of a 'bulk insert'.
- Current implementation: One server call in case of
- 'non bulk' execs or
- 'bulk' execs without LOBs else potential several server calls (split into packages). Package invariant:
- For all packages except the last one, the last row contains 'incomplete' LOB data ('piecewise' writing)
func (*Session) ExecCall ¶
func (s *Session) ExecCall(pr *PrepareResult, args []interface{}) (driver.Result, error)
ExecCall executes a stored procecure (by Exec).
func (*Session) ExecDirect ¶
ExecDirect executes a sql statement without statement parameters.
func (*Session) HDBVersion ¶
HDBVersion returns the hdb server version.
func (*Session) Prepare ¶
func (s *Session) Prepare(query string) (*PrepareResult, error)
Prepare prepares a sql statement.
func (*Session) QueryCall ¶
func (s *Session) QueryCall(pr *PrepareResult, args []interface{}) (driver.Rows, error)
QueryCall executes a stored procecure (by Query).
func (*Session) QueryDirect ¶
QueryDirect executes a query without query parameters.
type SessionConfig ¶
type SessionConfig struct {
DriverVersion, DriverName string
ApplicationName, Username, Password string
SessionVariables *vermap.VerMap
Locale string
FetchSize, LobChunkSize int
Dfv int
Legacy bool
CESU8Decoder func() transform.Transformer
CESU8Encoder func() transform.Transformer
}
SessionConfig represents the session relevant driver connector options.
type Sniffer ¶
type Sniffer struct {
// contains filtered or unexported fields
}
A Sniffer is a simple proxy for logging hdb protocol requests and responses.
func NewSniffer ¶
NewSniffer creates a new sniffer instance. The conn parameter is the net.Conn connection, where the Sniffer is listening for hdb protocol calls. The dbAddr is the hdb host port address in "host:port" format.
type WriterSetter ¶
WriterSetter is the interface wrapping the SetWriter method (Lob handling).
Source Files ¶
- authentication.go
- clientcontext.go
- clientcontextoption.go
- clientcontextoption_string.go
- clientid.go
- clientinfo.go
- command.go
- connectoption.go
- connectoption_string.go
- connectoptions.go
- convert.go
- datatype.go
- datatype_string.go
- doc.go
- endianess.go
- endianess_string.go
- error.go
- errorlevel.go
- fetchsize.go
- field.go
- fieldtype.go
- functioncode.go
- functioncode_string.go
- init.go
- julian.go
- keyvalue.go
- lob.go
- lobtypecode_string.go
- log.go
- message.go
- messagetype.go
- messagetype_string.go
- option.go
- parameter.go
- part.go
- partkind.go
- partkind_string.go
- parts.go
- protocol.go
- querydescr.go
- queryresultcache.go
- result.go
- rowsaffected.go
- segment.go
- segmentkind.go
- segmentkind_string.go
- session.go
- sessionconfig.go
- sniffer.go
- statementcontext.go
- statementcontexttype.go
- statementcontexttype_string.go
- statementid.go
- topology.go
- topologyoption.go
- topologyoption_string.go
- transactionflags.go
- transactionflagtype.go
- transactionflagtype_string.go
- typecode.go
- typecode_string.go