rename SQL files to make filenames consistent with versioning name

This commit is contained in:
Christian Grothoff 2020-02-09 16:34:40 +01:00
parent ae5583f044
commit cdaf1ce69b
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
8 changed files with 43 additions and 122 deletions

View File

@ -14,8 +14,8 @@ pkgcfg_DATA = \
sqldir = $(prefix)/share/taler/sql/auditor/ sqldir = $(prefix)/share/taler/sql/auditor/
sql_DATA = \ sql_DATA = \
0000.sql \ auditor-0000.sql \
0001.sql \ auditor-0001.sql \
drop0000.sql \ drop0000.sql \
restart0000.sql restart0000.sql

View File

@ -80,15 +80,9 @@ struct PostgresClosure
pthread_key_t db_conn_threadlocal; pthread_key_t db_conn_threadlocal;
/** /**
* Directory with SQL statements to run to create tables. * Our configuration.
*/ */
char *sql_dir; const struct GNUNET_CONFIGURATION_Handle *cfg;
/**
* Database connection string, as read from
* the configuration.
*/
char *connection_cfg_str;
/** /**
* Which currency should we assume all amounts to be in? * Which currency should we assume all amounts to be in?
@ -114,16 +108,12 @@ postgres_drop_tables (void *cls,
{ {
struct PostgresClosure *pc = cls; struct PostgresClosure *pc = cls;
struct GNUNET_PQ_Context *conn; struct GNUNET_PQ_Context *conn;
char *exec_dir;
GNUNET_asprintf (&exec_dir, conn = GNUNET_PQ_connect_with_cfg (pc->cfg,
(drop_exchangelist) ? "%sdrop" : "%srestart", "auditordb-postgres",
pc->sql_dir); (drop_exchangelist) ? "drop" : "restart",
conn = GNUNET_PQ_connect (pc->connection_cfg_str, NULL,
exec_dir, NULL);
NULL,
NULL);
GNUNET_free (exec_dir);
if (NULL == conn) if (NULL == conn)
return GNUNET_SYSERR; return GNUNET_SYSERR;
GNUNET_PQ_disconnect (conn); GNUNET_PQ_disconnect (conn);
@ -143,10 +133,11 @@ postgres_create_tables (void *cls)
struct PostgresClosure *pc = cls; struct PostgresClosure *pc = cls;
struct GNUNET_PQ_Context *conn; struct GNUNET_PQ_Context *conn;
conn = GNUNET_PQ_connect (pc->connection_cfg_str, conn = GNUNET_PQ_connect_with_cfg (pc->cfg,
pc->sql_dir, "auditordb-postgres",
NULL, "auditor-",
NULL); NULL,
NULL);
if (NULL == conn) if (NULL == conn)
return GNUNET_SYSERR; return GNUNET_SYSERR;
GNUNET_PQ_disconnect (conn); GNUNET_PQ_disconnect (conn);
@ -734,10 +725,11 @@ postgres_get_session (void *cls)
GNUNET_PQ_reconnect_if_down (session->conn); GNUNET_PQ_reconnect_if_down (session->conn);
return session; return session;
} }
db_conn = GNUNET_PQ_connect (pc->connection_cfg_str, db_conn = GNUNET_PQ_connect_with_cfg (pc->cfg,
NULL, "auditordb-postgres",
NULL, NULL,
ps); NULL,
ps);
if (NULL == db_conn) if (NULL == db_conn)
return NULL; return NULL;
session = GNUNET_new (struct TALER_AUDITORDB_Session); session = GNUNET_new (struct TALER_AUDITORDB_Session);
@ -897,10 +889,11 @@ postgres_gc (void *cls)
}; };
now = GNUNET_TIME_absolute_get (); now = GNUNET_TIME_absolute_get ();
conn = GNUNET_PQ_connect (pc->connection_cfg_str, conn = GNUNET_PQ_connect_with_cfg (pc->cfg,
NULL, "auditordb-postgres",
NULL, NULL,
ps); NULL,
ps);
if (NULL == conn) if (NULL == conn)
return GNUNET_SYSERR; return GNUNET_SYSERR;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@ -3247,50 +3240,16 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
const struct GNUNET_CONFIGURATION_Handle *cfg = cls; const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
struct PostgresClosure *pg; struct PostgresClosure *pg;
struct TALER_AUDITORDB_Plugin *plugin; struct TALER_AUDITORDB_Plugin *plugin;
const char *ec;
pg = GNUNET_new (struct PostgresClosure); pg = GNUNET_new (struct PostgresClosure);
if (GNUNET_OK != pg->cfg = cfg;
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, if (0 != pthread_key_create (&pg->db_conn_threadlocal,
&db_conn_destroy)) &db_conn_destroy))
{ {
TALER_LOG_ERROR ("Cannnot create pthread key.\n"); TALER_LOG_ERROR ("Cannnot create pthread key.\n");
GNUNET_free (pg->sql_dir);
GNUNET_free (pg); GNUNET_free (pg);
return NULL; return NULL;
} }
ec = getenv ("TALER_AUDITORDB_POSTGRES_CONFIG");
if (NULL != ec)
{
pg->connection_cfg_str = GNUNET_strdup (ec);
}
else
{
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"auditordb-postgres",
"CONFIG",
&pg->connection_cfg_str))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"auditordb-postgres",
"CONFIG");
GNUNET_free (pg->sql_dir);
GNUNET_free (pg);
return NULL;
}
}
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg, GNUNET_CONFIGURATION_get_value_string (cfg,
"taler", "taler",
@ -3300,8 +3259,6 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"taler", "taler",
"CURRENCY"); "CURRENCY");
GNUNET_free (pg->connection_cfg_str);
GNUNET_free (pg->sql_dir);
GNUNET_free (pg); GNUNET_free (pg);
return NULL; return NULL;
} }
@ -3407,8 +3364,6 @@ libtaler_plugin_auditordb_postgres_done (void *cls)
struct TALER_AUDITORDB_Plugin *plugin = cls; struct TALER_AUDITORDB_Plugin *plugin = cls;
struct PostgresClosure *pg = plugin->cls; struct PostgresClosure *pg = plugin->cls;
GNUNET_free (pg->connection_cfg_str);
GNUNET_free (pg->sql_dir);
GNUNET_free (pg->currency); GNUNET_free (pg->currency);
GNUNET_free (pg); GNUNET_free (pg);
GNUNET_free (plugin); GNUNET_free (plugin);

View File

@ -15,8 +15,8 @@ pkgcfg_DATA = \
sqldir = $(prefix)/share/taler/sql/exchange/ sqldir = $(prefix)/share/taler/sql/exchange/
sql_DATA = \ sql_DATA = \
0000.sql \ exchange-0000.sql \
0001.sql \ exchange-0001.sql \
drop0000.sql drop0000.sql
EXTRA_DIST = \ EXTRA_DIST = \

View File

@ -113,12 +113,6 @@ struct PostgresClosure
*/ */
const struct GNUNET_CONFIGURATION_Handle *cfg; const struct GNUNET_CONFIGURATION_Handle *cfg;
/**
* Database connection string, as read from
* the configuration.
*/
char *connection_cfg_str;
/** /**
* Directory with SQL statements to run to create tables. * Directory with SQL statements to run to create tables.
*/ */
@ -163,16 +157,12 @@ postgres_drop_tables (void *cls)
{ {
struct PostgresClosure *pc = cls; struct PostgresClosure *pc = cls;
struct GNUNET_PQ_Context *conn; struct GNUNET_PQ_Context *conn;
char *drop_dir;
GNUNET_asprintf (&drop_dir, conn = GNUNET_PQ_connect_with_cfg (pc->cfg,
"%sdrop", "exchangedb-postgres",
pc->sql_dir); "drop",
conn = GNUNET_PQ_connect (pc->connection_cfg_str, NULL,
drop_dir, NULL);
NULL,
NULL);
GNUNET_free (drop_dir);
if (NULL == conn) if (NULL == conn)
return GNUNET_SYSERR; return GNUNET_SYSERR;
GNUNET_PQ_disconnect (conn); GNUNET_PQ_disconnect (conn);
@ -194,7 +184,7 @@ postgres_create_tables (void *cls)
conn = GNUNET_PQ_connect_with_cfg (pc->cfg, conn = GNUNET_PQ_connect_with_cfg (pc->cfg,
"exchangedb-postgres", "exchangedb-postgres",
"", "exchange-",
NULL, NULL,
NULL); NULL);
if (NULL == conn) if (NULL == conn)
@ -1393,10 +1383,11 @@ postgres_get_session (void *cls)
GNUNET_PQ_PREPARED_STATEMENT_END GNUNET_PQ_PREPARED_STATEMENT_END
}; };
db_conn = GNUNET_PQ_connect (pc->connection_cfg_str, db_conn = GNUNET_PQ_connect_with_cfg (pc->cfg,
NULL, "exchangedb-postgres",
es, NULL,
ps); es,
ps);
} }
if (NULL == db_conn) if (NULL == db_conn)
return NULL; return NULL;
@ -5377,10 +5368,11 @@ postgres_gc (void *cls)
GNUNET_PQ_PREPARED_STATEMENT_END GNUNET_PQ_PREPARED_STATEMENT_END
}; };
conn = GNUNET_PQ_connect (pg->connection_cfg_str, conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
NULL, "exchangedb-postgres",
NULL, NULL,
ps); NULL,
ps);
} }
if (NULL == conn) if (NULL == conn)
return GNUNET_SYSERR; return GNUNET_SYSERR;
@ -7221,7 +7213,6 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
const struct GNUNET_CONFIGURATION_Handle *cfg = cls; const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
struct PostgresClosure *pg; struct PostgresClosure *pg;
struct TALER_EXCHANGEDB_Plugin *plugin; struct TALER_EXCHANGEDB_Plugin *plugin;
const char *ec;
pg = GNUNET_new (struct PostgresClosure); pg = GNUNET_new (struct PostgresClosure);
pg->cfg = cfg; pg->cfg = cfg;
@ -7246,28 +7237,6 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
GNUNET_free (pg); GNUNET_free (pg);
return NULL; return NULL;
} }
ec = getenv ("TALER_EXCHANGEDB_POSTGRES_CONFIG");
if (NULL != ec)
{
pg->connection_cfg_str = GNUNET_strdup (ec);
}
else
{
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"exchangedb-postgres",
"CONFIG",
&pg->connection_cfg_str))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchangedb-postgres",
"CONFIG");
GNUNET_free (pg->sql_dir);
GNUNET_free (pg);
return NULL;
}
}
if ( (GNUNET_OK != if ( (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (cfg, GNUNET_CONFIGURATION_get_value_time (cfg,
"exchangedb", "exchangedb",
@ -7283,7 +7252,6 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchangedb", "exchangedb",
"LEGAL/IDLE_RESERVE_EXPIRATION_TIME"); "LEGAL/IDLE_RESERVE_EXPIRATION_TIME");
GNUNET_free (pg->connection_cfg_str);
GNUNET_free (pg->sql_dir); GNUNET_free (pg->sql_dir);
GNUNET_free (pg); GNUNET_free (pg);
return NULL; return NULL;
@ -7297,7 +7265,6 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"taler", "taler",
"CURRENCY"); "CURRENCY");
GNUNET_free (pg->connection_cfg_str);
GNUNET_free (pg->sql_dir); GNUNET_free (pg->sql_dir);
GNUNET_free (pg); GNUNET_free (pg);
return NULL; return NULL;
@ -7413,7 +7380,6 @@ libtaler_plugin_exchangedb_postgres_done (void *cls)
/* If we launched a session for the main thread, /* If we launched a session for the main thread,
kill it here before we unload */ kill it here before we unload */
db_conn_destroy (pg->main_session); db_conn_destroy (pg->main_session);
GNUNET_free (pg->connection_cfg_str);
GNUNET_free (pg->sql_dir); GNUNET_free (pg->sql_dir);
GNUNET_free (pg->currency); GNUNET_free (pg->currency);
GNUNET_free (pg); GNUNET_free (pg);