From: Sandro Santilli Date: Tue, 1 Jun 2004 16:30:10 +0000 (+0000) Subject: Made AddGeometryColumn delete from geometry_column records which would be incompatibl... X-Git-Tag: pgis_0_9_1~233 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88b5aa149bed4beee3050bbad46ff47ba87a9951;p=postgis Made AddGeometryColumn delete from geometry_column records which would be incompatible with the one being added git-svn-id: http://svn.osgeo.org/postgis/trunk@561 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis.sql.in b/postgis.sql.in index 9aec0f379..968d2e7fd 100644 --- a/postgis.sql.in +++ b/postgis.sql.in @@ -2735,6 +2735,8 @@ BEGIN #endif + -- Add geometry column + EXECUTE ''ALTER TABLE '' || #if USE_VERSION >= 73 quote_ident(real_schema) || ''.'' || quote_ident(table_name) @@ -2744,6 +2746,23 @@ BEGIN || '' ADD COLUMN '' || quote_ident(column_name) || '' geometry ''; + + -- Delete stale record in geometry_column (if any) + + EXECUTE ''DELETE FROM geometry_columns WHERE + f_table_catalog = '' || quote_literal('''') || + '' AND f_table_schema = '' || +#if USE_VERSION >= 73 + quote_literal(real_schema) || +#else + quote_literal('''') || +#endif + '' AND f_table_name = '' || quote_literal(table_name) || + '' AND f_geometry_column = '' || quote_literal(column_name); + + + -- Add record in geometry_column + EXECUTE ''INSERT INTO geometry_columns VALUES ('' || quote_literal('''') || '','' || #if USE_VERSION >= 73 @@ -2756,6 +2775,8 @@ BEGIN new_dim || '','' || new_srid || '','' || quote_literal(new_type) || '')''; + -- Add table checks + EXECUTE ''ALTER TABLE '' || #if USE_VERSION >= 73 quote_ident(real_schema) || ''.'' || quote_ident(table_name)