rsqlib

package
v0.0.0-...-91c5940 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2017 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SECONDS_PER_DAY     = 24 * 3600    // 86400
	UNIX_SEC_LOWEST     = -62135596800 // -719162 days * 24 * 3600
	UNIX_SEC_1900_01_01 = -2208988800  // -25567 days * 24 * 3600
	UNIX_SEC_1970_01_01 = 0
)
View Source
const NULL_STRING = "<NULL>"

Variables

This section is empty.

Functions

This section is empty.

Types

type Bigint

type Bigint struct {
	Is_Null bool
	Val     int64
}

func (*Bigint) Datatype

func (field *Bigint) Datatype() Dtype_t

func (*Bigint) IsNull

func (field *Bigint) IsNull() bool

func (*Bigint) String

func (field *Bigint) String() string

type Bit

type Bit struct {
	Is_Null bool
	Val     uint8 // 0 or 1
}

func (*Bit) Datatype

func (field *Bit) Datatype() Dtype_t

func (*Bit) IsNull

func (field *Bit) IsNull() bool

func (*Bit) String

func (field *Bit) String() string

type Boolean

type Boolean struct {
	Is_Null bool
	Val     bool
}

func (*Boolean) Datatype

func (field *Boolean) Datatype() Dtype_t

func (*Boolean) IsNull

func (field *Boolean) IsNull() bool

func (*Boolean) String

func (field *Boolean) String() string

type Date

type Date struct {
	Is_Null bool
	Val     time.Time
}

func (*Date) Datatype

func (field *Date) Datatype() Dtype_t

func (*Date) IsNull

func (field *Date) IsNull() bool

func (*Date) String

func (field *Date) String() string

type Datetime

type Datetime struct {
	Is_Null bool
	Val     time.Time
}

func (*Datetime) Datatype

func (field *Datetime) Datatype() Dtype_t

func (*Datetime) IsNull

func (field *Datetime) IsNull() bool

func (*Datetime) String

func (field *Datetime) String() string

type Dtype_t

type Dtype_t uint8
const (
	DTYPE_VOID      Dtype_t = 1
	DTYPE_BOOLEAN   Dtype_t = 2
	DTYPE_VARBINARY Dtype_t = 4
	DTYPE_VARCHAR   Dtype_t = 6

	DTYPE_BIT      Dtype_t = 9
	DTYPE_TINYINT  Dtype_t = 10
	DTYPE_SMALLINT Dtype_t = 11
	DTYPE_INT      Dtype_t = 12
	DTYPE_BIGINT   Dtype_t = 13

	DTYPE_MONEY   Dtype_t = 15
	DTYPE_NUMERIC Dtype_t = 16
	DTYPE_FLOAT   Dtype_t = 17

	DTYPE_DATE     Dtype_t = 19
	DTYPE_TIME     Dtype_t = 20
	DTYPE_DATETIME Dtype_t = 21
)

type Error_info

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

func (Error_info) Category

func (e Error_info) Category() string

func (Error_info) Line_no

func (e Error_info) Line_no() int64

func (Error_info) Line_pos

func (e Error_info) Line_pos() int64

func (Error_info) Message

func (e Error_info) Message() string

func (Error_info) Severity

func (e Error_info) Severity() string

func (Error_info) Src_backtrace

func (e Error_info) Src_backtrace() string

func (Error_info) Src_file

func (e Error_info) Src_file() string

func (Error_info) Src_funcname

func (e Error_info) Src_funcname() string

func (Error_info) Src_line_no

func (e Error_info) Src_line_no() int64

func (Error_info) State

func (e Error_info) State() int64

func (Error_info) String

func (e Error_info) String() string

func (Error_info) String_format

func (e Error_info) String_format(level int, wrap bool) string

func (Error_info) Text

func (e Error_info) Text() string

type Float

type Float struct {
	Is_Null bool
	Val     float64
}

func (*Float) Datatype

