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

REGEXP_REPLACE 'pcre_exec: null argument passed' from regexp

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Confirmed (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 10.3, 10.4.10, 10.4.11, 10.4
    • Fix Version/s: 10.3, 10.4
    • Component/s: Character Sets, Data types
    • Labels:
      None
    • Environment:
      CentOS 7

      Description

      I am experiencing a bug when updating a field with a REGEX_REPLACE() when the field is a blank string and it is passed through TRIM() first.

      To Replicate:

      CREATE TABLE `test` (
       `input` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
       `output` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
       PRIMARY KEY (`input`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 
      

      INSERT INTO `test` (`input`, `output`) VALUES ('', NULL);
      

      UPDATE `test` SET `output` = REGEXP_REPLACE(TRIM(`input`), '[^a-z]', '');
      

      Expected Result:

      `output` is set to ''

      Actual Result:

      Got error 'pcre_exec: null argument passed' from regexp

      It seems to be something to do with the combination between TRIM() and a field with a blank string as:

      UPDATE `test` SET `output` = REGEXP_REPLACE(`input`, '[^a-z]', '');
      

      no error

      Also:

      UPDATE `test` SET `output` = REGEXP_REPLACE(TRIM(''), '[^a-z]', '');
      

      no error

        Attachments

          Activity

            People

            Assignee:
            bar Alexander Barkov
            Reporter:
            ChrisHSandN Chris Hewett
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated: