Re: [HACKERS] Re: SIGPIPE gripe

From: Peter T Mount <psqlhack(at)retep(dot)org(dot)uk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] Re: SIGPIPE gripe
Date: 1998-05-04 19:51:06
Message-ID: Pine.LNX.3.95.980504204642.27875A-100000@retep.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 4 May 1998, Tom Lane wrote:

[snip]

> Meanwhile, once the client receives the "AUTH OK" it initiates
> an empty query cycle (which is commented as intending to discover
> whether the database exists!):
>
> ...
>
> Client receives "AUTH_OK"
>
> Client sends "Q " query
>
> Client waits for response
>
> The problem, of course, is that if the backend manages to exit
> before the client gets to send its empty query, then the client
> is writing on a closed connection. Boom, SIGPIPE.

[snip]

> So ... since we're altering the protocol anyway ... the right fix is
> to alter the protocol a little more. Remember that "Z" message that
> the backend is now sending at the end of every query cycle? What
> we ought to do is make the BE send "Z" at completion of startup,
> as well. (In other words, "Z" will really mean "Ready for Query"
> rather than "Query Done". This is actually easier to implement in
> postgres.c than the other way.) Now the client's startup procedure
> looks like
>
> ...
>
> Client receives "AUTH_OK"
>
> Client waits for "Z" ; if get "E" instead, BE startup failed.

This sounds fair enough. Infact we could then throw a more meaningful
error message when this occurs.

> I suspect it's not really necessary to do an empty query after this,
> but we may as well leave that in there for additional reliability.

In JDBC, I replaced (back in 6.2) the empty query with one to get the
current DateStyle (which the driver then uses to handle dates correctly).

--
Peter T Mount peter(at)retep(dot)org(dot)uk or petermount(at)earthling(dot)net
Main Homepage: http://www.retep.org.uk
************ Someday I may rebuild this signature completely ;-) ************
Work Homepage: http://www.maidstone.gov.uk Work EMail: peter(at)maidstone(dot)gov(dot)uk

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jackson, DeJuan 1998-05-04 20:41:56 RE: [QUESTIONS] Best way to halt an unending query.
Previous Message Jackson, DeJuan 1998-05-04 19:32:39 RE: [QUESTIONS] COUNT (DISTINCT xxx) ?