pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Piotr Stefaniak <postgres@piotr-stefaniak.me>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: pgindent (was Re: [COMMITTERS] pgsql: Preventive maintenance in advance of pgindent run.)
Date: Thu, 18 May 2017 22:31:04 -0400
Message-ID: <28060.1495161064@sss.pgh.pa.us> (raw)
In-Reply-To: <15819.1495145176@sss.pgh.pa.us>
References: <20170517171600.fyxl3lhseszeuqrx@alvherre.pgsql>
	<AM3PR03MB1188858CCD55BC737C856F65F2E70@AM3PR03MB1188.eurprd03.prod.outlook.com>
	<880.1495045872@sss.pgh.pa.us>
	<VI1PR03MB119946C58CB0DD179DE43AD7F2E70@VI1PR03MB1199.eurprd03.prod.outlook.com>
	<5316.1495051919@sss.pgh.pa.us>
	<VI1PR03MB11999517FAD86D2C02407272F2E70@VI1PR03MB1199.eurprd03.prod.outlook.com>
	<11874.1495057567@sss.pgh.pa.us>
	<VI1PR03MB119987EDC3126CD6A56CF29CF2E40@VI1PR03MB1199.eurprd03.prod.outlook.com>
	<15819.1495145176@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

I wrote:
> Curiously, there are other enum declarations that don't get the phony
> extra indentation.  I traced through it a bit and eventually found that
> the difference between OK and not OK is that the declarations that don't
> get messed up look like "typedef enum enumlabel ...", ie the problem
> with this one is there's no extra identifier after "enum".  The proximate
> cause of that is this line in indent.c:

>       ps.in_decl = ps.decl_on_line = ps.last_token != type_def;

I found that things seem to work better with this change:

@@ -939,7 +938,7 @@ check_type:
        }
        ps.in_or_st = true; /* this might be a structure or initialization
                 * declaration */
-       ps.in_decl = ps.decl_on_line = ps.last_token != type_def;
+       ps.in_decl = ps.decl_on_line = (ps.last_token != type_def || type_code == structure);
        if ( /* !ps.in_or_st && */ ps.dec_nest <= 0)
        ps.just_saw_decl = 2;
        prefix_blankline_requested = 0;

I have no idea if that's a correct or sufficient fix, but it makes the
oddnesses around unnamed enum and struct declarations in the PG sources
go away.

There remain a small number of cases that look like bugs.  One is the
case I showed before:

