|| ' THEN 2'
|| ' ELSE'
|| ' ((1.0 - '
- || '(least(' || coalesce(quote_literal(parsed.address || '.0'),'NULL') || '::numeric,to_number(b.fromhn,''99999999''),to_number(b.tohn,''99999999'')) /'
- || ' greatest(' || coalesce(quote_literal(parsed.address || '.0'),'NULL') || '::numeric,to_number(b.fromhn,''99999999''),to_number(b.tohn,''99999999'')))'
+ || '(least_hn(' || coalesce(quote_literal(parsed.address || '.0'),'NULL') || ',least_hn(b.fromhn,b.tohn)::text) /'
+ || ' greatest_hn(' || coalesce(quote_literal(parsed.address || '.0'),'NULL') || ',greatest_hn(b.fromhn,b.tohn)::text))'
|| ') * 5)::integer + 5'
|| ' END'
|| ' as sub_rating,'
result := result + rate_attributes($1, $2, $3, $4, $5, $6, $7, $8);
RETURN result;
END;
-$_$ LANGUAGE plpgsql;
+$_$ LANGUAGE plpgsql IMMUTABLE;
-- rate_attributes(dirpA, dirpB, streetNameA, streetNameB, streetTypeA,
-- streetTypeB, dirsA, dirsB)
directionWeight;
return result;
END;
-$_$ LANGUAGE plpgsql STABLE COST 10;
+$_$ LANGUAGE plpgsql IMMUTABLE;