protocol

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2018 License: Apache-2.0 Imports: 23 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

This section is empty.

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 Field added in v0.11.1

type Field interface {
	TypeCode() TypeCode
	TypeLength() (int64, bool)
	TypePrecisionScale() (int64, int64, bool)
	Nullable() bool
	In() bool
	Out() bool
	Name() string
	SetLobReader(rd io.Reader) error
	String() string
}

type FieldSet

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

FieldSet contains database field metadata.

func (*FieldSet) Field added in v0.11.1

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

Field returns the field at index idx.

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.

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 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(ctx context.Context, 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 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.

type TypeCode added in v0.11.1

type TypeCode byte

null value indicator is high bit

func (TypeCode) DataType added in v0.11.1

func (k TypeCode) DataType() DataType

func (TypeCode) String added in v0.11.1

func (i TypeCode) String() string

func (TypeCode) TypeName added in v0.11.1

func (k TypeCode) TypeName() string

TypeName returns the database type name. see https://golang.org/pkg/database/sql/driver/#RowsColumnTypeDatabaseTypeName

Jump to

Keyboard shortcuts

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