]> granicus.if.org Git - postgresql/commitdiff
Tweak prettyprinting rules for saner indenting of UNION, INTERSECT,
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 1 Sep 2004 23:58:38 +0000 (23:58 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 1 Sep 2004 23:58:38 +0000 (23:58 +0000)
EXCEPT constructs.

src/backend/utils/adt/ruleutils.c

index 9004d294867e0375d75be029241f9897601c494a..af859222c368d4c0bd8e6a5678ccc15fea66f7f0 100644 (file)
@@ -3,7 +3,7 @@
  *                             back to source text
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.179 2004/08/29 05:06:49 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.180 2004/09/01 23:58:38 tgl Exp $
  *
  *       This software is copyrighted by Jan Wieck - Hamburg.
  *
@@ -2202,15 +2202,15 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context,
                {
                        case SETOP_UNION:
                                appendContextKeyword(context, "UNION ",
-                                                                        -PRETTYINDENT_STD, 0, 0);
+                                                                        -PRETTYINDENT_STD, PRETTYINDENT_STD, 0);
                                break;
                        case SETOP_INTERSECT:
                                appendContextKeyword(context, "INTERSECT ",
-                                                                        -PRETTYINDENT_STD, 0, 0);
+                                                                        -PRETTYINDENT_STD, PRETTYINDENT_STD, 0);
                                break;
                        case SETOP_EXCEPT:
                                appendContextKeyword(context, "EXCEPT ",
-                                                                        -PRETTYINDENT_STD, 0, 0);
+                                                                        -PRETTYINDENT_STD, PRETTYINDENT_STD, 0);
                                break;
                        default:
                                elog(ERROR, "unrecognized set op: %d",
@@ -2220,7 +2220,7 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context,
                        appendStringInfo(buf, "ALL ");
 
                if (PRETTY_INDENT(context))
-                       appendStringInfoChar(buf, '\n');
+                       appendContextKeyword(context, "", 0, 0, 0);
 
                need_paren = !IsA(op->rarg, RangeTblRef);
 
@@ -2869,22 +2869,18 @@ appendContextKeyword(deparse_context *context, const char *str,
        if (PRETTY_INDENT(context))
        {
                context->indentLevel += indentBefore;
-               if (context->indentLevel < 0)
-                       context->indentLevel = 0;
 
                appendStringInfoChar(context->buf, '\n');
                appendStringInfoSpaces(context->buf,
-                                                          context->indentLevel + indentPlus);
-       }
-
-       appendStringInfoString(context->buf, str);
+                                                          Max(context->indentLevel, 0) + indentPlus);
+               appendStringInfoString(context->buf, str);
 
-       if (PRETTY_INDENT(context))
-       {
                context->indentLevel += indentAfter;
                if (context->indentLevel < 0)
                        context->indentLevel = 0;
        }
+       else
+               appendStringInfoString(context->buf, str);
 }
 
 /*