Project

General

Profile

« Previous | Next » 

Revision 13491

schemas/util.sql: save_drop_views()/restore_views(): store the view path in addition to the definition so it can be used in restoring

View differences:

trunk/schemas/util.sql
72 72

  
73 73

  
74 74
--
75
-- Name: db_item; Type: TYPE; Schema: util; Owner: -
76
--
77

  
78
CREATE TYPE db_item AS (
79
	path text,
80
	def text
81
);
82

  
83

  
84
--
75 85
-- Name: restore_views_info; Type: TYPE; Schema: util; Owner: -
76 86
--
77 87

  
78 88
CREATE TYPE restore_views_info AS (
79
	recreate_cmds text[]
89
	views db_item[]
80 90
);
81 91

  
82 92

  
......
3320 3330
    LANGUAGE sql
3321 3331
    AS $_$
3322 3332
SELECT util.debug_print_var('views', $1);
3323
SELECT util.create_if_not_exists(recreate_cmd)
3324
FROM unnest($1.recreate_cmds) recreate_cmd; -- in forward dependency order
3333
SELECT util.create_if_not_exists((view_).def)
3334
FROM unnest($1.views) view_; -- in forward dependency order
3325 3335
	/* create_if_not_exists() rather than eval(), because cmd might manually
3326 3336
	re-create a deleted dependent view, causing it to already exist */
3327 3337
SELECT NULL::void; -- don't fold away functions called in previous query
......
3395 3405
    LANGUAGE sql
3396 3406
    AS $_$
3397 3407
SELECT ROW(/*return in forward dependency order*/util.array_reverse(array(
3398
SELECT util.save_drop_view(view_)
3408
SELECT (view_, util.save_drop_view(view_))::util.db_item
3399 3409
FROM unnest(/*drop in reverse dependency order*/util.array_reverse($1)) view_
3400 3410
)))::util.restore_views_info
3401 3411
$_$;

Also available in: Unified diff