mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-16 02:23:49 +08:00
These functions improve usability and take all the proper steps to set restoring on/off (and stop/start background workers in the process) and to set the license key via a function rather than a guc modification.
32 lines
942 B
PL/PgSQL
32 lines
942 B
PL/PgSQL
-- This file and its contents are licensed under the Apache License 2.0.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-APACHE for a copy of the license.
|
|
|
|
CREATE OR REPLACE FUNCTION timescaledb_pre_restore() RETURNS BOOL AS
|
|
$BODY$
|
|
DECLARE
|
|
db text;
|
|
BEGIN
|
|
SELECT current_database() INTO db;
|
|
EXECUTE format($$ALTER DATABASE %I SET timescaledb.restoring ='on'$$, db);
|
|
SET SESSION timescaledb.restoring = 'on';
|
|
PERFORM _timescaledb_internal.stop_background_workers();
|
|
RETURN true;
|
|
END
|
|
$BODY$
|
|
LANGUAGE PLPGSQL;
|
|
|
|
|
|
CREATE OR REPLACE FUNCTION timescaledb_post_restore() RETURNS BOOL AS
|
|
$BODY$
|
|
DECLARE
|
|
db text;
|
|
BEGIN
|
|
SELECT current_database() INTO db;
|
|
EXECUTE format($$ALTER DATABASE %I SET timescaledb.restoring ='off'$$, db);
|
|
SET SESSION timescaledb.restoring='off';
|
|
PERFORM _timescaledb_internal.start_background_workers();
|
|
RETURN true;
|
|
END
|
|
$BODY$
|
|
LANGUAGE PLPGSQL; |