Download PostgreSQL Programmer`s Guide The

Transcript
Chapter 25. Frontend/Backend Protocol
provisions for notification responses and command cancellation, which can occur at any time
after the startup phase.
Startup
Startup is divided into an authentication phase and a backend startup phase.
Initially, the frontend sends a StartupPacket. The postmaster uses this info and the contents of
the pg_hba.conf(5) file to determine what authentication method the frontend must use. The
postmaster then responds with one of the following messages:
ErrorResponse
The postmaster then immediately closes the connection.
AuthenticationOk
The postmaster then hands over to the backend. The postmaster takes no further part in
the communication.
AuthenticationKerberosV4
The frontend must then take part in a Kerberos V4 authentication dialog (not described
here) with the postmaster. If this is successful, the postmaster responds with an
AuthenticationOk, otherwise it responds with an ErrorResponse.
AuthenticationKerberosV5
The frontend must then take part in a Kerberos V5 authentication dialog (not described
here) with the postmaster. If this is successful, the postmaster responds with an
AuthenticationOk, otherwise it responds with an ErrorResponse.
AuthenticationUnencryptedPassword
The frontend must then send an UnencryptedPasswordPacket. If this is the correct
password, the postmaster responds with an AuthenticationOk, otherwise it responds with
an ErrorResponse.
AuthenticationEncryptedPassword
The frontend must then send an EncryptedPasswordPacket. If this is the correct password,
the postmaster responds with an AuthenticationOk, otherwise it responds with an
ErrorResponse.
If the frontend does not support the authentication method requested by the postmaster, then it
should immediately close the connection.
After sending AuthenticationOk, the postmaster attempts to launch a backend process. Since
this might fail, or the backend might encounter a failure during startup, the frontend must wait
for the backend to acknowledge successful startup. The frontend should send no messages at
this point. The possible messages from the backend during this phase are:
BackendKeyData
This message is issued after successful backend startup. It provides secret-key data that
the frontend must save if it wants to be able to issue cancel requests later. The frontend
204