Skip to content
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

VIEW parsing: accept DEFINER with ` and spaces #571

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@mlocati
Copy link

mlocati commented Mar 14, 2019

When parsing VIEW codes, we may have that DEFINER values may contain spaces, for example:

DEFINER=`skip-grants user`@skip-grants host`

In this example, `skip-grants user`@`skip-grants host` does not match the \S+ regular expression, and HeidiSQL crashes with this error message:

Regular expression did not match the VIEW code in ParseViewStructure()

So, what about accepting also values with spaces enclosed in backticks?

This PR changes the \S+ chunk to this one:

\S+|`[^`]*`(?:@(?:\S+|`[^`]*`)?)?

which means:

  • \S+ → any non-whitespace characters
  • | → or
  • `[^`]*` → a backtick, followed by any number of non backticks, then a backtick
  • (...)? → optionally followed by (?: → without capturing it):
    • @ → the at character
    • (...)? → optionally followed by (?: → without capturing it):
      • \S+ → any non-whitespace characters
      • | → or
      • `[^`]*` → a backtick, followed by any number of non backticks, then a backtick
@ansgarbecker

This comment has been minimized.

Copy link
Collaborator

ansgarbecker commented Mar 14, 2019

This does not accept duplicated backticks in the name, which was the reason why I introduced \S. A duplicated backtick in an identifier escapes this backtick for using it as a regular character in the identifier.

@mlocati

This comment has been minimized.

Copy link
Author

mlocati commented Mar 14, 2019

This change is fully backward compatible (\S+ is still in the regex)

@ansgarbecker

This comment has been minimized.

Copy link
Collaborator

ansgarbecker commented Mar 14, 2019

Well it still does not allow a space and a backtick at the same time.

But forget what I said, I made a blame on my code and saw I introduced it back in 2010 in 6c2a100, for other reasons. I only have to escape the quote char and it can be different char than backtick. Going to commit it pretty soon...

@mlocati mlocati deleted the mlocati:parse-view-spaces-in-definer branch Mar 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.