Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 817BF9FA3A7 for ; Fri, 10 Nov 2006 12:14:10 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 80400-03 for ; Fri, 10 Nov 2006 16:13:56 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id E7BB29FB2F1 for ; Fri, 10 Nov 2006 12:13:55 -0400 (AST) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 1992830E1A; Fri, 10 Nov 2006 17:13:55 +0100 (MET) From: Stijn Vanroye X-Newsgroups: pgsql.interfaces.odbc Subject: Curious Join issue causing an E_FAIL error (with odbc version 8.2.2.0) Date: Fri, 10 Nov 2006 17:08:27 +0100 Organization: Easy to Work Lines: 56 Message-ID: Reply-To: s.vanroye@easytowork.nl Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@news.hub.org User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) To: pgsql-odbc@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/28 X-Sequence-Number: 8410 Hi List, I have experienced a strange issue today: when executing a query with a 3-level join in it I got an E_FAIL error in my client software. I did manage to "fix" it but I still find it strange. Suppose you have the following situation: there are three tables A,B and C (quite dumb names I know) and the following query: select , C.id from A left join B on (A.fkB_id=B.id) left join C on (b.fkC_id=C.id) The above query produces the error. With some trial and error I managed to avoid the error by ommitting the C.id field from the select. Of course this is hardly a solution since I need those values ;) The next thing I tried was replace the C.id field with B.fkC_id (which have the same value since they form the join condition). No more error... Do note that with the specific data in the test case there where no records in the C table matching the join condition (since this can happen is the reason why a left join is used). It seems that in this particular case the problem is solved, but it still doesn't explain why the original query did run correctly with the odbc driver version 8.1.x. Browsing the logfiles I concluded that the ODBC did pull the data from the back-end using the first query. I have tried with both the 8.1.4 and 8.1.5 version of postgres. My conclusion is that there is some issue with the odbc 8.2.x tree that doesn't allow to use the C.id field in the select. Maybe related with the fact that there are no records matching the join in the C table. Unfortunatly I don't have the luxury of time to pursue this issue any further at the moment. Despite my conclusion beïng somewhat vague ;) I post this in the hope that somebody has seen something similar or can give a little less vague conclusion... To be honest, I am a bit afraid I might be confronted with the same problem later on. Sincerly, Stijn Vanroye www.xillion.nl www.easytowork.nl