-/** SQLConn represents one SQL session.
- * Each session has its own persistent connection to the database.
- * This is a subclass of InspSocket so it can easily recieve read/write events from the core socket
- * engine, unlike the original MySQL module this module does not block. Ever. It gets a mild stabbing
- * if it dares to.
- */
-
-class SQLConn : public InspSocket
-{
-private:
- SQLhost confhost; /* The <database> entry */
- Module* us; /* Pointer to the SQL provider itself */
- PGconn* sql; /* PgSQL database connection handle */
- SQLstatus status; /* PgSQL database connection status */
- bool qinprog; /* If there is currently a query in progress */
- QueryQueue queue; /* Queue of queries waiting to be executed on this connection */
- time_t idle; /* Time we last heard from the database */
-public:
-
- /* This class should only ever be created inside this module, using this constructor, so we don't have to worry about the default ones */
-
- SQLConn(InspIRCd* SI, Module* self, const SQLhost& hostinfo);
-
- ~SQLConn();
-
- bool DoConnect();
-
- virtual void Close();
-
- void DoClose();
-
- bool DoPoll();
-
- bool DoConnectedPoll();
-
- bool DoResetPoll();
-
- void ShowStatus();
-
- virtual bool OnDataReady();
-
- virtual bool OnWriteReady();
-
- virtual bool OnConnected();
-
- bool DoEvent();
-
- bool Reconnect();
-
- const char* StatusStr();
-
- SQLerror DoQuery(SQLrequest &req);
-
- SQLerror Query(const SQLrequest &req);
-
- void OnUnloadModule(Module* mod);
-
- const SQLhost GetConfHost();
-};
-
-SQLConn::SQLConn(InspIRCd* SI, Module* self, const SQLhost& hi)
-: InspSocket::InspSocket(SI), confhost(hi), us(self), sql(NULL), status(CWRITE), qinprog(false)
-{
- idle = this->Instance->Time();
- this->ClosePending = false;
-
- if(!this->DoConnect())
- {
- Instance->Log(DEFAULT, "WARNING: Could not connect to database with id: " + ConvToStr(hi.id));
- }
-}