tds

package
v0.0.0-...-b779cef Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: Apache-2.0 Imports: 26 Imported by: 4

Documentation

Overview

The package tds (Tabular Data Stream) is used to connect and communicate to a TDS server such as the ASE.

The communication between the client and server is abstracted using Connections (tds.Conn) and Channels (tds.Channel).

The Conn reads payloads from the server in a separate goroutine and routes them to their respective Channel.

The Channels provide two main methods to send and receive data: NextPackage to receive packages and QueuePackage to send packages.

A Package is a single type of information or instruction.

Communication:

Client				Server
SendPackage ->
	Package 1
	Package 2
	Package 3
				<- NextPackage
					Package 1
					Package 2
					Package 3
					Done
SendPackage ->
	Package 1

The client/server communication is half-duplex - a string of consecutive packages must be sent or received in full before a response or new request can be transmitted.

Index

Constants

View Source
const (
	TDS_MAXNAME   = 30
	TDS_NETBUF    = 4
	TDS_RPLEN     = 255
	TDS_VERSIZE   = 4
	TDS_PROGNLEN  = 10
	TDS_OLDSECURE = 2
	TDS_HA        = 6
	TDS_SECURE    = 2
	TDS_PKTLEN    = 6
	TDS_DUMMY     = 4
)

These constants define the maximum length for various options in a login payload.

View Source
const (
	// Size of a packet header.
	PacketHeaderSize = 8
)

Variables

View Source
var (
	ErrNoPackageReady = errors.New("no package ready")
	ErrChannelClosed  = errors.New("channel is closed")
)
View Source
var (
	ErrEOFAfterZeroRead = errors.New("received io.EOF after reading 0 bytes")
)
View Source
var ErrNotEnoughBytes = errors.New("not enough bytes in channel to parse package")

ErrNotEnoughBytes is returned by packages' ReadFrom if the BytesChannel does not have enough bytes to parse the package fully.

Functions

func IsDone

func IsDone(pkg Package) bool

IsDone returns true if the package terminates the stream.

func IsError

func IsError(pkg Package) bool

IsError returns true if the package signals an error - either in the communication or in the protocol.

func LookupFieldFmtData

func LookupFieldFmtData(dataType asetypes.DataType) (FieldFmt, FieldData, error)

LookupFieldFmtData returns both a FieldFmt and a FieldData for a given data type.

func SetInfo

func SetInfo(info *Info) error

Types

type BigDateTimeNFieldData

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

func (*BigDateTimeNFieldData) ReadFrom

func (field *BigDateTimeNFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (BigDateTimeNFieldData) WriteTo

func (field BigDateTimeNFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type BigDateTimeNFieldFmt

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

func (BigDateTimeNFieldFmt) FormatByteLength

func (field BigDateTimeNFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*BigDateTimeNFieldFmt) ReadFrom

func (field *BigDateTimeNFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (BigDateTimeNFieldFmt) WriteTo

func (field BigDateTimeNFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type BigTimeNFieldData

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

func (*BigTimeNFieldData) ReadFrom

func (field *BigTimeNFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (BigTimeNFieldData) WriteTo

func (field BigTimeNFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type BigTimeNFieldFmt

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

func (BigTimeNFieldFmt) FormatByteLength

func (field BigTimeNFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*BigTimeNFieldFmt) ReadFrom

func (field *BigTimeNFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (BigTimeNFieldFmt) WriteTo

func (field BigTimeNFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type BinaryFieldData

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

func (*BinaryFieldData) ReadFrom

func (field *BinaryFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (BinaryFieldData) WriteTo

func (field BinaryFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type BinaryFieldFmt

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

func (BinaryFieldFmt) FormatByteLength

func (field BinaryFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*BinaryFieldFmt) ReadFrom

func (field *BinaryFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (BinaryFieldFmt) WriteTo

func (field BinaryFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type BitFieldData

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

func (*BitFieldData) ReadFrom

func (field *BitFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (BitFieldData) WriteTo

func (field BitFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type BitFieldFmt

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

func (BitFieldFmt) FormatByteLength

func (field BitFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*BitFieldFmt) ReadFrom

func (field *BitFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (BitFieldFmt) WriteTo

func (field BitFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type BlobFieldData

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

func (*BlobFieldData) ReadFrom

func (field *BlobFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (BlobFieldData) WriteTo

func (field BlobFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type BlobFieldFmt

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

func (BlobFieldFmt) FormatByteLength

func (field BlobFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*BlobFieldFmt) ReadFrom

func (field *BlobFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (BlobFieldFmt) WriteTo

func (field BlobFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type BlobSerializationType

type BlobSerializationType uint8

BlobSerializationType defines the seralization type of a data blob.

const (
	NativeJavaSerialization BlobSerializationType = iota
	NativeCharacterFormat
	BinaryData
	UnicharUTF16
	UnicharUTF8
	UnicharSCSU
)

func (BlobSerializationType) String

func (i BlobSerializationType) String() string

type BlobType

type BlobType uint8

BlobType defines the type of a data blob.

const (
	TDS_BLOB_FULLCLASSNAME BlobType = iota + 1
	TDS_BLOB_DBID_CLASSDEF
	TDS_BLOB_CHAR
	TDS_BLOB_BINARY
	TDS_BLOB_UNICHAR
	TDS_LOBLOC_CHAR
	TDS_LOBLOC_BINARY
	TDS_LOBLOC_UNICHAR
)

func (BlobType) String

func (i BlobType) String() string

type BoundaryFieldData

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

func (*BoundaryFieldData) ReadFrom

func (field *BoundaryFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (BoundaryFieldData) WriteTo

func (field BoundaryFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type BoundaryFieldFmt

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

func (BoundaryFieldFmt) FormatByteLength

func (field BoundaryFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*BoundaryFieldFmt) ReadFrom

func (field *BoundaryFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (BoundaryFieldFmt) WriteTo

func (field BoundaryFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type BytesChannel

type BytesChannel interface {
	// Position marks the index of the packet and index of the byte the
	// channel currently is at.
	// The position is considered volatile and only valid until the next
	// call to DiscardUntilPosition.
	Position() (int, int)
	SetPosition(int, int)
	DiscardUntilCurrentPosition()

	io.Reader
	io.Writer

	Bytes(n int) ([]byte, error)
	WriteBytes([]byte) error

	Byte() (byte, error)
	WriteByte(byte) error

	Uint8() (uint8, error)
	WriteUint8(uint8) error

	Int8() (int8, error)
	WriteInt8(int8) error

	Uint16() (uint16, error)
	WriteUint16(uint16) error

	Int16() (int16, error)
	WriteInt16(int16) error

	Uint32() (uint32, error)
	WriteUint32(uint32) error

	Int32() (int32, error)
	WriteInt32(int32) error

	Uint64() (uint64, error)
	WriteUint64(uint64) error

	Int64() (int64, error)
	WriteInt64(int64) error

	String(int) (string, error)
	WriteString(string) error
}

BytesChannel defines the required methods for Packages to read and write information to a stream.

type CapabilityPackage

type CapabilityPackage struct {
	Capabilities map[CapabilityType]*valueMask
}

CapabilityPackage is used to communicate capabilities between clients and servers.

func NewCapabilityPackage

func NewCapabilityPackage(request []RequestCapability, response []ResponseCapability,
	security []SecurityCapability) (*CapabilityPackage, error)

NewCapabilityPackage returns a prepared CapabilityPackage.

func (*CapabilityPackage) HasCapability

func (pkg *CapabilityPackage) HasCapability(capabilityType CapabilityType, capability int) bool

HasCapability returns whether the package has the requested capability.

func (*CapabilityPackage) HasRequestCapability

func (pkg *CapabilityPackage) HasRequestCapability(capability RequestCapability) bool

HasRequestCapability returns whether the package has the requested request capability.

func (*CapabilityPackage) HasResponseCapability

func (pkg *CapabilityPackage) HasResponseCapability(capability ResponseCapability) bool

HasResponseCapabilities returns whether the package has the requested response capability.

func (*CapabilityPackage) HasSecurityCapability

func (pkg *CapabilityPackage) HasSecurityCapability(capability SecurityCapability) bool

HasSecurityCapabilities returns whether the package has the requested security capability.

func (*CapabilityPackage) ReadFrom

func (pkg *CapabilityPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (*CapabilityPackage) SetRequestCapability

func (pkg *CapabilityPackage) SetRequestCapability(capability RequestCapability, enable bool) error

SetRequestCapability sets the requested capability.

func (*CapabilityPackage) SetResponseCapability

func (pkg *CapabilityPackage) SetResponseCapability(capability ResponseCapability, enable bool) error

SetResponseCapability sets the response capability.

func (*CapabilityPackage) SetSecurityCapability

func (pkg *CapabilityPackage) SetSecurityCapability(capability SecurityCapability, enable bool) error

SetSecurityCapability sets the security capability.

func (CapabilityPackage) String

func (pkg CapabilityPackage) String() string

func (CapabilityPackage) WriteTo

func (pkg CapabilityPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type CapabilityType

type CapabilityType byte

CapabilityType is the type of capabilities.

const (
	CapabilityRequest CapabilityType = iota + 1
	CapabilityResponse
	CapabilitySecurity
)

Types of capabilities.

func (CapabilityType) String

func (i CapabilityType) String() string

type Channel

type Channel struct {

	// The RWMutex isn't used in its intended form of reader/writer
	// locks but rather allows multiple goroutines to acquire
	// a read-lock to use the channel for sending/receiving packages.
	//
	// The exclusive write lock is used to stop other goroutines from
	// using the channel when closing it.
	sync.RWMutex

	// CurrentHeaderType is the PacketHeaderType set on outgoing
	// packets.
	CurrentHeaderType PacketHeaderType
	// contains filtered or unexported fields
}

Channel is a channel in a multiplexed connection with a TDS server.

func (*Channel) Close

func (tdsChan *Channel) Close() error

Close communicates the termination of the channel with the TDS server.

The teardown on client side is guaranteed, even if Close returns an error. An error is only returned if the communication with the server fails or if packages or error remained in the channels.

If an error is returned it is a *multierror.Error with all errors.

func (*Channel) Login

func (tdsChan *Channel) Login(ctx context.Context, config *LoginConfig) error

Login performs the login negotiation with the TDS server.

func (*Channel) Logout

func (tdsChan *Channel) Logout() error

Logout performs the logout sequence.

func (*Channel) NextPackage

func (tdsChan *Channel) NextPackage(ctx context.Context, wait bool) (Package, error)

NextPackage returns the next package in the queue. An error may be returned in the following cases:

  1. The connections' context was closed.
  2. The connection has a communication error queued.
  3. The channel has a parsing error queued.

If wait is false a ErrNoPackageReady error may be returned.

If multiple errors and a package are ready a random error or package will be returned, as stated in the spec for select.

func (*Channel) NextPackageUntil

func (tdsChan *Channel) NextPackageUntil(ctx context.Context, wait bool, processPkg func(Package) (bool, error)) (Package, error)

NextPackageUntil calls NextPackage until the passed function processPkg returns true.

If processPkg returns true no further packages will be consumed, so the communication handling can be passed to another function.

If processPkg returns an error that is not an unwrapped io.EOF all packages in the payload will be consumed and an error containing all EEDPackages in the payload will be returned. io.EOF is handled differently to allow to handle multiple result sets in rows-like structs.

If processPkg is nil all packages in the current payload are consumed and no package and an io.EOF error is returned. The io.EOF is wrapped with an EEDError with all EEDPackages in the payload if the payload contained any EEDPackages.

To just consume all packages a consumer can return any error aside from an unwrapped io.EOF in processPkg and check if the error is not of this error:

_, err := ...NextPackageUntil(ctx, wait, func(pkg tds.Package) (bool, error) {
    switch pkg.(type) {
    case ...
        // handle communication
    case ...
        // handle final communication
        return true, DefinedError
    }
}
if err != nil && !errors.Is(err, DefinedError) {
    // error handling
}

func (*Channel) QueuePackage

func (tdsChan *Channel) QueuePackage(ctx context.Context, pkg Package) error

QueuePackages queues a package for transmission.

func (*Channel) RegisterEEDHooks

func (tdsChan *Channel) RegisterEEDHooks(fns ...EEDHook) error

RegisterEEDHooks registers a function to be called when the TDS server sends an EEDPackage.

The registered functions are called with the full EEDPackage.

Note that all registered hooks are called in sequence of being registered. Hooks with a longer run time or waiting on locks should utilize goroutines or use other means to prevent blocking other hooks.

func (*Channel) RegisterEnvChangeHooks

func (tdsChan *Channel) RegisterEnvChangeHooks(fns ...EnvChangeHook) error

RegisterEnvChangeHook registers a function to be called when the TDS server sends a TDS_ENVCHNAGE token.

The registered functions are called with the EnvChangeType of the update, the old value and the new value. The old value may be empty.

The functions should be registered _before_ calling `.Login` as env changes happen at the end of the login negotiation.

Note that all registered hooks are called in sequence of being registered. Hooks with a longer run time or waiting on locks should utilize goroutines or use other means to prevent blocking other hooks.

func (*Channel) Reset

func (tdsChan *Channel) Reset()

Reset resets the Channel after a communication has been completed.

func (*Channel) SendPackage

func (tdsChan *Channel) SendPackage(ctx context.Context, pkg Package) error

SendPackage combines calls to QueuePackage and SendRemainingPackets and can be used if e.g. the last package or only a single package must be sent.

func (*Channel) SendRemainingPackets

func (tdsChan *Channel) SendRemainingPackets(ctx context.Context) error

Send all remaining Packets in queue to the server. This includes Packets whose Data isn't exhausted.

func (*Channel) SetLastPkgRx

func (tdsChan *Channel) SetLastPkgRx(pkg Package)

func (*Channel) SetLastPkgTx

func (tdsChan *Channel) SetLastPkgTx(pkg Package)

func (*Channel) WritePacket

func (tdsChan *Channel) WritePacket(packet *Packet)

WritePacket receives packets from the associated Conn and attempts to produce Packages from the existing data.

type CharFieldData

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

func (*CharFieldData) ReadFrom

func (field *CharFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (CharFieldData) WriteTo

func (field CharFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type CharFieldFmt

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

func (CharFieldFmt) FormatByteLength

func (field CharFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*CharFieldFmt) ReadFrom

func (field *CharFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (CharFieldFmt) WriteTo

func (field CharFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type Conn

type Conn struct {
	Caps *CapabilityPackage
	// contains filtered or unexported fields
}

Conn handles a TDS-based connection.

Note: This is not the underlying structure for driver.Conn - that is Channel.

func NewConn

func NewConn(ctx context.Context, info *Info) (*Conn, error)

Dial returns a prepared and dialed Conn.

A new child context will be created from the passed context and used to abort any interaction with the server - hence closing the parent context will abort all interaction with the server.

func (*Conn) Close

func (tds *Conn) Close() error

Close closes a Conn and its unclosed Channels.

Teardown and closing on the client side is guaranteed, even if Close returns an error. An error is only returned if the communication with the server fails or if channels report errors during closing.

If an error is returned it is a *multierror.Error with all errors.

func (*Conn) NewChannel

func (tds *Conn) NewChannel() (*Channel, error)

NewChannel communicates the creation of a new channel with the server.

func (*Conn) PacketBodySize

func (tds *Conn) PacketBodySize() int

PacketBodySize returns the negotiated packet size minus the packet header size.

func (*Conn) PacketSize

func (tds *Conn) PacketSize() int

PacketSize returns the negotiated packet size.

func (*Conn) ReadFrom

func (tds *Conn) ReadFrom()

ReadFrom creates packets from payloads from the server and writes them to the corresponding Channel.

type ControlPackage

type ControlPackage struct {
}

func (*ControlPackage) ReadFrom

func (pkg *ControlPackage) ReadFrom(ch BytesChannel) error

func (ControlPackage) String

func (pkg ControlPackage) String() string

func (ControlPackage) WriteTo

func (pkg ControlPackage) WriteTo(ch BytesChannel) error

type CurClosePackage

type CurClosePackage struct {
	CursorID int32
	Name     string

	Options CursorCloseOption
}

CurClosePackage is used to close a cursor.

func (*CurClosePackage) ReadFrom

func (pkg *CurClosePackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (CurClosePackage) String

func (pkg CurClosePackage) String() string

func (CurClosePackage) WriteTo

func (pkg CurClosePackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type CurDeclarePackage

type CurDeclarePackage struct {
	Name    string
	Options CursorOption
	Status  CursorDStatus
	Stmt    string
	// contains filtered or unexported fields
}

CurDeclarePackage is used to declare cursors.

func NewCurDeclarePackage

func NewCurDeclarePackage(name, stmt string, status CursorDStatus, options CursorOption) (*CurDeclarePackage, error)

NewCurDeclarePackage takes all required values and returns a CurDeclarePackage with the required values and sensible defaults.

TODO: An error is only returned if ...

func (*CurDeclarePackage) ReadFrom

func (pkg *CurDeclarePackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (CurDeclarePackage) String

func (pkg CurDeclarePackage) String() string

func (CurDeclarePackage) WriteTo

func (pkg CurDeclarePackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type CurDeletePackage

type CurDeletePackage struct {
	CursorID int32
	Name     string

	Status    CursorDeleteStatus
	TableName string
}

CurDeletePackage is used to deallocate a cursor.

func (*CurDeletePackage) ReadFrom

func (pkg *CurDeletePackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (CurDeletePackage) String

func (pkg CurDeletePackage) String() string

func (CurDeletePackage) WriteTo

func (pkg CurDeletePackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type CurFetchPackage

type CurFetchPackage struct {
	CursorID int32
	Name     string

	Type      CursorFetchType
	RowNumber int32
}

CurFetchPackage is used to fetch more rows from a cursor.

func (*CurFetchPackage) ReadFrom

func (pkg *CurFetchPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (CurFetchPackage) String

func (pkg CurFetchPackage) String() string

func (CurFetchPackage) WriteTo

func (pkg CurFetchPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type CurInfoPackage

type CurInfoPackage struct {
	CursorID int32
	Name     string

	Command CursorCommand
	Status  CursorIStatus

	RowNum    int32
	TotalRows int32
	RowCount  int32
	// contains filtered or unexported fields
}

CurInfoPackage is used to send and receive information about a cursor.

func (*CurInfoPackage) ReadFrom

func (pkg *CurInfoPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (CurInfoPackage) String

func (pkg CurInfoPackage) String() string

func (CurInfoPackage) WriteTo

func (pkg CurInfoPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type CurOpenPackage

type CurOpenPackage struct {
	CursorID int32
	Name     string
	Status   CursorOStatus
}

CurOpenPackage is used to open a declared cursor.

func (*CurOpenPackage) ReadFrom

func (pkg *CurOpenPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (CurOpenPackage) String

func (pkg CurOpenPackage) String() string

func (CurOpenPackage) WriteTo

func (pkg CurOpenPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type CurUpdatePackage

type CurUpdatePackage struct {
	CursorID int32
	Name     string

	Status    CursorOStatus
	TableName string
	Stmt      string
}

CurUpdatePackage is used to update a cursor.

func (*CurUpdatePackage) ReadFrom

func (pkg *CurUpdatePackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (CurUpdatePackage) String

func (pkg CurUpdatePackage) String() string

func (CurUpdatePackage) WriteTo

func (pkg CurUpdatePackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type CursorCloseOption

type CursorCloseOption uint

CursorCloseOption is the type of values for CurClose packages.

const (
	TDS_CUR_COPT_UNUSED  CursorCloseOption = 0x0
	TDS_CUR_COPT_DEALLOC CursorCloseOption = 0x1
)

func (CursorCloseOption) String

func (i CursorCloseOption) String() string

type CursorCommand

type CursorCommand uint

CursorCommand is the type used to send commands on cursors.

const (
	TDS_CUR_CMD_SETCURROWS CursorCommand = iota + 1
	TDS_CUR_CMD_INQUIRE
	TDS_CUR_CMD_INFORM
	TDS_CUR_CMD_LISTALL
)

func (CursorCommand) String

func (i CursorCommand) String() string

type CursorDStatus

type CursorDStatus uint

CursorDStatus is the type to indicate the status of a cursor when declaring it.

const (
	TDS_CUR_DSTAT_UNUSED  CursorDStatus = 0x0
	TDS_CUR_DSTAT_HASARGS CursorDStatus = 0x1
)

func (CursorDStatus) String

func (i CursorDStatus) String() string

type CursorDeleteStatus

type CursorDeleteStatus uint

CursorDeleteStatus is the type for a currently unused bitmask.

const (
	TDS_CUR_DELSTAT_UNUSED CursorDeleteStatus = iota
)

func (CursorDeleteStatus) String

func (i CursorDeleteStatus) String() string

type CursorFetchType

type CursorFetchType uint

CursorFetchType is the type to indicate in which direction to fetch cursor results.

const (
	TDS_CUR_NEXT CursorFetchType = iota + 1
	TDS_CUR_PREV
	TDS_CUR_FIRST
	TDS_CUR_LAST
	TDS_CUR_ABS
	TDS_CUR_REL
)

func (CursorFetchType) String

func (i CursorFetchType) String() string

type CursorIStatus

type CursorIStatus uint

CursorIStatus is the type for a bitmask indicating the status of a cursor.

const (
	TDS_CUR_ISTAT_UNUSED          CursorIStatus = 0x0
	TDS_CUR_ISTAT_DECLARED        CursorIStatus = 0x1
	TDS_CUR_ISTAT_OPEN            CursorIStatus = 0x2
	TDS_CUR_ISTAT_CLOSED          CursorIStatus = 0x4
	TDS_CUR_ISTAT_RDONLY          CursorIStatus = 0x8
	TDS_CUR_ISTAT_UPDATABLE       CursorIStatus = 0x10
	TDS_CUR_ISTAT_ROWCNT          CursorIStatus = 0x20
	TDS_CUR_ISTAT_DEALLOC         CursorIStatus = 0x40
	TDS_CUR_ISTAT_SCROLLABLE      CursorIStatus = 0x80
	TDS_CUR_ISTAT_IMPLICIT        CursorIStatus = 0x100
	TDS_CUR_ISTAT_SENSITIVE       CursorIStatus = 0x200
	TDS_CUR_ISTAT_INSENSITIVE     CursorIStatus = 0x400
	TDS_CUR_ISTAT_SEMISENSITIVE   CursorIStatus = 0x800
	TDS_CUR_ISTAT_KEYSETDRIVEN    CursorIStatus = 0x1000
	TDS_CUR_ISTAT_RELLOCKSONCLOSE CursorIStatus = 0x2000
)

func (CursorIStatus) String

func (i CursorIStatus) String() string

type CursorOStatus

type CursorOStatus uint

CursorOStatus is the type for a value indicating the status of a cursor when opening it.

const (
	TDS_CUR_OSTAT_UNUSED CursorOStatus = iota
	TDS_CUR_OSTAT_HASARGS
	TDS_CUR_CONSEC_UPDS
)

func (CursorOStatus) String

func (i CursorOStatus) String() string

type CursorOption

type CursorOption uint

CursorOption is a bitmask to indicate options for a cursor.

const (
	TDS_CUR_DOPT_UNUSED          CursorOption = 0x0
	TDS_CUR_DOPT_RDONLY          CursorOption = 0x1
	TDS_CUR_DOPT_UPDATABLE       CursorOption = 0x2
	TDS_CUR_DOPT_SENSITIVE       CursorOption = 0x4
	TDS_CUR_DOPT_DYNAMIC         CursorOption = 0x8
	TDS_CUR_DOPT_IMPLICIT        CursorOption = 0x10
	TDS_CUR_DOPT_INSENSITIVE     CursorOption = 0x20
	TDS_CUR_DOPT_SEMISENSITIVE   CursorOption = 0x40
	TDS_CUR_DOPT_KEYSETDRIVEN    CursorOption = 0x80
	TDS_CUR_DOPT_SCROLLABLE      CursorOption = 0x100
	TDS_CUR_DOPT_RELLOCKSONCLOSE CursorOption = 0x200
)

func (CursorOption) String

func (i CursorOption) String() string

type DataStatus

type DataStatus uint

DataStatus defines the valid states of data in fields.

const (
	TDS_DATA_NONNULL           DataStatus = 0x0
	TDS_DATA_NULL              DataStatus = 0x1
	TDS_DATA_ZEROLENGTHNONNULL DataStatus = 0x2
	TDS_DATA_RESERVED          DataStatus = 0xfc
)

type DateFieldData

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

func (*DateFieldData) ReadFrom

func (field *DateFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (DateFieldData) WriteTo

func (field DateFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type DateFieldFmt

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

func (DateFieldFmt) FormatByteLength

func (field DateFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*DateFieldFmt) ReadFrom

func (field *DateFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (DateFieldFmt) WriteTo

func (field DateFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type DateNFieldData

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

func (*DateNFieldData) ReadFrom

func (field *DateNFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (DateNFieldData) WriteTo

func (field DateNFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type DateNFieldFmt

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

func (DateNFieldFmt) FormatByteLength

func (field DateNFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*DateNFieldFmt) ReadFrom

func (field *DateNFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (DateNFieldFmt) WriteTo

func (field DateNFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type DateTimeFieldData

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

func (*DateTimeFieldData) ReadFrom

func (field *DateTimeFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (DateTimeFieldData) WriteTo

func (field DateTimeFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type DateTimeFieldFmt

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

func (DateTimeFieldFmt) FormatByteLength

func (field DateTimeFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*DateTimeFieldFmt) ReadFrom

func (field *DateTimeFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (DateTimeFieldFmt) WriteTo

func (field DateTimeFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type DateTimeNFieldData

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

func (*DateTimeNFieldData) ReadFrom

func (field *DateTimeNFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (DateTimeNFieldData) WriteTo

func (field DateTimeNFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type DateTimeNFieldFmt

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

func (DateTimeNFieldFmt) FormatByteLength

func (field DateTimeNFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*DateTimeNFieldFmt) ReadFrom

func (field *DateTimeNFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (DateTimeNFieldFmt) WriteTo

func (field DateTimeNFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type DecNFieldData

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

func (*DecNFieldData) ReadFrom

func (field *DecNFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

type DecNFieldFmt

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

func (DecNFieldFmt) FormatByteLength

func (field DecNFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*DecNFieldFmt) ReadFrom

func (field *DecNFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (DecNFieldFmt) WriteTo

func (field DecNFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type DoneInProcPackage

type DoneInProcPackage = DonePackage

type DonePackage

type DonePackage struct {
	Status    DoneState
	TranState TransState
	Count     int32
}

DonePackage is used to finalize a package stream.

func (*DonePackage) ReadFrom

func (pkg *DonePackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (DonePackage) String

func (pkg DonePackage) String() string

String implements the fmt.Stringer interface.

func (DonePackage) WriteTo

func (pkg DonePackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type DoneProcPackage

type DoneProcPackage = DonePackage

type DoneState

type DoneState uint16

DoneState is the type for bitmask values of a done-package state.

const (
	TDS_DONE_FINAL      DoneState = 0x0
	TDS_DONE_MORE       DoneState = 0x1
	TDS_DONE_ERROR      DoneState = 0x2
	TDS_DONE_INXACT     DoneState = 0x4
	TDS_DONE_PROC       DoneState = 0x8
	TDS_DONE_COUNT      DoneState = 0x10
	TDS_DONE_ATTN       DoneState = 0x20
	TDS_DONE_EVENT      DoneState = 0x40
	TDS_DONE_CUMULATIVE DoneState = 0x80
)

States of a done-package.

func (DoneState) String

func (i DoneState) String() string

type DynamicOperationType

type DynamicOperationType byte

DynamicOperationType is a bitmask to indicate the options of a dynamic SQL statement.

const (
	TDS_DYN_INVALID    DynamicOperationType = 0x00
	TDS_DYN_PREPARE    DynamicOperationType = 0x01
	TDS_DYN_EXEC       DynamicOperationType = 0x02
	TDS_DYN_DEALLOC    DynamicOperationType = 0x04
	TDS_DYN_EXEC_IMMED DynamicOperationType = 0x08
	TDS_DYN_PROCNAME   DynamicOperationType = 0x10
	TDS_DYN_ACK        DynamicOperationType = 0x20
	TDS_DYN_DESCIN     DynamicOperationType = 0x40
	TDS_DYN_DESCOUT    DynamicOperationType = 0x80
)

Types of a dynamic-operation-package.

func (DynamicOperationType) String

func (i DynamicOperationType) String() string

type DynamicPackage

type DynamicPackage struct {
	Type   DynamicOperationType
	Status DynamicStatusType
	ID     string
	Stmt   string
	// contains filtered or unexported fields
}

DynamicPackage is used to allocate and deallocate as well as request information on a dynamic SQL statement.

func NewDynamicPackage

func NewDynamicPackage(wide bool) *DynamicPackage

NewDynamicPackage returns a dynamic package.

func (*DynamicPackage) ReadFrom

func (pkg *DynamicPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (DynamicPackage) String

func (pkg DynamicPackage) String() string

func (*DynamicPackage) WriteTo

func (pkg *DynamicPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type DynamicStatusType

type DynamicStatusType byte

DynamicStatusType is a bitmask indicating the status of a dynamic SQL statement.

const (
	TDS_DYNAMIC_UNUSED            DynamicStatusType = 0x0
	TDS_DYNAMIC_HASARGS           DynamicStatusType = 0x1
	TDS_DYNAMIC_SUPPRESS_FMT      DynamicStatusType = 0x2
	TDS_DYNAMIC_BATCH_PARAMS      DynamicStatusType = 0x4
	TDS_DYNAMIC_SUPPRESS_PARAMFMT DynamicStatusType = 0x8
)

Types of a dynamic-status-package.

func (DynamicStatusType) String

func (i DynamicStatusType) String() string

type EEDError

type EEDError struct {
	EEDPackages  []*EEDPackage
	WrappedError error
}

EEDError contains the extended error data packages and the wrapped error.

func (*EEDError) Add

func (err *EEDError) Add(eed *EEDPackage)

Add adds an EED-package to an err.EEDPackages.

func (EEDError) Error

func (err EEDError) Error() string

Error returns the string representation of EEDPackages.

func (EEDError) Is

func (err EEDError) Is(other error) bool

Is reports whether any wrapped EEDError in errs chain matches other.

type EEDHook

type EEDHook func(eedPackage EEDPackage)

EEDHook defines the signature of functions called by a Conn when the server sends an EEDPackage.

type EEDPackage

type EEDPackage struct {
	MsgNumber  uint32
	State      uint8
	Class      uint8
	SQLState   []byte
	Status     EEDStatus
	TranState  uint16
	Msg        string
	ServerName string
	ProcName   string
	LineNr     uint16
}

EEDPackage is used to communicate information and error messages.

func (*EEDPackage) ReadFrom

func (pkg *EEDPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (EEDPackage) String

func (pkg EEDPackage) String() string

func (EEDPackage) WriteTo

func (pkg EEDPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type EEDStatus

type EEDStatus uint8

EEDStatus is used to indicate the status of an EED package.

const (
	TDS_NO_EED      EEDStatus = 0x00
	TDS_EED_FOLLOWS EEDStatus = 0x1
	TDS_EED_INFO    EEDStatus = 0x2
)

func (EEDStatus) String

func (i EEDStatus) String() string

type EnvChangeHook

type EnvChangeHook func(typ EnvChangeType, oldValue, newValue string)

EnvChangeHook defines the signature of functions called by a Conn when the server sends a TDS_ENV_CHANGE package.

type EnvChangePackage

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

EnvChangePackage is used to communicate multiple environment changes.

func (*EnvChangePackage) ReadFrom

func (pkg *EnvChangePackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (EnvChangePackage) String

func (pkg EnvChangePackage) String() string

func (EnvChangePackage) WriteTo

func (pkg EnvChangePackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type EnvChangePackageField

type EnvChangePackageField struct {
	Type               EnvChangeType
	NewValue, OldValue string
}

EnvChangePackageField is a single environment change.

func (EnvChangePackageField) ByteLength

func (field EnvChangePackageField) ByteLength() int

ByteLength returns the length in bytes.

func (*EnvChangePackageField) ReadFrom

func (field *EnvChangePackageField) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.Package interface.

func (EnvChangePackageField) WriteTo

func (field EnvChangePackageField) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.Package interface.

type EnvChangeType

type EnvChangeType uint8

EnvChangeType signals which part of the environment was updated.

const (
	TDS_ENV_DB EnvChangeType = iota + 1
	TDS_ENV_LANG
	TDS_ENV_CHARSET
	TDS_ENV_PACKSIZE
)

func (EnvChangeType) String

func (i EnvChangeType) String() string

type ErrorPackage

type ErrorPackage struct {
	ErrorNumber int32
	State       uint8
	Class       uint8
	ErrorMsg    string
	ServerName  string
	ProcName    string
	LineNr      uint16
}

ErrorPackage is a deprecated package used to communicate errors.

func (*ErrorPackage) ReadFrom

func (pkg *ErrorPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (ErrorPackage) String

func (pkg ErrorPackage) String() string

func (ErrorPackage) WriteTo

func (pkg ErrorPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type FieldData

type FieldData interface {
	// Format information send by TDS server
	Status() DataStatus

	// Interface methods for go-ase
	Format() FieldFmt

	// ReadFrom reads bytes from the passed channel until either the
	// channel is closed or the package has all required information.
	// The read bytes are usually stored in fieldData* structs.
	ReadFrom(BytesChannel) (int, error)
	// WriteTo writes bytes to the passed channel until either the
	// channel is closed or the package has written all required
	// information. The information are usually based on fieldData*
	// structs.
	WriteTo(BytesChannel) (int, error)

	Value() interface{}
	SetValue(interface{})
	// contains filtered or unexported methods
}

FieldData defines the interface for datatype data.

func LookupFieldData

func LookupFieldData(fieldFmt FieldFmt) (FieldData, error)

LookupFieldData returns the FieldData for a given field format.

type FieldFmt

type FieldFmt interface {
	// Format information as sent to or received from TDS server
	DataType() asetypes.DataType
	SetDataType(asetypes.DataType)
	SetName(string)
	Name() string

	// specific to TDS_ROWFMT2
	SetColumnLabel(string)
	ColumnLabel() string
	SetCatalogue(string)
	Catalogue() string
	SetSchema(string)
	Schema() string
	SetTable(string)
	Table() string

	SetStatus(uint)
	Status() uint

	SetUserType(int32)
	UserType() int32
	SetLocaleInfo(string)
	LocaleInfo() string

	// Returns true if the data type has a fixed length.
	IsFixedLength() bool
	// The return value of LengthBytes depends on IsFixedLength.
	// If the data type has a fixed length LengthBytes returns the
	// total number of bytes of the data portion (not the entire data
	// field - only the actual data).
	// If the data type has a variable length LengthBytes returns the
	// number of bytes to be read from the data stream for the length in
	// bytes of the data portion.
	LengthBytes() int
	// Length returns the maximum length of the column
	// TODO: is this actually required when sending from client?
	MaxLength() int64

	// DisplayMaxLength returns a best guess of the maximum length
	// required to display the values of this column.
	DisplayMaxLength() int64

	// ReadFrom reads bytes from the passed channel until either the
	// channel is closed or the package has all required information.
	// The read bytes are usually stored in fieldFmt* structs.
	ReadFrom(BytesChannel) (int, error)
	// WriteTo writes bytes to the passed channel until either the
	// channel is closed or the package has written all required
	// information. The information are usually based on fieldFmt*
	// structs.
	WriteTo(BytesChannel) (int, error)

	FormatByteLength() int
	// contains filtered or unexported methods
}

FieldFmt defines the interface for datatype formats.

func LookupFieldFmt

func LookupFieldFmt(dataType asetypes.DataType) (FieldFmt, error)

LookupFieldFmt returns the FieldFmt for a given data type and sets required values in it.

type Flt4FieldData

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

func (*Flt4FieldData) ReadFrom

func (field *Flt4FieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (Flt4FieldData) WriteTo

func (field Flt4FieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type Flt4FieldFmt

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

func (Flt4FieldFmt) FormatByteLength

func (field Flt4FieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*Flt4FieldFmt) ReadFrom

func (field *Flt4FieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (Flt4FieldFmt) WriteTo

func (field Flt4FieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type Flt8FieldData

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

func (*Flt8FieldData) ReadFrom

func (field *Flt8FieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (Flt8FieldData) WriteTo

func (field Flt8FieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type Flt8FieldFmt

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

func (Flt8FieldFmt) FormatByteLength

func (field Flt8FieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*Flt8FieldFmt) ReadFrom

func (field *Flt8FieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (Flt8FieldFmt) WriteTo

func (field Flt8FieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type FltNFieldData

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

func (*FltNFieldData) ReadFrom

func (field *FltNFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (FltNFieldData) WriteTo

func (field FltNFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type FltNFieldFmt

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

func (FltNFieldFmt) FormatByteLength

func (field FltNFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*FltNFieldFmt) ReadFrom

func (field *FltNFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (FltNFieldFmt) WriteTo

func (field FltNFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type HeaderOnlyPackage

type HeaderOnlyPackage struct {
	Header PacketHeader
}

HeaderOnlyPackage is used to communicate header-only packets using the same communication channels as regular token-based packages in go-ase.

func (HeaderOnlyPackage) ReadFrom

func (pkg HeaderOnlyPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (HeaderOnlyPackage) String

func (pkg HeaderOnlyPackage) String() string

func (HeaderOnlyPackage) WriteTo

func (pkg HeaderOnlyPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type ImageFieldData

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

func (*ImageFieldData) ReadFrom

func (field *ImageFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (ImageFieldData) WriteTo

func (field ImageFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type ImageFieldFmt

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

func (ImageFieldFmt) FormatByteLength

func (field ImageFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*ImageFieldFmt) ReadFrom

func (field *ImageFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (ImageFieldFmt) WriteTo

func (field ImageFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type Info

type Info struct {
	dsn.Info

	Network        string `json:"network" doc:"Network to use, either 'tcp' or 'udp'"`
	ClientHostname string `json:"client-hostname" doc:"Hostname to send to server"`

	TLSEnable         bool   `json:"tls-enable" doc:"Enforce TLS use"`
	TLSHostname       string `json:"tls-hostname" doc:"Remote hostname to validate against SANs"`
	TLSSkipValidation bool   `json:"tls-skip-validation" doc:"Skip TLS validation - accepts any TLS certificate"`
	TLSCAFile         string `json:"tls-ca-file" doc:"Path to CA file to validate server certificate against"`

	PacketReadTimeout       int `` /* 130-byte string literal not displayed */
	ChannelPackageQueueSize int `json:"channel-package-queue-size" doc:"How many TDS packages can be queued in a TDS channel"`

	DebugLogPackages bool `json:"debug-log-packages" doc:"Log packages as they are transmitted/received"`
}

Info is a github.com/SAP/go-dblib/dsn compatible struct with required information for the TDS driver.

type Int1FieldData

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

func (*Int1FieldData) ReadFrom

func (field *Int1FieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (Int1FieldData) WriteTo

func (field Int1FieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type Int1FieldFmt

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

func (Int1FieldFmt) FormatByteLength

func (field Int1FieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*Int1FieldFmt) ReadFrom

func (field *Int1FieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (Int1FieldFmt) WriteTo

func (field Int1FieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type Int2FieldData

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

func (*Int2FieldData) ReadFrom

func (field *Int2FieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (Int2FieldData) WriteTo

func (field Int2FieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type Int2FieldFmt

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

func (Int2FieldFmt) FormatByteLength

func (field Int2FieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*Int2FieldFmt) ReadFrom

func (field *Int2FieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (Int2FieldFmt) WriteTo

func (field Int2FieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type Int4FieldData

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

func (*Int4FieldData) ReadFrom

func (field *Int4FieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (Int4FieldData) WriteTo

func (field Int4FieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type Int4FieldFmt

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

func (Int4FieldFmt) FormatByteLength

func (field Int4FieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*Int4FieldFmt) ReadFrom

func (field *Int4FieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (Int4FieldFmt) WriteTo

func (field Int4FieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type Int8FieldData

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

func (*Int8FieldData) ReadFrom

func (field *Int8FieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (Int8FieldData) WriteTo

func (field Int8FieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type Int8FieldFmt

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

func (Int8FieldFmt) FormatByteLength

func (field Int8FieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*Int8FieldFmt) ReadFrom

func (field *Int8FieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (Int8FieldFmt) WriteTo

func (field Int8FieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type IntNFieldData

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

func (*IntNFieldData) ReadFrom

func (field *IntNFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (IntNFieldData) WriteTo

func (field IntNFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type IntNFieldFmt

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

func (IntNFieldFmt) FormatByteLength

func (field IntNFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*IntNFieldFmt) ReadFrom

func (field *IntNFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (IntNFieldFmt) WriteTo

func (field IntNFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type IntervalFieldData

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

func (*IntervalFieldData) ReadFrom

func (field *IntervalFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (IntervalFieldData) WriteTo

func (field IntervalFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type IntervalFieldFmt

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

func (IntervalFieldFmt) FormatByteLength

func (field IntervalFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*IntervalFieldFmt) ReadFrom

func (field *IntervalFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (IntervalFieldFmt) WriteTo

func (field IntervalFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type KeyPackage

type KeyPackage struct {
	DataType asetypes.DataType
	Value    interface{}
}

KeyPackage is used to communicate the row position of a cursor.

func (*KeyPackage) ReadFrom

func (pkg *KeyPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (KeyPackage) String

func (pkg KeyPackage) String() string

func (KeyPackage) WriteTo

func (pkg KeyPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type LanguagePackage

type LanguagePackage struct {
	Status LanguageStatus
	Cmd    string
}

LanguagePackage is used to execute an SQL statement without arguments.

func (*LanguagePackage) ReadFrom

func (pkg *LanguagePackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (LanguagePackage) String

func (pkg LanguagePackage) String() string

func (*LanguagePackage) WriteTo

func (pkg *LanguagePackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type LanguageStatus

type LanguageStatus int

LanguageStatus is a bitmask for options on a language package.

const (
	TDS_LANGUAGE_NOARGS   LanguageStatus = 0x0
	TDS_LANGUAGE_HASARGS  LanguageStatus = 0x1
	TDS_LANG_BATCH_PARAMS LanguageStatus = 0x4
)

func (LanguageStatus) String

func (i LanguageStatus) String() string

type LastPkgAcceptor

type LastPkgAcceptor interface {
	LastPkg(Package) error
}

LastPkgAcceptor is the interface providing the LastPkg method.

type LoginAckPackage

type LoginAckPackage struct {
	Length         uint16
	Status         LoginAckStatus
	Version        *Version
	NameLength     uint8
	ProgramName    string
	ProgramVersion *Version
}

LoginAckPackage communicates the state of the login negotiation.

func (*LoginAckPackage) ReadFrom

func (pkg *LoginAckPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (LoginAckPackage) String

func (pkg LoginAckPackage) String() string

func (LoginAckPackage) WriteTo

func (pkg LoginAckPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type LoginAckStatus

type LoginAckStatus uint8

LoginAckstatus indicates the state of the login negotiation.

const (
	TDS_LOG_SUCCEED LoginAckStatus = 5 + iota
	TDS_LOG_FAIL
	TDS_LOG_NEGOTIATE
)

func (LoginAckStatus) String

func (i LoginAckStatus) String() string

type LoginConfig

type LoginConfig struct {
	DSN      *Info
	Hostname string

	// TODO name
	HostProc string
	AppName  string
	ServName string

	Language string
	CharSet  string

	RemoteServers []LoginConfigRemoteServer

	// Encrypt allows any TDSMsgId but only negotiation-relevant security
	// bits such as TDS_MSG_SEC_ENCRYPT will be recognized.
	Encrypt TDSMsgId
}

LoginConfig contains configuration to login to the server.

func NewLoginConfig

func NewLoginConfig(dsn *Info) (*LoginConfig, error)

NewLoginConfig creates a new login-configuration by using dsn information and setting default configuration-values in regard to the ASE database server (Should be be adjusted by clients).

type LoginConfigRemoteServer

type LoginConfigRemoteServer struct {
	Name, Password string
}

LoginConfigRemoteServer contains the name and the password to the server.

type LogoutPackage

type LogoutPackage struct {
	Options uint8
}

LogoutPackage is used to terminate and deallocate a connection.

func (*LogoutPackage) ReadFrom

func (pkg *LogoutPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (LogoutPackage) String

func (pkg LogoutPackage) String() string

func (LogoutPackage) WriteTo

func (pkg LogoutPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type LongBinaryFieldData

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

func (*LongBinaryFieldData) ReadFrom

func (field *LongBinaryFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (LongBinaryFieldData) WriteTo

func (field LongBinaryFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type LongBinaryFieldFmt

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

func (LongBinaryFieldFmt) FormatByteLength

func (field LongBinaryFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*LongBinaryFieldFmt) ReadFrom

func (field *LongBinaryFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (LongBinaryFieldFmt) WriteTo

func (field LongBinaryFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type LongCharFieldData

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

func (*LongCharFieldData) ReadFrom

func (field *LongCharFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (LongCharFieldData) WriteTo

func (field LongCharFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type LongCharFieldFmt

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

func (LongCharFieldFmt) FormatByteLength

func (field LongCharFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*LongCharFieldFmt) ReadFrom

func (field *LongCharFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (LongCharFieldFmt) WriteTo

func (field LongCharFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type MoneyFieldData

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

func (*MoneyFieldData) ReadFrom

func (field *MoneyFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (MoneyFieldData) WriteTo

func (field MoneyFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type MoneyFieldFmt

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

func (MoneyFieldFmt) FormatByteLength

func (field MoneyFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*MoneyFieldFmt) ReadFrom

func (field *MoneyFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (MoneyFieldFmt) WriteTo

func (field MoneyFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type MoneyNFieldData

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

func (*MoneyNFieldData) ReadFrom

func (field *MoneyNFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (MoneyNFieldData) WriteTo

func (field MoneyNFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type MoneyNFieldFmt

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

func (MoneyNFieldFmt) FormatByteLength

func (field MoneyNFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*MoneyNFieldFmt) ReadFrom

func (field *MoneyNFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (MoneyNFieldFmt) WriteTo

func (field MoneyNFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type MsgPackage

type MsgPackage struct {
	Status TDSMsgStatus
	MsgId  TDSMsgId
}

MsgPackage is used to communicate miscellaneous information that does not warrant its own package.

func NewMsgPackage

func NewMsgPackage(status TDSMsgStatus, msgId TDSMsgId) *MsgPackage

NewMsgPackage returns a TDS-message with status and id. TODO remove?

func (*MsgPackage) ReadFrom

func (pkg *MsgPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (MsgPackage) String

func (pkg MsgPackage) String() string

func (MsgPackage) WriteTo

func (pkg MsgPackage) WriteTo(ch BytesChannel) error

Write to implements the tds.Package interface.

type NumNFieldData

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

func (*NumNFieldData) ReadFrom

func (field *NumNFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

type NumNFieldFmt

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

func (NumNFieldFmt) FormatByteLength

func (field NumNFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*NumNFieldFmt) ReadFrom

func (field *NumNFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (NumNFieldFmt) WriteTo

func (field NumNFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type OptionCmd

type OptionCmd uint

OptionCmd defines the type of argument for an OptionCmdPackage.

const (
	TDS_OPT_SET OptionCmd = iota + 1
	TDS_OPT_DEFAULT
	TDS_OPT_LIST
	TDS_OPT_INFO
)

func (OptionCmd) String

func (i OptionCmd) String() string

type OptionCmdOption

type OptionCmdOption uint

OptionCmdOption defines which option is being configured.

const (
	TDS_OPT_UNUSED OptionCmdOption = iota
	TDS_OPT_DATEFIRST
	TDS_OPT_TEXTSIZE
	TDS_OPT_STAT_TIME
	TDS_OPT_STAT_IO
	TDS_OPT_ROWCOUNT
	TDS_OPT_NATLANG
	TDS_OPT_DATEFORMAT
	TDS_OPT_ISOLATION
	TDS_OPT_AUTHON
	TDS_OPT_CHARSET
	TDS_OPT_PLAN
	TDS_OPT_ERRLVL
	TDS_OPT_SHOWPLAN
	TDS_OPT_NOEXEC
	TDS_OPT_ARITHIGNOREON
	TDS_OPT_ARITHABORTON
	TDS_OPT_PARSEONLY
	TDS_OPT_ESTIMATE
	TDS_OPT_GETDATA
	TDS_OPT_NOCOUNT
	TDS_OPT_FORCEPLAN
	TDS_OPT_FORMATONLY
	TDS_OPT_CHAINXACTS
	TDS_OPT_CURCLOSEONXACT
	TDS_OPT_FIPSFLAG
	TDS_OPT_RESTREES
	TDS_OPT_IDENTITYON
	TDS_OPT_CURREAD
	TDS_OPT_CURWRITE
	TDS_OPT_IDENTITYOFF
	TDS_OPT_AUTHOFF
	TDS_OPT_ANSINULL
	TDS_OPT_QUOTED_IDENT
	TDS_OPT_ANSIPERM
	TDS_OPT_STR_RTRUNC
	TDS_OPT_SORTMERGE
	TDS_OPT_JTC
	TDS_OPT_CLIENTREALNAME
	TDS_OPT_CLIENTHOSTNAME
	TDS_OPT_CLIENTAPPLNAME
	TDS_OPT_IDENTITYUPD_ON
	TDS_OPT_IDENTITYUPD_OFF
	TDS_OPT_NODATA
	TDS_OPT_CIPHERTEXT
	TDS_OPT_SHOW_FI
	TDS_OPT_HIDE_VCC
	TDS_OPT_LOBLOCATOR
	TDS_REQ_LOBLOCATOR
	TDS_OPT_LOBLOCATORFETCHSIZE
	TDS_OPT_ISOLATION_MODE OptionCmdOption = iota + 52
)

func (OptionCmdOption) String

func (i OptionCmdOption) String() string

type OptionCmdPackage

type OptionCmdPackage struct {
	Cmd    OptionCmd
	Option OptionCmdOption
	// The type of OptionArg depends on the Option
	OptionArg []byte
}

OptionCmdPackage is used to set or reset an option.

func (*OptionCmdPackage) ReadFrom

func (pkg *OptionCmdPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (OptionCmdPackage) String

func (pkg OptionCmdPackage) String() string

func (OptionCmdPackage) WriteTo

func (pkg OptionCmdPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type OrderBy2Package

type OrderBy2Package struct {
	OrderByPackage
}

OrderBy2Package is a superset of OrderByPackage and supports more than 255 columns.

func (*OrderBy2Package) ReadFrom

func (pkg *OrderBy2Package) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (OrderBy2Package) String

func (pkg OrderBy2Package) String() string

func (OrderBy2Package) WriteTo

func (pkg OrderBy2Package) WriteTo(ch BytesChannel) error

WriteTo is not implemented.

type OrderByPackage

type OrderByPackage struct {
	ColumnOrder []int
	// contains filtered or unexported fields
}

OrderByPackage communicates in which order columns should be used.

When a statement is executed the returned columns are in whatever order is most convenient for the server. The server may then send an OrderByPackage to communicate in which order the columns should be listed.

func (*OrderByPackage) LastPkg

func (pkg *OrderByPackage) LastPkg(other Package) error

LastPkg implements the tds.LastPkgAcceptor interface.

func (*OrderByPackage) ReadFrom

func (pkg *OrderByPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (OrderByPackage) String

func (pkg OrderByPackage) String() string

func (OrderByPackage) WriteTo

func (pkg OrderByPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type Package

type Package interface {
	// ReadFrom reads bytes from the passed channel until either the
	// channel is closed or the package has all required information.
	// The read bytes are parsed into the package struct.
	ReadFrom(BytesChannel) error

	// WriteTo writes bytes to the passed channel until either the
	// channel is closed or the package has written all required
	// information.
	WriteTo(BytesChannel) error

	fmt.Stringer
}

Package is the interface providing the ReadFrom and WriteTo methods.

func LookupPackage

func LookupPackage(token Token) (Package, error)

LookupPackage returns the Package struct for a token.

type Packet

type Packet struct {
	Header PacketHeader
	Data   []byte
}

Packet represents a single packet in a message.

func NewPacket

func NewPacket(packetSize int) *Packet

NewPacket creates a packet-struct.

func (Packet) Bytes

func (packet Packet) Bytes() ([]byte, error)

Bytes returns a byte slice of a packet.

func (*Packet) ReadFrom

func (packet *Packet) ReadFrom(ctx context.Context, reader io.Reader, timeout time.Duration) (int64, error)

ReadFrom reads the packet-data and returns the amount of read bytes.

func (Packet) String

func (packet Packet) String() string

func (Packet) WriteTo

func (packet Packet) WriteTo(writer io.Writer) (int64, error)

WriteTo writes a byte slice and returns the amount of written bytes.

type PacketHeader

type PacketHeader struct {
	// Message type, e.g. for login or language command
	MsgType PacketHeaderType
	// Status, e.g. encrypted or EOM
	Status PacketHeaderStatus
	// Length of package in bytes
	Length uint16
	// Channel the packet belongs to when multiplexing
	Channel uint16
	// PacketNr for ordering when multiplexing
	PacketNr uint8
	// Allowed window size before ACK is received
	Window uint8
}

PacketHeader is the header of a Packet.

func NewPacketHeader

func NewPacketHeader(packetSize int) PacketHeader

NewPacketHeader returns an initialized PacketHeader.

func (PacketHeader) Read

func (header PacketHeader) Read(bs []byte) (int64, error)

Read implements io.Reader.

func (*PacketHeader) ReadFrom

func (header *PacketHeader) ReadFrom(r io.Reader) (int64, error)

ReadFrom implements io.ReaderFrom.

func (PacketHeader) String

func (header PacketHeader) String() string

func (*PacketHeader) Write

func (header *PacketHeader) Write(bs []byte) (int64, error)

Write implements io.Writer.

func (PacketHeader) WriteTo

func (header PacketHeader) WriteTo(w io.Writer) (int64, error)

WriteTo implements io.WriterTo

type PacketHeaderStatus

type PacketHeaderStatus uint8

PacketHeaderStatus defines the state of a packet.

const (
	// Last buffer in a request or response
	TDS_BUFSTAT_EOM PacketHeaderStatus = 0x1
	// Acknowledgment of last receiver attention
	TDS_BUFSTAT_ATTNACK PacketHeaderStatus = 0x2
	// Attention request
	TDS_BUFSTAT_ATTN PacketHeaderStatus = 0x4
	// Event notification
	TDS_BUFSTAT_EVENT PacketHeaderStatus = 0x8
	// Buffer is encrypted
	TDS_BUFSTAT_SEAL PacketHeaderStatus = 0x10
	// Buffer is encrypted (SQL Anywhere CMDSQ protocol)
	TDS_BUFSTAT_ENCRYPT PacketHeaderStatus = 0x20
	// Buffer is encrypted with symmetric key for on demand command
	// encryption
	TDS_BUFSTAT_SYMENCRYPT PacketHeaderStatus = 0x40
)

func (PacketHeaderStatus) String

func (i PacketHeaderStatus) String() string

type PacketHeaderType

type PacketHeaderType uint8

PacketHeaderType defines the type of a packet.

const (
	TDS_BUF_LANG PacketHeaderType = iota + 1
	TDS_BUF_LOGIN
	TDS_BUF_RPC
	TDS_BUF_RESPONSE
	TDS_BUF_UNFMT
	TDS_BUF_ATTN
	TDS_BUF_BULK
	TDS_BUF_SETUP
	TDS_BUF_CLOSE
	TDS_BUF_ERROR
	TDS_BUF_PROTACK
	TDS_BUF_ECHO
	TDS_BUF_LOGOUT
	TDS_BUF_ENDPARAM
	TDS_BUF_NORMAL
	TDS_BUF_URGENT
	TDS_BUF_MIGRATE
	TDS_BUF_HELLO
	TDS_BUF_CMDSEQ_NORMAL
	TDS_BUF_CMDSEQ_LOGIN
	TDS_BUF_CMDSEQ_LIVENESS
	TDS_BUF_CMDSEQ_RESERVED1
	TDS_BUF_CMDSEQ_RESERVED2
)

func (PacketHeaderType) String

func (i PacketHeaderType) String() string

type PacketQueue

type PacketQueue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

PacketQueue is loosely modeled after bytes.Buffer. It supports automatically writing data into Packets, generating new Packets as required and reading over Packet boundaries.

func NewPacketQueue

func NewPacketQueue(packetSize func() int) *PacketQueue

NewPacketQueue returns an initialized PacketQueue.

func (*PacketQueue) AddPacket

func (queue *PacketQueue) AddPacket(packet *Packet)

AddPacket adds a packet to the queue.

func (*PacketQueue) AllPacketsConsumed

func (queue *PacketQueue) AllPacketsConsumed() bool

AllPacketsConsumend returns true if all packets have been consumed.

func (*PacketQueue) Byte

func (queue *PacketQueue) Byte() (byte, error)

Byte implements the tds.BytesChannel interface.

func (*PacketQueue) Bytes

func (queue *PacketQueue) Bytes(n int) ([]byte, error)

Bytes returns a slice of bytes from the queue.

The returned byte slice will always be of length n.

If there aren't enough bytes to read n bytes Bytes will return a wrapped io.EOF. The returned byte slice will still be of length n.

func (*PacketQueue) DiscardUntilCurrentPosition

func (queue *PacketQueue) DiscardUntilCurrentPosition()

DiscardUntilCurrentPosition discards all consumed packets, indicated by the position indizes. See Position for more details regarding positions.

func (*PacketQueue) Int16

func (queue *PacketQueue) Int16() (int16, error)

Int16 implements the tds.BytesChannel interface.

func (*PacketQueue) Int32

func (queue *PacketQueue) Int32() (int32, error)

Int32 implements the tds.BytesChannel interface.

func (*PacketQueue) Int64

func (queue *PacketQueue) Int64() (int64, error)

Int64 implements the tds.BytesChannel interface.

func (*PacketQueue) Int8

func (queue *PacketQueue) Int8() (int8, error)

Int8 implements the tds.BytesChannel interface.

func (*PacketQueue) IsEOM

func (queue *PacketQueue) IsEOM() bool

IsEOM returns true if all packets have been consumed and it is the end of the message.

func (*PacketQueue) Position

func (queue *PacketQueue) Position() (int, int)

Position returns the two indizes used by PacketQueue to store its position in the queue and their respective data.

The first returned integer is the packet index. Note that the packet index can change in both directions - it grows when bytes are read or written and it shrinks when DiscardUntilCurrentPosition is called.

The second returned integer is the data index. The data index points to the last unread or unwritten byte of the packet the packet index points to. The data index only grows when bytes are read or written to the queue. It may shrink when DiscardUntilCurrentPosition is called.

func (*PacketQueue) Read

func (queue *PacketQueue) Read(p []byte) (int, error)

Read satisfies the io.Reader interface.

func (*PacketQueue) Reset

func (queue *PacketQueue) Reset()

Reset resets a PacketQueue as if it were newly initialized. Note: All queued packets will be discarded.

func (*PacketQueue) SetPosition

func (queue *PacketQueue) SetPosition(indexPacket, indexData int)

SetPosition sets the two indizes used by PacketQueue. See Position for more details.

func (*PacketQueue) String

func (queue *PacketQueue) String(size int) (string, error)

String implements the tds.BytesChannel interface.

func (*PacketQueue) Uint16

func (queue *PacketQueue) Uint16() (uint16, error)

Uint16 implements the tds.BytesChannel interface.

func (*PacketQueue) Uint32

func (queue *PacketQueue) Uint32() (uint32, error)

Uint32 implements the tds.BytesChannel interface.

func (*PacketQueue) Uint64

func (queue *PacketQueue) Uint64() (uint64, error)

Uint64 implements the tds.BytesChannel interface.

func (*PacketQueue) Uint8

func (queue *PacketQueue) Uint8() (uint8, error)

Uint8 implements the tds.BytesChannel interface.

func (*PacketQueue) Write

func (queue *PacketQueue) Write(p []byte) (int, error)

Write satisfies the io.Writer interface.

func (*PacketQueue) WriteByte

func (queue *PacketQueue) WriteByte(b byte) error

WriteByte implements the tds.BytesChannel interface.

func (*PacketQueue) WriteBytes

func (queue *PacketQueue) WriteBytes(bs []byte) error

WriteBytes writes a slice of bytes.

The returned integer is the size of bs, the returned error is always nil.

func (*PacketQueue) WriteInt16

func (queue *PacketQueue) WriteInt16(i int16) error

WriteInt16 implements the tds.BytesChannel interface.

func (*PacketQueue) WriteInt32

func (queue *PacketQueue) WriteInt32(i int32) error

WriteInt32 implements the tds.BytesChannel interface.

func (*PacketQueue) WriteInt64

func (queue *PacketQueue) WriteInt64(i int64) error

WriteInt64 implements the tds.BytesChannel interface.

func (*PacketQueue) WriteInt8

func (queue *PacketQueue) WriteInt8(i int8) error

WriteInt8 implements the tds.BytesChannel interface.

func (*PacketQueue) WriteString

func (queue *PacketQueue) WriteString(s string) error

WriteString implements the tds.BytesChannel interface.

func (*PacketQueue) WriteUint16

func (queue *PacketQueue) WriteUint16(i uint16) error

WriteUint16 implements the tds.BytesChannel interface.

func (*PacketQueue) WriteUint32

func (queue *PacketQueue) WriteUint32(i uint32) error

WriteUint32 implements the tds.BytesChannel interface.

func (*PacketQueue) WriteUint64

func (queue *PacketQueue) WriteUint64(i uint64) error

WriteUint64 implements the tds.BytesChannel interface.

func (*PacketQueue) WriteUint8

func (queue *PacketQueue) WriteUint8(i uint8) error

WriteUint8 implements the tds.BytesChannel interface.

type ParamFmtPackage

type ParamFmtPackage struct {
	Fmts []FieldFmt
	// contains filtered or unexported fields
}

ParamFmtPackage communicates the order and types of arguments/parameters of statements or responses.

func NewParamFmtPackage

func NewParamFmtPackage(wide bool, fmts ...FieldFmt) *ParamFmtPackage

NewParamFmtPackage returns a new ParamFmtPackage.

func (*ParamFmtPackage) ReadFrom

func (pkg *ParamFmtPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (*ParamFmtPackage) ReadFromField

func (pkg *ParamFmtPackage) ReadFromField(ch BytesChannel) (FieldFmt, int, error)

ReadFromField reads bytes from the passed channel until either the channel is closed or the package has all required information.

func (ParamFmtPackage) String

func (pkg ParamFmtPackage) String() string

func (ParamFmtPackage) WriteTo

func (pkg ParamFmtPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

func (ParamFmtPackage) WriteToField

func (pkg ParamFmtPackage) WriteToField(ch BytesChannel, field FieldFmt) (int, error)

WriteToField writes bytes to the passed channel until either the channel is closed or the package has written all required information.

type ParamFmtStatus

type ParamFmtStatus uint

ParamFmtStatus is the type for bitmask values of a ParamFmt status.

const (
	TDS_PARAM_NOSTATUS     ParamFmtStatus = 0x0
	TDS_PARAM_RETURN       ParamFmtStatus = 0x1
	TDS_PARAM_COLUMNSTATUS ParamFmtStatus = 0x8
	TDS_PARAM_NULLALLOWED  ParamFmtStatus = 0x20
)

func (ParamFmtStatus) String

func (i ParamFmtStatus) String() string

type ParamsPackage

type ParamsPackage struct {
	DataFields []FieldData
	// contains filtered or unexported fields
}

ParamsPackage is used to communicate a parameters or arguments.

func NewParamsPackage

func NewParamsPackage(data ...FieldData) *ParamsPackage

NewParamsPackage returns an initialized ParamsPkg.

func (*ParamsPackage) LastPkg

func (pkg *ParamsPackage) LastPkg(other Package) error

LastPkg implements the tds.LastPkgAcceptor interface.

func (*ParamsPackage) ReadFrom

func (pkg *ParamsPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (ParamsPackage) String

func (pkg ParamsPackage) String() string

func (ParamsPackage) WriteTo

func (pkg ParamsPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type RequestCapability

type RequestCapability int

RequestCapability is the type for request capabilities.

const (
	TDS_REQ_LANG RequestCapability = iota + 1
	TDS_REQ_RPC
	TDS_REQ_EVT
	TDS_REQ_MSTMT
	TDS_REQ_BCP
	TDS_REQ_CURSOR
	TDS_REQ_DYNF
	TDS_REQ_MSG
	TDS_REQ_PARAM
	TDS_DATA_INT1
	TDS_DATA_INT2
	TDS_DATA_INT4
	TDS_DATA_BIT
	TDS_DATA_CHAR
	TDS_DATA_VCHAR
	TDS_DATA_BIN
	TDS_DATA_VBIN
	TDS_DATA_MNY8
	TDS_DATA_MNY4
	TDS_DATA_DATE8
	TDS_DATA_DATE4
	TDS_DATA_FLT4
	TDS_DATA_FLT8
	TDS_DATA_NUM
	TDS_DATA_TEXT
	TDS_DATA_IMAGE
	TDS_DATA_DEC
	TDS_DATA_LCHAR
	TDS_DATA_LBIN
	TDS_DATA_INTN
	TDS_DATA_DATETIMEN
	TDS_DATA_MONEYN
	TDS_CSR_PREV
	TDS_CSR_FIRST
	TDS_CSR_LAST
	TDS_CSR_ABS
	TDS_CSR_REL
	TDS_CSR_MULTI
	TDS_CON_OOB
	TDS_CON_INBAND
	TDS_CON_LOGICAL
	TDS_PROTO_TEXT
	TDS_PROTO_BULK
	TDS_REQ_URGEVT
	TDS_DATA_SENSITIVITY
	TDS_DATA_BOUNDARY
	TDS_PROTO_DYNAMIC
	TDS_PROTO_DYNPROC
	TDS_DATA_FLTN
	TDS_DATA_BITN
	TDS_DATA_INT8
	TDS_DATA_VOID
	TDS_DOL_BULK
	TDS_OBJECT_JAVA1
	TDS_OBJECT_CHAR
	TDS_REQ_RESERVED1
	TDS_OBJECT_BINARY
	TDS_DATA_COLUMNSTATUS
	TDS_WIDETABLES
	TDS_REQ_RESERVED2
	TDS_DATA_UINT2
	TDS_DATA_UINT4
	TDS_DATA_UINT8
	TDS_DATA_UINTN
	TDS_CUR_IMPLICIT
	TDS_DATA_NLBIN
	TDS_IMAGE_NCHAR
	TDS_BLOB_NCHAR_16
	TDS_BLOB_NCHAR_8
	TDS_BLOB_NCHAR_SCSU
	TDS_DATA_DATE
	TDS_DATA_TIME
	TDS_DATA_INTERVAL
	TDS_CSR_SCROLL
	TDS_CSR_SENSITIVE
	TDS_CSR_INSENSITIVE
	TDS_CSR_SEMISENSITIVE
	TDS_CSR_KEYSETDRIVEN
	TDS_REQ_SRVPKTSIZE
	TDS_DATA_UNITEXT
	TDS_CAP_CLUSTERFAILOVER
	TDS_DATA_SINT1
	TDS_REQ_LARGEIDENT
	TDS_REQ_BLOB_NCHAR_16
	TDS_DATA_XML
	TDS_REQ_CURINFO3
	TDS_REQ_DBRPC2
	TDS_UNUSED_REQ
	TDS_REQ_MIGRATE
	TDS_MULTI_REQUESTS
	TDS_REQ_OPTIONCMD2
	TDS_REQ_LOGINFO
	TDS_DATA_BIGDATETIME
	TDS_DATA_USECS
	TDS_RPCPARAM_LOB
	TDS_REQ_INSTID
	TDS_REQ_GRID
	TDS_REQ_DYN_BATCH
	TDS_REQ_LANG_BATCH
	TDS_REQ_RPC_BATCH
	TDS_DATA_LOBLOCATOR
	TDS_REQ_ROWCOUNT_FOR_SELECT
	TDS_REQ_LOGPARAMS
	TDS_REQ_DYNAMIC_SUPPRESS_PARAMFMT
	TDS_REQ_READONLY
	TDS_REQ_COMMAND_ENCRYPTION
)

Types of request capabilities.

func (RequestCapability) String

func (i RequestCapability) String() string

type ResponseCapability

type ResponseCapability int

ResponseCapability is the type for response capabilities.

const (
	TDS_RES_NOMSG ResponseCapability = iota + 1
	TDS_RES_NOEED
	TDS_RES_NOPARAM
	TDS_DATA_NOINT1
	TDS_DATA_NOINT2
	TDS_DATA_NOINT4
	TDS_DATA_NOBIT
	TDS_DATA_NOCHAR
	TDS_DATA_NOVCHAR
	TDS_DATA_NOBIN
	TDS_DATA_NOVBIN
	TDS_DATA_NOMNY8
	TDS_DATA_NOMNY4
	TDS_DATA_NODATE8
	TDS_DATA_NODATE4
	TDS_DATA_NOFLT4
	TDS_DATA_NOFLT8
	TDS_DATA_NONUM
	TDS_DATA_NOTEXT
	TDS_DATA_NOIMAGE
	TDS_DATA_NODEC
	TDS_DATA_NOLCHAR
	TDS_DATA_NOLBIN
	TDS_DATA_NOINTN
	TDS_DATA_NODATETIMEN
	TDS_DATA_NOMONEYN
	TDS_CON_NOOOB
	TDS_CON_NOINBAND
	TDS_PROTO_NOTEXT
	TDS_PROTO_NOBULK
	TDS_DATA_NOSENSITIVITY
	TDS_DATA_NOBOUNDARY
	TDS_RES_NOTDSDEBUG
	TDS_RES_NOSTRIPBLANKS
	TDS_DATA_NOINT8
	TDS_OBJECT_NOJAVA1
	TDS_OBJECT_NOCHAR
	TDS_DATA_NOCOLUMNSTATUS
	TDS_OBJECT_NOBINARY
	TDS_RES_RESERVED
	TDS_DATA_NOUINT2
	TDS_DATA_NOUINT4
	TDS_DATA_NOUINT8
	TDS_DATA_NOUINTN
	TDS_NOWIDETABLES
	TDS_DATA_NONLBIN
	TDS_IMAGE_NONCHAR
	TDS_BLOB_NONCHAR_16
	TDS_BLOB_NONCHAR_8
	TDS_BLOB_NONCHAR_SCSU
	TDS_DATA_NODATE
	TDS_DATA_NOTIME
	TDS_DATA_NOINTERVAL
	TDS_DATA_NOUNITEXT
	TDS_DATA_NOSINT1
	TDS_NO_LARGEIDENT
	TDS_NO_BLOB_NCHAR_16
	TDS_NO_SRVPKTSIZE
	TDS_DATA_NOXML
	TDS_NONINT_RETURN_VALUE
	TDS_RES_NOXNLMETADATA
	TDS_RES_SUPPRESS_FMT
	TDS_RES_SUPPRESS_DONEINPROC
	TDS_UNUSED_RES
	TDS_DATA_NOBIGDATETIME
	TDS_DATA_NOUSECS
	TDS_RES_NO_TDSCONTROL
	TDS_RPCPARAM_NOLOB
	TDS_DATA_NOLOBLOCATOR
	TDS_RES_NOROWCOUNT_FOR_SELECT
	TDS_RES_CUMULATIVE_DONE
	TDS_RES_LIST_DR_MAP
	TDS_RES_DR_NOKILL
)

Types of response capabilities.

func (ResponseCapability) String

func (i ResponseCapability) String() string

type ReturnStatusPackage

type ReturnStatusPackage struct {
	ReturnValue int32
}

ReturnStatusPackage communicates the return status of stored procedures.

func (*ReturnStatusPackage) ReadFrom

func (pkg *ReturnStatusPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (ReturnStatusPackage) String

func (pkg ReturnStatusPackage) String() string

func (ReturnStatusPackage) WriteTo

func (pkg ReturnStatusPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type RowFmtPackage

type RowFmtPackage struct {
	Fmts []FieldFmt
	// contains filtered or unexported fields
}

RowFmtPackage communicates the data types of rows.

func (*RowFmtPackage) ReadFrom

func (pkg *RowFmtPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (*RowFmtPackage) ReadFromField

func (pkg *RowFmtPackage) ReadFromField(ch BytesChannel) (FieldFmt, int, error)

ReadFromField reads bytes from the passed channel until either the channel is closed or the package has all required information.

func (RowFmtPackage) String

func (pkg RowFmtPackage) String() string

func (*RowFmtPackage) WriteTo

func (pkg *RowFmtPackage) WriteTo(ch BytesChannel) error

WriteTo is not implemented.

type RowFmtStatus

type RowFmtStatus uint

RowFmtStatus is the type for bitmask values of a RowFmt status.

const (
	TDS_ROW_NOSTATUS     RowFmtStatus = 0x0
	TDS_ROW_HIDDEN       RowFmtStatus = 0x1
	TDS_ROW_KEY          RowFmtStatus = 0x2
	TDS_ROW_VERSION      RowFmtStatus = 0x4
	TDS_ROW_COLUMNSTATUS RowFmtStatus = 0x8
	TDS_ROW_UPDATEABLE   RowFmtStatus = 0x10
	TDS_ROW_NULLALLOWED  RowFmtStatus = 0x20
	TDS_ROW_IDENTITY     RowFmtStatus = 0x40
	TDS_ROW_PADCHAR      RowFmtStatus = 0x80
)

func (RowFmtStatus) String

func (i RowFmtStatus) String() string

type RowPackage

type RowPackage struct {
	ParamsPackage
}

RowPackage is used to communicate a row.

type SecurityCapability

type SecurityCapability int

SecurityCapability is the type for security capabilities.

type SensitivityFieldData

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

func (*SensitivityFieldData) ReadFrom

func (field *SensitivityFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (SensitivityFieldData) WriteTo

func (field SensitivityFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type SensitivityFieldFmt

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

func (SensitivityFieldFmt) FormatByteLength

func (field SensitivityFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*SensitivityFieldFmt) ReadFrom

func (field *SensitivityFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (SensitivityFieldFmt) WriteTo

func (field SensitivityFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type ShortDateFieldData

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

func (*ShortDateFieldData) ReadFrom

func (field *ShortDateFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (ShortDateFieldData) WriteTo

func (field ShortDateFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type ShortDateFieldFmt

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

func (ShortDateFieldFmt) FormatByteLength

func (field ShortDateFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*ShortDateFieldFmt) ReadFrom

func (field *ShortDateFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (ShortDateFieldFmt) WriteTo

func (field ShortDateFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type ShortMoneyFieldData

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

func (*ShortMoneyFieldData) ReadFrom

func (field *ShortMoneyFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (ShortMoneyFieldData) WriteTo

func (field ShortMoneyFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type ShortMoneyFieldFmt

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

func (ShortMoneyFieldFmt) FormatByteLength

func (field ShortMoneyFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*ShortMoneyFieldFmt) ReadFrom

func (field *ShortMoneyFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (ShortMoneyFieldFmt) WriteTo

func (field ShortMoneyFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type Sint1FieldData

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

func (*Sint1FieldData) ReadFrom

func (field *Sint1FieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (Sint1FieldData) WriteTo

func (field Sint1FieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type Sint1FieldFmt

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

func (Sint1FieldFmt) FormatByteLength

func (field Sint1FieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*Sint1FieldFmt) ReadFrom

func (field *Sint1FieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (Sint1FieldFmt) WriteTo

func (field Sint1FieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type TDSMsgId

type TDSMsgId uint16

TDSMsgId is the type of a message package.

const (
	TDS_MSG_SEC_ENCRYPT TDSMsgId = iota + 1
	TDS_MSG_SEC_LOGPWD
	TDS_MSG_SEC_REMPWD
	TDS_MSG_SEC_CHALLENGE
	TDS_MSG_SEC_RESPONSE
	TDS_MSG_SEC_GETLABEL
	TDS_MSG_SEC_LABEL
	TDS_MSG_SQL_TBLNAME
	TDS_MSG_GW_RESERVED
	TDS_MSG_OMNI_CAPABILITIES
	TDS_MSG_SEC_OPAQUE
	TDS_MSG_HAFAILOVER
	TDS_MSG_EMPTY
	TDS_MSG_SEC_ENCRYPT2
	TDS_MSG_SEC_LOGPWD2
	TDS_MSG_SEC_SUP_CIPHER2
	TDS_MSG_MIG_REQ
	TDS_MSG_MIG_SYNC
	TDS_MSG_MIG_CONT
	TDS_MSG_MIG_IGN
	TDS_MSG_MIG_FAIL
	TDS_MSG_SEC_REMPWD2
	TDS_MSG_MIG_RESUME
	TDS_MSG_HELLO
	TDS_MSG_LOGINPARAMS
	TDS_MSG_GRID_MIGREQ
	TDS_MSG_GRID_QUIESCE
	TDS_MSG_GRID_UNQUIESCE
	TDS_MSG_GRID_EVENT
	TDS_MSG_SEC_ENCRYPT3
	TDS_MSG_SEC_LOGPWD3
	TDS_MSG_SEC_REMPWD3
	TDS_MSG_DR_MAP
	TDS_MSG_SEC_SYMKEY
	TDS_MSG_SEC_ENCRYPT4
)

func (TDSMsgId) String

func (i TDSMsgId) String() string

type TDSMsgStatus

type TDSMsgStatus uint8

TDSMsgStatus defines wether a message package has arguments or not.

const (
	TDS_MSG_HASNOARGS TDSMsgStatus = iota
	TDS_MSG_HASARGS
)

func (TDSMsgStatus) String

func (i TDSMsgStatus) String() string

type TDSOpaqueSecurityToken

type TDSOpaqueSecurityToken uint8

TDSOpaqueSecurityToken is the type of a security token.

const (
	TDS_SEC_SECSESS TDSOpaqueSecurityToken = iota
	TDS_SEC_FORWARD
	TDS_SEC_SIGN
	TDS_SEC_OTHER
)

type TextFieldData

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

func (*TextFieldData) ReadFrom

func (field *TextFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (TextFieldData) WriteTo

func (field TextFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type TextFieldFmt

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

func (TextFieldFmt) FormatByteLength

func (field TextFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*TextFieldFmt) ReadFrom

func (field *TextFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (TextFieldFmt) WriteTo

func (field TextFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type TimeFieldData

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

func (*TimeFieldData) ReadFrom

func (field *TimeFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (TimeFieldData) WriteTo

func (field TimeFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type TimeFieldFmt

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

func (TimeFieldFmt) FormatByteLength

func (field TimeFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*TimeFieldFmt) ReadFrom

func (field *TimeFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (TimeFieldFmt) WriteTo

func (field TimeFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type TimeNFieldData

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

func (*TimeNFieldData) ReadFrom

func (field *TimeNFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (TimeNFieldData) WriteTo

func (field TimeNFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type TimeNFieldFmt

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

func (TimeNFieldFmt) FormatByteLength

func (field TimeNFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*TimeNFieldFmt) ReadFrom

func (field *TimeNFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (TimeNFieldFmt) WriteTo

func (field TimeNFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type Token

type Token byte

Token is the type for bitmask values of a TDS-token.

const (
	TDS_CURDECLARE3  Token = 0x10
	TDS_PARAMFMT2    Token = 0x20
	TDS_LANGUAGE     Token = 0x21
	TDS_ORDERBY2     Token = 0x22
	TDS_CURDECLARE2  Token = 0x23
	TDS_COLFMTOLD    Token = 0x2A
	TDS_DEBUGCMD     Token = 0x60
	TDS_ROWFMT2      Token = 0x61
	TDS_DYNAMIC2     Token = 0x62
	TDS_MSG          Token = 0x65
	TDS_LOGOUT       Token = 0x71
	TDS_OFFSET       Token = 0x78
	TDS_RETURNSTATUS Token = 0x79
	TDS_PROCID       Token = 0x7C
	TDS_CURCLOSE     Token = 0x80
	TDS_CURDELETE    Token = 0x81
	TDS_CURFETCH     Token = 0x82
	TDS_CURINFO      Token = 0x83
	TDS_CUROPEN      Token = 0x84
	TDS_CURUPDATE    Token = 0x85
	TDS_CURDECLARE   Token = 0x86
	TDS_CURINFO2     Token = 0x87
	TDS_CURINFO3     Token = 0x88
	TDS_COLNAME      Token = 0xA0
	TDS_COLFMT       Token = 0xA1
	TDS_EVENTNOTICE  Token = 0xA2
	TDS_TABNAME      Token = 0xA4
	TDS_COLINFO      Token = 0xA5
	TDS_OPTIONCMD    Token = 0xA6
	TDS_ALTNAME      Token = 0xA7
	TDS_ALTFMT       Token = 0xA8
	TDS_ORDERBY      Token = 0xA9
	TDS_ERROR        Token = 0xAA
	TDS_INFO         Token = 0xAB
	TDS_RETURNVALUE  Token = 0xAC
	TDS_LOGINACK     Token = 0xAD
	TDS_CONTROL      Token = 0xAE
	TDS_ALTCONTROL   Token = 0xAF
	TDS_KEY          Token = 0xCA
	TDS_ROW          Token = 0xD1
	TDS_ALTROW       Token = 0xD3
	TDS_PARAMS       Token = 0xD7
	TDS_RPC          Token = 0xE0
	TDS_CAPABILITY   Token = 0xE2
	TDS_ENVCHANGE    Token = 0xE3
	TDS_EED          Token = 0xE5
	TDS_DBRPC        Token = 0xE6
	TDS_DYNAMIC      Token = 0xE7
	TDS_DBRPC2       Token = 0xE8
	TDS_PARAMFMT     Token = 0xEC
	TDS_ROWFMT       Token = 0xEE
	TDS_DONE         Token = 0xFD
	TDS_DONEPROC     Token = 0xFE
	TDS_DONEINPROC   Token = 0xFF
)

Types of TDS-tokens.

func (Token) String

func (i Token) String() string

type TokenlessPackage

type TokenlessPackage struct {
	Data *bytes.Buffer
}

TokenlessPackage are used to transmit blobs of data.

func NewTokenlessPackage

func NewTokenlessPackage() *TokenlessPackage

NewTokenLessPackage returns an initialized TokenlessPackage.

func (*TokenlessPackage) ReadFrom

func (pkg *TokenlessPackage) ReadFrom(ch BytesChannel) error

ReadFrom implements the tds.Package interface.

func (TokenlessPackage) String

func (pkg TokenlessPackage) String() string

func (TokenlessPackage) WriteTo

func (pkg TokenlessPackage) WriteTo(ch BytesChannel) error

WriteTo implements the tds.Package interface.

type TransState

type TransState uint16

TransState is the type for bitmask values of a trans-package state.

const (
	TDS_NOT_IN_TRAN      TransState = 0x0
	TDS_TRAN_IN_PROGRESS TransState = 0x1
	TDS_TRAN_COMPLETED   TransState = 0x2
	TDS_TRAN_FAIL        TransState = 0x3
	TDS_TRAN_STMT_FAIL   TransState = 0x4
)

States of a trans-package.

func (TransState) String

func (i TransState) String() string

type Uint2FieldData

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

func (*Uint2FieldData) ReadFrom

func (field *Uint2FieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (Uint2FieldData) WriteTo

func (field Uint2FieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type Uint2FieldFmt

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

func (Uint2FieldFmt) FormatByteLength

func (field Uint2FieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*Uint2FieldFmt) ReadFrom

func (field *Uint2FieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (Uint2FieldFmt) WriteTo

func (field Uint2FieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type Uint4FieldData

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

func (*Uint4FieldData) ReadFrom

func (field *Uint4FieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (Uint4FieldData) WriteTo

func (field Uint4FieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type Uint4FieldFmt

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

func (Uint4FieldFmt) FormatByteLength

func (field Uint4FieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*Uint4FieldFmt) ReadFrom

func (field *Uint4FieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (Uint4FieldFmt) WriteTo

func (field Uint4FieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type Uint8FieldData

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

func (*Uint8FieldData) ReadFrom

func (field *Uint8FieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (Uint8FieldData) WriteTo

func (field Uint8FieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type Uint8FieldFmt

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

func (Uint8FieldFmt) FormatByteLength

func (field Uint8FieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*Uint8FieldFmt) ReadFrom

func (field *Uint8FieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (Uint8FieldFmt) WriteTo

func (field Uint8FieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type UintNFieldData

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

func (*UintNFieldData) ReadFrom

func (field *UintNFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (UintNFieldData) WriteTo

func (field UintNFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type UintNFieldFmt

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

func (UintNFieldFmt) FormatByteLength

func (field UintNFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*UintNFieldFmt) ReadFrom

func (field *UintNFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (UintNFieldFmt) WriteTo

func (field UintNFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type UniTextFieldData

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

func (*UniTextFieldData) ReadFrom

func (field *UniTextFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (UniTextFieldData) WriteTo

func (field UniTextFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type UniTextFieldFmt

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

func (UniTextFieldFmt) FormatByteLength

func (field UniTextFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*UniTextFieldFmt) ReadFrom

func (field *UniTextFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (UniTextFieldFmt) WriteTo

func (field UniTextFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type VarBinaryFieldData

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

func (*VarBinaryFieldData) ReadFrom

func (field *VarBinaryFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (VarBinaryFieldData) WriteTo

func (field VarBinaryFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type VarBinaryFieldFmt

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

func (VarBinaryFieldFmt) FormatByteLength

func (field VarBinaryFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*VarBinaryFieldFmt) ReadFrom

func (field *VarBinaryFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (VarBinaryFieldFmt) WriteTo

func (field VarBinaryFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type VarCharFieldData

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

func (*VarCharFieldData) ReadFrom

func (field *VarCharFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (VarCharFieldData) WriteTo

func (field VarCharFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type VarCharFieldFmt

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

func (VarCharFieldFmt) FormatByteLength

func (field VarCharFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*VarCharFieldFmt) ReadFrom

func (field *VarCharFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (VarCharFieldFmt) WriteTo

func (field VarCharFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

type Version

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

Version contains library-versions.

func NewVersion

func NewVersion(bs []byte) (*Version, error)

NewVersion creates a Version-struct.

func NewVersionString

func NewVersionString(s string) (*Version, error)

NewVersionString parses the passed string into a version-struct.

func (Version) Bytes

func (tdsv Version) Bytes() []byte

func (Version) Compare

func (tdsv Version) Compare(other Version) int

Compare returns 0 if tdsv and other are equal.

 1 is returned if a tdsv.property is greater than a other.property.
-1 is returned if a tdsv.property is smaller than a other.property.

func (Version) String

func (tdsv Version) String() string

type XMLFieldData

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

func (*XMLFieldData) ReadFrom

func (field *XMLFieldData) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldData interface.

func (XMLFieldData) WriteTo

func (field XMLFieldData) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldData interface.

type XMLFieldFmt

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

func (XMLFieldFmt) FormatByteLength

func (field XMLFieldFmt) FormatByteLength() int

FormatByteLength implements the tds.FieldFmt interface.

func (*XMLFieldFmt) ReadFrom

func (field *XMLFieldFmt) ReadFrom(ch BytesChannel) (int, error)

ReadFrom implements the tds.FieldFmt interface.

func (XMLFieldFmt) WriteTo

func (field XMLFieldFmt) WriteTo(ch BytesChannel) (int, error)

WriteTo implements the tds.FieldFmt interface.

Jump to

Keyboard shortcuts

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