Tweak prettyprinting rules for saner indenting of UNION, INTERSECT,

EXCEPT constructs.
This commit is contained in:
Tom Lane 2004-09-01 23:58:38 +00:00
parent 453c670b61
commit e41acf4029

View File

@ -3,7 +3,7 @@
* back to source text * back to source text
* *
* IDENTIFICATION * 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. * 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: case SETOP_UNION:
appendContextKeyword(context, "UNION ", appendContextKeyword(context, "UNION ",
-PRETTYINDENT_STD, 0, 0); -PRETTYINDENT_STD, PRETTYINDENT_STD, 0);
break; break;
case SETOP_INTERSECT: case SETOP_INTERSECT:
appendContextKeyword(context, "INTERSECT ", appendContextKeyword(context, "INTERSECT ",
-PRETTYINDENT_STD, 0, 0); -PRETTYINDENT_STD, PRETTYINDENT_STD, 0);
break; break;
case SETOP_EXCEPT: case SETOP_EXCEPT:
appendContextKeyword(context, "EXCEPT ", appendContextKeyword(context, "EXCEPT ",
-PRETTYINDENT_STD, 0, 0); -PRETTYINDENT_STD, PRETTYINDENT_STD, 0);
break; break;
default: default:
elog(ERROR, "unrecognized set op: %d", elog(ERROR, "unrecognized set op: %d",
@ -2220,7 +2220,7 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context,
appendStringInfo(buf, "ALL "); appendStringInfo(buf, "ALL ");
if (PRETTY_INDENT(context)) if (PRETTY_INDENT(context))
appendStringInfoChar(buf, '\n'); appendContextKeyword(context, "", 0, 0, 0);
need_paren = !IsA(op->rarg, RangeTblRef); need_paren = !IsA(op->rarg, RangeTblRef);
@ -2869,22 +2869,18 @@ appendContextKeyword(deparse_context *context, const char *str,
if (PRETTY_INDENT(context)) if (PRETTY_INDENT(context))
{ {
context->indentLevel += indentBefore; context->indentLevel += indentBefore;
if (context->indentLevel < 0)
context->indentLevel = 0;
appendStringInfoChar(context->buf, '\n'); appendStringInfoChar(context->buf, '\n');
appendStringInfoSpaces(context->buf, appendStringInfoSpaces(context->buf,
context->indentLevel + indentPlus); Max(context->indentLevel, 0) + indentPlus);
} appendStringInfoString(context->buf, str);
appendStringInfoString(context->buf, str);
if (PRETTY_INDENT(context))
{
context->indentLevel += indentAfter; context->indentLevel += indentAfter;
if (context->indentLevel < 0) if (context->indentLevel < 0)
context->indentLevel = 0; context->indentLevel = 0;
} }
else
appendStringInfoString(context->buf, str);
} }
/* /*