Revision 12429
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/schemas/util.sql | ||
---|---|---|
1020 | 1020 |
|
1021 | 1021 |
|
1022 | 1022 |
-- |
1023 |
-- Name: diff(text, text, anyelement, boolean); Type: FUNCTION; Schema: util; Owner: - |
|
1023 |
-- Name: diff(text, text, anyelement, boolean, text); Type: FUNCTION; Schema: util; Owner: -
|
|
1024 | 1024 |
-- |
1025 | 1025 |
|
1026 |
CREATE FUNCTION diff(left__ text, right__ text, col_type_null anyelement, single_row boolean DEFAULT false, OUT left_ anyelement, OUT right_ anyelement) RETURNS SETOF record |
|
1027 |
LANGUAGE sql |
|
1028 |
SET search_path TO util
|
|
1026 |
CREATE FUNCTION diff(left__ text, right__ text, col_type_null anyelement, single_row boolean DEFAULT false, search_path text DEFAULT NULL::text, OUT left_ anyelement, OUT right_ anyelement) RETURNS SETOF record
|
|
1027 |
LANGUAGE plpgsql
|
|
1028 |
SET search_path TO pg_temp
|
|
1029 | 1029 |
AS $_$ |
1030 |
SELECT * FROM |
|
1031 |
util.eval2col_pair($$ |
|
1030 |
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime |
|
1031 |
changes of search_path (schema elements are bound at inline time rather than |
|
1032 |
runtime) */ |
|
1033 |
/* function option search_path is needed to limit the effects of |
|
1034 |
`SET LOCAL search_path` (mk_set_search_path()) to the current function */ |
|
1035 |
BEGIN |
|
1036 |
EXECUTE util.mk_set_search_path(concat_ws(', ', search_path, 'util')); |
|
1037 |
-- need util.%== as default/fallback |
|
1038 |
|
|
1039 |
RETURN QUERY |
|
1040 |
SELECT * FROM |
|
1041 |
util.eval2col_pair($$ |
|
1032 | 1042 |
/* need to explicitly cast each side to the return type because this does not |
1033 | 1043 |
happen automatically even when an implicit cast is available */ |
1034 | 1044 |
SELECT left_::$$||pg_typeof($3)||$$, right_::$$||pg_typeof($3)||$$ |
... | ... | |
1040 | 1050 |
$$WHERE left_::$$||pg_typeof($3)||$$ IS DISTINCT FROM right_::$$||pg_typeof($3)||$$ |
1041 | 1051 |
ORDER BY left_, right_ |
1042 | 1052 |
$$, $3) |
1053 |
; |
|
1054 |
END; |
|
1043 | 1055 |
$_$; |
1044 | 1056 |
|
1045 | 1057 |
|
1046 | 1058 |
-- |
1047 |
-- Name: FUNCTION diff(left__ text, right__ text, col_type_null anyelement, single_row boolean, OUT left_ anyelement, OUT right_ anyelement); Type: COMMENT; Schema: util; Owner: - |
|
1059 |
-- Name: FUNCTION diff(left__ text, right__ text, col_type_null anyelement, single_row boolean, search_path text, OUT left_ anyelement, OUT right_ anyelement); Type: COMMENT; Schema: util; Owner: -
|
|
1048 | 1060 |
-- |
1049 | 1061 |
|
1050 |
COMMENT ON FUNCTION diff(left__ text, right__ text, col_type_null anyelement, single_row boolean, OUT left_ anyelement, OUT right_ anyelement) IS ' |
|
1062 |
COMMENT ON FUNCTION diff(left__ text, right__ text, col_type_null anyelement, single_row boolean, search_path text, OUT left_ anyelement, OUT right_ anyelement) IS '
|
|
1051 | 1063 |
col_type_null (*required*): NULL::col_type |
1052 | 1064 |
single_row: whether the tables consist of a single row, which should be |
1053 | 1065 |
displayed side-by-side |
Also available in: Unified diff
schemas/util.sql: diff(text, text): support custom search_path because custom %== operators are usually not in the util schema