ID:               28246
 Updated by:       [EMAIL PROTECTED]
 Reported By:      derrell dot lipman at unwireduniverse dot com
-Status:           Open
+Status:           Closed
 Bug Type:         SQLite related
 Operating System: Linux 2.4
 PHP Version:      5.0.0RC2
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2004-05-01 21:59:42] derrell dot lipman at unwireduniverse dot com

Description:
------------
There is no way to ascertain whether an ATTACH command worked, as
sqlite_query() and sqlite_unbuffered_query() return FALSE whether it
worked or not.

HERE'S THE FIX:
Upgrading the embedded sqlite from 2.8.11 to 2.8.13 solved this problem
(as well as correcting the 2.8.11 bugs, of course).


Reproduce code:
---------------
<?php
/*
 * We assume that /tmp/test1.db and /tmp/test2.db exist and have the
following
 * schema and data:
 *
 * test1.db:
 *   CREATE TABLE t1 (i INTEGER PRIMARY KEY, t TEXT);
 *   INSERT INTO t1 VALUES (23, 'hello');
 *
 * test2.db:
 *   CREATE TABLE t2 (j INTEGER PRIMARY KEY, t TEXT);
 *   INSERT INTO t2 VALUES (42, 'world');
 *
 */

if (($dbConn = sqlite_open("/tmp/test1.db", 0666)) === false)
{
    echo "open test1.db failed<p>";
    exit;
}

if (($dbRC =
     sqlite_query($dbConn, "ATTACH '/tmp/test2.db' AS test_db;")) ===
false)
{
    echo "This should have returned TRUE, but returned FALSE.  See, it
can get data from t2...<br>";

    if (! $dbRC = sqlite_query($dbConn, "SELECT j, t FROM t2;"))
    {
        echo "Could not retrieve data from t2<br>";
    }
    else
    {
        while ($row = @sqlite_fetch_array($dbRC, SQLITE_ASSOC))
        {
            echo "Got j = " . $row["j"] . ", t = " . $row["t"] .
"<br>";
        }
    }
    exit;
}

echo "ATTACH returned what it should have (this doesn't happen)<br>";
exit;

?>


Expected result:
----------------
TRUE

Actual result:
--------------
FALSE


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=28246&edit=1

Reply via email to