I just had an idea today, sort of inspired by some work I am doing and by a
patch to bind which uses an external database.
You'll think I'm nuts, but hear me out.
What if the BE protocol was constructed as a loadable plugin?
The plugin handles the "front" of the PostgreSQL backend. It reads from a
socket and handles a request. There should also be the ability to have
multiple BE protocols loaded at once. Each on their own port, of course.
So the postmaster process listens to a number of sockets for connections,
when a socket is accepted, its protocol handler is pulled out of a hash
table or array, a new backend is spawned (or perhaps a new thread is created
in some unlikely future PG), and control is passed to the BE protocol handler.
It is the job of the BE handler to read a socket and write the results. The
postmaster process need not care about what the backend handler does. The
only issue would be to try to document a process for creating a custom BE
protocol handler.
This would allow PG to incorporate a web services protocol. It would allow
servers like email, DNS, etc. to be constructed from within PostgreSQL.
What do you think?