Bug #90870 REGEXP_REPLACE truncate UPDATE
Submitted: 15 May 2018 12:23 Modified: 7 Jun 2018 13:46
Reporter: William Chiquito Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.0.11 OS:Any
Assigned to: CPU Architecture:Any
Tags: REGEXP_REPLACE, UPDATE

[15 May 2018 12:23] William Chiquito
Description:
REGEXP_REPLACE function truncates the result when performing an UPDATE.

How to repeat:
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.11    |
+-----------+
1 row in set (0.00 sec)

mysql> DROP TABLE IF EXISTS `test`;
Query OK, 0 rows affected (0.42 sec)

mysql> CREATE TABLE IF NOT EXISTS `test` (
    ->   `field` CHAR(6)
    -> );
Query OK, 0 rows affected (0.56 sec)

mysql> INSERT INTO `test` (`field`)
    -> VALUES ('567890');
Query OK, 1 row affected (0.08 sec)

mysql> SELECT REGEXP_REPLACE(`field`, '[7]', 'z')
    -> FROM `test`;
+-------------------------------------+
| REGEXP_REPLACE(`field`, '[7]', 'z') |
+-------------------------------------+
| 56z890                              |
+-------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT `field`
    -> FROM `test`;
+--------+
| field  |
+--------+
| 567890 |
+--------+
1 row in set (0.00 sec)

mysql> UPDATE `test`
    -> SET `field` = REGEXP_REPLACE(`field`, '[7]', 'z');
Query OK, 1 row affected (0.07 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> SELECT `field`
    -> FROM `test`;
+-------+
| field |
+-------+
| 56    |
+-------+
1 row in set (0.11 sec)

See Stack Overflow question: mysql regexp_replace with update - https://stackoverflow.com/questions/50309333/mysql-regexp-replace-with-update
[15 May 2018 12:38] MySQL Verification Team
Hello William,

Thank you for the report!

Thanks,
Umesh
[7 Jun 2018 13:46] Paul DuBois
Posted by developer:
 
Fixed in 8.0.12.

The REGEXP_REPLACE() function truncated its result when used in an
UPDATE statement.