List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:February 2 2000 5:59pm
Subject:Re: UPDATE Bug ???
View as plain text  
At 6:07 PM +0100 02-02-2000, Tobias Wagener wrote:
>Hello,
>
>I want to use the following statement:
>   UPDATE <table> SET <field> = <field> + 1 WHERE <field>
> >= 1000;
>
>The Table looks like this:
>CREATE <table> (
>   <field>        INT(11)  DEFAULT '0' NOT NULL,
>   <field2>....
>   <field3>... ,
>   KEY <field> ( <field> )
>);
>
>Now happens a strange thing. Sometimes this Statment is working and other
>times it's not working.
>
>When it does not work, the mysqld count's every row above 1000 in an endless
>loop up, until I kill the process.
>
>Does anybody know this problem, or does anybody has a solution?

Solution 1:

Change your WHERE clause to: WHERE <field>+0 >= 1000

this will prevent the index on field from being used, which is the source
of the problem

Solution 2:

Upgrade to MySQL 3.23.2 or newer, in which this problem is fixed.

-- 
Paul DuBois, paul@stripped
Thread
UPDATE Bug ???Tobias Wagener2 Feb
  • Re: UPDATE Bug ???sasha2 Feb
  • Re: UPDATE Bug ???Paul DuBois2 Feb