Curious Join issue causing an E_FAIL error (with odbc version 8.2.2.0)

Curious Join issue causing an E_FAIL error (with odbc version 8.2.2.0)

am 10.11.2006 17:08:27 von Stijn Vanroye

Hi List,

I have experienced a strange issue today: when executing a query with a=20
3-level join in it I got an E_FAIL error in my client software. I did=20
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=3DB.id)
left join C on (b.fkC_id=3DC.id)

The above query produces the error.
With some trial and error I managed to avoid the error by ommitting the=20
C.id field from the select. Of course this is hardly a solution since I=20
need those values ;)

The next thing I tried was replace the C.id field with B.fkC_id (which=20
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=20
records in the C table matching the join condition (since this can=20
happen is the reason why a left join is used).

It seems that in this particular case the problem is solved, but it=20
still doesn't explain why the original query did run correctly with the=20
odbc driver version 8.1.x.

Browsing the logfiles I concluded that the ODBC did pull the data from=20
the back-end using the first query. I have tried with both the 8.1.4 and=20
8.1.5 version of postgres.

My conclusion is that there is some issue with the odbc 8.2.x tree that=20
doesn't allow to use the C.id field in the select. Maybe related with=20
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=20
further at the moment. Despite my conclusion be=EFng somewhat vague ;) I=20
post this in the hope that somebody has seen something similar or can=20
give a little less vague conclusion... To be honest, I am a bit afraid I=20
might be confronted with the same problem later on.

Sincerly,

Stijn Vanroye

www.xillion.nl
www.easytowork.nl

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Re: Curious Join issue causing an E_FAIL error (with odbc version 8.2.2.0)

am 10.11.2006 17:21:55 von Tom Lane

Stijn Vanroye writes:
> 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...

Um, well no they don't necessarily have the same value. Since it's a
left join, C.id might read as null.

Perhaps your E_FAIL was a consequence of some bit of your code not being
prepared to cope with a NULL value?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Re: Curious Join issue causing an E_FAIL error (with odbc version

am 10.11.2006 17:55:19 von Stijn Vanroye

Tom Lane schreef:
> Stijn Vanroye writes:
>> 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...
>
> Um, well no they don't necessarily have the same value. Since it's a
> left join, C.id might read as null.
You are right, I stand corrected (and ashamed). I think that in my
specific case and use of the data this is not a problem, but I will have
to check into that to make sure!

>
> Perhaps your E_FAIL was a consequence of some bit of your code not being
> prepared to cope with a NULL value?
I don't think that's the case. My code never came into play. I am using
ADO components in delphi, maybe there is a problem with coping with null
values. But, the code for these components is completely unchanged
troughout all my tests (actually I think it hasn't changed since the
dawn of man ;) ). In fact, all my software, as well as the data and
where conditions have been exactly the same with every test case. With
no changes to the query, code, data or where conditions the error
manifested itself with the driver version 8.2.x, while it didn't occured
when using the 8.1.x driver.


Regards,

Stijn Vanroye

