From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Reduce indentation/parenthesization of set operations in rule/vi |
Date: | 2014-04-30 17:26:38 |
Message-ID: | E1WfYHG-00073d-H7@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Reduce indentation/parenthesization of set operations in rule/view dumps.
A query such as "SELECT x UNION SELECT y UNION SELECT z UNION ..."
produces a left-deep nested parse tree, which we formerly showed in its
full nested glory and with all the possible parentheses. This does little
for readability, though, and long UNION lists resulting in excessive
indentation are common. Instead, let's omit parentheses and indent all
the subqueries at the same level in such cases.
This patch skips indentation/parenthesization whenever the lefthand input
of a SetOperationStmt is another SetOperationStmt of the same kind and
ALL/DISTINCT property. We could teach the code the exact syntactic
precedence of set operations and thereby avoid parenthesization in some
more cases, but it's not clear that that'd be a readability win: it seems
better to parenthesize if the set operation changes. (As an example,
if there's one UNION in a long list of UNION ALL, it now stands out like
a sore thumb, which seems like a good thing.)
Back-patch to 9.3. This completes our response to a complaint from Greg
Stark that since commit 62e666400d there's a performance problem in pg_dump
for views containing long UNION sequences (or other types of deeply nested
constructs). The previous commit 0601cb54dac14d979d726ab2ebeda251ae36e857
handles the general problem, but this one makes the specific case of UNION
lists look a lot nicer.
Branch
------
REL9_3_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/0652d77fb067137be22dc3e42aa60bffa26726ac
Modified Files
--------------
src/backend/utils/adt/ruleutils.c | 81 +++++---
src/test/regress/expected/create_view.out | 274 +++++++++++++--------------
src/test/regress/expected/matview.out | 24 +--
src/test/regress/expected/rules.out | 290 ++++++++++++++---------------
src/test/regress/expected/with.out | 84 ++++-----
5 files changed, 390 insertions(+), 363 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2014-04-30 17:46:53 | pgsql: Check for interrupts and stack overflow during rule/view dumps. |
Previous Message | Tom Lane | 2014-04-30 16:48:28 | pgsql: Limit overall indentation in rule/view dumps. |