Bug #8942 SUBSTRING_INDEX in UPDATE causes internal loop
Submitted: 4 Mar 2005 10:13 Modified: 17 Mar 2005 17:24
Reporter: Jigal van Hemert
Status: Closed
Category:Server Severity:S3 (Non-critical)
Version:4.0.23 / 4.1.8 / 4.1.10 OS:Any (*)
Assigned to: Ramil Kalimullin Target Version:

[4 Mar 2005 10:13] Jigal van Hemert
Description:
UPDATE query with SUBSTRING_INDEX causes internal loop repeating the update  until the
value reaches the next power of 10. The affected rows count reflects the number of times
the update of the single row was repeated.
value   affected rows   new value
      1                9              10
    10               90             100
   100             900           1000
      4                 6               10
    587            413            1000

When query is repeated without other actions in between, it sometimes works correctly.

Bug works with bot MyISAM and InnoDB tables

How to repeat:
Table structure:
==========

CREATE TABLE `param_str` (
  `id` int(11) NOT NULL default '0',
  `name` varchar(32) NOT NULL default '',
  `value` varchar(255) default NULL,
  `match` varchar(255) default NULL,
  `match2` varchar(255) default NULL,
  `weight` tinyint(4) default NULL,
  KEY `id-name-value-match-match2`
(`id`,`name`,`value`(20),`match`(20),`match2`(20))
) TYPE=InnoDB;

INSERT INTO `param_str` VALUES (0, 'prf_hits', '1', NULL, NULL, NULL);

Query:
====

UPDATE `param_str`
SET `value` =
   SUBSTRING_INDEX(
    `value`,
    ';',
    1
   ) + 1
 WHERE
 `id`=0  AND
 `name`='prf_hits'
[17 Mar 2005 7:25] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/23127
[17 Mar 2005 7:37] Ramil Kalimullin
fixed in 4.0.25
[17 Mar 2005 17:24] Paul DuBois
Noted in 4.0.25 changelog.