Re: proposal: psql: show current user in prompt

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jelte Fennema <postgres(at)jeltef(dot)nl>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Kirk Wolak <wolakk(at)gmail(dot)com>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: proposal: psql: show current user in prompt
Date: 2023-09-05 03:49:33
Message-ID: CAFj8pRBZED54YkQpuzZqtgU8_DP=TcwY1Qf_jVfwpL2+4KPaBw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

po 4. 9. 2023 v 14:24 odesílatel Jelte Fennema <postgres(at)jeltef(dot)nl> napsal:

> On Sun, 3 Sept 2023 at 20:58, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote:
> > here is an try
>
> Overall it does what I had in mind. Below a few suggestions:
>
> +int
> +PQprotocolSubversion(const PGconn *conn)
>
> Ugh, it's quite annoying that the original PQprotocolVersion only
> returns the major version and thus we need this new function. It
> seems like it would be much nicer if it returned a number similar to
> PQserverVersion. I think it might be nicer to change PQprotocolVersion
> to do that than to add another function. We could do:
>
> return PG_PROTOCOL_MAJOR(conn->pversion) * 100 +
> PG_PROTOCOL_MINOR(conn->pversion);
>
> or even:
>
> if (PG_PROTOCOL_MAJOR(conn->pversion) == 3 &&
> PG_PROTOCOL_MINOR(conn->pversion))
> return 3;
> else
> return PG_PROTOCOL_MAJOR(conn->pversion) * 100 +
> PG_PROTOCOL_MINOR(conn->pversion);
>
> The second option would be safest backwards compatibility wise, but in
> practice you would only get another value than 3 (or 0) when
> connecting to pre 7.4 servers. That seems old enough that I don't
> think anyone is actually calling this function. **I'd like some
> feedback from others on this though.**
>

This point is open. I'll wait for a reply from others.

>
> + /* The protocol 3.0 is required */
> + if (PG_PROTOCOL_MAJOR(their_version) == 3)
> + conn->pversion = their_version;
>
> Let's compare against the actual PG_PROTOCOL_EARLIEST and
> PG_PROTOCOL_LATEST to determine if the version is supported or not.
>

changed

Attachment Content-Type Size
0004-Implementation-of-N-prompt-placeholder.patch text/x-patch 5.7 KB
0003-allow-to-connect-to-server-with-major-protocol-versi.patch text/x-patch 4.1 KB
0002-PQlinkParameterStatus-PQunlinkParameterStatus-test-b.patch text/x-patch 2.9 KB
0001-Protocol-ReportGUC-message.patch text/x-patch 10.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2023-09-05 04:08:37 Re: Impact of checkpointer during pg_upgrade
Previous Message Dilip Kumar 2023-09-05 03:39:43 Re: persist logical slots to disk during shutdown checkpoint