diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-02-24 10:06:43 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-02-24 10:06:43 +0100 |
commit | 5e5004020eb85a82394ac4d8bd83765304ffd8da (patch) | |
tree | ac9b01a0d203760133584b90492b27220670e272 /src/exchangedb/plugin_exchangedb_postgres.c | |
parent | e253a5b055dd1e9d335e7736160a5413ee4c157c (diff) |
-fix aggregator with deferred constraint
Diffstat (limited to 'src/exchangedb/plugin_exchangedb_postgres.c')
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index c80f33707..507a2c66c 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -7949,7 +7949,22 @@ postgres_start_deferred_wire_out (void *cls) struct PostgresClosure *pg = cls; struct GNUNET_PQ_ExecuteStatement es[] = { GNUNET_PQ_make_execute ("START TRANSACTION ISOLATION LEVEL READ COMMITTED"), - GNUNET_PQ_make_try_execute ("SET CONSTRAINTS wire_out_ref DEFERRED"), + GNUNET_PQ_make_execute ("DO $$" + "BEGIN" + " IF EXISTS (" + " SELECT 1" + " FROM information_Schema.constraint_column_usage" + " WHERE table_name='wire_out'" + " AND constraint_name='wire_out_ref')" + " THEN " + " SET CONSTRAINTS wire_out_ref DEFERRED;" + " END IF;" + "END $$"), + // FIXME: above logic is better as it tests that the constraint + // is actually applicable; but maybe we want to drop the constraint + // entirely once do_gc() is fixed to do without it? + // GNUNET_PQ_make_execute ("CALL defer_wire_out()"), + // GNUNET_PQ_make_execute ("SET CONSTRAINTS wire_out_ref DEFERRED;"), GNUNET_PQ_EXECUTE_STATEMENT_END }; |