Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit164acbe

Browse files
committed
Fix indentation of JOIN clauses in rule/view dumps.
The code attempted to outdent JOIN clauses further left than the parentFROM keyword, which was odd in any case, and led to inconsistent formattingsince in simple cases the clauses couldn't be moved any further left thanthat. And it left a permanent decrement of the indentation level, causingsubsequent lines to be much further left than they should be (again, thiscouldn't be seen in simple cases for lack of indentation to give up).After a little experimentation I chose to make it indent JOIN keywordstwo spaces from the parent FROM, which is one space more than the join'slefthand input in cases where that appears on a different line from FROM.Back-patch to 9.3. This is a purely cosmetic change, and the bug is quiteold, so that may seem arbitrary; but we are going to be making some otherchanges to the indentation behavior in both HEAD and 9.3, so it seemsreasonable to include this in 9.3 too. I committed this one first becauseits effects are more visible in the regression test results as theycurrently stand than they will be later.
1 parent8a90a39 commit164acbe

File tree

3 files changed

+384
-382
lines changed

3 files changed

+384
-382
lines changed

‎src/backend/utils/adt/ruleutils.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@
6666

6767
/* Indent counts */
6868
#definePRETTYINDENT_STD8
69-
#definePRETTYINDENT_JOIN 13
70-
#definePRETTYINDENT_JOIN_ON(PRETTYINDENT_JOIN-PRETTYINDENT_STD)
69+
#definePRETTYINDENT_JOIN4
7170
#definePRETTYINDENT_VAR4
7271

7372
/* Pretty flags */
@@ -8122,27 +8121,32 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
81228121
caseJOIN_INNER:
81238122
if (j->quals)
81248123
appendContextKeyword(context," JOIN ",
8125-
-PRETTYINDENT_JOIN,
8126-
PRETTYINDENT_JOIN,2);
8124+
-PRETTYINDENT_STD,
8125+
PRETTYINDENT_STD,
8126+
PRETTYINDENT_JOIN);
81278127
else
81288128
appendContextKeyword(context," CROSS JOIN ",
8129-
-PRETTYINDENT_JOIN,
8130-
PRETTYINDENT_JOIN,1);
8129+
-PRETTYINDENT_STD,
8130+
PRETTYINDENT_STD,
8131+
PRETTYINDENT_JOIN);
81318132
break;
81328133
caseJOIN_LEFT:
81338134
appendContextKeyword(context," LEFT JOIN ",
8134-
-PRETTYINDENT_JOIN,
8135-
PRETTYINDENT_JOIN,2);
8135+
-PRETTYINDENT_STD,
8136+
PRETTYINDENT_STD,
8137+
PRETTYINDENT_JOIN);
81368138
break;
81378139
caseJOIN_FULL:
81388140
appendContextKeyword(context," FULL JOIN ",
8139-
-PRETTYINDENT_JOIN,
8140-
PRETTYINDENT_JOIN,2);
8141+
-PRETTYINDENT_STD,
8142+
PRETTYINDENT_STD,
8143+
PRETTYINDENT_JOIN);
81418144
break;
81428145
caseJOIN_RIGHT:
81438146
appendContextKeyword(context," RIGHT JOIN ",
8144-
-PRETTYINDENT_JOIN,
8145-
PRETTYINDENT_JOIN,2);
8147+
-PRETTYINDENT_STD,
8148+
PRETTYINDENT_STD,
8149+
PRETTYINDENT_JOIN);
81468150
break;
81478151
default:
81488152
elog(ERROR,"unrecognized join type: %d",
@@ -8155,8 +8159,6 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
81558159
if (need_paren_on_right)
81568160
appendStringInfoChar(buf,')');
81578161

8158-
context->indentLevel-=PRETTYINDENT_JOIN_ON;
8159-
81608162
if (j->usingClause)
81618163
{
81628164
ListCell*lc;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp