Re: Implementation of the frontend protocol - Mailing list pgsql-general

From Tom Lane
Subject Re: Implementation of the frontend protocol
Date
Msg-id 2653.974218286@sss.pgh.pa.us
Whole thread Raw
In response to Implementation of the frontend protocol  (Peter Korsgaard <jacmet@control.auc.dk>)
List pgsql-general
Peter Korsgaard <jacmet@control.auc.dk> writes:
> I'm developing a SQL proxy and I would like to implement the server
> protocol used by Postgres, so the proxy may act like a PostgreSQL server
> towards the clients.

> I have read the nice and clean documentation of the protocol on
> http://www.postgresql.org/docs/programmer/protocol.htm, but instead of
> reimplementating the protocol I would like to reuse the current
> implementation.

I think you'd be better off coding from scratch.  The backend is built
on the model that it's in control and it can send off messages or bits
of messages whenever it feels like.  It's going to be very difficult to
adapt that code to a multi-client proxy server, even assuming you could
easily extract just the code that does communication --- but the forest
is rather thickly clustered around those trees ;-)

> As far as I can tell from the protocol specification and the description
> of how PostgreSQL processes a query (src/tools/backend/index.html) it is
> implemented in or around src/backend/postmaster/postmaster.c and
> src/backend/tcop/postgres.c - but I still have a bit of problems finding
> my way around the sourcecode.

postmaster.c and postgres.c are the outer loops, but they don't actually
do much of the message-slinging.  The low-level I/O code is in
backend/libpq.  The rest of the message processing is, um, hither and
yon.

            regards, tom lane

pgsql-general by date:

Previous
From: "Anders R. Sveen"
Date:
Subject: Re: Encoding
Next
From: Tom Lane
Date:
Subject: Re: Multiple Inheritance