MySQL Forums
Forum List  »  General

HANDLER syntax
Posted by: Bernd Glaser
Date: April 25, 2005 08:08AM

Hello
has anyone gained some experience with the HANDLER syntax (http://dev.mysql.com/doc/mysql/en/handler.html)? I'd like to use it for a specific project but strange things are happening. I've written a little test script in PHP:

$con = mysql_connect(....);
mysql_select_db('world');

mysql_query("HANDLER `country` OPEN");

$rst = mysql_query("HANDLER `country` READ `continent` = ('Europe')");
$row = mysql_fetch_assoc($rst);

while ($row) {

echo $row['Continent'].", ".$row['Name']."<br>";

$rst = mysql_query("HANDLER `country` READ NEXT WHERE (`continent` = 'Europe')");
$row = mysql_fetch_assoc($rst);
}

mysql_query("HANDLER `country` CLOSE");

mysql_close($con);

(This example uses the MySQL sample database 'world', I only added the index 'continent' to the 'country' table. Yes, I know that this would normally be done with a SELECT, this is just a demo, the real thing will be written in C++ and will be much more complex.)

This script works - but only once. When hitting the browser's reload button, only the first record is found, the one that is positioned to outside the loop. All the following HANDLER calls inside the loop that shoud position relative to the current record with the NEXT statement are not found anymore.

Now for the weird part: When I walk away frustrated an come back one or two hours later and hit the reload button again - it works again, all European countries are listed. But again only once. After reloading, the Netherlands are again the only country left in Europe.

Can anyone tell me what evil forces are at work here?

I'm using MySQL server 4.1.8 on a Linux machine and also tried that with WinXP. And b.t.w., this effect does not only happen in the 'world'-database, same thing with any database I've testet it with, no matter if it's MyISAM or InnoDB tables.

Options: ReplyQuote


Subject
Written By
Posted
HANDLER syntax
April 25, 2005 08:08AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.