Re: protocol version negotiation (Re: [HACKERS] Libpq PGRES_COPY_BOTH- version compatibility) - Mailing list pgsql-hackers
From | Robert Haas |
---|---|
Subject | Re: protocol version negotiation (Re: [HACKERS] Libpq PGRES_COPY_BOTH- version compatibility) |
Date | |
Msg-id | CA+TgmoaPt87thVX9QudujN5=Ezr4DGZ77JCxH3WP30eMuD40qQ@mail.gmail.com Whole thread Raw |
In response to | Re: protocol version negotiation (Re: [HACKERS] Libpq PGRES_COPY_BOTH - version compatibility) (Tom Lane <tgl@sss.pgh.pa.us>) |
Responses |
Re: protocol version negotiation (Re: [HACKERS] Libpq PGRES_COPY_BOTH- version compatibility)
|
List | pgsql-hackers |
On Wed, Jun 28, 2017 at 1:47 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > Robert Haas <robertmhaas@gmail.com> writes: >> Here's my proposal: > >> - If the server receives a StartupMessage for v3.x where x > the >> version it knows, instead of just slamming the connection shut, it >> responds by sending some new message (let's say, >> NegotiateProtocolVersion) specifying the highest protocol version it >> supports. > >> - The client may then continue by sending a new StartupMessage with a >> version with a version number that is within range. > > How about a slightly simpler design: we specify that all 3.x protocol > versions shall be mutually compatible so long as each side knows not > to send something that the other side doesn't understand. The field > in the StartupMessage is understood to be the max protocol version the > client knows how to cope with. If the client sends something > 3.0, > then the server responds with a ServerProtocolVersion message containing > the max protocol version it understands. Now both sides know what the > other side can do and should be able to adapt their behavior accordingly. > (If the client doesn't get a ServerProtocolVersion message, it should > assume server protocol 3.0.) One problem with that is that it means that the format of the StartupMessage itself can never change, which I think is not a good choice. If, for example, we want to add a new option to the startup message (aside from the existing user, database, options, and replication keywords), we really can't do that today. It wouldn't be so bad if unrecognized parameters were just ignored; the client would know from the ServerProtocolVersion (or ParameterStatus) message that server had ignored those options and could respond as it saw fit. But because they are treated as GUCs the server will error out. This is clearly not an entirely theoretical concern considering that 'replication' was added as a keyword here within recent memory. > In order to make the world safe for this, we'd have to adjust existing > releases to not complain about 3.x for x > 0, and the sooner we do that > the better chance of clients being able to make use of this within a > reasonable timeframe. > > It's possible that we should do something that's not based on just a > linear protocol version number, but instead involves some kind of > bitmask of capabilities, say. So the ServerProtocolVersion message > maybe needs to be a bit more complicated, and if the client does get > one back, maybe it should forward a ClientProtocolVersion message with > its own bitmask. But these things could be designed in detail later. Right. So for example we could decide that any parameter names that are passed in the startup packet that begin with an underscore are not GUCs but some kind of protocol extension; the server replies with some message containing a list of the ones which were not understood. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
pgsql-hackers by date: