CREATE FUNCTION CheckNoding(g geometry)
RETURNS TABLE(ap int[], bp int[], im text)
AS
$$
with
 noded as ( select $1 as g ),
 dumpd as ( select (st_dump(g)).* from noded ),
 matrx as ( select a.path as ap, b.path as bp,
                   st_relate(a.geom, b.geom, 2) as im
            from dumpd a, dumpd b where a.path < b.path )
select ap, bp, im from matrx where ST_RelateMatch(im, 'T********');
$$ 
LANGUAGE 'SQL';
