[MDEV-6027] RLIKE: "." no longer matching new line Created: 2014-04-05  Updated: 2014-04-23  Resolved: 2014-04-23

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.10
Fix Version/s: 10.0.11

Type: Bug Priority: Critical
Reporter: M Kellogg Assignee: Alexander Barkov
Resolution: Fixed Votes: 1
Labels: None
Environment:

Windows 8, Windows Server 2012 R2, maybe others



 Description   

In 5.5.36, RLIKE and REGEXP work as they always have:

SELECT 
'cat and
 dog' 
RLIKE 'cat.*dog';
=> 1
 
In 10.0.10, 
SELECT 
'cat and
 dog' 
RLIKE 'cat.*dog';
=> 0

I consider this to be a critical issue that would cause queries to not function as expected.



 Comments   
Comment by Elena Stepanova [ 2014-04-05 ]

Apparently the difference was caused by switching to PCRE.

Comment by Elena Stepanova [ 2014-04-06 ]

With PCRE, to have the dot to matchi a new line character, option (?s) should be set:

MariaDB [test]> SELECT  'cat and                              
 dog'  RLIKE '(?s)cat.*dog';
+--------------------------------------+
| 'cat and
 dog'  RLIKE '(?s)cat.*dog' |
+--------------------------------------+
|                                    1 |
+--------------------------------------+
1 row in set (0.00 sec)

See https://mariadb.com/kb/en/pcre-regular-expressions/#option-setting .

It's still not very good that the default behavior changed.

Comment by Jorge Manuel Silva [ 2014-04-07 ]

Maybe that option should be enabled by default, and using (?-s) would disable it.

Comment by Sergei Golubchik [ 2014-04-07 ]

On the other hand, it would be good to be as close to the "normal" pcre behavior as possible, users that know pcre shouldn't need to read mariadb manual to know all mariadb specific pcre quirks.

bar, perhaps we could add, like, @@default_regex_flags variable? This will keep pcre "normal behavior" in mariadb and won't change defaults post-GA, but users of old applications would be able to set 's' flag to be on by default.

Comment by Jorge Manuel Silva [ 2014-04-07 ]

That would be a good idea. I agree.

Comment by Alexander Barkov [ 2014-04-23 ]

Added a new variable @@default_regex_flags.

To make "." match new line, one can add this command into my.cnf:

[mysqld]
default-regex-flags=DOTALL

See here for more details:
https://mariadb.com/kb/en/server-system-variables/#default_regex_flags

Comment by Alexander Barkov [ 2014-04-23 ]

Pushed into 10.0.

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