Project

General

Profile

« Previous | Next » 

Revision 13486

schemas/util.sql: added restore_views() and use it in force_recreate()

View differences:

trunk/schemas/util.sql
1808 1808
	recreate_users_cmds text[] = util.save_drop_views(users);
1809 1809
BEGIN
1810 1810
	PERFORM util.eval(cmd);
1811
	PERFORM util.create_if_not_exists(recreate_cmd)
1812
	FROM unnest(recreate_users_cmds) recreate_cmd; --in forward dependency order
1813
		/* create_if_not_exists() rather than eval(), because cmd might manually
1814
		re-create a deleted dependent view, causing it to already exist */
1811
	PERFORM util.restore_views(recreate_users_cmds);
1815 1812
EXCEPTION
1816 1813
WHEN dependent_objects_still_exist THEN
1817 1814
	IF users IS NOT NULL THEN RAISE; END IF; -- save_drop_views() didn't fix it
......
3306 3303

  
3307 3304

  
3308 3305
--
3306
-- Name: restore_views(text[]); Type: FUNCTION; Schema: util; Owner: -
3307
--
3308

  
3309
CREATE FUNCTION restore_views(views text[]) RETURNS void
3310
    LANGUAGE sql
3311
    AS $_$
3312
SELECT util.debug_print_var('views', $1);
3313
SELECT util.create_if_not_exists(recreate_cmd)
3314
FROM unnest($1) recreate_cmd; -- in forward dependency order
3315
	/* create_if_not_exists() rather than eval(), because cmd might manually
3316
	re-create a deleted dependent view, causing it to already exist */
3317
SELECT NULL::void; -- don't fold away functions called in previous query
3318
$_$;
3319

  
3320

  
3321
--
3309 3322
-- Name: rm_freq(regclass[], text); Type: FUNCTION; Schema: util; Owner: -
3310 3323
--
3311 3324

  

Also available in: Unified diff