From 4a3d381d4d223aeb0239ff1840e90a3e74aba6aa Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Tue, 2 Jun 2026 20:24:51 +0200 Subject: [PATCH] Add compatibility view for chunk_constraint --- cmake/ScriptFiles.cmake | 1 + sql/updates/reverse-dev.sql | 8 +++----- sql/views.sql | 6 ------ sql/views_compat.sql | 18 ++++++++++++++++++ test/expected/drop_rename_hypertable.out | 1 + test/expected/pg_dump.out | 1 + 6 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 sql/views_compat.sql diff --git a/cmake/ScriptFiles.cmake b/cmake/ScriptFiles.cmake index d8df1359fee..dc17faaa3bf 100644 --- a/cmake/ScriptFiles.cmake +++ b/cmake/ScriptFiles.cmake @@ -44,6 +44,7 @@ set(SOURCE_FILES uuidv7.sql ts_stats.sql views.sql + views_compat.sql views_experimental.sql gapfill.sql compression.sql diff --git a/sql/updates/reverse-dev.sql b/sql/updates/reverse-dev.sql index 7edbf7d395e..4274cf1a29e 100644 --- a/sql/updates/reverse-dev.sql +++ b/sql/updates/reverse-dev.sql @@ -1,8 +1,6 @@ --- The PL/pgSQL helper switched to scalar args in the forward direction; --- drop it so the target version's chunk_constraint.sql can restore the --- row-typed signature. -DROP FUNCTION IF EXISTS _timescaledb_functions.chunk_constraint_add_table_constraint( - integer, name, name); + +DROP VIEW IF EXISTS _timescaledb_catalog.chunk_constraint; +DROP FUNCTION IF EXISTS _timescaledb_functions.chunk_constraint_add_table_constraint( integer, name, name); -- Recreate the chunk_constraint catalog table. CREATE TABLE _timescaledb_catalog.chunk_constraint ( diff --git a/sql/views.sql b/sql/views.sql index 7a00b52ede5..822dc31f45b 100644 --- a/sql/views.sql +++ b/sql/views.sql @@ -424,10 +424,6 @@ AS SELECT * FROM timescaledb_information.hypertable_compression_settings; CREATE OR REPLACE VIEW timescaledb_information.chunk_columnstore_settings AS SELECT * FROM timescaledb_information.chunk_compression_settings; ---temporary alias for bgw_job -CREATE OR REPLACE VIEW _timescaledb_config.bgw_job AS -SELECT * from _timescaledb_catalog.bgw_job; - -- chunk statistics view CREATE OR REPLACE VIEW timescaledb_information.stat_chunk_activity AS SELECT @@ -496,6 +492,4 @@ LEFT JOIN _timescaledb_catalog.chunk c ON format('%I.%I', c.schema_name, c.table_name)::regclass = o.uncompressed_relid LEFT JOIN _timescaledb_catalog.hypertable h ON h.id = c.hypertable_id; - -GRANT SELECT ON ALL TABLES IN SCHEMA _timescaledb_config TO PUBLIC; GRANT SELECT ON ALL TABLES IN SCHEMA timescaledb_information TO PUBLIC; diff --git a/sql/views_compat.sql b/sql/views_compat.sql new file mode 100644 index 00000000000..159fafadeba --- /dev/null +++ b/sql/views_compat.sql @@ -0,0 +1,18 @@ +-- 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. + +-- temporary views for compatibility + +CREATE OR REPLACE VIEW _timescaledb_config.bgw_job AS +SELECT * from _timescaledb_catalog.bgw_job; + +CREATE OR REPLACE VIEW _timescaledb_catalog.chunk_constraint AS +SELECT + chunk_id, + id AS dimension_slice_id, + format('constraint_%s',id) AS constraint_name, + NULL::text AS hypertable_constraint_name from _timescaledb_catalog.dimension_slice; + +GRANT SELECT ON ALL TABLES IN SCHEMA _timescaledb_config TO PUBLIC; +GRANT SELECT ON ALL TABLES IN SCHEMA _timescaledb_catalog TO PUBLIC; diff --git a/test/expected/drop_rename_hypertable.out b/test/expected/drop_rename_hypertable.out index c74272457ea..79238ab5cfa 100644 --- a/test/expected/drop_rename_hypertable.out +++ b/test/expected/drop_rename_hypertable.out @@ -183,6 +183,7 @@ SELECT schema, name FROM test.relation WHERE schema IN ('public', '_timescaledb_ _timescaledb_catalog | bgw_job _timescaledb_catalog | chunk _timescaledb_catalog | chunk_column_stats + _timescaledb_catalog | chunk_constraint _timescaledb_catalog | chunk_rewrite _timescaledb_catalog | compression_algorithm _timescaledb_catalog | compression_chunk_size diff --git a/test/expected/pg_dump.out b/test/expected/pg_dump.out index 6614bcf81a0..2aaa0f6159a 100644 --- a/test/expected/pg_dump.out +++ b/test/expected/pg_dump.out @@ -397,6 +397,7 @@ WHERE refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass AND _timescaledb_cache.cache_inval_bgw_job _timescaledb_cache.cache_inval_extension _timescaledb_cache.cache_inval_hypertable + _timescaledb_catalog.chunk_constraint _timescaledb_catalog.chunk_rewrite _timescaledb_catalog.compression_algorithm _timescaledb_catalog.tablespace_id_seq