Project

General

Profile

« Previous | Next » 

Revision 13606

schemas/util.sql: recreate_view(): support omitting the view_query if the view has already been modified (eg. for public.*_view, which allow changing the view as a separate step)

View differences:

util.sql
3129 3129
-- Name: recreate_view(regclass, text, text); Type: FUNCTION; Schema: util; Owner: -
3130 3130
--
3131 3131

  
3132
CREATE FUNCTION recreate_view(view_ regclass, view_query text, dependent_view_changes text DEFAULT ''::text) RETURNS void
3132
CREATE FUNCTION recreate_view(view_ regclass, view_query text DEFAULT NULL::text, dependent_view_changes text DEFAULT ''::text) RETURNS void
3133 3133
    LANGUAGE sql
3134 3134
    AS $_$
3135 3135
SELECT util.recreate($$
3136 3136
CREATE VIEW $$||$1||$$ AS 
3137
$$||$2||$$
3138
;
3137
$$||COALESCE($2, pg_get_viewdef($1))||$$;
3139 3138
$$||util.mk_set_relation_metadata($1)||$$
3140 3139

  
3141 3140
-- manually restore views that need to be updated for the changes
......
3158 3157
$$||util.mk_set_relation_metadata(''schema.dependent_view'')||$$
3159 3158
$$);
3160 3159

  
3160
if view has already been modified:
3161
SELECT util.recreate_view(''schema.main_view'', dependent_view_changes := $$
3162
CREATE VIEW schema.dependent_view AS 
3163
__;
3164
$$||util.mk_set_relation_metadata(''schema.dependent_view'')||$$
3165
$$);
3166

  
3161 3167
idempotent
3162 3168
';
3163 3169

  

Also available in: Unified diff