mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-16 02:23:49 +08:00
This patch stores the current catalog version in an internal table to allow us to verify catalog and code version match. When doing dump/restore people occasionally report very unusual errors and during investigation it is discovered that they loaded a dump from an older version and run it with a later code version. This allows to detect mismatches between installed code version and loaded dump version. The version number in the metadata table will be kept updated in upgrade and downgrade scripts.
15 lines
503 B
SQL
15 lines
503 B
SQL
-- 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.
|
|
|
|
DO $$
|
|
DECLARE
|
|
catalog_version TEXT;
|
|
BEGIN
|
|
SELECT value INTO catalog_version FROM _timescaledb_catalog.metadata WHERE key='timescaledb_version' AND value <> '@START_VERSION@';
|
|
IF FOUND THEN
|
|
RAISE EXCEPTION 'catalog version mismatch, expected "%" seen "%"', '@START_VERSION@', catalog_version;
|
|
END IF;
|
|
END$$;
|
|
|