pg_extractor
pg_extractor copied to clipboard
pretty print views
Views are dumped by pg_dump as one long line, impossible to read.
See discussion here (patch in discussion never seemed to make it to postgresql tree):
http://thread.gmane.org/gmane.comp.db.postgresql.devel.general/198523
Can pg_extract pretty-print?
Sent an email to the list to see if this was ever implemented. Looks like it was applied in 9.3.0 http://www.postgresql.org/message-id/[email protected]
It's also in the release notes in section E.5.3.6. Functions
Cause pg_get_viewdef() to start a new line by default after each SELECT target list entry and FROM entry (Marko Tiikkaja)
I tested things out and 9.3 pg_dump does make much more readable view output
For older pgs you can consider checking if "sqlformat" program is available, and if yes - using it as filer. In debian/ubuntu it should be available in python-sqlparse package.
Oh nice! I'll see if I can make that an option.
I see no big improvement using 9.3.4 pg_dump. Do you? I saw some additional patches in the old postgres-devel thread being revived due to your enquiry as well. sqlformat gives some help, but could be better with CASE statements.
I just did a basic select with some joins. For me, it had returns after each column and at the FROM & JOINs. Fancier stuff may not get the full formatting you're looking for.
I've got the sqlformat stuff on my todo list. Will get that added in when I have the time.
I'd honestly rather not have any non-standard third-party library dependencies in pg_extractor right now. If you, or anyone else wants to write up a push request for this, I'd gladly review it and see how it looks. I don't have any plans on implementing this myself anytime soon, though.