IStmtCacheConnection Class Referenceabstract

#include <Pt/Db/IConnection.h>

Connection backend with a prepared-statement cache.

Inherits IConnection.

Public Member Functions

virtual Statement prepareCached (const std::string &query)
 Compiles query and caches the prepared statement.
virtual void clearStatementCache ()
 Clears the prepared-statement cache.
virtual void beginPrepareCached (const std::string &query)
 Starts asynchronous prepare with cache lookup.
virtual Statement endPrepareCached ()
 Completes asynchronous prepareCached.
void setActive (Pt::System::EventLoop *loop)
 Attaches loop for asynchronous operations, or 0 to detach.
bool ping ()
 Returns true if the backend still answers.
void beginPing ()
 Starts an asynchronous ping.
bool endPing ()
 Completes an asynchronous ping.
Pt::SignalpingFinished ()
 Signal emitted when an asynchronous ping completes.
long long lastInsertId (const std::string &name)
 Returns the last generated row id.
bool isIdle () const
 Returns true if no asynchronous operation is pending.
bool hasTransaction () const
 Returns true if a transaction is active.
void open (const std::string &connStr)
 Opens the database with connStr.
void close ()
 Closes the database and cancels any pending operation.
void beginClose ()
 Starts an asynchronous close.
void endClose ()
 Completes an asynchronous close.
Pt::SignalcloseFinished ()
 Signal emitted when an asynchronous close completes.
bool isOpen () const
 Returns true if the database is open.
void beginOpen (const std::string &connStr)
 Starts an asynchronous open with connStr.
void endOpen ()
 Completes an asynchronous open.
Pt::SignalopenFinished ()
 Signal emitted when an asynchronous open completes.
void startTransaction (const char *sql=nullptr)
 Begins a transaction with optional sql.
void commitTransaction (const char *sql=nullptr)
 Commits the active transaction with optional sql.
void rollbackTransaction (const char *sql=nullptr)
 Rolls back the active transaction with optional sql.
void beginStartTransaction (Transaction &txn, const char *sql)
 Starts an asynchronous begin-transaction.
void endStartTransaction ()
 Completes an asynchronous begin-transaction.
void beginCommitTransaction (Transaction &txn, const char *sql)
 Starts an asynchronous commit.
void endCommitTransaction ()
 Completes an asynchronous commit.
void beginRollbackTransaction (Transaction &txn, const char *sql)
 Starts an asynchronous rollback.
void endRollbackTransaction ()
 Completes an asynchronous rollback.
size_type execute (const std::string &query)
 Executes query and returns the number of rows changed.
size_type execute (IStatement &stmt)
 Executes stmt and returns the number of rows changed.
void beginExecute (const std::string &sql)
 Starts asynchronous execution of sql.
void beginExecute (IStatement &stmt)
 Starts asynchronous execution of stmt.
size_type endExecute ()
 Completes asynchronous execution.
size_type endExecute (IStatement &stmt)
 Completes asynchronous execution of stmt.
Pt::SignalexecuteFinished ()
 Signal emitted when asynchronous execution completes.
Statement prepare (const std::string &query)
 Compiles query into a prepared statement.
Pt::SignalprepareCachedFinished ()
 Signal emitted when asynchronous prepareCached completes.
void beginPrepare (const std::string &query)
 Starts asynchronous compile of query.
Statement endPrepare ()
 Completes asynchronous compile.
Pt::SignalprepareFinished ()
 Signal emitted when asynchronous prepare completes.
Result select (const std::string &query)
 Executes query and returns a buffered result.
Result select (IStatement &stmt)
 Executes stmt and returns a buffered result.
void beginSelect (const std::string &sql)
 Starts an asynchronous select of sql.
void beginSelect (IStatement &stmt)
 Starts an asynchronous select of stmt.
Result endSelect ()
 Completes an asynchronous select.
Result endSelect (IStatement &stmt)
 Completes an asynchronous select of stmt.
Pt::SignalselectFinished ()
 Signal emitted when an asynchronous select completes.
Row selectRow (IStatement &stmt)
 Executes stmt and returns the first row.
Value selectValue (IStatement &stmt)
 Executes stmt and returns the first column of the first row.
Cursor getCursor (IStatement &stmt, size_type batchSize)
 Opens a batch cursor on stmt.
Result fetchBatch (ICursor &cursor, size_type batchSize)
 Fetches the next batch from cursor.
void beginBatchFetch (ICursor &cursor, size_type batchSize)
 Starts an asynchronous batch fetch from cursor.
Result endBatchFetch (ICursor &cursor)
 Completes an asynchronous batch fetch from cursor.
void cancelCursor (ICursor &cursor)
 Cancels a pending fetch on cursor.
void cancelStatement (IStatement &stmt)
 Cancels a pending operation on stmt.

Protected Member Functions

void cancelPending () noexcept
 Cancels any pending asynchronous operation. Never throws.
void cancelConnection () noexcept
 Cancels a pending connection-level asynchronous operation.

Member Function Documentation

◆ endPing()

bool endPing ( )
inherited
Returns
True if the backend still answers.

◆ lastInsertId()

long long lastInsertId ( const std::string & name)
inherited

Pass a sequence name on backends that use named sequences, or an empty string otherwise.