Revision 14640
Added by Aaron Marcuse-Kubitza over 10 years ago
trunk/schemas/util.sql | ||
---|---|---|
4819 | 4819 |
|
4820 | 4820 |
|
4821 | 4821 |
-- |
4822 |
-- Name: relation_replace(text, anyelement); Type: FUNCTION; Schema: util; Owner: - |
|
4823 |
-- |
|
4824 |
|
|
4825 |
CREATE FUNCTION relation_replace(replace text, with_ anyelement) RETURNS void |
|
4826 |
LANGUAGE sql |
|
4827 |
AS $_$ |
|
4828 |
SELECT CASE WHEN with_::text != replace THEN -- don't drop the relation to keep! |
|
4829 |
util.recreate($$ |
|
4830 |
SELECT util.drop_relation(util.relation_type($$||util.quote_typed(with_) |
|
4831 |
||$$), $$||util.quote_typed(replace)||$$); |
|
4832 |
SELECT util.rename_relation($$||util.quote_typed(with_)||$$, $$|| |
|
4833 |
util.quote_typed(replace)||$$); |
|
4834 |
$$) |
|
4835 |
END |
|
4836 |
$_$; |
|
4837 |
|
|
4838 |
|
|
4839 |
-- |
|
4822 | 4840 |
-- Name: relation_type(regclass); Type: FUNCTION; Schema: util; Owner: - |
4823 | 4841 |
-- |
4824 | 4842 |
|
Also available in: Unified diff
schemas/util.sql: added relation_replace()