Connection

A struct representing a database connection.

The Connection is responsible for handshaking with the server to establish authentication. It then passes client preferences to the server, and subsequently is the channel for all command packets that are sent, and all response packets received.

Uncompressed packets consist of a 4 byte header - 3 bytes of length, and one byte as a packet number. Connection deals with the headers and ensures that packet numbers are sequential.

The initial packet is sent by the server - esentially a 'hello' packet inviting login. That packet has a sequence number of zero. That sequence number is the incremented by cliemt and server packets thruogh the handshake sequence.

After login all further sequences are initialized by the client sending a command packet with a zero sequence number, to which the server replies with zero or more packets with sequential sequence numbers.

Constructors

this
this(string host, string user, string pwd, string db, ushort port, uint capFlags)

Construct opened connection.

this
this(string cs, uint capFlags)

Construct opened connection.

Destructor

~this
~this()
Undocumented in source.

Members

Functions

buildAuthPacket
uint buildAuthPacket()
Undocumented in source. Be warned that the author may not have intended to support it.
bumpPacket
void bumpPacket()
Undocumented in source. Be warned that the author may not have intended to support it.
close
void close()

Explicitly close the connection.

enableMultiStatements
void enableMultiStatements(bool on)

Enable multiple statement commands

getCmdResponse
OKPacket getCmdResponse(bool asString)
Undocumented in source. Be warned that the author may not have intended to support it.
getPacket
ubyte[] getPacket(uint pl)
Undocumented in source. Be warned that the author may not have intended to support it.
getServerInfo
void getServerInfo(ubyte* p)
Undocumented in source. Be warned that the author may not have intended to support it.
init_connection
void init_connection()
Undocumented in source. Be warned that the author may not have intended to support it.
makeToken
ubyte[] makeToken()
Undocumented in source. Be warned that the author may not have intended to support it.
open
bool open()
Undocumented in source. Be warned that the author may not have intended to support it.
parseGreeting
void parseGreeting()
Undocumented in source. Be warned that the author may not have intended to support it.
pingServer
OKPacket pingServer()

Check the server status

refreshServer
OKPacket refreshServer(int flags)

Refresh some features of he server.

resetPacket
void resetPacket()
Undocumented in source. Be warned that the author may not have intended to support it.
selectDB
void selectDB(string dbName)

Select a current database.

send
void send(ubyte[] packet)
Undocumented in source. Be warned that the author may not have intended to support it.
sendCmd
void sendCmd(ubyte cmd, string s)
Undocumented in source. Be warned that the author may not have intended to support it.
serverStats
string serverStats()

Get a textual report on the servr status.

setClientFlags
void setClientFlags(uint capFlags)
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

charSet
ubyte charSet [@property getter]

Current character set

currentDB
string currentDB [@property getter]

Current database

pktNumber
pktNumber [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
protocol
ubyte protocol [@property getter]

Return the in-force protocol number

serverCapabilities
uint serverCapabilities [@property getter]

Server capability flags

serverStatus
ushort serverStatus [@property getter]

Server status

serverVersion
string serverVersion [@property getter]

Server version

Static functions

parseConnectionString
string[] parseConnectionString(string cs)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

_authBuf
ubyte[] _authBuf;
_cCaps
uint _cCaps;
Undocumented in source.
_cpn
ubyte _cpn;
_db
string _db;
Undocumented in source.
_hdr
ubyte[4] _hdr;
Undocumented in source.
_host
string _host;
Undocumented in source.
_open
int _open;
Undocumented in source.
_packet
ubyte[] _packet;
Undocumented in source.
_pl
ushort _pl;
Undocumented in source.
_port
ushort _port;
_protocol
ubyte _protocol;
_pwd
string _pwd;
Undocumented in source.
_sCaps
uint _sCaps;
Undocumented in source.
_sCharSet
ubyte _sCharSet;
_sThread
uint _sThread;
Undocumented in source.
_serverStatus
ushort _serverStatus;
Undocumented in source.
_serverVersion
string _serverVersion;
Undocumented in source.
_socket
TcpConnection _socket;
Undocumented in source.
_token
ubyte[] _token;
_user
string _user;
Undocumented in source.

Meta