Re: Comments in .pgpass file...

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
Cc: Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Comments in .pgpass file...
Date: 2024-05-21 03:04:13
Message-ID: CAKFQuwYVc4+8iW92D=yEA6HYtPuSjZJo1PosrngfyAnfhWXkcQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Monday, May 20, 2024, Ron Johnson <ronljohnsonjr(at)gmail(dot)com> wrote:

> On Mon, May 20, 2024 at 9:10 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> Ron Johnson <ronljohnsonjr(at)gmail(dot)com> writes:
>> > It seems that psql (or maybe libpq) doesn't like trailing comments.
>>
>> Why would you think it would take that? The manual says that lines
>> beginning with '#' are comments, but not more than that.
>>
>
> https://www.postgresql.org/docs/current/libpq-pgpass.html
>
> I searched the man page for "#" and "comment". The only mention is in
> this sentence:
>
> [quote]
>
> *hostname*:*port*:*database*:*username*:*password*
>
> (You can add a reminder comment to the file by copying the line above and
> preceding it with #.)
> [/quote]
>
> That one sentence can easily be read as only referring to the
> "hostname:port..." line.
>

That would seem oddly specific and easily falsifiable. Which is probably
why no one else has pointed out the odd wording. They actually try the
generalization and it works.

But I agree the docs could use some improvement.

> Since postgresql.conf and pg_hba.conf (I don't use pg_ident.conf) allow
> trailing comments, it seems reasonable that .pgpass should too, for
> consistency.
>

Reasonable but probably not worth the hassle to figure out the details.
Though I’d be tempted to formalize the existing behavior and just add an
optional field after password to hold a description. If we do ever extend
off the end to specify yet more fields we’d make all the preceding optional
fields mandatory.

>
> Escapes. It escapes ":" and "\", so should be able to escape "#".
>

Frankly it probably shouldn’t escape anything in the password field,
including colons. But since that ship has sailed, see the preceding idea.

David J.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Ron Johnson 2024-05-21 03:13:45 Re: Comments in .pgpass file...
Previous Message Ron Johnson 2024-05-21 02:10:45 Re: Comments in .pgpass file...