Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-6027

RLIKE: "." no longer matching new line

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 10.0.10
    • Fix Version/s: 10.0.11
    • Component/s: None
    • 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.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            elenst Elena Stepanova added a comment - - edited

            Apparently the difference was caused by switching to PCRE.

            Show
            elenst Elena Stepanova added a comment - - edited Apparently the difference was caused by switching to PCRE.
            Hide
            elenst Elena Stepanova added a comment - - edited

            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.

            Show
            elenst Elena Stepanova added a comment - - edited 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.
            Hide
            Jorge Silva Jorge Manuel Silva added a comment -

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

            Show
            Jorge Silva Jorge Manuel Silva added a comment - Maybe that option should be enabled by default, and using (?-s) would disable it.
            Hide
            serg Sergei Golubchik added a comment -

            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.

            Alexander Barkov, 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.

            Show
            serg Sergei Golubchik added a comment - 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. Alexander Barkov , 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.
            Hide
            Jorge Silva Jorge Manuel Silva added a comment -

            That would be a good idea. I agree.

            Show
            Jorge Silva Jorge Manuel Silva added a comment - That would be a good idea. I agree.
            Hide
            bar Alexander Barkov added a comment -

            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

            Show
            bar Alexander Barkov added a comment - 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
            Hide
            bar Alexander Barkov added a comment -

            Pushed into 10.0.

            Show
            bar Alexander Barkov added a comment - Pushed into 10.0.

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                rebelde M Kellogg
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: