Strange selectall_hashref/fetchall_hashref problem with DBD::mysql

Strange selectall_hashref/fetchall_hashref problem with DBD::mysql

am 10.02.2006 13:04:33 von Martin.Evans

Hi,

selectall_hashref and fetchall_hashref work fine for me most of the time but
I've hit a scenario where I get a result I just cannot fathom.

I'm using DBI 1.50 and DBD::mysql 3.0002_4 (with a few minor patches I posted
on this list to make it compile and get rid of the FREE UNBIND problem I had).

I have tables:

race
race_id primary key auto increment
meeting_id foreign key to meeting_id in meeting

meeting
meeting_id primary key auto increment
created_date_time_utc datetime

(there are other columns but they are not referenced).

I do:

SELECT m.meeting_id,r.race_id FROM meeting m, race r where
r.meeting_id = m.meeting_id and
DATEDIFF('2006-02-10', DATE(m.created_date_time_utc)) <= 100

and dump the reference returned by selectall_hashref(race_id) or
fetchall_hashref(race_id) and get:

$VAR1 = {
'' => {
'race_id' => undef,
'meeting_id' => undef
}
};

The query does return rows. I know because:
1) if I change to use prepare/execute/fetchrow_array I can the rows
back
2) if I leave it as fetchall_hashref/selectall_hashref and set
DBI_TRACE to 20 I can see my data in the trace.

I can also change nothing other than switch to DBD::ODBC (and the myodbc
driver) and it works fine.

The interesting bit is if all I do is take the
"DATEDIFF('2006-02-10', DATE(m.created_date_time_utc)) <= 100" out of
the where clause it works, even though this makes no difference
I can see to either the number of rows returned, the column names or
result-set content. Unfortunatly the trace at level 20 is 120K.

I've tried reproducing with other tables which are more simple but
failed - the above is as simple as I can get it and fail.

Any ideas?

Martin
--
Martin J. Evans
Easysoft Ltd, UK
http://www.easysoft.com