www.xillion.nl
www.easytowork.nl

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Re: Curious Join issue causing an E_FAIL error (with odbc version

am 10.11.2006 19:55:46 von Tom Lane

Stijn Vanroye writes:
> ... With no changes to the query, code, data or where conditions the error
> manifested itself with the driver version 8.2.x, while it didn't occured
> when using the 8.1.x driver.

Well, that could be a driver bug, but you'll need to put together a
self-contained test case if you want anyone to look very hard for it.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Re: Curious Join issue causing an E_FAIL error (with odbc

am 13.11.2006 05:48:22 von Hiroshi Inoue

Stijn Vanroye wrote:
> 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.

Could you show me the whole code ?

regards,
Hiroshi Inoue

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Re: Curious Join issue causing an E_FAIL error (with odbc

am 13.11.2006 09:42:44 von Stijn Vanroye

Tom Lane schreef:
> Well, that could be a driver bug, but you'll need to put together a
> self-contained test case if you want anyone to look very hard for it.
Tom, what is desirable for the people on the list in terms of a
self-containted test case? Any specific requirements conscerning the
set-up or output of the test case?

Hiroshi Inoue schreef:
> Could you show me the whole code ?

This is not a query I wrote, so I haven't looked into why everyting is
as it is. In the select are some commented lines. That's the interesting
region, as well as the related left joins. I can't post all the table
definitions, but if you have a question about a field type or such, just
ask.

select
dbu_field.field_id,
dbu_field.fieldname,
dbu_field.length,
dbu_field."precision",
dbu_field.lookupclass_id,
dbu_field.lookupkeyfield_id,
dbu_field.lookupvaluefield_id,
dbu_field.agtype_id,
dbu_field.sql_filter,
dbu_field.sql_code,
lookupobject.classname as lookupobject,
lookuptable.tablename as lookuptable,
--original line
--lookuptable.table_id as lookuptable_id,
--new line
lookupobject.table_id as lookuptable_id,
lookupkeyfield.fieldname as lookupkeyfield,
lookupvaluefield.fieldname as lookupvaluefield,
agtype.description as agtype
from
dbu_field
left join dbu_class as lookupobject on
(dbu_field.lookupclass_id=lookupobject.class_id)
left join dbu_table as lookuptable on
(lookupobject.table_id=lookuptable.table_id)
left join dbu_field as lookupkeyfield on
(lookupkeyfield.field_id=dbu_field.lookupkeyfield_id)
left join dbu_field as lookupvaluefield on
(lookupvaluefield.field_id=dbu_field.lookupvaluefield_id)
left join dbu_agtype as agtype on (agtype.agtype_id=dbu_field.agtype_id)
where
dbu_field.class_id=123
order by
dbu_field.fieldorder;


Regards,

Stijn.

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Re: Curious Join issue causing an E_FAIL error (with odbc

am 13.11.2006 10:21:17 von Hiroshi Inoue

Stijn Vanroye wrote:
> Tom Lane schreef:
> > Well, that could be a driver bug, but you'll need to put together a
> > self-contained test case if you want anyone to look very hard for it.
> Tom, what is desirable for the people on the list in terms of a
> self-containted test case? Any specific requirements conscerning the
> set-up or output of the test case?
>
> Hiroshi Inoue schreef:
>> Could you show me the whole code ?
>
> This is not a query I wrote, so I haven't looked into why everyting is
> as it is. In the select are some commented lines. That's the interesting
> region, as well as the related left joins. I can't post all the table
> definitions, but if you have a question about a field type or such, just
> ask.

What I meant is the program not the query only.
Hmm could send me directly the Mylog output ?

regards,
Hiroshi Inoue

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Re: Curious Join issue causing an E_FAIL error (with odbc

am 13.11.2006 17:51:18 von Stijn Vanroye

Hiroshi Inoue schreef:
> Stijn Vanroye wrote:
>> Tom Lane schreef:
>> > Well, that could be a driver bug, but you'll need to put together a
>> > self-contained test case if you want anyone to look very hard for it.
>> Tom, what is desirable for the people on the list in terms of a
>> self-containted test case? Any specific requirements conscerning the
>> set-up or output of the test case?
>>
>> Hiroshi Inoue schreef:
>>> Could you show me the whole code ?
>>
>> This is not a query I wrote, so I haven't looked into why everyting is
>> as it is. In the select are some commented lines. That's the
>> interesting region, as well as the related left joins. I can't post
>> all the table definitions, but if you have a question about a field
>> type or such, just ask.
>
> What I meant is the program not the query only.
> Hmm could send me directly the Mylog output ?
I would love to send you the MyLog output, only it's 23Mb. I can't
exactly say which part of it is important or not, due to lack of experience.
I will, however, upload it to one of our server and send you the link
off-list.

Kind regards,

Stijn Vanroye.

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Re: Curious Join issue causing an E_FAIL error (with odbc version

am 16.11.2006 17:55:14 von Stijn Vanroye

Since I have been communicating off-list with Hiroshi I am posting the
outcome of the problem here:

The cause for the behaviour had to do with a small bug in the driver.
This bug is however solved in the latest snapshot (8.2.0201).


Regards,

Stijn Vanroye.

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster