[postgis-tickets] r17030 - Put back deprecated functions removed in r17029, but patch them to use newer pg_get_constraintdef function.
Regina Obe
lr at pcorp.us
Sun Nov 18 03:57:16 PST 2018
Author: robe
Date: 2018-11-18 15:57:16 -0800 (Sun, 18 Nov 2018)
New Revision: 17030
Modified:
trunk/NEWS
trunk/postgis/Makefile.in
trunk/postgis/postgis.sql.in
trunk/postgis/postgis_drop_after.sql
trunk/raster/rt_pg/rtpostgis.sql.in
Log:
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
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2018-11-18 23:12:34 UTC (rev 17029)
+++ trunk/NEWS 2018-11-18 23:57:16 UTC (rev 17030)
@@ -10,12 +10,6 @@
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)
Modified: trunk/postgis/Makefile.in
===================================================================
--- trunk/postgis/Makefile.in 2018-11-18 23:12:34 UTC (rev 17029)
+++ trunk/postgis/Makefile.in 2018-11-18 23:57:16 UTC (rev 17030)
@@ -122,7 +122,8 @@
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)
Modified: trunk/postgis/postgis.sql.in
===================================================================
--- trunk/postgis/postgis.sql.in 2018-11-18 23:12:34 UTC (rev 17029)
+++ trunk/postgis/postgis.sql.in 2018-11-18 23:57:16 UTC (rev 17030)
@@ -5669,6 +5669,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
-- Changed: 2.4.0 List also Parent partitioned tables
@@ -5690,7 +5749,7 @@
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))
Modified: trunk/postgis/postgis_drop_after.sql
===================================================================
--- trunk/postgis/postgis_drop_after.sql 2018-11-18 23:12:34 UTC (rev 17029)
+++ trunk/postgis/postgis_drop_after.sql 2018-11-18 23:57:16 UTC (rev 17030)
@@ -175,11 +175,7 @@
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
UPDATE pg_type SET typlen=16 WHERE typname='pgis_abs' AND typlen=8;
Modified: trunk/raster/rt_pg/rtpostgis.sql.in
===================================================================
--- trunk/raster/rt_pg/rtpostgis.sql.in 2018-11-18 23:12:34 UTC (rev 17029)
+++ trunk/raster/rt_pg/rtpostgis.sql.in 2018-11-18 23:57:16 UTC (rev 17030)
@@ -7572,7 +7572,7 @@
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 @@
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
More information about the postgis-tickets
mailing list