Add warning to event trigger

This commit is contained in:
Adam Guo 2025-03-27 14:46:07 +00:00
parent 5b95cfddf4
commit eefb16763e

View file

@ -25,17 +25,25 @@ $$
DECLARE DECLARE
old_search_path text; old_search_path text;
BEGIN BEGIN
-- Empty search path so that get_immv_def returns a fully-qualified query. -- Only need to refresh query strings if an object is renamed.
SELECT setting INTO old_search_path FROM pg_catalog.pg_settings -- As a rough heuristic, check if this is an ALTER command.
WHERE name = 'search_path'; IF tg_tag LIKE 'ALTER %' THEN
SET search_path = ''; -- Empty search path so that get_immv_def returns a fully-qualified query.
SELECT setting INTO old_search_path FROM pg_catalog.pg_settings
WHERE name = 'search_path';
SET search_path = '';
UPDATE pgivm.pg_ivm_immv SET querystring = pgivm.get_immv_def(immvrelid); UPDATE pgivm.pg_ivm_immv SET querystring = pgivm.get_immv_def(immvrelid);
-- Reset search path to the original value. -- Reset search path to the original value.
IF old_search_path != '' AND old_search_path != '""' THEN IF old_search_path != '' AND old_search_path != '""' THEN
EXECUTE format('SET search_path = %s', old_search_path); EXECUTE format('SET search_path = %s', old_search_path);
END IF;
END IF; END IF;
EXCEPTION
WHEN internal_error THEN
RAISE WARNING 'pg_ivm could not refresh the pg_ivm_immv query strings.'
USING HINT = 'Please recreate your IMMVs using pgivm.recreate_all_immvs().';
END END
$$; $$;