Subject: Add "host" to startup packet

From: Lev Kokotov <[email-masked]>
Date: Fri, 31 Mar 2023 17:23:28 -0700

Hello,

Patch attached below. TLDR, I'd like to add "host" to the startup packet.

I'm trying to run multiple Postgres servers in a multi-tenant environment
behind a pooler <https://github.com/postgresml/pgcat>. Currently, the only
way to differentiate Postgres databases is with the user/dbname combination
which are very often included in the startup packet by the client. However,
that's not sufficient if you have users that all want to have the user
"admin" and the database "production" :)

HTTP hosting providers solved this using the "Host" header, allowing the
server to identify which website the client wants. In the case of Postgres,
this is the DNS or IP address, depending on the client configuration.

Upon receiving a startup packet with user, dbname, and host, the pooler
(acting also as a proxy) can validate that the credentials exist for the
host and that they are valid, and authorize or decline the connection.

I have never submitted a patch for Postgres before, so I'm not entirely
sure how to test this change, although it seems pretty harmless. Any
feedback and help are appreciated!

Thank you!

Best,
Lev

---

From: Tom Lane <[email-masked]>
Date: Sun, 02 Apr 2023 11:38:25 -0400

> Patch attached below. TLDR, I'd like to add "host" to the startup packet.

I don't think this is of any use at all in isolation.  What is the server
going to do with it?  What's your plan for persuading clients other than
libpq to supply it?  How are poolers supposed to handle it?  What will
you do about old clients that don't supply it?  And most importantly,
how can a client know while connecting whether it's safe to include this,
realizing that existing servers will error out (they'll think it's a
GUC setting for "host")?

Even if all that infrastructure sprang into existence, is this really any
more useful than basing your switching on the host's resolved IP address?
I'm doubtful that there's enough win there to justify pushing this rock
to the top of the mountain.

			regards, tom lane