Revision 12293
Added by Aaron Marcuse-Kubitza almost 11 years ago
util.sql | ||
---|---|---|
2121 | 2121 |
|
2122 | 2122 |
|
2123 | 2123 |
-- |
2124 |
-- Name: remake_diff_table(text, regclass, regclass, text); Type: FUNCTION; Schema: util; Owner: - |
|
2125 |
-- |
|
2126 |
|
|
2127 |
CREATE FUNCTION remake_diff_table(diff_table text, left_table regclass, right_table regclass, type_table text) RETURNS void |
|
2128 |
LANGUAGE sql |
|
2129 |
AS $_$ |
|
2130 |
/* can't have in_table/out_table inherit from *each other*, because inheritance |
|
2131 |
also causes the rows of the parent table to be included in the child table. |
|
2132 |
instead, they need to inherit from a common, empty table. */ |
|
2133 |
SELECT util.drop_table($4, force := true); |
|
2134 |
SELECT util.copy_struct($2, $4); |
|
2135 |
SELECT util.inherit($2, $4); |
|
2136 |
SELECT util.inherit($3, $4); |
|
2137 |
|
|
2138 |
SELECT util.rematerialize_query($1, $$ |
|
2139 |
SELECT * FROM util.diff( |
|
2140 |
$$||quote_nullable($2)||$$ |
|
2141 |
, $$||quote_nullable($3)||$$ |
|
2142 |
, NULL::$$||$4||$$) |
|
2143 |
$$); |
|
2144 |
$_$; |
|
2145 |
|
|
2146 |
|
|
2147 |
-- |
|
2148 |
-- Name: FUNCTION remake_diff_table(diff_table text, left_table regclass, right_table regclass, type_table text); Type: COMMENT; Schema: util; Owner: - |
|
2149 |
-- |
|
2150 |
|
|
2151 |
COMMENT ON FUNCTION remake_diff_table(diff_table text, left_table regclass, right_table regclass, type_table text) IS ' |
|
2152 |
type_table (*required*): table to create as the shared base type |
|
2153 |
'; |
|
2154 |
|
|
2155 |
|
|
2156 |
-- |
|
2124 | 2157 |
-- Name: rematerialize_query(text, text); Type: FUNCTION; Schema: util; Owner: - |
2125 | 2158 |
-- |
2126 | 2159 |
|
Also available in: Unified diff
schemas/util.sql: added remake_diff_table()