pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Boszormenyi Zoltan <zb@cybertec.at>
To: Hiroshi Inoue <inoue@tpf.co.jp>
Cc: Hiroshi Saito <hiroshi@winpg.jp>
Cc: pgsql-odbc@postgresql.org, Hans-Jürgen Schönig <hs@cybertec.at>
Subject: Re: Error reporting goes into an infinite loop when compiled --with-odbcver=0x0250
Date: Sun, 09 Sep 2012 09:55:11 +0200
Message-ID: <504C4B5F.6080606@cybertec.at> (raw)
In-Reply-To: <504A8867.7020103@tpf.co.jp>
References: <50409E40.10803@cybertec.at>
	<5041D33B.7020509@tpf.co.jp>
	<5042284C.1000105@cybertec.at>
	<50424250.602@cybertec.at>
	<504A8867.7020103@tpf.co.jp>

Hi,

2012-09-08 01:51 keltezéssel, Hiroshi Inoue írta:
> Hi,
>
> Sorry for the late reoly.

no problem, it seems you didn't receive the personal copies of
my mails. There seems to be a problem with reverse DNS
on your side of the of the globe, I got this for the mails in which
I sent the attachments:

---8<------8<------8<------8<------8<---

                    The mail system

<hiroshi@winpg.jp>: host winpg.jp[219.94.251.195] said: 450 4.7.1 Client host
     rejected: cannot find your hostname, [87.118.86.135] (in reply to RCPT TO
     command)
  

Reporting-MTA: dns; km31432.keymachine.de
X-Postfix-Queue-ID: 23F503900523
X-Postfix-Sender: rfc822;zb@cybertec.at
Arrival-Date: Fri, 31 Aug 2012 11:21:41 +0000 (UTC)

Final-Recipient: rfc822;hiroshi@winpg.jp
Original-Recipient:rfc822;hiroshi@winpg.jp
Action: failed
Status: 4.7.1
Remote-MTA: dns; winpg.jp
Diagnostic-Code: smtp; 450 4.7.1 Client host rejected: cannot find your
     hostname, [87.118.86.135]

---8<------8<------8<------8<------8<---

> (2012/09/02 2:13), Boszormenyi Zoltan wrote:
>> Hi,
>>
>> 2012-09-01 17:22 keltezéssel, Boszormenyi Zoltan írta:
>>> Hi,
>>>
>>> 2012-09-01 11:19 keltezéssel, Hiroshi Inoue írta:
>>>> 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()?
>>>
>>> Yes, it detects which is supported and calls that in the error handler
>>> part
>>> of SQLExecute(). In case psqlODBC is compiled using
>>> --with-odbcver=0x0250,
>>> SQLGetDiagRec() is naturally not supported.
>>>
>>>> Could you send me (loop part of) the Mylog output?
>>>
>>> I attached the unixODBC tracefile (/tmp/Trace.txt), there is no "mylog"
>>> lines in it. I execute a single "select * from test;" and this table
>>> doesn't exist.
>>> The trace file shows that the error code is repeated ad infinitum.
>>>
>>> But for my debugging, I didn't use the ODBC tracing, I added my extra
>>> printf()s
>>> so I can see on the client terminal what is going on.
>>
>> Attached is the mylog output for the vanilla psqlODBC 09.01.0200
>> which also shows the infinite loop.
>
> Thanks.
>
> Clearing error info seems to cause the infinite loop.
>
> Simply removing the follwoing code would solve the bug.
> COuld you try it?
>
>         if (error->errorpos >= msglen)
>         {
>             ER_Destructor(error);
>             *pgerror = NULL;
>         }

Yes, it also solved the infinite loop. But then using the
PODBC_ERROR_CLEAR flag in PGAPI_Error() is unneeded.
Nothing else checks for this flag. Attached is the new patch,
tested with Valgrind, no leaks found in psqlodbc. The only
leaks reported were inside isql and libreadline.

>
> regards,
> Hiroshi Inoue
>
>
>


-- 
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
      http://www.postgresql.at/

Attachments:

psqlodbc-odbc2.5-fix1.patch (text/x-patch, 1.2K) download --- psqlodbc-09.01.0200/environ.c.old 2010-08-21 08:29:19.000000000 +0200 +++ psqlodbc-09.01.0200/environ.c 2012-09-09 08:37:38.055625304 +0200 @@ -194,8 +194,7 @@ CSTR func = "ER_ReturnError"; /* CC: return an error of a hstmt */ PG_ErrorInfo *error; - BOOL partial_ok = ((flag & PODBC_ALLOW_PARTIAL_EXTRACT) != 0), - clear_str = ((flag & PODBC_ERROR_CLEAR) != 0); + BOOL partial_ok = ((flag & PODBC_ALLOW_PARTIAL_EXTRACT) != 0); const char *msg; SWORD msglen, stapos, wrtlen, pcblen; @@ -259,15 +258,9 @@ strncpy_null(szSqlState, error->sqlstate, 6); mylog(" szSqlState = '%s',len=%d, szError='%s'\n", szSqlState, pcblen, szErrorMsg); - if (clear_str) - { - error->errorpos = stapos + wrtlen; - if (error->errorpos >= msglen) - { - ER_Destructor(error); - *pgerror = NULL; - } - } + + error->errorpos = stapos + wrtlen; + if (wrtlen == 0) return SQL_SUCCESS_WITH_INFO; else @@ -482,7 +475,7 @@ SQLSMALLINT FAR * pcbErrorMsg) { RETCODE ret; - UWORD flag = PODBC_ALLOW_PARTIAL_EXTRACT | PODBC_ERROR_CLEAR; + UWORD flag = PODBC_ALLOW_PARTIAL_EXTRACT; mylog("**** PGAPI_Error: henv=%p, hdbc=%p hstmt=%d\n", henv, hdbc, hstmt);

view thread (6+ messages)

Message-ID: <504C4B5F.6080606@cybertec.at>
Permalink:  ../504C4B5F.6080606@cybertec.at/
Also on:    postgresql.org/message-id/504C4B5F.6080606@cybertec.at

 ·  · 

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: zb@cybertec.at, inoue@tpf.co.jp, hiroshi@winpg.jp, hs@cybertec.at
  Subject: Re: Error reporting goes into an infinite loop when compiled --with-odbcver=0x0250
  In-Reply-To: <504C4B5F.6080606@cybertec.at>
  References: <50409E40.10803@cybertec.at> <5041D33B.7020509@tpf.co.jp> <5042284C.1000105@cybertec.at> <50424250.602@cybertec.at> <504A8867.7020103@tpf.co.jp> <504C4B5F.6080606@cybertec.at>

* 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