YoWuwuuuw commented on code in PR #7219: URL: https://github.com/apache/incubator-seata/pull/7219#discussion_r1994904637
########## sqlparser/seata-sqlparser-druid/src/main/java/org/apache/seata/sqlparser/druid/sqlserver/SqlServerOperateRecognizerHolder.java: ########## @@ -55,23 +57,29 @@ public SQLRecognizer getUpdateRecognizer(String sql, SQLStatement ast) { @Override public SQLRecognizer getSelectForUpdateRecognizer(String sql, SQLStatement ast) { - List<SQLHint> hints = ((SQLSelectStatement) ast).getSelect().getFirstQueryBlock().getFrom().getHints(); - if (CollectionUtils.isNotEmpty(hints)) { - List<String> hintsTexts = hints - .stream() - .map(hint -> { - if (hint instanceof SQLExprHint) { - SQLExpr expr = ((SQLExprHint) hint).getExpr(); - return expr instanceof SQLIdentifierExpr ? ((SQLIdentifierExpr) expr).getName() : ""; - } else if (hint instanceof SQLCommentHint) { - return ((SQLCommentHint) hint).getText(); - } - return ""; - }).collect(Collectors.toList()); - if (hintsTexts.contains("UPDLOCK")) { - return new SqlServerSelectForUpdateRecognizer(sql, ast); + SQLTableSource tableSource = ((SQLSelectStatement) ast).getSelect().getFirstQueryBlock().getFrom(); + + if (tableSource instanceof SQLSubqueryTableSource) { + return new SqlServerSelectForUpdateRecognizer(sql, ast); + } else { + List<SQLHint> hints = tableSource.getHints(); + if (CollectionUtils.isNotEmpty(hints)) { + List<String> hintsTexts = hints + .stream() + .map(hint -> { + if (hint instanceof SQLExprHint) { + SQLExpr expr = ((SQLExprHint) hint).getExpr(); + return expr instanceof SQLIdentifierExpr ? ((SQLIdentifierExpr) expr).getName() : ""; + } else if (hint instanceof SQLCommentHint) { + return ((SQLCommentHint) hint).getText(); + } + return ""; + }).collect(Collectors.toList()); + if (hintsTexts.contains("UPDLOCK")) { + return new SqlServerSelectForUpdateRecognizer(sql, ast); + } } + return null; } Review Comment: Yes, it was an unwarranted mistake, I corrected it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For additional commands, e-mail: notifications-h...@seata.apache.org