[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 07/08: NAMESTORE: Add tx API for postgres
From: |
gnunet |
Subject: |
[gnunet] 07/08: NAMESTORE: Add tx API for postgres |
Date: |
Fri, 23 Sep 2022 06:01:11 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit e238c132f9e9d75437c465d8641b45427c622df5
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Fri Sep 23 12:59:28 2022 +0900
NAMESTORE: Add tx API for postgres
---
src/namestore/Makefile.am | 13 ++++++-
src/namestore/plugin_namestore_postgres.c | 65 +++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 1 deletion(-)
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am
index 2d2c8ac3c..32f2605ca 100644
--- a/src/namestore/Makefile.am
+++ b/src/namestore/Makefile.am
@@ -57,7 +57,8 @@ POSTGRES_TESTS = test_plugin_namestore_postgres \
test_namestore_api_zone_iteration_stop_postgres \
test_namestore_api_monitoring_existing_postgres \
test_namestore_api_zone_to_name_postgres \
- perf_namestore_api_zone_iteration_postgres
+ perf_namestore_api_zone_iteration_postgres \
+ test_namestore_api_tx_rollback_postgres
endif
if HAVE_SQLITE
@@ -432,6 +433,16 @@ test_namestore_api_tx_rollback_sqlite_LDADD = \
$(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
$(top_builddir)/src/util/libgnunetutil.la
+test_namestore_api_tx_rollback_postgres_SOURCES = \
+ test_namestore_api_tx_rollback.c
+test_namestore_api_tx_rollback_postgres_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/identity/libgnunetidentity.la \
+ libgnunetnamestore.la \
+ $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+
test_namestore_api_zone_iteration_sqlite_SOURCES = \
test_namestore_api_zone_iteration.c
diff --git a/src/namestore/plugin_namestore_postgres.c
b/src/namestore/plugin_namestore_postgres.c
index 54a19794f..3b1b7ac21 100644
--- a/src/namestore/plugin_namestore_postgres.c
+++ b/src/namestore/plugin_namestore_postgres.c
@@ -553,6 +553,68 @@ namestore_postgres_zone_to_name (void *cls,
return GNUNET_OK;
}
+/**
+ * Begin a transaction for a client.
+ *
+ * @param cls closure (internal context for the plugin)
+ * @param emsg error message set of return code is #GNUNET_SYSERR
+ * @return #GNUNET_YES on success, #GNUNET_SYSERR if transaction cannot be
started.
+ */
+static enum GNUNET_GenericReturnValue
+namestore_postgres_transaction_begin (void *cls,
+ char **emsg)
+{
+ struct Plugin *plugin = cls;
+ struct GNUNET_PQ_ExecuteStatement es[] = {
+ GNUNET_PQ_make_execute ("BEGIN;"),
+ GNUNET_PQ_EXECUTE_STATEMENT_END
+ };
+
+ return GNUNET_PQ_exec_statements (plugin->dbh, es);
+}
+
+/**
+ * Commit a transaction for a client.
+ * This releases the lock on the database.
+ *
+ * @param cls closure (internal context for the plugin)
+ * @param emsg error message set of return code is #GNUNET_SYSERR
+ * @return #GNUNET_YES on success, #GNUNET_SYSERR if transaction cannot be
started.
+ */
+static enum GNUNET_GenericReturnValue
+namestore_postgres_transaction_rollback (void *cls,
+ char **emsg)
+{
+ struct Plugin *plugin = cls;
+ struct GNUNET_PQ_ExecuteStatement es[] = {
+ GNUNET_PQ_make_execute ("ROLLBACK;"),
+ GNUNET_PQ_EXECUTE_STATEMENT_END
+ };
+
+ return GNUNET_PQ_exec_statements (plugin->dbh, es);
+}
+
+/**
+ * Roll back a transaction for a client.
+ * This releases the lock on the database.
+ *
+ * @param cls closure (internal context for the plugin)
+ * @param emsg error message set of return code is #GNUNET_SYSERR
+ * @return #GNUNET_YES on success, #GNUNET_SYSERR if transaction cannot be
started.
+ */
+static enum GNUNET_GenericReturnValue
+namestore_postgres_transaction_commit (void *cls,
+ char **emsg)
+{
+ struct Plugin *plugin = cls;
+ struct GNUNET_PQ_ExecuteStatement es[] = {
+ GNUNET_PQ_make_execute ("COMMIT;"),
+ GNUNET_PQ_EXECUTE_STATEMENT_END
+ };
+
+ return GNUNET_PQ_exec_statements (plugin->dbh, es);
+}
+
/**
* Shutdown database connection and associate data
@@ -595,6 +657,9 @@ libgnunet_plugin_namestore_postgres_init (void *cls)
api->iterate_records = &namestore_postgres_iterate_records;
api->zone_to_name = &namestore_postgres_zone_to_name;
api->lookup_records = &namestore_postgres_lookup_records;
+ api->transaction_begin = &namestore_postgres_transaction_begin;
+ api->transaction_commit = &namestore_postgres_transaction_commit;
+ api->transaction_rollback = &namestore_postgres_transaction_rollback;
LOG (GNUNET_ERROR_TYPE_INFO,
"Postgres namestore plugin running\n");
return api;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] branch master updated (1672c85ad -> 8ecf052b2), gnunet, 2022/09/23
- [gnunet] 03/08: NAMESTORE: Fix existing monitoring test race condition, gnunet, 2022/09/23
- [gnunet] 01/08: NAMESTORE: Start transactional API, gnunet, 2022/09/23
- [gnunet] 04/08: NAMESTORE: Use a per client database connection, gnunet, 2022/09/23
- [gnunet] 06/08: NAMESTORE: Remove head based database, gnunet, 2022/09/23
- [gnunet] 07/08: NAMESTORE: Add tx API for postgres,
gnunet <=
- [gnunet] 02/08: NAMESTORE: Remove unneeded functions and renames., gnunet, 2022/09/23
- [gnunet] 05/08: NAMESTORE: Add begin, commit and rollback API messages, gnunet, 2022/09/23
- [gnunet] 08/08: Merge branch 'dev/schanzen/namestore_transactions', gnunet, 2022/09/23