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
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package com.alibaba.polardbx.server.handler.privileges.polar;

import com.alibaba.polardbx.CobarServer;
import com.alibaba.polardbx.druid.sql.ast.SQLExpr;
import com.alibaba.polardbx.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.polardbx.druid.sql.parser.SQLParserFeature;
import com.alibaba.polardbx.server.ServerConnection;
import com.alibaba.polardbx.druid.sql.ast.expr.SQLCharExpr;
Expand All @@ -26,8 +28,6 @@
import com.alibaba.polardbx.druid.sql.dialect.mysql.ast.expr.MySqlUserName;
import com.alibaba.polardbx.druid.sql.parser.ByteString;
import com.alibaba.polardbx.common.audit.AuditAction;
import com.alibaba.polardbx.common.exception.TddlRuntimeException;
import com.alibaba.polardbx.common.exception.code.ErrorCode;
import com.alibaba.polardbx.common.privilege.UserPasswdChecker;
import com.alibaba.polardbx.common.utils.GeneralUtil;
import com.alibaba.polardbx.common.utils.logger.Logger;
Expand Down Expand Up @@ -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

MySqlUserName userName;
if (target instanceof MySqlUserName) {
userName = (MySqlUserName) target;
} else {
userName = MySqlUserName.fromIdentifier((SQLIdentifierExpr) target);
}
String password = "";

if (assignItem.getValue() instanceof SQLCharExpr) {
Expand Down