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-08 19:07:23
Message-ID: CAFj8pRD-ZSiYJqX_6S97A3-tJCyVbXjwysPpEfjmji5Nz=TQEw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

út 5. 9. 2023 v 13:29 odesílatel Jelte Fennema <postgres(at)jeltef(dot)nl> napsal:

> On Tue, 5 Sept 2023 at 05:50, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote:
>
> > I prefer to introduce a new function - it is ten lines of code. The form
> is not important - it can be a full number or minor number. It doesn't
> matter I think. But my opinion in this area is not strong, and I like to
> see feedback from others too. It is true that this feature and interface is
> not fully complete.
>
> I think when using the API it is nicest to have a single function that
> returns the full version number. i.e. if we're introducing a new
> function I think it should be PQprotocolFullVersion instead of
> PQprotocolSubversion. Then instead of doing a version check like this:
>
> if (PQprotocolVersion(pset.db) == 3 && PQprotocolSubversion(pset.db) >= 1)
>
> You can do the simpler:
>
> if (PQprotocolFullVersion(pset.db) >= 301)
>
> This is also in line with how you do version checks for postgres versions.
>
> So I think this patch should at least add that one instead of
> PQprotocolSubversion. If we then decide to replace PQprotocolVersion
> with this new implementation, that would be a trivial change.
>

ok changed - there is minor problem - almost all PQ functions are of int
type, but ProtocolVersion is uint

Using different mapping to int can be problematic - can be messy if we
cannot to use PG_PROTOCOL macro.

> >> + /* 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
>
> I think we should also check the minor version part. So like this instead
> + if (their_version < PG_PROTOCOL_EARLIEST || their_version >
> PG_PROTOCOL_LATEST)
>
>
done

Regards

Pavel

>
> PS. If you use the -v flag of git format-patch a version number is
> prepended to your patches. That makes it easier to reference them.
>

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2023-09-08 19:07:35 Re: proposal: psql: show current user in prompt
Previous Message Alexander Lakhin 2023-09-08 19:00:00 Re: lockup in parallel hash join on dikkop (freebsd 14.0-current)