From: Bborie Park Date: Sat, 4 Aug 2012 14:28:15 +0000 (+0000) Subject: Replaced last commit with something much simpler and possibly more X-Git-Tag: 2.1.0beta2~710 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0215a5a3779ca235b784c2468eec52ca234574d6;p=postgis Replaced last commit with something much simpler and possibly more effective git-svn-id: http://svn.osgeo.org/postgis/trunk@10162 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in.c b/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in.c index 4b3a84fea..89353ae5b 100644 --- a/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in.c +++ b/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in.c @@ -104,82 +104,24 @@ DROP CAST IF EXISTS (raster AS geometry); CREATE CAST (raster AS geometry) WITH FUNCTION st_convexhull(raster) AS ASSIGNMENT; --- new TYPEs -DROP FUNCTION IF EXISTS _checktype_drop_create(name, name[], name[]); -CREATE OR REPLACE FUNCTION _checktype_drop_create( - reftype name, - refatt name[], - refatttype name[] -) - RETURNS void AS $$ - DECLARE - att name[]; - atttype name[]; - - dodrop boolean DEFAULT FALSE; - docreate boolean DEFAULT FALSE; - - cnt int; - i int; - found boolean; - typeargtext text DEFAULT ''; - BEGIN - cnt := array_length(refatt, 1); - EXECUTE 'SELECT array_agg(a.attname), array_agg(att.typname) ' || - 'FROM pg_type t ' || - 'JOIN pg_class c ' || - 'ON t.typrelid = c.oid ' || - 'JOIN pg_attribute a ' || - 'ON a.attrelid = c.oid ' || - 'JOIN pg_type att ' || - 'ON a.atttypid = att.oid ' || - 'WHERE t.typname = ' || quote_literal(reftype) - INTO att, atttype; - - -- check specifics of TYPE - IF att IS NOT NULL THEN - FOR i in 1..cnt LOOP - SELECT refatt[i] = ANY(att) INTO found; - - IF NOT found THEN - docreate := TRUE; - EXIT; - END IF; - - IF refatttype[i] != atttype[i] THEN - dodrop := TRUE; - docreate := TRUE; - END IF; - END LOOP; - ELSE - docreate := TRUE; - END IF; - - IF dodrop THEN - EXECUTE 'DROP TYPE IF EXISTS ' || reftype || ' CASCADE'; - END IF; - - IF docreate THEN - FOR i in 1..cnt LOOP - typeargtext := typeargtext || quote_ident(refatt[i]) || ' ' || refatttype[i]; - IF i < cnt THEN - typeargtext := typeargtext || ','; - END IF; - END LOOP; - EXECUTE 'CREATE TYPE ' || quote_ident(reftype) || ' AS (' || typeargtext || ')'; - END IF; - END; - $$ LANGUAGE 'plpgsql' VOLATILE; - -SELECT _checktype_drop_create( - 'addbandarg', - ARRAY['index', 'pixeltype', 'initialvalue', 'nodataval']::name[], - ARRAY['int4', 'text', 'float8', 'float8']::name[] -); -SELECT _checktype_drop_create( - 'agg_samealignment', - ARRAY['refraster', 'aligned']::name[], - ARRAY['raster', 'bool']::name[] +-- new TYPE +ALTER TYPE addbandarg RENAME TO old_addbandarg; +DROP FUNCTION IF EXISTS st_addband(raster, old_addbandarg[]); +DROP TYPE IF EXISTS old_addbandarg; +CREATE TYPE addbandarg AS ( + index int, + pixeltype text, + initialvalue float8, + nodataval float8 ); -DROP FUNCTION _checktype_drop_create(name, name[], name[]); +-- new TYPE +ALTER TYPE agg_samealignment RENAME TO old_agg_samealignment; +DROP AGGREGATE IF EXISTS st_samealignment(raster); +DROP FUNCTION IF EXISTS _st_samealignment_transfn(old_agg_samealignment, raster); +DROP FUNCTION IF EXISTS _st_samealignment_finalfn(old_agg_samealignment); +DROP TYPE IF EXISTS old_agg_samealignment; +CREATE TYPE agg_samealignment AS ( + refraster raster, + aligned boolean +);