Bug #96754 regexp_replace bug with derived tables
Submitted: 4 Sep 2019 19:20 Modified: 4 Sep 2019 21:13
Reporter: Matt Wegrzyn Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.0.13 OS:Windows
Assigned to: CPU Architecture:Any
Tags: regex, REGEXP, regular expressions

[4 Sep 2019 19:20] Matt Wegrzyn
Description:
regexp_replace does not work when used in derived tables.

How to repeat:
Simply run the following query:

SELECT test_col from (SELECT regexp_replace('http://test.com';, '(http://)';, '') test_col) t1

Returns blank value. Should instead return 'test.com' value.
[4 Sep 2019 21:10] MySQL Verification Team
Thank you for the bug report. I couldn't repeat with current released version:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.17 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use test
Database changed
mysql> SELECT test_col from (SELECT regexp_replace('http://test.com';, '(http://)';, '') test_col) t1;
+----------+
| test_col |
+----------+
| test.com |
+----------+
1 row in set (0.00 sec)

mysql>
[4 Sep 2019 21:13] Matt Wegrzyn
It seems this may have been resolved in recent versions. But I can confirm it is an issue in 8.0.13 in our production database.

Works fine for me on 8.0.16 on local though.