Re: proposal: psql: show current user in prompt
| От | Jelte Fennema |
|---|---|
| Тема | Re: proposal: psql: show current user in prompt |
| Дата | |
| Msg-id | CAGECzQRsMPhf1kdzH11J_aEDQnVjRqPS6OBB2jRpjtDCgZ-6cQ@mail.gmail.com обсуждение исходный текст |
| Ответ на | Re: proposal: psql: show current user in prompt (Pavel Stehule <pavel.stehule@gmail.com>) |
| Ответы |
Re: proposal: psql: show current user in prompt
Re: proposal: psql: show current user in prompt |
| Список | pgsql-hackers |
On Sun, 3 Sept 2023 at 20:58, Pavel Stehule <pavel.stehule@gmail.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.**
+ /* 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.
В списке pgsql-hackers по дате отправления: