From:
Operating system: Linux
PHP version: 5.3.5
Package: PDO related
Bug Type: Bug
Bug description:MYSQLND + PDO MySQL requires #define MYSQL_OPT_LOCAL_INFILE
Description:
------------
Hi,
On php 5.3.x PDO LOAD DATA LOCAL INFILE support seems broken. Running the
code below issues a warning:
Warning: PDOStatement::execute(): LOAD DATA LOCAL INFILE forbidden in
/home/tamas/percona/load3.php on line 17
This is coming from mysqlnd when CLIENT_LOCAL_FILES option is disabled.
Looking at the trace file, PDO doesn't call mysql_options
(set_client_option) to enable local infile support. I tracked down this is
caused by the following ifdef in ext/pdo_mysql/mysql_driver.c:
#ifdef MYSQL_OPT_LOCAL_INFILE
if (mysql_options(H->server, MYSQL_OPT_LOCAL_INFILE, (const char
*)&local_infile)) {
pdo_mysql_error(dbh);
goto cleanup;
}
#endif
MYSQL_OPT_LOCAL_INFILE is undefined hence the whole block which would
enable local infile support is disabled. When the ifdef/endif line is
commented out everything works. I also tested with mysqli, that is
unaffected and works as expected.
And a related bug to this one: http://bugs.php.net/46964
Configure Command => './configure'
'--prefix=/home/tamas/percona/php53dbg' '--disable-all'
'--with-pdo-mysql=mysqlnd' '--enable-debug' '--enable-pdo'
'--with-mysqli=mysqlnd' '--with-mysql=mysqlnd'
Thanks,
Tamas
Test script:
---------------
define('MYSQL_ALL_DSN','mysql:host=10.8.0.1;dbname=c');
define('MYSQL_ALL_USER','a');
define('MYSQL_ALL_PASS','b');
$sql = 'LOAD DATA LOCAL INFILE \'/home/tamas/percona/testLoad.data\' INTO
TABLE mail_message '.
'FIELDS TERMINATED BY \',\' OPTIONALLY ENCLOSED BY \'"\' LINES
TERMINATED BY \'\n\' '.
'(priority, user_id, `to`, template_id, data, custom_text_hash,
spam)';
$con = new PDO(MYSQL_ALL_DSN, MYSQL_ALL_USER, MYSQL_ALL_PASS,
array(
PDO::MYSQL_ATTR_LOCAL_INFILE => 1,
));
$stmt = $con->prepare($sql);
$stmt->execute();
--
Edit bug report at http://bugs.php.net/bug.php?id=54158&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=54158&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=54158&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=54158&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=54158&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=54158&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=54158&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=54158&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=54158&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=54158&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=54158&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=54158&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=54158&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=54158&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=54158&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54158&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54158&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=54158&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=54158&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=54158&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=54158&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=54158&r=mysqlcfg