rsgb
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
populate_geometry_columns(use_typmod boolean DEFAULT true)
Parameters
Name
Type
Mode
use_typmod
boolean
IN
Definition
DECLARE inserted integer; oldcount integer; probed integer; stale integer; gcs RECORD; gc RECORD; gsrid integer; gndims integer; gtype text; query text; gc_is_valid boolean; BEGIN SELECT count(*) INTO oldcount FROM public.geometry_columns; inserted := 0; -- Count the number of geometry columns in all tables and views SELECT count(DISTINCT c.oid) INTO probed FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n WHERE c.relkind IN('r','v','f', 'p') AND t.typname = 'geometry' AND a.attisdropped = false AND a.atttypid = t.oid AND a.attrelid = c.oid AND c.relnamespace = n.oid AND n.nspname NOT ILIKE 'pg_temp%' AND c.relname != 'raster_columns' ; -- Iterate through all non-dropped geometry columns RAISE DEBUG 'Processing Tables.....'; FOR gcs IN SELECT DISTINCT ON (c.oid) c.oid, n.nspname, c.relname FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n WHERE c.relkind IN( 'r', 'f', 'p') AND t.typname = 'geometry' AND a.attisdropped = false AND a.atttypid = t.oid AND a.attrelid = c.oid AND c.relnamespace = n.oid AND n.nspname NOT ILIKE 'pg_temp%' AND c.relname != 'raster_columns' LOOP inserted := inserted + public.populate_geometry_columns(gcs.oid, use_typmod); END LOOP; IF oldcount > inserted THEN stale = oldcount-inserted; ELSE stale = 0; END IF; RETURN 'probed:' ||probed|| ' inserted:'||inserted; END