liquid_feedback_core
changeset 149:a07cfe298806
Dropped backwards compatiblity functions "array_init_string" and "square_matrix_init_string"
author | jbe |
---|---|
date | Thu Jun 02 02:07:50 2011 +0200 (2011-06-02) |
parents | ec1fdf2fc8c9 |
children | a426ce0124a2 |
files | core.sql |
line diff
1.1 --- a/core.sql Thu Jun 02 01:53:04 2011 +0200 1.2 +++ b/core.sql Thu Jun 02 02:07:50 2011 +0200 1.3 @@ -3623,67 +3623,6 @@ 1.4 COMMENT ON FUNCTION "defeat_strength"(INT4, INT4) IS 'Calculates defeat strength (INT8!) of a pairwise defeat primarily by the absolute number of votes for the winner and secondarily by the absolute number of votes for the loser'; 1.5 1.6 1.7 -CREATE FUNCTION "array_init_string"("dim_p" INTEGER) 1.8 - RETURNS TEXT 1.9 - LANGUAGE 'plpgsql' IMMUTABLE AS $$ 1.10 - DECLARE 1.11 - "i" INTEGER; 1.12 - "ary_text_v" TEXT; 1.13 - BEGIN 1.14 - IF "dim_p" >= 1 THEN 1.15 - "ary_text_v" := '{NULL'; 1.16 - "i" := "dim_p"; 1.17 - LOOP 1.18 - "i" := "i" - 1; 1.19 - EXIT WHEN "i" = 0; 1.20 - "ary_text_v" := "ary_text_v" || ',NULL'; 1.21 - END LOOP; 1.22 - "ary_text_v" := "ary_text_v" || '}'; 1.23 - RETURN "ary_text_v"; 1.24 - ELSE 1.25 - RAISE EXCEPTION 'Dimension needs to be at least 1.'; 1.26 - END IF; 1.27 - END; 1.28 - $$; 1.29 - 1.30 -COMMENT ON FUNCTION "array_init_string"(INTEGER) IS 'Needed for PostgreSQL < 8.4, due to missing "array_fill" function'; 1.31 - 1.32 - 1.33 -CREATE FUNCTION "square_matrix_init_string"("dim_p" INTEGER) 1.34 - RETURNS TEXT 1.35 - LANGUAGE 'plpgsql' IMMUTABLE AS $$ 1.36 - DECLARE 1.37 - "i" INTEGER; 1.38 - "row_text_v" TEXT; 1.39 - "ary_text_v" TEXT; 1.40 - BEGIN 1.41 - IF "dim_p" >= 1 THEN 1.42 - "row_text_v" := '{NULL'; 1.43 - "i" := "dim_p"; 1.44 - LOOP 1.45 - "i" := "i" - 1; 1.46 - EXIT WHEN "i" = 0; 1.47 - "row_text_v" := "row_text_v" || ',NULL'; 1.48 - END LOOP; 1.49 - "row_text_v" := "row_text_v" || '}'; 1.50 - "ary_text_v" := '{' || "row_text_v"; 1.51 - "i" := "dim_p"; 1.52 - LOOP 1.53 - "i" := "i" - 1; 1.54 - EXIT WHEN "i" = 0; 1.55 - "ary_text_v" := "ary_text_v" || ',' || "row_text_v"; 1.56 - END LOOP; 1.57 - "ary_text_v" := "ary_text_v" || '}'; 1.58 - RETURN "ary_text_v"; 1.59 - ELSE 1.60 - RAISE EXCEPTION 'Dimension needs to be at least 1.'; 1.61 - END IF; 1.62 - END; 1.63 - $$; 1.64 - 1.65 -COMMENT ON FUNCTION "square_matrix_init_string"(INTEGER) IS 'Needed for PostgreSQL < 8.4, due to missing "array_fill" function'; 1.66 - 1.67 - 1.68 CREATE FUNCTION "calculate_ranks"("issue_id_p" "issue"."id"%TYPE) 1.69 RETURNS VOID 1.70 LANGUAGE 'plpgsql' VOLATILE AS $$ 1.71 @@ -3707,7 +3646,7 @@ 1.72 IF "dimension_v" > 1 THEN 1.73 -- Create "vote_matrix" with absolute number of votes in pairwise 1.74 -- comparison: 1.75 - "vote_matrix" := "square_matrix_init_string"("dimension_v"); -- TODO: replace by "array_fill" function (PostgreSQL 8.4) 1.76 + "vote_matrix" := array_fill(NULL::INT4, ARRAY["dimension_v", "dimension_v"]); 1.77 "i" := 1; 1.78 "j" := 2; 1.79 FOR "battle_row" IN 1.80 @@ -3732,7 +3671,7 @@ 1.81 END IF; 1.82 -- Store defeat strengths in "matrix" using "defeat_strength" 1.83 -- function: 1.84 - "matrix" := "square_matrix_init_string"("dimension_v"); -- TODO: replace by "array_fill" function (PostgreSQL 8.4) 1.85 + "matrix" := array_fill(NULL::INT8, ARRAY["dimension_v", "dimension_v"]); 1.86 "i" := 1; 1.87 LOOP 1.88 "j" := 1; 1.89 @@ -3779,7 +3718,7 @@ 1.90 "i" := "i" + 1; 1.91 END LOOP; 1.92 -- Determine order of winners: 1.93 - "rank_ary" := "array_init_string"("dimension_v"); -- TODO: replace by "array_fill" function (PostgreSQL 8.4) 1.94 + "rank_ary" := array_fill(NULL::INT4, ARRAY["dimension_v"]); 1.95 "rank_v" := 1; 1.96 "done_v" := 0; 1.97 LOOP