Re: PHP5 RC3
| From: | Derrell dot Lipman at UnwiredUniverse dot com | Date: | Mon, 21 Jun 2004 16:06:27 +0000 |
| Subject: | Re: PHP5 RC3 | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-10692@lists.php.net to get a copy of this message | ||
Derrell.Lipman@UnwiredUniverse.com writes:
> Steph <steph@zend.com> writes:
>
>> Derrell: which system are you running, and do you have a short test script
>> for the ATTACH command please?
>
> I will generate one and post it in a few hours.
I had to go watch the launch and recovery of SpaceShipOne! Success! Awesome!
Here's a quick and dirty test program for the ATTACH problem. It fails on
vanilla RC3 but succeeds on my RC2 patched with sqlite 2.8.13. Later today,
I'll apply 2.8.14 to HEAD and provide a patch.
<?php
function Query($dbConn, $query)
{
/* Issue the query. */
if (! ($dbRC =
@sqlite_unbuffered_query($dbConn, $query)))
{
$err = sqlite_last_error($dbConn);
echo "FAIL:<br>$query<br>" . sqlite_error_string($err) .
"<p>";
exit;
}
return $dbRC;
}
function OpenDB($name)
{
/* Open the first test database */
$dbConn = sqlite_open("$name", 0666);
if (! $dbConn)
{
echo "Could not open/create $name<br>";
exit;
}
return $dbConn;
}
function CreateDB($name)
{
$dbConn = OpenDB($name);
/* See if this was a pre-existing database */
$query =
"SELECT 1 " .
" FROM sqlite_master " .
" WHERE type = 'table' " .
" AND name = 'test';";
$dbRC = Query($dbConn, $query);
/* Is the table already there? */
if (! ($row = @sqlite_fetch_array($dbRC, SQLITE_ASSOC)))
{
/* Nope. Create it. */
$query =
"CREATE TABLE test (" .
" i INTEGER PRIMARY KEY, " .
" t TEXT);";
Query($dbConn, $query);
for ($i = 1; $i <= 3; $i++)
{
$query =
"INSERT INTO test " .
" (i, t) " .
" VALUES " .
" ($i, 'Row number $i');";
Query($dbConn, $query);
}
}
sqlite_close($dbConn);
}
/* Create the two databases (if they don't already exist) */
CreateDB('/tmp/t1');
CreateDB('/tmp/t2');
/* Open the first database */
$dbConn = OpenDB('/tmp/t1');
/* Attach the second database */
$query =
"ATTACH '/tmp/t2' AS table2;";
Query($dbConn, $query);
/* Prove we attached */
$query =
"SELECT " .
" t1.i AS t1i, " .
" t1.t AS t1t, " .
" t2.i AS t2i, " .
" t2.t AS t2t " .
" FROM main.test t1 " .
" LEFT OUTER JOIN table2.test t2;";
$dbRC = Query($dbConn, $query);
while ($row = sqlite_fetch_array($dbRC, SQLITE_ASSOC))
{
echo
"t1i=" . $row["t1i"] . " " .
"t1t=" . $row["t1t"] . " " .
"t2i=" . $row["t2i"] . " " .
"t2t=" . $row["t2t"] . "<br>";
}
exit;