Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T7jsG-0008Ee-MB for pgsql-odbc@postgresql.org; Sat, 01 Sep 2012 09:20:16 +0000 Received: from sd.tpf.co.jp ([210.161.239.34]) by makus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1T7jsE-0002UI-IX for pgsql-odbc@postgresql.org; Sat, 01 Sep 2012 09:20:15 +0000 Received: (qmail 26476 invoked by uid 512); 1 Sep 2012 09:20:11 -0000 X-Authentication: inoue was authenticated by sd.tpf.co.jp at 1 Sep 2012 09:20:11 -0000 Received: from unknown (HELO ?192.168.2.100?) (183.76.21.62) by sd.tpf.co.jp with SMTP; 1 Sep 2012 09:20:11 -0000 Message-ID: <5041D33B.7020509@tpf.co.jp> Date: Sat, 01 Sep 2012 18:19:55 +0900 From: Hiroshi Inoue User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: Boszormenyi Zoltan CC: Hiroshi Saito , pgsql-odbc@postgresql.org, =?ISO-8859-2?Q?Hans-J=FCrgen_Sch=F6nig?= Subject: Re: Error reporting goes into an infinite loop when compiled --with-odbcver=0x0250 References: <50409E40.10803@cybertec.at> In-Reply-To: <50409E40.10803@cybertec.at> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.1 (--) X-Archive-Number: 201209/1 X-Sequence-Number: 10940 Hi, (2012/08/31 20:21), Boszormenyi Zoltan wrote: > Hi, > > we had to recently test psqlODBC with an older application > which doesn't expect ODBC 3.x. > > The problem is that the client locks up as soon as it encounters > an error of any kind, like restarting the server from under the client > or simply executing a bad query. > > After debugging the problem and reading the code of both > unixODBC 2.3.1 and psqlODBC (version 09.00.0310 and 09.01.0200), > I discovered that the DriverManager calls the driver's SQLError() > and SQLGetDiagRec() in a loop Does the DriverManager call both SQLError() and SQLGetDiagRec()? Could you send me (loop part of) the Mylog output? regards, Hiroshi Inoue > and expects it to return the error > message in pieces and when there is nothing left to return, > these driver methods must return some SQL error instead of > SQL_SUCCESS[_WITH_INFO]. SQLGetDiagRec() does this properly > because the DriverManager keeps track of the pieces via the > RecNumber argument but SQLError() calls PGAPI_StmtError() > with RecNumber == -1 every time. Instead, it uses the internal > error structure to keep track of the string left to return. SQLError() > calls PGAPI_StmtError() with > flag = PODBC_ALLOW_PARTIAL_EXTRACT | PODBC_ERROR_CLEAR > which means that ER_ReturnError() may free the error structure. > > The interaction between the looping and the freeing of the error > structure is buggy, the error makes it go into an infinite loop. > > The attached patch fixes this problem. Though, I am not sure about > whether the (stapos > msglen) and (error->errorpos >= msglen) > checks are redundant or not. > > Best regards, > Zoltán Böszörményi