• Tom Lane's avatar
    Handle corner cases correctly in psql's reconnection logic. · aef36238
    Tom Lane authored
    After an unexpected connection loss and successful reconnection,
    psql neglected to resynchronize its internal state about the server,
    such as server version.  Ordinarily we'd be reconnecting to the same
    server and so this isn't really necessary, but there are scenarios
    where we do need to update --- one example is where we have a list
    of possible connection targets and they're not all alike.
    
    Define "resynchronize" as including connection_warnings(), so that
    this case acts the same as \connect.  This seems useful; for example,
    if the server version did change, the user might wish to know that.
    An attuned user might also notice that the new connection isn't
    SSL-encrypted, for example, though this approach isn't especially
    in-your-face about such changes.  Although this part is a behavioral
    change, it only affects interactive sessions, so it should not break
    any applications.
    
    Also, in do_connect, make sure that we desynchronize correctly when
    abandoning an old connection in non-interactive mode.
    
    These problems evidently are the result of people patching only one
    of the two places where psql deals with connection changes, so insert
    some cross-referencing comments in hopes of forestalling future bugs
    of the same ilk.
    
    Lastly, in Windows builds, issue codepage mismatch warnings only at
    startup, not during reconnections.  psql's codepage can't change
    during a reconnect, so complaining about it again seems like useless
    noise.
    
    Peter Billen and Tom Lane.  Back-patch to all supported branches.
    
    Discussion: https://postgr.es/m/CAMTXbE8e6U=EBQfNSe01Ej17CBStGiudMAGSOPaw-ALxM-5jXg@mail.gmail.com
    aef36238
command.c 123 KB