[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: modify GNUNET_PQ_connect_with_cfg to ena
From: |
gnunet |
Subject: |
[gnunet] branch master updated: modify GNUNET_PQ_connect_with_cfg to enable flexible loading of .sql files |
Date: |
Fri, 24 Jan 2020 16:34:24 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 2fd320bc7 modify GNUNET_PQ_connect_with_cfg to enable flexible loading
of .sql files
2fd320bc7 is described below
commit 2fd320bc7263b1dadd8fbead1004e9ee8b822f45
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Jan 24 16:30:45 2020 +0100
modify GNUNET_PQ_connect_with_cfg to enable flexible loading of .sql files
---
contrib/build-common | 2 +-
src/datacache/plugin_datacache_postgres.c | 1 +
src/datastore/plugin_datastore_postgres.c | 1 +
src/include/gnunet_pq_lib.h | 5 +++++
src/namecache/plugin_namecache_postgres.c | 1 +
src/namestore/plugin_namestore_postgres.c | 1 +
src/pq/pq_connect.c | 26 +++++++++++++++++---------
7 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/contrib/build-common b/contrib/build-common
index 1915a74bb..d81bbfabc 160000
--- a/contrib/build-common
+++ b/contrib/build-common
@@ -1 +1 @@
-Subproject commit 1915a74bbb4cd2ae9bc541a382dfebc37064a2fd
+Subproject commit d81bbfabc2538932f631d3946bd6a9b95182b4f2
diff --git a/src/datacache/plugin_datacache_postgres.c
b/src/datacache/plugin_datacache_postgres.c
index 09049fde2..c21be9219 100644
--- a/src/datacache/plugin_datacache_postgres.c
+++ b/src/datacache/plugin_datacache_postgres.c
@@ -123,6 +123,7 @@ init_connection (struct Plugin *plugin)
plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->env->cfg,
"datacache-postgres",
+ NULL,
es,
ps);
if (NULL == plugin->dbh)
diff --git a/src/datastore/plugin_datastore_postgres.c
b/src/datastore/plugin_datastore_postgres.c
index eba717226..88ceb1b0a 100644
--- a/src/datastore/plugin_datastore_postgres.c
+++ b/src/datastore/plugin_datastore_postgres.c
@@ -172,6 +172,7 @@ init_connection (struct Plugin *plugin)
plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->env->cfg,
"datastore-postgres",
+ NULL,
es,
ps);
if (NULL == plugin->dbh)
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h
index 8b32a9265..53d2549c2 100644
--- a/src/include/gnunet_pq_lib.h
+++ b/src/include/gnunet_pq_lib.h
@@ -742,8 +742,12 @@ GNUNET_PQ_connect (const char *config_str,
* statements in @a es are executed whenever we (re)connect to the
* database, and that the prepared statements in @a ps are "ready".
*
+ * The caller does not have to ensure that @a es and @a ps remain allocated
+ * and initialized in memory until #GNUNET_PQ_disconnect() is called, as a
copy will be made.
+ *
* @param cfg configuration
* @param section configuration section to use to get Postgres configuration
options
+ * @param load_path_suffix suffix to append to the SQL_DIR in the configuration
* @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated
* array of statements to execute upon EACH connection, can be NULL
* @param ps array of prepared statements to prepare, can be NULL
@@ -752,6 +756,7 @@ GNUNET_PQ_connect (const char *config_str,
struct GNUNET_PQ_Context *
GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
const char *section,
+ const char *load_path,
const struct GNUNET_PQ_ExecuteStatement *es,
const struct GNUNET_PQ_PreparedStatement *ps);
diff --git a/src/namecache/plugin_namecache_postgres.c
b/src/namecache/plugin_namecache_postgres.c
index f4a114e22..0e947e9c5 100644
--- a/src/namecache/plugin_namecache_postgres.c
+++ b/src/namecache/plugin_namecache_postgres.c
@@ -113,6 +113,7 @@ database_setup (struct Plugin *plugin)
plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
"namecache-postgres",
+ NULL,
es,
ps);
}
diff --git a/src/namestore/plugin_namestore_postgres.c
b/src/namestore/plugin_namestore_postgres.c
index d0fc33fe9..01dddde9e 100644
--- a/src/namestore/plugin_namestore_postgres.c
+++ b/src/namestore/plugin_namestore_postgres.c
@@ -158,6 +158,7 @@ database_setup (struct Plugin *plugin)
plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
"namestore-postgres",
+ NULL,
es,
ps);
}
diff --git a/src/pq/pq_connect.c b/src/pq/pq_connect.c
index 1ef2da762..7cd7d8787 100644
--- a/src/pq/pq_connect.c
+++ b/src/pq/pq_connect.c
@@ -267,12 +267,12 @@ GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db)
* statements in @a es are executed whenever we (re)connect to the
* database, and that the prepared statements in @a ps are "ready".
*
- * The caller MUST ensure that @a es and @a ps remain allocated and
- * initialized in memory until #GNUNET_PQ_disconnect() is called,
- * as they may be needed repeatedly and no copy will be made.
+ * The caller does not have to ensure that @a es and @a ps remain allocated
+ * and initialized in memory until #GNUNET_PQ_disconnect() is called, as a
copy will be made.
*
* @param cfg configuration
* @param section configuration section to use to get Postgres configuration
options
+ * @param load_path_suffix suffix to append to the SQL_DIR in the configuration
* @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated
* array of statements to execute upon EACH connection, can be NULL
* @param ps array of prepared statements to prepare, can be NULL
@@ -281,12 +281,14 @@ GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db)
struct GNUNET_PQ_Context *
GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
const char *section,
+ const char *load_path_suffix,
const struct GNUNET_PQ_ExecuteStatement *es,
const struct GNUNET_PQ_PreparedStatement *ps)
{
struct GNUNET_PQ_Context *db;
char *conninfo;
char *load_path;
+ char *sp;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
@@ -294,17 +296,23 @@ GNUNET_PQ_connect_with_cfg (const struct
GNUNET_CONFIGURATION_Handle *cfg,
"CONFIG",
&conninfo))
conninfo = NULL;
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- section,
- "SQL_PATH",
- &load_path))
- load_path = NULL;
+ load_path = NULL;
+ sp = NULL;
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_filename (cfg,
+ section,
+ "SQL_DIR",
+ &sp))
+ GNUNET_asprintf (&load_path,
+ "%s%s",
+ sp,
+ load_path_suffix);
db = GNUNET_PQ_connect (conninfo == NULL ? "" : conninfo,
load_path,
es,
ps);
GNUNET_free_non_null (load_path);
+ GNUNET_free_non_null (sp);
GNUNET_free_non_null (conninfo);
return db;
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: modify GNUNET_PQ_connect_with_cfg to enable flexible loading of .sql files,
gnunet <=