Extensibility of the PostgreSQL wire protocol

Started by Jan Wieckalmost 5 years ago46 messages
#1Jan Wieck
jan@wi3ck.info

The following is a request for discussion and comments, not a refined
proposal accompanied by a working patch.

As recently publicly announced Amazon Web Services is working on Babelfish,
a set of extensions that will allow PostgreSQL to be compatible with other
database systems. One part of this will be an extension that allows
PostgreSQL to listen on a secondary port and process a different wire
protocol. The first extension we are creating in this direction is handling
of the Tabular Data Stream (TDS), used by Sybase and Microsoft SQL-Server
databases. It is more efficient to build an extension, that can handle the
TDS protocol inside the backend, than creating a proxy process that
translates from TDS to libpq protocol and back.

Creating the necessary infrastructure in the postmaster and backend will
open up more possibilities, that are not tied to our compatibility efforts.
Possible use cases for wire protocol extensibility include the development
of a completely new, not backwards compatible PostgreSQL protocol or
extending the existing wire protocol with things like 3rd party connection
pool specific features (like transfer of file descriptors between pool and
working backend for example).

Our current plan is to create a new set of API calls and hooks that allow
to register additional wire protocols. The existing backend libpq
implementation will be modified to register itself using the new API. This
will serve as a proof of concept as well as ensure that the API definition
is not slanted towards a specific protocol. It is also similar to the way
table access methods and compression methods are added.

A wire protocol extension will be a standard PostgreSQL dynamic loadable
extension module. The wire protocol extensions to load will be listed in
the shared_preload_libraries GUC. The extension's Init function will
register a hook function to be called where the postmaster is currently
creating the libpq server sockets. This hook callback will then create the
server sockets and register them for monitoring via select(2) in the
postmaster main loop, using a new API function. Part of the registration
information are callback functions to invoke for accepting and
authenticating incoming connections, error reporting as well as a function
that will implement the TCOP loop for the protocol. Ongoing work on the TDS
protocol has shown us that different protocols make it desirable to have
separate implementations of the TCOP loop. The TCOP function will return
only after the connection has been terminated. Fortunately half the
interface already exists since the sending of result sets is implemented
via callback functions that are registered as the dest receiver, which
works pretty well in our current code.

Regards, Jan

--
Jan Wieck
Principal Database Engineer
Amazon Web Services

#2Jonah H. Harris
jonah.harris@gmail.com
In reply to: Jan Wieck (#1)
Re: Extensibility of the PostgreSQL wire protocol

On Mon, Jan 25, 2021 at 10:07 AM Jan Wieck <jan@wi3ck.info> wrote:

The following is a request for discussion and comments, not a refined
proposal accompanied by a working patch.

After implementing this three different ways inside the backend over the
years, I landed on almost this identical approach for handling the MySQL,
TDS, MongoDB, and Oracle protocols for NEXTGRES.

Initially, each was implemented as an background worker extension which had
to handle its own networking, passing the fd off to new protocol-specific
connections, etc. This worked, but duplicate a good amount of logic. It
would be great to have a standard, loadable, way to add support for a new
protocol.

--
Jonah H. Harris

#3Jan Wieck
jan@wi3ck.info
In reply to: Jonah H. Harris (#2)
Re: Extensibility of the PostgreSQL wire protocol

Hi Jonah,

On Mon, Jan 25, 2021 at 10:18 AM Jonah H. Harris <jonah.harris@gmail.com>
wrote:

On Mon, Jan 25, 2021 at 10:07 AM Jan Wieck <jan@wi3ck.info> wrote:

The following is a request for discussion and comments, not a refined
proposal accompanied by a working patch.

After implementing this three different ways inside the backend over the
years, I landed on almost this identical approach for handling the MySQL,
TDS, MongoDB, and Oracle protocols for NEXTGRES.

Could any of that be open sourced? It would be an excellent addition to add
one of those as example code.

Regards, Jan

Initially, each was implemented as an background worker extension which
had to handle its own networking, passing the fd off to new
protocol-specific connections, etc. This worked, but duplicate a good
amount of logic. It would be great to have a standard, loadable, way to add
support for a new protocol.

--
Jonah H. Harris

--
Jan Wieck

#4Robert Haas
robertmhaas@gmail.com
In reply to: Jan Wieck (#1)
Re: Extensibility of the PostgreSQL wire protocol

On Mon, Jan 25, 2021 at 10:07 AM Jan Wieck <jan@wi3ck.info> wrote:

Our current plan is to create a new set of API calls and hooks that allow to register additional wire protocols. The existing backend libpq implementation will be modified to register itself using the new API. This will serve as a proof of concept as well as ensure that the API definition is not slanted towards a specific protocol. It is also similar to the way table access methods and compression methods are added.

If we're going to end up with an open source implementation of
something useful in contrib or whatever, then I think this is fine.
But, if not, then we're just making it easier for Amazon to do
proprietary stuff without getting any benefit for the open-source
project. In fact, in that case PostgreSQL would ensure have to somehow
ensure that the hooks don't get broken without having any code that
actually uses them, so not only would the project get no benefit, but
it would actually incur a small tax. I wouldn't say that's an
absolutely show-stopper, but it definitely isn't my first choice.

--
Robert Haas
EDB: http://www.enterprisedb.com

#5Fabrízio de Royes Mello
fabriziomello@gmail.com
In reply to: Robert Haas (#4)
Re: Extensibility of the PostgreSQL wire protocol

On Wed, Feb 10, 2021 at 1:43 PM Robert Haas <robertmhaas@gmail.com> wrote:

On Mon, Jan 25, 2021 at 10:07 AM Jan Wieck <jan@wi3ck.info> wrote:

Our current plan is to create a new set of API calls and hooks that

allow to register additional wire protocols. The existing backend libpq
implementation will be modified to register itself using the new API. This
will serve as a proof of concept as well as ensure that the API definition
is not slanted towards a specific protocol. It is also similar to the way
table access methods and compression methods are added.

If we're going to end up with an open source implementation of
something useful in contrib or whatever, then I think this is fine.
But, if not, then we're just making it easier for Amazon to do
proprietary stuff without getting any benefit for the open-source
project. In fact, in that case PostgreSQL would ensure have to somehow
ensure that the hooks don't get broken without having any code that
actually uses them, so not only would the project get no benefit, but
it would actually incur a small tax. I wouldn't say that's an
absolutely show-stopper, but it definitely isn't my first choice.

As far I understood Jan's proposal is to add enough hooks on PostgreSQL to
enable us to extend the wire protocol and add a contrib module as an
example (maybe TDS, HTTP or just adding new capabilities to current
implementation).

Regards,

--
Fabrízio de Royes Mello
PostgreSQL Developer at OnGres Inc. - https://ongres.com

#6Jonah H. Harris
jonah.harris@gmail.com
In reply to: Robert Haas (#4)
Re: Extensibility of the PostgreSQL wire protocol

On Wed, Feb 10, 2021 at 11:43 AM Robert Haas <robertmhaas@gmail.com> wrote:

On Mon, Jan 25, 2021 at 10:07 AM Jan Wieck <jan@wi3ck.info> wrote:

Our current plan is to create a new set of API calls and hooks that

allow to register additional wire protocols. The existing backend libpq
implementation will be modified to register itself using the new API. This
will serve as a proof of concept as well as ensure that the API definition
is not slanted towards a specific protocol. It is also similar to the way
table access methods and compression methods are added.

If we're going to end up with an open source implementation of
something useful in contrib or whatever, then I think this is fine.
But, if not, then we're just making it easier for Amazon to do
proprietary stuff without getting any benefit for the open-source
project. In fact, in that case PostgreSQL would ensure have to somehow
ensure that the hooks don't get broken without having any code that
actually uses them, so not only would the project get no benefit, but
it would actually incur a small tax. I wouldn't say that's an
absolutely show-stopper, but it definitely isn't my first choice.

Agreed on adding substantial hooks if they're not likely to be used. While
I haven't yet seen AWS' implementation or concrete proposal, given the
people involved, I assume it's fairly similar to how I implemented it.
Assuming that's correct and it doesn't require substantial redevelopment,
I'd certainly open-source my MySQL-compatible protocol and parser
implementation. From my perspective, it would be awesome if these could be
done as extensions.

While I'm not planning to open source it as of yet, for my
Oracle-compatible stuff, I don't think I'd be able to do anything other
than the protocol as an extension given the core-related changes similar to
what EDB has to do. I don't think there's any easy way to get around that.
But, for the protocol and any type of simple translation to Postgres'
dialect, I think that could easily be hook-based.

--
Jonah H. Harris

#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Robert Haas (#4)
Re: Extensibility of the PostgreSQL wire protocol

Robert Haas <robertmhaas@gmail.com> writes:

If we're going to end up with an open source implementation of
something useful in contrib or whatever, then I think this is fine.
But, if not, then we're just making it easier for Amazon to do
proprietary stuff without getting any benefit for the open-source
project. In fact, in that case PostgreSQL would ensure have to somehow
ensure that the hooks don't get broken without having any code that
actually uses them, so not only would the project get no benefit, but
it would actually incur a small tax. I wouldn't say that's an
absolutely show-stopper, but it definitely isn't my first choice.

As others noted, a test module could be built to add some coverage here.

What I'm actually more concerned about, in this whole line of development,
is the follow-on requests that will surely occur to kluge up Postgres
to make its behavior more like $whatever. As in "well, now that we
can serve MySQL clients protocol-wise, can't we pretty please have a
mode that makes the parser act more like MySQL". If we start having
modes for MySQL identifier quoting, Oracle outer join syntax, yadda
yadda, it's going to be way more of a maintenance nightmare than some
hook functions. So if we accept any patch along this line, I want to
drive a hard stake in the ground that the answer to that sort of thing
will be NO.

Assuming we're going to keep to that, though, it seems like people
doing this sort of thing will inevitably end up with a fork anyway.
So maybe we should just not bother with the first step either.

regards, tom lane

#8Jonah H. Harris
jonah.harris@gmail.com
In reply to: Tom Lane (#7)
Re: Extensibility of the PostgreSQL wire protocol

On Wed, Feb 10, 2021 at 1:10 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

What I'm actually more concerned about, in this whole line of development,
is the follow-on requests that will surely occur to kluge up Postgres
to make its behavior more like $whatever. As in "well, now that we
can serve MySQL clients protocol-wise, can't we pretty please have a
mode that makes the parser act more like MySQL". If we start having
modes for MySQL identifier quoting, Oracle outer join syntax, yadda
yadda, it's going to be way more of a maintenance nightmare than some
hook functions. So if we accept any patch along this line, I want to
drive a hard stake in the ground that the answer to that sort of thing
will be NO.

Actually, a substantial amount can be done with hooks. For Oracle, which is
substantially harder than MySQL, I have a completely separate parser that
generates a PG-compatible parse tree packaged up as an extension. To handle
autonomous transactions, database links, hierarchical query conversion,
hints, and some execution-related items requires core changes. But, the
protocol and parsing can definitely be done with hooks. And, as was
mentioned previously, this isn't tied directly to emulating another
database - it would enable us to support an HTTP-ish interface directly in
the server as an extension as well. A lot of this can be done with
background worker extensions now, which is how my stuff was primarily
architected, but it's hacky when it comes to areas where the items Jan
discussed could clean things up and make them more pluggable.

Assuming we're going to keep to that, though, it seems like people

doing this sort of thing will inevitably end up with a fork anyway.
So maybe we should just not bother with the first step either.

Perhaps I'm misunderstanding you, but I wouldn't throw this entire idea out
(which enables a substantial addition of extensible functionality with a
limited set of touchpoints) on the premise of future objections.

--
Jonah H. Harris

#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jonah H. Harris (#8)
Re: Extensibility of the PostgreSQL wire protocol

"Jonah H. Harris" <jonah.harris@gmail.com> writes:

On Wed, Feb 10, 2021 at 1:10 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

... If we start having
modes for MySQL identifier quoting, Oracle outer join syntax, yadda
yadda, it's going to be way more of a maintenance nightmare than some
hook functions. So if we accept any patch along this line, I want to
drive a hard stake in the ground that the answer to that sort of thing
will be NO.

Actually, a substantial amount can be done with hooks. For Oracle, which is
substantially harder than MySQL, I have a completely separate parser that
generates a PG-compatible parse tree packaged up as an extension. To handle
autonomous transactions, database links, hierarchical query conversion,
hints, and some execution-related items requires core changes.

That is a spot-on definition of where I do NOT want to end up. Hooks
everywhere and enormous extensions that break anytime we change anything
in the core. It's not really clear that anybody is going to find that
more maintainable than a straight fork, except to the extent that it
enables the erstwhile forkers to shove some of their work onto the PG
community.

My feeling about this is if you want to use Oracle, go use Oracle.
Don't ask PG to take on a ton of maintenance issues so you can have
a frankenOracle.

regards, tom lane

#10Jonah H. Harris
jonah.harris@gmail.com
In reply to: Tom Lane (#9)
Re: Extensibility of the PostgreSQL wire protocol

On Wed, Feb 10, 2021 at 2:04 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

That is a spot-on definition of where I do NOT want to end up. Hooks
everywhere and enormous extensions that break anytime we change anything
in the core. It's not really clear that anybody is going to find that
more maintainable than a straight fork, except to the extent that it
enables the erstwhile forkers to shove some of their work onto the PG
community.

Given the work over the last few major releases to make several other
aspects of Postgres pluggable, how is implementing a pluggable protocol API
any different?

To me, this sounds more like a philosophical disagreement with how people
could potentially use Postgres than a technical one. My point is only that,
using current PG functionality, I could equally write a pluggable storage
interface for my Oracle and InnoDB data file readers/writers, which would
similarly allow for the creation of a Postgres franken-Oracle by extension
only.

I don't think anyone is asking for hooks for all the things I mentioned - a
pluggable transaction manager, for example, doesn't make much sense. But,
when it comes to having actually done this vs. posited about its
usefulness, I'd say it has some merit and doesn't really introduce that
much complexity or maintenance overhead to core - whether the extensions
still work properly is up to the extension authors... isn't that the whole
point of extensions?

--
Jonah H. Harris

#11Jan Wieck
jan@wi3ck.info
In reply to: Robert Haas (#4)
Re: Extensibility of the PostgreSQL wire protocol

On Wed, Feb 10, 2021 at 11:43 AM Robert Haas <robertmhaas@gmail.com> wrote:

On Mon, Jan 25, 2021 at 10:07 AM Jan Wieck <jan@wi3ck.info> wrote:

Our current plan is to create a new set of API calls and hooks that

allow to register additional wire protocols. The existing backend libpq
implementation will be modified to register itself using the new API. This
will serve as a proof of concept as well as ensure that the API definition
is not slanted towards a specific protocol. It is also similar to the way
table access methods and compression methods are added.

If we're going to end up with an open source implementation of
something useful in contrib or whatever, then I think this is fine.
But, if not, then we're just making it easier for Amazon to do
proprietary stuff without getting any benefit for the open-source
project. In fact, in that case PostgreSQL would ensure have to somehow
ensure that the hooks don't get broken without having any code that
actually uses them, so not only would the project get no benefit, but
it would actually incur a small tax. I wouldn't say that's an
absolutely show-stopper, but it definitely isn't my first choice.

At this very moment there are several parts to this. One is the hooks to
make wire protocols into loadable modules, which is what this effort is
about. Another is the TDS protocol as it is being implemented for Babelfish
and third is the Babelfish extension itself. Both will require additional
hooks and APIs I am not going to address here. I consider them not material
to my effort.

As for making the wire protocol itself expandable I really see a lot of
potential outside of what Amazon wants here. And I would not be advertising
it if it would be for Babelfish alone. As I laid out, just the ability for
a third party to add additional messages for special connection pool
support would be enough to make it useful. There also have been discussions
in the JDBC subproject to combine certain messages into one single message.
Why not allow the JDBC project to develop their own, JDBC-optimized backend
side? Last but not least, what would be wrong with listening for MariaDB
clients?

I am planning on a follow up project to this, demoting libpq itself to just
another loadable protocol. Just the way procedural languages are all on the
same level because that is how I developed the loadable, procedural
language handler all those years ago.

Considering how spread out and quite frankly unorganized our wire protocol
handling is, this is not a small order.

Regards, Jan

--
Robert Haas
EDB: http://www.enterprisedb.com

--
Jan Wieck

#12Robert Haas
robertmhaas@gmail.com
In reply to: Tom Lane (#9)
Re: Extensibility of the PostgreSQL wire protocol

On Wed, Feb 10, 2021 at 2:04 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

That is a spot-on definition of where I do NOT want to end up. Hooks
everywhere and enormous extensions that break anytime we change anything
in the core. It's not really clear that anybody is going to find that
more maintainable than a straight fork, except to the extent that it
enables the erstwhile forkers to shove some of their work onto the PG
community.

+1.

Making the lexer and parser extensible seems desirable to me. It would
be beneficial not only for companies like EDB and Amazon that might
want to extend the grammar in various ways, but also for extension
authors. However, it's vastly harder than Jan's proposal to make the
wire protocol pluggable. The wire protocol is pretty well-isolated
from the rest of the system. As long as you can get queries out of the
packets the client sends and package up the results to send back, it's
all good. The parser, on the other hand, is not at all well-isolated
from the rest of the system. There's a LOT of code that knows a whole
lot of stuff about the structure of parse trees, so your variant
parser can't produce parse trees for new kinds of DDL, or for new
query constructs. And if it parsed some completely different syntax
where, say, joins were not explicit, it would still have to figure out
how to represent them in a way that looked just like it came out of
the regular parser -- otherwise, parse analysis and query planning and
so forth are not going to work, unless you go and change a lot of
other code too, and I don't really have any idea how we could solve
that, even in theory. But that kind of thing just isn't a problem for
the proposal on this thread.

That being said, I'm not in favor of transferring maintenance work to
the community for this set of hooks any more than I am for something
on the parsing side. In general, I'm in favor of as much extensibility
as we can reasonably create, but with a complicated proposal like this
one, the community should expect to be able to get something out of
it. And so far what I hear Jan saying is that these hooks could in
theory be used for things other than Amazon's proprietary efforts and
those things could in theory bring benefits to the community, but
there are no actual plans to do anything with this that would benefit
anyone other than Amazon. Which seems to bring us right back to
expecting the community to maintain things for the benefit of
third-party forks.

--
Robert Haas
EDB: http://www.enterprisedb.com

#13Jonah H. Harris
jonah.harris@gmail.com
In reply to: Robert Haas (#12)
Re: Extensibility of the PostgreSQL wire protocol

On Thu, Feb 11, 2021 at 9:28 AM Robert Haas <robertmhaas@gmail.com> wrote:

That being said, I'm not in favor of transferring maintenance work to
the community for this set of hooks any more than I am for something
on the parsing side. In general, I'm in favor of as much extensibility
as we can reasonably create, but with a complicated proposal like this
one, the community should expect to be able to get something out of
it. And so far what I hear Jan saying is that these hooks could in
theory be used for things other than Amazon's proprietary efforts and
those things could in theory bring benefits to the community, but
there are no actual plans to do anything with this that would benefit
anyone other than Amazon. Which seems to bring us right back to
expecting the community to maintain things for the benefit of
third-party forks.

I'm quite sure I said I'd open source my MySQL implementation, which allows
Postgres to appear to MySQL clients as a MySQL/MariaDB server. This is
neither proprietary nor Amazon-related and makes Postgres substantially
more useful for a large number of applications.

As Jan said in his last email, they're not proposing all the different
aspects needed. In fact, nothing has actually been proposed yet. This is an
entirely philosophical debate. I don't even know what's being proposed at
this point - I just know it *could* be useful. Let's just wait and see what
is actually proposed before shooting it down, yes?

--
Jonah H. Harris

#14Robert Haas
robertmhaas@gmail.com
In reply to: Jonah H. Harris (#13)
Re: Extensibility of the PostgreSQL wire protocol

On Thu, Feb 11, 2021 at 9:42 AM Jonah H. Harris <jonah.harris@gmail.com> wrote:

I'm quite sure I said I'd open source my MySQL implementation, which allows Postgres to appear to MySQL clients as a MySQL/MariaDB server. This is neither proprietary nor Amazon-related and makes Postgres substantially more useful for a large number of applications.

OK. There's stuff to think about there, too: do we want that in
contrib? Is it in good enough shape to be in contrib even if we did?
If it's not in contrib, how do we incorporate it into, say, the
buildfarm, so that we know if we break something? Is it actively
maintained and stable, so that if it needs adjustment for upstream
changes we can count on that getting addressed in a timely fashion? I
don't know the answers to these questions and am not trying to
prejudge, but I think they are important and relevant questions.

As Jan said in his last email, they're not proposing all the different aspects needed. In fact, nothing has actually been proposed yet. This is an entirely philosophical debate. I don't even know what's being proposed at this point - I just know it *could* be useful. Let's just wait and see what is actually proposed before shooting it down, yes?

I don't think I'm trying to shoot anything down, because as I said, I
like extensibility and am generally in favor of it. Rather, I'm
expressing a concern which seems to me to be justified, based on what
was posted. I'm sorry that my tone seems to have aggravated you, but
it wasn't intended to do so.

--
Robert Haas
EDB: http://www.enterprisedb.com

#15Tom Lane
tgl@sss.pgh.pa.us
In reply to: Robert Haas (#14)
Re: Extensibility of the PostgreSQL wire protocol

Robert Haas <robertmhaas@gmail.com> writes:

On Thu, Feb 11, 2021 at 9:42 AM Jonah H. Harris <jonah.harris@gmail.com> wrote:

As Jan said in his last email, they're not proposing all the different
aspects needed. In fact, nothing has actually been proposed yet. This
is an entirely philosophical debate. I don't even know what's being
proposed at this point - I just know it *could* be useful. Let's just
wait and see what is actually proposed before shooting it down, yes?

I don't think I'm trying to shoot anything down, because as I said, I
like extensibility and am generally in favor of it. Rather, I'm
expressing a concern which seems to me to be justified, based on what
was posted. I'm sorry that my tone seems to have aggravated you, but
it wasn't intended to do so.

Likewise, the point I was trying to make is that a "pluggable wire
protocol" is only a tiny part of what would be needed to have a credible
MySQL, Oracle, or whatever clone. There are large semantic differences
from those products; there are maintenance issues arising from the fact
that we whack structures like parse trees around all the time; and so on.
Maybe there is some useful thing that can be accomplished here, but we
need to consider the bigger picture rather than believing (without proof)
that a few hook variables will be enough to do anything.

regards, tom lane

#16Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#15)
Re: Extensibility of the PostgreSQL wire protocol

On 2/11/21 10:06 AM, Tom Lane wrote:

Robert Haas <robertmhaas@gmail.com> writes:

On Thu, Feb 11, 2021 at 9:42 AM Jonah H. Harris <jonah.harris@gmail.com> wrote:

As Jan said in his last email, they're not proposing all the different
aspects needed. In fact, nothing has actually been proposed yet. This
is an entirely philosophical debate. I don't even know what's being
proposed at this point - I just know it *could* be useful. Let's just
wait and see what is actually proposed before shooting it down, yes?

I don't think I'm trying to shoot anything down, because as I said, I
like extensibility and am generally in favor of it. Rather, I'm
expressing a concern which seems to me to be justified, based on what
was posted. I'm sorry that my tone seems to have aggravated you, but
it wasn't intended to do so.

Likewise, the point I was trying to make is that a "pluggable wire
protocol" is only a tiny part of what would be needed to have a credible
MySQL, Oracle, or whatever clone. There are large semantic differences
from those products; there are maintenance issues arising from the fact
that we whack structures like parse trees around all the time; and so on.
Maybe there is some useful thing that can be accomplished here, but we
need to consider the bigger picture rather than believing (without proof)
that a few hook variables will be enough to do anything.

Yeah. I think we'd need a fairly fully worked implementation to see
where it goes. Is Amazon going to release (under TPL) its TDS
implementation of this? That might go a long way to convincing me this
is worth considering.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#17Jim Mlodgenski
jimmy76@gmail.com
In reply to: Andrew Dunstan (#16)
Re: Extensibility of the PostgreSQL wire protocol

On Thu, Feb 11, 2021 at 10:29 AM Andrew Dunstan <andrew@dunslane.net> wrote:

On 2/11/21 10:06 AM, Tom Lane wrote:

Robert Haas <robertmhaas@gmail.com> writes:

On Thu, Feb 11, 2021 at 9:42 AM Jonah H. Harris <jonah.harris@gmail.com>

wrote:

As Jan said in his last email, they're not proposing all the different
aspects needed. In fact, nothing has actually been proposed yet. This
is an entirely philosophical debate. I don't even know what's being
proposed at this point - I just know it *could* be useful. Let's just
wait and see what is actually proposed before shooting it down, yes?

I don't think I'm trying to shoot anything down, because as I said, I
like extensibility and am generally in favor of it. Rather, I'm
expressing a concern which seems to me to be justified, based on what
was posted. I'm sorry that my tone seems to have aggravated you, but
it wasn't intended to do so.

Likewise, the point I was trying to make is that a "pluggable wire
protocol" is only a tiny part of what would be needed to have a credible
MySQL, Oracle, or whatever clone. There are large semantic differences
from those products; there are maintenance issues arising from the fact
that we whack structures like parse trees around all the time; and so on.
Maybe there is some useful thing that can be accomplished here, but we
need to consider the bigger picture rather than believing (without proof)
that a few hook variables will be enough to do anything.

Yeah. I think we'd need a fairly fully worked implementation to see
where it goes. Is Amazon going to release (under TPL) its TDS
implementation of this? That might go a long way to convincing me this
is worth considering.

Everything is planned to be released under the Apache 2.0 license so

people are free to do with it as they choose.

#18Joshua Drake
jd@commandprompt.com
In reply to: Tom Lane (#9)
Re: Extensibility of the PostgreSQL wire protocol

On Wed, Feb 10, 2021 at 11:04 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:

"Jonah H. Harris" <jonah.harris@gmail.com> writes:

On Wed, Feb 10, 2021 at 1:10 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

... If we start having
modes for MySQL identifier quoting, Oracle outer join syntax, yadda
yadda, it's going to be way more of a maintenance nightmare than some
hook functions. So if we accept any patch along this line, I want to
drive a hard stake in the ground that the answer to that sort of thing
will be NO.

Actually, a substantial amount can be done with hooks. For Oracle, which

is

substantially harder than MySQL, I have a completely separate parser that
generates a PG-compatible parse tree packaged up as an extension. To

handle

autonomous transactions, database links, hierarchical query conversion,
hints, and some execution-related items requires core changes.

That is a spot-on definition of where I do NOT want to end up. Hooks
everywhere and enormous extensions that break anytime we change anything
in the core. It's not really clear that anybody is going to find that
more maintainable than a straight fork, except to the extent that it
enables the erstwhile forkers to shove some of their work onto the PG
community.

My feeling about this is if you want to use Oracle, go use Oracle.
Don't ask PG to take on a ton of maintenance issues so you can have
a frankenOracle.

PostgreSQL over the last decade spent a considerable amount of time
allowing it to become extensible outside of core. We are now useful in
workloads nobody would have considered in 2004 or 2008.

The more extensibility we add, the LESS we maintain. It is a lot easier to
maintain an API than it is an entire kernel. When I look at all the
interesting features coming from the ecosystem, they are all built on the
hooks that this community worked so hard to create. This idea is an
extension of that and a result of the community's success.

The more extensible we make PostgreSQL, the more the hacker community can
innovate without damaging the PostgreSQL reputation as a rock solid
database system.

Features like these only enable the entire community to innovate. Is the
real issue that the more extensible PostgreSQL is, the more boring it will
become?

JD

Show quoted text

regards, tom lane

#19Fabrízio de Royes Mello
fabriziomello@gmail.com
In reply to: Tom Lane (#15)
Re: Extensibility of the PostgreSQL wire protocol

On Thu, Feb 11, 2021 at 12:07 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Robert Haas <robertmhaas@gmail.com> writes:

On Thu, Feb 11, 2021 at 9:42 AM Jonah H. Harris <jonah.harris@gmail.com>

wrote:

As Jan said in his last email, they're not proposing all the different
aspects needed. In fact, nothing has actually been proposed yet. This
is an entirely philosophical debate. I don't even know what's being
proposed at this point - I just know it *could* be useful. Let's just
wait and see what is actually proposed before shooting it down, yes?

I don't think I'm trying to shoot anything down, because as I said, I
like extensibility and am generally in favor of it. Rather, I'm
expressing a concern which seems to me to be justified, based on what
was posted. I'm sorry that my tone seems to have aggravated you, but
it wasn't intended to do so.

Likewise, the point I was trying to make is that a "pluggable wire
protocol" is only a tiny part of what would be needed to have a credible
MySQL, Oracle, or whatever clone. There are large semantic differences
from those products; there are maintenance issues arising from the fact
that we whack structures like parse trees around all the time; and so on.
Maybe there is some useful thing that can be accomplished here, but we
need to consider the bigger picture rather than believing (without proof)
that a few hook variables will be enough to do anything.

Just to don't miss the point, creating a compat protocol to mimic others
(TDS,
MySQL, etc) is just one use case.

There are other use cases to make wire protocol extensible, for example for
telemetry I can use some hooks to propagate context [1]https://www.w3.org/TR/trace-context/ and get more
detailed
tracing information about the negotiation between frontend and backend and
being able to implement a truly query tracing tool, for example.

Another use case is extending the current protocol to, for example, send
more
information about query execution on CommandComplete command instead of
just the number of affected rows.

About the HTTP protocol I think PG should have it, maybe pure HTTP (no
REST,
just HTTP) because it's the most interoperable. Performance can still be
very good
with HTTP2, and you have a huge ecosystem of tools and proxies (like Envoy)
that
would do wonders with this. You could safely query a db from a web page
(passing
through proxies that would do auth, TLS, etc). Or maybe a higher performing
gRPC
version (which is also HTTP2 and is amazing), but this makes it a bit more
difficult
to query from a web page. In either case, context propagation is already
built-in, and
in a standard way.

Regards,

[1]: https://www.w3.org/TR/trace-context/

--
Fabrízio de Royes Mello
PostgreSQL Developer at OnGres Inc. - https://ongres.com

#20Dave Cramer
davecramer@postgres.rocks
In reply to: Robert Haas (#12)
Re: Extensibility of the PostgreSQL wire protocol

On Thu, 11 Feb 2021 at 09:28, Robert Haas <robertmhaas@gmail.com> wrote:

On Wed, Feb 10, 2021 at 2:04 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

That is a spot-on definition of where I do NOT want to end up. Hooks
everywhere and enormous extensions that break anytime we change anything
in the core. It's not really clear that anybody is going to find that
more maintainable than a straight fork, except to the extent that it
enables the erstwhile forkers to shove some of their work onto the PG
community.

+1.

Making the lexer and parser extensible seems desirable to me. It would
be beneficial not only for companies like EDB and Amazon that might
want to extend the grammar in various ways, but also for extension
authors. However, it's vastly harder than Jan's proposal to make the
wire protocol pluggable. The wire protocol is pretty well-isolated
from the rest of the system. As long as you can get queries out of the
packets the client sends and package up the results to send back, it's
all good.

I would have to disagree that the wire protocol is well-isolated. Sending
and receiving are not in a single file
The codes are not even named constants so trying to find a specific one is
difficult.

Anything that would clean this up would be a benefit

That being said, I'm not in favor of transferring maintenance work to

the community for this set of hooks any more than I am for something
on the parsing side. In general, I'm in favor of as much extensibility
as we can reasonably create, but with a complicated proposal like this
one, the community should expect to be able to get something out of
it. And so far what I hear Jan saying is that these hooks could in
theory be used for things other than Amazon's proprietary efforts and
those things could in theory bring benefits to the community, but
there are no actual plans to do anything with this that would benefit
anyone other than Amazon. Which seems to bring us right back to
expecting the community to maintain things for the benefit of
third-party forks.

if this proposal brought us the ability stream results that would be a huge
plus!

Dave Cramer
www.postgres.rocks

Show quoted text
#21Jan Wieck
jan@wi3ck.info
In reply to: Dave Cramer (#20)
2 attachment(s)
Re: Extensibility of the PostgreSQL wire protocol

Attached are a first patch and a functioning extension that implements a
telnet protocol server.

The extension needs to be loaded via shared_preload_libraries and
configured for a port number and listen_addresses as follows:

shared_preload_libraries = 'telnet_srv'

telnet_srv.listen_addresses = '*'
telnet_srv.port = 54323

It is incomplete in that it doesn't address things like the COPY protocol.
But it is enough to give a more detailed idea of what this interface will
look like and what someone would do to implement their own protocol or
extend an existing one.

The overall idea here is to route all functions, that communicate with the
frontend, through function pointers that hang off of MyProcPort. Since we
are performing socket communication in them I believe one extra function
pointer indirection is unlikely to have significant performance impact.

Best Regards, Jan
On behalf of Amazon Web Services

On Sun, Feb 14, 2021 at 12:36 PM Dave Cramer <davecramer@postgres.rocks>
wrote:

On Thu, 11 Feb 2021 at 09:28, Robert Haas <robertmhaas@gmail.com> wrote:

On Wed, Feb 10, 2021 at 2:04 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

That is a spot-on definition of where I do NOT want to end up. Hooks
everywhere and enormous extensions that break anytime we change anything
in the core. It's not really clear that anybody is going to find that
more maintainable than a straight fork, except to the extent that it
enables the erstwhile forkers to shove some of their work onto the PG
community.

+1.

Making the lexer and parser extensible seems desirable to me. It would
be beneficial not only for companies like EDB and Amazon that might
want to extend the grammar in various ways, but also for extension
authors. However, it's vastly harder than Jan's proposal to make the
wire protocol pluggable. The wire protocol is pretty well-isolated
from the rest of the system. As long as you can get queries out of the
packets the client sends and package up the results to send back, it's
all good.

I would have to disagree that the wire protocol is well-isolated. Sending
and receiving are not in a single file
The codes are not even named constants so trying to find a specific one is
difficult.

Anything that would clean this up would be a benefit

That being said, I'm not in favor of transferring maintenance work to

the community for this set of hooks any more than I am for something
on the parsing side. In general, I'm in favor of as much extensibility
as we can reasonably create, but with a complicated proposal like this
one, the community should expect to be able to get something out of
it. And so far what I hear Jan saying is that these hooks could in
theory be used for things other than Amazon's proprietary efforts and
those things could in theory bring benefits to the community, but
there are no actual plans to do anything with this that would benefit
anyone other than Amazon. Which seems to bring us right back to
expecting the community to maintain things for the benefit of
third-party forks.

if this proposal brought us the ability stream results that would be a
huge plus!

Dave Cramer
www.postgres.rocks

--
Jan Wieck

Attachments:

wire_proto_2021-02-18_1.diff.gzapplication/gzip; name=wire_proto_2021-02-18_1.diff.gzDownload
telnet_srv_2021-02-18_1.tgzapplication/x-compressed-tar; name=telnet_srv_2021-02-18_1.tgzDownload
���.`�\{s�F������0�M�)��|e�v)��-��Hmr�P 0$��$�6���������:Im]X�D�����=�P,�@���n{�~��.>/^�������������g��0no��p��8��0*|���~����n������~�������Y� >���g��{���=;���^<���
�����m�|�OSl��(����{���g�~h��Ow^$�*
��	}!?�2P^�Dy����|�W��7_���t�������
U<�����8�����y+�p��A,��0Y��'����t�?�//�N��7�mP=�s�����?q�h�4���h5��ofN����B�<Z���S�[n�Q��&���J���A�cj- ���c�K/ l
8���b��8R����t8�ri����>p������j�SD�]��t�8�zj��{~����}���A��������*D���b��?������C�[���*l��KP�B��	W=�A�]I���7O��f������Y����\�������<�v�*�b��������,����S�j9���bo)����v���f��:��/OnF���l�?j6{[�H3o�DvL�$\�/��G�x�����hOGi���#���"X��F�v����B����������+��d#��8�9Y-���~!a!��7 �AlR�FO��%���}?t��B���v<�1[4�Z��B�W�b8��,��$p�Z�t|[SN	���m����z{����sTh��9mMW������a��U����;S2���5s��G�����J�:~�d��5�����C���
�b����K�f�Ta�v�����!sg��*������:b5���|LK+#'Q�.C��\k	�
�DQ���-���_����H���5#�}"��v_��	v���F
�`+����Y��o���"�F:�P��u�<9��{l��l�*�n:$��.��X��{���a���(��U{�`�	�c?$���mA+\KGz`��*�0�9�9P����Y!4�%=E���U1���J���C�I��wA����(���D
_34W�w�	�*����R�Lr/0�n�3��	x..'����a�F��w��MFzh�h��%"���mq���E� ��lot`FS�`��%��"�:�{M��+gd����������v2�`�����5.��42��x
���9�����Ye*�b��)H�W���TOWsD��Q/�E�=��!L���q�Or�y�����FCo�H�T?�V��R�����6�Uf��
��q������������$(�*��������Y�|���w��d1K��*��H1zW�������I���d�<�pD��@M��T�����,��;����:F]53El��h�`��R�&�YX�@��4�@1�a���*y���^�>�I��fOAX!��� X��dc<Mff��h����� �!&���+J) ���r����B/��;�i�
�&�D����wje;R���:� �����J��/����\����[$�U$o�^9w�W&~�����79��+I�|�v3s��+sP-�T��:O3����rq3mg��,~�Yf�?p�/��{&���A]�n)x1������:�j�1��fc���fq'��\2-��$Y����x��Vl���B,�A\%#4,���:�r
���M|�y3[�������`�������v"aR$B�"�x�'A*�g7�\x�4�Gv���y�0��a���BVL�2���p�	�uv�^�l����YC�yow�y�pxp��0{�:�[W�����x2���w�WZ{ �Z�������H�T�n�T����ll�4���W����n�0zv�V��)����<D�����|������I�7dqU�H�����b����x��F�K�������U<x��	O�#E���!�
��uf���=��n!G�	����Q���aO�L{�`k�NG%���U��}�n!�#�p��>i�K��|h�N��q����:Dp�e�r2��r���:������-y	WMQ��{t���#��V�p�����P�i��1����L�_D�`I�A4�B��������<�u��xda���g����pC��>�P����	�A���(n�����^�l�VG���	�YXH�*��!(�g�) �]S�f!�%�J=� $� ,�(x�9�]P��C�����KD���lP?�Q����t��g!����X�.L|�
6��l'N���3>z�����A��~7B�uz7|��oK5?����B|�{2:�hxd0H�����fz�h��`;����������C�}g���Fo����{	��>�������A�{�.%��u^��0��g~�m�0��/P�H��� ����:,#���eB�FRaF� ����y��@���1D�YL��$\�:
��y]�WXJ`�&���r�����,�#����h�}N"oI�*t���D��M14y
�SX�cHY�.� �mO����cd�n��L��O�N�Q��wv�������O�j�����e���K�]���0#}��=k}E�1}<9�����������MG�dr�6<ke+U�
~8wel{>�#:���%~�n��[c`����W��0Z��d���
�2�8E�
��Z��}�U��� �F*tgR����`�:�m��:g���3��(:�����+"S�'>s��v��s�f��z�{�WL�����(����J��x����5�`2r@F�����KFK���0}[��?7�k��lHn���������x���,=�%c���m�k��%f�.��f*�����jIYj����H�Q8/DP)9*�e@��=U	�]�R�^�`��;���n�k�� =�	a�=��Z�:�M��^?Z��7j�JG�-�Is^{ty�-da��R���Ad�V�����d,63���2i��s�u��
�qT@�9��w>"�1���8=.St��������H�5O�0~�*�����T���N������t�U8q��3+�pC��'1�y��;�9VbW�l`���ra�zt�=K+;�90iw��"��>�����y��4l-�������@=L"�Uu�,`N�pi=��y�b%Z�w��}���������B�\�y����u��)�9D�A���>���t�
'�oo��^���������������FB���"���W����,|���������U@�������2����^\N��Ae�n�������"G�<[��pp1�C���6��������������V7���b������_k��1����-_�\�K�������c[�e`������G�g	�/_�,4���w�$��,����5����z�����z�]Xkrv�z-��}����&�0����L�|w&�|�j�6�A`��E���{�o���|������ts5��P�������#��28���(l����0��	E������~�u)��*�U�9cbe���������ZF�����J:��=��y~5P��59>���9�{�05+`P#�).��h_����n�GDn�A^�{�%���9r���o�XR���!;.r�D������7@d��.����N�}u��!�dH�u"F��/=�M�W�H�[�	Ud�����������a��s�>�.�L2�(,��i
������1�_�mh��;[���������t�|'L����y���b@<�������*�l��
"=��Cw�;;��L*�L�I��e�s��6�t��
f&ZhM�;dw� �<����K��
�Jq�.�0��V��x��%��'�;�����7i/bT$Y-qu>|n�^^�OD�M�xYU?����i�N9'��4��'��6^���,pf�+�LJYj5�z�kaPV�9M��������eT�Y�8��Z��6:��L�2��Fi�\ld���*^�/���D����m�N�E;����S����f���#i��v�p�
�T?�-���th$K*�P���;�T��Pbb ���� ;�MWv�aN8(����Z�E�����-�NHc��h��+M�iL�'�A_���D]��t��C����Wb7w�%�����J}PAu��9�-�������Z`)]o�1�����79J�{��8����d�*2���TxG�c*���moL����I��Fi�)��bm�.zy��-�.��V�������b'�����d��
Ae�PQ��W>.���6vg�X��l9��x�)M��RT�(�h~j����������:t��@"VV�vSqSa�:%$��;��$���%C��&U�t-��:8�\���\Zoy��*�V\Q��kglS�����b}��'~�ETU��kD�%��O.Rz����~'�JLH�D|w���9GjT�f�$zS��c��������� ��J������g��k*}}���i��f!����p��5n�)VcR+2�\��[3k��)�>��Kpb����0
�K��]��43�=�Z�����9���eK�J��u�q9dO� ����${������ �k4N`:�k���Wl�0$C��%��}H@{M�����d��I&)���9r-!n���T��u�C7�t=Q�\ms�����qe�^�jL�����n�����k�7������.��H-4�j-tMl�F��lX��F���a�2-��DA�\��� =��
}��o�i����e�)Q��^�H�N��S�H�"��N*E���7�NJR�N9i��j��05��:5#T�"�"-DNj`�W34�tw6�Iq|D/��r��e���P�L�q#-;�����B�|k*��M$��D�����'��`�;�>�F�L������n��h��(B<[����>�T
Z������?L������hbQ
0.���B^�~49�\z1������_:���kfJ�Q��8��X_5�U�Y�j#��F��Rr�|����1B�(bG�_L�V#[��|s���B���lQ5�1_�����}sD���:j}$�G
�::6��#��������.��B��#3/��>f�e��6k�>d�V`�K���%���	�H�y
��)zp��|�! �
W�L�e&`U�#��&<iQ���� ������;:����	R�;#D�5�����X�sQ2���Y ��\`�1P��B�m?^�����LmzGV{[�Y�O�u�^��U��F��O��{��(Y��I��������*0���l}����R��	^�Qb�p�H_�r�O�`�56E������5���	����w���;;{���z��5~�w��.���{�������v�w��������meo����$�I���:��k���'rt^
����6&��_�Xa�v�`���E�zp<������^�+�E(n`u[����h���BY6����x�>����)���)�?��D����G����\�w���|��/��#>_��!�T�M������G4/���1Z�6_��^<��FhO��w�f3W������q�%�.�����hp2���;A��������~�RW�4�����������W��6vB�������h����i6�g�yl]^Mh';;�������j�!b��q������
��Zy�_�O��"�h��pd)�'�;����]:4#g����'�����4~+��O�^�3/8�r]���q���-�h��w�{�;����'R�3/.��h�����A���y���f����x`]��0�?����8��-�����.��h���W�l\\�?�N3}��:w�|Y��)H	`��l�O=���u�(��N<���;�?�R[�����w���H"��_~�?�e������}t$Yy^����8cj���=��F��"1�h5=�:h$��f��)u�����vu�F������c`��`�N�c��L l�8���1q��8vL��?n���jI;�yt��V�Uuo�������{����������459�zD�~cY�F
bd�[�����\���o��?y�H�������c���n��H�:@.���(�/�k������BB�9P�c��>�����`��=n�/4�T\�� !���C�#qY�?AAp���{�?z������81951��������G�����zz[[����+�8Y�����^������M���@����3A��~-�|�r�:�Y���m�n�u��Spl��-��VE[w��E�o6<�^D-Q��n}�k�/����}��S~��~�2���uU�/��9�=9�����w��+����)���^P\-�q/
��i~����>y[�Ok�#-Z�!����M-��C�I�aN���2�A��i�j%p����um�v��_�	m���qF	�,��r��.�9��{,	c m�I���P��(1�]���)��9G�:d��kdF�����IK��(�E>7�@z�7���l�����`����Qo�i��n2�&�e�M���u�2L��HH�H)�K���9�6G����)8#���3l2��_��j��q/���&��J�b{l���,�*9�Ha�������by~�������������jq���kEs�M���|1������x�@R�:��@�����&/g���,���V�Vp�l�\�u\����hQ�z����o�f�G��*�VN_.8C���b�#f����#e��UZ.��\2�8���w�dB�^Z����*i���$�L}�R���(q�O��t��n�lP�#��v����W6�5n�LU������IJ3���RS��,z�*9��H��i�-`�*����0�H�+����N���$��MY�t��^9`�V��'z�X�4}�[ e���J�dXR���?k�d5y��}���vOV������lz:��guny|~��H; �P�=��{E�G��%�X�mJ��@�[D*�}!�x^��2%X�����$2�e8�����m|���
}$G��[��x�@X�Y
��%������=�:u:�������*�����q��z�C����36c�a��zf�������($2n�MQ;n-kC��0����*��F�M][9_���92Q�II"?�����knPD5����r�����|��?H?m5��@6;�����3	��`�R\][Y,MGc�����1P�6�u%r���h��6U/q�"I*'?��mW/H�-E�-B�W~<��*"f7��":i���{��C���Et0Q�P,��L^H����X$�ugw����d�b���8_>;{�]K���3Q���
��b���5[�pT��p���t3��-d.��4P���������{I\>�<�z�#�R�A!���_�������sS�sSt�6o@�a'��0
�D�o��Cly���U���p�����0=*8��D��q��1��e�Nhc����M*��yP�������	paV�����R�=�k�a�v��y*�����n4^�JM
��c���Xb���33-�k�=N,UH.������������
&V2��N,f:��P\E>�!1�!�h�ID!�eXy(h�h��C'�����u�VLd<��f�DV�mc�N.-q���	<����L�Ye��V{�^�,��	���n��������r�K8<<�&����s��C���	���������:F��j>��K�r�f��������7��{4�H<���8R��,��`i.aL�!F(tT=j.)���.���VZ�X�6��0������y*"Sd�^6Y��W@l+8a��iyW��1�O��3�G���FO"���>��:8_
��|���Zw����Z���s�Yj��(f��;���6�gC��!_����������-�j��z\t�
�Ma}����>��sj�O8y�50��u������+��L@�!�rN������Ip���0K��l��g�j��4#:s�}�fxlA�7����.���e���������_974�|���.�4-��D�l2���1M%c
'�>3]1�O�����x�q��hx��J�������-e7���,}�����r��Mq�+�TGm�X�+w������T�.h:����� ��&�g�g�hd��V�jT��Z�,����d�4�?l���H�gv
�����	z���������I�R	V&5���;�Ar���&��`f�T�G���R
���iDU�B���������.�n�u����@�*v��Z�H�����5�����$����Qs�!��e���0�V��f���K�������,-�W�k�")]|J�y'�3����3��P�M�1���������v��>�(���5&p�a�xC��8�v
��c���g
g�o����6��(��n��D���t<���X����5�)s�#�4�S�r^�������q��mkY�1u�]�|����#Z������_�=i�d�|���:CN���[����HD������}rz�;s�A���5[������7��
�FC;��X�����t��	K������IW����de��B^	��C!������*���:�lT�M���z�J�D���Z��:����D%�//�,�.��]���\��RO��U����j)
�N�\u�(I���&��Ri}��_$
]�{����i	>9vtlrb=�HA�O9��&�4JX�5��8�b�mID~�����6�35��1����
\��r����Y��N��f�@`�\�UnO���g>��y��"MS6�H�^fw��������:�R��j?���(
c�:��2�Hs��8�]��%J-� =��\!+�fR3����6D-~k���^��B��|O�����
���v�����	? �>SL,������I�3�
)��W�z�7����LQ���L���B���K>��=����w�6����.%����{�����D�=�aAU����_�����[o�,�����	�����0t%Rs����]�"�	�E���j*G�\!���;w��Q@���J�^�S���pf��w���X��8���#�;m��xx�w�#��8�oW3X<B�}7�S�UGy��:&�*��/{��G	S�R�E����2-��g��-��.�������/8	�����lZ >m�()r�a\w��0�o%����>v���8�bnM"m}�/�5�5
�C��|���u��]]��n���Il��@Ms��#�ECe�0�i�����[������l�:��r���D"Xt0���4�������L�����B���Q?QZ�=m�6�$�:8M�����=�{i�#`�S�����,�gHzs@�����:�g���F��~�K@�G�E��K�6�+S,����e�GJ>��H����C�MX	KJg
�a	�H�nx��D��{-�CV�$=(�%����+�V.�4&�bFnh����&������.V����+�\bH+�nO��B*{��lM�Es��B�Z!���t��IcE�^j9VJ�����E�3�`X�����-����#OGIon7�v��������DE	��`zl46��6Y������m�c��M�pIeQ%���q�
"�!���"D�A8&b�1
_�ZU��4�Mf�(���A���M
�E����������>�}*��i�#�@���	+�Q���!���M�p����[e��V��,/�l���W��������
%5cd�Q���������,g�*5�n��j6�:E��������p?+
(���VK�$h�4�jX�����f[ l�#����Z����Z"�#�eF��\<,Y��������V�	�������.smD{��-�>	;X�� �e����Gl�n�P������cF;<�	�����>����� S��7�vn����2x�������>����]���a�-�������-w��5����G,���0�:������anD���l����{T<Jcw5["��i�D����a4k4��4e��'�9�+\�wIC�:UF��D��P�!���l�������U��uv����[�[���_��D!��\��j���(;�=���O�n����F��*�<����&g��	����-T���f�vMF�>�����Q{w�T�lJW����D��fee��&���
�&-R)�UT�����'����D���Jk�&'3��u�J��x�F���xG<v*GH$]j�A@6]i��y�[^+��J�L?;F&QQ_��Hrd@����]D�pedX�<�k�-�U}�dbC��5�����J[?��{��d��-O��Gnh�Yu���|�s�J��<�����jyqE�Z��c����}m6���E9:�XKk���m����7E+O����������
}���y���m�2�[	0�Q;��\d��t��0�"nq/(����U��{����
Fk81���{���XXil�v�3I�S���pt.?P�o�H~�,�"ie���]�{���*
����X�C������'���C����5���j��C��S�����dX��T��o���xC��Vc:�:w�����S�_�����M&��Tv���]����v�fDa����y�C�X>)9=g�IjQ��%N�hU�1��
���1�A����W�����V���9(	xd�,����v������zB�w$�&�"�n>�i�!v�n�m�D,a��xC��������	������)2�<]\aQ�=�.�
G&/�i�2UbE�E������)���-���5��m�(m��jhV���-"�5]_�N����<<1Ig�TN�*P�I��D1K���-����Q��H�C�,D5Go���F�m�X|a�t�K1�V�BJk�L!d B�u��Y�O�x�e�F#�!�!�Uw0���������gRbX�T*>�GP"�v���P`��Vk���Dz����MHX�v���I���$"�M���o�+���v��n72&��tZ���9?����As�3Vi��/���>y��������Zi����&\=�6���h7F������G��}����_:q)������s���P���&��e:
5	��oM�Y�,G
����}���{������Z3�FTz�69�+:�g_��JA���.���ai�C�����(�]�i[����z�N��_�(����_x���aQf��^:f��*�Q�k���8������ ����wum`j�LN��;��Z�G���i�:lJ���9.��<�.�i(��`�����2��xG��h<��� �	vx.�#��(n�*!�mw1(�u$����iy���Z�r�J��*���x�������zB���cP_A����(=,�%�7R��9(��Q�+}��i����M4l�������q����G�>z�(��;>ul���H\�������|�~<9���k�^����2�����{�'���1����1����^!/��Tb��6��w��W��\�������������	Vo:�<�)k�v���\�kp
��5���\���i��y%�^�����1����������o�������������'�������������\�kp
��5���\�kp
��u��[�d�����z�����W���|��^�<��3����?����(�����7���L�����t���i`x:��'d2��<����0���L��_�	����0
�<�x�@&�k���{�Y�q�C�L������~
x)px*����|xp��M���N��1���\��a`��
��o��
�hG��},�
�8
L��]�p�}�1`�*��=�:PV������I�^w]z���z\�o��2[��(7�j{�����3�N��5�K���8�s��L��9���S��1�������G�t0������5b���}���<�d	:#����1
�j4;���5r��,k�f;��<3+��rN��[�b[Urx�N�K��>�9�����YZ%��D~�5���hs�h[��+� e��bWY2���~kFNC4��Js[�����p�u[wH�<{M����f_���
�=.z��e�a
s@���kP���Wj;���F���i5�����d��P+ y9OB��,I���&�3�����6������c����R�D����)��)�?Qw;V~8tvJm�|:�\��V)�/�-��5\.F���8z���D�:�R6��O��4��j�c����[�������z#��'��x���r�o`n�������T<h��|�QB\6�e9��,u��r��������,$�j,���1l�5to:pl�C����AB-����%�>D������KL�K�����c��CN�Qf�����?���L���	_����N.�f���L�@�V�S�����L������2�[���Rb,�u;y�C�7I+�o��\���8��TZ��%����P�V��o�\zGY��7���2��sU%/xa����\�I[��Rp���4WP�fu�Df�a<�H��D��Ujf��5�G��%���`z�$W$cd�yU�����moV
�M��y���<1Y��L���5��>����,L-$�q�tT�C�<��(2-n�/�~��Q(�\lOTzTs/oV����W�}e2�,[^>SF�����n��}8���*�v,�/�P���"h�XK0��C��q��""��HU},<����i��KrX��g��MXc���6�]�1T�G�f��;#��s�(�L���������CA�b<Qu;~-�yhlk���m�=
n�i��VP�@���u/�	��O�*���<�{u�G��Z�THdJ{Hi�7����N����%T��r���D��h���X��5:��y��V"!5�u�x����`��f�}���7��^���-?����fc\:J�#��{�l0�;�D������n%�9h6�{�K�Z������C����'���B�.�o��j��f���Qitjt+QdN���w�<.�����1fh��!RB^��I���Eu�K�����m���UW$9Ip�D^K�����z�m7��������o@(T��\�!����$�1��p�l]�?�������	�kX���A���&0�~x&����|x/�&�'�
��	�����?�	�|W��?�(�J�
���E�����X���!���[�xpx&����_�������o�I��
�����Q�_�1}=>���\��^W2�iQ��y9b�����L�`��QR-��������>�?#=�6�_��������n��o��^�~Ic��L��0[�)�g�d�,UOs��)nO1�d.%����8����������/H{���1|`�gT�a|�3Q����<����FL�
�����������f#Y5}�Q�u���4�^�EV���YE�����F�?��_%_��6���Q��� bi��E�����z7#���-���H�'�4�'��D�F�&�v2wtH����u�A�Do�	v&���==��M�.�!�L����v�K�Y���N>r�D��F3#�:�:�d�2�4��GN�it�'T����i���6R�f7JUH�B������L6U������v����]��g�q�!~��3���s���:�<� �#����;'���@�q#������O���!O�=8V
y����m�eB�(��sF+Zp|
uF\���C�����z������m���F\����oX�C�_�
xG�x�5�����{���GP��+�������\�f��J���������U&�(Y_��L�*��fI_U�::�	�onN�]l,D�U��8�&���>G'��
/P������1��gL#����3o�Z���D?DwB�F���M,!�m�xoj�{�8W��e,��C�=M�����6aj~4!nh6�2�+����&Eb��
�C2�)��<��I���RV�!F�B��AJ@��F�)�_2;xB��|<�E���e
�f�^�gM+m��3�������7�z'e?�g|Wvv�I���P���Qco����j��Q�w���Y�o�H��G'��\�u�-*o��J4���_��4�?9���}��?�$����o^���)�9�SU�u����;��~�
���+�*P��2p�N��(����L������x���u��,p~�������:�����	`�a���?z|&�K�O
���)����6;����U�n�,�| <x
p�7�L���x���/&��O|�q��7��|^u
dW�z�u��5`���
0
<
x
����
�8�+j����?��$p����g?|��L���%�~�=���WW�
�/.���j��:�n`�8��a�I�w����i���o�~x=��y�px�m��?�|x7�6������6�����e	|���Ct��+��xf����J_N��:�6��7���b����<Sci�����^��	#7�������{s�#
��f(;��$7d��}��O;C3�����%�0+��������*��7^�ILbQi&e���"�(���y���d5��D��]!$69�!d�rG����@k�Hu�Y����6[m�LM,I�:��@����u+��[[������&S�&Zz��O)����-O�g��PVw�_�)H)����G��G;�o�ZtzL���pS��C��DL�����nR�K2w.���#��dW2����$6VN���}�Ku7����|�"��QnU���7�@w]|����t��llm��F,�o���m�	�"���a��x��Si(r���(}�5v��3I���ST�{H��Z,OK7�Y.+,i	FN�{���Z��:$�1;��Tj|[:c'�l�������*�
���^��������`�X:K^l��L���qo�������3s��������jqe�`���v	0�� ������)���u�N�.��9���
Y[F=FX��x�R���O�?~<����d)X���_����=e��e����[��(6	�`�*���6+�G�Tl���Q�,t��p���$��~���c��L��&O
��I���n��+��t�]�^�t��ATm��!~��
GA$��q��2�[�N���;��fB(Y&�#���~������L��*Y,^�����<�%�5Of��L��`&�<��I3����_�]���-��N��p]IM��#���We�Bt�5����aD���������-����p�'�>������Z�a�X2��#�:��/����/���9��i]�w�5`�7��:������^?������o�,��_�|���/���?��{���pp�,�b��w���?>�
��5@XF�'�'[��x
�*���-��������7��o.�b�E�I�;����������.�����%������_��n`��������M�����Z������V��k���
|�#���������\AS��/n�Ql97�SX{��w��o~����u�~�
 B�;X��=�������
�/V�C@�A�����W�&���=�;�wo^��Z�ok@	������N
��u�>���{�����������!��/zk9l,[i
��	�?���$�ki�Tynvq��P�_�(����Z�G�+�V�&]��+*��nQk�H���m�)E�t&v7�jOl�ttO/����^�g��O�G�������d��.`���c[^]���7E/�a��jx�������q&+��!��Y,��g�(���-Xl������!5M} 	H�{V"`������PX��s����gWg���g����9z��}Y��E������|qq�Ln����F���:?W����}_�_<��L�����d%?������J<y��7�S�;��(���������G�?'�?'�MX�W#=�<K��D������q�C3V��k�����[����sb�Nf�u>��������YI���C��������b*G��������Vi��[�%_6�bI���?AVY��p4��9Fh�s�����oO�o�AM��>F��,�{JW�rO�x`�i���}���#���!�fm`��/�:������xN p-��,�hg�u�a�]���/�~��hoZNX;����R�r(`���5c�6�������[�
��5�c����Q�)8��������CfO��L)ml�m�](&�_N<��	$0OK���*����#{�h&������-�:��)ZnlW��G��B�/�}S���d����v��x�h���P�Jj$��:E��1Wy�����y�Da�2�d��N.]����q�d��#�
��8m,��5�l����x��|�(X|��P�����������V�����qZ������8���|43g��1O\�#������������r�fC����"R3�yJ6����=7>������Rq#�wYlp�b;����XHL9���0�4�X��B#3����>������~[��k���g���<�7_�����f���tR����a}2r���^�.����t��>��d��"3�������������D�h1��������m���m�^HO�j�{� ����X����7�|��:���~x�6�A�'���nQn�oa����O��������7�j����^�k� ���������������'�w?�
������`�_��>�c��`l/��>���J�00<���~xP������	���E��������|�y�4�%`x�U������7�e`�]�����?�)����"px*��[�����5|N���|
k��o6�u��	��%���>�.�^��o^4�u���`�����9���N������m��\�g����{8��� + �����;<�d���5K�osNr�rn�L�@gC����N�>��m�"��O�p�+,>�E�� �����u$�'�~���s��';����n�v������4I�y�w0�t�Y&,��.���+��R/IB�9J������v�jx�m�eZ��V���	���e��8����La��W���I���fd�&�vj���H�(�PP�L����q�u/�����$;��^����Z:M�������J2q-S����������94p�����<�@T
�GA�%)���w[U���N��5�(�;4���������.H�L�|&	=��z��w�F�=�ev�c�)MX���x}����������f[����!��d�������_�X�mk�����)��l��6�)�b���j�����7N�A�"�
�;4r�i���H���2i��
���[���[��"���������7k�����GC����Q��������
�{������"���;�����,�M-Y�.��M��@�P����VE�bJ$�����l����1/�D��#�[
U���v�n\���v�[V�Z�A��fB��'s;t���y�����=:N�^iy>��������Yl6���i�2k�����u7��@����H��[:��P������3�����P�������G�2����s_-�%VW^5w�3���/�N-�^Z9;���|d�r��K���%�b����4�/��+��W�/
C�A7C���,�������k�R�pMh�����>G�o���bF_�TB��
~��HVt��g������'�
���"%'�������>��,����'a5�[p�Q������acr�H?<'�,	����&R�R-��<�o@@��uH�a>y���&�$�hcy�R6o����hE��$Q�)�X��F�Ye��fC}��E��A�����A�`��9����y�+��v�����������g�*��k�P�Q;��jQb��|z���2�����A��O53�BRdd{7���r�r,����+����b��J�]����'J��tz�{Y�
��5���\�kp
��5���������;�
#22Kuntal Ghosh
kuntalghosh.2007@gmail.com
In reply to: Jan Wieck (#21)
Re: Extensibility of the PostgreSQL wire protocol

On Thu, Feb 18, 2021 at 9:32 PM Jan Wieck <jan@wi3ck.info> wrote:

And, here is how it looks with the following configuration:
telnet_srv.port = 1433
telnet_srv.listen_addresses = '*'

telnet localhost 1433

  master
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
PostgreSQL Telnet Interface

database name: postgres
username: kuntal
password: changeme

select 1;

?column?
----
1

SELECT 1

select 1/0;

Message: ERROR - division by zero

Few comments in the extension code (although experimental):

1. In telnet_srv.c,
+ static int        pe_port;
..
+       DefineCustomIntVariable("telnet_srv.port",
+                                                       "Telnet server port.",
+                                                       NULL,
+                                                       &pe_port,
+                                                       pe_port,
+                                                       1024,
+                                                       65536,
+                                                       PGC_POSTMASTER,
+                                                       0,
+                                                       NULL,
+                                                       NULL,
+                                                       NULL);

The variable pe_port should be initialized to a value which is > 1024
and < 65536. Otherwise, the following assert will fail,
TRAP: FailedAssertion("newval >= conf->min", File: "guc.c", Line:
5541, PID: 12100)

2. The function pq_putbytes shouldn't be used by anyone other than
old-style COPY out.
+ pq_putbytes(msg, strlen(msg));
Otherwise, the following assert will fail in the same function:
/* Should only be called by old-style COPY OUT */
Assert(DoingCopyOut);

--
Thanks & Regards,
Kuntal Ghosh
Amazon Web Services

#23Damir Simunic
damir.simunic@gmail.com
In reply to: Tom Lane (#15)
Re: Extensibility of the PostgreSQL wire protocol

On 11 Feb 2021, at 16:06, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Maybe there is some useful thing that can be accomplished here, but we
need to consider the bigger picture rather than believing (without proof)
that a few hook variables will be enough to do anything.

regards, tom lane

Pluggable wire protocol is a game-changer on its own.

The bigger picture is that a right protocol choice enables large-scale architectural simplifications for whole classes of production applications.

For browser-based applications (lob, saas, e-commerce), having the database server speak the browser protocol enables architectures without backend application code. This in turn leads to significant reductions of latency, complexity, and application development time. And it’s not just lack of backend code: one also profits from all the existing infrastructure like per-query compression/format choice, browser connection management, sse, multiple streams, prioritization, caching/cdns, etc.

Don’t know if you’d consider it as a proof, yet I am seeing 2x to 4x latency reduction in production applications from protocol conversion to http/2. My present solution is a simple connection pooler I built on top of Nginx transforming the tcp stream as it passes through.

In a recent case, letting the browser talk directly to the database allowed me to get rid of a ~100k-sloc .net backend and all the complexity and infrastructure that goes with coding/testing/deploying/maintaining it, while keeping all the positives: per-query compression/data conversion, querying multiple databases over a single connection, session cookies, etc. Deployment is trivial compared to what was before. Latency is down 2x-4x across the board.

Having some production experience with this approach, I can see how http/2-speaking Postgres would further reduce latency, processing cost, and time-to-interaction for applications.

A similar case can be made for IoT where one would want to plug an iot-optimized protocol. Again, most of the benefit is possible with a protocol-converting proxy, but there are additional non-trivial performance gains to be had if the database server speaks the right protocol.

While not the only use cases, I’d venture a guess these represent a sizable chunk of what Postgres is used for today, and will be used even more for, so the positive impact of a pluggable protocol would be significant.

--
Damir

#24Jan Wieck
jan@wi3ck.info
In reply to: Kuntal Ghosh (#22)
Re: Extensibility of the PostgreSQL wire protocol

Thank you Kuntal,

On Fri, Feb 19, 2021 at 4:36 AM Kuntal Ghosh <kuntalghosh.2007@gmail.com>
wrote:

On Thu, Feb 18, 2021 at 9:32 PM Jan Wieck <jan@wi3ck.info> wrote:

Few comments in the extension code (although experimental):

1. In telnet_srv.c,
+ static int        pe_port;
..
+       DefineCustomIntVariable("telnet_srv.port",
+                                                       "Telnet server
port.",
+                                                       NULL,
+                                                       &pe_port,
+                                                       pe_port,
+                                                       1024,
+                                                       65536,
+                                                       PGC_POSTMASTER,
+                                                       0,
+                                                       NULL,
+                                                       NULL,
+                                                       NULL);

The variable pe_port should be initialized to a value which is > 1024
and < 65536. Otherwise, the following assert will fail,
TRAP: FailedAssertion("newval >= conf->min", File: "guc.c", Line:
5541, PID: 12100)

Right, forgot to turn on Asserts.

2. The function pq_putbytes shouldn't be used by anyone other than
old-style COPY out.
+ pq_putbytes(msg, strlen(msg));
Otherwise, the following assert will fail in the same function:
/* Should only be called by old-style COPY OUT */
Assert(DoingCopyOut);

I would argue that the Assert needs to be changed. It is obvious that the
Assert in place is meant to guard against direct usage of pg_putbytes() in
an attempt to force all code to use pq_putmessage() instead. This is good
when speaking libpq wire protocol since all messages there are prefixed
with a one byte message type. It does not apply to other protocols.

I propose to create another global boolean IsNonLibpqFrontend which the
protocol extension will set to true when accepting the connection and the
above then will change to

Assert(DoingCopyOut || IsNonLibpqFrontend);

Regards, Jan

--
Thanks & Regards,
Kuntal Ghosh
Amazon Web Services

--
Jan Wieck

#25Heikki Linnakangas
hlinnaka@iki.fi
In reply to: Damir Simunic (#23)
Re: Extensibility of the PostgreSQL wire protocol

On 19/02/2021 14:29, Damir Simunic wrote:

On 11 Feb 2021, at 16:06, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Maybe there is some useful thing that can be accomplished here, but
we need to consider the bigger picture rather than believing
(without proof) that a few hook variables will be enough to do
anything.

Pluggable wire protocol is a game-changer on its own.

The bigger picture is that a right protocol choice enables
large-scale architectural simplifications for whole classes of
production applications.

For browser-based applications (lob, saas, e-commerce), having the
database server speak the browser protocol enables architectures
without backend application code. This in turn leads to significant
reductions of latency, complexity, and application development time.
And it’s not just lack of backend code: one also profits from all the
existing infrastructure like per-query compression/format choice,
browser connection management, sse, multiple streams, prioritization,
caching/cdns, etc.

Don’t know if you’d consider it as a proof, yet I am seeing 2x to 4x
latency reduction in production applications from protocol conversion
to http/2. My present solution is a simple connection pooler I built
on top of Nginx transforming the tcp stream as it passes through.

I can see value in supporting different protocols. I don't like the
approach discussed in this thread, however.

For example, there has been discussion elsewhere about integrating
connection pooling into the server itself. For that, you want to have a
custom process that listens for incoming connections, and launches
backends independently of the incoming connections. These hooks would
not help with that.

Similarly, if you want to integrate a web server into the database
server, you probably also want some kind of connection pooling. A
one-to-one relationship between HTTP connections and backend processes
doesn't seem nice.

With the hooks that exist today, would it possible to write a background
worker that listens on a port, instead of postmaster? Can you launch
backends from a background worker? And communicate the backend processes
using a shared memory message queue (see pqmq.c).

I would recommend this approach: write a separate program that sits
between the client and PostgreSQL, speaking custom protocol to the
client, and libpq to the backend. And then move that program into a
background worker process.

In a recent case, letting the browser talk directly to the database
allowed me to get rid of a ~100k-sloc .net backend and all the
complexity and infrastructure that goes with
coding/testing/deploying/maintaining it, while keeping all the
positives: per-query compression/data conversion, querying multiple
databases over a single connection, session cookies, etc. Deployment
is trivial compared to what was before. Latency is down 2x-4x across
the board.

Querying multiple databases over a single connection is not possible
with the approach taken here. Not sure about the others things you listed.

- Heikki

#26Jonah H. Harris
jonah.harris@gmail.com
In reply to: Heikki Linnakangas (#25)
Re: Extensibility of the PostgreSQL wire protocol

On Fri, Feb 19, 2021 at 8:48 AM Heikki Linnakangas <hlinnaka@iki.fi> wrote:

With the hooks that exist today, would it possible to write a background
worker that listens on a port, instead of postmaster? Can you launch
backends from a background worker? And communicate the backend processes
using a shared memory message queue (see pqmq.c).

Yes. That's similar to how mine work: A background worker that acts as a
listener for the new protocol which then sets up a new dynamic background
worker on accept(), waits for its creation, passes the fd to the new
background worker, and sits in a while (!got_sigterm) loop checking the
socket for activity and running the protocol similar to postmaster. I
haven't looked at the latest connection pooling patches but, in general,
connection pooling is an abstract issue and should be usable for any type
of connection as, realistically, it's just an event loop and state problem
- it shouldn't be protocol specific.

I would recommend this approach: write a separate program that sits

between the client and PostgreSQL, speaking custom protocol to the
client, and libpq to the backend. And then move that program into a
background worker process.

Doing protocol conversion between libpq and a different protocol works, but
is slow. My implementations were originally all proxies that worked outside
the database, then I moved them inside, then I replaced all the libpq code
with SPI-related calls.

In a recent case, letting the browser talk directly to the database
allowed me to get rid of a ~100k-sloc .net backend and all the
complexity and infrastructure that goes with
coding/testing/deploying/maintaining it, while keeping all the
positives: per-query compression/data conversion, querying multiple
databases over a single connection, session cookies, etc. Deployment
is trivial compared to what was before. Latency is down 2x-4x across
the board.

Querying multiple databases over a single connection is not possible
with the approach taken here. Not sure about the others things you listed.

Accessing multiple databases from the same backend is problematic overall -
I didn't solve that in my implementations either. IIRC, once a bgworker is
attached to a specific database, it's basically stuck with that database.

--
Jonah H. Harris

#27Jan Wieck
jan@wi3ck.info
In reply to: Heikki Linnakangas (#25)
Re: Extensibility of the PostgreSQL wire protocol

On 2/19/21 8:48 AM, Heikki Linnakangas wrote:

I can see value in supporting different protocols. I don't like the
approach discussed in this thread, however.

For example, there has been discussion elsewhere about integrating
connection pooling into the server itself. For that, you want to have a
custom process that listens for incoming connections, and launches
backends independently of the incoming connections. These hooks would
not help with that.

The two are not mutually exclusive. You are right that the current
proposal would not help with that type of built in connection pool, but
it may be extended to that.

Give the function, that postmaster is calling to accept a connection
when a server_fd is ready, a return code that it can use to tell
postmaster "forget about it, don't fork or do anything else with it".
This function is normally calling StreamConnection() before the
postmaster then forks the backend. But it could instead hand over the
socket to the pool background worker (I presume Jonah is transferring
them from process to process via UDP packet). The pool worker is then
launching the actual backends which receive a requesting client via the
same socket transfer to perform one or more transactions, then hand the
socket back to the pool worker.

All of that would still require a protocol extension that has special
messages for "here is a client socket for you" and "you can have that
back".

I would recommend this approach: write a separate program that sits
between the client and PostgreSQL, speaking custom protocol to the
client, and libpq to the backend. And then move that program into a
background worker process.

That is a classic protocol converting proxy. It has been done in the
past with not really good results, both performance wise as with respect
to protocol completeness.

Regards, Jan

--
Jan Wieck
Principle Database Engineer
Amazon Web Services

#28Damir Simunic
damir.simunic@gmail.com
In reply to: Heikki Linnakangas (#25)
Re: Extensibility of the PostgreSQL wire protocol

On 19 Feb 2021, at 14:48, Heikki Linnakangas <hlinnaka@iki.fi> wrote:

For example, there has been discussion elsewhere about integrating connection pooling into the server itself. For that, you want to have a custom process that listens for incoming connections, and launches backends independently of the incoming connections. These hooks would not help with that.

Not clear how the connection polling in the core is linked to discussing pluggable wire protocols.

Similarly, if you want to integrate a web server into the database server, you probably also want some kind of connection pooling. A one-to-one relationship between HTTP connections and backend processes doesn't seem nice.

HTTP/2 is just a protocol, not unlike fe/be that has a one-to-one relationship to backend processes as it stands. It shuttles data back and forth in query/response exchanges, and happens to be used by web servers and web browsers, among other things. My mentioning of it was simply an example I can speak of from experience, as opposed to speculating. Could have brought up any other wire protocol if I had experience with it, say MQTT.

To make it clear, “a pluggable wire protocol” as discussed here is a set of rules that defines how data is transmitted: what the requests and responses are, and how is the data laid out on the wire, what to do in case of error, etc. Nothing to do with a web server; why would one want to integrate it in the database, anyway?

The intended contribution to the discussion of big picture of pluggable wire protocols is that there are significant use cases where the protocol choice is restricted on the client side, and allowing a pluggable wire protocol on the server side brings tangible benefits in performance and architectural simplification. That’s all. The rest were supporting facts that hopefully can also serve as a counterpoint to “pluggable wire protocol is primarily useful to make Postgres pretend to be Mysql."

Protocol conversion HTTP/2<—>FE/BE on the connection pooler already brings a lot of the mentioned benefits, and I’m satisfied with it. Beyond that I’m simply supporting the idea of pluggable protocols as experience so far allows me to see advantages that might sound theoretical to someone who never tried this scenario in production.

Glad to offer a couple of examples where I see potential for performance gains for having such a wire protocol pluggable in the core. Let me know if you want me to elaborate.

Querying multiple databases over a single connection is not possible with the approach taken here.

Indeed, querying multiple databases over a single connection is something you need a proxy for and a different client protocol from fe/be. No need to mix that with the talk about pluggable wire protocol.

My mentioning of it was in the sense “a lot of LoB backend code is nothing more than a bloated protocol converter that happens to also allow connecting to multiple databases from a single client connection => letting the client speak to the database [trough a proxy in this case] removed the bloated source of latency but kept the advantages.”

--
Damir

#29Jan Wieck
jan@wi3ck.info
In reply to: Damir Simunic (#28)
Re: Extensibility of the PostgreSQL wire protocol

On 2/19/21 12:18 PM, Damir Simunic wrote:

On 19 Feb 2021, at 14:48, Heikki Linnakangas <hlinnaka@iki.fi> wrote:

For example, there has been discussion elsewhere about integrating connection pooling into the server itself. For that, you want to have a custom process that listens for incoming connections, and launches backends independently of the incoming connections. These hooks would not help with that.

Not clear how the connection polling in the core is linked to discussing pluggable wire protocols.

It isn't per se. But there are things pluggable wire protocols can help
with in regards to connection pooling. For example a connection pool
like pgbouncer can be configured to switch client-backend association on
a transaction level. It therefore scans the traffic for the in
transaction state. This however only works if an application uses
identical session states across all connections in a pool. The JDBC
driver for example only really prepares PreparedStatements after a
number of executions and then assigns a name based on a counter to them.
So it is neither guaranteed that a certain backend has the same
statements prepared, nor that they are named the same. Therefore JDBC
based applications cannot use PreparedStatements through pgbouncer in
transaction mode.

An "extended" libpq protocol could allow the pool to give clients a
unique ID. The protocol handler would then maintain maps with the SQL of
prepared statements and what the client thinks their prepared statement
name is. So when a client sends a P packet, the protocol handler would
lookup the mapping and see if it already has that statement prepared.
Just add the mapping info or actually create a new statement entry in
the maps. These maps are of course shared across backends. So if then
another client sends bind+execute and the backend doesn't have a plan
for that query, it would internally create one.

There are security implications here, so things like the search path
might have to be part of the maps, but those are implementation details.

At the end this would allow a project like pgbouncer to create an
extended version of libpq protocol that caters to the very special needs
of that pool.

Most of that would of course be possible on the pool side itself. But
the internal structure of pgbouncer isn't suitable for that. It is very
lightweight and for long SQL queries may never have the complete 'P'
message in memory. It would also not have direct access to security
related information like the search path, which would require extra
round trips between the pool and the backend to retrieve it.

So while not suitable to create a built in pool by itself, loadable wire
protocols can definitely help with connection pooling.

I also am not sure if building a connection pool into a background
worker or postmaster is a good idea to begin with. One of the important
features of a pool is to be able to suspend traffic and make the server
completely idle to for example be able to restart the postmaster without
forcibly disconnecting all clients. A pool built into a background
worker cannot do that.

Regards, Jan

--
Jan Wieck
Principle Database Engineer
Amazon Web Services

#30Damir Simunic
damir.simunic@gmail.com
In reply to: Jan Wieck (#29)
Re: Extensibility of the PostgreSQL wire protocol

On 19 Feb 2021, at 19:30, Jan Wieck <jan@wi3ck.info> wrote:

An "extended" libpq protocol could allow the pool to give clients a unique ID. The protocol handler would then maintain maps with the SQL of prepared statements and what the client thinks their prepared statement name is.

Or, the connection pooler could support a different wire protocol that has some form of client cookies and could let the client hold on to an opaque token to present back with every query and use that to route to the right backend with a prepared statement for that client (or match the appropriate cached p statement from the cache), even across client disconnections.

Most of that would of course be possible on the pool side itself. But the internal structure of pgbouncer isn't suitable for that. It is very lightweight and for long SQL queries may never have the complete 'P' message in memory. It would also not have direct access to security related information like the search path, which would require extra round trips between the pool and the backend to retrieve it.

So while not suitable to create a built in pool by itself, loadable wire protocols can definitely help with connection pooling.

I think loadable wire protocols will have a positive effect on developing more sophisticated connection poolers.

I also am not sure if building a connection pool into a background worker or postmaster is a good idea to begin with. One of the important features of a pool is to be able to suspend traffic and make the server completely idle to for example be able to restart the postmaster without forcibly disconnecting all clients.

Agreed. Going even further, a connection pooler supporting a protocol like quic (where the notion of connection is decoupled from the actual socket connection) could help a lot with balancing load between servers and data centers, which also would not be convenient for the actual Postgres to do with present architecture. (And here, too, a pluggable wire protocol would help with keeping tabs on individual backends).

--
Damir

#31Álvaro Hernández
aht@ongres.com
In reply to: Heikki Linnakangas (#25)
Re: Extensibility of the PostgreSQL wire protocol

On 19/2/21 14:48, Heikki Linnakangas wrote:

[...]

I can see value in supporting different protocols. I don't like the
approach discussed in this thread, however.

For example, there has been discussion elsewhere about integrating
connection pooling into the server itself. For that, you want to have
a custom process that listens for incoming connections, and launches
backends independently of the incoming connections. These hooks would
not help with that.

Similarly, if you want to integrate a web server into the database
server, you probably also want some kind of connection pooling. A
one-to-one relationship between HTTP connections and backend processes
doesn't seem nice.

    While I'm far from an HTTP/2 expert and I may be wrong, from all I
know HTTP/2 allows to create full-duplex, multiplexed, asynchronous
channels. So multiple connections can be funneled through a single
connection. This decreases the need and aim for connection pooling. It
doesn't eliminate it completely, as you may have the channel busy if a
single tenant is sending a lot of data; and you could not have more than
one concurrent action from a single tenant. OTOH, given these HTTP/2
properties, a non-pooled HTTP/2 endpoint may provide already significant
benefits due to the multiplexing capabilities.

    So definitely we don't need to consider an HTTP endpoint would
entail a 1:1 mapping between connections and backend processes.

    Álvaro

--

Alvaro Hernandez

-----------
OnGres

#32Álvaro Hernández
aht@ongres.com
In reply to: Jan Wieck (#29)
Re: Extensibility of the PostgreSQL wire protocol

On 19/2/21 19:30, Jan Wieck wrote:

[...]

I also am not sure if building a connection pool into a background
worker or postmaster is a good idea to begin with. One of the
important features of a pool is to be able to suspend traffic and make
the server completely idle to for example be able to restart the
postmaster without forcibly disconnecting all clients. A pool built
into a background worker cannot do that.

    In my opinion, there are different reasons to use a connection pool,
that lead to different placements of that connection pool on the
architecture of the system. The ability of a pool to suspend (pause)
traffic and apply live re-configurations is a very important one to
implement high availability practices, transparent scaling, and others.
But these poolers belong to middleware layers (as in different processes
in different servers), where these pausing operations make complete sense.

    Connection poolers fronting the database have other specific
missions, namely to control the fan-in of connections to the database.
These connection poolers make sense being as close to the database as
possible (ideally: embedded) but don't need to perform pause operations
here.

    Álvaro

--

Alvaro Hernandez

-----------
OnGres

#33Dave Cramer
davecramer@postgres.rocks
In reply to: Álvaro Hernández (#32)
Re: Extensibility of the PostgreSQL wire protocol

On Fri, 19 Feb 2021 at 15:39, Álvaro Hernández <aht@ongres.com> wrote:

On 19/2/21 19:30, Jan Wieck wrote:

[...]

I also am not sure if building a connection pool into a background
worker or postmaster is a good idea to begin with. One of the
important features of a pool is to be able to suspend traffic and make
the server completely idle to for example be able to restart the
postmaster without forcibly disconnecting all clients. A pool built
into a background worker cannot do that.

Yes, when did it become a good idea to put a connection pooler in the
backend???

Dave Cramer
www.postgres.rocks

#34Jan Wieck
jan@wi3ck.info
In reply to: Dave Cramer (#33)
Re: Extensibility of the PostgreSQL wire protocol

On 2/22/21 7:34 AM, Dave Cramer wrote:

Yes, when did it become a good idea to put a connection pooler in the
backend???

Dave Cramer
www.postgres.rocks

As Alvaro said, different pool purposes lead to different pool
architecture and placement.

However, the changes proposed here, aiming at the ability to load
modified or entirely different wire protocol handlers, do not limit such
connection pooling. To the contrary.

Any connection pool, that wants to maintain more client connections than
actual database backends, must know when it is appropriate to do so.
Usually the right moment to break the current client-backend association
is when the backend is outside a transaction block and waiting for the
next client request. To do so pools cannot blindly shovel data back and
forth. They need to scan one way or another for the backend's 'Z'
message, sent in tcop/dest.c ReadyForQuery(), where the backend also
reports the current transaction state. IOW the pool must follow the flow
of libpq messages on all connections, message by message, row by row,
just for the purpose of seeing that one, single bit. It is possible to
transmit that information to the pool on a separate channel.

Regards, Jan

--
Jan Wieck
Principle Database Engineer
Amazon Web Services

#35Jan Wieck
jan@wi3ck.info
In reply to: Kuntal Ghosh (#22)
2 attachment(s)
Re: Extensibility of the PostgreSQL wire protocol

On 2/19/21 4:36 AM, Kuntal Ghosh wrote:

On Thu, Feb 18, 2021 at 9:32 PM Jan Wieck <jan@wi3ck.info> wrote:

Few comments in the extension code (although experimental):

1. In telnet_srv.c,
+ static int        pe_port;
..
+       DefineCustomIntVariable("telnet_srv.port",
+                                                       "Telnet server port.",
+                                                       NULL,
+                                                       &pe_port,
+                                                       pe_port,
+                                                       1024,
+                                                       65536,
+                                                       PGC_POSTMASTER,
+                                                       0,
+                                                       NULL,
+                                                       NULL,
+                                                       NULL);

The variable pe_port should be initialized to a value which is > 1024
and < 65536. Otherwise, the following assert will fail,
TRAP: FailedAssertion("newval >= conf->min", File: "guc.c", Line:
5541, PID: 12100)

2. The function pq_putbytes shouldn't be used by anyone other than
old-style COPY out.
+ pq_putbytes(msg, strlen(msg));
Otherwise, the following assert will fail in the same function:
/* Should only be called by old-style COPY OUT */
Assert(DoingCopyOut);

Attached are an updated patch and telnet_srv addressing the above problems.

Regards, Jan

--
Jan Wieck
Principle Database Engineer
Amazon Web Services

Attachments:

telnet_srv_2021-02-22_1.tgzapplication/x-compressed-tar; name=telnet_srv_2021-02-22_1.tgzDownload
wire_proto_2021-02-22_1.diff.gzapplication/gzip; name=wire_proto_2021-02-22_1.diff.gzDownload
#36David Fetter
david@fetter.org
In reply to: Dave Cramer (#33)
Re: Extensibility of the PostgreSQL wire protocol

On Mon, Feb 22, 2021 at 07:34:51AM -0500, Dave Cramer wrote:

On Fri, 19 Feb 2021 at 15:39, �lvaro Hern�ndez <aht@ongres.com> wrote:

On 19/2/21 19:30, Jan Wieck wrote:

[...]

I also am not sure if building a connection pool into a
background worker or postmaster is a good idea to begin with.
One of the important features of a pool is to be able to suspend
traffic and make the server completely idle to for example be
able to restart the postmaster without forcibly disconnecting
all clients. A pool built into a background worker cannot do
that.

Yes, when did it become a good idea to put a connection pooler in
the backend???

It became a great idea when we noticed just how large and
resource-intensive backends were, especially in light of applications'
broad tendency to assume that they're free. While I agree that that's
not a good assumption, it's one that's so common everywhere in
computing that we really need to face up to the fact that it's not
going away any time soon.

Decoupling the parts that serve requests from the parts that execute
queries also goes a long way toward things we've wanted for quite
awhile like admission control systems and/or seamless zero-downtime
upgrades.

Separately, as the folks at AWS and elsewhere have mentioned, being
able to pretend at some level to be a different RDBMS can only happen
if we respond to its wire protocol.

Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

#37Jan Wieck
jan@wi3ck.info
In reply to: Tom Lane (#7)
Re: Extensibility of the PostgreSQL wire protocol

On 2/10/21 1:10 PM, Tom Lane wrote:

What I'm actually more concerned about, in this whole line of development,
is the follow-on requests that will surely occur to kluge up Postgres
to make its behavior more like $whatever. As in "well, now that we
can serve MySQL clients protocol-wise, can't we pretty please have a
mode that makes the parser act more like MySQL".

Those requests will naturally follow. But I don't see it as the main
project's responsibility to satisfy them. It would be rather natural to
develop the two things together. The same developer or group of
developers, who are trying to connect a certain client, will want to
have other compatibility features.

As Jim Mlodgenski just posted in [0]/messages/by-id/CAB_5SReoPJAPO26Z8+WN6ugfBb2UDc3c21rRz9=BziBmCaph5Q@mail.gmail.com, having the ability to also extend
and/or replace the parser will give them the ability to do just that.

Regards, Jan

[0]: /messages/by-id/CAB_5SReoPJAPO26Z8+WN6ugfBb2UDc3c21rRz9=BziBmCaph5Q@mail.gmail.com
/messages/by-id/CAB_5SReoPJAPO26Z8+WN6ugfBb2UDc3c21rRz9=BziBmCaph5Q@mail.gmail.com

--
Jan Wieck
Principle Database Engineer
Amazon Web Services

#38Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jan Wieck (#37)
Re: Extensibility of the PostgreSQL wire protocol

Jan Wieck <jan@wi3ck.info> writes:

On 2/10/21 1:10 PM, Tom Lane wrote:

What I'm actually more concerned about, in this whole line of development,
is the follow-on requests that will surely occur to kluge up Postgres
to make its behavior more like $whatever. As in "well, now that we
can serve MySQL clients protocol-wise, can't we pretty please have a
mode that makes the parser act more like MySQL".

Those requests will naturally follow. But I don't see it as the main
project's responsibility to satisfy them. It would be rather natural to
develop the two things together. The same developer or group of
developers, who are trying to connect a certain client, will want to
have other compatibility features.

As Jim Mlodgenski just posted in [0], having the ability to also extend
and/or replace the parser will give them the ability to do just that.

Yeah, and as I pointed out somewhere upthread, trying to replace the
whole parser will just end in a maintenance nightmare. The constructs
that the parser has to emit are complex, Postgres-specific, and
constantly evolving. We are NOT going to promise any sort of cross
version compatibility for parse trees.

regards, tom lane

#39Jonah H. Harris
jonah.harris@gmail.com
In reply to: Tom Lane (#38)
Re: Extensibility of the PostgreSQL wire protocol

On Mon, Feb 22, 2021 at 1:01 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Jan Wieck <jan@wi3ck.info> writes:

As Jim Mlodgenski just posted in [0], having the ability to also extend
and/or replace the parser will give them the ability to do just that.

Yeah, and as I pointed out somewhere upthread, trying to replace the
whole parser will just end in a maintenance nightmare. The constructs
that the parser has to emit are complex, Postgres-specific, and
constantly evolving. We are NOT going to promise any sort of cross
version compatibility for parse trees.

Wholeheartedly agreed. Core should only ever maintain the hooks, never
their usage. It's the responsibility of the extension author to maintain
their code just as it is to manage their use of all other hook usages. Yes,
it's sometimes a maintenance nightmare - but with great power comes great
responsibility... as is anything loaded directly into the process.

--
Jonah H. Harris

#40Jan Wieck
jan@wi3ck.info
In reply to: Tom Lane (#38)
Re: Extensibility of the PostgreSQL wire protocol

On 2/22/21 1:01 PM, Tom Lane wrote:

Yeah, and as I pointed out somewhere upthread, trying to replace the
whole parser will just end in a maintenance nightmare. The constructs
that the parser has to emit are complex, Postgres-specific, and
constantly evolving. We are NOT going to promise any sort of cross
version compatibility for parse trees.

Absolutely agreed. We cannot promise that the parsetree generated in one
version will work with the planner, optimizer and executor of the next.
These types of projects will need to pay close attention and more
importantly, develop their own regression test suites that detect when
something has changed in core. That said, discussion about the parser
hook should happen in the other thread.

I don't even expect that we can guarantee that the functions I am trying
to allow to be redirected for the wire protocol will be stable forever.
libpq V4 may need to change some of the call signatures, which has
happened before. For example, the function to send the command
completion message to the frontend (tcop/dest.c EndCommand()) changed
from 12 to 13.

Regards, Jan

--
Jan Wieck
Principle Database Engineer
Amazon Web Services

#41Jan Wieck
jan@wi3ck.info
In reply to: Jan Wieck (#27)
Re: Extensibility of the PostgreSQL wire protocol

On 2/19/21 10:13 AM, Jan Wieck wrote:

Give the function, that postmaster is calling to accept a connection
when a server_fd is ready, a return code that it can use to tell
postmaster "forget about it, don't fork or do anything else with it".
This function is normally calling StreamConnection() before the
postmaster then forks the backend. But it could instead hand over the
socket to the pool background worker (I presume Jonah is transferring
them from process to process via UDP packet). The pool worker is then
launching the actual backends which receive a requesting client via the
same socket transfer to perform one or more transactions, then hand the
socket back to the pool worker.

The function in question, which is StreamConnection() and with this
patch can be replaced with an extension funtion via the fn_accept
pointer, already has that capability. If StreamConnection() or its
replacement returns a NULL pointer, the postmaster just skips calling
BackendStartup(). So everything is already in place for the above to work.

Regards, Jan

--
Jan Wieck
Principle Database Engineer
Amazon Web Services

#42Peter Eisentraut
peter.eisentraut@enterprisedb.com
In reply to: Jan Wieck (#35)
Re: Extensibility of the PostgreSQL wire protocol

I think, the way the abstractions are chosen in this patch, it is still
very much tied to how the libpq protocol works. For example, there is a
cancel key and a ready-for-query message. Some of the details of the
simple and the extended query are exposed. So you could create a
protocol that has a different way of encoding the payloads, as your
telnet example does, but I don't believe that you could implement a
competitor's protocol through this. Unless you have that done and want
to show it?

#43Hannu Krosing
hannuk@google.com
In reply to: Peter Eisentraut (#42)
Re: Extensibility of the PostgreSQL wire protocol

I have not looked at the actual patch, but does it allow you to set up
its own channels to listen to ?

For example if I'd want to set up a server to listen to incoming connections
over QUIC [1]https://en.wikipedia.org/wiki/QUIC - a protocol which create a connection over UDP and allows
clients to move to new IP addresses (among other things) then would the
current extensibility proposal cover this ?

Maybe a correct approach would be to just start up a separate
"postmaster" to listen to a different protocol ?

[1]: https://en.wikipedia.org/wiki/QUIC

Cheers
Hannu

#44Jan Wieck
jan@wi3ck.info
In reply to: Peter Eisentraut (#42)
Re: Extensibility of the PostgreSQL wire protocol

On 3/3/21 2:43 PM, Peter Eisentraut wrote:

I think, the way the abstractions are chosen in this patch, it is still
very much tied to how the libpq protocol works. For example, there is a
cancel key and a ready-for-query message. Some of the details of the
simple and the extended query are exposed. So you could create a
protocol that has a different way of encoding the payloads, as your
telnet example does, but I don't believe that you could implement a
competitor's protocol through this. Unless you have that done and want
to show it?

Correct, a lot of what this patch does is to allow a developer of such
protocol extension to just "extend" what the server side libpq does, by
building a wrapper around the function they are interested in. That
doesn't change the protocol, but rather allows additional functionality
like the telemetry data gathering, Fabrizio was talking about.

The telnet_srv tutorial extension (which needs more documentation) is an
example of how far one can go by replacing those funcitons, in that it
actually implements a very different wire protocol. This one still fits
into the regular libpq message flow.

Another possibility, and this is what is being used by the AWS team
implementing the TDS protocol for Babelfish, is to completely replace
the entire TCOP mainloop function PostgresMain(). That is of course a
rather drastic move and requires a lot more coding on the extension
side, but the whole thing was developed that way from the beginning and
it is working. I don't have a definitive date when that code will be
presented. Kuntal or Prateek may be able to fill in more details.

Regards, Jan

--
Jan Wieck
Principle Database Engineer
Amazon Web Services

#45Hannu Krosing
hannuk@google.com
In reply to: Jan Wieck (#44)
Re: Extensibility of the PostgreSQL wire protocol

On Thu, Mar 4, 2021 at 9:55 PM Jan Wieck <jan@wi3ck.info> wrote:

Another possibility, and this is what is being used by the AWS team
implementing the TDS protocol for Babelfish, is to completely replace
the entire TCOP mainloop function PostgresMain().

I suspect this is the only reasonable way to do it for protocols which are
not very close to libpq.

That is of course a
rather drastic move and requires a lot more coding on the extension
side,

Not necessarily - if the new protocol is close to existing one, then it is
copy/paste + some changes.

If it is radically different, then trying to fit it into the current
mainloop will
be even harder than writing from scratch.

And will very likely fail in the end anyway :)

but the whole thing was developed that way from the beginning and
it is working. I don't have a definitive date when that code will be
presented. Kuntal or Prateek may be able to fill in more details.

Are you really fully replacing the main loop, or are you running a second
main loop in parallel in the same database server instance, perhaps as
a separate TDS_postmaster backend ?

Will the data still also be accessible "as postgres" via port 5432 when
TDS/SQLServer support is active ?

#46Jan Wieck
jan@wi3ck.info
In reply to: Hannu Krosing (#45)
Re: Extensibility of the PostgreSQL wire protocol

On 3/4/21 7:38 PM, Hannu Krosing wrote:

On Thu, Mar 4, 2021 at 9:55 PM Jan Wieck <jan@wi3ck.info> wrote:

but the whole thing was developed that way from the beginning and
it is working. I don't have a definitive date when that code will be
presented. Kuntal or Prateek may be able to fill in more details.

Are you really fully replacing the main loop, or are you running a second
main loop in parallel in the same database server instance, perhaps as
a separate TDS_postmaster backend ?

Will the data still also be accessible "as postgres" via port 5432 when
TDS/SQLServer support is active ?

The individual backend (session) is running a different main loop. A
libpq based client will still get the regular libpq and the original
PostgresMain() behavior on port 5432. The default port for TDS is 1433
and with everything in place I can connect to the same database on that
port with Microsoft's SQLCMD.

The whole point of all this is to allow the postmaster to listen to more
than just 5432 and have different communication protocols on those
*additional* ports. Nothing is really *replaced*. The parts of the
backend, that do actual socket communication, are just routed through
function pointers so that an extension can change their behavior.

Regards, Jan

--
Jan Wieck
Principle Database Engineer
Amazon Web Services