From: Regina Obe Date: Wed, 6 Jul 2011 00:40:46 +0000 (+0000) Subject: Get rid of use of array_accum and replace with array_agg (which exists in PostgreSQL... X-Git-Tag: 2.0.0alpha1~1248 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d569b122c0e633772d52dd034cd9356c5a624677;p=postgis Get rid of use of array_accum and replace with array_agg (which exists in PostgreSQL 9\8.4+). Now that we only support 8.4+, we can just use array_agg. git-svn-id: http://svn.osgeo.org/postgis/trunk@7594 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/extras/tiger_geocoder/tiger_2010/geocode/geocode_address.sql b/extras/tiger_geocoder/tiger_2010/geocode/geocode_address.sql index f8aa625d4..f316d4ab8 100644 --- a/extras/tiger_geocoder/tiger_2010/geocode/geocode_address.sql +++ b/extras/tiger_geocoder/tiger_2010/geocode/geocode_address.sql @@ -35,17 +35,17 @@ BEGIN (SELECT zip_state.statefp as statefp,$1 as location, true As exact, ARRAY[zip_state.zip] as zip,1 as pref FROM zip_state WHERE zip_state.zip = $2 AND (' || quote_nullable(in_statefp) || ' IS NULL OR zip_state.statefp = ' || quote_nullable(in_statefp) || ') - UNION SELECT zip_state_loc.statefp,zip_state_loc.place As location,false As exact, array_accum(zip_state_loc.zip) AS zip,1 + abs(COALESCE(diff_zip(max(zip), $2),0) - COALESCE(diff_zip(min(zip), $2),0)) As pref + UNION SELECT zip_state_loc.statefp,zip_state_loc.place As location,false As exact, array_agg(zip_state_loc.zip) AS zip,1 + abs(COALESCE(diff_zip(max(zip), $2),0) - COALESCE(diff_zip(min(zip), $2),0)) As pref FROM zip_state_loc WHERE zip_state_loc.statefp = ' || quote_nullable(in_statefp) || ' AND lower($1) = lower(zip_state_loc.place) GROUP BY zip_state_loc.statefp,zip_state_loc.place - UNION SELECT zip_state_loc.statefp,zip_state_loc.place As location,false As exact, array_accum(zip_state_loc.zip),3 + UNION SELECT zip_state_loc.statefp,zip_state_loc.place As location,false As exact, array_agg(zip_state_loc.zip),3 FROM zip_state_loc WHERE zip_state_loc.statefp = ' || quote_nullable(in_statefp) || ' AND soundex($1) = soundex(zip_state_loc.place) GROUP BY zip_state_loc.statefp,zip_state_loc.place - UNION SELECT zip_lookup_base.statefp,zip_lookup_base.city As location,false As exact, array_accum(zip_lookup_base.zip),4 + UNION SELECT zip_lookup_base.statefp,zip_lookup_base.city As location,false As exact, array_agg(zip_lookup_base.zip),4 FROM zip_lookup_base WHERE zip_lookup_base.statefp = ' || quote_nullable(in_statefp) || ' AND (soundex($1) = soundex(zip_lookup_base.city) OR soundex($1) = soundex(zip_lookup_base.county)) @@ -57,17 +57,17 @@ BEGIN (SELECT zip_state.statefp as statefp,parsed.location as location, true As exact, ARRAY[zip_state.zip] as zip,1 as pref FROM zip_state WHERE zip_state.zip = parsed.zip AND (in_statefp IS NULL OR zip_state.statefp = in_statefp) - UNION SELECT zip_state_loc.statefp,parsed.location,false As exact, array_accum(zip_state_loc.zip),2 + diff_zip(zip[1], parsed.zip) + UNION SELECT zip_state_loc.statefp,parsed.location,false As exact, array_agg(zip_state_loc.zip),2 + diff_zip(zip[1], parsed.zip) FROM zip_state_loc WHERE zip_state_loc.statefp = in_statefp AND lower(parsed.location) = lower(zip_state_loc.place) GROUP BY zip_state_loc.statefp,parsed.location - UNION SELECT zip_state_loc.statefp,parsed.location,false As exact, array_accum(zip_state_loc.zip),3 + UNION SELECT zip_state_loc.statefp,parsed.location,false As exact, array_agg(zip_state_loc.zip),3 FROM zip_state_loc WHERE zip_state_loc.statefp = in_statefp AND soundex(parsed.location) = soundex(zip_state_loc.place) GROUP BY zip_state_loc.statefp,parsed.location - UNION SELECT zip_lookup_base.statefp,parsed.location,false As exact, array_accum(zip_lookup_base.zip),4 + UNION SELECT zip_lookup_base.statefp,parsed.location,false As exact, array_agg(zip_lookup_base.zip),4 FROM zip_lookup_base WHERE zip_lookup_base.statefp = in_statefp AND (soundex(parsed.location) = soundex(zip_lookup_base.city) OR soundex(parsed.location) = soundex(zip_lookup_base.county)) diff --git a/extras/tiger_geocoder/tiger_2010/tiger_loader.sql b/extras/tiger_geocoder/tiger_2010/tiger_loader.sql index 277ceccf4..fb336b974 100644 --- a/extras/tiger_geocoder/tiger_2010/tiger_loader.sql +++ b/extras/tiger_geocoder/tiger_2010/tiger_loader.sql @@ -14,12 +14,6 @@ -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SET search_path TO tiger,public; BEGIN; -DROP AGGREGATE IF EXISTS array_accum(anyelement); -CREATE AGGREGATE array_accum(anyelement) ( - SFUNC=array_append, - STYPE=anyarray, - INITCOND='{}' -); CREATE OR REPLACE FUNCTION loader_macro_replace(param_input text, param_keys text[],param_values text[]) RETURNS text AS $$