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

Support Mysql CALL sql with mysql prefix #31133

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -163,7 +163,7 @@ querySpecification
;

call
: CALL identifier (LP_ (expr (COMMA_ expr)*)? RP_)?
: CALL (owner DOT_)? identifier (LP_ (expr (COMMA_ expr)*)? RP_)?
;

doStatement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ public final class MySQLDMLStatementVisitor extends MySQLStatementVisitor implem
public ASTNode visitCall(final CallContext ctx) {
List<ExpressionSegment> params = new ArrayList<>();
ctx.expr().forEach(each -> params.add((ExpressionSegment) visit(each)));
return new MySQLCallStatement(ctx.identifier().getText(), params);
String procedureName = ctx.identifier().getText();
if (null != ctx.owner()) {
procedureName = ctx.owner().getText().concat(".").concat(procedureName);
}
return new MySQLCallStatement(procedureName, params);
}

@Override
Expand Down
10 changes: 10 additions & 0 deletions test/it/parser/src/main/resources/case/dml/call.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,14 @@
<common-expression literal-text="1.0/0.1" start-index="7" stop-index="13" />
</procedure-parameter>
</call>

<call sql-case-id="call_with_mysql_firewall_group_enlist">
<procedure-name name="mysql.sp_firewall_group_enlist"/>
<procedure-parameter>
<literal-expression value="fwgrp" start-index="36" stop-index="42"/>
</procedure-parameter>
<procedure-parameter>
<literal-expression value="member2@localhost" start-index="45" stop-index="63"/>
</procedure-parameter>
</call>
</sql-parser-test-cases>
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
<sql-case id="call_with_mixed_notation_with_apos" value="CALL p(10, b =&gt; &apos;Hello&apos;);" db-types="PostgreSQL" />
<sql-case id="call_with_named_notation_with_apos" value="CALL p(b =&gt; &apos;Hello&apos;, a =&gt; 10);" db-types="PostgreSQL" />
<sql-case id="call_with_positional_notation_with_expression" value="CALL p(1.0/0.1);" db-types="PostgreSQL" />
<sql-case id="call_with_mysql_firewall_group_enlist" value="CALL mysql.sp_firewall_group_enlist('fwgrp', 'member2@localhost')" db-types="MySQL"/>
</sql-cases>