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

Fix (issuse: #104) : Cast error when 'set password' #112

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

joeCarf
Copy link
Contributor

@joeCarf joeCarf commented Dec 2, 2022

Problems solved in this PR

issuse: #104

Changes proposed in this PR

Tests

  • Unit test
  • DML_DDL test

Release note

None

@joeCarf joeCarf changed the title Fix : Cast error when 'set password' Fix (issuse: #104) : Cast error when 'set password' Dec 8, 2022
@joeCarf
Copy link
Contributor Author

joeCarf commented Jan 9, 2023

@Oldbread3 PTAL:)

@Oldbread3
Copy link
Collaborator

Will this fix cause exception for statement like set password for yejr@'%' = password('xx'); ?

@Oldbread3
Copy link
Collaborator

Amend use name at code path below might be the proper way to fix this issue.

@joeCarf
Copy link
Contributor Author

joeCarf commented Jan 11, 2023

Amend use name at code path below might be the proper way to fix this issue.

when using statement set password for yejr@'%' = password('xx');, variable user is a MySqlUserName object, while using set password for yejr = password('xx'); statement, user is a SQLIdentifierExpr object.

should i just cast SQLIdentifierExpr to MySqlUserName in MysqlStatementParser.class (code path above) or or use if sentense just in code path below ?

@@ -74,7 +74,13 @@ private static List<PolarAccountInfo> getGrantees(ByteString sql, PolarAccountIn
SQLSetStatement statement =
(SQLSetStatement) FastsqlUtils.parseSql(sql, SQLParserFeature.IgnoreNameQuotes).get(0);
SQLAssignItem assignItem = statement.getItems().get(0);
MySqlUserName userName = (MySqlUserName) assignItem.getTarget();
SQLExpr target = assignItem.getTarget();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be a more safe way to fix this issue, cause it did't change parseSet() function in MysqlStatementParser, and won't affect other using scenario. PTAL:) @Oldbread3

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -74,7 +74,13 @@ private static List<PolarAccountInfo> getGrantees(ByteString sql, PolarAccountIn
SQLSetStatement statement =
(SQLSetStatement) FastsqlUtils.parseSql(sql, SQLParserFeature.IgnoreNameQuotes).get(0);
SQLAssignItem assignItem = statement.getItems().get(0);
MySqlUserName userName = (MySqlUserName) assignItem.getTarget();
SQLExpr target = assignItem.getTarget();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@joeCarf
Copy link
Contributor Author

joeCarf commented Mar 9, 2023

这个pr还不能合入嘛 @Oldbread3 @ZSYTY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants