commit df6585633847490f7f362a23e2f6c99f7944fac1
parent 074814f88416e3637c0ea4770e8d1d32134f13d7
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
Date: Wed, 3 Apr 2024 16:16:43 +0200
donaudb reset
Diffstat:
2 files changed, 30 insertions(+), 71 deletions(-)
diff --git a/src/donau-tools/donau-dbinit.c b/src/donau-tools/donau-dbinit.c
@@ -36,16 +36,6 @@ static int global_ret;
static int reset_db;
/**
- * -s option: clear revolving shard locks
- */
-// static int clear_shards;
-
-/**
- * -g option: garbage collect DB reset
- */
-static int gc_db;
-
-/**
* -P option: setup a partitioned database
*/
static uint32_t num_partitions;
@@ -83,15 +73,17 @@ run (void *cls,
global_ret = EXIT_NOTINSTALLED;
return;
}
- // if (reset_db)
- // {
- // if (GNUNET_OK !=
- // plugin->drop_tables (plugin->cls))
- // {
- // GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- // "Could not drop tables as requested. Either database was not yet initialized, or permission denied. Consult the logs. Will still try to create new tables.\n");
- // }
- // }
+
+ if (reset_db)
+ {
+ if (GNUNET_OK !=
+ plugin->drop_tables (plugin->cls))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not drop tables as requested. Either database was not yet initialized, or permission denied. Consult the logs. Will still try to create new tables.\n");
+ }
+ }
+
if (GNUNET_OK !=
plugin->create_tables (plugin->cls,
force_create_partitions || num_partitions > 0,
@@ -104,37 +96,7 @@ run (void *cls,
global_ret = EXIT_NOPERMISSION;
return;
}
- // if (gc_db || clear_shards)
- if (gc_db)
- {
- if (GNUNET_OK !=
- plugin->preflight (plugin->cls))
- {
- fprintf (stderr,
- "Failed to prepare database.\n");
- DONAUDB_plugin_unload (plugin);
- plugin = NULL;
- global_ret = EXIT_NOPERMISSION;
- return;
- }
- // if (clear_shards)
- // {
- // if (GNUNET_OK !=
- // plugin->delete_shard_locks (plugin->cls))
- // {
- // fprintf (stderr,
- // "Clearing revolving shards failed!\n");
- // }
- // }
- if (gc_db)
- {
- if (GNUNET_SYSERR == plugin->gc (plugin->cls))
- {
- fprintf (stderr,
- "Garbage collection failed!\n");
- }
- }
- }
+
DONAUDB_plugin_unload (plugin);
plugin = NULL;
}
@@ -153,27 +115,19 @@ main (int argc,
char *const *argv)
{
const struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_flag ('g',
- "gc",
- "garbage collect database",
- &gc_db),
GNUNET_GETOPT_option_flag ('r',
"reset",
"reset database (DANGEROUS: all existing data is lost!)",
&reset_db),
- // GNUNET_GETOPT_option_flag ('s',
- // "shardunlock",
- // "unlock all revolving shard locks (use after system crash or shard size change while services are not running)",
- // &clear_shards),
- // GNUNET_GETOPT_option_uint ('P',
- // "partition",
- // "NUMBER",
- // "Setup a partitioned database where each table which can be partitioned holds NUMBER partitions on a single DB node",
- // &num_partitions),
- // GNUNET_GETOPT_option_flag ('f',
- // "force",
- // "Force partitions to be created if there is only one partition",
- // &force_create_partitions),
+ GNUNET_GETOPT_option_uint ('P',
+ "partition",
+ "NUMBER",
+ "Setup a partitioned database where each table which can be partitioned holds NUMBER partitions on a single DB node",
+ &num_partitions),
+ GNUNET_GETOPT_option_flag ('f',
+ "force",
+ "Force partitions to be created if there is only one partition",
+ &force_create_partitions),
GNUNET_GETOPT_OPTION_END
};
enum GNUNET_GenericReturnValue ret;
diff --git a/src/donaudb/drop.sql b/src/donaudb/drop.sql
@@ -17,10 +17,15 @@
-- Everything in one big transaction
BEGIN;
+WITH xpatches AS (
+ SELECT patch_name
+ FROM _v.patches
+ WHERE starts_with(patch_name,'exchange-')
+)
+ SELECT _v.unregister_patch(xpatches.patch_name)
+ FROM xpatches;
-SELECT _v.unregister_patch('donau-0001');
-SELECT _v.unregister_patch('donau-0002');
-
-DROP SCHEMA donau CASCADE;
+-- FIXME
+-- DROP SCHEMA donau CASCADE;
COMMIT;