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 IsSupportedDfv(dfv int) bool
- func RegisterScanType(dt DataType, scanType reflect.Type) bool
- func SupportedDfvs(defaultOnly bool) []int
- type Auth
- type AuthCertKeySetter
- type AuthCookieGetter
- type AuthFailedError
- type AuthPasswordSetter
- type AuthTokenSetter
- 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) DBConnectInfo(databaseName string) (*hdb.DBConnectInfo, error)
- func (s *Session) DatabaseName() string
- func (s *Session) Disconnect() error
- func (s *Session) DropStatementID(id uint64) error
- func (s *Session) Exec(pr *PrepareResult, nvargs []driver.NamedValue, commit bool) (driver.Result, error)
- func (s *Session) ExecCall(pr *PrepareResult, nvargs []driver.NamedValue) (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, nvargs []driver.NamedValue, commit bool) (driver.Rows, error)
- func (s *Session) QueryCall(pr *PrepareResult, nvargs []driver.NamedValue) (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 SessionAttrs
- func (a *SessionAttrs) ApplicationName() string
- func (a *SessionAttrs) CESU8Decoder() func() transform.Transformer
- func (a *SessionAttrs) CESU8Encoder() func() transform.Transformer
- func (a *SessionAttrs) Clone() *SessionAttrs
- func (a *SessionAttrs) Dfv() int
- func (a *SessionAttrs) FetchSize() int
- func (a *SessionAttrs) Legacy() bool
- func (a *SessionAttrs) LobChunkSize() int
- func (a *SessionAttrs) Locale() string
- func (a *SessionAttrs) SessionVariables() map[string]string
- func (a *SessionAttrs) SetApplicationName(name string)
- func (a *SessionAttrs) SetCESU8Decoder(cesu8Decoder func() transform.Transformer)
- func (a *SessionAttrs) SetCESU8Encoder(cesu8Encoder func() transform.Transformer)
- func (a *SessionAttrs) SetDfv(dfv int)
- func (a *SessionAttrs) SetFetchSize(fetchSize int)
- func (a *SessionAttrs) SetLegacy(b bool)
- func (a *SessionAttrs) SetLobChunkSize(lobChunkSize int)
- func (a *SessionAttrs) SetLocale(locale string)
- func (a *SessionAttrs) SetSessionVariables(sessionVariables map[string]string)
- type Sniffer
- type WriterSetter
Constants ¶
const ( DfvLevel0 int = 0 // base data format DfvLevel1 int = 1 // eval types support all data types DfvLevel2 int = 2 // reserved, broken, do not use DfvLevel3 int = 3 // additional types Longdate, Secondate, Daydate, Secondtime supported for NGAP DfvLevel4 int = 4 // generic support for new date/time types DfvLevel5 int = 5 // spatial types in ODBC on request DfvLevel6 int = 6 // BINTEXT DfvLevel7 int = 7 // with boolean support DfvLevel8 int = 8 // with FIXED8/12/16 support )
Data format version values.
const MaxNumArg = math.MaxInt32
MaxNumArg is the maximum number of arguments allowed to send in a part.
Variables ¶
var ClientID string
ClientID holds the client ID of the driver's process and is set during go-hdb initialization to driver.clientID value.
var DriverVersion string
DriverVersion holds the version of the driver and is set during go-hdb initialization to driver.DriverVersion value.
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 IsSupportedDfv ¶ added in v0.107.0
IsSupportedDfv returns true if the data format version dfv is supported by the driver, false otherwise.
func RegisterScanType ¶
RegisterScanType registers driver owned datatype scantypes (e.g. Decimal, Lob).
func SupportedDfvs ¶ added in v0.107.0
SupportedDfvs returns a slice of data format versions supported by the driver. If parameter defaultOnly is set only the default dfv is returned, otherwise all supported dfv values are returned.
Types ¶
type Auth ¶ added in v0.107.0
type Auth struct {
// contains filtered or unexported fields
}
Auth holds the client authentication methods dependant on the driver.Connector attributes.
func (*Auth) AddSessionCookie ¶ added in v0.107.0
AddSessionCookie adds session cookie authentication method.
type AuthCertKeySetter ¶ added in v0.107.0
type AuthCertKeySetter interface {
SetCertKey(cert, key []byte)
}
AuthCertKeySetter is implemented by authentication methods supporting certificate and key updates.
type AuthCookieGetter ¶ added in v0.107.0
AuthCookieGetter is implemented by authentication methods supporting cookies to reconnect.
type AuthFailedError ¶ added in v0.107.0
type AuthFailedError struct {
// contains filtered or unexported fields
}
A AuthFailedError is returned if the last authorization step would fail with a hdb error 10 (authorization failed).
func (*AuthFailedError) Error ¶ added in v0.107.0
func (e *AuthFailedError) Error() string
func (*AuthFailedError) MethodType ¶ added in v0.107.0
func (e *AuthFailedError) MethodType() string
MethodType returns the authentication method type.
func (*AuthFailedError) Unwrap ¶ added in v0.107.0
func (e *AuthFailedError) Unwrap() error
Unwrap returns the nested error.
type AuthPasswordSetter ¶ added in v0.107.0
type AuthPasswordSetter interface {
SetPassword(string)
}
AuthPasswordSetter is implemented by authentication methods supporting password updates.
type AuthTokenSetter ¶ added in v0.107.0
type AuthTokenSetter interface {
SetToken(string)
}
AuthTokenSetter is implemented by authentication methods supporting token updates.
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, attrs *SessionAttrs, auth *Auth) (*Session, error)
NewSession creates a new database session.
func (*Session) CloseResultsetID ¶
CloseResultsetID releases the hdb resultset handle.
func (*Session) DBConnectInfo ¶ added in v0.105.2
func (s *Session) DBConnectInfo(databaseName string) (*hdb.DBConnectInfo, error)
DBConnectInfo provided hdb connection information.
func (*Session) DatabaseName ¶ added in v0.105.2
DatabaseName returns the database name.
func (*Session) Disconnect ¶
Disconnect disconnects the session.
func (*Session) DropStatementID ¶
DropStatementID releases the hdb statement handle.
func (*Session) Exec ¶
func (s *Session) Exec(pr *PrepareResult, nvargs []driver.NamedValue, 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, nvargs []driver.NamedValue) (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) Query ¶
func (s *Session) Query(pr *PrepareResult, nvargs []driver.NamedValue, commit bool) (driver.Rows, error)
Query executes a query.
func (*Session) QueryCall ¶
func (s *Session) QueryCall(pr *PrepareResult, nvargs []driver.NamedValue) (driver.Rows, error)
QueryCall executes a stored procecure (by Query).
func (*Session) QueryDirect ¶
QueryDirect executes a query without query parameters.
type SessionAttrs ¶ added in v0.107.0
type SessionAttrs struct {
// contains filtered or unexported fields
}
SessionAttrs represents the session relevant driver connector attributes.
func NewSessionAttrs ¶ added in v0.107.0
func NewSessionAttrs() *SessionAttrs
NewSessionAttrs returns a new SessionAttrs instance.
func (*SessionAttrs) ApplicationName ¶ added in v0.107.0
func (a *SessionAttrs) ApplicationName() string
ApplicationName returns the application name attribute.
func (*SessionAttrs) CESU8Decoder ¶ added in v0.107.0
func (a *SessionAttrs) CESU8Decoder() func() transform.Transformer
CESU8Decoder returns the CESU-8 decoder of the connector.
func (*SessionAttrs) CESU8Encoder ¶ added in v0.107.0
func (a *SessionAttrs) CESU8Encoder() func() transform.Transformer
CESU8Encoder returns the CESU-8 encoder of the connector.
func (*SessionAttrs) Clone ¶ added in v0.107.0
func (a *SessionAttrs) Clone() *SessionAttrs
Clone returns a clone of a SessionAttrs.
func (*SessionAttrs) Dfv ¶ added in v0.107.0
func (a *SessionAttrs) Dfv() int
Dfv returns the client data format version attribute.
func (*SessionAttrs) FetchSize ¶ added in v0.107.0
func (a *SessionAttrs) FetchSize() int
FetchSize returns the fetch size attribute.
func (*SessionAttrs) Legacy ¶ added in v0.107.0
func (a *SessionAttrs) Legacy() bool
Legacy returns the legacy attribute.
func (*SessionAttrs) LobChunkSize ¶ added in v0.107.0
func (a *SessionAttrs) LobChunkSize() int
LobChunkSize returns the lob chunk size attribute.
func (*SessionAttrs) Locale ¶ added in v0.107.0
func (a *SessionAttrs) Locale() string
Locale returns the locale attribute.
func (*SessionAttrs) SessionVariables ¶ added in v0.107.0
func (a *SessionAttrs) SessionVariables() map[string]string
SessionVariables returns the session variables attribute.
func (*SessionAttrs) SetApplicationName ¶ added in v0.107.0
func (a *SessionAttrs) SetApplicationName(name string)
SetApplicationName sets the application name attribute.
func (*SessionAttrs) SetCESU8Decoder ¶ added in v0.107.0
func (a *SessionAttrs) SetCESU8Decoder(cesu8Decoder func() transform.Transformer)
SetCESU8Decoder sets the CESU-8 decoder of the connector.
func (*SessionAttrs) SetCESU8Encoder ¶ added in v0.107.0
func (a *SessionAttrs) SetCESU8Encoder(cesu8Encoder func() transform.Transformer)
SetCESU8Encoder sets the CESU-8 encoder of the connector.
func (*SessionAttrs) SetDfv ¶ added in v0.107.0
func (a *SessionAttrs) SetDfv(dfv int)
SetDfv sets the client data format version attribute.
func (*SessionAttrs) SetFetchSize ¶ added in v0.107.0
func (a *SessionAttrs) SetFetchSize(fetchSize int)
SetFetchSize sets the fetch size attribute.
func (*SessionAttrs) SetLegacy ¶ added in v0.107.0
func (a *SessionAttrs) SetLegacy(b bool)
SetLegacy sets the connector legacy attribute.
func (*SessionAttrs) SetLobChunkSize ¶ added in v0.107.0
func (a *SessionAttrs) SetLobChunkSize(lobChunkSize int)
SetLobChunkSize sets the lob chunk size attribute.
func (*SessionAttrs) SetLocale ¶ added in v0.107.0
func (a *SessionAttrs) SetLocale(locale string)
SetLocale sets the locale attribute.
func (*SessionAttrs) SetSessionVariables ¶ added in v0.107.0
func (a *SessionAttrs) SetSessionVariables(sessionVariables map[string]string)
SetSessionVariables sets the session varibles attribute.
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 ¶
- auth.go
- auth1.18.go
- authjwt.go
- authscram.go
- authscrampbkdf2sha256.go
- authscramsha256.go
- authsessioncookie.go
- authtrace.go
- authx509.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
- dbconnectinfo.go
- dbconnectinfotype.go
- dbconnectinfotype_string.go
- dfv.go
- doc.go
- dvp_string.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
- message.go
- messagetype.go
- messagetype_string.go
- option.go
- parameter.go
- part.go
- partkind.go
- partkind_string.go
- parts.go
- protocol.go
- protocoltrace.go
- querydescr.go
- queryresultcache.go
- result.go
- rowsaffected.go
- segment.go
- segmentkind.go
- segmentkind_string.go
- session.go
- sessionattrs.go
- sessionattrs1.18.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