CREATE OR REPLACE FUNCTION _raster_constraint_info_srid(rastschema name, rasttable name, rastcolumn name)
RETURNS integer AS $$
SELECT
- replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', '')::integer
+ regexp_replace(
+ split_part(s.consrc, ' = ', 2),
+ '[\(\)]', '', 'g'
+ )::integer
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
WHERE n.nspname = $1
AND c.relname = $2
CREATE OR REPLACE FUNCTION _raster_constraint_info_scale(rastschema name, rasttable name, rastcolumn name, axis char)
RETURNS double precision AS $$
SELECT
- replace(
+ regexp_replace(
replace(
- replace(
- replace(
- split_part(
- split_part(s.consrc, ' = ', 2),
- '::', 1
- ),
- 'round(', ''
- ),
- ')', ''
+ split_part(
+ split_part(s.consrc, ' = ', 2),
+ '::', 1
),
- '(', ''
+ 'round(', ''
),
- ' ', ''
+ '[ ''''\(\)]', '', 'g'
)::double precision
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
WHERE n.nspname = $1
WHEN strpos(s.consrc, 'ANY (ARRAY[') > 0 THEN
split_part((regexp_matches(s.consrc, E'ARRAY\\[(.*?){1}\\]'))[1], ',', 1)::integer
ELSE
- replace(replace(split_part(s.consrc, '= ', 2), ')', ''), '(', '')::integer
+ regexp_replace(
+ split_part(s.consrc, '= ', 2),
+ '[\(\)]', '', 'g'
+ )::integer
END
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
WHERE n.nspname = $1
CREATE OR REPLACE FUNCTION _raster_constraint_info_num_bands(rastschema name, rasttable name, rastcolumn name)
RETURNS integer AS $$
SELECT
- replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', '')::integer
+ regexp_replace(
+ split_part(s.consrc, ' = ', 2),
+ '[\(\)]', '', 'g'
+ )::integer
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
WHERE n.nspname = $1
AND c.relname = $2
CREATE OR REPLACE FUNCTION _raster_constraint_info_pixel_types(rastschema name, rasttable name, rastcolumn name)
RETURNS text[] AS $$
SELECT
- trim(both '''' from split_part(replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', ''), '::', 1))::text[]
+ trim(
+ both '''' from split_part(
+ regexp_replace(
+ split_part(s.consrc, ' = ', 2),
+ '[\(\)]', '', 'g'
+ ),
+ '::', 1
+ )
+ )::text[]
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
WHERE n.nspname = $1
AND c.relname = $2
SELECT
trim(both '''' from
split_part(
- replace(
- replace(
- split_part(s.consrc, ' = ', 2),
- ')', ''
- ),
- '(', ''
+ regexp_replace(
+ split_part(s.consrc, ' = ', 2),
+ '[\(\)]', '', 'g'
),
'::', 1
)
CREATE OR REPLACE FUNCTION _raster_constraint_info_out_db(rastschema name, rasttable name, rastcolumn name)
RETURNS boolean[] AS $$
SELECT
- trim(both '''' from split_part(replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', ''), '::', 1))::boolean[]
+ trim(
+ both '''' from split_part(
+ regexp_replace(
+ split_part(s.consrc, ' = ', 2),
+ '[\(\)]', '', 'g'
+ ),
+ '::', 1
+ )
+ )::boolean[]
FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
WHERE n.nspname = $1
AND c.relname = $2