aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/auditordb/auditordb-postgres.conf3
-rw-r--r--src/auditordb/plugin_auditordb_postgres.c23
-rw-r--r--src/auditordb/test-auditor-db-postgres.conf4
-rw-r--r--src/exchangedb/Makefile.am2
-rw-r--r--src/exchangedb/exchangedb-postgres.conf3
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c27
-rw-r--r--src/exchangedb/test-exchange-db-postgres.conf3
7 files changed, 60 insertions, 5 deletions
diff --git a/src/auditordb/auditordb-postgres.conf b/src/auditordb/auditordb-postgres.conf
index 9a6d39884..fe408c3bb 100644
--- a/src/auditordb/auditordb-postgres.conf
+++ b/src/auditordb/auditordb-postgres.conf
@@ -1,3 +1,6 @@
[auditordb-postgres]
# Argument for Postgres for how to connect to the database.
CONFIG = "postgres:///taler"
+
+# Where are the SQL files to setup our tables?
+SQL_DIR = $DATADIR/sql/auditor/
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c
index 7e6b7bf09..30b036c9e 100644
--- a/src/auditordb/plugin_auditordb_postgres.c
+++ b/src/auditordb/plugin_auditordb_postgres.c
@@ -80,6 +80,11 @@ struct PostgresClosure
pthread_key_t db_conn_threadlocal;
/**
+ * Directory with SQL statements to run to create tables.
+ */
+ char *sql_dir;
+
+ /**
* Database connection string, as read from
* the configuration.
*/
@@ -408,8 +413,8 @@ postgres_create_tables (void *cls)
struct GNUNET_PQ_Context *conn;
conn = GNUNET_PQ_connect (pc->connection_cfg_str,
+ pc->sql_dir,
NULL,
- es,
NULL);
if (NULL == conn)
return GNUNET_SYSERR;
@@ -3446,10 +3451,23 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
const char *ec;
pg = GNUNET_new (struct PostgresClosure);
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (cfg,
+ "auditordb-postgres",
+ "SQL_DIR",
+ &pg->sql_dir))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "auditordb-postgres",
+ "SQL_DIR");
+ GNUNET_free (pg);
+ return NULL;
+ }
if (0 != pthread_key_create (&pg->db_conn_threadlocal,
&db_conn_destroy))
{
TALER_LOG_ERROR ("Cannnot create pthread key.\n");
+ GNUNET_free (pg->sql_dir);
GNUNET_free (pg);
return NULL;
}
@@ -3469,6 +3487,7 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"auditordb-postgres",
"CONFIG");
+ GNUNET_free (pg->sql_dir);
GNUNET_free (pg);
return NULL;
}
@@ -3483,6 +3502,7 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
"taler",
"CURRENCY");
GNUNET_free (pg->connection_cfg_str);
+ GNUNET_free (pg->sql_dir);
GNUNET_free (pg);
return NULL;
}
@@ -3589,6 +3609,7 @@ libtaler_plugin_auditordb_postgres_done (void *cls)
struct PostgresClosure *pg = plugin->cls;
GNUNET_free (pg->connection_cfg_str);
+ GNUNET_free (pg->sql_dir);
GNUNET_free (pg->currency);
GNUNET_free (pg);
GNUNET_free (plugin);
diff --git a/src/auditordb/test-auditor-db-postgres.conf b/src/auditordb/test-auditor-db-postgres.conf
index b08195eb8..924aef435 100644
--- a/src/auditordb/test-auditor-db-postgres.conf
+++ b/src/auditordb/test-auditor-db-postgres.conf
@@ -6,6 +6,8 @@ DB = postgres
# Argument for Postgres for how to connect to the database.
CONFIG = "postgres:///talercheck"
+# Where are the SQL files to setup our tables?
+SQL_DIR = $DATADIR/sql/exchange/
+
[taler]
CURRENCY = "EUR"
-
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am
index 52e1bdad8..40db09749 100644
--- a/src/exchangedb/Makefile.am
+++ b/src/exchangedb/Makefile.am
@@ -22,7 +22,7 @@ EXTRA_DIST = \
exchangedb.conf \
exchangedb-postgres.conf \
plugin_exchangedb_common.c \
- test-exchange-db-postgres.conf
+ test-exchange-db-postgres.conf \
$(sql_DATA)
plugindir = $(libdir)/taler
diff --git a/src/exchangedb/exchangedb-postgres.conf b/src/exchangedb/exchangedb-postgres.conf
index 5ebd656c8..40fe3de0e 100644
--- a/src/exchangedb/exchangedb-postgres.conf
+++ b/src/exchangedb/exchangedb-postgres.conf
@@ -1,2 +1,5 @@
[exchangedb-postgres]
CONFIG = "postgres:///taler"
+
+# Where are the SQL files to setup our tables?
+SQL_DIR = $DATADIR/sql/exchange/
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 47ac8e7bf..e144342f4 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -115,6 +115,11 @@ struct PostgresClosure
char *connection_cfg_str;
/**
+ * Directory with SQL statements to run to create tables.
+ */
+ char *sql_dir;
+
+ /**
* After how long should idle reserves be closed?
*/
struct GNUNET_TIME_Relative idle_reserve_expiration_time;
@@ -503,8 +508,8 @@ postgres_create_tables (void *cls)
struct GNUNET_PQ_Context *conn;
conn = GNUNET_PQ_connect (pc->connection_cfg_str,
+ pc->sql_dir,
NULL,
- es,
NULL);
if (NULL == conn)
return GNUNET_SYSERR;
@@ -7489,11 +7494,23 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
const char *ec;
pg = GNUNET_new (struct PostgresClosure);
-
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (cfg,
+ "exchangedb-postgres",
+ "SQL_DIR",
+ &pg->sql_dir))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "exchangedb-postgres",
+ "CONFIG");
+ GNUNET_free (pg);
+ return NULL;
+ }
if (0 != pthread_key_create (&pg->db_conn_threadlocal,
&db_conn_destroy))
{
TALER_LOG_ERROR ("Cannnot create pthread key.\n");
+ GNUNET_free (pg->sql_dir);
GNUNET_free (pg);
return NULL;
}
@@ -7513,6 +7530,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchangedb-postgres",
"CONFIG");
+ GNUNET_free (pg->sql_dir);
GNUNET_free (pg);
return NULL;
}
@@ -7533,6 +7551,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchangedb",
"LEGAL/IDLE_RESERVE_EXPIRATION_TIME");
+ GNUNET_free (pg->connection_cfg_str);
+ GNUNET_free (pg->sql_dir);
GNUNET_free (pg);
return NULL;
}
@@ -7545,6 +7565,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"taler",
"CURRENCY");
+ GNUNET_free (pg->connection_cfg_str);
+ GNUNET_free (pg->sql_dir);
GNUNET_free (pg);
return NULL;
}
@@ -7656,6 +7678,7 @@ libtaler_plugin_exchangedb_postgres_done (void *cls)
struct PostgresClosure *pg = plugin->cls;
GNUNET_free (pg->connection_cfg_str);
+ GNUNET_free (pg->sql_dir);
GNUNET_free (pg->currency);
GNUNET_free (pg);
GNUNET_free (plugin);
diff --git a/src/exchangedb/test-exchange-db-postgres.conf b/src/exchangedb/test-exchange-db-postgres.conf
index e61c4505a..f6db76942 100644
--- a/src/exchangedb/test-exchange-db-postgres.conf
+++ b/src/exchangedb/test-exchange-db-postgres.conf
@@ -7,6 +7,9 @@ DB = postgres
#The connection string the plugin has to use for connecting to the database
CONFIG = postgres:///talercheck
+# Where are the SQL files to setup our tables?
+SQL_DIR = $DATADIR/sql/exchange/
+
[taler]
CURRENCY = EUR