protocol

package
v0.105.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: Apache-2.0 Imports: 33 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

View Source
const (

	// MaxNumArg is the maximum number of arguments allowed to send in a part.
	MaxNumArg = math.MaxInt16
)

Variables

View Source
var ErrDecimalOutOfRange = errors.New("decimal out of range error")

ErrDecimalOutOfRange means that a big.Rat exceeds the size of hdb decimal fields.

View Source
var ErrFloatOutOfRange = errors.New("float out of range error")

ErrFloatOutOfRange means that a float exceeds the size of the hdb float field.

View Source
var ErrIntegerOutOfRange = errors.New("integer out of range error")

ErrIntegerOutOfRange means that an integer exceeds the size of the hdb integer field.

View Source
var ErrUint64OutOfRange = errors.New("uint64 values with high bit set are not supported")

ErrUint64OutOfRange means that a uint64 exceeds the size of a int64.

View Source
var QueryResultCache = newQueryResultCache()

QueryResultCache is a query result cache supporting reading procedure (call) table parameter via separate query (legacy mode).

Functions

func RegisterScanType

func RegisterScanType(dt DataType, scanType reflect.Type)

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.

func (DataType) ScanType

func (dt DataType) ScanType() reflect.Type

ScanType return the scan type (reflect.Type) of the corresponding data type.

func (DataType) String

func (i DataType) String() string

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.

const (
	QkUnknown QueryKind = iota
	QkCall
	QkSelect
	QkInsert
	QkUpdate
	QkUpsert
	QkCreate
	QkDrop
	QkSet
	QkID
)

Query kind constants.

func (QueryKind) String

func (k QueryKind) String() string

type ReadProvider

type ReadProvider interface {
	Reader() io.Reader
}

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

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) Disconnect

func (s *Session) Disconnect() error

Disconnect disconnects the session.

func (*Session) DropStatementID

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

DropStatementID releases the hdb statement handle.

func (*Session) Exec

func (s *Session) Exec(pr *PrepareResult, args []interface{}, commit bool) (driver.Result, error)

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

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

ExecDirect executes a sql statement without statement parameters.

func (*Session) HDBVersion

func (s *Session) HDBVersion() *hdb.Version

HDBVersion returns the hdb server version.

func (*Session) Prepare

func (s *Session) Prepare(query string) (*PrepareResult, error)

Prepare prepares a sql statement.

func (*Session) Query

func (s *Session) Query(pr *PrepareResult, args []interface{}, commit bool) (driver.Rows, error)

Query executes a query.

func (*Session) QueryCall

func (s *Session) QueryCall(pr *PrepareResult, args []interface{}) (driver.Rows, error)

QueryCall executes a stored procecure (by Query).

func (*Session) QueryDirect

func (s *Session) QueryDirect(query string, commit bool) (driver.Rows, error)

QueryDirect executes a query without query parameters.

func (*Session) Rollback

func (s *Session) Rollback() error

Rollback executes a database rollback.

func (*Session) SessionID

func (s *Session) SessionID() int64

SessionID returns the session id of the hdb connection.

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

func NewSniffer(conn net.Conn, dbConn net.Conn) *Sniffer

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) Do

func (s *Sniffer) Do() error

Do starts the protocol request and response logging.

type WriterSetter

type WriterSetter interface{ SetWriter(w io.Writer) error }

WriterSetter is the interface wrapping the SetWriter method (Lob handling).

Directories

Path Synopsis
Package encoding implements hdb field type en,- and decodings.
Package encoding implements hdb field type en,- and decodings.
Package scanner implements a HANA SQL query scanner.
Package scanner implements a HANA SQL query scanner.

Jump to

Keyboard shortcuts

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