Let insert IDs be 64-bit values
This commit is contained in:
parent
e560d964dc
commit
06c0de2204
|
@ -19,6 +19,7 @@
|
|||
# define LIBDATABASE_DATABASE_DATABASE_H
|
||||
|
||||
# include <stdarg.h>
|
||||
# include <stdint.h>
|
||||
# include <System.h>
|
||||
|
||||
|
||||
|
@ -49,7 +50,7 @@ typedef struct _DatabasePluginDefinition
|
|||
DatabasePlugin * (*init)(Config * config, char const * section);
|
||||
void (*destroy)(DatabasePlugin * plugin);
|
||||
/* accessors */
|
||||
int (*get_last_id)(DatabasePlugin * plugin);
|
||||
int64_t (*get_last_id)(DatabasePlugin * plugin);
|
||||
/* useful */
|
||||
int (*query)(DatabasePlugin * plugin, char const * query,
|
||||
DatabaseCallback callback, void * data);
|
||||
|
@ -72,7 +73,7 @@ Database * database_new(char const * engine, Config * config,
|
|||
void database_delete(Database * database);
|
||||
|
||||
/* accessors */
|
||||
int database_get_last_id(Database * database);
|
||||
int64_t database_get_last_id(Database * database);
|
||||
|
||||
/* useful */
|
||||
DatabaseStatement * database_prepare_new(
|
||||
|
|
|
@ -68,7 +68,7 @@ void database_delete(Database * database)
|
|||
|
||||
/* accessors */
|
||||
/* database_get_last_id */
|
||||
int database_get_last_id(Database * database)
|
||||
int64_t database_get_last_id(Database * database)
|
||||
{
|
||||
return database->dplugin->get_last_id(database->database);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ typedef struct _DatabaseStatement
|
|||
static PDO * _pdo_init(Config * config, char const * section);
|
||||
static void _pdo_destroy(PDO * pdo);
|
||||
|
||||
static int _pdo_get_last_id(PDO * pdo);
|
||||
static int64_t _pdo_get_last_id(PDO * pdo);
|
||||
|
||||
static int _pdo_query(PDO * pdo, char const * query, DatabaseCallback callback,
|
||||
void * data);
|
||||
|
@ -203,7 +203,7 @@ static void _pdo_destroy(PDO * pdo)
|
|||
|
||||
/* accessors */
|
||||
/* _pdo_get_last_id */
|
||||
static int _pdo_get_last_id(PDO * pdo)
|
||||
static int64_t _pdo_get_last_id(PDO * pdo)
|
||||
{
|
||||
return pdo->dplugin->get_last_id(pdo->database);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ static int _pgsql_process(PgSQL * pgsql, PGresult * res,
|
|||
static PgSQL * _pgsql_init(Config * config, char const * section);
|
||||
static void _pgsql_destroy(PgSQL * pgsql);
|
||||
|
||||
static int _pgsql_get_last_id(PgSQL * pgsql);
|
||||
static int64_t _pgsql_get_last_id(PgSQL * pgsql);
|
||||
|
||||
static int _pgsql_query(PgSQL * pgsql, char const * query,
|
||||
DatabaseCallback callback, void * data);
|
||||
|
@ -148,7 +148,7 @@ static void _pgsql_destroy(PgSQL * pgsql)
|
|||
|
||||
/* accessors */
|
||||
/* pgsql_get_last_id */
|
||||
static int _pgsql_get_last_id(PgSQL * pgsql)
|
||||
static int64_t _pgsql_get_last_id(PgSQL * pgsql)
|
||||
{
|
||||
/* FIXME use currval() of the relevant instead */
|
||||
if(pgsql->last == InvalidOid)
|
||||
|
|
|
@ -46,7 +46,7 @@ typedef struct _DatabaseStatement
|
|||
static SQLite2 * _sqlite2_init(Config * config, char const * section);
|
||||
static void _sqlite2_destroy(SQLite2 * pgsql);
|
||||
|
||||
static int _sqlite2_get_last_id(SQLite2 * pgsql);
|
||||
static int64_t _sqlite2_get_last_id(SQLite2 * pgsql);
|
||||
|
||||
static int _sqlite2_query(SQLite2 * pgsql, char const * query,
|
||||
DatabaseCallback callback, void * data);
|
||||
|
@ -116,7 +116,7 @@ static void _sqlite2_destroy(SQLite2 * sqlite)
|
|||
|
||||
/* accessors */
|
||||
/* _sqlite2_get_last_id */
|
||||
static int _sqlite2_get_last_id(SQLite2 * sqlite)
|
||||
static int64_t _sqlite2_get_last_id(SQLite2 * sqlite)
|
||||
{
|
||||
/* FIXME really implement */
|
||||
return -1;
|
||||
|
|
|
@ -46,7 +46,7 @@ typedef struct _DatabaseStatement
|
|||
static SQLite3 * _sqlite3_init(Config * config, char const * section);
|
||||
static void _sqlite3_destroy(SQLite3 * sqlite3);
|
||||
|
||||
static int _sqlite3_get_last_id(SQLite3 * sqlite3);
|
||||
static int64_t _sqlite3_get_last_id(SQLite3 * sqlite3);
|
||||
|
||||
static int _sqlite3_query(SQLite3 * sqlite3, char const * query,
|
||||
DatabaseCallback callback, void * data);
|
||||
|
@ -115,7 +115,7 @@ static void _sqlite3_destroy(SQLite3 * sqlite3)
|
|||
|
||||
/* accessors */
|
||||
/* _sqlite3_get_last_id */
|
||||
static int _sqlite3_get_last_id(SQLite3 * sqlite3)
|
||||
static int64_t _sqlite3_get_last_id(SQLite3 * sqlite3)
|
||||
{
|
||||
/* XXX returns an int64_t */
|
||||
return sqlite3_last_insert_rowid(sqlite3->handle);
|
||||
|
|
|
@ -45,7 +45,7 @@ typedef struct _DatabaseStatement
|
|||
static Template * _template_init(Config * config, char const * section);
|
||||
static void _template_destroy(Template * pgsql);
|
||||
|
||||
static int _template_get_last_id(Template * pgsql);
|
||||
static int64_t _template_get_last_id(Template * pgsql);
|
||||
|
||||
static int _template_query(Template * pgsql, char const * query,
|
||||
DatabaseCallback callback, void * data);
|
||||
|
@ -97,7 +97,7 @@ static void _template_destroy(Template * template)
|
|||
|
||||
/* accessors */
|
||||
/* _template_get_last_id */
|
||||
static int _template_get_last_id(Template * template)
|
||||
static int64_t _template_get_last_id(Template * template)
|
||||
{
|
||||
/* FIXME really implement */
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue
Block a user