Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wxo3L-0002Pw-T7 for pgsql-odbc@arkaria.postgresql.org; Fri, 20 Jun 2014 01:55:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wxo3L-0005LU-4x for pgsql-odbc@arkaria.postgresql.org; Fri, 20 Jun 2014 01:55:43 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Wxo3K-0005LN-3N for pgsql-odbc@postgresql.org; Fri, 20 Jun 2014 01:55:42 +0000 Received: from mout.kundenserver.de ([212.227.17.10]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Wxo3G-0002j6-SP for pgsql-odbc@postgresql.org; Fri, 20 Jun 2014 01:55:40 +0000 Received: from ayaki.localdomain (106-69-84-43.dyn.iinet.net.au [106.69.84.43]) by mrelayeu.kundenserver.de (node=mreue105) with ESMTP (Nemesis) id 0MWzzA-1XCBfv0RKm-00W2Ai; Fri, 20 Jun 2014 03:55:36 +0200 Message-ID: <53A39493.5030104@2ndquadrant.com> Date: Fri, 20 Jun 2014 09:55:31 +0800 From: Craig Ringer Organization: 2nd Quadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Hiroshi Inoue CC: "pgsql-odbc@postgresql.org" Subject: Re: Protocol de-synchronisation bug, bogus query sent References: <53A25C95.707@2ndquadrant.com> <53A26635.4030200@tpf.co.jp> <53A26D79.1070601@2ndquadrant.com> <53A27CF8.9090504@2ndquadrant.com> <53A2D2AB.8050109@tpf.co.jp> <53A3805C.7010800@2ndquadrant.com> In-Reply-To: <53A3805C.7010800@2ndquadrant.com> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------090006020208070601080808" X-Provags-ID: V02:K0:1GahvVrNf4RIPZGH0xDx0mEeRuXL7/4VsUKUylJdSQi mqx4zUwEuuk3h7G98l5w43fvr37FE9mmzJtpH2UtCm2/7BzlFq /lGJXhgfd+aL95r5iIsmXlKbUDRChA2bcSs1fDnDMGN/xtp6WC vkSA3z9L/NdBy8II7OZNYbdFwmbXa1wKyJ6UuV+vum5YDpU7vm iSSv5O3f/ZXl15q1SqSz050oFGRrSNaCqF2j2ScSDvPdGvgHQV ftf8DjYcd6G1n0TmYfSFmQ8GN1YV6lnqCC/Pneq/HvnhQCBMqP ZY5yWw4nwBd/RHTa4vzalnnuW9JE11xw+LNG8O1aba5rg5zGON BgrR3BlPxacX6Z9bV2XmEYnUmKxkfSfJBsmigDbgO X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org This is a multi-part message in MIME format. --------------090006020208070601080808 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 06/20/2014 08:29 AM, Craig Ringer wrote: > On 06/19/2014 08:08 PM, Hiroshi Inoue wrote: >> (2014/06/19 11:47), Craig Ringer wrote: >>> On 06/19/2014 12:56 PM, Craig Ringer wrote: >>>> >>>> and we're attempting to use the version obtained from the server before >>>> we have it, instead of the conninfo-specified version to use for >>>> protocol selection purposes. >>> >>> The attached patch fixes this. >> >> Thanks. >> I would also check the source of this trouble. > > Huh? > > That _is_ the source of this trouble. Some code that runs during > connection setup, before the server version is available, tries to use > the version obtained from the server instead of the protocol version > requested in the conninfo. Just to clarify, only the 0002 patch is required. My branch at: https://github.com/ringerc/psqlodbc/tree/fix-febe-protocol-desync-emptyquery only contains the second patch. I've attached a revised version that should make that clearer. Please apply / pull. -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services --------------090006020208070601080808 Content-Type: text/x-patch; name="0001-Fix-use-of-server-queried-version-before-connection.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Fix-use-of-server-queried-version-before-connection.pat"; filename*1="ch" From a0a21dc691e580302f4109cfe3a9b9dd7f7b39ce Mon Sep 17 00:00:00 2001 From: Craig Ringer Date: Thu, 19 Jun 2014 13:56:57 +0800 Subject: [PATCH] Fix use of server-queried version before connection psqlODBC attempted to use the version that's queried from the server before it was obtained from the server during the connection setup. Because the server version is initialized to 0.0, tests for "server version >= 7.4" or "server version >= 6.4" using the PG_VERSION_LT macro were always returning false. Instead, use PROTOCOL_64 and PROTOCOL_74 tests against conninfo. These don't offer any "greater than" form, so just test both. There's little point adding anything prettier when it can all be removed when v1/v2 protocol support is removed soon anyway. The main symptom of this issue was that psqlODBC was sending an invalid protocol message for the v3 protocol, "Q \0", causing the server to wait for the second half of the length word forever. At connection close, the server would emit: unexpected EOF within message length word This issue was observed while tracking down problems with XA transactions in MSDTC failing to commit after a successful prepare because an isolated tx created via getLockedXAConn() got stuck here, but is not confined to that problem. --- connection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connection.c b/connection.c index 52f5463..c6ff21e 100644 --- a/connection.c +++ b/connection.c @@ -2747,7 +2747,7 @@ CC_send_query_append(ConnectionClass *self, const char *query, QueryInfo *qi, UD empty_reqs; BOOL ReadyToReturn = FALSE, query_completed = FALSE, - beforeV2 = PG_VERSION_LT(self, 6.4), + beforeV2 = !(PROTOCOL_64(&self->connInfo) || PROTOCOL_74(&self->connInfo)), aborted = FALSE, used_passed_result_object = FALSE, discard_next_begin = FALSE, -- 1.9.0 --------------090006020208070601080808 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc --------------090006020208070601080808--