The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

SQLConn Class Reference

SQLConn represents one SQL session. More...

Inheritance diagram for SQLConn:

Inheritance graph
[legend]
Collaboration diagram for SQLConn:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SQLConn (InspIRCd *SI, Module *m, const SQLhost &hi)
 ~SQLConn ()
SQLerror Query (SQLrequest &req)
void ResultReady (MsSQLResult *res, int cols, char **data, char **colnames)
void AffectedReady (MsSQLResult *res)
bool OpenDB ()
void CloseDB ()
SQLhost GetConfHost ()
void SendResults ()
void ClearResults ()
void SendNotify ()
void DoLeadingQuery ()
 SQLConn (InspIRCd *SI, Module *self, const SQLhost &hi)
 ~SQLConn ()
virtual void HandleEvent (EventType et, int errornum)
 Process an I/O event.
bool DoConnect ()
bool DoPoll ()
bool DoConnectedPoll ()
bool DoResetPoll ()
bool OnDataReady ()
bool OnWriteReady ()
bool OnConnected ()
void DelayReconnect ()
bool DoEvent ()
SQLerror DoQuery (SQLrequest &req)
SQLerror Query (const SQLrequest &req)
void OnUnloadModule (Module *mod)
const SQLhost GetConfHost ()
void Close ()
 SQLConn (InspIRCd *SI, Module *m, const SQLhost &hi)
 ~SQLConn ()
SQLerror Query (SQLrequest &req)
void ResultReady (SQLite3Result *res, int cols, char **data, char **colnames)
void AffectedReady (SQLite3Result *res)
int OpenDB ()
void CloseDB ()
SQLhost GetConfHost ()
void SendResults ()
void ClearResults ()
void SendNotify ()

Static Public Member Functions

static int HandleMessage (const TDSCONTEXT *pContext, TDSSOCKET *pTdsSocket, TDSMESSAGE *pMessage)
static int HandleError (const TDSCONTEXT *pContext, TDSSOCKET *pTdsSocket, TDSMESSAGE *pMessage)
static int QueryResult (void *params, int argc, char **argv, char **azColName)
static void QueryUpdateHook (void *params, int eventid, char const *azSQLite, char const *azColName, sqlite_int64 rowid)

Public Attributes

QueryQueue queue

Private Attributes

ResultQueue results
InspIRCdServerInstance
Modulemod
SQLhost host
TDSLOGIN * login
TDSSOCKET * sock
TDSCONTEXT * context
InspIRCdServerInstance
SQLhost confhost
Moduleus
PGconn * sql
SQLstatus status
bool qinprog
time_t idle
InspIRCdServerInstance
Modulemod
sqlite3 * conn

Detailed Description

SQLConn represents one SQL session.

Definition at line 284 of file m_mssql.cpp.


Constructor & Destructor Documentation

SQLConn::SQLConn InspIRCd SI,
Module m,
const SQLhost hi
[inline]
 

Definition at line 298 of file m_mssql.cpp.

References CloseDB(), DEFAULT, host, SQLhost::id, Mutex::Lock(), LogManager::Log(), InspIRCd::Logs, SQLhost::name, OpenDB(), ServerInstance, sock, and Mutex::Unlock().

SQLConn::~SQLConn  )  [inline]
 

Definition at line 331 of file m_mssql.cpp.

References CloseDB().

SQLConn::SQLConn InspIRCd SI,
Module self,
const SQLhost hi
[inline]
 

Definition at line 324 of file m_pgsql.cpp.

References ConvToStr(), DEFAULT, DelayReconnect(), DoConnect(), SQLhost::id, idle, LogManager::Log(), InspIRCd::Logs, ServerInstance, and InspIRCd::Time().

SQLConn::~SQLConn  )  [inline]
 

Definition at line 335 of file m_pgsql.cpp.

References Close().

SQLConn::SQLConn InspIRCd SI,
Module m,
const SQLhost hi
[inline]
 

Definition at line 272 of file m_sqlite3.cpp.

References CloseDB(), DEFAULT, host, SQLhost::id, LogManager::Log(), InspIRCd::Logs, OpenDB(), and ServerInstance.

SQLConn::~SQLConn  )  [inline]
 

Definition at line 282 of file m_sqlite3.cpp.

References CloseDB().


Member Function Documentation

void SQLConn::AffectedReady SQLite3Result res  )  [inline]
 

Definition at line 386 of file m_sqlite3.cpp.

References SQLite3Result::UpdateAffectedCount().

void SQLConn::AffectedReady MsSQLResult res  )  [inline]
 

Definition at line 516 of file m_mssql.cpp.

References MsSQLResult::UpdateAffectedCount().

void SQLConn::ClearResults  )  [inline]
 

Definition at line 428 of file m_sqlite3.cpp.

References results.

void SQLConn::ClearResults  )  [inline]
 

Definition at line 603 of file m_mssql.cpp.

References results.

void SQLConn::Close  )  [inline]
 

Definition at line 688 of file m_pgsql.cpp.

References DEBUG, SocketEngine::DelFd(), LogManager::Log(), InspIRCd::Logs, InspIRCd::SE, ServerInstance, and sql.

Referenced by ~SQLConn().

void SQLConn::CloseDB  )  [inline]
 

Definition at line 396 of file m_sqlite3.cpp.

References conn.

void SQLConn::CloseDB  )  [inline]
 

Definition at line 556 of file m_mssql.cpp.

References context, login, and sock.

Referenced by OpenDB(), SQLConn(), and ~SQLConn().

void SQLConn::DelayReconnect  ) 
 

Definition at line 975 of file m_pgsql.cpp.

References us.

Referenced by DoConnectedPoll(), HandleEvent(), and SQLConn().

bool SQLConn::DoConnect  )  [inline]
 

Definition at line 361 of file m_pgsql.cpp.

References confhost, DEBUG, DoPoll(), EventHandler::fd, SQLhost::GetDSN(), LogManager::Log(), InspIRCd::Logs, ServerInstance, and sql.

Referenced by SQLConn().

bool SQLConn::DoConnectedPoll  )  [inline]
 

Definition at line 411 of file m_pgsql.cpp.

References DelayReconnect(), DoQuery(), SQLresult::error, QueryQueue::front(), Request::GetSource(), SQLerror::Id(), SQLrequest::id, idle, QueryQueue::pop(), SQLquery::q, qinprog, SQLrequest::query, SQLresult::query, queue, Request::Send(), ServerInstance, sql, SQL_QREPLY_FAIL, SQLerror::Str(), InspIRCd::Time(), QueryQueue::totalsize(), and us.

Referenced by DoEvent(), DoPoll(), and DoResetPoll().

bool SQLConn::DoEvent  )  [inline]
 

Definition at line 543 of file m_pgsql.cpp.

References CREAD, CWRITE, DoConnectedPoll(), DoPoll(), DoResetPoll(), RREAD, RWRITE, and status.

Referenced by OnConnected(), OnDataReady(), and OnWriteReady().

void SQLConn::DoLeadingQuery  )  [inline]
 

Definition at line 647 of file m_mssql.cpp.

References SQLrequest::error, QueryQueue::front(), Query(), and queue.

Referenced by QueryThread::Run().

bool SQLConn::DoPoll  )  [inline]
 

Definition at line 390 of file m_pgsql.cpp.

References CREAD, CWRITE, DoConnectedPoll(), InspIRCd::SE, ServerInstance, sql, status, SocketEngine::WantWrite(), and WWRITE.

Referenced by DoConnect(), DoEvent(), and DoResetPoll().

SQLerror SQLConn::DoQuery SQLrequest req  )  [inline]
 

Definition at line 562 of file m_pgsql.cpp.

References DEBUG, LogManager::Log(), InspIRCd::Logs, SQLquery::p, SQLquery::q, qinprog, SQLrequest::query, ServerInstance, sql, SQL_BAD_CONN, SQL_QSEND_FAIL, status, WREAD, and WWRITE.

Referenced by DoConnectedPoll(), and Query().

bool SQLConn::DoResetPoll  )  [inline]
 

Definition at line 503 of file m_pgsql.cpp.

References CREAD, CWRITE, DoConnectedPoll(), DoPoll(), InspIRCd::SE, ServerInstance, sql, status, SocketEngine::WantWrite(), and WWRITE.

Referenced by DoEvent().

SQLhost SQLConn::GetConfHost  )  [inline]
 

Definition at line 402 of file m_sqlite3.cpp.

References host.

const SQLhost SQLConn::GetConfHost  )  [inline]
 

Definition at line 683 of file m_pgsql.cpp.

References confhost.

SQLhost SQLConn::GetConfHost  )  [inline]
 

Definition at line 575 of file m_mssql.cpp.

References host.

static int SQLConn::HandleError const TDSCONTEXT *  pContext,
TDSSOCKET *  pTdsSocket,
TDSMESSAGE *  pMessage
[inline, static]
 

Definition at line 502 of file m_mssql.cpp.

References DEFAULT, host, SQLhost::id, Mutex::Lock(), LogManager::Log(), InspIRCd::Logs, ServerInstance, and Mutex::Unlock().

Referenced by OpenDB().

virtual void SQLConn::HandleEvent EventType  et,
int  errornum
[inline, virtual]
 

Process an I/O event.

You MUST implement this function in your derived class, and it will be called whenever read or write events are received, depending on what your functions Readable() and Writeable() returns and wether you previously made a call to SocketEngine::WantWrite().

Parameters:
et either one of EVENT_READ for read events, and EVENT_WRITE for write events.

Implements EventHandler.

Definition at line 340 of file m_pgsql.cpp.

References DelayReconnect(), EVENT_ERROR, EVENT_READ, EVENT_WRITE, OnDataReady(), and OnWriteReady().

static int SQLConn::HandleMessage const TDSCONTEXT *  pContext,
TDSSOCKET *  pTdsSocket,
TDSMESSAGE *  pMessage
[inline, static]
 

Definition at line 493 of file m_mssql.cpp.

References DEBUG, host, SQLhost::id, Mutex::Lock(), LogManager::Log(), InspIRCd::Logs, ServerInstance, and Mutex::Unlock().

Referenced by OpenDB().

bool SQLConn::OnConnected  )  [inline]
 

Definition at line 536 of file m_pgsql.cpp.

References DoEvent().

bool SQLConn::OnDataReady  )  [inline]
 

Definition at line 524 of file m_pgsql.cpp.

References DoEvent().

Referenced by HandleEvent().

void SQLConn::OnUnloadModule Module mod  )  [inline]
 

Definition at line 678 of file m_pgsql.cpp.

References QueryQueue::PurgeModule(), and queue.

bool SQLConn::OnWriteReady  )  [inline]
 

Definition at line 530 of file m_pgsql.cpp.

References DoEvent().

Referenced by HandleEvent().

int SQLConn::OpenDB  )  [inline]
 

Definition at line 391 of file m_sqlite3.cpp.

References conn, SQLhost::host, and host.

bool SQLConn::OpenDB  )  [inline]
 

Definition at line 521 of file m_mssql.cpp.

References CloseDB(), conn, context, HandleError(), HandleMessage(), SQLhost::host, host, login, SQLhost::pass, SQLhost::port, sock, and SQLhost::user.

Referenced by SQLConn().

SQLerror SQLConn::Query SQLrequest req  )  [inline]
 

Definition at line 287 of file m_sqlite3.cpp.

References conn, SQLresult::dbid, Request::GetSource(), host, SQLhost::id, SQLrequest::id, mod, SQLquery::p, SQLquery::q, SQLresult::query, SQLrequest::query, QueryResult(), QueryUpdateHook(), results, SendNotify(), and SQL_QSEND_FAIL.

SQLerror SQLConn::Query const SQLrequest req  )  [inline]
 

Definition at line 662 of file m_pgsql.cpp.

References DoQuery(), QueryQueue::front(), QueryQueue::push(), qinprog, queue, and QueryQueue::totalsize().

SQLerror SQLConn::Query SQLrequest req  )  [inline]
 

Definition at line 336 of file m_mssql.cpp.

References SQLresult::dbid, DEBUG, Request::GetSource(), host, SQLhost::id, SQLrequest::id, Mutex::Lock(), LogManager::Log(), InspIRCd::Logs, MAXBUF, mod, SQLquery::p, SQLquery::q, SQLresult::query, SQLrequest::query, ResultReady(), results, SendNotify(), ServerInstance, sock, SQL_BAD_CONN, SQL_QSEND_FAIL, Mutex::Unlock(), and MsSQLResult::UpdateAffectedCount().

Referenced by DoLeadingQuery().

static int SQLConn::QueryResult void *  params,
int  argc,
char **  argv,
char **  azColName
[inline, static]
 

Definition at line 368 of file m_sqlite3.cpp.

Referenced by Query().

static void SQLConn::QueryUpdateHook void *  params,
int  eventid,
char const *  azSQLite,
char const *  azColName,
sqlite_int64  rowid
[inline, static]
 

Definition at line 375 of file m_sqlite3.cpp.

Referenced by Query().

void SQLConn::ResultReady SQLite3Result res,
int  cols,
char **  data,
char **  colnames
[inline]
 

Definition at line 381 of file m_sqlite3.cpp.

References SQLite3Result::AddRow().

void SQLConn::ResultReady MsSQLResult res,
int  cols,
char **  data,
char **  colnames
[inline]
 

Definition at line 511 of file m_mssql.cpp.

References MsSQLResult::AddRow().

Referenced by Query().

void SQLConn::SendNotify  )  [inline]
 

Definition at line 438 of file m_sqlite3.cpp.

References AF_FAMILY, SQLiteListener::GetPort(), irc::sockets::insp_aton(), and QueueFD.

void SQLConn::SendNotify  )  [inline]
 

Definition at line 613 of file m_mssql.cpp.

References AF_FAMILY, MsSQLListener::GetPort(), irc::sockets::insp_aton(), and QueueFD.

Referenced by Query().

void SQLConn::SendResults  )  [inline]
 

Definition at line 407 of file m_sqlite3.cpp.

References Request::GetDest(), results, and Request::Send().

void SQLConn::SendResults  )  [inline]
 

Definition at line 580 of file m_mssql.cpp.

References Request::GetDest(), Mutex::Lock(), results, Request::Send(), and Mutex::Unlock().


Member Data Documentation

SQLhost SQLConn::confhost [private]
 

Definition at line 315 of file m_pgsql.cpp.

Referenced by DoConnect(), and GetConfHost().

sqlite3* SQLConn::conn [private]
 

Definition at line 269 of file m_sqlite3.cpp.

Referenced by CloseDB(), OpenDB(), and Query().

TDSCONTEXT* SQLConn::context [private]
 

Definition at line 293 of file m_mssql.cpp.

Referenced by CloseDB(), and OpenDB().

SQLhost SQLConn::host [private]
 

Definition at line 290 of file m_mssql.cpp.

Referenced by GetConfHost(), HandleError(), HandleMessage(), OpenDB(), Query(), and SQLConn().

time_t SQLConn::idle [private]
 

Definition at line 321 of file m_pgsql.cpp.

Referenced by DoConnectedPoll(), and SQLConn().

TDSLOGIN* SQLConn::login [private]
 

Definition at line 291 of file m_mssql.cpp.

Referenced by CloseDB(), and OpenDB().

Module* SQLConn::mod [private]
 

Definition at line 267 of file m_sqlite3.cpp.

Module* SQLConn::mod [private]
 

Definition at line 289 of file m_mssql.cpp.

Referenced by Query().

bool SQLConn::qinprog [private]
 

Definition at line 319 of file m_pgsql.cpp.

Referenced by DoConnectedPoll(), DoQuery(), and Query().

QueryQueue SQLConn::queue
 

Definition at line 296 of file m_mssql.cpp.

Referenced by DoConnectedPoll(), DoLeadingQuery(), OnUnloadModule(), Query(), and QueryThread::Run().

ResultQueue SQLConn::results [private]
 

Definition at line 287 of file m_mssql.cpp.

Referenced by ClearResults(), Query(), and SendResults().

InspIRCd* SQLConn::ServerInstance [private]
 

Definition at line 266 of file m_sqlite3.cpp.

InspIRCd* SQLConn::ServerInstance [private]
 

Definition at line 314 of file m_pgsql.cpp.

InspIRCd* SQLConn::ServerInstance [private]
 

Definition at line 288 of file m_mssql.cpp.

Referenced by Close(), DoConnect(), DoConnectedPoll(), DoPoll(), DoQuery(), DoResetPoll(), HandleError(), HandleMessage(), Query(), and SQLConn().

TDSSOCKET* SQLConn::sock [private]
 

Definition at line 292 of file m_mssql.cpp.

Referenced by CloseDB(), OpenDB(), Query(), and SQLConn().

PGconn* SQLConn::sql [private]
 

Definition at line 317 of file m_pgsql.cpp.

Referenced by Close(), DoConnect(), DoConnectedPoll(), DoPoll(), DoQuery(), and DoResetPoll().

SQLstatus SQLConn::status [private]
 

Definition at line 318 of file m_pgsql.cpp.

Referenced by DoEvent(), DoPoll(), DoQuery(), and DoResetPoll().

Module* SQLConn::us [private]
 

Definition at line 316 of file m_pgsql.cpp.

Referenced by DelayReconnect(), and DoConnectedPoll().


The documentation for this class was generated from the following files: