diff options
m--------- | contrib/build-common | 0 | ||||
-rw-r--r-- | src/datacache/plugin_datacache_postgres.c | 1 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_postgres.c | 1 | ||||
-rw-r--r-- | src/include/gnunet_pq_lib.h | 5 | ||||
-rw-r--r-- | src/namecache/plugin_namecache_postgres.c | 1 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_postgres.c | 1 | ||||
-rw-r--r-- | src/pq/pq_connect.c | 26 |
7 files changed, 26 insertions, 9 deletions
diff --git a/contrib/build-common b/contrib/build-common | |||
Subproject 1915a74bbb4cd2ae9bc541a382dfebc37064a2f | Subproject d81bbfabc2538932f631d3946bd6a9b95182b4f | ||
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) | |||
123 | 123 | ||
124 | plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->env->cfg, | 124 | plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->env->cfg, |
125 | "datacache-postgres", | 125 | "datacache-postgres", |
126 | NULL, | ||
126 | es, | 127 | es, |
127 | ps); | 128 | ps); |
128 | if (NULL == plugin->dbh) | 129 | 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) | |||
172 | 172 | ||
173 | plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->env->cfg, | 173 | plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->env->cfg, |
174 | "datastore-postgres", | 174 | "datastore-postgres", |
175 | NULL, | ||
175 | es, | 176 | es, |
176 | ps); | 177 | ps); |
177 | if (NULL == plugin->dbh) | 178 | 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, | |||
742 | * statements in @a es are executed whenever we (re)connect to the | 742 | * statements in @a es are executed whenever we (re)connect to the |
743 | * database, and that the prepared statements in @a ps are "ready". | 743 | * database, and that the prepared statements in @a ps are "ready". |
744 | * | 744 | * |
745 | * The caller does not have to ensure that @a es and @a ps remain allocated | ||
746 | * and initialized in memory until #GNUNET_PQ_disconnect() is called, as a copy will be made. | ||
747 | * | ||
745 | * @param cfg configuration | 748 | * @param cfg configuration |
746 | * @param section configuration section to use to get Postgres configuration options | 749 | * @param section configuration section to use to get Postgres configuration options |
750 | * @param load_path_suffix suffix to append to the SQL_DIR in the configuration | ||
747 | * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated | 751 | * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated |
748 | * array of statements to execute upon EACH connection, can be NULL | 752 | * array of statements to execute upon EACH connection, can be NULL |
749 | * @param ps array of prepared statements to prepare, can be NULL | 753 | * @param ps array of prepared statements to prepare, can be NULL |
@@ -752,6 +756,7 @@ GNUNET_PQ_connect (const char *config_str, | |||
752 | struct GNUNET_PQ_Context * | 756 | struct GNUNET_PQ_Context * |
753 | GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, | 757 | GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, |
754 | const char *section, | 758 | const char *section, |
759 | const char *load_path, | ||
755 | const struct GNUNET_PQ_ExecuteStatement *es, | 760 | const struct GNUNET_PQ_ExecuteStatement *es, |
756 | const struct GNUNET_PQ_PreparedStatement *ps); | 761 | const struct GNUNET_PQ_PreparedStatement *ps); |
757 | 762 | ||
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) | |||
113 | 113 | ||
114 | plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg, | 114 | plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg, |
115 | "namecache-postgres", | 115 | "namecache-postgres", |
116 | NULL, | ||
116 | es, | 117 | es, |
117 | ps); | 118 | ps); |
118 | } | 119 | } |
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) | |||
158 | 158 | ||
159 | plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg, | 159 | plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg, |
160 | "namestore-postgres", | 160 | "namestore-postgres", |
161 | NULL, | ||
161 | es, | 162 | es, |
162 | ps); | 163 | ps); |
163 | } | 164 | } |
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) | |||
267 | * statements in @a es are executed whenever we (re)connect to the | 267 | * statements in @a es are executed whenever we (re)connect to the |
268 | * database, and that the prepared statements in @a ps are "ready". | 268 | * database, and that the prepared statements in @a ps are "ready". |
269 | * | 269 | * |
270 | * The caller MUST ensure that @a es and @a ps remain allocated and | 270 | * The caller does not have to ensure that @a es and @a ps remain allocated |
271 | * initialized in memory until #GNUNET_PQ_disconnect() is called, | 271 | * and initialized in memory until #GNUNET_PQ_disconnect() is called, as a copy will be made. |
272 | * as they may be needed repeatedly and no copy will be made. | ||
273 | * | 272 | * |
274 | * @param cfg configuration | 273 | * @param cfg configuration |
275 | * @param section configuration section to use to get Postgres configuration options | 274 | * @param section configuration section to use to get Postgres configuration options |
275 | * @param load_path_suffix suffix to append to the SQL_DIR in the configuration | ||
276 | * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated | 276 | * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated |
277 | * array of statements to execute upon EACH connection, can be NULL | 277 | * array of statements to execute upon EACH connection, can be NULL |
278 | * @param ps array of prepared statements to prepare, can be NULL | 278 | * @param ps array of prepared statements to prepare, can be NULL |
@@ -281,12 +281,14 @@ GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db) | |||
281 | struct GNUNET_PQ_Context * | 281 | struct GNUNET_PQ_Context * |
282 | GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, | 282 | GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, |
283 | const char *section, | 283 | const char *section, |
284 | const char *load_path_suffix, | ||
284 | const struct GNUNET_PQ_ExecuteStatement *es, | 285 | const struct GNUNET_PQ_ExecuteStatement *es, |
285 | const struct GNUNET_PQ_PreparedStatement *ps) | 286 | const struct GNUNET_PQ_PreparedStatement *ps) |
286 | { | 287 | { |
287 | struct GNUNET_PQ_Context *db; | 288 | struct GNUNET_PQ_Context *db; |
288 | char *conninfo; | 289 | char *conninfo; |
289 | char *load_path; | 290 | char *load_path; |
291 | char *sp; | ||
290 | 292 | ||
291 | if (GNUNET_OK != | 293 | if (GNUNET_OK != |
292 | GNUNET_CONFIGURATION_get_value_string (cfg, | 294 | GNUNET_CONFIGURATION_get_value_string (cfg, |
@@ -294,17 +296,23 @@ GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
294 | "CONFIG", | 296 | "CONFIG", |
295 | &conninfo)) | 297 | &conninfo)) |
296 | conninfo = NULL; | 298 | conninfo = NULL; |
297 | if (GNUNET_OK != | 299 | load_path = NULL; |
298 | GNUNET_CONFIGURATION_get_value_string (cfg, | 300 | sp = NULL; |
299 | section, | 301 | if (GNUNET_OK == |
300 | "SQL_PATH", | 302 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
301 | &load_path)) | 303 | section, |
302 | load_path = NULL; | 304 | "SQL_DIR", |
305 | &sp)) | ||
306 | GNUNET_asprintf (&load_path, | ||
307 | "%s%s", | ||
308 | sp, | ||
309 | load_path_suffix); | ||
303 | db = GNUNET_PQ_connect (conninfo == NULL ? "" : conninfo, | 310 | db = GNUNET_PQ_connect (conninfo == NULL ? "" : conninfo, |
304 | load_path, | 311 | load_path, |
305 | es, | 312 | es, |
306 | ps); | 313 | ps); |
307 | GNUNET_free_non_null (load_path); | 314 | GNUNET_free_non_null (load_path); |
315 | GNUNET_free_non_null (sp); | ||
308 | GNUNET_free_non_null (conninfo); | 316 | GNUNET_free_non_null (conninfo); |
309 | return db; | 317 | return db; |
310 | } | 318 | } |