Revision 12280
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/schemas/util.sql | ||
---|---|---|
922 | 922 |
|
923 | 923 |
|
924 | 924 |
-- |
925 |
-- Name: diff_queries(text, text, anyelement); Type: FUNCTION; Schema: util; Owner: -
|
|
925 |
-- Name: diff_any(text, text, anyelement); Type: FUNCTION; Schema: util; Owner: -
|
|
926 | 926 |
-- |
927 | 927 |
|
928 |
CREATE FUNCTION diff_queries(left_query text, right_query text, col_type_null anyelement, OUT left_ anyelement, OUT right_ anyelement) RETURNS SETOF record
|
|
928 |
CREATE FUNCTION diff_any(left_ text, right_ text, col_type_null anyelement, OUT left_ anyelement, OUT right_ anyelement) RETURNS SETOF record
|
|
929 | 929 |
LANGUAGE sql STABLE |
930 | 930 |
AS $_$ |
931 | 931 |
SELECT * FROM |
932 | 932 |
util.eval2col_pair($$ |
933 |
SELECT left_, right_ FROM |
|
934 |
( |
|
935 |
$$||$1||$$ |
|
936 |
) left_ |
|
937 |
FULL JOIN |
|
938 |
( |
|
939 |
$$||$2||$$ |
|
940 |
) right_ |
|
933 |
SELECT left_, right_ |
|
934 |
FROM $$||$1||$$ left_ |
|
935 |
FULL JOIN $$||$2||$$ right_ |
|
941 | 936 |
ON left_ = right_ |
942 | 937 |
WHERE left_ IS DISTINCT FROM right_ |
943 | 938 |
ORDER BY left_, right_ |
... | ... | |
946 | 941 |
|
947 | 942 |
|
948 | 943 |
-- |
944 |
-- Name: FUNCTION diff_any(left_ text, right_ text, col_type_null anyelement, OUT left_ anyelement, OUT right_ anyelement); Type: COMMENT; Schema: util; Owner: - |
|
945 |
-- |
|
946 |
|
|
947 |
COMMENT ON FUNCTION diff_any(left_ text, right_ text, col_type_null anyelement, OUT left_ anyelement, OUT right_ anyelement) IS ' |
|
948 |
col_type_null (*required*): NULL::col_type |
|
949 |
'; |
|
950 |
|
|
951 |
|
|
952 |
-- |
|
953 |
-- Name: diff_queries(text, text, anyelement); Type: FUNCTION; Schema: util; Owner: - |
|
954 |
-- |
|
955 |
|
|
956 |
CREATE FUNCTION diff_queries(left_query text, right_query text, col_type_null anyelement, OUT left_ anyelement, OUT right_ anyelement) RETURNS SETOF record |
|
957 |
LANGUAGE sql STABLE |
|
958 |
AS $_$ |
|
959 |
SELECT * FROM util.diff_any('('||$1||')', '('||$2||')', $3) |
|
960 |
$_$; |
|
961 |
|
|
962 |
|
|
963 |
-- |
|
949 | 964 |
-- Name: FUNCTION diff_queries(left_query text, right_query text, col_type_null anyelement, OUT left_ anyelement, OUT right_ anyelement); Type: COMMENT; Schema: util; Owner: - |
950 | 965 |
-- |
951 | 966 |
|
... | ... | |
968 | 983 |
CREATE FUNCTION diff_views(left_view regclass, right_view regclass, col_type_null anyelement, OUT left_ anyelement, OUT right_ anyelement) RETURNS SETOF record |
969 | 984 |
LANGUAGE sql STABLE |
970 | 985 |
AS $_$ |
971 |
SELECT * FROM util.diff_queries($$SELECT * FROM $$||$1, $$SELECT * FROM $$||$2, $3)
|
|
986 |
SELECT * FROM util.diff_any($1::text, $2::text, $3)
|
|
972 | 987 |
$_$; |
973 | 988 |
|
974 | 989 |
|
Also available in: Unified diff
bugfix: schemas/util.sql: diff_queries(), diff_views(): embed views verbatim as FROM items, so that the type of their corresponding columns is the view's rowtype. this is necessary in order to match the types of the columns to the return type (set by col_type_null).