Revision 12352
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/schemas/vegbien.my.sql | ||
---|---|---|
952 | 952 |
|
953 | 953 |
|
954 | 954 |
-- |
955 |
-- Name: rename_query_view(regclass, varchar(255), anyelement); Type: FUNCTION; Schema: public_validations; Owner: - |
|
956 |
-- |
|
957 |
|
|
958 |
|
|
959 |
|
|
960 |
|
|
961 |
-- |
|
962 |
-- Name: FUNCTION rename_query_view(from_ regclass, to_ varchar(255), schema_anchor anyelement); Type: COMMENT; Schema: public_validations; Owner: - |
|
963 |
-- |
|
964 |
|
|
965 |
|
|
966 |
|
|
967 |
|
|
968 |
-- |
|
955 | 969 |
-- Name: rm_query_view(regclass, anyelement); Type: FUNCTION; Schema: public_validations; Owner: - |
956 | 970 |
-- |
957 | 971 |
|
trunk/schemas/vegbien.sql | ||
---|---|---|
2173 | 2173 |
|
2174 | 2174 |
|
2175 | 2175 |
-- |
2176 |
-- Name: rename_query_view(regclass, text, anyelement); Type: FUNCTION; Schema: public_validations; Owner: - |
|
2177 |
-- |
|
2178 |
|
|
2179 |
CREATE FUNCTION rename_query_view(from_ regclass, to_ text, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void |
|
2180 |
LANGUAGE plpgsql |
|
2181 |
SET search_path TO pg_temp |
|
2182 |
AS $$ |
|
2183 |
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime |
|
2184 |
changes of search_path (schema elements are bound at inline time rather than |
|
2185 |
runtime) */ |
|
2186 |
/* function option search_path is needed to limit the effects of |
|
2187 |
`SET LOCAL search_path` (mk_set_search_path()) to the current function */ |
|
2188 |
BEGIN |
|
2189 |
EXECUTE util.mk_use_own_schema(schema_anchor); |
|
2190 |
|
|
2191 |
PERFORM util.rename_relation(view_, |
|
2192 |
new_query_view_relation_name(util.name(from_), to_, util.name(view_))) |
|
2193 |
FROM query_relations(from_) view_ |
|
2194 |
; |
|
2195 |
END; |
|
2196 |
$$; |
|
2197 |
|
|
2198 |
|
|
2199 |
-- |
|
2200 |
-- Name: FUNCTION rename_query_view(from_ regclass, to_ text, schema_anchor anyelement); Type: COMMENT; Schema: public_validations; Owner: - |
|
2201 |
-- |
|
2202 |
|
|
2203 |
COMMENT ON FUNCTION rename_query_view(from_ regclass, to_ text, schema_anchor anyelement) IS ' |
|
2204 |
renames all DB objects related to a particular validations query |
|
2205 |
|
|
2206 |
usage: |
|
2207 |
SELECT public_validations.rename_query_view(''public_validations._view_name''); |
|
2208 |
|
|
2209 |
idempotent |
|
2210 |
|
|
2211 |
schema_anchor: identifies which schema to use. should be left as the default value. |
|
2212 |
'; |
|
2213 |
|
|
2214 |
|
|
2215 |
-- |
|
2176 | 2216 |
-- Name: rm_query_view(regclass, anyelement); Type: FUNCTION; Schema: public_validations; Owner: - |
2177 | 2217 |
-- |
2178 | 2218 |
|
Also available in: Unified diff
schemas/vegbien.sql: added rename_query_view(), which renames all DB objects related to a particular validations query