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

Commitd166eed

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 parent5358bfd commitd166eed

File tree

4 files changed

+403
-401
lines changed

4 files changed

+403
-401
lines changed

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

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

6969
/* Indent counts */
7070
#definePRETTYINDENT_STD8
71-
#definePRETTYINDENT_JOIN 13
72-
#definePRETTYINDENT_JOIN_ON(PRETTYINDENT_JOIN-PRETTYINDENT_STD)
71+
#definePRETTYINDENT_JOIN4
7372
#definePRETTYINDENT_VAR4
7473

7574
/* Pretty flags */
@@ -8378,27 +8377,32 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
83788377
caseJOIN_INNER:
83798378
if (j->quals)
83808379
appendContextKeyword(context," JOIN ",
8381-
-PRETTYINDENT_JOIN,
8382-
PRETTYINDENT_JOIN,2);
8380+
-PRETTYINDENT_STD,
8381+
PRETTYINDENT_STD,
8382+
PRETTYINDENT_JOIN);
83838383
else
83848384
appendContextKeyword(context," CROSS JOIN ",
8385-
-PRETTYINDENT_JOIN,
8386-
PRETTYINDENT_JOIN,1);
8385+
-PRETTYINDENT_STD,
8386+
PRETTYINDENT_STD,
8387+
PRETTYINDENT_JOIN);
83878388
break;
83888389
caseJOIN_LEFT:
83898390
appendContextKeyword(context," LEFT JOIN ",
8390-
-PRETTYINDENT_JOIN,
8391-
PRETTYINDENT_JOIN,2);
8391+
-PRETTYINDENT_STD,
8392+
PRETTYINDENT_STD,
8393+
PRETTYINDENT_JOIN);
83928394
break;
83938395
caseJOIN_FULL:
83948396
appendContextKeyword(context," FULL JOIN ",
8395-
-PRETTYINDENT_JOIN,
8396-
PRETTYINDENT_JOIN,2);
8397+
-PRETTYINDENT_STD,
8398+
PRETTYINDENT_STD,
8399+
PRETTYINDENT_JOIN);
83978400
break;
83988401
caseJOIN_RIGHT:
83998402
appendContextKeyword(context," RIGHT JOIN ",
8400-
-PRETTYINDENT_JOIN,
8401-
PRETTYINDENT_JOIN,2);
8403+
-PRETTYINDENT_STD,
8404+
PRETTYINDENT_STD,
8405+
PRETTYINDENT_JOIN);
84028406
break;
84038407
default:
84048408
elog(ERROR,"unrecognized join type: %d",
@@ -8411,8 +8415,6 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
84118415
if (need_paren_on_right)
84128416
appendStringInfoChar(buf,')');
84138417

8414-
context->indentLevel-=PRETTYINDENT_JOIN_ON;
8415-
84168418
if (j->usingClause)
84178419
{
84188420
ListCell*lc;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp