Manual. Uses ST_Polygonize from GDAL. I did not manage to get this to work, but it is manual, mind you.
Fast method, but complex query. Uses ST_Polygonize from GDAL. I suggest using this method, works well with insanely large datasets. Remember to use GiST index.
Relatively slow, but seems to work, also gives you good control over dangles and cuts.