protocol

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2018 License: Apache-2.0 Imports: 24 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 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 ParameterField added in v0.11.3

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

ParameterField contains database field attributes for parameters.

func (*ParameterField) In added in v0.11.3

func (f *ParameterField) In() bool

In returns true if the parameter field is an input field.

func (*ParameterField) Name added in v0.11.3

func (f *ParameterField) Name() string

Name returns the parameter field name.

func (*ParameterField) Nullable added in v0.11.3

func (f *ParameterField) Nullable() bool

Nullable returns true if the field may be null, false otherwise. see https://golang.org/pkg/database/sql/driver/#RowsColumnTypeNullable

func (*ParameterField) Out added in v0.11.3

func (f *ParameterField) Out() bool

Out returns true if the parameter field is an output field.

func (*ParameterField) SetLobReader added in v0.11.3

func (f *ParameterField) SetLobReader(rd io.Reader) error

SetLobReader sets the io.Reader if a Lob parameter field.

func (*ParameterField) String added in v0.11.3

func (f *ParameterField) String() string

String implements the Stringer interface.

func (*ParameterField) TypeCode added in v0.11.3

func (f *ParameterField) TypeCode() TypeCode

TypeCode returns the type code of the field.

func (*ParameterField) TypeLength added in v0.11.3

func (f *ParameterField) TypeLength() (int64, bool)

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

func (*ParameterField) TypePrecisionScale added in v0.11.3

func (f *ParameterField) TypePrecisionScale() (int64, int64, bool)

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

type ParameterFieldSet added in v0.11.3

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

ParameterFieldSet contains database field metadata for parameters.

func (*ParameterFieldSet) Field added in v0.11.3

func (f *ParameterFieldSet) Field(idx int) *ParameterField

Field returns the field at index idx.

func (*ParameterFieldSet) NumInputField added in v0.11.3

func (f *ParameterFieldSet) NumInputField() int

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

func (*ParameterFieldSet) NumOutputField added in v0.11.3

func (f *ParameterFieldSet) NumOutputField() int

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

func (*ParameterFieldSet) OutputField added in v0.11.3

func (f *ParameterFieldSet) OutputField(idx int) *ParameterField

OutputField returns the output field at index idx.

func (*ParameterFieldSet) String added in v0.11.3

func (f *ParameterFieldSet) String() string

String implements the Stringer interface.

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 ResultField added in v0.11.3

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

ResultField contains database field attributes for result fields.

func (*ResultField) Name added in v0.11.3

func (f *ResultField) Name() string

Name returns the result field name.

func (*ResultField) Nullable added in v0.11.3

func (f *ResultField) Nullable() bool

Nullable returns true if the field may be null, false otherwise. see https://golang.org/pkg/database/sql/driver/#RowsColumnTypeNullable

func (*ResultField) String added in v0.11.3

func (f *ResultField) String() string

String implements the Stringer interface.

func (*ResultField) TypeCode added in v0.11.3

func (f *ResultField) TypeCode() TypeCode

TypeCode returns the type code of the field.

func (*ResultField) TypeLength added in v0.11.3

func (f *ResultField) TypeLength() (int64, bool)

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

func (*ResultField) TypePrecisionScale added in v0.11.3

func (f *ResultField) TypePrecisionScale() (int64, int64, bool)

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

type ResultFieldSet added in v0.11.3

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

ResultFieldSet contains database field metadata for result fields.

func (*ResultFieldSet) Field added in v0.11.3

func (f *ResultFieldSet) Field(idx int) *ResultField

Field returns the field at index idx.

func (*ResultFieldSet) NumField added in v0.11.3

func (f *ResultFieldSet) NumField() int

NumField returns the number of fields of a query.

func (*ResultFieldSet) String added in v0.11.3

func (f *ResultFieldSet) String() string

String implements the Stringer interface.

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 *ParameterFieldSet, args []driver.NamedValue) (*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, prmFieldSet *ParameterFieldSet, args []driver.NamedValue) (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 *ResultFieldSet, fieldValues *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

Prepare prepares a sql statement.

func (*Session) Query

func (s *Session) Query(stmtID uint64, prmFieldSet *ParameterFieldSet, resultFieldSet *ResultFieldSet, args []driver.NamedValue) (uint64, *FieldValues, PartAttributes, error)

Query executes a query.

func (*Session) QueryDirect

func (s *Session) QueryDirect(query string) (uint64, *ResultFieldSet, *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() *ResultFieldSet

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

TypeCode identify the type of a field transferred to or from the database.

func (TypeCode) DataType added in v0.11.1

func (k TypeCode) DataType() DataType

DataType converts a type code into one of the supported data types by the driver.

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