HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_SqliteDriver Class Referencefinal

#include <UT_SQL.h>

+ Inheritance diagram for UT_SqliteDriver:

Public Member Functions

 UT_SqliteDriver ()
 
 ~UT_SqliteDriver () override
 
 UT_NON_COPYABLE (UT_SqliteDriver)
 
void setDatabaseName (const UT_StringHolder &db_name) override
 
void setConnectOptions (const UT_Options &options) override
 
bool connect (UT_ErrorCode *ec=nullptr) override
 
bool close (UT_ErrorCode *ec=nullptr) override
 
NO_DISCARD SYS_FORCE_INLINE bool isValid () const override
 
NO_DISCARD bool isReadOnly (const char *db="main", UT_ErrorCode *ec=nullptr) const override
 
NO_DISCARD voidnativeAPI () override
 
NO_DISCARD voidnativeAPI () const override
 
NO_DISCARD int dataVersion (UT_ErrorCode *ec=nullptr) const
 
NO_DISCARD int userVersion (UT_ErrorCode *ec=nullptr) const
 
void setUserVersion (int version, UT_ErrorCode *ec=nullptr) const
 
NO_DISCARD bool tableExists (const UT_StringRef &name, UT_ErrorCode *ec=nullptr) const override
 Check if the specified table exists. More...
 
NO_DISCARD bool indexExists (const UT_StringRef &name, UT_ErrorCode *ec=nullptr) const override
 
NO_DISCARD bool viewExists (const UT_StringRef &name, UT_ErrorCode *ec=nullptr) const override
 
NO_DISCARD bool columnExists (const UT_StringRef &table_name, const UT_StringRef &column_name, UT_ErrorCode *ec=nullptr) const override
 
NO_DISCARD UT_StringHolder errorMessage () const override
 
NO_DISCARD int errorCode () const override
 
NO_DISCARD int extendedErrorCode () const override
 
NO_DISCARD UT_StringHolder getSchema (UT_ErrorCode *ec=nullptr) const override
 
void setBusyTimeout (int timeout_ms)
 
bool copyTo (UT_SqliteDriver &destination, UT_ErrorCode *ec=nullptr) const
 
UT_SharedPtr< UT_SqlStatementImplcreateStatementImpl () override
 
UT_SharedPtr< UT_SqlStatementImplcreateStatementImpl () const override
 
UT_SharedPtr< UT_SqlStatementImplcachedStatement (const UT_SqlStatementHandleId &id, const UT_StringRef &sql, UT_ErrorCode *ec=nullptr) const override
 
UT_SharedPtr< UT_SqlStatementImplfindCachedStatement (const UT_SqlStatementHandleId &id) const override
 
bool startTransaction (UT_ErrorCode *ec=nullptr) override
 
bool endTransaction (bool commit, UT_ErrorCode *ec=nullptr) override
 
int exec (const UT_StringRef &sql, UT_ErrorCode *ec=nullptr) const override
 Returns the number of rows modified, inserted or deleted. More...
 
- Public Member Functions inherited from UT_SqlBaseDriver
virtual ~UT_SqlBaseDriver ()=default
 
 UT_NON_COPYABLE (UT_SqlBaseDriver)
 
virtual void setHostName (const UT_StringHolder &host)
 
virtual void setPort (int port)
 
virtual void setUserName (const UT_StringHolder &user)
 
virtual void setPassword (const UT_StringHolder &password)
 
template<typename... Args>
bool run (UT_ErrorCode *ec, const UT_StringRef &sql, Args &&...args)
 Helper function to run an sql statement with provided typed args. More...
 

Static Public Attributes

static constexpr UT_StringLit theFilenameOpt = "SQLITE_FILENAME"
 
static constexpr UT_StringLit theBusyTimeoutOpt = "SQLITE_BUSY_TIMEOUT"
 

Protected Member Functions

bool schemaItemExists (const UT_StringRef &type, const UT_StringRef &name, UT_ErrorCode *ec) const
 
- Protected Member Functions inherited from UT_SqlBaseDriver
 UT_SqlBaseDriver ()=default
 

Detailed Description

Definition at line 994 of file UT_SQL.h.

Constructor & Destructor Documentation

UT_SqliteDriver::UT_SqliteDriver ( )
UT_SqliteDriver::~UT_SqliteDriver ( )
override

Member Function Documentation

UT_SharedPtr<UT_SqlStatementImpl> UT_SqliteDriver::cachedStatement ( const UT_SqlStatementHandleId id,
const UT_StringRef sql,
UT_ErrorCode ec = nullptr 
) const
overridevirtual

Get a sql statement that is retrieved from the cache. If the statement is not already cached then its compiled and then cached if the compiled statement is valid.

Implements UT_SqlBaseDriver.

bool UT_SqliteDriver::close ( UT_ErrorCode ec = nullptr)
overridevirtual

Implements UT_SqlBaseDriver.

NO_DISCARD bool UT_SqliteDriver::columnExists ( const UT_StringRef table_name,
const UT_StringRef column_name,
UT_ErrorCode ec = nullptr 
) const
overridevirtual

Implements UT_SqlBaseDriver.

bool UT_SqliteDriver::connect ( UT_ErrorCode ec = nullptr)
overridevirtual

Implements UT_SqlBaseDriver.

bool UT_SqliteDriver::copyTo ( UT_SqliteDriver destination,
UT_ErrorCode ec = nullptr 
) const

Copy the contents of this database into the provided destination database. Return true on success and false otherwise. On failure, the error code is set in the destination database.

UT_SharedPtr<UT_SqlStatementImpl> UT_SqliteDriver::createStatementImpl ( )
overridevirtual

Implements UT_SqlBaseDriver.

UT_SharedPtr<UT_SqlStatementImpl> UT_SqliteDriver::createStatementImpl ( ) const
overridevirtual

Implements UT_SqlBaseDriver.

NO_DISCARD int UT_SqliteDriver::dataVersion ( UT_ErrorCode ec = nullptr) const

Check the database's "data_version" (see https://www.sqlite.org/pragma.html#pragma_data_version)

bool UT_SqliteDriver::endTransaction ( bool  commit,
UT_ErrorCode ec = nullptr 
)
overridevirtual

Implements UT_SqlBaseDriver.

NO_DISCARD int UT_SqliteDriver::errorCode ( ) const
overridevirtual

Implements UT_SqlBaseDriver.

NO_DISCARD UT_StringHolder UT_SqliteDriver::errorMessage ( ) const
overridevirtual

Implements UT_SqlBaseDriver.

int UT_SqliteDriver::exec ( const UT_StringRef sql,
UT_ErrorCode ec = nullptr 
) const
overridevirtual

Returns the number of rows modified, inserted or deleted.

Implements UT_SqlBaseDriver.

NO_DISCARD int UT_SqliteDriver::extendedErrorCode ( ) const
overridevirtual

Implements UT_SqlBaseDriver.

UT_SharedPtr<UT_SqlStatementImpl> UT_SqliteDriver::findCachedStatement ( const UT_SqlStatementHandleId id) const
overridevirtual

Find an sql handle based on its id. The sql statement must have already been added from cachedStatement(). This method is typically used when a statement has already been compiled and added to the cache but needs to be dynamically looked up some time later.

Implements UT_SqlBaseDriver.

NO_DISCARD UT_StringHolder UT_SqliteDriver::getSchema ( UT_ErrorCode ec = nullptr) const
overridevirtual

Implements UT_SqlBaseDriver.

NO_DISCARD bool UT_SqliteDriver::indexExists ( const UT_StringRef name,
UT_ErrorCode ec = nullptr 
) const
overridevirtual

Implements UT_SqlBaseDriver.

NO_DISCARD bool UT_SqliteDriver::isReadOnly ( const char *  db = "main",
UT_ErrorCode ec = nullptr 
) const
overridevirtual

Implements UT_SqlBaseDriver.

NO_DISCARD SYS_FORCE_INLINE bool UT_SqliteDriver::isValid ( ) const
inlineoverridevirtual

Implements UT_SqlBaseDriver.

Definition at line 1014 of file UT_SQL.h.

NO_DISCARD void* UT_SqliteDriver::nativeAPI ( )
inlineoverridevirtual

Implements UT_SqlBaseDriver.

Definition at line 1020 of file UT_SQL.h.

NO_DISCARD void* UT_SqliteDriver::nativeAPI ( ) const
inlineoverridevirtual

Implements UT_SqlBaseDriver.

Definition at line 1021 of file UT_SQL.h.

bool UT_SqliteDriver::schemaItemExists ( const UT_StringRef type,
const UT_StringRef name,
UT_ErrorCode ec 
) const
protected
void UT_SqliteDriver::setBusyTimeout ( int  timeout_ms)
inline

This sets a busy handler that sleeps for a specified amount of time when a table is locked. The handler will sleep multiple times until at least milliseconds of sleeping have accumulated. After the timeout the handler returns 0 which causes the step() to return kSQLITE_BUSY.

Definition at line 1056 of file UT_SQL.h.

void UT_SqliteDriver::setConnectOptions ( const UT_Options options)
overridevirtual

Reimplemented from UT_SqlBaseDriver.

void UT_SqliteDriver::setDatabaseName ( const UT_StringHolder db_name)
inlineoverridevirtual

Reimplemented from UT_SqlBaseDriver.

Definition at line 1005 of file UT_SQL.h.

void UT_SqliteDriver::setUserVersion ( int  version,
UT_ErrorCode ec = nullptr 
) const
bool UT_SqliteDriver::startTransaction ( UT_ErrorCode ec = nullptr)
overridevirtual

These are primarily used by UT_SqlTransaction (but can be used by any client code) and provide an abstraction that resembles nested transations. This is inspired by (and follows the same behaviour as): https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase#beginTransaction()

Implements UT_SqlBaseDriver.

NO_DISCARD bool UT_SqliteDriver::tableExists ( const UT_StringRef name,
UT_ErrorCode ec = nullptr 
) const
overridevirtual

Check if the specified table exists.

Implements UT_SqlBaseDriver.

NO_DISCARD int UT_SqliteDriver::userVersion ( UT_ErrorCode ec = nullptr) const

Get/set the database's "user_version" (see https://www.sqlite.org/pragma.html#pragma_user_version)

UT_SqliteDriver::UT_NON_COPYABLE ( UT_SqliteDriver  )
NO_DISCARD bool UT_SqliteDriver::viewExists ( const UT_StringRef name,
UT_ErrorCode ec = nullptr 
) const
overridevirtual

Implements UT_SqlBaseDriver.

Member Data Documentation

constexpr UT_StringLit UT_SqliteDriver::theBusyTimeoutOpt = "SQLITE_BUSY_TIMEOUT"
static

Definition at line 998 of file UT_SQL.h.

constexpr UT_StringLit UT_SqliteDriver::theFilenameOpt = "SQLITE_FILENAME"
static

Definition at line 997 of file UT_SQL.h.


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