From daa3285b6c0f1a92998f87562c828e9f1d13eca5 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 4 Jun 2004 10:07:40 +0000 Subject: [PATCH] Added DropGeometryColumn function git-svn-id: http://svn.osgeo.org/postgis/trunk@587 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis.sql.in | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/postgis.sql.in b/postgis.sql.in index 9ed8d1781..ff040317e 100644 --- a/postgis.sql.in +++ b/postgis.sql.in @@ -2589,6 +2589,83 @@ BEGIN END; ' LANGUAGE 'plpgsql' WITH (isstrict); +----------------------------------------------------------------------- +-- DROPGEOMETRYTABLE +-- , , +----------------------------------------------------------------------- +-- +-- Drop a table and all its references in geometry_columns +-- +----------------------------------------------------------------------- +CREATEFUNCTION DropGeometryTable(varchar, varchar,varchar) + RETURNS text + AS +' +DECLARE + catalog_name alias for $1; + schema_name alias for $2; + table_name alias for $3; + real_schema name; + +BEGIN + +#if USE_VERSION >= 73 + IF ( schema_name = '''' ) THEN + SELECT current_schema() into real_schema; + ELSE + real_schema = schema_name; + END IF; +#endif // USE_VERSION >= 73 + + -- Remove refs from geometry_columns table + EXECUTE ''DELETE FROM geometry_columns WHERE '' || +#if USE_VERSION >= 73 + ''f_table_schema = '' || quote_literal(real_schema) || + '' AND '' || +#endif + '' f_table_name = '' || quote_literal(table_name); + + -- Remove table + EXECUTE ''DROP TABLE '' +#if USE_VERSION >= 73 + || quote_ident(real_schema) || ''.'' || +#endif + quote_ident(table_name); + + RETURN +#if USE_VERSION >= 73 + real_schema || ''.'' || +#endif + table_name ||'' dropped.''; + +END; +' +LANGUAGE 'plpgsql' WITH (isstrict); + +----------------------------------------------------------------------- +-- DROPGEOMETRYTABLE +-- ,
+----------------------------------------------------------------------- +-- +-- Drop a table and all its references in geometry_columns +-- +----------------------------------------------------------------------- +CREATEFUNCTION DropGeometryTable(varchar,varchar) RETURNS text AS +'SELECT DropGeometryTable('''',$1,$2)' +LANGUAGE 'sql' WITH (isstrict); + +----------------------------------------------------------------------- +-- DROPGEOMETRYTABLE +--
+----------------------------------------------------------------------- +-- +-- Drop a table and all its references in geometry_columns +-- For PG>=73 use current_schema() +-- +----------------------------------------------------------------------- +CREATEFUNCTION DropGeometryTable(varchar) RETURNS text AS +'SELECT DropGeometryTable('''','''',$1)' +LANGUAGE 'sql' WITH (isstrict); ----------------------------------------------------------------------- -- UPDATE_GEOMETRY_STATS() -- 2.50.1