@@ -531,7 +531,7 @@ static bool
 ean2string(ean13 ean, bool errorOK, char *result, bool shortType)
 {
    const char *(*TABLE)[2];
-   const unsigned (*TABLE_index)[2];
+   const unsigned(*TABLE_index)[2];
    enum isn_type type = INVALID;
 
    char       *aux;

I have an impression that this might be related to the ps.in_decl business,
but the patch shown above did not change it.  Possibly related is this:

inline patch 1: src/include/access/gin_private.h (+2/-2 lines) download inline-1.patchdiff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h index 986fe6e..a2d11e5 100644 --- a/src/include/access/gin_private.h +++ b/src/include/access/gin_private.h @@ -149,8 +149,8 @@ typedef struct GinBtreeData bool (*findItem) (GinBtree, GinBtreeStack *); /* insert methods */ - OffsetNumber (*findChildPtr) (GinBtree, Page, BlockNumber, OffsetNumber); - GinPlaceToPageRC (*beginPlaceToPage) (GinBtree, Buffer, GinBtreeStack *, void *, BlockNumber, void **, Page *, Page *); + OffsetNumber(*findChildPtr) (GinBtree, Page, BlockNumber, OffsetNumber); + GinPlaceToPageRC(*beginPlaceToPage) (GinBtree, Buffer, GinBtreeStack *, void *, BlockNumber, void **, Page *, Page *); void (*execPlaceToPage) (GinBtree, Buffer, GinBtreeStack *, void *, BlockNumber, void *); void *(*prepareDownlink) (GinBtree, Buffer); void (*fillRoot) (GinBtree, Page, BlockNumber, Page, BlockNumber, Page);
Whatever's going on there, it seems to affect only a very small number of places. No idea why. Also, multiple comments on the same line are now run together, which is surely not better: @@ -2144,11 +2144,11 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, bool opportunistic) */ NewPage->xlp_magic = XLOG_PAGE_MAGIC; - /* NewPage->xlp_info = 0; */ /* done by memset */ + /* NewPage->xlp_info = 0; *//* done by memset */ NewPage->xlp_tli = ThisTimeLineID; NewPage->xlp_pageaddr = NewPageBeginPtr; - /* NewPage->xlp_rem_len = 0; */ /* done by memset */ + /* NewPage->xlp_rem_len = 0; *//* done by memset */ /* * If online backup is not in progress, mark the header to indicate Also, I found two places where an overlength comment line is simply busted altogether --- notice that a character is missing at the split point: @@ -257,7 +257,8 @@ get_pgpid(bool is_status_request) /* * The Linux Standard Base Core Specification 3.1 says this should * return '4, program or service status is unknown' - * https://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-g + * https://refspecs.linu + * base.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-g * eneric/iniscrptact.html */ exit(is_status_request ? 4 : 1); @@ -629,7 +629,8 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary, PGresult **res) /* * This code erroneously assumes '\.' on a line alone * inside a quoted CSV string terminates the \copy. - * http://www.postgresql.org/message-id/E1TdNVQ-0001ju-GO@w + * http://w + * w.postgresql.org/message-id/E1TdNVQ-0001ju-GO@w * rigleys.postgresql.org */ if (strcmp(buf, "\\.\n") == 0 || Another problem is that the handling of unrecognized typedef names as field types in a struct has gotten significantly worse:
inline patch 2: src/include/lib/simplehash.h (+1/-1 lines) download inline-2.patchdiff --git a/src/include/lib/simplehash.h b/src/include/lib/simplehash.h index a35addf..919d262 100644 --- a/src/include/lib/simplehash.h +++ b/src/include/lib/simplehash.h @@ -114,14 +114,14 @@ typedef struct SH_TYPE uint32 grow_threshold; /* hash buckets */ - SH_ELEMENT_TYPE *data; + SH_ELEMENT_TYPE * data; /* memory context to use for allocations */ MemoryContext ctx;
I don't mind the space after the star so much, but the indentation is awful. In this particular example we *cannot* fix it by making SH_ELEMENT_TYPE a real typedef, because it's actually meant to be a macro and vary from one inclusion of simplehash.h to another. I guess a possible answer is to create a list of "manual" typedef names to add to the ones extracted from the buildfarm. But if it's possible for indent to be a bit more fail-soft in this type of case, we'd not have to. It seems like other users of indent might have more need for plausible treatment of unknown typedef names than we do, too. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers Patches: download all (2 files, .tar.gz)

view thread (37+ messages)  latest in thread

Message-ID: <28060.1495161064@sss.pgh.pa.us>
Permalink:  ../28060.1495161064@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28060.1495161064@sss.pgh.pa.us

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, postgres@piotr-stefaniak.me, alvherre@2ndquadrant.com, peter.eisentraut@2ndquadrant.com, pgsql-hackers@postgresql.org
  Subject: Re: pgindent (was Re: [COMMITTERS] pgsql: Preventive maintenance in advance of pgindent run.)
  In-Reply-To: <28060.1495161064@sss.pgh.pa.us>
  References: <20170517171600.fyxl3lhseszeuqrx@alvherre.pgsql> <AM3PR03MB1188858CCD55BC737C856F65F2E70@AM3PR03MB1188.eurprd03.prod.outlook.com> <880.1495045872@sss.pgh.pa.us> <VI1PR03MB119946C58CB0DD179DE43AD7F2E70@VI1PR03MB1199.eurprd03.prod.outlook.com> <5316.1495051919@sss.pgh.pa.us> <VI1PR03MB11999517FAD86D2C02407272F2E70@VI1PR03MB1199.eurprd03.prod.outlook.com> <11874.1495057567@sss.pgh.pa.us> <VI1PR03MB119987EDC3126CD6A56CF29CF2E40@VI1PR03MB1199.eurprd03.prod.outlook.com> <15819.1495145176@sss.pgh.pa.us> <28060.1495161064@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox