32 #ifndef _INCLUDE_SOURCEMOD_INTERFACE_DBDRIVER_H_
33 #define _INCLUDE_SOURCEMOD_INTERFACE_DBDRIVER_H_
44 #define SMINTERFACE_DBI_NAME "IDBI"
45 #define SMINTERFACE_DBI_VERSION 9
55 DBVal_TypeMismatch = 1,
100 virtual DBResult
GetString(
unsigned int columnId,
const char **pString,
size_t *length) =0;
114 virtual DBResult
CopyString(
unsigned int columnId,
128 virtual DBResult
GetFloat(
unsigned int columnId,
float *pFloat) =0;
139 virtual DBResult
GetInt(
unsigned int columnId,
int *pInt) =0;
147 virtual bool IsNull(
unsigned int columnId) =0;
164 virtual size_t GetDataSize(
unsigned int columnId) =0;
176 virtual DBResult
GetBlob(
unsigned int columnId,
const void **pData,
size_t *length) =0;
189 virtual DBResult
CopyBlob(
unsigned int columnId,
void *buffer,
size_t maxlength,
size_t *written) =0;
229 virtual bool FieldNameToNum(
const char *name,
unsigned int *columnId) =0;
342 virtual bool BindParamInt(
unsigned int param,
int num,
bool signd=
true) =0;
371 virtual bool BindParamString(
unsigned int param,
const char *text,
bool copy) =0;
403 virtual const char *
GetError(
int *errCode=NULL) =0;
441 virtual bool Close() =0;
452 virtual const char *
GetError(
int *errorCode=NULL) =0;
505 virtual bool QuoteString(
const char *str,
char buffer[],
size_t maxlen,
size_t *newSize) =0;
611 #if !defined(SOURCEMOD_SQL_DRIVER_CODE)
655 virtual unsigned int GetDBIVersion()
657 return SMINTERFACE_DBI_VERSION;
754 virtual IdentityToken_t *
GetOwner() =0;
791 DBHandle_Database = 1,
840 virtual bool Connect(
const char *name,
845 size_t maxlength) =0;
871 virtual Handle_t
CreateHandle(DBHandleType type,
void *ptr, IdentityToken_t *pToken) =0;
882 virtual HandleError
ReadHandle(Handle_t hndl, DBHandleType type,
void **ptr) =0;
892 virtual HandleError
ReleaseHandle(Handle_t hndl, DBHandleType type, IdentityToken_t *token) =0;
931 #endif //_INCLUDE_SOURCEMOD_INTERFACE_DBDRIVER_H_
virtual unsigned int GetInsertID()=0
Retrieves the last insert ID on this database connection.
virtual HandleError ReadHandle(Handle_t hndl, DBHandleType type, void **ptr)=0
Reads an IDBDriver pointer from an IDBDriver handle. Not thread safe.
virtual void RemoveDriver(IDBDriver *pDriver)=0
Removes a driver from the DBI system. Not thread safe.
virtual void AddDriver(IDBDriver *pDriver)=0
Adds a driver to the DBI system. Not thread safe.
virtual DBResult GetString(unsigned int columnId, const char **pString, size_t *length)=0
Retrieves a database field result as a string.
virtual unsigned int GetInsertIDForQuery(IQuery *query)=0
Retrieves the last insert id of the given query.
virtual bool LockForFullAtomicOperation()=0
Locks the database for an atomic query+retrieval operation.
virtual bool FieldNameToNum(const char *name, unsigned int *columnId)=0
Converts a column name to a column id.
Defines the interface for creating, reading, and removing Handles.
virtual DBResult CopyBlob(unsigned int columnId, void *buffer, size_t maxlength, size_t *written)=0
Copies field data as a raw bitstream.
Describes database connection info.
Definition: IDBDriver.h:631
unsigned int port
Definition: IDBDriver.h:645
virtual IResultRow * FetchRow()=0
Returns a pointer to the current row and advances the internal row pointer/counter to the next row av...
virtual const char * GetInterfaceName()=0
Must return a string defining the interface's unique name.
virtual void ShutdownThreadSafety()=0
Shuts down thread safety for the calling thread.
virtual unsigned int GetInsertID()=0
Retrieves the last insert ID on this database connection.
Represents a one database result row.
Definition: IDBDriver.h:85
virtual unsigned int GetDriverCount()=0
Returns the number of drivers loaded. Not thread safe.
virtual void IncReferenceCount()=0
Increases the reference count on the database.
virtual const char * GetIdentifier()=0
Returns a case insensitive database identifier string.
virtual IQuery * DoQuery(const char *query)=0
Prepares and executes a query in one step, and returns the resultant data set.
Defines the Share System, responsible for shared resources and dependencies.
virtual IDatabase * Connect(const DatabaseInfo *info, bool persistent, char *error, size_t maxlength)=0
Initiates a database connection.
virtual Handle_t GetHandle()=0
Retrieves a Handle_t handle of the IDBDriver type.
const char * driver
Definition: IDBDriver.h:644
virtual unsigned int GetRowCount()=0
Returns the number of rows in the set.
virtual void Destroy()=0
Called when the operation is finalized and any resources can be released.
virtual unsigned int GetInterfaceVersion()=0
Must return an integer defining the interface's version.
virtual IResultSet * GetResultSet()=0
Returns a pointer to the current result set, if any.
Defines the base functionality required by a shared interface.
Definition: IShareSys.h:92
virtual IResultRow * CurrentRow()=0
Returns a pointer to the current row.
virtual bool BindParamString(unsigned int param, const char *text, bool copy)=0
Binds a string as a parameter.
virtual HandleError ReleaseHandle(Handle_t hndl, DBHandleType type, IdentityToken_t *token)=0
Releases an IDBDriver handle.
Encapsulates a database connection.
Definition: IDBDriver.h:425
Definition: IDBDriver.h:286
virtual bool BindParamBlob(unsigned int param, const void *data, size_t length, bool copy)=0
Binds a blob of raw data as a parameter.
virtual void Destroy()=0
Frees resources created by this query.
const char * database
Definition: IDBDriver.h:641
virtual IDBDriver * FindOrLoadDriver(const char *driver)=0
Given a driver name, attempts to find it. If it is not found, SourceMod will attempt to load it...
virtual unsigned int GetAffectedRows()=0
Number of rows affected by the last execute.
virtual IdentityToken_t * GetOwner()=0
Must return the object owning this threaded operation. This is never called inside the thread...
virtual DBType GetFieldDataType(unsigned int field)=0
Returns a field's type as it will be interpreted by the GetDataSize() function. For example...
virtual IPreparedQuery * PrepareQuery(const char *query, char *error, size_t maxlength, int *errCode=NULL)=0
Prepares a query statement for multiple executions and/or binding marked parameters (...
virtual bool BindParamFloat(unsigned int param, float f)=0
Binds a float parameter.
virtual bool SetCharacterSet(const char *characterset)=0
Sets the character set of the current connection.
void Release()
Wrapper around Close(), for ke::Ref.
Definition: IDBDriver.h:622
virtual bool AddToThreadQueue(IDBThreadOperation *op, PrioQueueLevel prio)=0
Adds a threaded database operation to the priority queue. This function is not thread safe...
virtual bool MoreRows()=0
Returns if there is still data in the result set.
virtual bool Connect(const char *name, IDBDriver **pdr, IDatabase **pdb, bool persistent, char *error, size_t maxlength)=0
Tries to connect to a named database. Not thread safe.
unsigned int maxTimeout
Definition: IDBDriver.h:646
virtual void RunThinkPart()=0
Called in a server frame after the thread operation has completed. This is the non-threaded completio...
virtual const char * FieldNumToName(unsigned int columnId)=0
Converts a column number to a column name.
void AddRef()
Wrapper around IncReferenceCount(), for ke::Ref.
Definition: IDBDriver.h:615
virtual DBResult GetFloat(unsigned int columnId, float *pFloat)=0
Retrieves a database field result as a float.
virtual size_t GetDataSize(unsigned int columnId)=0
Returns the size of a field (text/raw/blob) in bytes. For strings, this returned size will not includ...
virtual void UnlockFromFullAtomicOperation()=0
Unlocks a locked atomic fetch.
const char * host
Definition: IDBDriver.h:640
virtual bool QuoteString(const char *str, char buffer[], size_t maxlen, size_t *newSize)=0
virtual Handle_t CreateHandle(DBHandleType type, void *ptr, IdentityToken_t *pToken)=0
Creates a Handle_t of the IDBDriver type. Not thread safe.
virtual void RunThreadPart()=0
Called inside the thread; this is where any blocking or threaded operations must occur.
Describes the DBI manager.
Definition: IDBDriver.h:797
Describes an SQL driver.
Definition: IDBDriver.h:652
virtual bool DoSimpleQueryEx(const char *query, size_t len)=0
Prepares and executes a binary query in one step, and discards any return data.
virtual bool IsThreadSafe()=0
Returns whether the driver is thread safe.
Definition: IDBDriver.h:330
virtual bool Rewind()=0
Rewinds back to the beginning of the row iteration.
const char * user
Definition: IDBDriver.h:642
virtual DBResult CopyString(unsigned int columnId, char *buffer, size_t maxlength, size_t *written)=0
Retrieves a database field result as a string, using a user-supplied buffer. If the field is NULL...
IExtension * myself
Definition: smsdk_ext.cpp:41
virtual unsigned int GetAffectedRowsForQuery(IQuery *query)=0
Retrieves the number of affected rows from the last execute of the given query.
virtual unsigned int GetAffectedRows()=0
Number of rows affected by the last execute.
Definition: IAdminSystem.h:63
unsigned int dbiVersion
Definition: IDBDriver.h:639
virtual bool DoSimpleQuery(const char *query)=0
Prepares and executes a query in one step, and discards any return data.
Encapsulates an IExtensionInterface and its dependencies.
Definition: IExtensionSys.h:53
virtual IQuery * DoQueryEx(const char *query, size_t len)=0
Prepares and executes a binary query in one step, and returns the resultant data set.
virtual DBResult GetBlob(unsigned int columnId, const void **pData, size_t *length)=0
Retrieves field data as a raw bitstream. The pointer returned will become invalid after advancing to ...
virtual bool BindParamNull(unsigned int param)=0
Binds an SQL NULL type as a parameter.
virtual bool Close()=0
Disconnects the database and frees its associated memory. Note that the actual object will not be fre...
Describes a set of database results.
Definition: IDBDriver.h:195
virtual const char * GetError(int *errCode=NULL)=0
Returns the last error message from this statement.
virtual const char * GetProductName()=0
Returns a case sensitive implementation name.
virtual bool Execute()=0
Executes the query with the currently bound parameters.
virtual IDBDriver * GetDefaultDriver()=0
Returns the default driver, or NULL if none is set. This function is not thread safe.
virtual bool IsNull(unsigned int columnId)=0
Returns whether or not a field is NULL.
virtual DBResult GetInt(unsigned int columnId, int *pInt)=0
Retrieves a database field result as an integer.
virtual DBType GetFieldType(unsigned int field)=0
Returns a field's type as it should be interpreted by the user.
virtual IDBDriver * GetDriver()=0
Must return the driver this operation is using, or NULL if not using any driver. This is not never in...
virtual IDBDriver * GetDriver(unsigned int index)=0
Returns a driver by index. Not thread safe.
virtual const DatabaseInfo * FindDatabaseConf(const char *name)=0
Searches for database info by name. Both the return pointer and all pointers contained therein should...
virtual IdentityToken_t * GetIdentity()=0
Returns the driver's controlling identity (must be the same as from IExtension::GetIdentity).
virtual bool InitializeThreadSafety()=0
Initializes thread safety for the calling thread.
virtual void AddDependency(IExtension *myself, IDBDriver *driver)=0
Adds a dependency from one extension to the owner of a driver.
virtual bool BindParamInt(unsigned int param, int num, bool signd=true)=0
Binds an integer parameter.
virtual unsigned int GetFieldCount()=0
Returns the number of fields in the set.
virtual bool FetchMoreResults()=0
Advances to the next result set if one exists. This is for checking for MORE result sets...
virtual const char * GetError(int *errorCode=NULL)=0
Error code and string returned by the last operation on this connection.
Definition: IDBDriver.h:736
const char * pass
Definition: IDBDriver.h:643
virtual void CancelThinkPart()=0
If RunThinkPart() is not called, this will be called instead. Note that RunThreadPart() is ALWAYS cal...
virtual IDBDriver * GetDriver()=0
Returns the parent driver.