WIP: pg_pretty_query

Pavel Stehule <pavel.stehule@gmail.com>

From: Pavel Stehule <pavel.stehule@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: Andrew Dunstan <andrew@dunslane.net>
Date: 2012-08-07T14:14:34Z
Lists: pgsql-hackers

Attachments

Hello

last year we are spoke about reusing pretty print view code for some queries.

Here is patch:

this patch is really short - it is nice. But - it works only with
known database objects (probably we would it) and it doesn't format
subqueries well


postgres=# select pg_pretty_query('select x.*, z.* from foo, foo x, x
z  where x.a = 10 and x.a = 30 and EXISTS(SELECT * FROM foo WHERE a =
z.a)', true, false);
                     pg_pretty_query
----------------------------------------------------------
  SELECT x.a, z.a                                        +
    FROM foo, foo x, x z                                 +
   WHERE x.a = 10 AND x.a = 30 AND (EXISTS ( SELECT foo.a+
            FROM foo                                     +
           WHERE foo.a = z.a))
(1 row)

Regards

Pavel