[MDEV-10070] testing a regex ends up in changing to non existent database Created: 2016-05-14  Updated: 2017-02-26  Resolved: 2017-02-26

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 5.5, 10.0, 10.1, 10.2
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Georg Richter Assignee: Oleksandr Byelkin
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

Testing a select regexp_replace ends up in some strange behavior:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 25
Server version: 10.2.0-MariaDB Source distribution
 
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]> select regexp_replace("/* test */ LOAD /* infile load */ DATA LOCAL INFILE /* 'foo' */ 'foo.txt'', "/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/", "");
ERROR: Unknown command '\*'.
ERROR 1049 (42000): Unknown database 'n]|(*+([^*/]|[rn])))**+/",'
unknown [n]|(*+([^*/]|[rn])))**+/",]> select 1;
No connection. Trying to reconnect...
ERROR 1049 (42000): Unknown database 'n]|(*+([^*/]|[rn])))**+/",'
ERROR: Can't connect to the server
 
unknown [n]|(*+([^*/]|[rn])))**+/",]> 



 Comments   
Comment by Oleksandr Byelkin [ 2016-05-14 ]

I think because of forgotten " rest of the string trying to interpret mysql client.

mysqltest is more conservative and just point on junk at the end of the line. I tried to fix it and got a bit different errors connected to the regexp:

select regexp_replace("/* test */ LOAD /* infile load */ DATA LOCAL INFILE /* 'foo' */ 'foo.txt''", "/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/", "");
main.test                                [ fail ]
        Test ended at 2016-05-14 14:21:50
 
CURRENT_TEST: main.test
mysqltest: At line 1: query 'select regexp_replace("/* test */ LOAD /* infile load */ DATA LOCAL INFILE /* 'foo' */ 'foo.txt''", "/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/", "")' failed: 1139: Got error 'nothing to repeat at offset 14' from regexp

Generated at Thu Feb 08 07:39:26 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.