|
Home > Archive > PostgreSQL JDBC > December 2005 > Re: an efficient way of checking if the connection to a db
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: an efficient way of checking if the connection to a db
|
|
| Kris Jurka 2005-12-15, 8:25 pm |
|
On Thu, 15 Dec 2005, Tom Lane wrote:
> It probably is. However, sending an empty query string to the backend
> to execute ought to be competitive with a bare Sync. libpq supports
> that; does JDBC?
You can say Statement.execute(""), but that still does the full extended
query protocol setup:
14:25:48.375 (1) FE=> Parse(stmt=null,quer
y="",oids={})
14:25:48.377 (1) FE=> Bind(stmt=null,porta
l=null)
14:25:48.378 (1) FE=> Describe(portal=null
)
14:25:48.378 (1) FE=> Execute(portal=null,
limit=0)
14:25:48.378 (1) FE=> Sync
14:25:48.379 (1) <=BE ParseComplete [null]
14:25:48.380 (1) <=BE BindComplete [null]
14:25:48.380 (1) <=BE NoData
14:25:48.380 (1) <=BE EmptyQuery
14:25:48.381 (1) <=BE ReadyForQuery(I)
Testing this with the V2 protocol reveals an issue, but it looks like
the server's fault.
14:33:42.550 (1) FE=> Query("")
14:33:42.550 (1) <=BE EmptyQuery
At this point the driver is waiting for ReadyForQuery, but the server is
waiting for another query. The documentation states, "If a completely
empty (no contents other than whitespace) query string is received, the
response is EmptyQueryResponse followed by ReadyForQuery."
Kris Jurka
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq
| |
| Tom Lane 2005-12-15, 8:25 pm |
| Kris Jurka <books@ejurka.com> writes:
> Testing this with the V2 protocol reveals an issue, but it looks like
> the server's fault.
> 14:33:42.550 (1) FE=> Query("")
> 14:33:42.550 (1) <=BE EmptyQuery
> At this point the driver is waiting for ReadyForQuery, but the server is
> waiting for another query.
I think you've got a problem on the driver side.
Here, strace'ing a program doing PQexec(conn, "") shows:
17:53:33.677241 send(3, "Q\0\0\0\5\0", 6, 0) = 6
....
17:53:33.678085 recv(3, "I\0\0\0\4Z\0\0\0\5I", 16384, 0) = 11
which looks like EmptyQueryResponse followed by ReadyForQuery to me.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq
|
|
|
|
|