Documentation
¶
Index ¶
- Constants
- type Bigint
- type Bit
- type Boolean
- type Date
- type Datetime
- type Dtype_t
- type Error_info
- func (e Error_info) Category() string
- func (e Error_info) Line_no() int64
- func (e Error_info) Line_pos() int64
- func (e Error_info) Message() string
- func (e Error_info) Severity() string
- func (e Error_info) Src_backtrace() string
- func (e Error_info) Src_file() string
- func (e Error_info) Src_funcname() string
- func (e Error_info) Src_line_no() int64
- func (e Error_info) State() int64
- func (e Error_info) String() string
- func (e Error_info) String_format(level int, wrap bool) string
- func (e Error_info) Text() string
- type Float
- type IField
- type Int
- type Money
- type Numeric
- type Options
- type Request_t
- type Response_t
- type Session
- func (session *Session) Close() error
- func (session *Session) Create_colname_list() ([]string, error)
- func (session *Session) Create_row() ([]IField, error)
- func (session *Session) Fill_row_with_values(row []IField) error
- func (session *Session) Mr() *msgp.Reader
- func (session *Session) Read_Error_info() (*Error_info, error)
- func (session *Session) Read_batch_end_RC() (rc int64, err error)
- func (session *Session) Read_int64() (int64, error)
- func (session *Session) Read_response_type() (Response_t, error)
- func (session *Session) Read_server_info() error
- func (session *Session) Read_string() (string, error)
- func (session *Session) Send_batch(batch_text []byte) error
- func (session *Session) Send_special_request(reqtyp Request_t) error
- func (session *Session) Server_batch_text_max_size() int64
- func (session *Session) Server_read_timeout() int64
- func (session *Session) Server_version_string() string
- type Smallint
- type Time
- type Tinyint
- type Varbinary
- type Varchar
- type Void
Constants ¶
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 )
const NULL_STRING = "<NULL>"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 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 Money ¶
type Numeric ¶
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 ¶
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 ¶
Create_colname_list returns a list of column names from a messagepack Reader.
func (*Session) Create_row ¶
Create_row creates a row from a messagepack Reader.
func (*Session) Fill_row_with_values ¶
Fill_row_with_values fills in values into row fields, from a messagepack 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 ¶
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 ¶
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 ¶
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 ¶
Read_string reads a string, from a messagepack Reader.
func (*Session) Send_batch ¶
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 ¶
Send_special_request sends a keepalive message to the server.
Request must be REQTYP_KEEPALIVE.