diff --git a/include/Database/database.h b/include/Database/database.h index 6745585..cd688d2 100644 --- a/include/Database/database.h +++ b/include/Database/database.h @@ -19,6 +19,7 @@ # define LIBDATABASE_DATABASE_DATABASE_H # include +# include # include @@ -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( diff --git a/src/database.c b/src/database.c index 8d378e0..7bf5bf2 100644 --- a/src/database.c +++ b/src/database.c @@ -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); } diff --git a/src/engines/pdo.c b/src/engines/pdo.c index bfae8b2..983f397 100644 --- a/src/engines/pdo.c +++ b/src/engines/pdo.c @@ -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); } diff --git a/src/engines/pgsql.c b/src/engines/pgsql.c index 1595e0e..cbb5a4e 100644 --- a/src/engines/pgsql.c +++ b/src/engines/pgsql.c @@ -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) diff --git a/src/engines/sqlite2.c b/src/engines/sqlite2.c index 5100c82..e3d2c30 100644 --- a/src/engines/sqlite2.c +++ b/src/engines/sqlite2.c @@ -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; diff --git a/src/engines/sqlite3.c b/src/engines/sqlite3.c index 774afd4..292650c 100644 --- a/src/engines/sqlite3.c +++ b/src/engines/sqlite3.c @@ -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); diff --git a/src/engines/template.c b/src/engines/template.c index a033c3f..6f8f047 100644 --- a/src/engines/template.c +++ b/src/engines/template.c @@ -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;