protocol

package
v0.9.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2017 License: Apache-2.0 Imports: 22 Imported by: 0

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

This section is empty.

Variables

This section is empty.

Functions

func LobWriteDescrToPointer

func LobWriteDescrToPointer(w *LobWriteDescr) int64

LobWriteDescrToPointer returns a pointer to a LobWriteDescr compatible to sql/driver/Value (int64).

Types

type DataType

type DataType byte

DataType is the type definition for data types supported by this package.

const (
	DtUnknown DataType = iota // unknown data type
	DtTinyint
	DtSmallint
	DtInteger
	DtBigint
	DtReal
	DtDouble
	DtDecimal
	DtTime
	DtString
	DtBytes
	DtLob
)

Data type constants.

func (DataType) String

func (i DataType) String() string

type ErrorLevel

type ErrorLevel int8

ErrorLevel send from database server.

const (
	HdbWarning    ErrorLevel = 0
	HdbError      ErrorLevel = 1
	HdbFatalError ErrorLevel = 2
)

HDB error level constants.

func (ErrorLevel) String

func (i ErrorLevel) String() string

type FieldSet

type FieldSet struct {
	// contains filtered or unexported fields
}

FieldSet contains database field metadata.

func (*FieldSet) DataType

func (f *FieldSet) DataType(idx int) DataType

DataType returns the datatype of the field at index idx.

func (*FieldSet) DatabaseTypeName added in v0.9.4

func (f *FieldSet) DatabaseTypeName(idx int) string

DatabaseTypeName returns the type name of the field at index idx. see https://golang.org/pkg/database/sql/driver/#RowsColumnTypeDatabaseTypeName

func (*FieldSet) NumInputField

func (f *FieldSet) NumInputField() int

NumInputField returns the number of input fields in a database statement.

func (*FieldSet) NumOutputField

func (f *FieldSet) NumOutputField() int

NumOutputField returns the number of output fields of a query or stored procedure.

func (*FieldSet) OutputNames

func (f *FieldSet) OutputNames(names []string) error

OutputNames fills the names parameter with field names of all output fields. The size of the names slice must be at least NumOutputField big.

func (*FieldSet) String

func (f *FieldSet) String() string

String implements the Stringer interface.

func (*FieldSet) TypeLength added in v0.9.4

func (f *FieldSet) TypeLength(idx int) (int64, bool)

TypeLength returns the type length of the field at index idx. see https://golang.org/pkg/database/sql/driver/#RowsColumnTypeLength

func (*FieldSet) TypeNullable added in v0.9.4

func (f *FieldSet) TypeNullable(idx int) bool

TypeNullable returns true if the column at index idx may be null, false otherwise. see https://golang.org/pkg/database/sql/driver/#RowsColumnTypeNullable

func (*FieldSet) TypePrecisionScale added in v0.9.4

func (f *FieldSet) TypePrecisionScale(idx int) (int64, int64, bool)

TypePrecisionScale returns the type precision and scale (decimal types) of the field at index idx. see https://golang.org/pkg/database/sql/driver/#RowsColumnTypePrecisionScale

type FieldValues

type FieldValues struct {
	// contains filtered or unexported fields
}

FieldValues contains rows read from database.

func (*FieldValues) NumRow

func (f *FieldValues) NumRow() int

NumRow returns the number of rows available in FieldValues.

func (*FieldValues) Row

func (f *FieldValues) Row(idx int, dest []driver.Value)

Row fills the dest value slice with row data at index idx.

func (*FieldValues) String

func (f *FieldValues) String() string

type LobReadDescr

type LobReadDescr struct {
	// contains filtered or unexported fields
}

LobReadDescr is the package internal representation of a lob field to be read from database.

func PointerToLobReadDescr

func PointerToLobReadDescr(ptr int64) *LobReadDescr

PointerToLobReadDescr returns the address of a LobReadDescr from an sql/driver/Value (int64) compatible pointer.

func (*LobReadDescr) SetWriter

func (d *LobReadDescr) SetWriter(w io.Writer) error

SetWriter sets the io.Writer destination for a lob field to be read from database.

type LobWriteDescr

type LobWriteDescr struct {
	// contains filtered or unexported fields
}

