| Bug #15665 | "USE" statement fails with server-side prepared statements | ||
|---|---|---|---|
| Submitted: | 11 Dec 2005 10:47 | Modified: | 1 Feb 2006 23:42 | 
| Reporter: | Giuseppe Maxia | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connectors: DBD::mysql ( Perl ) | Severity: | S2 (Serious) | 
| Version: | 3.0002_4 | OS: | Linux (Linux) | 
| Assigned to: | Bugs System | CPU Architecture: | Any | 
   [11 Dec 2005 14:22]
   Valeriy Kravchuk        
  Thank you for a problem report. Verified just as described, with 5.0.18-BK (ChangeSet@1.1992, 2005-12-09 00:58:59+03:00): [openxs@Fedora mysql-5.0]$ perl 15665.pl DBD::mysql::VERSION 3.0002_4 mysql_emulated_prepare 1 OK mysql_server_prepare 1 DO: Something wrong while try to prepare query This command is not supported in the prepared statement protocol yet
   [6 Jan 2006 19:47]
   Cory Twibell        
  Also fails for 'Flush Privileges' using MySQL5.0.17-pro-log DBD::mysql 3.0002_4 $dbh->do( q(FLUSH PRIVILEGES) ) or die $dbh->errstr;
   [1 Feb 2006 23:42]
   Patrick Galbraith        
  Thank you for pointing this bug out - fixed! Please get version 3.0002_5
   [2 Mar 2006 22:01]
   Sean Stevens        
  I'm still seeing this problem. It seems to show up when using mysqlhotcopy. I'm running mysql-5.0.18 on Solaris 10 with DBI 1.50 and DBD::mysql 3.0002_5. Any ideas?


Description: When setting mysql_server_prepare=1 in a connection (which is the default in DBD::mysql 3.0002_4), "USE" statements can't be executed, because the prepare statement protocol does not support it. It is not properly a bug, but a feature that breaks compatibility with old code. Since "USE" is such a common statement, something must be done to ensure that old code does not break when using it. How to repeat: #!/usr/bin/perl use strict; use warnings; use DBI; my $dbh_emulated=DBI->connect('dbi:mysql:test;host=localhost' . ';mysql_emulated_prepare=1' . ";mysql_read_default_file=$ENV{HOME}/.my.cnf", undef, undef, {RaiseError => 1, PrintError=>1}) or die "Can't connect: $DBI::errstr\n"; my $dbh_prepared=DBI->connect('dbi:mysql:test;host=localhost' . ";mysql_read_default_file=$ENV{HOME}/.my.cnf", undef, undef, {RaiseError => 1, PrintError=>1}) or die "Can't connect: $DBI::errstr\n"; print "DBD::mysql::VERSION $DBD::mysql::VERSION\n"; print "mysql_emulated_prepare 1 \n"; $dbh_emulated->do(qq{USE test}) and print "OK\n"; print "mysql_server_prepare 1 \n"; $dbh_prepared->do(qq{USE test})and print "OK\n"; __END__ DBD::mysql::VERSION 3.0002_4 mysql_emulated_prepare 1 OK mysql_server_prepare 1 DO: Something wrong while try to prepare query This command is not supported in the prepared statement protocol yet Suggested fix: $dbh->{mysql_emulated_prepare}=1; $dbh->do(qq{USE dbname});