pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: Craig Ringer <craig@2ndquadrant.com>
To: pgsql-odbc@postgresql.org <pgsql-odbc@postgresql.org>
Subject: Re: Protocol de-synchronisation bug, bogus query sent
Date: Thu, 19 Jun 2014 13:32:45 +0300
Message-ID: <53A2BC4D.2030503@vmware.com> (raw)
In-Reply-To: <53A25C95.707@2ndquadrant.com>
References: <53A25C95.707@2ndquadrant.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>

On 06/19/2014 06:44 AM, Craig Ringer wrote:
> The whole code block around connection.c:3082 appears to be attempting
> to send an empty query in order to elicit an 'I' (EmptyQueryResponse)
> message. It sends a malformed protocol message:
>
>      SOCK_put_string(self->sock, "Q ");
>      SOCK_flush_output(self->sock);
>
> so the server just waits for the rest of the message, never responding.
>
> When the connection is killed by program exit later, the server will log:
>
> LOG:  unexpected EOF within message length word
> LOG:  disconnection: session time: 0:00:08.910 user=Administrator
> database=XXXX host=127.0.0.1 port=53705
> LOG:  could not receive data from client: No connection could be made
> because the target machine actively refused it.
>
>
> That's because the V3 protocol specifies that the message format for
> Query is:
>
> 'Q'
> [32 bit integer]
> [query string]
>
> http://www.postgresql.org/docs/current/static/protocol-message-formats.html
>
> ... but psqlODBC just sends:
>
> 'Q'
> '\x20'
> '\x00'
>
> If it is really necessary to go through this empty-query dance, then for
> the V3 protocol the correct message would be:
>
> /* Send an empty query to elicit an 'I' (EmptyQueryResponse)
>   * from the server */
> SOCK_put_char(self->sock, 'Q');
> SOCK_put_int(self->sock, 5, 4);
> SOCK_put_char(self->sock, '\0');

Hmm. Just before that code, there's this:

>  if (!beforeV2)
>      break;

So we shouldn't even get there with protocol version 3. But if you 
managed to hit that, apparently we do. Can you debug that further?
- Heikki


-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



view thread (11+ messages)  latest in thread

Message-ID: <53A2BC4D.2030503@vmware.com>
Permalink:  ../53A2BC4D.2030503@vmware.com/
Also on:    postgresql.org/message-id/53A2BC4D.2030503@vmware.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: hlinnakangas@vmware.com, craig@2ndquadrant.com
  Subject: Re: Protocol de-synchronisation bug, bogus query sent
  In-Reply-To: <53A2BC4D.2030503@vmware.com>
  References: <53A25C95.707@2ndquadrant.com> <53A2BC4D.2030503@vmware.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox