-move everything into schema

This commit is contained in:
Christian Grothoff 2022-07-25 20:18:08 +02:00
parent de83b055d5
commit 6d2e6d8061
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 33 additions and 9 deletions

View File

@ -17,6 +17,13 @@
-- Everything in one big transaction -- Everything in one big transaction
BEGIN; BEGIN;
-------------------- Schema ----------------------------
CREATE SCHEMA exchange;
COMMENT ON SCHEMA exchange IS 'taler-exchange data';
SET search_path TO exchange;
-------------------- Tables ---------------------------- -------------------- Tables ----------------------------
CREATE OR REPLACE FUNCTION create_partitioned_table( CREATE OR REPLACE FUNCTION create_partitioned_table(

View File

@ -20,9 +20,6 @@ BEGIN;
SELECT _v.unregister_patch('exchange-0001'); SELECT _v.unregister_patch('exchange-0001');
DROP SCHEMA public CASCADE; DROP SCHEMA exchange CASCADE;
CREATE SCHEMA public;
GRANT ALL ON SCHEMA public TO postgres;
COMMENT ON SCHEMA public IS 'standard public schema';
COMMIT; COMMIT;

View File

@ -222,6 +222,11 @@ postgres_create_shard_tables (void *cls,
GNUNET_PQ_query_param_uint32 (&idx), GNUNET_PQ_query_param_uint32 (&idx),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
struct GNUNET_PQ_ExecuteStatement es[] = {
GNUNET_PQ_make_try_execute ("SET search_path TO exchange;"),
GNUNET_PQ_EXECUTE_STATEMENT_END
};
struct GNUNET_PQ_PreparedStatement ps[] = { struct GNUNET_PQ_PreparedStatement ps[] = {
GNUNET_PQ_make_prepare ("create_shard_tables", GNUNET_PQ_make_prepare ("create_shard_tables",
"SELECT" "SELECT"
@ -234,7 +239,7 @@ postgres_create_shard_tables (void *cls,
conn = GNUNET_PQ_connect_with_cfg (pg->cfg, conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
"exchangedb-postgres", "exchangedb-postgres",
"shard-", "shard-",
NULL, es,
ps); ps);
if (NULL == conn) if (NULL == conn)
return GNUNET_SYSERR; return GNUNET_SYSERR;
@ -273,11 +278,15 @@ postgres_setup_partitions (void *cls,
1), 1),
GNUNET_PQ_PREPARED_STATEMENT_END GNUNET_PQ_PREPARED_STATEMENT_END
}; };
struct GNUNET_PQ_ExecuteStatement es[] = {
GNUNET_PQ_make_try_execute ("SET search_path TO exchange;"),
GNUNET_PQ_EXECUTE_STATEMENT_END
};
conn = GNUNET_PQ_connect_with_cfg (pg->cfg, conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
"exchangedb-postgres", "exchangedb-postgres",
NULL, NULL,
NULL, es,
ps); ps);
if (NULL == conn) if (NULL == conn)
return GNUNET_SYSERR; return GNUNET_SYSERR;
@ -353,7 +362,10 @@ postgres_setup_foreign_servers (void *cls,
GNUNET_PQ_query_param_string (remote_user_pw), GNUNET_PQ_query_param_string (remote_user_pw),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
struct GNUNET_PQ_ExecuteStatement es[] = {
GNUNET_PQ_make_try_execute ("SET search_path TO exchange;"),
GNUNET_PQ_EXECUTE_STATEMENT_END
};
struct GNUNET_PQ_PreparedStatement ps[] = { struct GNUNET_PQ_PreparedStatement ps[] = {
GNUNET_PQ_make_prepare ("create_foreign_servers", GNUNET_PQ_make_prepare ("create_foreign_servers",
"SELECT" "SELECT"
@ -366,7 +378,7 @@ postgres_setup_foreign_servers (void *cls,
conn = GNUNET_PQ_connect_with_cfg (pg->cfg, conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
"exchangedb-postgres", "exchangedb-postgres",
NULL, NULL,
NULL, es,
ps); ps);
if (NULL == conn) if (NULL == conn)
{ {
@ -4455,6 +4467,7 @@ internal_setup (struct PostgresClosure *pg,
"SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;"), "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;"),
GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"), GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"),
GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"), GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"),
GNUNET_PQ_make_try_execute ("SET search_path TO exchange;"),
GNUNET_PQ_EXECUTE_STATEMENT_END GNUNET_PQ_EXECUTE_STATEMENT_END
}; };
#else #else
@ -4464,6 +4477,7 @@ internal_setup (struct PostgresClosure *pg,
GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"), GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"),
GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"), GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"),
GNUNET_PQ_make_try_execute ("SET autocommit=OFF;"), GNUNET_PQ_make_try_execute ("SET autocommit=OFF;"),
GNUNET_PQ_make_try_execute ("SET search_path TO exchange;"),
GNUNET_PQ_EXECUTE_STATEMENT_END GNUNET_PQ_EXECUTE_STATEMENT_END
}; };
#endif #endif
@ -10501,6 +10515,10 @@ postgres_gc (void *cls)
GNUNET_TIME_UNIT_YEARS, GNUNET_TIME_UNIT_YEARS,
10)); 10));
{ {
struct GNUNET_PQ_ExecuteStatement es[] = {
GNUNET_PQ_make_try_execute ("SET search_path TO exchange;"),
GNUNET_PQ_EXECUTE_STATEMENT_END
};
struct GNUNET_PQ_PreparedStatement ps[] = { struct GNUNET_PQ_PreparedStatement ps[] = {
/* Used in #postgres_gc() */ /* Used in #postgres_gc() */
GNUNET_PQ_make_prepare ("run_gc", GNUNET_PQ_make_prepare ("run_gc",
@ -10514,7 +10532,7 @@ postgres_gc (void *cls)
conn = GNUNET_PQ_connect_with_cfg (pg->cfg, conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
"exchangedb-postgres", "exchangedb-postgres",
NULL, NULL,
NULL, es,
ps); ps);
} }
if (NULL == conn) if (NULL == conn)

View File

@ -17,6 +17,8 @@
-- Everything in one big transaction -- Everything in one big transaction
BEGIN; BEGIN;
SET search_path TO exchange;
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
-- Stored procedures -- Stored procedures
--------------------------------------------------------------------------- ---------------------------------------------------------------------------