I updated the function probe_geometry_columns().<br>Hope that help.<br>Fred<br><br>--------------------------------------------<br>-- Function: probe_geometry_columns()<br><br>-- DROP FUNCTION probe_geometry_columns();<br>
<br>CREATE OR REPLACE FUNCTION probe_geometry_columns()<br>  RETURNS text AS<br>$BODY$<br>DECLARE<br>    inserted integer;<br>    oldcount integer;<br>    probed integer;<br>    stale integer;<br>BEGIN<br><br>    SELECT count(*) INTO oldcount FROM geometry_columns;<br>
<br>    SELECT count(*) INTO probed<br>        FROM pg_class c, pg_attribute a, pg_type t,<br>            pg_namespace n,<br>            pg_constraint sridcheck, pg_constraint typecheck<br><br>        WHERE t.typname = 'geometry'<br>
        AND a.atttypid = t.oid<br>        AND a.attrelid = c.oid<br>        AND c.relnamespace = n.oid<br>        AND sridcheck.connamespace = n.oid<br>        AND typecheck.connamespace = n.oid<br>        AND sridcheck.conrelid = c.oid<br>
        AND sridcheck.consrc LIKE '(%.srid('||a.attname||') = %)'<br>        AND typecheck.conrelid = c.oid<br>        AND typecheck.consrc LIKE<br>        '((%.geometrytype('||a.attname||') = ''%''::text) OR (% IS NULL))'<br>
        ;<br><br>    INSERT INTO geometry_columns SELECT<br>        ''::varchar as f_table_catalogue,<br>        n.nspname::varchar as f_table_schema,<br>        c.relname::varchar as f_table_name,<br>        a.attname::varchar as f_geometry_column,<br>
        2 as coord_dimension,<br>        trim(both  ' =)' from<br>            replace(replace(split_part(<br>                sridcheck.consrc, ' = ', 2), ')', ''), '(', ''))::integer AS srid,<br>
        trim(both ' =)''' from substr(typecheck.consrc,<br>            strpos(typecheck.consrc, '='),<br>            strpos(typecheck.consrc, '::')-<br>            strpos(typecheck.consrc, '=')<br>
            ))::varchar as type<br>        FROM pg_class c, pg_attribute a, pg_type t,<br>            pg_namespace n,<br>            pg_constraint sridcheck, pg_constraint typecheck<br>        WHERE t.typname = 'geometry'<br>
        AND a.atttypid = t.oid<br>        AND a.attrelid = c.oid<br>        AND c.relnamespace = n.oid<br>        AND sridcheck.connamespace = n.oid<br>        AND typecheck.connamespace = n.oid<br>        AND sridcheck.conrelid = c.oid<br>
        AND sridcheck.consrc LIKE '(%.srid('||a.attname||') = %)'<br>        AND typecheck.conrelid = c.oid<br>        AND typecheck.consrc LIKE<br>        '((%.geometrytype('||a.attname||') = ''%''::text) OR (% IS NULL))'<br>
<br>            AND NOT EXISTS (<br>                    SELECT oid FROM geometry_columns gc<br>                    WHERE c.relname::varchar = gc.f_table_name<br>                    AND n.nspname::varchar = gc.f_table_schema<br>
                    AND a.attname::varchar = gc.f_geometry_column<br>            );<br><br>    GET DIAGNOSTICS inserted = ROW_COUNT;<br><br>    IF oldcount > probed THEN<br>        stale = oldcount-probed;<br>    ELSE<br>
        stale = 0;<br>    END IF;<br><br>    RETURN 'probed:'||probed::text||<br>        ' inserted:'||inserted::text||<br>        ' conflicts:'||(probed-inserted)::text||<br>        ' stale:'||stale::text;<br>
END<br><br>$BODY$<br>  LANGUAGE 'plpgsql' VOLATILE<br>  COST 100;<br>ALTER FUNCTION probe_geometry_columns() OWNER TO postgres;<br>COMMENT ON FUNCTION probe_geometry_columns() IS 'Scans all tables with PostGIS geometry constraints and adds them to the geometry_columns table if they are not there.';<br>
<br><br><br><br><br><br><br><br><br><div class="gmail_quote">On Tue, May 18, 2010 at 3:38 PM, Fred Lehodey <span dir="ltr"><<a href="mailto:lehodey@gmail.com">lehodey@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<br>I have no success trying the function probe_geometry_columns() with Postgis 1.5.0 <br><br>1) Not sure but comparing the SQL with Postgis 1.3.3:<br>the clause  (in the INSERT step and not the count of probed)<br>"sridcheck.consrc LIKE '(<b>srid</b>('||a.attname||') = %)'   in postgis 1.3.3<br>

is now:<br>"sridcheck.consrc LIKE '(<b>st_srid</b>('||a.attname||') = %)'  in postgis 1.5.0<br>
This looks like a tipo error. (this is not the function here but the constraint text in pg_constraint) <br><br><br>2) I have a second problem with pg_constraint table and the "consrc" field.<br>Most of time I have something like :<br>

"(public.srid(the_geom) = 27492)"  <br>and not (as expected by the function probe_geometry_columns()) :<br>"(srid(the_geom) = 27492)"<br><br>Thanks for any feed-back.<br><font color="#888888"><br>Fred.<br>
<br><br>
</font></blockquote></div><br>