Subject: | DBD::mysql - Unknown column 'foo' in 'where clause' |
Hi,
This patch is a workaround for a DBD::mysql or MySQL issue. The issue
is if a placeholder is "primed" using an integer-type value, and then later used with a string, the placeholder expansion is broken.
For more details on the MySQL issue, see:
http://marc.theaimsgroup.com/?l=msql-mysql-modules&m=103014432822561&w=2
This manifests itself if you use both integers and strings as session IDs with Apache::Session. The workaround included in the patch is to explicitly set the datatype to DBI::SQL_VARCHAR.
-TJ
--- /home/tjmather/Apache-Session-1.54/Session/Store/DBI.pm 2000-07-24 12:01:31.000000000 -0400
+++ DBI.pm 2002-11-14 16:33:09.000000000 -0500
@@ -36,7 +36,7 @@
INSERT INTO sessions (id, a_session) VALUES (?,?)});
}
- $self->{insert_sth}->bind_param(1, $session->{data}->{_session_id});
+ $self->{insert_sth}->bind_param(1, $session->{data}->{_session_id}, DBI::SQL_VARCHAR);
$self->{insert_sth}->bind_param(2, $session->{serialized});
$self->{insert_sth}->execute;
@@ -60,7 +60,7 @@
}
$self->{update_sth}->bind_param(1, $session->{serialized});
- $self->{update_sth}->bind_param(2, $session->{data}->{_session_id});
+ $self->{update_sth}->bind_param(2, $session->{data}->{_session_id}, DBI::SQL_VARCHAR);
$self->{update_sth}->execute;
@@ -81,7 +81,7 @@
SELECT a_session FROM sessions WHERE id = ?});
}
- $self->{materialize_sth}->bind_param(1, $session->{data}->{_session_id});
+ $self->{materialize_sth}->bind_param(1, $session->{data}->{_session_id}, DBI::SQL_VARCHAR);
$self->{materialize_sth}->execute;
@@ -110,7 +110,7 @@
DELETE FROM sessions WHERE id = ?});
}
- $self->{remove_sth}->bind_param(1, $session->{data}->{_session_id});
+ $self->{remove_sth}->bind_param(1, $session->{data}->{_session_id}, DBI::SQL_VARCHAR);
$self->{remove_sth}->execute;
$self->{remove_sth}->finish;