LobWriteDescr is the package internal representation of a lob field to be written to database.

func (*LobWriteDescr) SetReader

func (d *LobWriteDescr) SetReader(r io.Reader)

SetReader sets the io.Reader source for a lob field to be written to database.

type PartAttributes

type PartAttributes interface {
	ResultsetClosed() bool
	LastPacket() bool
	NoRows() bool
}

PartAttributes is an interface defining methods for reading query resultset parts.

type QueryType

type QueryType byte

QueryType is the type definition for query types supported by this package.

const (
	QtNone QueryType = iota
	QtSelect
	QtProcedureCall
)

Query type constants.

func (QueryType) String

func (i QueryType) String() string

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session represents a HDB session.

func NewSession

func NewSession(prm *SessionPrm) (*Session, error)

NewSession creates a new database session.

func (*Session) BadErr

func (s *Session) BadErr() error

BadErr returns the error, that caused the bad session state.

func (*Session) Call

func (s *Session) Call(id uint64, prmFieldSet *FieldSet, args []driver.Value) (*FieldValues, []*TableResult, error)

Call executes a stored procedure.

func (*Session) Close

func (s *Session) Close() error

Close closes the session.

func (*Session) CloseResultsetID

func (s *Session) CloseResultsetID(id uint64) error

CloseResultsetID releases the hdb resultset handle.

func (*Session) Commit

func (s *Session) Commit() error

Commit executes a database commit.

func (*Session) DropStatementID

func (s *Session) DropStatementID(id uint64) error

DropStatementID releases the hdb statement handle.

func (*Session) Exec

func (s *Session) Exec(id uint64, parameterFieldSet *FieldSet, args []driver.Value) (driver.Result, error)

Exec executes a sql statement.

func (*Session) ExecDirect

func (s *Session) ExecDirect(query string) (driver.Result, error)

ExecDirect executes a sql statement without statement parameters.

func (*Session) FetchNext

func (s *Session) FetchNext(id uint64, resultFieldSet *FieldSet) (*FieldValues, PartAttributes, error)

FetchNext fetches next chunk in query result set.

func (*Session) InTx

func (s *Session) InTx() bool

InTx indicates, if the session is in transaction mode.

func (*Session) IsBad

func (s *Session) IsBad() bool

IsBad indicates, that the session is in bad state.

func (*Session) Prepare

func (s *Session) Prepare(query string) (QueryType, uint64, *FieldSet, *FieldSet, error)

Prepare prepares a sql statement.

func (*Session) Query

func (s *Session) Query(stmtID uint64, parameterFieldSet *FieldSet, resultFieldSet *FieldSet, args []driver.Value) (uint64, *FieldValues, PartAttributes, error)

Query executes a query.

func (*Session) QueryDirect

func (s *Session) QueryDirect(query string) (uint64, *FieldSet, *FieldValues, PartAttributes, error)

QueryDirect executes a query without query parameters.

func (*Session) Rollback

func (s *Session) Rollback() error

Rollback executes a database rollback.

func (*Session) SetInTx

func (s *Session) SetInTx(v bool)

SetInTx sets session in transaction mode.

type SessionPrm

type SessionPrm struct {
	Host, Username, Password       string
	Locale                         string
	BufferSize, FetchSize, Timeout int
}

func (*SessionPrm) String

func (p *SessionPrm) String() string

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

func NewSniffer(conn net.Conn, dbAddr string) (*Sniffer, error)

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.

func (*Sniffer) Go

func (s *Sniffer) Go()

Go starts the protocol request and response logging.

type TableResult

type TableResult struct {
	// contains filtered or unexported fields
}

TableResult is the package internal representation of a table like output parameter of a stored procedure.

func (*TableResult) Attrs

func (r *TableResult) Attrs() PartAttributes

Attrs returns the PartAttributes interface of the fetched resultset part.

func (*TableResult) FieldSet

func (r *TableResult) FieldSet() *FieldSet

FieldSet returns the field metadata of the table.

func (*TableResult) FieldValues

func (r *TableResult) FieldValues() *FieldValues

FieldValues returns the field values (fetched resultset part) of the table.

func (*TableResult) ID

func (r *TableResult) ID() uint64

ID returns the resultset id.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL