Skip to main content

forward

Function forward 

Source
pub async fn forward(
    client: &mut Framed<TcpStream, FrontendCodec>,
    server: &mut ServerConn,
    pools: &Arc<PoolManager>,
) -> Result<()>
Expand description

Forward messages between client and server for the lifetime of the session.

Terminate from the client is intercepted so the server connection can be returned to the pool rather than closed.

One client owns the backend for the whole session, but the backend is reused by later sessions, so prepared statements still flow through halephant’s canonical-name rewriting. Forwarding client-chosen names (such as psycopg3’s _pg3_0, which restarts at 0 on every new connection) verbatim would collide with a name a previous session left prepared on that backend and draw 42P05 duplicate_prepared_statement. Rewriting every Parse to SHA-256(query, param_oids) makes the backend see only collision-free hashes; the per-backend cache that records them persists across sessions, while the per-client name map is dropped on disconnect.