From: Regina Obe Date: Sun, 18 Nov 2018 23:57:16 +0000 (+0000) Subject: Put back deprecated functions removed in r17029, but patch them to use newer pg_get_c... X-Git-Tag: 3.0.0alpha1~278 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5781430122d0266ba4b7480fc5be2d5c89bdabd9;p=postgis Put back deprecated functions removed in r17029, but patch them to use newer pg_get_constraintdef function. Also mark them as undeprecated cause they are used in other management functions, and it's too messy to change those to use teh raw sql. We maybe stuck with these forever :( Closes #4243 for PostGIS 3.0 Also fix error in raster patching References #4231 for PostGIS 3.0 git-svn-id: http://svn.osgeo.org/postgis/trunk@17030 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index 78020f8a5..18abb56ce 100644 --- a/NEWS +++ b/NEWS @@ -10,12 +10,6 @@ PostGIS 3.0.0 dimentions that aren't present in both operands. Please REINDEX your ND indexes after upgrade. - - #4231, remove deprecated functions postgis_constraint_srid, - postgis_constraint_dims, postgis_constraint_type - These were deprecated in PostGIS 2.2.0 - and used pg_constraint.consrc which was removed in PostgreSQL 12 - (Regina Obe) - * New Features * - #2902, postgis_geos_noop (Sandro Santilli) - #4128, ST_AsMVT support for Feature ID (Stepan Kuzmin) diff --git a/postgis/Makefile.in b/postgis/Makefile.in index f32fd9db0..31d080203 100644 --- a/postgis/Makefile.in +++ b/postgis/Makefile.in @@ -122,7 +122,8 @@ PG_OBJS= \ mvt.o \ lwgeom_out_mvt.o \ geobuf.o \ - lwgeom_out_geobuf.o + lwgeom_out_geobuf.o \ + postgis_legacy.o # Objects to build using PGXS OBJS=$(PG_OBJS) diff --git a/postgis/postgis.sql.in b/postgis/postgis.sql.in index 237073ae6..3a88787c9 100644 --- a/postgis/postgis.sql.in +++ b/postgis/postgis.sql.in @@ -5668,6 +5668,65 @@ $$ $$ LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL COST 200; +-- Availability: 2.0.0 +-- TODO: Can't deprecate this because UpdateGeometrySRID still uses them +CREATE OR REPLACE FUNCTION postgis_constraint_srid(geomschema text, geomtable text, geomcolumn text) RETURNS integer AS +$$ +SELECT replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', '')::integer + FROM pg_class c, pg_namespace n, pg_attribute a + , (SELECT connamespace, conrelid, conkey, pg_get_constraintdef(oid) As consrc + FROM pg_constraint) AS s + WHERE n.nspname = $1 + AND c.relname = $2 + AND a.attname = $3 + AND a.attrelid = c.oid + AND s.connamespace = n.oid + AND s.conrelid = c.oid + AND a.attnum = ANY (s.conkey) + AND s.consrc LIKE '%srid(% = %'; +$$ +LANGUAGE 'sql' STABLE STRICT _PARALLEL; + +-- Availability: 2.0.0 +-- TODO: Can't deprecate this because UpdateGeometrySRID still uses them +CREATE OR REPLACE FUNCTION postgis_constraint_dims(geomschema text, geomtable text, geomcolumn text) RETURNS integer AS +$$ +SELECT replace(split_part(s.consrc, ' = ', 2), ')', '')::integer + FROM pg_class c, pg_namespace n, pg_attribute a + , (SELECT connamespace, conrelid, conkey, pg_get_constraintdef(oid) As consrc + FROM pg_constraint) AS s + WHERE n.nspname = $1 + AND c.relname = $2 + AND a.attname = $3 + AND a.attrelid = c.oid + AND s.connamespace = n.oid + AND s.conrelid = c.oid + AND a.attnum = ANY (s.conkey) + AND s.consrc LIKE '%ndims(% = %'; +$$ +LANGUAGE 'sql' STABLE STRICT _PARALLEL; + +-- support function to pull out geometry type from constraint check +-- will return pretty name instead of ugly name +-- Availability: 2.0.0 +-- TODO: Can't deprecate this because UpdateGeometrySRID still uses them +CREATE OR REPLACE FUNCTION postgis_constraint_type(geomschema text, geomtable text, geomcolumn text) RETURNS varchar AS +$$ +SELECT replace(split_part(s.consrc, '''', 2), ')', '')::varchar + FROM pg_class c, pg_namespace n, pg_attribute a + , (SELECT connamespace, conrelid, conkey, pg_get_constraintdef(oid) As consrc + FROM pg_constraint) AS s + WHERE n.nspname = $1 + AND c.relname = $2 + AND a.attname = $3 + AND a.attrelid = c.oid + AND s.connamespace = n.oid + AND s.conrelid = c.oid + AND a.attnum = ANY (s.conkey) + AND s.consrc LIKE '%geometrytype(% = %'; +$$ +LANGUAGE 'sql' STABLE STRICT _PARALLEL; + -- Availability: 2.0.0 -- Changed: 2.1.8 significant performance improvement for constraint based columns -- Changed: 2.2.0 get rid of schema, table, column cast to improve performance @@ -5690,7 +5749,7 @@ CREATE OR REPLACE VIEW geometry_columns AS s.conrelid, s.conkey, replace(split_part(s.consrc, ''''::text, 2), ')'::text, ''::text) As type FROM (SELECT connamespace, conrelid, conkey, pg_get_constraintdef(oid) As consrc - FROM pg_constraint) AS s + FROM pg_constraint) AS s WHERE s.consrc ~~* '%geometrytype(% = %'::text ) st ON st.connamespace = n.oid AND st.conrelid = c.oid AND (a.attnum = ANY (st.conkey)) diff --git a/postgis/postgis_drop_after.sql b/postgis/postgis_drop_after.sql index 962dd00c2..6c06156e6 100644 --- a/postgis/postgis_drop_after.sql +++ b/postgis/postgis_drop_after.sql @@ -175,10 +175,6 @@ DROP FUNCTION IF EXISTS _ST_DumpPoints( geometry, integer[]); -- removed 2.4.0, DROP FUNCTION IF EXISTS _ST_DistanceRectTree(g1 geometry, g2 geometry); DROP FUNCTION IF EXISTS _ST_DistanceRectTreeCached(g1 geometry, g2 geometry); -DROP FUNCTION IF EXISTS postgis_constraint_srid(text,text,text); -DROP FUNCTION IF EXISTS postgis_constraint_dims(text,text,text); -DROP FUNCTION IF EXISTS postgis_constraint_type(text,text,text); - -- pgis_abs type was increased from 8 bytes in 2.1 to 16 bytes in 2.2 -- See #3460 diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in index 249279884..f1071c11f 100644 --- a/raster/rt_pg/rtpostgis.sql.in +++ b/raster/rt_pg/rtpostgis.sql.in @@ -7572,7 +7572,7 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_spatially_unique(rastschema n SELECT TRUE FROM pg_class c, pg_namespace n, pg_attribute a - , (SELECT connamespace, conrelid, conkey, contype, pg_get_constraintdef(oid) As consrc + , (SELECT connamespace, conrelid, conindid, conkey, contype, conexclop, pg_get_constraintdef(oid) As consrc FROM pg_constraint) AS s , pg_index idx, pg_operator op WHERE n.nspname = $1 @@ -7623,7 +7623,7 @@ CREATE OR REPLACE FUNCTION _drop_raster_constraint_spatially_unique(rastschema n SELECT s.conname INTO cn FROM pg_class c, pg_namespace n, pg_attribute a - , (SELECT connamespace, conrelid, conkey, contype, pg_get_constraintdef(oid) As consrc + , (SELECT connamespace, conrelid, conkey, conindid, contype, conexclop, pg_get_constraintdef(oid) As consrc FROM pg_constraint) AS s , pg_index idx, pg_operator op WHERE n.nspname = $1