]> granicus.if.org Git - postgis/commitdiff
Changed fix_geometry_columns() for PG >= 73 so to set f_table_schema to
authorSandro Santilli <strk@keybit.net>
Thu, 18 Dec 2003 18:07:06 +0000 (18:07 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 18 Dec 2003 18:07:06 +0000 (18:07 +0000)
the empty string if its value is not a valid pg namespace.

git-svn-id: http://svn.osgeo.org/postgis/trunk@412 b70326c6-7e19-0410-871a-916f4a2858ee

Attic/postgis_sql_71_end.sql.in
Attic/postgis_sql_72_end.sql.in
Attic/postgis_sql_73_end.sql.in
Attic/postgis_sql_74_end.sql.in
Attic/postgis_sql_common.sql.in

index 19342cb697a7d1110d103be4063e39b848f6c1d3..dc001ba79e626cfd962b8c9f7779e360f476f95c 100644 (file)
 --  
 -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -- $Log$
+-- Revision 1.3  2003/12/18 18:07:06  strk
+-- Changed fix_geometry_columns() for PG >= 73 so to set f_table_schema to
+-- the empty string if its value is not a valid pg namespace.
+--
 -- Revision 1.2  2003/07/01 18:30:55  pramsey
 -- Added CVS revision headers.
 --
@@ -192,4 +196,18 @@ INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
        WHERE amname = 'gist' AND opcname = 'gist_geometry_ops'
                AND proname = 'ggeometry_same';
 
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - -
+-- FIX_GEOMETRY_COLUMNS()
+
+CREATE FUNCTION fix_geometry_columns() RETURNS text
+AS 
+'
+BEGIN
+       EXECUTE ''update geometry_columns set attrelid = (select pg_class.oid AS attrelid from pg_class,pg_attribute where relname =geometry_columns.f_table_name::name and pg_attribute.attrelid = pg_class.oid and pg_attribute.attname = geometry_columns.f_geometry_column::name), varattnum = (select pg_attribute.attnum from pg_class,pg_attribute where relname =geometry_columns.f_table_name::name and pg_attribute.attrelid = pg_class.oid and pg_attribute.attname = geometry_columns.f_geometry_column::name)'';
+       RETURN ''geometry_columns table is now linked to the system tables'';
+END;
+'
+LANGUAGE 'plpgsql' ;
+
+
 END TRANSACTION;
index feac62f7d844f84eab600511b882b4af352a4b70..60619434c782acc9abf80edc6bd72b0b0261dcdd 100644 (file)
 --  
 -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -- $Log$
+-- Revision 1.4  2003/12/18 18:07:06  strk
+-- Changed fix_geometry_columns() for PG >= 73 so to set f_table_schema to
+-- the empty string if its value is not a valid pg namespace.
+--
 -- Revision 1.3  2003/07/01 18:30:55  pramsey
 -- Added CVS revision headers.
 --
@@ -306,4 +310,18 @@ INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
       and opcname = 'gist_geometry_ops'
       and proname = 'gbox_same';
 
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - -
+-- FIX_GEOMETRY_COLUMNS()
+
+CREATE FUNCTION fix_geometry_columns() RETURNS text
+AS 
+'
+BEGIN
+       EXECUTE ''update geometry_columns set attrelid = (select pg_class.oid AS attrelid from pg_class,pg_attribute where relname =geometry_columns.f_table_name::name and pg_attribute.attrelid = pg_class.oid and pg_attribute.attname = geometry_columns.f_geometry_column::name), varattnum = (select pg_attribute.attnum from pg_class,pg_attribute where relname =geometry_columns.f_table_name::name and pg_attribute.attrelid = pg_class.oid and pg_attribute.attname = geometry_columns.f_geometry_column::name)'';
+       RETURN ''geometry_columns table is now linked to the system tables'';
+END;
+'
+LANGUAGE 'plpgsql' ;
+
+
 END TRANSACTION;
index 5c49751ac08702ddb04d47341cc2d0671467f85b..1785181aa8f9bb506866bc8229a6cf2858edd31e 100644 (file)
 --  
 -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -- $Log$
+-- Revision 1.6  2003/12/18 18:07:06  strk
+-- Changed fix_geometry_columns() for PG >= 73 so to set f_table_schema to
+-- the empty string if its value is not a valid pg namespace.
+--
 -- Revision 1.5  2003/11/28 11:25:31  strk
 -- Added explicit geometry as text cast
 --
@@ -195,4 +199,25 @@ UPDATE pg_opclass
        SET opckeytype = (select oid from pg_type where typname = 'box') 
        WHERE opcname = 'gist_geometry_ops';
 
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - -
+-- FIX_GEOMETRY_COLUMNS()
+--
+-- Since 7.3 schema support has been added.
+-- Previous postgis versions used to put the database name in
+-- the schema column. This needs to be fixed, so we set to the
+-- empty string any schema value not existing in pg_namespace
+--
+
+CREATE FUNCTION fix_geometry_columns() RETURNS text
+AS 
+'
+BEGIN
+       EXECUTE ''update geometry_columns set attrelid = (select pg_class.oid AS attrelid from pg_class,pg_attribute where relname =geometry_columns.f_table_name::name and pg_attribute.attrelid = pg_class.oid and pg_attribute.attname = geometry_columns.f_geometry_column::name), varattnum = (select pg_attribute.attnum from pg_class,pg_attribute where relname =geometry_columns.f_table_name::name and pg_attribute.attrelid = pg_class.oid and pg_attribute.attname = geometry_columns.f_geometry_column::name)'';
+       EXECUTE ''update geometry_columns set f_table_schema = '''''''' where f_table_schema not in ( select nspname::varchar from pg_namespace )'';
+       RETURN ''geometry_columns table is now linked to the system tables'';
+END;
+'
+LANGUAGE 'plpgsql' ;
+
+
 END TRANSACTION;
index d6d0f59595f0696170c55dddc5eb55e3e1a1ea09..ecd235e0fdc6700207cdd1dd9deff59017d99485 100644 (file)
 --  
 -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -- $Log$
+-- Revision 1.5  2003/12/18 18:07:06  strk
+-- Changed fix_geometry_columns() for PG >= 73 so to set f_table_schema to
+-- the empty string if its value is not a valid pg namespace.
+--
 -- Revision 1.4  2003/11/28 11:25:31  strk
 -- Added explicit geometry as text cast
 --
@@ -228,4 +232,24 @@ CREATE OPERATOR CLASS btree_geometry_ops
        FUNCTION        1       geometry_cmp (geometry, geometry);
 
 
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - -
+-- FIX_GEOMETRY_COLUMNS()
+--
+-- Since 7.3 schema support has been added.
+-- Previous postgis versions used to put the database name in
+-- the schema column. This needs to be fixed, so we set to the
+-- empty string any schema value not existing in pg_namespace
+--
+
+CREATE FUNCTION fix_geometry_columns() RETURNS text
+AS 
+'
+BEGIN
+       EXECUTE ''update geometry_columns set attrelid = (select pg_class.oid AS attrelid from pg_class,pg_attribute where relname =geometry_columns.f_table_name::name and pg_attribute.attrelid = pg_class.oid and pg_attribute.attname = geometry_columns.f_geometry_column::name), varattnum = (select pg_attribute.attnum from pg_class,pg_attribute where relname =geometry_columns.f_table_name::name and pg_attribute.attrelid = pg_class.oid and pg_attribute.attname = geometry_columns.f_geometry_column::name)'';
+       EXECUTE ''update geometry_columns set f_table_schema = '''''''' where f_table_schema not in ( select nspname::varchar from pg_namespace )'';
+       RETURN ''geometry_columns table is now linked to the system tables'';
+END;
+'
+LANGUAGE 'plpgsql' ;
+
 END TRANSACTION;
index 76b225c6f9b4fb456075e6fa3ba5c30bf2f80f84..90319d3735f40a93c5d9526953145e744023df72 100644 (file)
 --  
 -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -- $Log$
+-- Revision 1.25  2003/12/18 18:07:06  strk
+-- Changed fix_geometry_columns() for PG >= 73 so to set f_table_schema to
+-- the empty string if its value is not a valid pg namespace.
+--
 -- Revision 1.24  2003/12/12 10:08:24  strk
 -- Added GEOSnoop function and some optional debugging output for
 -- geos<->postgis converter (define DEBUG_CONVERTER at top postgis_geos.c)
@@ -119,20 +123,7 @@ AS 'SELECT \'@POSTGIS_VERSION@\'::text AS version'
 LANGUAGE 'sql';
 
 -- - - - - - - - - - - - - - - - - - - - - - - - - - - -
--- FIX_GEOMETRY_COLUMNS()
-
-CREATE FUNCTION fix_geometry_columns() RETURNS text
-AS 
-'
-BEGIN
-       EXECUTE ''update geometry_columns set attrelid = (select pg_class.oid AS attrelid from pg_class,pg_attribute where relname =geometry_columns.f_table_name::name and pg_attribute.attrelid = pg_class.oid and pg_attribute.attname = geometry_columns.f_geometry_column::name), varattnum = (select pg_attribute.attnum from pg_class,pg_attribute where relname =geometry_columns.f_table_name::name and pg_attribute.attrelid = pg_class.oid and pg_attribute.attname = geometry_columns.f_geometry_column::name)'';
-       RETURN ''geometry_columns table is now linked to the system tables'';
-END;
-'
-LANGUAGE 'plpgsql' ;
-
--- - - - - - - - - - - - - - - - - - - - - - - - - - - -
--- FIND_SRID( <schema/database>, <table>, <geom col> )
+-- FIND_SRID( <schema>, <table>, <geom col> )
 
 CREATE FUNCTION find_srid(varchar,varchar,varchar) RETURNS int4 AS
 'DECLARE
@@ -263,7 +254,7 @@ END;
 -- SRID checks the coord_dimension to make sure its between 0 and 3
 -- should also check the precision grid (future expansion)
 -- also checks to see if the database_name is in the pg_database table.
-
+--
 CREATE FUNCTION AddGeometryColumn(varchar,varchar,varchar,integer,varchar,integer)
        RETURNS text
        AS