I have a table with a column that contains a regular expression used to match rows from other tables. I then need to query like this
SELECT st.id
FROM some_table st
WHERE '1234' REGEXP st.regexp;
As long as the column regexp contains a valid expression or null the query will run fine. But, if you have an invalid regexp in any of the rows, the entire query fails with error 3685. It is then virtually impossible to find where the error is, as there is no function for validating the regular expression. Something like VALID_REGEXP() would solve it like
SELECT *
FROM some_table st
WHERE NOT VALID_REGEXP(st.regexp);
I am validating on INSERT/UPDATE by doing
SELECT '' REGEXP 'regexp-to-test'
But, if an invalid expression find its way in anyway, there is no way to find it in several millions of rows, as you will have to test them one-by-one and looking for error 3685.
Any hint on how to, in one query, find all rows with invalid regular expressions in their regexp column?
SELECT '' REGEXP <expression>
will let me know if is valid, as it will return a row while it will return with error 3685 if it fails. But, testing row-by-row is not an options as there is a huge amount of rows to test.