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 - essentially a 'hello' packet inviting login. That packet has a sequence number of zero. That sequence number is the incremented by client and server packets through 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.

class Connection {}

Constructors

this
this(string host, string user, string pwd, string db, ushort port, SvrCapFlags capFlags)
this(MySQLSocketType socketType, string host, string user, string pwd, string db, ushort port, SvrCapFlags capFlags)
this(OpenSocketCallbackPhobos openSocket, string host, string user, string pwd, string db, ushort port, SvrCapFlags capFlags)
this(OpenSocketCallbackVibeD openSocket, string host, string user, string pwd, string db, ushort port, SvrCapFlags capFlags)

Construct opened connection.

this
this(string cs, SvrCapFlags capFlags)
this(MySQLSocketType socketType, string cs, SvrCapFlags capFlags)
this(OpenSocketCallbackPhobos openSocket, string cs, SvrCapFlags capFlags)
this(OpenSocketCallbackVibeD openSocket, string cs, SvrCapFlags capFlags)

Construct opened connection.

Members

Enums

OpenState
enum OpenState
Undocumented in source.

Functions

acquire
void acquire()
Undocumented in source. Be warned that the author may not have intended to support it.
acquire
void acquire()
Undocumented in source. Be warned that the author may not have intended to support it.
amOwner
bool amOwner()
Undocumented in source. Be warned that the author may not have intended to support it.
amOwner
bool amOwner()
Undocumented in source. Be warned that the author may not have intended to support it.
authenticate
void authenticate(ubyte[] greeting)
Undocumented in source.
buildAuthPacket
ubyte[] buildAuthPacket(ubyte[] token)
Undocumented in source.
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.

connect
void connect(SvrCapFlags clientCapabilities)
Undocumented in source.
consumeServerInfo
void consumeServerInfo(ubyte[] packet)
Undocumented in source. Be warned that the author may not have intended to support it.
enableMultiStatements
void enableMultiStatements(bool on)

Enable multiple statement commands

enforceNothingPending
void enforceNothingPending()
Undocumented in source. Be warned that the author may not have intended to support it.
getCmdResponse
OKErrorPacket getCmdResponse(bool asString)
Undocumented in source. Be warned that the author may not have intended to support it.
getCommonCapabilities
SvrCapFlags getCommonCapabilities(SvrCapFlags server, SvrCapFlags client)
Undocumented in source. Be warned that the author may not have intended to support it.
getNextRow
Row getNextRow()

Get the next Row of a pending result set.

getPacket
ubyte[] getPacket()
Undocumented in source. Be warned that the author may not have intended to support it.
initConnection
void initConnection()
Undocumented in source. Be warned that the author may not have intended to support it.
isOwner
bool isOwner()
Undocumented in source. Be warned that the author may not have intended to support it.
isOwner
bool isOwner()
Undocumented in source. Be warned that the author may not have intended to support it.
kill
void kill()
Undocumented in source. Be warned that the author may not have intended to support it.
makeToken
ubyte[] makeToken(ubyte[] authBuf)
Undocumented in source. Be warned that the author may not have intended to support it.
parseGreeting
ubyte[] parseGreeting()
Undocumented in source. Be warned that the author may not have intended to support it.
pingServer
OKErrorPacket pingServer()

Check the server status

purgeResult
ulong purgeResult()

Flush any outstanding result set elements.

reconnect
void reconnect()
Undocumented in source. Be warned that the author may not have intended to support it.
reconnect
void reconnect(SvrCapFlags clientCapabilities)
Undocumented in source. Be warned that the author may not have intended to support it.
refreshServer
OKErrorPacket refreshServer(RefreshFlags flags)

Refresh some feature(s) of the server.

release
void release()
Undocumented in source. Be warned that the author may not have intended to support it.
release
void release()
Undocumented in source. Be warned that the author may not have intended to support it.
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(const(ubyte)[] packet)
Undocumented in source.
send
void send(const(ubyte)[] header, const(ubyte)[] data)
Undocumented in source.
sendCmd
void sendCmd(CommandType cmd, const(T)[] data)
Undocumented in source.
serverStats
string serverStats()

Get a textual report on the server status.

setClientFlags
void setClientFlags(SvrCapFlags 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

closed
bool closed [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
currentDB
string currentDB [@property getter]

Current database

hasPending
bool hasPending [@property getter]

Gets whether anything (rows, headers or binary) is pending. New commands cannot be sent on a conncection while anything is pending.

lastCommandId
ulong lastCommandId [@property getter]

This gets incremented every time a command is issued or results are purged, so a ResultRange can tell whether it's been invalidated.

lastInsertID
ulong lastInsertID [@property getter]

After a command that inserted a row into a table with an auto-increment ID column, this method allows you to retrieve the last insert ID.

pktNumber
ubyte pktNumber [@property getter]

ordering. First packet should have 0

protocol
ubyte protocol [@property getter]

Return the in-force protocol number

resultFieldDescriptions
FieldDescription[] resultFieldDescriptions [@property getter]

Gets the result header's field descriptions.

rowsPending
bool rowsPending [@property getter]

Gets whether rows are pending

serverCapabilities
uint serverCapabilities [@property getter]

Server capability flags

serverStatus
ushort serverStatus [@property getter]

Server status

serverVersion
string serverVersion [@property getter]

Server version

socketType
MySQLSocketType socketType [@property getter]

Socket type being used

Static functions

defaultOpenSocketPhobos
PlainPhobosSocket defaultOpenSocketPhobos(string host, ushort port)
Undocumented in source. Be warned that the author may not have intended to support it.
defaultOpenSocketVibeD
PlainVibeDSocket defaultOpenSocketVibeD(string host, ushort port)
Undocumented in source. Be warned that the author may not have intended to support it.
parseConnectionString
string[] parseConnectionString(string cs)
_binaryPending
bool _binaryPending;
_cCaps
SvrCapFlags _cCaps;
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

_clientCapabilities
SvrCapFlags _clientCapabilities;
Undocumented in source.
_cpn
ubyte _cpn;

Packet Number in packet header. Serial number to ensure correct

_db
string _db;
Undocumented in source.
_fieldCount
ushort _fieldCount;
_headersPending
bool _headersPending;
Undocumented in source.
_host
string _host;
Undocumented in source.
_insertID
ulong _insertID;
Undocumented in source.
_lastCommandId
ulong _lastCommandId;
Undocumented in source.
_open
OpenState _open;
Undocumented in source.
_openSocketPhobos
OpenSocketCallbackPhobos _openSocketPhobos;
Undocumented in source.
_openSocketVibeD
OpenSocketCallbackVibeD _openSocketVibeD;
Undocumented in source.
_port
ushort _port;
_protocol
ubyte _protocol;
_pwd
string _pwd;
Undocumented in source.
_rowsPending
bool _rowsPending;
Undocumented in source.
_rsh
ResultSetHeaders _rsh;
Undocumented in source.
_sCaps
SvrCapFlags _sCaps;
Undocumented in source.
_sCharSet
ubyte _sCharSet;
Undocumented in source.
_sThread
uint _sThread;
Undocumented in source.
_serverStatus
ushort _serverStatus;
Undocumented in source.
_serverVersion
string _serverVersion;
Undocumented in source.
_socket
MySQLSocket _socket;
Undocumented in source.
_socketType
MySQLSocketType _socketType;
_user
string _user;
Undocumented in source.

Meta