aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/versioning.sql
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2023-08-27 14:06:28 +0200
committerChristian Grothoff <grothoff@gnunet.org>2023-08-27 14:06:28 +0200
commite7a67dfbb515c71e9fbefe9e30ec1a2e017adf38 (patch)
treec14a22f2e92c19e3a2ce02761e7bddc422b62f14 /src/exchangedb/versioning.sql
parentffa45201bd1c279a5ca83cd8dedf08ac115049e1 (diff)
downloadexchange-e7a67dfbb515c71e9fbefe9e30ec1a2e017adf38.tar.xz
-fix issue with multiple dbinit running concurrently
Diffstat (limited to 'src/exchangedb/versioning.sql')
-rw-r--r--src/exchangedb/versioning.sql7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/exchangedb/versioning.sql b/src/exchangedb/versioning.sql
index 116f409b7..c7fa81213 100644
--- a/src/exchangedb/versioning.sql
+++ b/src/exchangedb/versioning.sql
@@ -146,12 +146,17 @@
BEGIN;
+-- Added by Christian Grothoff to support concurrency, see
+-- https://stackoverflow.com/questions/29900845/create-schema-if-not-exists-raises-duplicate-key-error?rq=4
+LOCK TABLE pg_catalog.pg_namespace;
+
+
-- This file adds versioning support to database it will be loaded to.
-- It requires that PL/pgSQL is already loaded - will raise exception otherwise.
-- All versioning "stuff" (tables, functions) is in "_v" schema.
-- All functions are defined as 'RETURNS SETOF INT4' to be able to make them to RETURN literally nothing (0 rows).
--- >> RETURNS VOID<< IS similar, but it still outputs "empty line" in psql when calling.
+-- >> RETURNS VOID<< IS similar, but it still outputs "empty line" in psql when calling
CREATE SCHEMA IF NOT EXISTS _v;
COMMENT ON SCHEMA _v IS 'Schema for versioning data and functionality.';