php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53649 mysql_query with "load data" unable to save result set
Submitted: 2011-01-04 16:24 UTC Modified: 2011-01-07 15:19 UTC
From: jeremy dot archuleta at gmail dot com Assigned: mysql (profile)
Status: Duplicate Package: MySQL related
PHP Version: 5.3.4 OS: Mac OS
Private report: No CVE-ID: None
 [2011-01-04 16:24 UTC] jeremy dot archuleta at gmail dot com
Description:
------------
I believe that using mysql_query() with "load data" should always be a 
TRUE/FALSE return value. However, if a mysql_query() call that returns a result 
set is performed *before* the "load data" query, then there is a warning stating 
that the result set can not be saved.

In short:
Warning:
 mysql_query("SELECT ..."); // result set *before*
 mysql_query("LOAD DATA ..."); // warning

Works:
 mysql_query("LOAD DATA ..."); // works
 mysql_query("SELECT ..."); // result set *after*

Works:
 mysql_query("UPDATE ..."); // *no* result set
 mysql_query("LOAD DATA ..."); // works

Works and Warning:
 mysql_query("LOAD DATA ..."); // works
 mysql_query("SELECT ..."); // result set *after*
 mysql_query("LOAD DATA ..."); // warning


MacOS 10.5.8
$ uname -a
Darwin clark-kent-2.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 
PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386

Using PHP from macports
$ php --version
PHP 5.3.3 (cli) (built: Oct 25 2010 17:21:53) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

$ php -i
phpinfo()
PHP Version => 5.3.3

System => Darwin clark-kent-2.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 
15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386
Build Date => Oct 25 2010 17:19:57
Configure Command =>  './configure'  '--prefix=/opt/local' '--
mandir=/opt/local/share/man' '--infodir=/opt/local/share/info' '--with-config-
file-path=/opt/local/etc/php5' '--with-config-file-scan-
dir=/opt/local/var/db/php5' '--disable-all' '--enable-bcmath' '--enable-ctype' 
'--enable-dom' '--enable-fileinfo' '--enable-filter' '--enable-hash' '--enable-
json' '--enable-libxml' '--enable-pdo' '--enable-phar' '--enable-session' '--
enable-simplexml' '--enable-tokenizer' '--enable-xml' '--enable-xmlreader' '--
enable-xmlwriter' '--with-bz2=/opt/local' '--with-mhash=/opt/local' '--with-
pcre-regex=/opt/local' '--with-readline=/opt/local' '--with-libxml-
dir=/opt/local' '--with-zlib=/opt/local' '--disable-cgi' '--with-
apxs2=/opt/local/apache2/bin/apxs' '--with-pear=/opt/local/lib/php'


Using MySQL from macports
$ mysql --version
mysql  Ver 14.14 Distrib 5.1.51, for apple-darwin9.8.0 (i386) using readline 6.1



Test script:
---------------
<?php
error_reporting(E_ALL | E_STRICT);
$sql = "LOAD DATA LOCAL INFILE '/tmp/a.out' INTO TABLE tmp (value)";
$db = mysql_connect('localhost', 'root', 'password');
mysql_select_db('some_database');

// "load data" *before* another query will work
// (this will return TRUE)
print ("This works\n");
$works = mysql_query($sql, $db);

print ("This also works\n");
$also_works = mysql_query("SELECT * FROM tmp", $db);

// "load data" *after* a query produces warning about not saving result set
// (should return TRUE/FALSE I believe)
print ("This fails with warning\n");
$fails_with_warning = mysql_query($sql, $db);
?>

Expected result:
----------------
This works
This also works
This fails with warning

Actual result:
--------------
This works
This also works
This fails with warning
Warning: mysql_query(): Unable to save result set in tmp.php on line 18


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-05 20:49 UTC] jeremy dot archuleta at gmail dot com
Bug is also reported in MySQLi package: http://bugs.php.net/bug.php?id=53503

And reported to be fixed in PHP 5.3.5
 [2011-01-06 15:35 UTC] uw@php.net
-Assigned To: +Assigned To: mysql
 [2011-01-07 15:19 UTC] andrey@php.net
-Status: Assigned +Status: Duplicate
 [2011-01-07 15:19 UTC] andrey@php.net
Duplicate of 53503, because of a bug in mysqlnd. No need for a change in ext/mysql
 [2013-05-07 11:55 UTC] MichelHelms at gmail dot com
Bug still available here in PHP 5.3.5.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC