mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-19 20:24:46 +08:00
This is part of the ongoing effort to simplify the metadata tables and removing any triggers on them that cause side effects. This change includes the following: - Remove the on_change_hypertable() trigger on the hypertable catalog table. - Remove the TRUNCATE blocking triggers on all metadata tables. If we think such blocking is important, we should do this in an event trigger or the processUtility hook. - Put all SQL files in a single load_order.txt instead of splitting across three distinct files. Now all SQL files are included in update scripts as well for simplicity and consistency. - As a result of removing triggers and related functions, the setup_main() and restore_timescaledb() functions are no longer needed. This also further simplifies the database restore process as calling restore_timescaledb() is no longer needed (or possible). - Refactor create_hypertable_row() to do more validation before allocating a new hypertable ID. This avoids incrementing the serial ID unnecessarily in case some validations fail.
37 lines
2.4 KiB
SQL
37 lines
2.4 KiB
SQL
-- This file contains infrastructure for cache invalidation of TimescaleDB
|
|
-- metadata caches kept in C. Please look at cache_invalidate.c for a
|
|
-- description of how this works.
|
|
CREATE TABLE IF NOT EXISTS _timescaledb_cache.cache_inval_hypertable();
|
|
|
|
-- This is pretty subtle. We create this dummy cache_inval_extension table
|
|
-- solely for the purpose of getting a relcache invalidation event when it is
|
|
-- deleted on DROP extension. It has no related triggers. When the table is
|
|
-- invalidated, all backends will be notified and will know that they must
|
|
-- invalidate all cached information, including catalog table and index OIDs,
|
|
-- etc.
|
|
CREATE TABLE IF NOT EXISTS _timescaledb_cache.cache_inval_extension();
|
|
|
|
-- not actually strictly needed but good for sanity as all tables should be dumped.
|
|
SELECT pg_catalog.pg_extension_config_dump('_timescaledb_cache.cache_inval_hypertable', '');
|
|
SELECT pg_catalog.pg_extension_config_dump('_timescaledb_cache.cache_inval_extension', '');
|
|
|
|
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.hypertable;
|
|
CREATE TRIGGER "0_cache_inval" AFTER INSERT OR UPDATE OR DELETE OR TRUNCATE ON _timescaledb_catalog.hypertable
|
|
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger('cache_inval_hypertable');
|
|
|
|
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.chunk;
|
|
CREATE TRIGGER "0_cache_inval" AFTER INSERT OR UPDATE OR DELETE OR TRUNCATE ON _timescaledb_catalog.chunk
|
|
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger('cache_inval_hypertable');
|
|
|
|
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.chunk_constraint;
|
|
CREATE TRIGGER "0_cache_inval" AFTER INSERT OR UPDATE OR DELETE OR TRUNCATE ON _timescaledb_catalog.chunk_constraint
|
|
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger('cache_inval_hypertable');
|
|
|
|
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.dimension_slice;
|
|
CREATE TRIGGER "0_cache_inval" AFTER INSERT OR UPDATE OR DELETE OR TRUNCATE ON _timescaledb_catalog.dimension_slice
|
|
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger('cache_inval_hypertable');
|
|
|
|
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.dimension;
|
|
CREATE TRIGGER "0_cache_inval" AFTER INSERT OR UPDATE OR DELETE OR TRUNCATE ON _timescaledb_catalog.dimension
|
|
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger('cache_inval_hypertable');
|