diff options
Diffstat (limited to 'src/common/sql.h')
-rw-r--r-- | src/common/sql.h | 33 |
1 files changed, 4 insertions, 29 deletions
diff --git a/src/common/sql.h b/src/common/sql.h index c3598273e..fc1562347 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -5,9 +5,9 @@ #ifndef COMMON_SQL_H #define COMMON_SQL_H -#include <stdarg.h>// va_list +#include "common/hercules.h" -#include "../common/cbasetypes.h" +#include <stdarg.h>// va_list // Return codes #define SQL_ERROR (-1) @@ -142,8 +142,6 @@ struct sql_interface { /// Allocates and initializes a new Sql handle. struct Sql *(*Malloc) (void); - - /////////////////////////////////////////////////////////////////////////////// // Prepared Statements /////////////////////////////////////////////////////////////////////////////// @@ -157,7 +155,6 @@ struct sql_interface { // 1) SELECT col FROM table WHERE id=? // 2) INSERT INTO table(col1,col2) VALUES(?,?) - /*===================================== SQL Statement interface [Susu] *-------------------------------------*/ @@ -169,8 +166,6 @@ struct sql_interface { /// @return SqlStmt handle or NULL if an error occurred struct SqlStmt* (*StmtMalloc)(Sql* sql); - - /// Prepares the statement. /// Any previous result is freed and all parameter bindings are removed. /// The query is constructed as if it was sprintf. @@ -185,8 +180,6 @@ struct sql_interface { /// @return SQL_SUCCESS or SQL_ERROR int (*StmtPrepareV)(SqlStmt* self, const char* query, va_list args); - - /// Prepares the statement. /// Any previous result is freed and all parameter bindings are removed. /// The query is used directly. @@ -194,15 +187,11 @@ struct sql_interface { /// @return SQL_SUCCESS or SQL_ERROR int (*StmtPrepareStr)(SqlStmt* self, const char* query); - - /// Returns the number of parameters in the prepared statement. /// /// @return Number or parameters size_t (*StmtNumParams)(SqlStmt* self); - - /// Binds a parameter to a buffer. /// The buffer data will be used when the statement is executed. /// All parameters should have bindings. @@ -210,30 +199,22 @@ struct sql_interface { /// @return SQL_SUCCESS or SQL_ERROR int (*StmtBindParam)(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len); - - /// Executes the prepared statement. /// Any previous result is freed and all column bindings are removed. /// /// @return SQL_SUCCESS or SQL_ERROR int (*StmtExecute)(SqlStmt* self); - - /// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE statement. /// /// @return Value of the auto-increment column uint64 (*StmtLastInsertId)(SqlStmt* self); - - /// Returns the number of columns in each row of the result. /// /// @return Number of columns size_t (*StmtNumColumns)(SqlStmt* self); - - /// Binds the result of a column to a buffer. /// The buffer will be filled with data when the next row is fetched. /// For string/enum buffer types there has to be enough space for the data @@ -242,23 +223,17 @@ struct sql_interface { /// @return SQL_SUCCESS or SQL_ERROR int (*StmtBindColumn)(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len, uint32* out_length, int8* out_is_null); - - /// Returns the number of rows in the result. /// /// @return Number of rows uint64 (*StmtNumRows)(SqlStmt* self); - - /// Fetches the next row. /// All column bindings will be filled with data. /// /// @return SQL_SUCCESS, SQL_ERROR or SQL_NO_DATA int (*StmtNextRow)(SqlStmt* self); - - /// Frees the result of the statement execution. void (*StmtFreeResult)(SqlStmt* self); @@ -269,8 +244,6 @@ struct sql_interface { }; -struct sql_interface *SQL; - #ifdef HERCULES_CORE void sql_defaults(void); @@ -280,6 +253,8 @@ void Sql_HerculesUpdateCheck(Sql* self); void Sql_HerculesUpdateSkip(Sql* self,const char *filename); #endif // HERCULES_CORE +HPShared struct sql_interface *SQL; + #if defined(SQL_REMOVE_SHOWDEBUG) #define Sql_ShowDebug(self) (void)0 #else |