summaryrefslogtreecommitdiff
path: root/src/common/sql.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-09-18 13:09:16 +0200
committerHaru <haru@dotalux.com>2015-09-25 12:55:36 +0200
commit1aea178ef7cdb76eda5600540b5fbd29fd54ff88 (patch)
tree855d4feafba212d7f36872c1b46814c1f1a85e75 /src/common/sql.c
parente99bf73af31a8b1f09b9ce033c16832ee5cac51d (diff)
downloadhercules-1aea178ef7cdb76eda5600540b5fbd29fd54ff88.tar.gz
hercules-1aea178ef7cdb76eda5600540b5fbd29fd54ff88.tar.bz2
hercules-1aea178ef7cdb76eda5600540b5fbd29fd54ff88.tar.xz
hercules-1aea178ef7cdb76eda5600540b5fbd29fd54ff88.zip
More aggressive whitespace cleanup. Follow up to 51329e6
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common/sql.c')
-rw-r--r--src/common/sql.c88
1 files changed, 0 insertions, 88 deletions
diff --git a/src/common/sql.c b/src/common/sql.c
index 0ca51e272..ee759eb61 100644
--- a/src/common/sql.c
+++ b/src/common/sql.c
@@ -36,8 +36,6 @@ struct Sql {
int keepalive;
};
-
-
// Column length receiver.
// Takes care of the possible size mismatch between uint32 and unsigned long.
struct s_column_length {
@@ -46,8 +44,6 @@ struct s_column_length {
};
typedef struct s_column_length s_column_length;
-
-
/// Sql statement
struct SqlStmt {
StringBuf buf;
@@ -61,14 +57,10 @@ struct SqlStmt {
bool bind_columns;
};
-
-
///////////////////////////////////////////////////////////////////////////////
// Sql Handle
///////////////////////////////////////////////////////////////////////////////
-
-
/// Allocates and initializes a new Sql handle.
Sql* Sql_Malloc(void)
{
@@ -84,8 +76,6 @@ Sql* Sql_Malloc(void)
return self;
}
-
-
static int Sql_P_Keepalive(Sql* self);
/// Establishes a connection.
@@ -111,8 +101,6 @@ int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* hos
return SQL_SUCCESS;
}
-
-
/// Retrieves the timeout of the connection.
int Sql_GetTimeout(Sql* self, uint32* out_timeout)
{
@@ -130,8 +118,6 @@ int Sql_GetTimeout(Sql* self, uint32* out_timeout)
return SQL_ERROR;
}
-
-
/// Retrieves the name of the columns of a table into out_buf, with the separator after each name.
int Sql_GetColumnNames(Sql* self, const char* table, char* out_buf, size_t buf_len, char sep)
{
@@ -160,8 +146,6 @@ int Sql_GetColumnNames(Sql* self, const char* table, char* out_buf, size_t buf_l
return SQL_SUCCESS;
}
-
-
/// Changes the encoding of the connection.
int Sql_SetEncoding(Sql* self, const char* encoding)
{
@@ -170,8 +154,6 @@ int Sql_SetEncoding(Sql* self, const char* encoding)
return SQL_ERROR;
}
-
-
/// Pings the connection.
int Sql_Ping(Sql* self)
{
@@ -180,8 +162,6 @@ int Sql_Ping(Sql* self)
return SQL_ERROR;
}
-
-
/// Wrapper function for Sql_Ping.
///
/// @private
@@ -193,8 +173,6 @@ static int Sql_P_KeepaliveTimer(int tid, int64 tick, int id, intptr_t data)
return 0;
}
-
-
/// Establishes keepalive (periodic ping) on the connection.
///
/// @return the keepalive timer id, or INVALID_TIMER
@@ -218,8 +196,6 @@ static int Sql_P_Keepalive(Sql* self)
return timer->add_interval(timer->gettick() + ping_interval*1000, Sql_P_KeepaliveTimer, 0, (intptr_t)self, ping_interval*1000);
}
-
-
/// Escapes a string.
size_t Sql_EscapeString(Sql* self, char *out_to, const char *from)
{
@@ -229,8 +205,6 @@ size_t Sql_EscapeString(Sql* self, char *out_to, const char *from)
return (size_t)mysql_escape_string(out_to, from, (unsigned long)strlen(from));
}
-
-
/// Escapes a string.
size_t Sql_EscapeStringLen(Sql* self, char *out_to, const char *from, size_t from_len)
{
@@ -240,8 +214,6 @@ size_t Sql_EscapeStringLen(Sql* self, char *out_to, const char *from, size_t fro
return (size_t)mysql_escape_string(out_to, from, (unsigned long)from_len);
}
-
-
/// Executes a query.
int Sql_Query(Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3)));
int Sql_Query(Sql *self, const char *query, ...) {
@@ -255,8 +227,6 @@ int Sql_Query(Sql *self, const char *query, ...) {
return res;
}
-
-
/// Executes a query.
int Sql_QueryV(Sql* self, const char* query, va_list args)
{
@@ -282,8 +252,6 @@ int Sql_QueryV(Sql* self, const char* query, va_list args)
return SQL_SUCCESS;
}
-
-
/// Executes a query.
int Sql_QueryStr(Sql* self, const char* query)
{
@@ -309,8 +277,6 @@ int Sql_QueryStr(Sql* self, const char* query)
return SQL_SUCCESS;
}
-
-
/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE query.
uint64 Sql_LastInsertId(Sql* self)
{
@@ -320,8 +286,6 @@ uint64 Sql_LastInsertId(Sql* self)
return 0;
}
-
-
/// Returns the number of columns in each row of the result.
uint32 Sql_NumColumns(Sql* self)
{
@@ -330,8 +294,6 @@ uint32 Sql_NumColumns(Sql* self)
return 0;
}
-
-
/// Returns the number of rows in the result.
uint64 Sql_NumRows(Sql* self)
{
@@ -340,8 +302,6 @@ uint64 Sql_NumRows(Sql* self)
return 0;
}
-
-
/// Fetches the next row.
int Sql_NextRow(Sql* self) {
if( self && self->result ) {
@@ -357,8 +317,6 @@ int Sql_NextRow(Sql* self) {
return SQL_ERROR;
}
-
-
/// Gets the data of a column.
int Sql_GetData(Sql* self, size_t col, char** out_buf, size_t* out_len)
{
@@ -375,8 +333,6 @@ int Sql_GetData(Sql* self, size_t col, char** out_buf, size_t* out_len)
return SQL_ERROR;
}
-
-
/// Frees the result of the query.
void Sql_FreeResult(Sql* self) {
if( self && self->result ) {
@@ -387,8 +343,6 @@ void Sql_FreeResult(Sql* self) {
}
}
-
-
/// Shows debug information (last query).
void Sql_ShowDebug_(Sql* self, const char* debug_file, const unsigned long debug_line)
{
@@ -400,8 +354,6 @@ void Sql_ShowDebug_(Sql* self, const char* debug_file, const unsigned long debug
ShowDebug("at %s:%lu\n", debug_file, debug_line);
}
-
-
/// Frees a Sql handle returned by Sql_Malloc.
void Sql_Free(Sql* self) {
if( self )
@@ -414,14 +366,10 @@ void Sql_Free(Sql* self) {
}
}
-
-
///////////////////////////////////////////////////////////////////////////////
// Prepared Statements
///////////////////////////////////////////////////////////////////////////////
-
-
/// Returns the mysql integer type for the target size.
///
/// @private
@@ -439,8 +387,6 @@ static enum enum_field_types Sql_P_SizeToMysqlIntType(int sz)
}
}
-
-
/// Binds a parameter/result.
///
/// @private
@@ -514,8 +460,6 @@ static int Sql_P_BindSqlDataType(MYSQL_BIND* bind, enum SqlDataType buffer_type,
return SQL_SUCCESS;
}
-
-
/// Prints debug information about a field (type and length).
///
/// @private
@@ -551,8 +495,6 @@ static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_ty
ShowDebug("%stype=%s%s, length=%lu%s\n", prefix, sign, type_string, length, length_postfix);
}
-
-
/// Reports debug information about a truncated column.
///
/// @private
@@ -575,8 +517,6 @@ static void SqlStmt_P_ShowDebugTruncatedColumn(SqlStmt* self, size_t i)
mysql_free_result(meta);
}
-
-
/// Allocates and initializes a new SqlStmt handle.
SqlStmt* SqlStmt_Malloc(Sql* sql) {
SqlStmt* self;
@@ -604,8 +544,6 @@ SqlStmt* SqlStmt_Malloc(Sql* sql) {
return self;
}
-
-
/// Prepares the statement.
int SqlStmt_Prepare(SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3)));
int SqlStmt_Prepare(SqlStmt *self, const char *query, ...) {
@@ -619,8 +557,6 @@ int SqlStmt_Prepare(SqlStmt *self, const char *query, ...) {
return res;
}
-
-
/// Prepares the statement.
int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args)
{
@@ -641,8 +577,6 @@ int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args)
return SQL_SUCCESS;
}
-
-
/// Prepares the statement.
int SqlStmt_PrepareStr(SqlStmt* self, const char* query)
{
@@ -663,8 +597,6 @@ int SqlStmt_PrepareStr(SqlStmt* self, const char* query)
return SQL_SUCCESS;
}
-
-
/// Returns the number of parameters in the prepared statement.
size_t SqlStmt_NumParams(SqlStmt* self)
{
@@ -674,8 +606,6 @@ size_t SqlStmt_NumParams(SqlStmt* self)
return 0;
}
-
-
/// Binds a parameter to a buffer.
int SqlStmt_BindParam(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, void* buffer, size_t buffer_len)
{
@@ -704,8 +634,6 @@ int SqlStmt_BindParam(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, v
return SQL_SUCCESS;// out of range - ignore
}
-
-
/// Executes the prepared statement.
int SqlStmt_Execute(SqlStmt* self)
{
@@ -731,8 +659,6 @@ int SqlStmt_Execute(SqlStmt* self)
return SQL_SUCCESS;
}
-
-
/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE statement.
uint64 SqlStmt_LastInsertId(SqlStmt* self)
{
@@ -742,8 +668,6 @@ uint64 SqlStmt_LastInsertId(SqlStmt* self)
return 0;
}
-
-
/// Returns the number of columns in each row of the result.
size_t SqlStmt_NumColumns(SqlStmt* self)
{
@@ -753,8 +677,6 @@ size_t SqlStmt_NumColumns(SqlStmt* self)
return 0;
}
-
-
/// Binds the result of a column to a buffer.
int SqlStmt_BindColumn(SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len, uint32 *out_length, int8 *out_is_null) {
if (self == NULL)
@@ -796,8 +718,6 @@ int SqlStmt_BindColumn(SqlStmt *self, size_t idx, enum SqlDataType buffer_type,
}
}
-
-
/// Returns the number of rows in the result.
uint64 SqlStmt_NumRows(SqlStmt* self)
{
@@ -807,8 +727,6 @@ uint64 SqlStmt_NumRows(SqlStmt* self)
return 0;
}
-
-
/// Fetches the next row.
int SqlStmt_NextRow(SqlStmt* self)
{
@@ -892,8 +810,6 @@ int SqlStmt_NextRow(SqlStmt* self)
return SQL_SUCCESS;
}
-
-
/// Frees the result of the statement execution.
void SqlStmt_FreeResult(SqlStmt* self)
{
@@ -901,8 +817,6 @@ void SqlStmt_FreeResult(SqlStmt* self)
mysql_stmt_free_result(self->stmt);
}
-
-
/// Shows debug information (with statement).
void SqlStmt_ShowDebug_(SqlStmt* self, const char* debug_file, const unsigned long debug_line)
{
@@ -914,8 +828,6 @@ void SqlStmt_ShowDebug_(SqlStmt* self, const char* debug_file, const unsigned lo
ShowDebug("at %s:%lu\n", debug_file, debug_line);
}
-
-
/// Frees a SqlStmt returned by SqlStmt_Malloc.
void SqlStmt_Free(SqlStmt* self)
{