func (field *Float) Datatype() Dtype_t

func (*Float) IsNull

func (field *Float) IsNull() bool

func (*Float) String

func (field *Float) String() string

type IField

type IField interface {
	Datatype() Dtype_t
	IsNull() bool
	String() string
	// contains filtered or unexported methods
}

Int, Float, etc implement IField interface. A series of IFields makes up a row, which will receive the deserialized values sent by the server.

The user can then access to the value stored in each field. He can then copy these values to a suitable variable type, e.g. copy Numeric values into math.big.Rat or decnum.Quad type.

type Int

type Int struct {
	Is_Null bool
	Val     int32
}

func (*Int) Datatype

func (field *Int) Datatype() Dtype_t

func (*Int) IsNull

func (field *Int) IsNull() bool

func (*Int) String

func (field *Int) String() string

type Money

type Money struct {
	Precision uint16
	Scale     uint16
	Is_Null   bool
	Val       []byte // the value is received as string, and we only want to display it. No need to convert it to e.g. big.Rat.
}

func (*Money) Datatype

func (field *Money) Datatype() Dtype_t

func (*Money) IsNull

func (field *Money) IsNull() bool

func (*Money) String

func (field *Money) String() string

type Numeric

type Numeric struct {
	Precision uint16
	Scale     uint16
	Is_Null   bool
	Val       []byte // the value is received as string, and we only want to display it. No need to convert it to e.g. big.Rat.
}

func (*Numeric) Datatype

func (field *Numeric) Datatype() Dtype_t

func (*Numeric) IsNull

func (field *Numeric) IsNull() bool

func (*Numeric) String

func (field *Numeric) String() string

type Options

type Options struct {
	Showtree bool // show AST tree
	No_cf    bool // no constant folding, for debugging
	No_exec  bool // don't run the batches
}

type Request_t

type Request_t uint8

Request_t is the message types sent from client to server

const (
	REQTYP_AUTH      Request_t = 20
	REQTYP_BATCH     Request_t = 21
	REQTYP_KEEPALIVE Request_t = 30
)

type Response_t

type Response_t uint8

message types sent from server to client

const (
	RESTYP_LOGIN_FAILED  Response_t = 0
	RESTYP_LOGIN_SUCCESS Response_t = 1

	RESTYP_RECORD_LAYOUT   Response_t = 3
	RESTYP_RECORD          Response_t = 4
	RESTYP_RECORD_FINISHED Response_t = 5

	RESTYP_EXECUTION_FINISHED Response_t = 7

	RESTYP_PRINT   Response_t = 10
	RESTYP_MESSAGE Response_t = 11
	RESTYP_ERROR   Response_t = 12

	RESTYP_BATCH_END Response_t = 14
)

type Session

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

A new Session is created by the Connect function.

Once created, the fields of a Session object are NEVER changed.

func Connect

func Connect(remote_server string, login_name string, password string, database string, opt *Options, keepalive_interval int) (*Session, error)

Connect returns a Session if login has been successful. This Session object contains an open net.Conn connection.

If login or connection failed, it just returns an error.

If no error occurred, a valid Session object is returned. You must call Session.Close() when you are finished with it or if an error occurs during its use.

func (*Session) Close

func (session *Session) Close() error

Close closes the session and underlying connection socket.

Returns an error if the internal call session.conn.Close() has failed, but it can be ignored, as there is nothing much to do in this case.

To cancel a running query, just call session.Close(). The server will notice that the connection has been closed and will free the resources.

This function can be called asynchronously from another goroutine, as it is thread safe and can be called multiple times.

func (*Session) Create_colname_list

func (session *Session) Create_colname_list() ([]string, error)

Create_colname_list returns a list of column names from a messagepack Reader.

func (*Session) Create_row

func (session *Session) Create_row() ([]IField, error)

Create_row creates a row from a messagepack Reader.

func (*Session) Fill_row_with_values

