diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-05-15 17:24:27 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-05-15 17:24:27 +0200 |
commit | d080e59e272e307b9ebc267f2c4dd2941cd79436 (patch) | |
tree | fceb6637439e4786d643f9235028f960cc9ab0e5 /src/mintdb | |
parent | 33f5242ac4105d8631d659447989cb718459b081 (diff) |
resolve #3717
Diffstat (limited to 'src/mintdb')
-rw-r--r-- | src/mintdb/plugin_mintdb_postgres.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c index 45599f6e9..baf94ddab 100644 --- a/src/mintdb/plugin_mintdb_postgres.c +++ b/src/mintdb/plugin_mintdb_postgres.c @@ -986,7 +986,8 @@ postgres_reserves_update (void *cls, /** * Insert a incoming transaction into reserves. New reserves are also created - * through this function. + * through this function. Note that this API call starts (and stops) its + * own transaction scope (so the application must not do so). * * @param cls the `struct PostgresClosure` with the plugin-specific state * @param session the database connection handle @@ -1025,9 +1026,8 @@ postgres_reserves_in_insert (void *cls, &reserve); if (GNUNET_SYSERR == reserve_exists) { - postgres_rollback (cls, - session); - return GNUNET_SYSERR; + GNUNET_break (0); + goto rollback; } if (GNUNET_NO == reserve_exists) { @@ -1084,6 +1084,21 @@ postgres_reserves_in_insert (void *cls, params); if (PGRES_COMMAND_OK != PQresultStatus(result)) { + const char *efield; + + efield = PQresultErrorField (result, + PG_DIAG_SQLSTATE); + if ( (PGRES_FATAL_ERROR == PQresultStatus(result)) && + (NULL != strstr ("23505", /* unique violation */ + efield)) ) + { + /* This means we had the same reserve/justification/details + before */ + PQclear (result); + postgres_rollback (cls, + session); + return GNUNET_NO; + } QUERY_ERR (result); goto rollback; } |