Some minor modifications to database files
This commit is contained in:
@@ -6,5 +6,5 @@ void sessionEnd()
|
||||
{
|
||||
destroyAllConnections();
|
||||
mysql_library_end();
|
||||
setDefaultTimeout(-1);
|
||||
setDefaultTimeout((unsigned int)-1);
|
||||
}
|
||||
@@ -7,6 +7,6 @@
|
||||
#include "db_column.h"
|
||||
#include "db_query.h"
|
||||
|
||||
void sessionEnd();
|
||||
void sessionEnd(void);
|
||||
|
||||
#endif // H__DATABASE__
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define H__DB_CONNECTION__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define SQCONN(s) (MYSQL *)s->conn
|
||||
|
||||
@@ -27,13 +28,13 @@ struct stored_conn_t {
|
||||
struct stored_conn_t *connectionById(int conn_id);
|
||||
struct stored_conn_t *connectionByName(const char *name);
|
||||
|
||||
int connectionCount();
|
||||
int connectionCount(void);
|
||||
|
||||
// Connection management
|
||||
struct stored_conn_t *createStoredConnection(const char *name);
|
||||
struct stored_conn_t *resetStoredConnection(struct stored_conn_t *sconn);
|
||||
void destroyStoredConnection(struct stored_conn_t *sconn);
|
||||
void destroyAllConnections();
|
||||
void destroyAllConnections(void);
|
||||
|
||||
int connectToHost(struct stored_conn_t *sconn,
|
||||
const char *host, unsigned int port,
|
||||
@@ -42,6 +43,6 @@ int connectToSocket(struct stored_conn_t *sconn,
|
||||
const char *unix_socket,
|
||||
const char *user, const char *passwd, const char *db);
|
||||
void closeConnection(struct stored_conn_t *sconn);
|
||||
void closeAllConnections();
|
||||
void closeAllConnections(void);
|
||||
|
||||
#endif // H__DB_CONNECTION__
|
||||
|
||||
@@ -57,12 +57,18 @@ uint64_t scalarQuery(struct stored_conn_t *sconn, const char *qry, size_t qry_le
|
||||
return (uint64_t)-1;
|
||||
}
|
||||
if (n_row > 1) {
|
||||
fprintf(stderr, "[%d]scalarQuery: WARN: Too many rows in result, only returning first value\n", __LINE__);
|
||||
fprintf(
|
||||
stderr, "[%d]scalarQuery: WARN: Too many rows in result, only returning first value\n",
|
||||
__LINE__
|
||||
);
|
||||
}
|
||||
|
||||
n_col = mysql_num_fields(result);
|
||||
if (n_col > 1) {
|
||||
fprintf(stderr, "[%d]scalarQuery: WARN: Too many columns in result, only returning first value\n", __LINE__);
|
||||
fprintf(
|
||||
stderr, "[%d]scalarQuery: WARN: Too many columns in result, only returning first value\n",
|
||||
__LINE__
|
||||
);
|
||||
}
|
||||
|
||||
row = mysql_fetch_row(result);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef H__DB_QUERY__
|
||||
#define H__DB_QUERY__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "db_connection.h"
|
||||
#include "db_column.h"
|
||||
|
||||
// Generic query methods
|
||||
uint64_t simpleQuery(struct stored_conn_t *sconn, const char *qry, size_t qry_len);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "db_timeout.h"
|
||||
|
||||
|
||||
int defaultTimeout = -1;
|
||||
static unsigned int defaultTimeout = (unsigned int)-1;
|
||||
|
||||
|
||||
void setDefaultTimeout(unsigned int timeout)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#ifndef __DB_TIMEOUT_H__
|
||||
#define __DB_TIMEOUT_H__
|
||||
#ifndef H__DB_TIMEOUT__
|
||||
#define H__DB_TIMEOUT__
|
||||
|
||||
#include "db_connection.h"
|
||||
|
||||
// Timeouts can either be set globally or on a per-connection basis
|
||||
void setDefaultTimeout(unsigned int timeout);
|
||||
unsigned int getDefaultTimeout();
|
||||
unsigned int getDefaultTimeout(void);
|
||||
|
||||
int setTimeout(struct stored_conn_t *sconn, unsigned int timeout);
|
||||
|
||||
#endif // __DB_TIMEOUT_H__
|
||||
#endif // H__DB_TIMEOUT__
|
||||
|
||||
Reference in New Issue
Block a user