Commit debd4dd6 authored by Regina Obe's avatar Regina Obe

Remove deprecated functions postgis_constraint_srid, postgis_constraint_dims,...

Remove deprecated functions postgis_constraint_srid, postgis_constraint_dims, postgis_constraint_type
Replace use of pg_constraint.consrc with ​pg_get_constraintdef(oid) pg_constraint.consrc was removed in PostgreSQL 12 and pg_get_constraintdef function has existed at least since PostgreSQL 9.4 (our lowest supported for 2.5), so safe to use across all our supported versions
References #4321 for PostGIS 3.0

git-svn-id: http://svn.osgeo.org/postgis/trunk@17029 b70326c6-7e19-0410-871a-916f4a2858ee
parent 43e9bc1c
Pipeline #37042469 failed with stage
in 7 minutes and 20 seconds
......@@ -10,6 +10,12 @@ 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)
......
......@@ -5668,63 +5668,12 @@ $$
$$
LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL COST 200;
-- Availability: 2.0.0
-- Deprecation in 2.2.0
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, pg_constraint 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
-- Deprecation in 2.2.0
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, pg_constraint 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
-- Deprecation in 2.2.0
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, pg_constraint 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
-- Changed: 2.5.2 replace use of pg_constraint.consrc with pg_get_constraintdef, consrc removed pg12
CREATE OR REPLACE VIEW geometry_columns AS
SELECT current_database()::character varying(256) AS f_table_catalog,
n.nspname AS f_table_schema,
......@@ -5740,21 +5689,24 @@ CREATE OR REPLACE VIEW geometry_columns AS
LEFT JOIN ( SELECT s.connamespace,
s.conrelid,
s.conkey, replace(split_part(s.consrc, ''''::text, 2), ')'::text, ''::text) As type
FROM pg_constraint AS s
FROM (SELECT connamespace, conrelid, conkey, pg_get_constraintdef(oid) As consrc
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))
LEFT JOIN ( SELECT s.connamespace,
s.conrelid,
s.conkey, replace(split_part(s.consrc, ' = '::text, 2), ')'::text, ''::text)::integer As ndims
FROM pg_constraint AS s
FROM (SELECT connamespace, conrelid, conkey, pg_get_constraintdef(oid) As consrc
FROM pg_constraint) AS s
WHERE s.consrc ~~* '%ndims(% = %'::text
) sn ON sn.connamespace = n.oid AND sn.conrelid = c.oid AND (a.attnum = ANY (sn.conkey))
LEFT JOIN ( SELECT s.connamespace,
s.conrelid,
s.conkey, replace(replace(split_part(s.consrc, ' = '::text, 2), ')'::text, ''::text), '('::text, ''::text)::integer As srid
FROM pg_constraint AS s
FROM (SELECT connamespace, conrelid, conkey, pg_get_constraintdef(oid) As consrc
FROM pg_constraint) AS s
WHERE s.consrc ~~* '%srid(% = %'::text
) sr ON sr.connamespace = n.oid AND sr.conrelid = c.oid AND (a.attnum = ANY (sr.conkey))
......
......@@ -175,6 +175,10 @@ 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
......
......@@ -7210,7 +7210,9 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_srid(rastschema name, rasttab
split_part(s.consrc, ' = ', 2),
'[\(\)]', '', 'g'
)::integer
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
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
......@@ -7280,7 +7282,9 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_scale(rastschema name, rastta
),
'[ ''''\(\)]', '', 'g'
)::text AS val
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
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
......@@ -7366,7 +7370,9 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_blocksize(rastschema name, ra
'[\(\)]', '', 'g'
)::integer
END
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
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
......@@ -7442,7 +7448,9 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_extent(rastschema name, rastt
RETURNS geometry AS $$
SELECT
trim(both '''' from split_part(trim(split_part(s.consrc, ' @ ', 2)), '::', 1))::geometry
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
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
......@@ -7504,7 +7512,9 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_alignment(rastschema name, ra
RETURNS boolean AS $$
SELECT
TRUE
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
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
......@@ -7561,7 +7571,10 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_spatially_unique(rastschema n
RETURNS boolean AS $$
SELECT
TRUE
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s, pg_index idx, pg_operator op
FROM pg_class c, pg_namespace n, pg_attribute a
, (SELECT connamespace, conrelid, conkey, contype, pg_get_constraintdef(oid) As consrc
FROM pg_constraint) AS s
, pg_index idx, pg_operator op
WHERE n.nspname = $1
AND c.relname = $2
AND a.attname = $3
......@@ -7609,7 +7622,10 @@ CREATE OR REPLACE FUNCTION _drop_raster_constraint_spatially_unique(rastschema n
BEGIN
SELECT
s.conname INTO cn
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s, pg_index idx, pg_operator op
FROM pg_class c, pg_namespace n, pg_attribute a
, (SELECT connamespace, conrelid, conkey, contype, pg_get_constraintdef(oid) As consrc
FROM pg_constraint) AS s
, pg_index idx, pg_operator op
WHERE n.nspname = $1
AND c.relname = $2
AND a.attname = $3
......@@ -7632,7 +7648,9 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_coverage_tile(rastschema name
RETURNS boolean AS $$
SELECT
TRUE
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
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
......@@ -7743,7 +7761,9 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_num_bands(rastschema name, ra
split_part(s.consrc, ' = ', 2),
'[\(\)]', '', 'g'
)::integer
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
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
......@@ -7810,7 +7830,9 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_pixel_types(rastschema name,
'::', 1
)
)::text[]
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
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
......@@ -7893,7 +7915,9 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_nodata_values(rastschema name
'::', 1
)
)::double precision[]
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
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
......@@ -7982,7 +8006,9 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_out_db(rastschema name, rastt
'::', 1
)
)::boolean[]
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
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
......@@ -8624,7 +8650,9 @@ CREATE OR REPLACE FUNCTION _overview_constraint_info(
split_part(split_part(s.consrc, '''::name', 2), '''', 2)::name,
split_part(split_part(s.consrc, '''::name', 3), '''', 2)::name,
trim(both from split_part(s.consrc, ',', 2))::integer
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
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
......@@ -8694,7 +8722,8 @@ CREATE OR REPLACE VIEW raster_overviews AS
pg_attribute a,
pg_type t,
pg_namespace n,
pg_constraint s
(SELECT connamespace, conrelid, conkey, pg_get_constraintdef(oid) As consrc
FROM pg_constraint) AS s
WHERE t.typname = 'raster'::name
AND a.attisdropped = false
AND a.atttypid = t.oid
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment