--- /dev/null
+# perl create_undef.pl <postgis.sql>
+# creates a new sql script to delete all the postgis functions et al.
+
+($#ARGV == 0) || die "usage: perl create_undef.pl <postgis.sql>\ncreates a new sql script to delete all the postgis functions et al.";
+
+
+# drops are in the following order:
+# 1. Indexing system stuff
+# 2. Meta datatables <not done>
+# 3. Aggregates - must be of type geometry
+# 4. Operators - must be of type op(geometry,geometry)
+# 5. Functions
+# 6. Types
+
+@aggs =();
+@funcs = ();
+@types = ();
+@ops = ();
+
+
+open( INPUT,$ARGV[0]) || die "couldnt open file: $ARGV[0]";
+
+
+ print "begin;\n";
+ print "--- indexing meta table stuff\n";
+ print "delete from pg_amproc where amopclaid = (select oid from pg_opclass where opcname = 'gist_geometry_ops');\n";
+ print "delete from pg_amop where amopclaid = (select oid from pg_opclass where opcname = 'gist_geometry_ops');\n";
+ print "delete from pg_opclass where opcname = 'gist_geometry_ops';\n";
+
+
+ while( $line = <INPUT>)
+ {
+
+ if ($line =~ /^create function/i)
+ {
+ push (@funcs, $line);
+ }
+ if ($line =~ /^create operator/i)
+ {
+ push (@ops, $line);
+ }
+ if ($line =~ /^create AGGREGATE/i)
+ {
+ push (@aggs, $line);
+ }
+ if ($line =~ /^create type/i)
+ {
+ push (@types, $line);
+ }
+ }
+
+ #now have all the info, do the deletions
+
+ print "--- AGGREGATEs\n";
+
+ foreach $agg (@aggs)
+ {
+ if ($agg =~ /create AGGREGATE ([^(]+)/i )
+ {
+ print "drop AGGREGATE $1 geometry;\n";
+ }
+ else
+ {
+ die "couldnt parse line: $line\n";
+ }
+ }
+
+ print "--- operators\n";
+
+ foreach $op (@ops)
+ {
+ if ($op =~ /create operator ([^(]+)/i )
+ {
+ print "drop operator $1 (geometry,geometry);\n";
+ }
+ else
+ {
+ die "couldnt parse line: $line\n";
+ }
+ }
+
+
+ print "--- functions\n";
+
+ foreach $fn (@funcs)
+ {
+ chomp($fn); chomp($fn);
+
+
+ if ($fn =~ /create function ([^(]+)\(([^()]*)\)/i )
+ {
+ print "drop function $1 ($2);\n";
+ }
+ else
+ {
+ die "couldnt parse line: $line\n";
+ }
+ }
+
+ print "--- types\n";
+
+ foreach $type (@types)
+ {
+ if ($type =~ /create type ([^(]+)/i )
+ {
+ print "drop type $1;\n";
+ }
+ else
+ {
+ die "couldnt parse line: $line\n";
+ }
+ }
+
+
+
+ print "end;\n";
+
+
+close( INPUT );
+
+1;
+
--- /dev/null
+begin;
+--- indexing meta table stuff
+delete from pg_amproc where amopclaid = (select oid from pg_opclass where opcname = 'gist_geometry_ops');
+delete from pg_amop where amopclaid = (select oid from pg_opclass where opcname = 'gist_geometry_ops');
+delete from pg_opclass where opcname = 'gist_geometry_ops';
+--- AGGREGATEs
+drop AGGREGATE extent geometry;
+--- operators
+drop operator << (geometry,geometry);
+drop operator &< (geometry,geometry);
+drop operator && (geometry,geometry);
+drop operator &> (geometry,geometry);
+drop operator >> (geometry,geometry);
+drop operator ~= (geometry,geometry);
+drop operator @ (geometry,geometry);
+drop operator ~ (geometry,geometry);
+drop operator = (geometry,geometry);
+drop operator < (geometry,geometry);
+drop operator > (geometry,geometry);
+--- functions
+drop function POSTGIS_VERSION ();
+drop function DropGeometryColumn (varchar,varchar,varchar);
+drop function AddGeometryColumn (varchar,varchar,varchar,integer,varchar,integer);
+drop function BOX3D_in (opaque);
+drop function BOX3D_out (opaque);
+drop function SPHEROID_in (opaque);
+drop function SPHEROID_out (opaque);
+drop function geometry_in (opaque);
+drop function geometry_out (opaque);
+drop function box3d (GEOMETRY);
+drop function geometry (BOX3D);
+drop function expand (BOX3D,float8);
+drop function asbinary (GEOMETRY);
+drop function asbinary (GEOMETRY,TEXT);
+drop function npoints (GEOMETRY);
+drop function nrings (GEOMETRY);
+drop function mem_size (GEOMETRY);
+drop function numb_sub_objs (GEOMETRY);
+drop function summary (GEOMETRY);
+drop function translate (GEOMETRY,float8,float8,float8);
+drop function dimension (GEOMETRY);
+drop function geometrytype (GEOMETRY);
+drop function envelope (GEOMETRY);
+drop function x (GEOMETRY);
+drop function y (GEOMETRY);
+drop function z (GEOMETRY);
+drop function numpoints (GEOMETRY);
+drop function pointn (GEOMETRY,INTEGER);
+drop function exteriorring (GEOMETRY);
+drop function numinteriorrings (GEOMETRY);
+drop function interiorringn (GEOMETRY,INTEGER);
+drop function numgeometries (GEOMETRY);
+drop function geometryn (GEOMETRY,INTEGER);
+drop function distance (GEOMETRY,GEOMETRY);
+drop function astext (geometry);
+drop function srid (geometry);
+drop function geometryfromtext (geometry,int4);
+drop function setSRID (geometry,int4);
+drop function length_spheroid (GEOMETRY,SPHEROID);
+drop function length3d_spheroid (GEOMETRY,SPHEROID);
+drop function length3d (GEOMETRY);
+drop function length (GEOMETRY);
+drop function area2d (GEOMETRY);
+drop function perimeter3d (GEOMETRY);
+drop function perimeter (GEOMETRY);
+drop function truly_inside (GEOMETRY,GEOMETRY);
+drop function point_inside_circle (GEOMETRY,float8,float8,float8);
+drop function startpoint (GEOMETRY);
+drop function endpoint (GEOMETRY);
+drop function isclosed (GEOMETRY);
+drop function centroid (GEOMETRY);
+drop function combine_bbox (BOX3D,GEOMETRY);
+drop function geometry_overleft (GEOMETRY, GEOMETRY);
+drop function geometry_overright (GEOMETRY, GEOMETRY);
+drop function geometry_left (GEOMETRY, GEOMETRY);
+drop function geometry_right (GEOMETRY, GEOMETRY);
+drop function geometry_contain (GEOMETRY, GEOMETRY);
+drop function geometry_contained (GEOMETRY, GEOMETRY);
+drop function geometry_overlap (GEOMETRY, GEOMETRY);
+drop function geometry_same (GEOMETRY, GEOMETRY);
+drop function geometry_lt (GEOMETRY, GEOMETRY);
+drop function geometry_gt (GEOMETRY, GEOMETRY);
+drop function geometry_eq (GEOMETRY, GEOMETRY);
+drop function force_2d (GEOMETRY);
+drop function force_3d (GEOMETRY);
+drop function force_collection (GEOMETRY);
+drop function ggeometry_consistent (opaque,GEOMETRY,int4);
+drop function ggeometry_compress (opaque);
+drop function ggeometry_penalty (opaque,opaque,opaque);
+drop function ggeometry_picksplit (opaque, opaque);
+drop function ggeometry_union (bytea, opaque);
+drop function ggeometry_same (opaque, opaque, opaque);
+drop function rtree_decompress (opaque);
+drop function geometry_union (GEOMETRY,GEOMETRY);
+drop function geometry_inter (GEOMETRY,GEOMETRY);
+drop function geometry_size (GEOMETRY,opaque);
+--- types
+drop type SPHEROID ;
+drop type BOX3D ;
+drop type WKB ;
+drop type GEOMETRY ;
+end;
+++ /dev/null
-begin;
-
-delete from pg_amproc where amopclaid = (select oid from pg_opclass where opcname = 'rt_geometry_ops');
-
-delete from pg_amop where amopclaid = (select oid from pg_opclass where opcname = 'rt_geometry_ops');
-
-delete from pg_opclass where opcname = 'rt_geometry_ops';
-
-
-delete from pg_amproc where amopclaid = (select oid from pg_opclass where opcname = 'gist_geometry_ops');
-
-delete from pg_amop where amopclaid = (select oid from pg_opclass where opcname = 'gist_geometry_ops');
-
-delete from pg_opclass where opcname = 'gist_geometry_ops';
-
-
-drop OPERATOR > (geometry,geometry);
-drop OPERATOR < (geometry,geometry);
-drop OPERATOR = (geometry,geometry);
-drop OPERATOR ~ (geometry,geometry);
-drop OPERATOR @ (geometry,geometry);
-drop OPERATOR ~= (geometry,geometry);
-drop OPERATOR && (geometry,geometry);
-drop OPERATOR &> (geometry,geometry);
-drop OPERATOR >> (geometry,geometry);
-drop OPERATOR &< (geometry,geometry);
-
-drop OPERATOR << (geometry,geometry);
-drop function geometry_size(GEOMETRY,opaque) ;
-drop function geometry_inter(GEOMETRY,GEOMETRY) ;
-drop function geometry_union(GEOMETRY,GEOMETRY) ;
-
-
-drop function rtree_decompress(opaque) ;
-drop function ggeometry_union(bytea, opaque) ;
-drop function ggeometry_same(opaque, opaque, opaque);
-drop function ggeometry_picksplit(opaque, opaque) ;
-drop function ggeometry_penalty(opaque,opaque,opaque) ;
-drop function ggeometry_compress(opaque) ;
-drop function ggeometry_consistent(opaque,GEOMETRY,int4) ;
-
-
-drop FUNCTION force_3d(GEOMETRY) ;
-drop FUNCTION force_2d(GEOMETRY) ;
-drop FUNCTION geometry_eq(GEOMETRY, GEOMETRY) ;
-drop FUNCTION geometry_gt(GEOMETRY, GEOMETRY) ;
-drop FUNCTION geometry_lt(GEOMETRY, GEOMETRY) ;
-
-drop FUNCTION geometry_same(GEOMETRY, GEOMETRY);
-drop FUNCTION geometry_overlap(GEOMETRY, GEOMETRY) ;
-drop FUNCTION geometry_contained(GEOMETRY, GEOMETRY) ;
-drop function geometry_contain(GEOMETRY, GEOMETRY) ;
-drop FUNCTION geometry_right(GEOMETRY, GEOMETRY) ;
-drop FUNCTION geometry_left(GEOMETRY, GEOMETRY) ;
-drop FUNCTION geometry_overright(GEOMETRY, GEOMETRY) ;
-drop FUNCTION geometry_overleft(GEOMETRY, GEOMETRY) ;
-
-
-
-drop AGGREGATE extent geometry;
-drop FUNCTION combine_bbox(BOX3D,GEOMETRY);
-drop FUNCTION truly_inside(GEOMETRY,GEOMETRY);
-drop FUNCTION perimeter2d(GEOMETRY);
-drop FUNCTION perimeter3d(GEOMETRY);
-
-
-
-drop FUNCTION area2d(GEOMETRY);
-drop FUNCTION length2d(GEOMETRY);
-drop FUNCTION length3d(GEOMETRY);
-drop FUNCTION translate(GEOMETRY,float8,float8,float8);
-drop FUNCTION summary(GEOMETRY);
-drop FUNCTION numb_sub_objs(GEOMETRY);
-
-
-drop FUNCTION mem_size(GEOMETRY);
-drop FUNCTION nrings(GEOMETRY);
-drop FUNCTION npoints(GEOMETRY);
-drop FUNCTION wkb_XDR(GEOMETRY);
-drop FUNCTION wkb_NDR(GEOMETRY);
-drop FUNCTION geometry(BOX3D);
-drop FUNCTION box3d(GEOMETRY);
-
-
-drop function geometry_in(opaque);
-drop function geometry_out(opaque);
-drop FUNCTION BOX3D_in(opaque);
-drop FUNCTION BOX3D_out(opaque);
-
-drop TYPE BOX3D ;
-drop TYPE WKB ;
-drop TYPE GEOMETRY ;
-
-
-end;
\ No newline at end of file