Testing geometries for simplicity is done by the ST_IsSimple function. It accepts a geometry and returns a Boolean indicating whether a given geometry is simple. For example, a simple line looks like the following:
SELECT ST_IsSimple(ST_MakeLine(ST_MakePoint(20,50),ST_MakePoint(19.95,49.98)));
st_issimple
-------------
t
The next line has a repeated point:
SELECT ST_IsSimple(ST_MakeLine(ARRAY[ST_MakePoint(20,50),ST_MakePoint(19.95,49.98),ST_MakePoint(19.90,49.90), ST_MakePoint(19.95,49.98)]));
st_issimple
-------------
f
So the ST_IsSimple function returns FALSE.
For geometries stored in a table, the following syntax can be used to show the non-simple ones:
SELECT * FROM planet_osm_line WHERE ST_IsSimple(way) = FALSE;