func (session *Session) Fill_row_with_values(row []IField) error

Fill_row_with_values fills in values into row fields, from a messagepack Reader.

func (*Session) Mr

func (session *Session) Mr() *msgp.Reader

func (*Session) Read_Error_info

func (session *Session) Read_Error_info() (*Error_info, error)

Read_Error_info reads error information returned by server.

Used to read content of message RESTYP_BATCH_ERROR.

func (*Session) Read_batch_end_RC

func (session *Session) Read_batch_end_RC() (rc int64, err error)

Read_batch_end_RC reads a return code value when batch ends.

Used to read content of message RESTYP_BATCH_END.

func (*Session) Read_int64

func (session *Session) Read_int64() (int64, error)

Read_int64 reads int64, from a messagepack Reader.

func (*Session) Read_response_type

func (session *Session) Read_response_type() (Response_t, error)

Read_response_type reads just one byte from the connection, to identify the type of the response received from the server.

func (*Session) Read_server_info

func (session *Session) Read_server_info() error

Read_server_info reads information from server, such as version string, max batch size, etc. These information are received just after the login has been authenticated.

func (*Session) Read_string

func (session *Session) Read_string() (string, error)

Read_string reads a string, from a messagepack Reader.

func (*Session) Send_batch

func (session *Session) Send_batch(batch_text []byte) error

Send_batch sends a batch SQL text to the server. If it fails, because connection is broken, or data doesn't comply with the communication protocol, an error is returned.

Send_batch and Send_special_request can be called from multiple goroutines, as the calls are serialized by session.mw_lock.

func (*Session) Send_special_request

func (session *Session) Send_special_request(reqtyp Request_t) error

Send_special_request sends a keepalive message to the server.

Request must be REQTYP_KEEPALIVE.

func (*Session) Server_batch_text_max_size

func (session *Session) Server_batch_text_max_size() int64

func (*Session) Server_read_timeout

func (session *Session) Server_read_timeout() int64

func (*Session) Server_version_string

func (session *Session) Server_version_string() string

type Smallint

type Smallint struct {
	Is_Null bool
	Val     int16
}

func (*Smallint) Datatype

func (field *Smallint) Datatype() Dtype_t

func (*Smallint) IsNull

func (field *Smallint) IsNull() bool

func (*Smallint) String

func (field *Smallint) String() string

type Time

type Time struct {
	Is_Null bool
	Val     time.Time
}

func (*Time) Datatype

func (field *Time) Datatype() Dtype_t

func (*Time) IsNull

func (field *Time) IsNull() bool

func (*Time) String

func (field *Time) String() string

type Tinyint

type Tinyint struct {
	Is_Null bool
	Val     uint8
}

func (*Tinyint) Datatype

func (field *Tinyint) Datatype() Dtype_t

func (*Tinyint) IsNull

func (field *Tinyint) IsNull() bool

func (*Tinyint) String

func (field *Tinyint) String() string

type Varbinary

type Varbinary struct {
	Precision uint16
	Is_Null   bool
	Val       []byte
}

func (*Varbinary) Datatype

func (field *Varbinary) Datatype() Dtype_t

func (*Varbinary) IsNull

func (field *Varbinary) IsNull() bool

func (*Varbinary) String

func (field *Varbinary) String() string

type Varchar

type Varchar struct {
	Precision uint16
	Fixlen    bool
	Is_Null   bool
	Val       []byte
}

func (*Varchar) Datatype

func (field *Varchar) Datatype() Dtype_t

func (*Varchar) IsNull

func (field *Varchar) IsNull() bool

func (*Varchar) String

func (field *Varchar) String() string

type Void

type Void struct {
	Is_Null bool // always true
}

func (*Void) Datatype

func (field *Void) Datatype() Dtype_t

func (*Void) IsNull

func (field *Void) IsNull() bool

func (*Void) String

func (field *Void) String() string

Jump to

Keyboard shortcuts

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