Project

General

Profile

« Previous | Next » 

Revision 12653

bugfix: schemas/util.sql: diff(regclass, regclass): need to create a diff when the # of copies of a row differs between the tables. this uses new util.to_freq().

View differences:

trunk/schemas/util.sql
1037 1037
CREATE FUNCTION diff(left_table regclass, right_table regclass, col_type_null anyelement, OUT left_ anyelement, OUT right_ anyelement) RETURNS SETOF record
1038 1038
    LANGUAGE sql
1039 1039
    AS $_$
1040
SELECT * FROM util.diff($1::text, $2::text, $3,
1041
	single_row := util.has_single_row($1) AND util.has_single_row($2))
1040
-- create a diff when the # of copies of a row differs between the tables
1041
SELECT util.to_freq($1);
1042
SELECT util.to_freq($2);
1043
SELECT util.eval($$ALTER TABLE $$||util.typeof($3)||$$ ADD COLUMN copies bigint NOT NULL$$);
1044

  
1045
SELECT * FROM util.diff($1, $2, $3, has_freq := true)
1042 1046
$_$;
1043 1047

  
1044 1048

  
......
1047 1051
--
1048 1052

  
1049 1053
COMMENT ON FUNCTION diff(left_table regclass, right_table regclass, col_type_null anyelement, OUT left_ anyelement, OUT right_ anyelement) IS '
1050
col_type_null (*required*): NULL::shared_base_type
1051 1054
usage:
1052 1055
SELECT * FROM util.diff(''"left_table"''::regclass, ''"right_table"''::regclass, NULL::shared_base_type)
1056

  
1057
col_type_null (*required*): NULL::shared_base_type
1053 1058
';
1054 1059

  
1055 1060

  
......
1117 1122

  
1118 1123

  
1119 1124
--
1125
-- Name: diff(regclass, regclass, anyelement, boolean); Type: FUNCTION; Schema: util; Owner: -
1126
--
1127

  
1128
CREATE FUNCTION diff(left_table regclass, right_table regclass, col_type_null anyelement, has_freq boolean, OUT left_ anyelement, OUT right_ anyelement) RETURNS SETOF record
1129
    LANGUAGE sql
1130
    AS $_$
1131
SELECT * FROM util.diff($1::text, $2::text, $3,
1132
	single_row := util.has_single_row($1) AND util.has_single_row($2))
1133
$_$;
1134

  
1135

  
1136
--
1137
-- Name: FUNCTION diff(left_table regclass, right_table regclass, col_type_null anyelement, has_freq boolean, OUT left_ anyelement, OUT right_ anyelement); Type: COMMENT; Schema: util; Owner: -
1138
--
1139

  
1140
COMMENT ON FUNCTION diff(left_table regclass, right_table regclass, col_type_null anyelement, has_freq boolean, OUT left_ anyelement, OUT right_ anyelement) IS '
1141
helper function used by diff(regclass, regclass)
1142

  
1143
usage:
1144
SELECT * FROM util.diff(''"left_freq_table"''::regclass, ''"right_freq_table"''::regclass, NULL::shared_base_type, has_freq := true)
1145

  
1146
col_type_null (*required*): NULL::shared_base_type
1147
';
1148

  
1149

  
1150
--
1120 1151
-- Name: do_optionally_ignore(text, boolean); Type: FUNCTION; Schema: util; Owner: -
1121 1152
--
1122 1153

  

Also available in: Unified diff