Skip to content

Commit 897a13c

Browse files
committed
Add check for _timescaledb_catalog.chunk_column_stats with range_start > range_end
1 parent 9afc0d9 commit 897a13c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

diagnostic.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ BEGIN
1919
END
2020
$$ SET search_path = pg_catalog, pg_temp;
2121

22+
CREATE OR REPLACE FUNCTION pg_temp.check_catalog_corruption() RETURNS void LANGUAGE plpgsql AS
23+
$$
24+
DECLARE
25+
v_count int8;
26+
BEGIN
27+
SELECT count(*) INTO v_count FROM _timescaledb_catalog.chunk_column_stats WHERE range_start > range_end;
28+
IF v_count >= 1 THEN
29+
RAISE WARNING 'Found %s entries in _timescaledb_catalog.chunk_column_stats with range_start > range_end', v_count;
30+
END IF;
31+
END
32+
$$ SET search_path = pg_catalog, pg_temp;
33+
2234
CREATE OR REPLACE FUNCTION pg_temp.check_scheduler_present() RETURNS void LANGUAGE plpgsql AS
2335
$$
2436
DECLARE

0 commit comments

Comments
 (0)