psycstore: adapt to changed gnunetpq API

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
Daniel Golle 2019-10-29 22:33:56 +01:00
parent 5fc42cc72b
commit be0d5ec3c0
No known key found for this signature in database
GPG Key ID: DD8D36F0A710502F

View File

@ -70,7 +70,7 @@ struct Plugin
/** /**
* Native Postgres database handle. * Native Postgres database handle.
*/ */
PGconn *dbh; struct GNUNET_PQ_Context *dbh;
enum Transactions transaction; enum Transactions transaction;
@ -160,22 +160,7 @@ database_setup (struct Plugin *plugin)
GNUNET_PQ_EXECUTE_STATEMENT_END GNUNET_PQ_EXECUTE_STATEMENT_END
}; };
/* Open database and precompile statements */
plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
"psycstore-postgres");
if (NULL == plugin->dbh)
return GNUNET_SYSERR;
if (GNUNET_OK !=
GNUNET_PQ_exec_statements (plugin->dbh,
es))
{
PQfinish (plugin->dbh);
plugin->dbh = NULL;
return GNUNET_SYSERR;
}
/* Prepare statements */ /* Prepare statements */
{
struct GNUNET_PQ_PreparedStatement ps[] = { struct GNUNET_PQ_PreparedStatement ps[] = {
GNUNET_PQ_make_prepare ("transaction_begin", GNUNET_PQ_make_prepare ("transaction_begin",
"BEGIN", 0), "BEGIN", 0),
@ -346,15 +331,14 @@ database_setup (struct Plugin *plugin)
GNUNET_PQ_PREPARED_STATEMENT_END GNUNET_PQ_PREPARED_STATEMENT_END
}; };
if (GNUNET_OK != /* Open database and precompile statements */
GNUNET_PQ_prepare_statements (plugin->dbh, plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
ps)) "psycstore-postgres",
{ es,
PQfinish (plugin->dbh); ps);
plugin->dbh = NULL;
if (NULL == plugin->dbh)
return GNUNET_SYSERR; return GNUNET_SYSERR;
}
}
return GNUNET_OK; return GNUNET_OK;
} }
@ -368,7 +352,7 @@ database_setup (struct Plugin *plugin)
static void static void
database_shutdown (struct Plugin *plugin) database_shutdown (struct Plugin *plugin)
{ {
PQfinish (plugin->dbh); GNUNET_PQ_disconnect (plugin->dbh);
plugin->dbh = NULL; plugin->dbh = NULL;
} }