Add warning to event trigger
This commit is contained in:
parent
5b95cfddf4
commit
eefb16763e
1 changed files with 16 additions and 8 deletions
|
|
@ -25,17 +25,25 @@ $$
|
|||
DECLARE
|
||||
old_search_path text;
|
||||
BEGIN
|
||||
-- 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 = '';
|
||||
-- Only need to refresh query strings if an object is renamed.
|
||||
-- As a rough heuristic, check if this is an ALTER command.
|
||||
IF tg_tag LIKE 'ALTER %' THEN
|
||||
-- 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.
|
||||
IF old_search_path != '' AND old_search_path != '""' THEN
|
||||
EXECUTE format('SET search_path = %s', old_search_path);
|
||||
-- Reset search path to the original value.
|
||||
IF old_search_path != '' AND old_search_path != '""' THEN
|
||||
EXECUTE format('SET search_path = %s', old_search_path);
|
||||
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
|
||||
$$;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue