Project

General

Profile

« Previous | Next » 

Revision 12478

schemas/util.sql: mk_diff_query(): parameterized the customizable parts of the query, to allow them to be replaced with their EXPLAIN expansion (which is what we ultimately want, so that the query does not refer to any internal tables or views)

View differences:

trunk/schemas/util.sql
2027 2027

  
2028 2028

  
2029 2029
--
2030
-- Name: mk_diff_query(text, text, boolean); Type: FUNCTION; Schema: util; Owner: -
2030
-- Name: mk_diff_query(text, text, boolean, text, text, text); Type: FUNCTION; Schema: util; Owner: -
2031 2031
--
2032 2032

  
2033
CREATE FUNCTION mk_diff_query(left_ text, right_ text, single_row boolean DEFAULT false) RETURNS text
2033
CREATE FUNCTION mk_diff_query(left_ text, right_ text, single_row boolean DEFAULT false, cols text DEFAULT 'left_, right_'::text, join_cond text DEFAULT 'left_ %== right_ -- refer to EXPLAIN output for expansion of %=='::text, filter text DEFAULT 'left_ IS DISTINCT FROM right_'::text) RETURNS text
2034 2034
    LANGUAGE sql IMMUTABLE
2035 2035
    AS $_$
2036 2036
SELECT
2037
$$SELECT left_, right_
2037
$$SELECT
2038
$$||$4||$$
2038 2039
FROM $$||$1||$$ left_
2039 2040
$$||util._if($3, 'CROSS'::text, 'FULL')||$$ JOIN $$||$2||$$ right_
2040 2041
$$||util._if($3, ''::text,
2041
$$ON left_ %== right_ -- refer to EXPLAIN output for expansion of %==
2042
$$ON $$||$5||$$
2042 2043
$$)||
2043
$$WHERE left_ IS DISTINCT FROM right_
2044
$$WHERE $$||$6||$$
2044 2045
ORDER BY left_, right_
2045 2046
$$
2046 2047
$_$;
2047 2048

  
2048 2049

  
2049 2050
--
2050
-- Name: FUNCTION mk_diff_query(left_ text, right_ text, single_row boolean); Type: COMMENT; Schema: util; Owner: -
2051
-- Name: FUNCTION mk_diff_query(left_ text, right_ text, single_row boolean, cols text, join_cond text, filter text); Type: COMMENT; Schema: util; Owner: -
2051 2052
--
2052 2053

  
2053
COMMENT ON FUNCTION mk_diff_query(left_ text, right_ text, single_row boolean) IS '
2054
COMMENT ON FUNCTION mk_diff_query(left_ text, right_ text, single_row boolean, cols text, join_cond text, filter text) IS '
2054 2055
single_row: whether the tables consist of a single row, which should be
2055 2056
	displayed side-by-side
2056 2057
';

Also available in: Unified diff