Skip to content

[BugFix]Fix unclear error messages when an unsupported regex type is … #57904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wuyanxing
Copy link
Contributor

@wuyanxing wuyanxing commented Apr 11, 2025

…used.

Why I'm doing:

select 'a' RLIKE '([A-Za-z0-9]+[\\u4e00-\\u9fa5]{2}[A-Za-z0-9]+)';
before:
ERROR 1064 (HY000): error parsing regexp: invalid escape sequence: \u
after fix:
ERROR 1064 (HY000): Getting analyzing error from line 1, column 11 to line 1, column 17. Detail message: Invalid regular expression in ''a' REGEXP '([A-Za-z0-9]+[\u4e00-\u9fa5]{2}[A-Za-z0-9]+)''.

What I'm doing:

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.5
    • 3.4
    • 3.3
    • 3.2
    • 3.1

@wuyanxing wuyanxing requested a review from a team as a code owner April 11, 2025 01:56
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


wuyanxing seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@stephen-shelby
Copy link
Contributor

I can't reproduce your case in main branch. And I can see the exact error message. Can you give some other examples?

@wuyanxing
Copy link
Contributor Author

wuyanxing commented Apr 11, 2025

I can't reproduce your case in main branch. And I can see the exact error message. Can you give some other examples?

the Exception is :
com.google.re2j.PatternSyntaxException: error parsing regexp: invalid escape sequence: \u
at com.google.re2j.Parser.parseEscape(Parser.java:1439) ~[re2j-1.1.jar:?]
at com.google.re2j.Parser.parseClassChar(Parser.java:1455) ~[re2j-1.1.jar:?]
at com.google.re2j.Parser.parseClass(Parser.java:1664) ~[re2j-1.1.jar:?]
at com.google.re2j.Parser.parseInternal(Parser.java:870) ~[re2j-1.1.jar:?]
at com.google.re2j.Parser.parse(Parser.java:802) ~[re2j-1.1.jar:?]
at com.google.re2j.RE2.compileImpl(RE2.java:183) ~[re2j-1.1.jar:?]
at com.google.re2j.Pattern.compile(Pattern.java:136) ~[re2j-1.1.jar:?]
at com.google.re2j.Pattern.compile(Pattern.java:96) ~[re2j-1.1.jar:?]

PatternSyntaxException is java.util.regex.PatternSyntaxException,but Pattern is com.google.re2j.Pattern.
I updated the code to throw com.google.re2j.PatternSyntaxException instead of java.util.regex.PatternSyntaxException, to ensure consistency with the RE2J regex engine being used.

Copy link

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[FE Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@stephen-shelby
Copy link
Contributor

select 'a' RLIKE '([A-Za-z0-9]+[\u4e00-\u9fa5]{2}[A-Za-z0-9]+)';

I mean I can't reproduce your case in main branch.

mysql> select 'a' RLIKE '([A-Za-z0-9]+[\u4e00-\u9fa5]{2}[A-Za-z0-9]+)';
+---------------------------------------------------------+
| 'a' REGEXP '([A-Za-z0-9]+[u4e00-u9fa5]{2}[A-Za-z0-9]+)' |
+---------------------------------------------------------+
|                                                       0 |
+---------------------------------------------------------+

could your test it with main branch?

@wuyanxing
Copy link
Contributor Author

wuyanxing commented Apr 11, 2025

select 'a' RLIKE '([A-Za-z0-9]+[\u4e00-\u9fa5]{2}[A-Za-z0-9]+)';

I mean I can't reproduce your case in main branch.

mysql> select 'a' RLIKE '([A-Za-z0-9]+[\u4e00-\u9fa5]{2}[A-Za-z0-9]+)';
+---------------------------------------------------------+
| 'a' REGEXP '([A-Za-z0-9]+[u4e00-u9fa5]{2}[A-Za-z0-9]+)' |
+---------------------------------------------------------+
|                                                       0 |
+---------------------------------------------------------+

could your test it with main branch?

sry, I wrote the wrong SQL,try the one below instead.
select 'a' RLIKE '([A-Za-z0-9]+[\\u4e00-\\u9fa5]{2}[A-Za-z0-9]+)';

@github-actions github-actions bot added the 3.5 label Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants