From: Sandro Santilli Date: Thu, 18 Dec 2003 18:07:06 +0000 (+0000) Subject: Changed fix_geometry_columns() for PG >= 73 so to set f_table_schema to X-Git-Tag: pgis_0_8_1~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=20109b41e929c05c3129b11452f8b7e2f85f1757;p=postgis 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. git-svn-id: http://svn.osgeo.org/postgis/trunk@412 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/Attic/postgis_sql_71_end.sql.in b/Attic/postgis_sql_71_end.sql.in index 19342cb69..dc001ba79 100644 --- a/Attic/postgis_sql_71_end.sql.in +++ b/Attic/postgis_sql_71_end.sql.in @@ -12,6 +12,10 @@ -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- $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; diff --git a/Attic/postgis_sql_72_end.sql.in b/Attic/postgis_sql_72_end.sql.in index feac62f7d..60619434c 100644 --- a/Attic/postgis_sql_72_end.sql.in +++ b/Attic/postgis_sql_72_end.sql.in @@ -12,6 +12,10 @@ -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- $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; diff --git a/Attic/postgis_sql_73_end.sql.in b/Attic/postgis_sql_73_end.sql.in index 5c49751ac..1785181aa 100644 --- a/Attic/postgis_sql_73_end.sql.in +++ b/Attic/postgis_sql_73_end.sql.in @@ -12,6 +12,10 @@ -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- $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; diff --git a/Attic/postgis_sql_74_end.sql.in b/Attic/postgis_sql_74_end.sql.in index d6d0f5959..ecd235e0f 100644 --- a/Attic/postgis_sql_74_end.sql.in +++ b/Attic/postgis_sql_74_end.sql.in @@ -12,6 +12,10 @@ -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- $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; diff --git a/Attic/postgis_sql_common.sql.in b/Attic/postgis_sql_common.sql.in index 76b225c6f..90319d373 100644 --- a/Attic/postgis_sql_common.sql.in +++ b/Attic/postgis_sql_common.sql.in @@ -12,6 +12,10 @@ -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- $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( , , ) +-- FIND_SRID( ,
, ) 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