mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-26 01:52:37 +00:00
Spatial table constraints names get column name appended.
rename_geometry_table_constraints() obsoleted. git-svn-id: http://svn.osgeo.org/postgis/trunk@683 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
parent
c6924639f4
commit
a0f200aae7
|
@ -417,34 +417,17 @@ LANGUAGE 'sql' WITH (iscachable,isstrict);
|
|||
-----------------------------------------------------------------------
|
||||
-- RENAME_GEOMETRY_TABLE_CONSTRAINTS()
|
||||
-----------------------------------------------------------------------
|
||||
-- Rename SRID checks to enforce_srid
|
||||
-- Rename TYPE checks to enforce_geotype
|
||||
-- This function has been obsoleted for the difficulty in
|
||||
-- finding attribute on which the constraint is applied.
|
||||
-- AddGeometryColumn will name the constraints in a meaningful
|
||||
-- way, but nobody can rely on it since old postgis versions did
|
||||
-- not do that.
|
||||
-----------------------------------------------------------------------
|
||||
CREATEFUNCTION rename_geometry_table_constraints() RETURNS text
|
||||
AS
|
||||
'
|
||||
DECLARE
|
||||
fixed_srid integer;
|
||||
fixed_type integer;
|
||||
BEGIN
|
||||
UPDATE pg_constraint SET conname = ''enforce_geotype''
|
||||
WHERE consrc like
|
||||
''((geometrytype(%) = ''''%''''::text) OR (% IS NULL))''
|
||||
AND conname != ''enforce_geotype'';
|
||||
|
||||
GET DIAGNOSTICS fixed_type = ROW_COUNT;
|
||||
|
||||
UPDATE pg_constraint SET conname = ''enforce_srid''
|
||||
WHERE consrc like
|
||||
''(srid(% = %)''
|
||||
AND conname != ''enforce_srid'';
|
||||
|
||||
GET DIAGNOSTICS fixed_srid = ROW_COUNT;
|
||||
|
||||
RETURN ''fixed srid_checks:''||fixed_srid||
|
||||
'' type_checks:''||fixed_type;
|
||||
END;
|
||||
' LANGUAGE 'plpgsql';
|
||||
SELECT ''rename_geometry_table_constraint() is obsoleted''::text
|
||||
' LANGUAGE 'SQL';
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- FIX_GEOMETRY_COLUMNS()
|
||||
|
@ -2329,7 +2312,8 @@ BEGIN
|
|||
#else
|
||||
quote_ident(table_name)
|
||||
#endif
|
||||
|| '' ADD CONSTRAINT enforce_srid CHECK (SRID('' || quote_ident(column_name) ||
|
||||
|| '' ADD CONSTRAINT "enforce_srid_'' ||
|
||||
column_name || ''" CHECK (SRID('' || quote_ident(column_name) ||
|
||||
'') = '' || new_srid || '')'' ;
|
||||
|
||||
IF (not(new_type = ''GEOMETRY'')) THEN
|
||||
|
@ -2339,7 +2323,8 @@ BEGIN
|
|||
#else
|
||||
quote_ident(table_name)
|
||||
#endif
|
||||
|| '' ADD CONSTRAINT enforce_geotype CHECK (geometrytype('' ||
|
||||
|| '' ADD CONSTRAINT "enforce_geotype_'' ||
|
||||
column_name || ''" CHECK (geometrytype('' ||
|
||||
quote_ident(column_name) || '')='' ||
|
||||
quote_literal(new_type) || '' OR ('' ||
|
||||
quote_ident(column_name) || '') is null)'';
|
||||
|
|
Loading…
Reference in a new issue